From c6d73b0e3246efc824cb98338d4be7ee5bc9f308 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Wed, 19 Nov 2008 23:44:34 +0000 Subject: [PATCH] Now in own repository for remote checkouts --- .gitattributes | 549 +++++ devel/.htaccess | 1 + devel/class_Debug.php | 53 + inc/.htaccess | 1 + inc/classes.php | 63 + inc/classes/.htaccess | 1 + inc/classes/exceptions/.htaccess | 1 + inc/classes/exceptions/actions/.htaccess | 1 + .../actions/class_InvalidActionException.php | 47 + inc/classes/exceptions/auth/.htaccess | 1 + .../auth/class_UserAuthorizationException.php | 46 + inc/classes/exceptions/class_ | 39 + .../exceptions/class_FrameworkException.php | 202 ++ inc/classes/exceptions/compressor/.htaccess | 1 + .../class_MismatchingCompressorsException.php | 51 + inc/classes/exceptions/container/.htaccess | 1 + .../class_ContainerItemIsNoArrayException.php | 46 + .../class_ContainerItemIsNullException.php | 46 + .../class_ContainerMaybeDamagedException.php | 46 + inc/classes/exceptions/controller/.htaccess | 1 + .../class_DefaultControllerException.php | 48 + .../class_InvalidControllerException.php | 50 + inc/classes/exceptions/criteria/.htaccess | 1 + inc/classes/exceptions/crypto/.htaccess | 1 + .../class_EncryptInvalidLengthException.php | 52 + .../crypto/class_EncryptMissingException.php | 48 + inc/classes/exceptions/database/.htaccess | 1 + inc/classes/exceptions/database/class_ | 39 + .../database/class_DatabaseException.php | 39 + .../exceptions/database/general/.htaccess | 1 + .../class_DatabaseUpdateSupportException.php | 45 + .../database/general/class_SqlException.php | 47 + .../exceptions/database/local_file/.htaccess | 1 + .../class_SavePathIsEmptyException.php | 45 + .../class_SavePathIsNoDirectoryException.php | 42 + .../class_SavePathReadProtectedException.php | 42 + .../class_SavePathWriteProtectedException.php | 42 + .../exceptions/database/wrapper/.htaccess | 1 + ...class_WrapperUserNameNotFoundException.php | 49 + inc/classes/exceptions/filter/.htaccess | 1 + .../filter/class_FilterChainException.php | 45 + inc/classes/exceptions/helper/.htaccess | 1 + .../helper/class_FormClosedException.php | 47 + .../helper/class_FormGroupClosedException.php | 46 + .../helper/class_FormOpenedException.php | 47 + ...ass_HelperGroupAlreadyCreatedException.php | 46 + ...elperNoPreviousOpenedSubGroupException.php | 46 + ..._HelperSubGroupAlreadyCreatedException.php | 46 + .../helper/class_InvalidFormNameException.php | 45 + .../helper/class_NoGroupOpenedException.php | 46 + .../class_UserInstanceMissingException.php | 46 + inc/classes/exceptions/io/.htaccess | 1 + .../io/class_DirPointerNotOpenedException.php | 42 + .../io/class_FileNotFoundException.php | 49 + .../class_FilePointerNotOpenedException.php | 42 + .../io/class_FileReadProtectedException.php | 42 + .../io/class_InvalidDataLengthException.php | 47 + ...lass_InvalidDirectoryResourceException.php | 45 + .../io/class_InvalidMD5ChecksumException.php | 47 + .../io/class_PathIsEmptyException.php | 45 + .../io/class_PathIsNoDirectoryException.php | 42 + .../io/class_PathReadProtectedException.php | 42 + inc/classes/exceptions/language/.htaccess | 1 + ...ass_InvalidLanguagePathStringException.php | 46 + .../class_LanguagePathIsEmptyException.php | 45 + ...ass_LanguagePathIsNoDirectoryException.php | 46 + ...ass_LanguagePathReadProtectedException.php | 46 + .../class_MissingFileIoHandlerException.php | 45 + .../class_MissingLanguageHandlerException.php | 45 + inc/classes/exceptions/main/.htaccess | 1 + .../main/class_AssertionException.php | 39 + .../main/class_ClassMismatchException.php | 45 + .../main/class_ClassNotFoundException.php | 51 + .../class_ConfigEntryIsEmptyException.php | 45 + .../class_ConfigEntryNotFoundException.php | 51 + .../class_DimNotFoundInArrayException.php | 50 + .../main/class_EmptyVariableException.php | 46 + .../main/class_ExceptionNotFoundException.php | 48 + .../main/class_FatalErrorException.php | 40 + .../main/class_GetterNotFoundException.php | 48 + .../main/class_InvalidArrayCountException.php | 48 + .../main/class_InvalidCommandException.php | 50 + .../class_InvalidCommandInstanceException.php | 46 + .../main/class_InvalidInterfaceException.php | 46 + .../main/class_InvalidObjectException.php | 45 + .../class_MissingArrayElementsException.php | 57 + ...ingDecimalsThousandsSeperatorException.php | 45 + .../main/class_MissingMethodException.php | 47 + .../main/class_NoArrayCreatedException.php | 48 + .../main/class_NoArrayException.php | 42 + .../main/class_NoObjectException.php | 46 + .../main/class_NullPointerException.php | 45 + ...ss_ResponseHeadersAlreadySentException.php | 45 + .../main/class_VariableIsNotSetException.php | 47 + inc/classes/exceptions/result/.htaccess | 1 + .../class_InvalidDatabaseResultException.php | 46 + .../result/class_ResultUpdateException.php | 45 + inc/classes/exceptions/template/.htaccess | 1 + .../class_BasePathIsEmptyException.php | 45 + .../class_BasePathIsNoDirectoryException.php | 46 + .../class_BasePathReadProtectedException.php | 46 + .../class_InvalidBasePathStringException.php | 46 + .../class_UnexpectedTemplateTypeException.php | 47 + ...ass_UnsupportedTemplateEngineException.php | 44 + .../class_ViewHelperNotFoundException.php | 47 + inc/classes/exceptions/user/.htaccess | 1 + ...class_AccountPasswordMismatchException.php | 45 + .../user/class_UserEmailMissingException.php | 46 + .../class_UserPasswordMismatchException.php | 46 + .../user/class_UsernameMissingException.php | 46 + inc/classes/exceptions/xml/.htaccess | 1 + .../xml/class_InvalidXmlNodeException.php | 53 + .../xml/class_XmlNodeMismatchException.php | 47 + .../xml/class_XmlParserException.php | 47 + inc/classes/interfaces/.htaccess | 1 + inc/classes/interfaces/actions/.htaccess | 1 + .../actions/class_PerformableAction.php | 36 + .../interfaces/actions/commands/.htaccess | 1 + .../actions/commands/class_Commandable.php | 36 + inc/classes/interfaces/application/.htaccess | 1 + .../class_ManageableApplication.php | 99 + inc/classes/interfaces/auth/.htaccess | 1 + .../interfaces/auth/class_Authorizeable.php | 41 + inc/classes/interfaces/cache/.htaccess | 1 + .../interfaces/cache/class_Cacheable.php | 35 + inc/classes/interfaces/captcha/.htaccess | 1 + .../captcha/class_SolveableCaptcha.php | 41 + inc/classes/interfaces/class_ | 28 + .../interfaces/class_FrameworkInterface.php | 37 + inc/classes/interfaces/compressor/.htaccess | 1 + .../compressor/class_Compressor.php | 52 + inc/classes/interfaces/controller/.htaccess | 1 + .../controller/class_Controller.php | 36 + inc/classes/interfaces/criteria/.htaccess | 1 + .../interfaces/criteria/class_Criteria.php | 45 + .../interfaces/criteria/extended/.htaccess | 1 + .../extended/class_LocalSearchCriteria.php | 28 + .../extended/class_LocalUpdateCriteria.php | 28 + .../extended/class_StoreableCriteria.php | 28 + inc/classes/interfaces/crypto/.htaccess | 1 + .../interfaces/crypto/class_Cryptable.php | 55 + inc/classes/interfaces/database/.htaccess | 1 + .../class_FrameworkDatabaseInterface.php | 28 + .../interfaces/database/class_Updateable.php | 37 + .../interfaces/database/frontend/.htaccess | 1 + .../class_DatabaseFrontendInterface.php | 69 + .../interfaces/database/middleware/.htaccess | 1 + .../middleware/class_DatabaseConnector.php | 28 + inc/classes/interfaces/debug/.htaccess | 1 + .../interfaces/debug/class_Debugger.php | 35 + inc/classes/interfaces/discovery/.htaccess | 1 + .../discovery/class_Discoverable.php | 43 + inc/classes/interfaces/filter/.htaccess | 1 + .../interfaces/filter/class_Filterable.php | 36 + inc/classes/interfaces/helper/.htaccess | 1 + .../interfaces/helper/class_HelpableLogin.php | 36 + .../helper/class_HelpableTemplate.php | 34 + inc/classes/interfaces/io/.htaccess | 1 + .../interfaces/io/class_Streamable.php | 28 + inc/classes/interfaces/io/file/.htaccess | 1 + .../io/file/class_FileInputStreamer.php | 38 + .../io/file/class_FileOutputStreamer.php | 38 + inc/classes/interfaces/io/output/.htaccess | 1 + .../io/output/class_OutputStreamer.php | 43 + inc/classes/interfaces/language/.htaccess | 1 + .../language/class_ManageableLanguage.php | 34 + inc/classes/interfaces/login/.htaccess | 1 + .../interfaces/login/class_LoginableUser.php | 38 + inc/classes/interfaces/mailer/.htaccess | 1 + .../mailer/class_DeliverableMail.php | 56 + inc/classes/interfaces/reader/.htaccess | 1 + .../interfaces/reader/class_ReadableNews.php | 34 + inc/classes/interfaces/registration/.htaccess | 1 + .../registration/class_UserRegister.php | 76 + inc/classes/interfaces/registry/.htaccess | 1 + .../interfaces/registry/class_Register.php | 52 + .../registry/class_Registerable.php | 28 + inc/classes/interfaces/request/.htaccess | 1 + .../interfaces/request/class_Requestable.php | 84 + inc/classes/interfaces/resolver/.htaccess | 1 + .../interfaces/resolver/actions/.htaccess | 1 + .../resolver/actions/class_ActionResolver.php | 51 + .../interfaces/resolver/class_Resolver.php | 28 + .../interfaces/resolver/commands/.htaccess | 1 + .../commands/class_CommandResolver.php | 44 + .../interfaces/resolver/controller/.htaccess | 1 + .../controller/class_ControllerResolver.php | 34 + inc/classes/interfaces/response/.htaccess | 1 + .../response/class_Responseable.php | 109 + inc/classes/interfaces/result/.htaccess | 1 + .../result/class_SearchableResult.php | 44 + .../result/class_UpdateableResult.php | 45 + inc/classes/interfaces/template/.htaccess | 1 + .../template/class_CompileableTemplate.php | 89 + .../template/view/class_ViewHelper.php | 35 + inc/classes/interfaces/user/.htaccess | 1 + .../user/class_ManageableAccount.php | 50 + .../interfaces/user/extended/.htaccess | 1 + .../user/extended/class_ManageableGuest.php | 28 + .../user/extended/class_ManageableMember.php | 28 + inc/classes/main/.htaccess | 1 + inc/classes/main/actions/.htaccess | 1 + inc/classes/main/actions/class_ | 62 + inc/classes/main/actions/class_BaseAction.php | 44 + .../main/actions/post_registration/.htaccess | 1 + .../class_LoginAfterRegistrationAction.php | 83 + inc/classes/main/actions/web/.htaccess | 1 + .../web/class_WebLoginProfileAction.php | 77 + inc/classes/main/application/.htaccess | 1 + .../application/class_BaseApplication.php | 48 + inc/classes/main/auth/.htaccess | 1 + inc/classes/main/auth/class_CookieAuth.php | 126 ++ inc/classes/main/cache/.htaccess | 1 + inc/classes/main/cache/class_MemoryCache.php | 114 + inc/classes/main/class_ | 41 + inc/classes/main/class_Base | 42 + .../main/class_BaseFrameworkSystem.php | 1077 ++++++++++ .../main/class_FrameworkArrayObject.php | 53 + inc/classes/main/commands/.htaccess | 1 + inc/classes/main/commands/class_ | 64 + .../main/commands/class_BaseCommand.php | 62 + inc/classes/main/commands/image/.htaccess | 1 + .../image/class_ImageCodeCaptchaCommand.php | 98 + inc/classes/main/commands/web/.htaccess | 1 + inc/classes/main/commands/web/class_ | 77 + .../commands/web/class_WebConfirmCommand.php | 129 ++ .../commands/web/class_WebDoFormCommand.php | 78 + .../commands/web/class_WebHomeCommand.php | 120 ++ .../web/class_WebLoginAreaCommand.php | 197 ++ .../commands/web/class_WebLoginCommand.php | 123 ++ .../web/class_WebLoginFailedCommand.php | 123 ++ .../commands/web/class_WebLogoutCommand.php | 89 + .../web/class_WebLogoutDoneCommand.php | 123 ++ .../commands/web/class_WebRegisterCommand.php | 127 ++ .../web/class_WebResendLinkCommand.php | 142 ++ inc/classes/main/compressor/.htaccess | 1 + .../main/compressor/class_Bzip2Compressor.php | 99 + .../main/compressor/class_GzipCompressor.php | 99 + .../main/compressor/class_NullCompressor.php | 93 + inc/classes/main/console/.htaccess | 1 + .../main/console/class_ConsoleTools.php | 83 + inc/classes/main/controller/.htaccess | 1 + inc/classes/main/controller/captcha/.htaccess | 1 + .../class_ImageCodeCaptchaController.php | 84 + inc/classes/main/controller/class_ | 75 + .../main/controller/class_BaseController.php | 112 + inc/classes/main/controller/form/.htaccess | 1 + .../form/class_WebDoFormController.php | 100 + inc/classes/main/controller/image/.htaccess | 1 + .../image/class_ImageDefaultController.php | 75 + inc/classes/main/controller/login/.htaccess | 1 + .../login/class_WebLoginAreaController.php | 106 + inc/classes/main/controller/web/.htaccess | 1 + inc/classes/main/controller/web/class_ | 85 + .../web/class_WebConfirmController.php | 88 + .../web/class_WebDefaultController.php | 76 + .../web/class_WebDefaultNewsController.php | 88 + .../web/class_WebLoginController.php | 86 + .../web/class_WebLoginFailedController.php | 75 + .../web/class_WebLogoutController.php | 82 + .../web/class_WebLogoutDoneController.php | 86 + .../web/class_WebRegisterController.php | 86 + .../web/class_WebStatusController.php | 76 + inc/classes/main/criteria/.htaccess | 1 + .../main/criteria/class_DataSetCriteria.php | 187 ++ .../main/criteria/class_SearchCriteria.php | 213 ++ .../main/criteria/class_UpdateCriteria.php | 104 + inc/classes/main/crypto/.htaccess | 1 + .../main/crypto/class_CryptoHelper.php | 260 +++ inc/classes/main/database/.htaccess | 1 + inc/classes/main/database/class_ | 42 + .../database/class_BaseDatabaseFrontend.php | 50 + .../database/class_BaseDatabaseWrapper.php | 161 ++ inc/classes/main/database/databases/.htaccess | 1 + .../databases/class_LocalFileDatabase.php | 611 ++++++ inc/classes/main/database/wrapper/.htaccess | 1 + .../wrapper/class_NewsDatabaseWrapper.php | 56 + .../wrapper/class_PaymentsDatabaseWrapper.php | 59 + .../wrapper/class_UserDatabaseWrapper.php | 118 ++ .../class_UserPointsDatabaseWrapper.php | 56 + inc/classes/main/debug/.htaccess | 1 + .../main/debug/class_DebugConsoleOutput.php | 84 + .../main/debug/class_DebugErrorLogOutput.php | 93 + .../main/debug/class_DebugWebOutput.php | 86 + inc/classes/main/discovery/.htaccess | 1 + inc/classes/main/discovery/class_ | 78 + .../main/discovery/class_BaseDiscovery.php | 66 + inc/classes/main/discovery/payment/.htaccess | 1 + .../payment/class_LocalPaymentDiscovery.php | 94 + inc/classes/main/factories/.htaccess | 1 + inc/classes/main/factories/cache/.htaccess | 1 + .../factories/cache/class_CacheFactory.php | 74 + .../main/factories/class_BaseFactory.php | 66 + inc/classes/main/factories/objects/.htaccess | 1 + .../factories/objects/class_ObjectFactory.php | 111 + inc/classes/main/factories/web/.htaccess | 1 + .../factories/web/class_WebNewsFactory.php | 84 + inc/classes/main/filter/.htaccess | 1 + inc/classes/main/filter/auth/.htaccess | 1 + .../main/filter/auth/class_UserAuthFilter.php | 141 ++ inc/classes/main/filter/change/.htaccess | 1 + .../filter/change/class_EmailChangeFilter.php | 125 ++ .../change/class_PasswordChangeFilter.php | 116 + inc/classes/main/filter/checkboxes/.htaccess | 1 + .../checkboxes/class_RulesAcceptedFilter.php | 80 + inc/classes/main/filter/class_ | 67 + .../filter/class_AbstractFilterDecorator.php | 87 + inc/classes/main/filter/class_BaseFilter.php | 45 + inc/classes/main/filter/class_FilterChain.php | 92 + inc/classes/main/filter/crypto/.htaccess | 1 + .../crypto/class_CaptchaEncryptFilter.php | 94 + inc/classes/main/filter/decorator/.htaccess | 1 + inc/classes/main/filter/guest/.htaccess | 1 + .../guest/class_UserNameIsGuestFilter.php | 74 + inc/classes/main/filter/news/.htaccess | 1 + .../filter/news/class_NewsDownloadFilter.php | 71 + .../filter/news/class_NewsProcessFilter.php | 66 + inc/classes/main/filter/null/.htaccess | 1 + .../main/filter/null/class_NullFilter.php | 66 + inc/classes/main/filter/payment/.htaccess | 1 + .../payment/class_PaymentDiscoveryFilter.php | 135 ++ inc/classes/main/filter/update/.htaccess | 1 + .../class_UserStatusConfimedUpdateFilter.php | 78 + .../filter/update/class_UserUpdateFilter.php | 78 + inc/classes/main/filter/validator/.htaccess | 1 + .../validator/class_EmailValidatorFilter.php | 172 ++ .../class_PasswordValidatorFilter.php | 107 + .../class_UserNameValidatorFilter.php | 142 ++ inc/classes/main/filter/verifier/.htaccess | 1 + .../class_AccountPasswordVerifierFilter.php | 113 + .../class_ConfirmCodeVerifierFilter.php | 112 + ...ass_GraphicalCodeCaptchaVerifierFilter.php | 126 ++ .../class_PasswordGuestVerifierFilter.php | 88 + .../verifier/class_PasswordVerifierFilter.php | 88 + .../class_UserGuestVerifierFilter.php | 145 ++ .../verifier/class_UserNameVerifierFilter.php | 142 ++ .../class_UserStatusVerifierFilter.php | 78 + .../class_UserUnconfirmedVerifierFilter.php | 96 + inc/classes/main/helper/.htaccess | 1 + inc/classes/main/helper/captcha/.htaccess | 1 + inc/classes/main/helper/captcha/class_ | 78 + .../main/helper/captcha/class_BaseCaptcha.php | 87 + .../main/helper/captcha/images/.htaccess | 1 + .../captcha/images/class_ImageHelper.php | 391 ++++ inc/classes/main/helper/captcha/web/.htaccess | 1 + .../web/class_GraphicalCodeCaptcha.php | 157 ++ inc/classes/main/helper/class_ | 63 + inc/classes/main/helper/class_BaseHelper.php | 503 +++++ inc/classes/main/helper/login/.htaccess | 1 + .../helper/login/class_BaseLoginHelper.php | 38 + inc/classes/main/helper/web/.htaccess | 1 + inc/classes/main/helper/web/blocks/.htaccess | 1 + .../web/blocks/class_WebBlockHelper.php | 151 ++ inc/classes/main/helper/web/class_ | 76 + .../main/helper/web/class_BaseWebHelper.php | 210 ++ inc/classes/main/helper/web/forms/.htaccess | 1 + .../helper/web/forms/class_WebFormHelper.php | 779 +++++++ inc/classes/main/helper/web/links/.htaccess | 1 + .../helper/web/links/class_WebLinkHelper.php | 289 +++ inc/classes/main/images/.htaccess | 1 + inc/classes/main/images/class_ | 53 + inc/classes/main/images/class_BaseImage.php | 549 +++++ inc/classes/main/images/extended/.htaccess | 1 + .../main/images/extended/class_PngImage.php | 79 + inc/classes/main/io/.htaccess | 1 + inc/classes/main/io/class_FileIoStream.php | 226 ++ .../io/class_FrameworkDirectoryPointer.php | 240 +++ .../io/class_FrameworkFileInputPointer.php | 223 ++ .../io/class_FrameworkFileOutputPointer.php | 193 ++ inc/classes/main/language/.htaccess | 1 + .../main/language/class_LanguageSystem.php | 183 ++ inc/classes/main/mailer/.htaccess | 1 + inc/classes/main/mailer/class_ | 70 + inc/classes/main/mailer/class_BaseMailer.php | 214 ++ inc/classes/main/mailer/debug/.htaccess | 1 + .../main/mailer/debug/class_DebugMailer.php | 175 ++ inc/classes/main/output/.htaccess | 1 + .../main/output/class_ConsoleOutput.php | 115 + inc/classes/main/output/class_WebOutput.php | 92 + inc/classes/main/points/.htaccess | 1 + inc/classes/main/points/class_UserPoints.php | 93 + inc/classes/main/reader/.htaccess | 1 + .../main/reader/class_DefaultNewsReader.php | 87 + inc/classes/main/registration/.htaccess | 1 + .../registration/class_BaseRegistration.php | 105 + inc/classes/main/registry/.htaccess | 1 + inc/classes/main/registry/class_Registry.php | 132 ++ inc/classes/main/request/.htaccess | 1 + .../main/request/class_HttpRequest.php | 208 ++ inc/classes/main/resolver/.htaccess | 1 + inc/classes/main/resolver/action/.htaccess | 1 + .../action/class_BaseActionResolver.php | 134 ++ .../main/resolver/action/web/.htaccess | 1 + .../action/web/class_WebActionResolver.php | 147 ++ .../main/resolver/class_BaseResolver.php | 71 + inc/classes/main/resolver/command/.htaccess | 1 + .../command/class_BaseCommandResolver.php | 113 + .../main/resolver/command/image/.htaccess | 1 + .../image/class_ImageCommandResolver.php | 178 ++ .../main/resolver/command/web/.htaccess | 1 + inc/classes/main/resolver/command/web/class_ | 178 ++ .../command/web/class_WebCommandResolver.php | 178 ++ .../main/resolver/controller/.htaccess | 1 + .../class_BaseControllerResolver.php | 126 ++ .../main/resolver/controller/image/.htaccess | 1 + .../image/class_ImageControllerResolver.php | 161 ++ .../main/resolver/controller/web/.htaccess | 1 + .../web/class_WebControllerResolver.php | 182 ++ inc/classes/main/response/.htaccess | 1 + .../main/response/class_BaseResponse.php | 211 ++ inc/classes/main/response/http/.htaccess | 1 + .../main/response/http/class_HttpResponse.php | 211 ++ inc/classes/main/response/image/.htaccess | 1 + .../response/image/class_ImageResponse.php | 268 +++ inc/classes/main/result/.htaccess | 1 + .../main/result/class_DatabaseResult.php | 404 ++++ inc/classes/main/rng/.htaccess | 1 + .../main/rng/class_RandomNumberGenerator.php | 180 ++ inc/classes/main/template/.htaccess | 1 + .../template/class_BaseTemplateEngine.php | 1299 ++++++++++++ inc/classes/main/template/image/.htaccess | 1 + .../image/class_ImageTemplateEngine.php | 472 +++++ inc/classes/main/template/mail/.htaccess | 1 + .../mail/class_MailTemplateEngine.php | 357 ++++ inc/classes/main/template/web/.htaccess | 1 + .../template/web/class_WebTemplateEngine.php | 92 + inc/classes/main/user/.htaccess | 1 + inc/classes/main/user/class_BaseUser.php | 340 +++ inc/classes/main/user/guest/.htaccess | 1 + inc/classes/main/user/guest/class_Guest.php | 107 + inc/classes/main/user/member/.htaccess | 1 + inc/classes/main/user/member/class_Member.php | 175 ++ inc/classes/middleware/.htaccess | 1 + .../middleware/class_BaseMiddleware.php | 42 + inc/classes/middleware/compressor/.htaccess | 1 + .../compressor/class_CompressorChannel.php | 129 ++ inc/classes/middleware/database/.htaccess | 1 + .../database/class_DatabaseConnection.php | 186 ++ inc/classes/middleware/debug/.htaccess | 1 + .../debug/class_DebugMiddleware.php | 119 ++ inc/classes/middleware/io/.htaccess | 1 + .../middleware/io/class_FileIoHandler.php | 150 ++ inc/classes/third_party/.htaccess | 1 + inc/classes/third_party/akismet/.htaccess | 1 + .../third_party/akismet/akismet.class.php | 388 ++++ inc/classes/third_party/api/.htaccess | 1 + .../third_party/api/primusportal/.htaccess | 1 + .../api/primusportal/class_PrimeraApi.php | 240 +++ .../third_party/api/wernisportal/.htaccess | 1 + .../api/wernisportal/class_WernisApi.php | 416 ++++ inc/classes/third_party/php_mailer/.htaccess | 1 + .../third_party/php_mailer/ChangeLog.txt | 307 +++ inc/classes/third_party/php_mailer/LICENSE | 504 +++++ inc/classes/third_party/php_mailer/README | 178 ++ .../php_mailer/class.phpmailer.php | 1886 +++++++++++++++++ .../third_party/php_mailer/class.pop3.php | 393 ++++ .../third_party/php_mailer/class.smtp.php | 1113 ++++++++++ .../php_mailer/docs/extending.html | 148 ++ .../third_party/php_mailer/docs/faq.html | 67 + .../php_mailer/docs/pop3_article.txt | 39 + .../third_party/php_mailer/docs/use_gmail.txt | 45 + .../php_mailer/examples/contents.html | 12 + .../php_mailer/examples/images/bkgrnd.gif | Bin 0 -> 49 bytes .../php_mailer/examples/images/phpmailer.gif | Bin 0 -> 4756 bytes .../php_mailer/examples/images/phpmailer.png | Bin 0 -> 3506 bytes .../examples/images/phpmailer_mini.gif | Bin 0 -> 1042 bytes .../php_mailer/examples/index.html | 73 + .../examples/pop3_before_smtp_test.php | 39 + .../php_mailer/examples/test_gmail.php | 50 + .../php_mailer/examples/test_mail.php | 29 + .../php_mailer/examples/test_sendmail.php | 37 + .../php_mailer/examples/test_smtp.php | 39 + .../third_party/php_mailer/language/.htaccess | 1 + .../php_mailer/language/phpmailer.lang-br.php | 24 + .../php_mailer/language/phpmailer.lang-ca.php | 24 + .../php_mailer/language/phpmailer.lang-cz.php | 26 + .../php_mailer/language/phpmailer.lang-de.php | 26 + .../php_mailer/language/phpmailer.lang-dk.php | 26 + .../php_mailer/language/phpmailer.lang-en.php | 25 + .../php_mailer/language/phpmailer.lang-es.php | 25 + .../php_mailer/language/phpmailer.lang-et.php | 24 + .../php_mailer/language/phpmailer.lang-fi.php | 25 + .../php_mailer/language/phpmailer.lang-fo.php | 27 + .../php_mailer/language/phpmailer.lang-fr.php | 26 + .../php_mailer/language/phpmailer.lang-hu.php | 25 + .../php_mailer/language/phpmailer.lang-it.php | 30 + .../php_mailer/language/phpmailer.lang-ja.php | Bin 0 -> 2672 bytes .../php_mailer/language/phpmailer.lang-nl.php | 25 + .../php_mailer/language/phpmailer.lang-no.php | 25 + .../php_mailer/language/phpmailer.lang-pl.php | 25 + .../php_mailer/language/phpmailer.lang-ro.php | 25 + .../php_mailer/language/phpmailer.lang-ru.php | 26 + .../php_mailer/language/phpmailer.lang-se.php | 26 + .../php_mailer/language/phpmailer.lang-tr.php | 26 + .../phpdoc/PHPMailer/PHPMailer.html | 1475 +++++++++++++ .../php_mailer/phpdoc/PHPMailer/SMTP.html | 734 +++++++ .../PHPMailer/_class_phpmailer_php.html | 60 + .../phpdoc/PHPMailer/_class_smtp_php.html | 60 + .../third_party/php_mailer/phpdoc/blank.html | 13 + .../phpdoc/classtrees_PHPMailer.html | 28 + .../php_mailer/phpdoc/elementindex.html | 734 +++++++ .../phpdoc/elementindex_PHPMailer.html | 731 +++++++ .../third_party/php_mailer/phpdoc/errors.html | 23 + .../third_party/php_mailer/phpdoc/index.html | 24 + .../php_mailer/phpdoc/li_PHPMailer.html | 36 + .../php_mailer/phpdoc/media/banner.css | 32 + .../php_mailer/phpdoc/media/stylesheet.css | 133 ++ .../php_mailer/phpdoc/packages.html | 27 + .../php_mailer/test/phpmailer_test.php | 572 +++++ .../third_party/php_mailer/test/phpunit.php | 376 ++++ .../third_party/php_mailer/test/test.png | Bin 0 -> 1280 bytes inc/config.php | 288 +++ inc/config/.htaccess | 1 + inc/config/class_FrameworkConfiguration.php | 272 +++ inc/config/config-hubmaster.php | 88 + inc/database.php | 92 + inc/database/.htaccess | 1 + inc/database/lib-local.php | 51 + inc/file_io.php | 34 + inc/includes.php | 86 + inc/language.php | 50 + inc/language/.htaccess | 1 + inc/loader/.htaccess | 1 + inc/loader/class_ClassLoader.php | 376 ++++ inc/output.php | 32 + inc/selector.php | 68 + templates/.htaccess | 1 + templates/_compiled/.htaccess | 1 + templates/de/.htaccess | 1 + templates/de/code/.htaccess | 1 + templates/de/code/emergency_exit.ctp | 29 + templates/de/code/footer_msg.ctp | 8 + templates/de/code/header.ctp | 20 + templates/de/html/.htaccess | 1 + templates/images/.htaccess | 1 + templates/images/_cache/.htaccess | 1 + templates/images/de/.htaccess | 1 + templates/images/de/image/.htaccess | 1 + templates/images/de/image/base_image.itp | 28 + templates/images/de/image/emergency_exit.itp | 40 + tests/ConfigTest.php | 165 ++ tests/RegistryTest.php | 94 + tests/RequestTest.php | 102 + tests/Test.php | 54 + tests/all-tests.sh | 3 + tests/old/contract-test.php | 612 ++++++ tests/old/loader-test.php | 162 ++ tests/old/personell-test.php | 162 ++ tests/unittest.sh | 5 + 549 files changed, 44303 insertions(+) create mode 100644 .gitattributes create mode 100644 devel/.htaccess create mode 100644 devel/class_Debug.php create mode 100644 inc/.htaccess create mode 100644 inc/classes.php create mode 100644 inc/classes/.htaccess create mode 100644 inc/classes/exceptions/.htaccess create mode 100644 inc/classes/exceptions/actions/.htaccess create mode 100644 inc/classes/exceptions/actions/class_InvalidActionException.php create mode 100644 inc/classes/exceptions/auth/.htaccess create mode 100644 inc/classes/exceptions/auth/class_UserAuthorizationException.php create mode 100644 inc/classes/exceptions/class_ create mode 100644 inc/classes/exceptions/class_FrameworkException.php create mode 100644 inc/classes/exceptions/compressor/.htaccess create mode 100644 inc/classes/exceptions/compressor/class_MismatchingCompressorsException.php create mode 100644 inc/classes/exceptions/container/.htaccess create mode 100644 inc/classes/exceptions/container/class_ContainerItemIsNoArrayException.php create mode 100644 inc/classes/exceptions/container/class_ContainerItemIsNullException.php create mode 100644 inc/classes/exceptions/container/class_ContainerMaybeDamagedException.php create mode 100644 inc/classes/exceptions/controller/.htaccess create mode 100644 inc/classes/exceptions/controller/class_DefaultControllerException.php create mode 100644 inc/classes/exceptions/controller/class_InvalidControllerException.php create mode 100644 inc/classes/exceptions/criteria/.htaccess create mode 100644 inc/classes/exceptions/crypto/.htaccess create mode 100644 inc/classes/exceptions/crypto/class_EncryptInvalidLengthException.php create mode 100644 inc/classes/exceptions/crypto/class_EncryptMissingException.php create mode 100644 inc/classes/exceptions/database/.htaccess create mode 100644 inc/classes/exceptions/database/class_ create mode 100644 inc/classes/exceptions/database/class_DatabaseException.php create mode 100644 inc/classes/exceptions/database/general/.htaccess create mode 100644 inc/classes/exceptions/database/general/class_DatabaseUpdateSupportException.php create mode 100644 inc/classes/exceptions/database/general/class_SqlException.php create mode 100644 inc/classes/exceptions/database/local_file/.htaccess create mode 100644 inc/classes/exceptions/database/local_file/class_SavePathIsEmptyException.php create mode 100644 inc/classes/exceptions/database/local_file/class_SavePathIsNoDirectoryException.php create mode 100644 inc/classes/exceptions/database/local_file/class_SavePathReadProtectedException.php create mode 100644 inc/classes/exceptions/database/local_file/class_SavePathWriteProtectedException.php create mode 100644 inc/classes/exceptions/database/wrapper/.htaccess create mode 100644 inc/classes/exceptions/database/wrapper/class_WrapperUserNameNotFoundException.php create mode 100644 inc/classes/exceptions/filter/.htaccess create mode 100644 inc/classes/exceptions/filter/class_FilterChainException.php create mode 100644 inc/classes/exceptions/helper/.htaccess create mode 100644 inc/classes/exceptions/helper/class_FormClosedException.php create mode 100644 inc/classes/exceptions/helper/class_FormGroupClosedException.php create mode 100644 inc/classes/exceptions/helper/class_FormOpenedException.php create mode 100644 inc/classes/exceptions/helper/class_HelperGroupAlreadyCreatedException.php create mode 100644 inc/classes/exceptions/helper/class_HelperNoPreviousOpenedSubGroupException.php create mode 100644 inc/classes/exceptions/helper/class_HelperSubGroupAlreadyCreatedException.php create mode 100644 inc/classes/exceptions/helper/class_InvalidFormNameException.php create mode 100644 inc/classes/exceptions/helper/class_NoGroupOpenedException.php create mode 100644 inc/classes/exceptions/helper/class_UserInstanceMissingException.php create mode 100644 inc/classes/exceptions/io/.htaccess create mode 100644 inc/classes/exceptions/io/class_DirPointerNotOpenedException.php create mode 100644 inc/classes/exceptions/io/class_FileNotFoundException.php create mode 100644 inc/classes/exceptions/io/class_FilePointerNotOpenedException.php create mode 100644 inc/classes/exceptions/io/class_FileReadProtectedException.php create mode 100644 inc/classes/exceptions/io/class_InvalidDataLengthException.php create mode 100644 inc/classes/exceptions/io/class_InvalidDirectoryResourceException.php create mode 100644 inc/classes/exceptions/io/class_InvalidMD5ChecksumException.php create mode 100644 inc/classes/exceptions/io/class_PathIsEmptyException.php create mode 100644 inc/classes/exceptions/io/class_PathIsNoDirectoryException.php create mode 100644 inc/classes/exceptions/io/class_PathReadProtectedException.php create mode 100644 inc/classes/exceptions/language/.htaccess create mode 100644 inc/classes/exceptions/language/class_InvalidLanguagePathStringException.php create mode 100644 inc/classes/exceptions/language/class_LanguagePathIsEmptyException.php create mode 100644 inc/classes/exceptions/language/class_LanguagePathIsNoDirectoryException.php create mode 100644 inc/classes/exceptions/language/class_LanguagePathReadProtectedException.php create mode 100644 inc/classes/exceptions/language/class_MissingFileIoHandlerException.php create mode 100644 inc/classes/exceptions/language/class_MissingLanguageHandlerException.php create mode 100644 inc/classes/exceptions/main/.htaccess create mode 100644 inc/classes/exceptions/main/class_AssertionException.php create mode 100644 inc/classes/exceptions/main/class_ClassMismatchException.php create mode 100644 inc/classes/exceptions/main/class_ClassNotFoundException.php create mode 100644 inc/classes/exceptions/main/class_ConfigEntryIsEmptyException.php create mode 100644 inc/classes/exceptions/main/class_ConfigEntryNotFoundException.php create mode 100644 inc/classes/exceptions/main/class_DimNotFoundInArrayException.php create mode 100644 inc/classes/exceptions/main/class_EmptyVariableException.php create mode 100644 inc/classes/exceptions/main/class_ExceptionNotFoundException.php create mode 100644 inc/classes/exceptions/main/class_FatalErrorException.php create mode 100644 inc/classes/exceptions/main/class_GetterNotFoundException.php create mode 100644 inc/classes/exceptions/main/class_InvalidArrayCountException.php create mode 100644 inc/classes/exceptions/main/class_InvalidCommandException.php create mode 100644 inc/classes/exceptions/main/class_InvalidCommandInstanceException.php create mode 100644 inc/classes/exceptions/main/class_InvalidInterfaceException.php create mode 100644 inc/classes/exceptions/main/class_InvalidObjectException.php create mode 100644 inc/classes/exceptions/main/class_MissingArrayElementsException.php create mode 100644 inc/classes/exceptions/main/class_MissingDecimalsThousandsSeperatorException.php create mode 100644 inc/classes/exceptions/main/class_MissingMethodException.php create mode 100644 inc/classes/exceptions/main/class_NoArrayCreatedException.php create mode 100644 inc/classes/exceptions/main/class_NoArrayException.php create mode 100644 inc/classes/exceptions/main/class_NoObjectException.php create mode 100644 inc/classes/exceptions/main/class_NullPointerException.php create mode 100644 inc/classes/exceptions/main/class_ResponseHeadersAlreadySentException.php create mode 100644 inc/classes/exceptions/main/class_VariableIsNotSetException.php create mode 100644 inc/classes/exceptions/result/.htaccess create mode 100644 inc/classes/exceptions/result/class_InvalidDatabaseResultException.php create mode 100644 inc/classes/exceptions/result/class_ResultUpdateException.php create mode 100644 inc/classes/exceptions/template/.htaccess create mode 100644 inc/classes/exceptions/template/class_BasePathIsEmptyException.php create mode 100644 inc/classes/exceptions/template/class_BasePathIsNoDirectoryException.php create mode 100644 inc/classes/exceptions/template/class_BasePathReadProtectedException.php create mode 100644 inc/classes/exceptions/template/class_InvalidBasePathStringException.php create mode 100644 inc/classes/exceptions/template/class_UnexpectedTemplateTypeException.php create mode 100644 inc/classes/exceptions/template/class_UnsupportedTemplateEngineException.php create mode 100644 inc/classes/exceptions/template/class_ViewHelperNotFoundException.php create mode 100644 inc/classes/exceptions/user/.htaccess create mode 100644 inc/classes/exceptions/user/class_AccountPasswordMismatchException.php create mode 100644 inc/classes/exceptions/user/class_UserEmailMissingException.php create mode 100644 inc/classes/exceptions/user/class_UserPasswordMismatchException.php create mode 100644 inc/classes/exceptions/user/class_UsernameMissingException.php create mode 100644 inc/classes/exceptions/xml/.htaccess create mode 100644 inc/classes/exceptions/xml/class_InvalidXmlNodeException.php create mode 100644 inc/classes/exceptions/xml/class_XmlNodeMismatchException.php create mode 100644 inc/classes/exceptions/xml/class_XmlParserException.php create mode 100644 inc/classes/interfaces/.htaccess create mode 100644 inc/classes/interfaces/actions/.htaccess create mode 100644 inc/classes/interfaces/actions/class_PerformableAction.php create mode 100644 inc/classes/interfaces/actions/commands/.htaccess create mode 100644 inc/classes/interfaces/actions/commands/class_Commandable.php create mode 100644 inc/classes/interfaces/application/.htaccess create mode 100644 inc/classes/interfaces/application/class_ManageableApplication.php create mode 100644 inc/classes/interfaces/auth/.htaccess create mode 100644 inc/classes/interfaces/auth/class_Authorizeable.php create mode 100644 inc/classes/interfaces/cache/.htaccess create mode 100644 inc/classes/interfaces/cache/class_Cacheable.php create mode 100644 inc/classes/interfaces/captcha/.htaccess create mode 100644 inc/classes/interfaces/captcha/class_SolveableCaptcha.php create mode 100644 inc/classes/interfaces/class_ create mode 100644 inc/classes/interfaces/class_FrameworkInterface.php create mode 100644 inc/classes/interfaces/compressor/.htaccess create mode 100644 inc/classes/interfaces/compressor/class_Compressor.php create mode 100644 inc/classes/interfaces/controller/.htaccess create mode 100644 inc/classes/interfaces/controller/class_Controller.php create mode 100644 inc/classes/interfaces/criteria/.htaccess create mode 100644 inc/classes/interfaces/criteria/class_Criteria.php create mode 100644 inc/classes/interfaces/criteria/extended/.htaccess create mode 100644 inc/classes/interfaces/criteria/extended/class_LocalSearchCriteria.php create mode 100644 inc/classes/interfaces/criteria/extended/class_LocalUpdateCriteria.php create mode 100644 inc/classes/interfaces/criteria/extended/class_StoreableCriteria.php create mode 100644 inc/classes/interfaces/crypto/.htaccess create mode 100644 inc/classes/interfaces/crypto/class_Cryptable.php create mode 100644 inc/classes/interfaces/database/.htaccess create mode 100644 inc/classes/interfaces/database/class_FrameworkDatabaseInterface.php create mode 100644 inc/classes/interfaces/database/class_Updateable.php create mode 100644 inc/classes/interfaces/database/frontend/.htaccess create mode 100644 inc/classes/interfaces/database/frontend/class_DatabaseFrontendInterface.php create mode 100644 inc/classes/interfaces/database/middleware/.htaccess create mode 100644 inc/classes/interfaces/database/middleware/class_DatabaseConnector.php create mode 100644 inc/classes/interfaces/debug/.htaccess create mode 100644 inc/classes/interfaces/debug/class_Debugger.php create mode 100644 inc/classes/interfaces/discovery/.htaccess create mode 100644 inc/classes/interfaces/discovery/class_Discoverable.php create mode 100644 inc/classes/interfaces/filter/.htaccess create mode 100644 inc/classes/interfaces/filter/class_Filterable.php create mode 100644 inc/classes/interfaces/helper/.htaccess create mode 100644 inc/classes/interfaces/helper/class_HelpableLogin.php create mode 100644 inc/classes/interfaces/helper/class_HelpableTemplate.php create mode 100644 inc/classes/interfaces/io/.htaccess create mode 100644 inc/classes/interfaces/io/class_Streamable.php create mode 100644 inc/classes/interfaces/io/file/.htaccess create mode 100644 inc/classes/interfaces/io/file/class_FileInputStreamer.php create mode 100644 inc/classes/interfaces/io/file/class_FileOutputStreamer.php create mode 100644 inc/classes/interfaces/io/output/.htaccess create mode 100644 inc/classes/interfaces/io/output/class_OutputStreamer.php create mode 100644 inc/classes/interfaces/language/.htaccess create mode 100644 inc/classes/interfaces/language/class_ManageableLanguage.php create mode 100644 inc/classes/interfaces/login/.htaccess create mode 100644 inc/classes/interfaces/login/class_LoginableUser.php create mode 100644 inc/classes/interfaces/mailer/.htaccess create mode 100644 inc/classes/interfaces/mailer/class_DeliverableMail.php create mode 100644 inc/classes/interfaces/reader/.htaccess create mode 100644 inc/classes/interfaces/reader/class_ReadableNews.php create mode 100644 inc/classes/interfaces/registration/.htaccess create mode 100644 inc/classes/interfaces/registration/class_UserRegister.php create mode 100644 inc/classes/interfaces/registry/.htaccess create mode 100644 inc/classes/interfaces/registry/class_Register.php create mode 100644 inc/classes/interfaces/registry/class_Registerable.php create mode 100644 inc/classes/interfaces/request/.htaccess create mode 100644 inc/classes/interfaces/request/class_Requestable.php create mode 100644 inc/classes/interfaces/resolver/.htaccess create mode 100644 inc/classes/interfaces/resolver/actions/.htaccess create mode 100644 inc/classes/interfaces/resolver/actions/class_ActionResolver.php create mode 100644 inc/classes/interfaces/resolver/class_Resolver.php create mode 100644 inc/classes/interfaces/resolver/commands/.htaccess create mode 100644 inc/classes/interfaces/resolver/commands/class_CommandResolver.php create mode 100644 inc/classes/interfaces/resolver/controller/.htaccess create mode 100644 inc/classes/interfaces/resolver/controller/class_ControllerResolver.php create mode 100644 inc/classes/interfaces/response/.htaccess create mode 100644 inc/classes/interfaces/response/class_Responseable.php create mode 100644 inc/classes/interfaces/result/.htaccess create mode 100644 inc/classes/interfaces/result/class_SearchableResult.php create mode 100644 inc/classes/interfaces/result/class_UpdateableResult.php create mode 100644 inc/classes/interfaces/template/.htaccess create mode 100644 inc/classes/interfaces/template/class_CompileableTemplate.php create mode 100644 inc/classes/interfaces/template/view/class_ViewHelper.php create mode 100644 inc/classes/interfaces/user/.htaccess create mode 100644 inc/classes/interfaces/user/class_ManageableAccount.php create mode 100644 inc/classes/interfaces/user/extended/.htaccess create mode 100644 inc/classes/interfaces/user/extended/class_ManageableGuest.php create mode 100644 inc/classes/interfaces/user/extended/class_ManageableMember.php create mode 100644 inc/classes/main/.htaccess create mode 100644 inc/classes/main/actions/.htaccess create mode 100644 inc/classes/main/actions/class_ create mode 100644 inc/classes/main/actions/class_BaseAction.php create mode 100644 inc/classes/main/actions/post_registration/.htaccess create mode 100644 inc/classes/main/actions/post_registration/class_LoginAfterRegistrationAction.php create mode 100644 inc/classes/main/actions/web/.htaccess create mode 100644 inc/classes/main/actions/web/class_WebLoginProfileAction.php create mode 100644 inc/classes/main/application/.htaccess create mode 100644 inc/classes/main/application/class_BaseApplication.php create mode 100644 inc/classes/main/auth/.htaccess create mode 100644 inc/classes/main/auth/class_CookieAuth.php create mode 100644 inc/classes/main/cache/.htaccess create mode 100644 inc/classes/main/cache/class_MemoryCache.php create mode 100644 inc/classes/main/class_ create mode 100644 inc/classes/main/class_Base create mode 100644 inc/classes/main/class_BaseFrameworkSystem.php create mode 100644 inc/classes/main/class_FrameworkArrayObject.php create mode 100644 inc/classes/main/commands/.htaccess create mode 100644 inc/classes/main/commands/class_ create mode 100644 inc/classes/main/commands/class_BaseCommand.php create mode 100644 inc/classes/main/commands/image/.htaccess create mode 100644 inc/classes/main/commands/image/class_ImageCodeCaptchaCommand.php create mode 100644 inc/classes/main/commands/web/.htaccess create mode 100644 inc/classes/main/commands/web/class_ create mode 100644 inc/classes/main/commands/web/class_WebConfirmCommand.php create mode 100644 inc/classes/main/commands/web/class_WebDoFormCommand.php create mode 100644 inc/classes/main/commands/web/class_WebHomeCommand.php create mode 100644 inc/classes/main/commands/web/class_WebLoginAreaCommand.php create mode 100644 inc/classes/main/commands/web/class_WebLoginCommand.php create mode 100644 inc/classes/main/commands/web/class_WebLoginFailedCommand.php create mode 100644 inc/classes/main/commands/web/class_WebLogoutCommand.php create mode 100644 inc/classes/main/commands/web/class_WebLogoutDoneCommand.php create mode 100644 inc/classes/main/commands/web/class_WebRegisterCommand.php create mode 100644 inc/classes/main/commands/web/class_WebResendLinkCommand.php create mode 100644 inc/classes/main/compressor/.htaccess create mode 100644 inc/classes/main/compressor/class_Bzip2Compressor.php create mode 100644 inc/classes/main/compressor/class_GzipCompressor.php create mode 100644 inc/classes/main/compressor/class_NullCompressor.php create mode 100644 inc/classes/main/console/.htaccess create mode 100644 inc/classes/main/console/class_ConsoleTools.php create mode 100644 inc/classes/main/controller/.htaccess create mode 100644 inc/classes/main/controller/captcha/.htaccess create mode 100644 inc/classes/main/controller/captcha/class_ImageCodeCaptchaController.php create mode 100644 inc/classes/main/controller/class_ create mode 100644 inc/classes/main/controller/class_BaseController.php create mode 100644 inc/classes/main/controller/form/.htaccess create mode 100644 inc/classes/main/controller/form/class_WebDoFormController.php create mode 100644 inc/classes/main/controller/image/.htaccess create mode 100644 inc/classes/main/controller/image/class_ImageDefaultController.php create mode 100644 inc/classes/main/controller/login/.htaccess create mode 100644 inc/classes/main/controller/login/class_WebLoginAreaController.php create mode 100644 inc/classes/main/controller/web/.htaccess create mode 100644 inc/classes/main/controller/web/class_ create mode 100644 inc/classes/main/controller/web/class_WebConfirmController.php create mode 100644 inc/classes/main/controller/web/class_WebDefaultController.php create mode 100644 inc/classes/main/controller/web/class_WebDefaultNewsController.php create mode 100644 inc/classes/main/controller/web/class_WebLoginController.php create mode 100644 inc/classes/main/controller/web/class_WebLoginFailedController.php create mode 100644 inc/classes/main/controller/web/class_WebLogoutController.php create mode 100644 inc/classes/main/controller/web/class_WebLogoutDoneController.php create mode 100644 inc/classes/main/controller/web/class_WebRegisterController.php create mode 100644 inc/classes/main/controller/web/class_WebStatusController.php create mode 100644 inc/classes/main/criteria/.htaccess create mode 100644 inc/classes/main/criteria/class_DataSetCriteria.php create mode 100644 inc/classes/main/criteria/class_SearchCriteria.php create mode 100644 inc/classes/main/criteria/class_UpdateCriteria.php create mode 100644 inc/classes/main/crypto/.htaccess create mode 100644 inc/classes/main/crypto/class_CryptoHelper.php create mode 100644 inc/classes/main/database/.htaccess create mode 100644 inc/classes/main/database/class_ create mode 100644 inc/classes/main/database/class_BaseDatabaseFrontend.php create mode 100644 inc/classes/main/database/class_BaseDatabaseWrapper.php create mode 100644 inc/classes/main/database/databases/.htaccess create mode 100644 inc/classes/main/database/databases/class_LocalFileDatabase.php create mode 100644 inc/classes/main/database/wrapper/.htaccess create mode 100644 inc/classes/main/database/wrapper/class_NewsDatabaseWrapper.php create mode 100644 inc/classes/main/database/wrapper/class_PaymentsDatabaseWrapper.php create mode 100644 inc/classes/main/database/wrapper/class_UserDatabaseWrapper.php create mode 100644 inc/classes/main/database/wrapper/class_UserPointsDatabaseWrapper.php create mode 100644 inc/classes/main/debug/.htaccess create mode 100644 inc/classes/main/debug/class_DebugConsoleOutput.php create mode 100644 inc/classes/main/debug/class_DebugErrorLogOutput.php create mode 100644 inc/classes/main/debug/class_DebugWebOutput.php create mode 100644 inc/classes/main/discovery/.htaccess create mode 100644 inc/classes/main/discovery/class_ create mode 100644 inc/classes/main/discovery/class_BaseDiscovery.php create mode 100644 inc/classes/main/discovery/payment/.htaccess create mode 100644 inc/classes/main/discovery/payment/class_LocalPaymentDiscovery.php create mode 100644 inc/classes/main/factories/.htaccess create mode 100644 inc/classes/main/factories/cache/.htaccess create mode 100644 inc/classes/main/factories/cache/class_CacheFactory.php create mode 100644 inc/classes/main/factories/class_BaseFactory.php create mode 100644 inc/classes/main/factories/objects/.htaccess create mode 100644 inc/classes/main/factories/objects/class_ObjectFactory.php create mode 100644 inc/classes/main/factories/web/.htaccess create mode 100644 inc/classes/main/factories/web/class_WebNewsFactory.php create mode 100644 inc/classes/main/filter/.htaccess create mode 100644 inc/classes/main/filter/auth/.htaccess create mode 100644 inc/classes/main/filter/auth/class_UserAuthFilter.php create mode 100644 inc/classes/main/filter/change/.htaccess create mode 100644 inc/classes/main/filter/change/class_EmailChangeFilter.php create mode 100644 inc/classes/main/filter/change/class_PasswordChangeFilter.php create mode 100644 inc/classes/main/filter/checkboxes/.htaccess create mode 100644 inc/classes/main/filter/checkboxes/class_RulesAcceptedFilter.php create mode 100644 inc/classes/main/filter/class_ create mode 100644 inc/classes/main/filter/class_AbstractFilterDecorator.php create mode 100644 inc/classes/main/filter/class_BaseFilter.php create mode 100644 inc/classes/main/filter/class_FilterChain.php create mode 100644 inc/classes/main/filter/crypto/.htaccess create mode 100644 inc/classes/main/filter/crypto/class_CaptchaEncryptFilter.php create mode 100644 inc/classes/main/filter/decorator/.htaccess create mode 100644 inc/classes/main/filter/guest/.htaccess create mode 100644 inc/classes/main/filter/guest/class_UserNameIsGuestFilter.php create mode 100644 inc/classes/main/filter/news/.htaccess create mode 100644 inc/classes/main/filter/news/class_NewsDownloadFilter.php create mode 100644 inc/classes/main/filter/news/class_NewsProcessFilter.php create mode 100644 inc/classes/main/filter/null/.htaccess create mode 100644 inc/classes/main/filter/null/class_NullFilter.php create mode 100644 inc/classes/main/filter/payment/.htaccess create mode 100644 inc/classes/main/filter/payment/class_PaymentDiscoveryFilter.php create mode 100644 inc/classes/main/filter/update/.htaccess create mode 100644 inc/classes/main/filter/update/class_UserStatusConfimedUpdateFilter.php create mode 100644 inc/classes/main/filter/update/class_UserUpdateFilter.php create mode 100644 inc/classes/main/filter/validator/.htaccess create mode 100644 inc/classes/main/filter/validator/class_EmailValidatorFilter.php create mode 100644 inc/classes/main/filter/validator/class_PasswordValidatorFilter.php create mode 100644 inc/classes/main/filter/validator/class_UserNameValidatorFilter.php create mode 100644 inc/classes/main/filter/verifier/.htaccess create mode 100644 inc/classes/main/filter/verifier/class_AccountPasswordVerifierFilter.php create mode 100644 inc/classes/main/filter/verifier/class_ConfirmCodeVerifierFilter.php create mode 100644 inc/classes/main/filter/verifier/class_GraphicalCodeCaptchaVerifierFilter.php create mode 100644 inc/classes/main/filter/verifier/class_PasswordGuestVerifierFilter.php create mode 100644 inc/classes/main/filter/verifier/class_PasswordVerifierFilter.php create mode 100644 inc/classes/main/filter/verifier/class_UserGuestVerifierFilter.php create mode 100644 inc/classes/main/filter/verifier/class_UserNameVerifierFilter.php create mode 100644 inc/classes/main/filter/verifier/class_UserStatusVerifierFilter.php create mode 100644 inc/classes/main/filter/verifier/class_UserUnconfirmedVerifierFilter.php create mode 100644 inc/classes/main/helper/.htaccess create mode 100644 inc/classes/main/helper/captcha/.htaccess create mode 100644 inc/classes/main/helper/captcha/class_ create mode 100644 inc/classes/main/helper/captcha/class_BaseCaptcha.php create mode 100644 inc/classes/main/helper/captcha/images/.htaccess create mode 100644 inc/classes/main/helper/captcha/images/class_ImageHelper.php create mode 100644 inc/classes/main/helper/captcha/web/.htaccess create mode 100644 inc/classes/main/helper/captcha/web/class_GraphicalCodeCaptcha.php create mode 100644 inc/classes/main/helper/class_ create mode 100644 inc/classes/main/helper/class_BaseHelper.php create mode 100644 inc/classes/main/helper/login/.htaccess create mode 100644 inc/classes/main/helper/login/class_BaseLoginHelper.php create mode 100644 inc/classes/main/helper/web/.htaccess create mode 100644 inc/classes/main/helper/web/blocks/.htaccess create mode 100644 inc/classes/main/helper/web/blocks/class_WebBlockHelper.php create mode 100644 inc/classes/main/helper/web/class_ create mode 100644 inc/classes/main/helper/web/class_BaseWebHelper.php create mode 100644 inc/classes/main/helper/web/forms/.htaccess create mode 100644 inc/classes/main/helper/web/forms/class_WebFormHelper.php create mode 100644 inc/classes/main/helper/web/links/.htaccess create mode 100644 inc/classes/main/helper/web/links/class_WebLinkHelper.php create mode 100644 inc/classes/main/images/.htaccess create mode 100644 inc/classes/main/images/class_ create mode 100644 inc/classes/main/images/class_BaseImage.php create mode 100644 inc/classes/main/images/extended/.htaccess create mode 100644 inc/classes/main/images/extended/class_PngImage.php create mode 100644 inc/classes/main/io/.htaccess create mode 100644 inc/classes/main/io/class_FileIoStream.php create mode 100644 inc/classes/main/io/class_FrameworkDirectoryPointer.php create mode 100644 inc/classes/main/io/class_FrameworkFileInputPointer.php create mode 100644 inc/classes/main/io/class_FrameworkFileOutputPointer.php create mode 100644 inc/classes/main/language/.htaccess create mode 100644 inc/classes/main/language/class_LanguageSystem.php create mode 100644 inc/classes/main/mailer/.htaccess create mode 100644 inc/classes/main/mailer/class_ create mode 100644 inc/classes/main/mailer/class_BaseMailer.php create mode 100644 inc/classes/main/mailer/debug/.htaccess create mode 100644 inc/classes/main/mailer/debug/class_DebugMailer.php create mode 100644 inc/classes/main/output/.htaccess create mode 100644 inc/classes/main/output/class_ConsoleOutput.php create mode 100644 inc/classes/main/output/class_WebOutput.php create mode 100644 inc/classes/main/points/.htaccess create mode 100644 inc/classes/main/points/class_UserPoints.php create mode 100644 inc/classes/main/reader/.htaccess create mode 100644 inc/classes/main/reader/class_DefaultNewsReader.php create mode 100644 inc/classes/main/registration/.htaccess create mode 100644 inc/classes/main/registration/class_BaseRegistration.php create mode 100644 inc/classes/main/registry/.htaccess create mode 100644 inc/classes/main/registry/class_Registry.php create mode 100644 inc/classes/main/request/.htaccess create mode 100644 inc/classes/main/request/class_HttpRequest.php create mode 100644 inc/classes/main/resolver/.htaccess create mode 100644 inc/classes/main/resolver/action/.htaccess create mode 100644 inc/classes/main/resolver/action/class_BaseActionResolver.php create mode 100644 inc/classes/main/resolver/action/web/.htaccess create mode 100644 inc/classes/main/resolver/action/web/class_WebActionResolver.php create mode 100644 inc/classes/main/resolver/class_BaseResolver.php create mode 100644 inc/classes/main/resolver/command/.htaccess create mode 100644 inc/classes/main/resolver/command/class_BaseCommandResolver.php create mode 100644 inc/classes/main/resolver/command/image/.htaccess create mode 100644 inc/classes/main/resolver/command/image/class_ImageCommandResolver.php create mode 100644 inc/classes/main/resolver/command/web/.htaccess create mode 100644 inc/classes/main/resolver/command/web/class_ create mode 100644 inc/classes/main/resolver/command/web/class_WebCommandResolver.php create mode 100644 inc/classes/main/resolver/controller/.htaccess create mode 100644 inc/classes/main/resolver/controller/class_BaseControllerResolver.php create mode 100644 inc/classes/main/resolver/controller/image/.htaccess create mode 100644 inc/classes/main/resolver/controller/image/class_ImageControllerResolver.php create mode 100644 inc/classes/main/resolver/controller/web/.htaccess create mode 100644 inc/classes/main/resolver/controller/web/class_WebControllerResolver.php create mode 100644 inc/classes/main/response/.htaccess create mode 100644 inc/classes/main/response/class_BaseResponse.php create mode 100644 inc/classes/main/response/http/.htaccess create mode 100644 inc/classes/main/response/http/class_HttpResponse.php create mode 100644 inc/classes/main/response/image/.htaccess create mode 100644 inc/classes/main/response/image/class_ImageResponse.php create mode 100644 inc/classes/main/result/.htaccess create mode 100644 inc/classes/main/result/class_DatabaseResult.php create mode 100644 inc/classes/main/rng/.htaccess create mode 100644 inc/classes/main/rng/class_RandomNumberGenerator.php create mode 100644 inc/classes/main/template/.htaccess create mode 100644 inc/classes/main/template/class_BaseTemplateEngine.php create mode 100644 inc/classes/main/template/image/.htaccess create mode 100644 inc/classes/main/template/image/class_ImageTemplateEngine.php create mode 100644 inc/classes/main/template/mail/.htaccess create mode 100644 inc/classes/main/template/mail/class_MailTemplateEngine.php create mode 100644 inc/classes/main/template/web/.htaccess create mode 100644 inc/classes/main/template/web/class_WebTemplateEngine.php create mode 100644 inc/classes/main/user/.htaccess create mode 100644 inc/classes/main/user/class_BaseUser.php create mode 100644 inc/classes/main/user/guest/.htaccess create mode 100644 inc/classes/main/user/guest/class_Guest.php create mode 100644 inc/classes/main/user/member/.htaccess create mode 100644 inc/classes/main/user/member/class_Member.php create mode 100644 inc/classes/middleware/.htaccess create mode 100644 inc/classes/middleware/class_BaseMiddleware.php create mode 100644 inc/classes/middleware/compressor/.htaccess create mode 100644 inc/classes/middleware/compressor/class_CompressorChannel.php create mode 100644 inc/classes/middleware/database/.htaccess create mode 100644 inc/classes/middleware/database/class_DatabaseConnection.php create mode 100644 inc/classes/middleware/debug/.htaccess create mode 100644 inc/classes/middleware/debug/class_DebugMiddleware.php create mode 100644 inc/classes/middleware/io/.htaccess create mode 100644 inc/classes/middleware/io/class_FileIoHandler.php create mode 100644 inc/classes/third_party/.htaccess create mode 100644 inc/classes/third_party/akismet/.htaccess create mode 100644 inc/classes/third_party/akismet/akismet.class.php create mode 100644 inc/classes/third_party/api/.htaccess create mode 100644 inc/classes/third_party/api/primusportal/.htaccess create mode 100644 inc/classes/third_party/api/primusportal/class_PrimeraApi.php create mode 100644 inc/classes/third_party/api/wernisportal/.htaccess create mode 100644 inc/classes/third_party/api/wernisportal/class_WernisApi.php create mode 100644 inc/classes/third_party/php_mailer/.htaccess create mode 100644 inc/classes/third_party/php_mailer/ChangeLog.txt create mode 100644 inc/classes/third_party/php_mailer/LICENSE create mode 100644 inc/classes/third_party/php_mailer/README create mode 100644 inc/classes/third_party/php_mailer/class.phpmailer.php create mode 100644 inc/classes/third_party/php_mailer/class.pop3.php create mode 100644 inc/classes/third_party/php_mailer/class.smtp.php create mode 100644 inc/classes/third_party/php_mailer/docs/extending.html create mode 100644 inc/classes/third_party/php_mailer/docs/faq.html create mode 100644 inc/classes/third_party/php_mailer/docs/pop3_article.txt create mode 100644 inc/classes/third_party/php_mailer/docs/use_gmail.txt create mode 100644 inc/classes/third_party/php_mailer/examples/contents.html create mode 100644 inc/classes/third_party/php_mailer/examples/images/bkgrnd.gif create mode 100644 inc/classes/third_party/php_mailer/examples/images/phpmailer.gif create mode 100644 inc/classes/third_party/php_mailer/examples/images/phpmailer.png create mode 100644 inc/classes/third_party/php_mailer/examples/images/phpmailer_mini.gif create mode 100644 inc/classes/third_party/php_mailer/examples/index.html create mode 100644 inc/classes/third_party/php_mailer/examples/pop3_before_smtp_test.php create mode 100644 inc/classes/third_party/php_mailer/examples/test_gmail.php create mode 100644 inc/classes/third_party/php_mailer/examples/test_mail.php create mode 100644 inc/classes/third_party/php_mailer/examples/test_sendmail.php create mode 100644 inc/classes/third_party/php_mailer/examples/test_smtp.php create mode 100644 inc/classes/third_party/php_mailer/language/.htaccess create mode 100644 inc/classes/third_party/php_mailer/language/phpmailer.lang-br.php create mode 100644 inc/classes/third_party/php_mailer/language/phpmailer.lang-ca.php create mode 100644 inc/classes/third_party/php_mailer/language/phpmailer.lang-cz.php create mode 100644 inc/classes/third_party/php_mailer/language/phpmailer.lang-de.php create mode 100644 inc/classes/third_party/php_mailer/language/phpmailer.lang-dk.php create mode 100644 inc/classes/third_party/php_mailer/language/phpmailer.lang-en.php create mode 100644 inc/classes/third_party/php_mailer/language/phpmailer.lang-es.php create mode 100644 inc/classes/third_party/php_mailer/language/phpmailer.lang-et.php create mode 100644 inc/classes/third_party/php_mailer/language/phpmailer.lang-fi.php create mode 100644 inc/classes/third_party/php_mailer/language/phpmailer.lang-fo.php create mode 100644 inc/classes/third_party/php_mailer/language/phpmailer.lang-fr.php create mode 100644 inc/classes/third_party/php_mailer/language/phpmailer.lang-hu.php create mode 100644 inc/classes/third_party/php_mailer/language/phpmailer.lang-it.php create mode 100644 inc/classes/third_party/php_mailer/language/phpmailer.lang-ja.php create mode 100644 inc/classes/third_party/php_mailer/language/phpmailer.lang-nl.php create mode 100644 inc/classes/third_party/php_mailer/language/phpmailer.lang-no.php create mode 100644 inc/classes/third_party/php_mailer/language/phpmailer.lang-pl.php create mode 100644 inc/classes/third_party/php_mailer/language/phpmailer.lang-ro.php create mode 100644 inc/classes/third_party/php_mailer/language/phpmailer.lang-ru.php create mode 100644 inc/classes/third_party/php_mailer/language/phpmailer.lang-se.php create mode 100644 inc/classes/third_party/php_mailer/language/phpmailer.lang-tr.php create mode 100644 inc/classes/third_party/php_mailer/phpdoc/PHPMailer/PHPMailer.html create mode 100644 inc/classes/third_party/php_mailer/phpdoc/PHPMailer/SMTP.html create mode 100644 inc/classes/third_party/php_mailer/phpdoc/PHPMailer/_class_phpmailer_php.html create mode 100644 inc/classes/third_party/php_mailer/phpdoc/PHPMailer/_class_smtp_php.html create mode 100644 inc/classes/third_party/php_mailer/phpdoc/blank.html create mode 100644 inc/classes/third_party/php_mailer/phpdoc/classtrees_PHPMailer.html create mode 100644 inc/classes/third_party/php_mailer/phpdoc/elementindex.html create mode 100644 inc/classes/third_party/php_mailer/phpdoc/elementindex_PHPMailer.html create mode 100644 inc/classes/third_party/php_mailer/phpdoc/errors.html create mode 100644 inc/classes/third_party/php_mailer/phpdoc/index.html create mode 100644 inc/classes/third_party/php_mailer/phpdoc/li_PHPMailer.html create mode 100644 inc/classes/third_party/php_mailer/phpdoc/media/banner.css create mode 100644 inc/classes/third_party/php_mailer/phpdoc/media/stylesheet.css create mode 100644 inc/classes/third_party/php_mailer/phpdoc/packages.html create mode 100644 inc/classes/third_party/php_mailer/test/phpmailer_test.php create mode 100644 inc/classes/third_party/php_mailer/test/phpunit.php create mode 100644 inc/classes/third_party/php_mailer/test/test.png create mode 100644 inc/config.php create mode 100644 inc/config/.htaccess create mode 100644 inc/config/class_FrameworkConfiguration.php create mode 100644 inc/config/config-hubmaster.php create mode 100644 inc/database.php create mode 100644 inc/database/.htaccess create mode 100644 inc/database/lib-local.php create mode 100644 inc/file_io.php create mode 100644 inc/includes.php create mode 100644 inc/language.php create mode 100644 inc/language/.htaccess create mode 100644 inc/loader/.htaccess create mode 100644 inc/loader/class_ClassLoader.php create mode 100644 inc/output.php create mode 100644 inc/selector.php create mode 100644 templates/.htaccess create mode 100644 templates/_compiled/.htaccess create mode 100644 templates/de/.htaccess create mode 100644 templates/de/code/.htaccess create mode 100644 templates/de/code/emergency_exit.ctp create mode 100644 templates/de/code/footer_msg.ctp create mode 100644 templates/de/code/header.ctp create mode 100644 templates/de/html/.htaccess create mode 100644 templates/images/.htaccess create mode 100644 templates/images/_cache/.htaccess create mode 100644 templates/images/de/.htaccess create mode 100644 templates/images/de/image/.htaccess create mode 100644 templates/images/de/image/base_image.itp create mode 100644 templates/images/de/image/emergency_exit.itp create mode 100644 tests/ConfigTest.php create mode 100644 tests/RegistryTest.php create mode 100644 tests/RequestTest.php create mode 100644 tests/Test.php create mode 100644 tests/all-tests.sh create mode 100644 tests/old/contract-test.php create mode 100644 tests/old/loader-test.php create mode 100644 tests/old/personell-test.php create mode 100644 tests/unittest.sh diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..0f127fc1 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,549 @@ +* text=auto !eol +devel/.htaccess -text +devel/class_Debug.php -text +inc/.htaccess -text +inc/classes.php -text +inc/classes/.htaccess -text +inc/classes/exceptions/.htaccess -text +inc/classes/exceptions/actions/.htaccess -text +inc/classes/exceptions/actions/class_InvalidActionException.php -text +inc/classes/exceptions/auth/.htaccess -text +inc/classes/exceptions/auth/class_UserAuthorizationException.php -text +inc/classes/exceptions/class_ -text +inc/classes/exceptions/class_FrameworkException.php -text +inc/classes/exceptions/compressor/.htaccess -text +inc/classes/exceptions/compressor/class_MismatchingCompressorsException.php -text +inc/classes/exceptions/container/.htaccess -text +inc/classes/exceptions/container/class_ContainerItemIsNoArrayException.php -text +inc/classes/exceptions/container/class_ContainerItemIsNullException.php -text +inc/classes/exceptions/container/class_ContainerMaybeDamagedException.php -text +inc/classes/exceptions/controller/.htaccess -text +inc/classes/exceptions/controller/class_DefaultControllerException.php -text +inc/classes/exceptions/controller/class_InvalidControllerException.php -text +inc/classes/exceptions/criteria/.htaccess -text +inc/classes/exceptions/crypto/.htaccess -text +inc/classes/exceptions/crypto/class_EncryptInvalidLengthException.php -text +inc/classes/exceptions/crypto/class_EncryptMissingException.php -text +inc/classes/exceptions/database/.htaccess -text +inc/classes/exceptions/database/class_ -text +inc/classes/exceptions/database/class_DatabaseException.php -text +inc/classes/exceptions/database/general/.htaccess -text +inc/classes/exceptions/database/general/class_DatabaseUpdateSupportException.php -text +inc/classes/exceptions/database/general/class_SqlException.php -text +inc/classes/exceptions/database/local_file/.htaccess -text +inc/classes/exceptions/database/local_file/class_SavePathIsEmptyException.php -text +inc/classes/exceptions/database/local_file/class_SavePathIsNoDirectoryException.php -text +inc/classes/exceptions/database/local_file/class_SavePathReadProtectedException.php -text +inc/classes/exceptions/database/local_file/class_SavePathWriteProtectedException.php -text +inc/classes/exceptions/database/wrapper/.htaccess -text +inc/classes/exceptions/database/wrapper/class_WrapperUserNameNotFoundException.php -text +inc/classes/exceptions/filter/.htaccess -text +inc/classes/exceptions/filter/class_FilterChainException.php -text +inc/classes/exceptions/helper/.htaccess -text +inc/classes/exceptions/helper/class_FormClosedException.php -text +inc/classes/exceptions/helper/class_FormGroupClosedException.php -text +inc/classes/exceptions/helper/class_FormOpenedException.php -text +inc/classes/exceptions/helper/class_HelperGroupAlreadyCreatedException.php -text +inc/classes/exceptions/helper/class_HelperNoPreviousOpenedSubGroupException.php -text +inc/classes/exceptions/helper/class_HelperSubGroupAlreadyCreatedException.php -text +inc/classes/exceptions/helper/class_InvalidFormNameException.php -text +inc/classes/exceptions/helper/class_NoGroupOpenedException.php -text +inc/classes/exceptions/helper/class_UserInstanceMissingException.php -text +inc/classes/exceptions/io/.htaccess -text +inc/classes/exceptions/io/class_DirPointerNotOpenedException.php -text +inc/classes/exceptions/io/class_FileNotFoundException.php -text +inc/classes/exceptions/io/class_FilePointerNotOpenedException.php -text +inc/classes/exceptions/io/class_FileReadProtectedException.php -text +inc/classes/exceptions/io/class_InvalidDataLengthException.php -text +inc/classes/exceptions/io/class_InvalidDirectoryResourceException.php -text +inc/classes/exceptions/io/class_InvalidMD5ChecksumException.php -text +inc/classes/exceptions/io/class_PathIsEmptyException.php -text +inc/classes/exceptions/io/class_PathIsNoDirectoryException.php -text +inc/classes/exceptions/io/class_PathReadProtectedException.php -text +inc/classes/exceptions/language/.htaccess -text +inc/classes/exceptions/language/class_InvalidLanguagePathStringException.php -text +inc/classes/exceptions/language/class_LanguagePathIsEmptyException.php -text +inc/classes/exceptions/language/class_LanguagePathIsNoDirectoryException.php -text +inc/classes/exceptions/language/class_LanguagePathReadProtectedException.php -text +inc/classes/exceptions/language/class_MissingFileIoHandlerException.php -text +inc/classes/exceptions/language/class_MissingLanguageHandlerException.php -text +inc/classes/exceptions/main/.htaccess -text +inc/classes/exceptions/main/class_AssertionException.php -text +inc/classes/exceptions/main/class_ClassMismatchException.php -text +inc/classes/exceptions/main/class_ClassNotFoundException.php -text +inc/classes/exceptions/main/class_ConfigEntryIsEmptyException.php -text +inc/classes/exceptions/main/class_ConfigEntryNotFoundException.php -text +inc/classes/exceptions/main/class_DimNotFoundInArrayException.php -text +inc/classes/exceptions/main/class_EmptyVariableException.php -text +inc/classes/exceptions/main/class_ExceptionNotFoundException.php -text +inc/classes/exceptions/main/class_FatalErrorException.php -text +inc/classes/exceptions/main/class_GetterNotFoundException.php -text +inc/classes/exceptions/main/class_InvalidArrayCountException.php -text +inc/classes/exceptions/main/class_InvalidCommandException.php -text +inc/classes/exceptions/main/class_InvalidCommandInstanceException.php -text +inc/classes/exceptions/main/class_InvalidInterfaceException.php -text +inc/classes/exceptions/main/class_InvalidObjectException.php -text +inc/classes/exceptions/main/class_MissingArrayElementsException.php -text +inc/classes/exceptions/main/class_MissingDecimalsThousandsSeperatorException.php -text +inc/classes/exceptions/main/class_MissingMethodException.php -text +inc/classes/exceptions/main/class_NoArrayCreatedException.php -text +inc/classes/exceptions/main/class_NoArrayException.php -text +inc/classes/exceptions/main/class_NoObjectException.php -text +inc/classes/exceptions/main/class_NullPointerException.php -text +inc/classes/exceptions/main/class_ResponseHeadersAlreadySentException.php -text +inc/classes/exceptions/main/class_VariableIsNotSetException.php -text +inc/classes/exceptions/result/.htaccess -text +inc/classes/exceptions/result/class_InvalidDatabaseResultException.php -text +inc/classes/exceptions/result/class_ResultUpdateException.php -text +inc/classes/exceptions/template/.htaccess -text +inc/classes/exceptions/template/class_BasePathIsEmptyException.php -text +inc/classes/exceptions/template/class_BasePathIsNoDirectoryException.php -text +inc/classes/exceptions/template/class_BasePathReadProtectedException.php -text +inc/classes/exceptions/template/class_InvalidBasePathStringException.php -text +inc/classes/exceptions/template/class_UnexpectedTemplateTypeException.php -text +inc/classes/exceptions/template/class_UnsupportedTemplateEngineException.php -text +inc/classes/exceptions/template/class_ViewHelperNotFoundException.php -text +inc/classes/exceptions/user/.htaccess -text +inc/classes/exceptions/user/class_AccountPasswordMismatchException.php -text +inc/classes/exceptions/user/class_UserEmailMissingException.php -text +inc/classes/exceptions/user/class_UserPasswordMismatchException.php -text +inc/classes/exceptions/user/class_UsernameMissingException.php -text +inc/classes/exceptions/xml/.htaccess -text +inc/classes/exceptions/xml/class_InvalidXmlNodeException.php -text +inc/classes/exceptions/xml/class_XmlNodeMismatchException.php -text +inc/classes/exceptions/xml/class_XmlParserException.php -text +inc/classes/interfaces/.htaccess -text +inc/classes/interfaces/actions/.htaccess -text +inc/classes/interfaces/actions/class_PerformableAction.php -text +inc/classes/interfaces/actions/commands/.htaccess -text +inc/classes/interfaces/actions/commands/class_Commandable.php -text +inc/classes/interfaces/application/.htaccess -text +inc/classes/interfaces/application/class_ManageableApplication.php -text +inc/classes/interfaces/auth/.htaccess -text +inc/classes/interfaces/auth/class_Authorizeable.php -text +inc/classes/interfaces/cache/.htaccess -text +inc/classes/interfaces/cache/class_Cacheable.php -text +inc/classes/interfaces/captcha/.htaccess -text +inc/classes/interfaces/captcha/class_SolveableCaptcha.php -text +inc/classes/interfaces/class_ -text +inc/classes/interfaces/class_FrameworkInterface.php -text +inc/classes/interfaces/compressor/.htaccess -text +inc/classes/interfaces/compressor/class_Compressor.php -text +inc/classes/interfaces/controller/.htaccess -text +inc/classes/interfaces/controller/class_Controller.php -text +inc/classes/interfaces/criteria/.htaccess -text +inc/classes/interfaces/criteria/class_Criteria.php -text +inc/classes/interfaces/criteria/extended/.htaccess -text +inc/classes/interfaces/criteria/extended/class_LocalSearchCriteria.php -text +inc/classes/interfaces/criteria/extended/class_LocalUpdateCriteria.php -text +inc/classes/interfaces/criteria/extended/class_StoreableCriteria.php -text +inc/classes/interfaces/crypto/.htaccess -text +inc/classes/interfaces/crypto/class_Cryptable.php -text +inc/classes/interfaces/database/.htaccess -text +inc/classes/interfaces/database/class_FrameworkDatabaseInterface.php -text +inc/classes/interfaces/database/class_Updateable.php -text +inc/classes/interfaces/database/frontend/.htaccess -text +inc/classes/interfaces/database/frontend/class_DatabaseFrontendInterface.php -text +inc/classes/interfaces/database/middleware/.htaccess -text +inc/classes/interfaces/database/middleware/class_DatabaseConnector.php -text +inc/classes/interfaces/debug/.htaccess -text +inc/classes/interfaces/debug/class_Debugger.php -text +inc/classes/interfaces/discovery/.htaccess -text +inc/classes/interfaces/discovery/class_Discoverable.php -text +inc/classes/interfaces/filter/.htaccess -text +inc/classes/interfaces/filter/class_Filterable.php -text +inc/classes/interfaces/helper/.htaccess -text +inc/classes/interfaces/helper/class_HelpableLogin.php -text +inc/classes/interfaces/helper/class_HelpableTemplate.php -text +inc/classes/interfaces/io/.htaccess -text +inc/classes/interfaces/io/class_Streamable.php -text +inc/classes/interfaces/io/file/.htaccess -text +inc/classes/interfaces/io/file/class_FileInputStreamer.php -text +inc/classes/interfaces/io/file/class_FileOutputStreamer.php -text +inc/classes/interfaces/io/output/.htaccess -text +inc/classes/interfaces/io/output/class_OutputStreamer.php -text +inc/classes/interfaces/language/.htaccess -text +inc/classes/interfaces/language/class_ManageableLanguage.php -text +inc/classes/interfaces/login/.htaccess -text +inc/classes/interfaces/login/class_LoginableUser.php -text +inc/classes/interfaces/mailer/.htaccess -text +inc/classes/interfaces/mailer/class_DeliverableMail.php -text +inc/classes/interfaces/reader/.htaccess -text +inc/classes/interfaces/reader/class_ReadableNews.php -text +inc/classes/interfaces/registration/.htaccess -text +inc/classes/interfaces/registration/class_UserRegister.php -text +inc/classes/interfaces/registry/.htaccess -text +inc/classes/interfaces/registry/class_Register.php -text +inc/classes/interfaces/registry/class_Registerable.php -text +inc/classes/interfaces/request/.htaccess -text +inc/classes/interfaces/request/class_Requestable.php -text +inc/classes/interfaces/resolver/.htaccess -text +inc/classes/interfaces/resolver/actions/.htaccess -text +inc/classes/interfaces/resolver/actions/class_ActionResolver.php -text +inc/classes/interfaces/resolver/class_Resolver.php -text +inc/classes/interfaces/resolver/commands/.htaccess -text +inc/classes/interfaces/resolver/commands/class_CommandResolver.php -text +inc/classes/interfaces/resolver/controller/.htaccess -text +inc/classes/interfaces/resolver/controller/class_ControllerResolver.php -text +inc/classes/interfaces/response/.htaccess -text +inc/classes/interfaces/response/class_Responseable.php -text +inc/classes/interfaces/result/.htaccess -text +inc/classes/interfaces/result/class_SearchableResult.php -text +inc/classes/interfaces/result/class_UpdateableResult.php -text +inc/classes/interfaces/template/.htaccess -text +inc/classes/interfaces/template/class_CompileableTemplate.php -text +inc/classes/interfaces/template/view/class_ViewHelper.php -text +inc/classes/interfaces/user/.htaccess -text +inc/classes/interfaces/user/class_ManageableAccount.php -text +inc/classes/interfaces/user/extended/.htaccess -text +inc/classes/interfaces/user/extended/class_ManageableGuest.php -text +inc/classes/interfaces/user/extended/class_ManageableMember.php -text +inc/classes/main/.htaccess -text +inc/classes/main/actions/.htaccess -text +inc/classes/main/actions/class_ -text +inc/classes/main/actions/class_BaseAction.php -text +inc/classes/main/actions/post_registration/.htaccess -text +inc/classes/main/actions/post_registration/class_LoginAfterRegistrationAction.php -text +inc/classes/main/actions/web/.htaccess -text +inc/classes/main/actions/web/class_WebLoginProfileAction.php -text +inc/classes/main/application/.htaccess -text +inc/classes/main/application/class_BaseApplication.php -text +inc/classes/main/auth/.htaccess -text +inc/classes/main/auth/class_CookieAuth.php -text +inc/classes/main/cache/.htaccess -text +inc/classes/main/cache/class_MemoryCache.php -text +inc/classes/main/class_ -text +inc/classes/main/class_Base -text +inc/classes/main/class_BaseFrameworkSystem.php -text +inc/classes/main/class_FrameworkArrayObject.php -text +inc/classes/main/commands/.htaccess -text +inc/classes/main/commands/class_ -text +inc/classes/main/commands/class_BaseCommand.php -text +inc/classes/main/commands/image/.htaccess -text +inc/classes/main/commands/image/class_ImageCodeCaptchaCommand.php -text +inc/classes/main/commands/web/.htaccess -text +inc/classes/main/commands/web/class_ -text +inc/classes/main/commands/web/class_WebConfirmCommand.php -text +inc/classes/main/commands/web/class_WebDoFormCommand.php -text +inc/classes/main/commands/web/class_WebHomeCommand.php -text +inc/classes/main/commands/web/class_WebLoginAreaCommand.php -text +inc/classes/main/commands/web/class_WebLoginCommand.php -text +inc/classes/main/commands/web/class_WebLoginFailedCommand.php -text +inc/classes/main/commands/web/class_WebLogoutCommand.php -text +inc/classes/main/commands/web/class_WebLogoutDoneCommand.php -text +inc/classes/main/commands/web/class_WebRegisterCommand.php -text +inc/classes/main/commands/web/class_WebResendLinkCommand.php -text +inc/classes/main/compressor/.htaccess -text +inc/classes/main/compressor/class_Bzip2Compressor.php -text +inc/classes/main/compressor/class_GzipCompressor.php -text +inc/classes/main/compressor/class_NullCompressor.php -text +inc/classes/main/console/.htaccess -text +inc/classes/main/console/class_ConsoleTools.php -text +inc/classes/main/controller/.htaccess -text +inc/classes/main/controller/captcha/.htaccess -text +inc/classes/main/controller/captcha/class_ImageCodeCaptchaController.php -text +inc/classes/main/controller/class_ -text +inc/classes/main/controller/class_BaseController.php -text +inc/classes/main/controller/form/.htaccess -text +inc/classes/main/controller/form/class_WebDoFormController.php -text +inc/classes/main/controller/image/.htaccess -text +inc/classes/main/controller/image/class_ImageDefaultController.php -text +inc/classes/main/controller/login/.htaccess -text +inc/classes/main/controller/login/class_WebLoginAreaController.php -text +inc/classes/main/controller/web/.htaccess -text +inc/classes/main/controller/web/class_ -text +inc/classes/main/controller/web/class_WebConfirmController.php -text +inc/classes/main/controller/web/class_WebDefaultController.php -text +inc/classes/main/controller/web/class_WebDefaultNewsController.php -text +inc/classes/main/controller/web/class_WebLoginController.php -text +inc/classes/main/controller/web/class_WebLoginFailedController.php -text +inc/classes/main/controller/web/class_WebLogoutController.php -text +inc/classes/main/controller/web/class_WebLogoutDoneController.php -text +inc/classes/main/controller/web/class_WebRegisterController.php -text +inc/classes/main/controller/web/class_WebStatusController.php -text +inc/classes/main/criteria/.htaccess -text +inc/classes/main/criteria/class_DataSetCriteria.php -text +inc/classes/main/criteria/class_SearchCriteria.php -text +inc/classes/main/criteria/class_UpdateCriteria.php -text +inc/classes/main/crypto/.htaccess -text +inc/classes/main/crypto/class_CryptoHelper.php -text +inc/classes/main/database/.htaccess -text +inc/classes/main/database/class_ -text +inc/classes/main/database/class_BaseDatabaseFrontend.php -text +inc/classes/main/database/class_BaseDatabaseWrapper.php -text +inc/classes/main/database/databases/.htaccess -text +inc/classes/main/database/databases/class_LocalFileDatabase.php -text +inc/classes/main/database/wrapper/.htaccess -text +inc/classes/main/database/wrapper/class_NewsDatabaseWrapper.php -text +inc/classes/main/database/wrapper/class_PaymentsDatabaseWrapper.php -text +inc/classes/main/database/wrapper/class_UserDatabaseWrapper.php -text +inc/classes/main/database/wrapper/class_UserPointsDatabaseWrapper.php -text +inc/classes/main/debug/.htaccess -text +inc/classes/main/debug/class_DebugConsoleOutput.php -text +inc/classes/main/debug/class_DebugErrorLogOutput.php -text +inc/classes/main/debug/class_DebugWebOutput.php -text +inc/classes/main/discovery/.htaccess -text +inc/classes/main/discovery/class_ -text +inc/classes/main/discovery/class_BaseDiscovery.php -text +inc/classes/main/discovery/payment/.htaccess -text +inc/classes/main/discovery/payment/class_LocalPaymentDiscovery.php -text +inc/classes/main/factories/.htaccess -text +inc/classes/main/factories/cache/.htaccess -text +inc/classes/main/factories/cache/class_CacheFactory.php -text +inc/classes/main/factories/class_BaseFactory.php -text +inc/classes/main/factories/objects/.htaccess -text +inc/classes/main/factories/objects/class_ObjectFactory.php -text +inc/classes/main/factories/web/.htaccess -text +inc/classes/main/factories/web/class_WebNewsFactory.php -text +inc/classes/main/filter/.htaccess -text +inc/classes/main/filter/auth/.htaccess -text +inc/classes/main/filter/auth/class_UserAuthFilter.php -text +inc/classes/main/filter/change/.htaccess -text +inc/classes/main/filter/change/class_EmailChangeFilter.php -text +inc/classes/main/filter/change/class_PasswordChangeFilter.php -text +inc/classes/main/filter/checkboxes/.htaccess -text +inc/classes/main/filter/checkboxes/class_RulesAcceptedFilter.php -text +inc/classes/main/filter/class_ -text +inc/classes/main/filter/class_AbstractFilterDecorator.php -text +inc/classes/main/filter/class_BaseFilter.php -text +inc/classes/main/filter/class_FilterChain.php -text +inc/classes/main/filter/crypto/.htaccess -text +inc/classes/main/filter/crypto/class_CaptchaEncryptFilter.php -text +inc/classes/main/filter/decorator/.htaccess -text +inc/classes/main/filter/guest/.htaccess -text +inc/classes/main/filter/guest/class_UserNameIsGuestFilter.php -text +inc/classes/main/filter/news/.htaccess -text +inc/classes/main/filter/news/class_NewsDownloadFilter.php -text +inc/classes/main/filter/news/class_NewsProcessFilter.php -text +inc/classes/main/filter/null/.htaccess -text +inc/classes/main/filter/null/class_NullFilter.php -text +inc/classes/main/filter/payment/.htaccess -text +inc/classes/main/filter/payment/class_PaymentDiscoveryFilter.php -text +inc/classes/main/filter/update/.htaccess -text +inc/classes/main/filter/update/class_UserStatusConfimedUpdateFilter.php -text +inc/classes/main/filter/update/class_UserUpdateFilter.php -text +inc/classes/main/filter/validator/.htaccess -text +inc/classes/main/filter/validator/class_EmailValidatorFilter.php -text +inc/classes/main/filter/validator/class_PasswordValidatorFilter.php -text +inc/classes/main/filter/validator/class_UserNameValidatorFilter.php -text +inc/classes/main/filter/verifier/.htaccess -text +inc/classes/main/filter/verifier/class_AccountPasswordVerifierFilter.php -text +inc/classes/main/filter/verifier/class_ConfirmCodeVerifierFilter.php -text +inc/classes/main/filter/verifier/class_GraphicalCodeCaptchaVerifierFilter.php -text +inc/classes/main/filter/verifier/class_PasswordGuestVerifierFilter.php -text +inc/classes/main/filter/verifier/class_PasswordVerifierFilter.php -text +inc/classes/main/filter/verifier/class_UserGuestVerifierFilter.php -text +inc/classes/main/filter/verifier/class_UserNameVerifierFilter.php -text +inc/classes/main/filter/verifier/class_UserStatusVerifierFilter.php -text +inc/classes/main/filter/verifier/class_UserUnconfirmedVerifierFilter.php -text +inc/classes/main/helper/.htaccess -text +inc/classes/main/helper/captcha/.htaccess -text +inc/classes/main/helper/captcha/class_ -text +inc/classes/main/helper/captcha/class_BaseCaptcha.php -text +inc/classes/main/helper/captcha/images/.htaccess -text +inc/classes/main/helper/captcha/images/class_ImageHelper.php -text +inc/classes/main/helper/captcha/web/.htaccess -text +inc/classes/main/helper/captcha/web/class_GraphicalCodeCaptcha.php -text +inc/classes/main/helper/class_ -text +inc/classes/main/helper/class_BaseHelper.php -text +inc/classes/main/helper/login/.htaccess -text +inc/classes/main/helper/login/class_BaseLoginHelper.php -text +inc/classes/main/helper/web/.htaccess -text +inc/classes/main/helper/web/blocks/.htaccess -text +inc/classes/main/helper/web/blocks/class_WebBlockHelper.php -text +inc/classes/main/helper/web/class_ -text +inc/classes/main/helper/web/class_BaseWebHelper.php -text +inc/classes/main/helper/web/forms/.htaccess -text +inc/classes/main/helper/web/forms/class_WebFormHelper.php -text +inc/classes/main/helper/web/links/.htaccess -text +inc/classes/main/helper/web/links/class_WebLinkHelper.php -text +inc/classes/main/images/.htaccess -text +inc/classes/main/images/class_ -text +inc/classes/main/images/class_BaseImage.php -text +inc/classes/main/images/extended/.htaccess -text +inc/classes/main/images/extended/class_PngImage.php -text +inc/classes/main/io/.htaccess -text +inc/classes/main/io/class_FileIoStream.php -text +inc/classes/main/io/class_FrameworkDirectoryPointer.php -text +inc/classes/main/io/class_FrameworkFileInputPointer.php -text +inc/classes/main/io/class_FrameworkFileOutputPointer.php -text +inc/classes/main/language/.htaccess -text +inc/classes/main/language/class_LanguageSystem.php -text +inc/classes/main/mailer/.htaccess -text +inc/classes/main/mailer/class_ -text +inc/classes/main/mailer/class_BaseMailer.php -text +inc/classes/main/mailer/debug/.htaccess -text +inc/classes/main/mailer/debug/class_DebugMailer.php -text +inc/classes/main/output/.htaccess -text +inc/classes/main/output/class_ConsoleOutput.php -text +inc/classes/main/output/class_WebOutput.php -text +inc/classes/main/points/.htaccess -text +inc/classes/main/points/class_UserPoints.php -text +inc/classes/main/reader/.htaccess -text +inc/classes/main/reader/class_DefaultNewsReader.php -text +inc/classes/main/registration/.htaccess -text +inc/classes/main/registration/class_BaseRegistration.php -text +inc/classes/main/registry/.htaccess -text +inc/classes/main/registry/class_Registry.php -text +inc/classes/main/request/.htaccess -text +inc/classes/main/request/class_HttpRequest.php -text +inc/classes/main/resolver/.htaccess -text +inc/classes/main/resolver/action/.htaccess -text +inc/classes/main/resolver/action/class_BaseActionResolver.php -text +inc/classes/main/resolver/action/web/.htaccess -text +inc/classes/main/resolver/action/web/class_WebActionResolver.php -text +inc/classes/main/resolver/class_BaseResolver.php -text +inc/classes/main/resolver/command/.htaccess -text +inc/classes/main/resolver/command/class_BaseCommandResolver.php -text +inc/classes/main/resolver/command/image/.htaccess -text +inc/classes/main/resolver/command/image/class_ImageCommandResolver.php -text +inc/classes/main/resolver/command/web/.htaccess -text +inc/classes/main/resolver/command/web/class_ -text +inc/classes/main/resolver/command/web/class_WebCommandResolver.php -text +inc/classes/main/resolver/controller/.htaccess -text +inc/classes/main/resolver/controller/class_BaseControllerResolver.php -text +inc/classes/main/resolver/controller/image/.htaccess -text +inc/classes/main/resolver/controller/image/class_ImageControllerResolver.php -text +inc/classes/main/resolver/controller/web/.htaccess -text +inc/classes/main/resolver/controller/web/class_WebControllerResolver.php -text +inc/classes/main/response/.htaccess -text +inc/classes/main/response/class_BaseResponse.php -text +inc/classes/main/response/http/.htaccess -text +inc/classes/main/response/http/class_HttpResponse.php -text +inc/classes/main/response/image/.htaccess -text +inc/classes/main/response/image/class_ImageResponse.php -text +inc/classes/main/result/.htaccess -text +inc/classes/main/result/class_DatabaseResult.php -text +inc/classes/main/rng/.htaccess -text +inc/classes/main/rng/class_RandomNumberGenerator.php -text +inc/classes/main/template/.htaccess -text +inc/classes/main/template/class_BaseTemplateEngine.php -text +inc/classes/main/template/image/.htaccess -text +inc/classes/main/template/image/class_ImageTemplateEngine.php -text +inc/classes/main/template/mail/.htaccess -text +inc/classes/main/template/mail/class_MailTemplateEngine.php -text +inc/classes/main/template/web/.htaccess -text +inc/classes/main/template/web/class_WebTemplateEngine.php -text +inc/classes/main/user/.htaccess -text +inc/classes/main/user/class_BaseUser.php -text +inc/classes/main/user/guest/.htaccess -text +inc/classes/main/user/guest/class_Guest.php -text +inc/classes/main/user/member/.htaccess -text +inc/classes/main/user/member/class_Member.php -text +inc/classes/middleware/.htaccess -text +inc/classes/middleware/class_BaseMiddleware.php -text +inc/classes/middleware/compressor/.htaccess -text +inc/classes/middleware/compressor/class_CompressorChannel.php -text +inc/classes/middleware/database/.htaccess -text +inc/classes/middleware/database/class_DatabaseConnection.php -text +inc/classes/middleware/debug/.htaccess -text +inc/classes/middleware/debug/class_DebugMiddleware.php -text +inc/classes/middleware/io/.htaccess -text +inc/classes/middleware/io/class_FileIoHandler.php -text +inc/classes/third_party/.htaccess -text +inc/classes/third_party/akismet/.htaccess -text +inc/classes/third_party/akismet/akismet.class.php -text +inc/classes/third_party/api/.htaccess -text +inc/classes/third_party/api/primusportal/.htaccess -text +inc/classes/third_party/api/primusportal/class_PrimeraApi.php -text +inc/classes/third_party/api/wernisportal/.htaccess -text +inc/classes/third_party/api/wernisportal/class_WernisApi.php -text +inc/classes/third_party/php_mailer/.htaccess -text +inc/classes/third_party/php_mailer/ChangeLog.txt -text +inc/classes/third_party/php_mailer/LICENSE -text +inc/classes/third_party/php_mailer/README -text +inc/classes/third_party/php_mailer/class.phpmailer.php -text +inc/classes/third_party/php_mailer/class.pop3.php -text +inc/classes/third_party/php_mailer/class.smtp.php -text +inc/classes/third_party/php_mailer/docs/extending.html -text +inc/classes/third_party/php_mailer/docs/faq.html -text +inc/classes/third_party/php_mailer/docs/pop3_article.txt -text +inc/classes/third_party/php_mailer/docs/use_gmail.txt -text +inc/classes/third_party/php_mailer/examples/contents.html -text +inc/classes/third_party/php_mailer/examples/images/bkgrnd.gif -text +inc/classes/third_party/php_mailer/examples/images/phpmailer.gif -text +inc/classes/third_party/php_mailer/examples/images/phpmailer.png -text +inc/classes/third_party/php_mailer/examples/images/phpmailer_mini.gif -text +inc/classes/third_party/php_mailer/examples/index.html -text +inc/classes/third_party/php_mailer/examples/pop3_before_smtp_test.php -text +inc/classes/third_party/php_mailer/examples/test_gmail.php -text +inc/classes/third_party/php_mailer/examples/test_mail.php -text +inc/classes/third_party/php_mailer/examples/test_sendmail.php -text +inc/classes/third_party/php_mailer/examples/test_smtp.php -text +inc/classes/third_party/php_mailer/language/.htaccess -text +inc/classes/third_party/php_mailer/language/phpmailer.lang-br.php -text +inc/classes/third_party/php_mailer/language/phpmailer.lang-ca.php -text +inc/classes/third_party/php_mailer/language/phpmailer.lang-cz.php -text +inc/classes/third_party/php_mailer/language/phpmailer.lang-de.php -text +inc/classes/third_party/php_mailer/language/phpmailer.lang-dk.php -text +inc/classes/third_party/php_mailer/language/phpmailer.lang-en.php -text +inc/classes/third_party/php_mailer/language/phpmailer.lang-es.php -text +inc/classes/third_party/php_mailer/language/phpmailer.lang-et.php -text +inc/classes/third_party/php_mailer/language/phpmailer.lang-fi.php -text +inc/classes/third_party/php_mailer/language/phpmailer.lang-fo.php -text +inc/classes/third_party/php_mailer/language/phpmailer.lang-fr.php -text +inc/classes/third_party/php_mailer/language/phpmailer.lang-hu.php -text +inc/classes/third_party/php_mailer/language/phpmailer.lang-it.php -text +inc/classes/third_party/php_mailer/language/phpmailer.lang-ja.php -text +inc/classes/third_party/php_mailer/language/phpmailer.lang-nl.php -text +inc/classes/third_party/php_mailer/language/phpmailer.lang-no.php -text +inc/classes/third_party/php_mailer/language/phpmailer.lang-pl.php -text +inc/classes/third_party/php_mailer/language/phpmailer.lang-ro.php -text +inc/classes/third_party/php_mailer/language/phpmailer.lang-ru.php -text +inc/classes/third_party/php_mailer/language/phpmailer.lang-se.php -text +inc/classes/third_party/php_mailer/language/phpmailer.lang-tr.php -text +inc/classes/third_party/php_mailer/phpdoc/PHPMailer/PHPMailer.html -text +inc/classes/third_party/php_mailer/phpdoc/PHPMailer/SMTP.html -text +inc/classes/third_party/php_mailer/phpdoc/PHPMailer/_class_phpmailer_php.html -text +inc/classes/third_party/php_mailer/phpdoc/PHPMailer/_class_smtp_php.html -text +inc/classes/third_party/php_mailer/phpdoc/blank.html -text +inc/classes/third_party/php_mailer/phpdoc/classtrees_PHPMailer.html -text +inc/classes/third_party/php_mailer/phpdoc/elementindex.html -text +inc/classes/third_party/php_mailer/phpdoc/elementindex_PHPMailer.html -text +inc/classes/third_party/php_mailer/phpdoc/errors.html -text +inc/classes/third_party/php_mailer/phpdoc/index.html -text +inc/classes/third_party/php_mailer/phpdoc/li_PHPMailer.html -text +inc/classes/third_party/php_mailer/phpdoc/media/banner.css -text +inc/classes/third_party/php_mailer/phpdoc/media/stylesheet.css -text +inc/classes/third_party/php_mailer/phpdoc/packages.html -text +inc/classes/third_party/php_mailer/test/phpmailer_test.php -text +inc/classes/third_party/php_mailer/test/phpunit.php -text +inc/classes/third_party/php_mailer/test/test.png -text +inc/config.php -text +inc/config/.htaccess -text +inc/config/class_FrameworkConfiguration.php -text +inc/config/config-hubmaster.php -text +inc/database.php -text +inc/database/.htaccess -text +inc/database/lib-local.php -text +inc/file_io.php -text +inc/includes.php -text +inc/language.php -text +inc/language/.htaccess -text +inc/loader/.htaccess -text +inc/loader/class_ClassLoader.php -text +inc/output.php -text +inc/selector.php -text +templates/.htaccess -text +templates/_compiled/.htaccess -text +templates/de/.htaccess -text +templates/de/code/.htaccess -text +templates/de/code/emergency_exit.ctp -text +templates/de/code/footer_msg.ctp -text +templates/de/code/header.ctp -text +templates/de/html/.htaccess -text +templates/images/.htaccess -text +templates/images/_cache/.htaccess -text +templates/images/de/.htaccess -text +templates/images/de/image/.htaccess -text +templates/images/de/image/base_image.itp -text +templates/images/de/image/emergency_exit.itp -text +tests/ConfigTest.php -text +tests/RegistryTest.php -text +tests/RequestTest.php -text +tests/Test.php -text +tests/all-tests.sh -text +tests/old/contract-test.php -text +tests/old/loader-test.php -text +tests/old/personell-test.php -text +tests/unittest.sh -text diff --git a/devel/.htaccess b/devel/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/devel/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/devel/class_Debug.php b/devel/class_Debug.php new file mode 100644 index 00000000..a732cb85 --- /dev/null +++ b/devel/class_Debug.php @@ -0,0 +1,53 @@ + + * @version 0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class Debug { + // Constructor + public function __construct () { + // eval()-Befehle debuggen + //define('DEBUG_EVAL', true); + // SimulatorBase debuggen (VORSICHT! SEHR VIELE DEBUG-MELDUNGEN!!!) + //define('DEBUG_CORE', true); + //////// Objekte debuggen (ausgeben) //////// + // Datenbank-Objekt debuggen + //define('DEBUG_DATABASE_OBJ', true); + //////// Alles unteren debuggen //////// + //define('DEBUG_ALL', true); + // Kompressor debuggen + //define('DEBUG_COMPRESSOR', true); + // Datenbankschichten debuggen + //define('DEBUG_DATABASE', true); + // Template-System debuggen + //define('DEBUG_TEMPLATE', true); + // Konfiguration debuggen + //define('DEBUG_CONFIG', true); + } +} + +/** + * Initialize the dummy debug class + */ +$dummy = new Debug(); +unset($dummy); + +// +?> diff --git a/inc/.htaccess b/inc/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes.php b/inc/classes.php new file mode 100644 index 00000000..78bafebb --- /dev/null +++ b/inc/classes.php @@ -0,0 +1,63 @@ + + * @version 0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +// Lower framework classes +$lowerClasses = array( + 0 => "exceptions", // Exceptions + 1 => "interfaces", // Interfaces + 2 => "main", // General main classes + 3 => "middleware" // The middleware +); + +// Load all classes +foreach ($lowerClasses as $className) { + // Try to load the framework classes + try { + ClassLoader::getInstance()->loadClasses(sprintf("inc/classes/%s/", $className)); + } catch (PathIsNoDirectoryException $e) { + ApplicationEntryPoint::app_die(sprintf("[Main:] Could not load framework classes from path %s for the follwing reason: %s", + $className + )); + } catch (PathIsEmptyException $e) { + ApplicationEntryPoint::app_die(sprintf("[Main:] Could not load framework classes from path %s for the follwing reason: %s", + $className + )); + } catch (PathReadProtectedException $e) { + ApplicationEntryPoint::app_die(sprintf("[Main:] Could not load framework classes from path %s for the follwing reason: %s", + $className + )); + } catch (DirPointerNotOpenedException $e) { + ApplicationEntryPoint::app_die(sprintf("[Main:] Could not load framework classes from path %s for the follwing reason: %s", + $className + )); + } +} + +// Clean up the global namespace +unset($lowerClasses[3]); // Applications shall not have any middleware +unset($className); + +////// Until here the framework classes are loaded ////// + +// [EOF] +?> diff --git a/inc/classes/.htaccess b/inc/classes/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/exceptions/.htaccess b/inc/classes/exceptions/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/exceptions/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/exceptions/actions/.htaccess b/inc/classes/exceptions/actions/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/exceptions/actions/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/exceptions/actions/class_InvalidActionException.php b/inc/classes/exceptions/actions/class_InvalidActionException.php new file mode 100644 index 00000000..96c1b73a --- /dev/null +++ b/inc/classes/exceptions/actions/class_InvalidActionException.php @@ -0,0 +1,47 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class InvalidActionException extends FrameworkException { + /** + * The super constructor for all exceptions + * + * @param $msgArray An array with message parts + * @param $code An optional code for better debugging + * @return void + */ + public function __construct(array $msgArray, $code) { + // Prepare the message + $message = sprintf("[%s:%d] Cannot resolve action %s (%s).", + $msgArray[0]->__toString(), + $this->getLine(), + $msgArray[1], + $msgArray[0]->getClassName() + ); + + // Call parent contructor with message + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/auth/.htaccess b/inc/classes/exceptions/auth/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/exceptions/auth/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/exceptions/auth/class_UserAuthorizationException.php b/inc/classes/exceptions/auth/class_UserAuthorizationException.php new file mode 100644 index 00000000..a07bf453 --- /dev/null +++ b/inc/classes/exceptions/auth/class_UserAuthorizationException.php @@ -0,0 +1,46 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class UserAuthorizationException extends FrameworkException { + /** + * The super constructor for all exceptions + * + * @param $filterInstance An instance of the filter throwing this exception + * @param $code Error code + * @return void + */ + public function __construct(Filterable $filterInstance, $code) { + // Construct the message + $message = sprintf("[%s:%d] Authorization has failed. Error code %s", + $filterInstance->__toString(), + $this->getLine(), + $this->getHexCode($code) + ); + + // Call parent exception constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/class_ b/inc/classes/exceptions/class_ new file mode 100644 index 00000000..afe1a08b --- /dev/null +++ b/inc/classes/exceptions/class_ @@ -0,0 +1,39 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ???Exception extends FrameworkException { + /** + * The super constructor for all exceptions + * + * @param $message Error message + * @param $code Error code + * @return void + */ + public function __construct($message, $code) { + // Call parent exception constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/class_FrameworkException.php b/inc/classes/exceptions/class_FrameworkException.php new file mode 100644 index 00000000..c3a2c1a3 --- /dev/null +++ b/inc/classes/exceptions/class_FrameworkException.php @@ -0,0 +1,202 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +abstract class FrameworkException extends ReflectionException { + /** + * Array for the backtrace + */ + private $backTrace = array(); + + /** + * Extra data + */ + private $extraData = ""; + + /** + * The super constructor for all exceptions + * + * @param $message The non-optional message for the exception + * @param $code An optional code for better debugging + * @return void + */ + public function __construct($message, $code = 0) { + // Extract backtrace + $this->saveBackTrace(); + + // Cast all data + $message = (string) $message; + $code = (int) $code; + + // In emergency exit? + if (defined('EMERGENCY_EXIT_CALLED')) { + // Output message + printf("[%s:] Message: %s, Backtrace:
%s
", + $this->__toString(), + $message, + $this->getPrintableBackTrace() + ); + + // End here + exit(); + } // END - if + // Make sure everything is assigned properly + parent::__construct($message, $code); + + // Log it away if DEBUG_ALL is set + if (defined('DEBUG_ALL')) { + // Log the error + error_log(sprintf("[%s:] %s (%s)", + $this->__toString(), + $message, + $this->getHexCode() + )); + } // END - if + } + + /** + * Save the current backtrace + * + * @return void + */ + private final function saveBackTrace () { + // Get full backtrace + $this->backTrace = debug_backtrace(); + + // Remove this call + $dummy = array_shift($this->backTrace); + + // resort the array + ksort($this->backTrace); + } + + /** + * Get saved backtrace + * + * @return $backTrace The full backtrace in an array + */ + public final function getBackTrace () { + return $this->backTrace; + } + + /** + * Getter for printable backtrace + * + * @return $backTrace Backtrace for web pages + */ + public final function getPrintableBackTrace () { + // Get the backtrace + $dbgTrace = $this->getBackTrace(); + + // Taken from de.php.net user comments + $dbgMsg = "
\nDebug backtrace begin:
\n"; + foreach ($dbgTrace as $dbgIndex => $dbgInfo) { + // No info by default + $info = "NULL"; + + // Are there arguments? + if ((isset($dbgInfo['args'])) && (is_array($dbgInfo['args'])) && (isset($dbgInfo['args'][0]))) { + //* DEBUG: */ echo $dbgIndex.":
".htmlentities(print_r($dbgInfo['args'], true))."
"; + $info = ""; + foreach ($dbgInfo['args'] as $debug) { + // Add only non-array elements + if (!is_array($debug)) { + $info .= $debug.", "; + } // END - if + } // END - if + + $info = substr($info, 0, -2); + } // END - if + + // Prepare argument infos + $info = "{$info}"; + + // File detection + $file = "Unknown file"; + if (isset($dbgInfo['file'])) { + $file = basename($dbgInfo['file']); + } // END - if + + // Line detection + $line = "Unknown line"; + if (isset($dbgInfo['line'])) { + $line = "line {$dbgInfo['line']}"; + } // END - if + + // The message + $dbgMsg .= "\t at ".$dbgIndex." ".$file." (".$line.") -> ".$dbgInfo['function']."(".$info.")
\n"; + } // END - if + $dbgMsg .= "Debug backtrace end
\n"; + + return $dbgMsg; + } + + /** + * Returns the name of the thrown exception + * + * @return $toString The name of the thrown exception + */ + public function __toString() { + return get_class($this); + } + + /** + * Getter for hex-decimal code + * + * @param $code Integer code to encode in hex + * @return $hexCode The exception code in hex-decimal format + */ + public final function getHexCode ($code = null) { + // Get the decimal code + if (is_null($code)) $code = $this->getCode(); + + // Format it to hex-decimal, 0x as prefix and 3 chars + $hexCode = sprintf("0x%03s", dechex($code)); + + // Return it + return $hexCode; + } + + /** + * Setter for extra data + * + * @param $extraData Extra data to store + * @return void + */ + protected final function setExtraData ($extraData) { + $this->extraData = $extraData; + } + + /** + * Getter for extra data + * + * @return $extraData Extra data to store + */ + public final function getExtraData () { + return $this->extraData; + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/compressor/.htaccess b/inc/classes/exceptions/compressor/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/exceptions/compressor/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/exceptions/compressor/class_MismatchingCompressorsException.php b/inc/classes/exceptions/compressor/class_MismatchingCompressorsException.php new file mode 100644 index 00000000..dfba485b --- /dev/null +++ b/inc/classes/exceptions/compressor/class_MismatchingCompressorsException.php @@ -0,0 +1,51 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class MismatchingCompressorsException extends FrameworkException { + /** + * The constructor + * + * @param $array Message from the exception + * @param $code Code number for the exception + * @return void + */ + public function __construct (array $array, $code) { + // Add a message around the missing class + $message = sprintf("[%s:%d] Der Kompressor %s zu den geladenen Daten aus %s und der aktuell verwendete Kompressor %s stimmen nicht überein!", + $array[0]->__toString(), + $this->getLine(), + strtoupper($array[1]), + sprintf("%s:%s", + basename(dirname($array[2])), + basename($array[2]) + ), + strtoupper($array[3]) + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/container/.htaccess b/inc/classes/exceptions/container/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/exceptions/container/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/exceptions/container/class_ContainerItemIsNoArrayException.php b/inc/classes/exceptions/container/class_ContainerItemIsNoArrayException.php new file mode 100644 index 00000000..fe6914e7 --- /dev/null +++ b/inc/classes/exceptions/container/class_ContainerItemIsNoArrayException.php @@ -0,0 +1,46 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * @deprecated + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ContainerItemIsNoArrayException extends FrameworkException { + /** + * The constructor + * + * @param $class Class throwing this exception + * @param $code Code number for the exception + * @return void + */ + public function __construct (FrameworkInterface $class, $code) { + // Add a message around the missing class + $message = sprintf("[%s:%d] A container item is not an array.", + $class->__toString(), + $this->getLine() + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/container/class_ContainerItemIsNullException.php b/inc/classes/exceptions/container/class_ContainerItemIsNullException.php new file mode 100644 index 00000000..9d0b40b4 --- /dev/null +++ b/inc/classes/exceptions/container/class_ContainerItemIsNullException.php @@ -0,0 +1,46 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * @deprecated + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ContainerItemIsNullException extends FrameworkException { + /** + * The constructor + * + * @param $class Class throwing this exception + * @param $code Code number for the exception + * @return void + */ + public function __construct (FrameworkInterface $class, $code) { + // Add a message around the missing class + $message = sprintf("[%s:%d] A container item is null.", + $class->__toString(), + $this->getLine() + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/container/class_ContainerMaybeDamagedException.php b/inc/classes/exceptions/container/class_ContainerMaybeDamagedException.php new file mode 100644 index 00000000..f8307b22 --- /dev/null +++ b/inc/classes/exceptions/container/class_ContainerMaybeDamagedException.php @@ -0,0 +1,46 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * @deprecated + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ContainerMaybeDamagedException extends FrameworkException { + /** + * The constructor + * + * @param $class Class throwing this exception + * @param $code Code number for the exception + * @return void + */ + public function __construct (FrameworkInterface $class, $code) { + // Add a message around the missing class + $message = sprintf("[%s:%d] A container is possibly damaged.", + $class->__toString(), + $this->getLine() + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/controller/.htaccess b/inc/classes/exceptions/controller/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/exceptions/controller/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/exceptions/controller/class_DefaultControllerException.php b/inc/classes/exceptions/controller/class_DefaultControllerException.php new file mode 100644 index 00000000..e0c891c7 --- /dev/null +++ b/inc/classes/exceptions/controller/class_DefaultControllerException.php @@ -0,0 +1,48 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class DefaultControllerException extends FrameworkException { + /** + * The super constructor for all exceptions + * + * @param $resolverInstance An instance of a resolver class + * @param $code An optional code for better debugging + * @return void + */ + public function __construct(ControllerResolver $resolverInstance, $code) { + // Prepare the message + $message = sprintf("[%s:%d] Cannot resolv default controller. Maybe missing?", + $resolverInstance->__toString(), + $this->getLine() + ); + + // Set extra data + $this->setExtraData($resolverInstance->getClassName().":".$this->getLine()); + + // Call parent contructor with message + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/controller/class_InvalidControllerException.php b/inc/classes/exceptions/controller/class_InvalidControllerException.php new file mode 100644 index 00000000..7fec6320 --- /dev/null +++ b/inc/classes/exceptions/controller/class_InvalidControllerException.php @@ -0,0 +1,50 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class InvalidControllerException extends FrameworkException { + /** + * The super constructor for all exceptions + * + * @param $msgArray An array with message parts + * @param $code An optional code for better debugging + * @return void + */ + public function __construct(array $msgArray, $code) { + // Prepare the message + $message = sprintf("[%s:%d] Cannot resolve controller %s (class name: %s).", + $msgArray[0]->__toString(), + $this->getLine(), + $msgArray[1], + $msgArray[0]->getClassName() + ); + + // Set extra data + $this->setExtraData($msgArray[0]->getClassName().":".$this->getLine()); + + // Call parent contructor with message + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/criteria/.htaccess b/inc/classes/exceptions/criteria/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/exceptions/criteria/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/exceptions/crypto/.htaccess b/inc/classes/exceptions/crypto/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/exceptions/crypto/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/exceptions/crypto/class_EncryptInvalidLengthException.php b/inc/classes/exceptions/crypto/class_EncryptInvalidLengthException.php new file mode 100644 index 00000000..4b6314d3 --- /dev/null +++ b/inc/classes/exceptions/crypto/class_EncryptInvalidLengthException.php @@ -0,0 +1,52 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class EncryptInvalidLengthException extends FrameworkException { + /** + * The super constructor for all exceptions + * + * @param $message Error message + * @param $code Error code + * @return void + */ + public function __construct(Filterable $filterInstance, $code) { + // Get length + $length = $filterInstance->getConfigInstance()->readConfig('captcha_string_length'); + + // Construct message + $message = sprintf("[%s:%d] Encrypt string has an invalid length. Valid: %d", + $filterInstance->__toString(), + $this->getLine(), + $length + ); + + // Set extra data + $this->setExtraData($filterInstance->__toString().":".$length); + + // Call parent exception constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/crypto/class_EncryptMissingException.php b/inc/classes/exceptions/crypto/class_EncryptMissingException.php new file mode 100644 index 00000000..78583c0c --- /dev/null +++ b/inc/classes/exceptions/crypto/class_EncryptMissingException.php @@ -0,0 +1,48 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class EncryptMissingException extends FrameworkException { + /** + * The super constructor for all exceptions + * + * @param $message Error message + * @param $code Error code + * @return void + */ + public function __construct(Filterable $filterInstance, $code) { + // Construct message + $message = sprintf("[%s:%d] Encrypt string is missing.", + $filterInstance->__toString(), + $this->getLine() + ); + + // Set extra data + $this->setExtraData($filterInstance->__toString()); + + // Call parent exception constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/database/.htaccess b/inc/classes/exceptions/database/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/exceptions/database/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/exceptions/database/class_ b/inc/classes/exceptions/database/class_ new file mode 100644 index 00000000..1124b160 --- /dev/null +++ b/inc/classes/exceptions/database/class_ @@ -0,0 +1,39 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ???Exception extends DatabaseException { + /** + * The constructor + * + * @param $message Message from the exception + * @param $code Code number for the exception + * @return void + */ + public function __construct ($message, $code) { + // Just call the parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/database/class_DatabaseException.php b/inc/classes/exceptions/database/class_DatabaseException.php new file mode 100644 index 00000000..ab2eabb0 --- /dev/null +++ b/inc/classes/exceptions/database/class_DatabaseException.php @@ -0,0 +1,39 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class DatabaseException extends FrameworkException { + /** + * The constructor + * + * @param $message Message from the exception + * @param $code Code number for the exception + * @return void + */ + public function __construct ($message, $code) { + // Just call the parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/database/general/.htaccess b/inc/classes/exceptions/database/general/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/exceptions/database/general/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/exceptions/database/general/class_DatabaseUpdateSupportException.php b/inc/classes/exceptions/database/general/class_DatabaseUpdateSupportException.php new file mode 100644 index 00000000..637b9629 --- /dev/null +++ b/inc/classes/exceptions/database/general/class_DatabaseUpdateSupportException.php @@ -0,0 +1,45 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class DatabaseUpdateSupportException extends DatabaseException { + /** + * The constructor + * + * @param $class Class trying the invalid database update + * @param $code Code number for the exception + * @return void + */ + public function __construct (FrameworkInterface $class, $code) { + // Generate message + $message = sprintf("[%s:%d] Database updated not allowed for this class.", + $class->__toString(), + $this->getLine() + ); + + // Just call the parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/database/general/class_SqlException.php b/inc/classes/exceptions/database/general/class_SqlException.php new file mode 100644 index 00000000..06349288 --- /dev/null +++ b/inc/classes/exceptions/database/general/class_SqlException.php @@ -0,0 +1,47 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class SqlException extends DatabaseException { + /** + * The constructor + * + * @param $msgArray Message array + * @param $code Code number for the exception + * @return void + */ + public function __construct (array $msgArray, $code) { + // Construct the message + $message = sprintf("[%s:%d] SQL error detected. Message from database: %s, code: %s.", + $msgArray[0]->__toString(), + $this->getLine(), + $msgArray[1], + $this->getHexCode($msgArray[2]) + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/database/local_file/.htaccess b/inc/classes/exceptions/database/local_file/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/exceptions/database/local_file/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/exceptions/database/local_file/class_SavePathIsEmptyException.php b/inc/classes/exceptions/database/local_file/class_SavePathIsEmptyException.php new file mode 100644 index 00000000..06f14ca2 --- /dev/null +++ b/inc/classes/exceptions/database/local_file/class_SavePathIsEmptyException.php @@ -0,0 +1,45 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class SavePathIsEmptyException extends DatabaseException { + /** + * The constructor + * + * @param $class Class throwing this exception + * @param $code Code number for the exception + * @return void + */ + public function __construct (FrameworkInterface $class, $code) { + // Add a message around the missing class + $message = sprintf("[%s:%d] Save path is empty.", + $class->__toString(), + $this->getLine() + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/database/local_file/class_SavePathIsNoDirectoryException.php b/inc/classes/exceptions/database/local_file/class_SavePathIsNoDirectoryException.php new file mode 100644 index 00000000..b14fa973 --- /dev/null +++ b/inc/classes/exceptions/database/local_file/class_SavePathIsNoDirectoryException.php @@ -0,0 +1,42 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class SavePathIsNoDirectoryException extends DatabaseException { + /** + * The constructor + * + * @param $message Message from the exception + * @param $code Code number for the exception + * @return void + */ + public function __construct ($path, $code) { + // Add a message around the missing class + $message = sprintf("Der angegebene Speicherpfad %s ist ungütig (kein Pfad).", $path); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/database/local_file/class_SavePathReadProtectedException.php b/inc/classes/exceptions/database/local_file/class_SavePathReadProtectedException.php new file mode 100644 index 00000000..ce0ffa6b --- /dev/null +++ b/inc/classes/exceptions/database/local_file/class_SavePathReadProtectedException.php @@ -0,0 +1,42 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class SavePathReadProtectedException extends DatabaseException { + /** + * The constructor + * + * @param $message Message from the exception + * @param $code Code number for the exception + * @return void + */ + public function __construct ($path, $code) { + // Add a message around the missing class + $message = sprintf("Der Pfad %s ist lese-geschützt. Bitte Zugriffsrechte (CHMOD) zum Lesen setzen.", $path); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/database/local_file/class_SavePathWriteProtectedException.php b/inc/classes/exceptions/database/local_file/class_SavePathWriteProtectedException.php new file mode 100644 index 00000000..81a1067e --- /dev/null +++ b/inc/classes/exceptions/database/local_file/class_SavePathWriteProtectedException.php @@ -0,0 +1,42 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class SavePathWriteProtectedException extends DatabaseException { + /** + * The constructor + * + * @param $message Message from the exception + * @param $code Code number for the exception + * @return void + */ + public function __construct ($path, $code) { + // Add a message around the missing class + $message = sprintf("Der angegebene Speicherpfad %s ist schreibgeschützt. Bitte Zugriffsrechte (CHMOD) entsprechend setzen.", $path); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/database/wrapper/.htaccess b/inc/classes/exceptions/database/wrapper/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/exceptions/database/wrapper/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/exceptions/database/wrapper/class_WrapperUserNameNotFoundException.php b/inc/classes/exceptions/database/wrapper/class_WrapperUserNameNotFoundException.php new file mode 100644 index 00000000..819b388f --- /dev/null +++ b/inc/classes/exceptions/database/wrapper/class_WrapperUserNameNotFoundException.php @@ -0,0 +1,49 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * @todo This class is no longer used + * @deprecated + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class WrapperUserNameNotFoundException extends DatabaseException { + /** + * The constructor + * + * @param $msgArray Message from the exception + * @param $code Code number for the exception + * @return void + */ + public function __construct (array $msgArray, $code) { + // Add a message around the missing class + $message = sprintf("[%s:%d] Username %s was not found. Requesting class: %s", + $msgArray[0]->__toString(), + $this->getLine(), + $msgArray[1]->getUserName(), + $msgArray[1]->__toString() + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/filter/.htaccess b/inc/classes/exceptions/filter/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/exceptions/filter/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/exceptions/filter/class_FilterChainException.php b/inc/classes/exceptions/filter/class_FilterChainException.php new file mode 100644 index 00000000..b2cbb109 --- /dev/null +++ b/inc/classes/exceptions/filter/class_FilterChainException.php @@ -0,0 +1,45 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class FilterChainException extends FrameworkException { + /** + * The super constructor for all exceptions + * + * @param $filterInstance Instance of a filter class + * @param $code Exception code for better debugging + * @return void + */ + public function __construct(Filterable $filterInstance, $code) { + // Construct the message + $message = sprintf("[%s:%d] Filter chain interruppted by fatal error in filter.", + $filterInstance->__toString(), + $this->getLine() + ); + + // Call the parent exception + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/helper/.htaccess b/inc/classes/exceptions/helper/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/exceptions/helper/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/exceptions/helper/class_FormClosedException.php b/inc/classes/exceptions/helper/class_FormClosedException.php new file mode 100644 index 00000000..9978e5e5 --- /dev/null +++ b/inc/classes/exceptions/helper/class_FormClosedException.php @@ -0,0 +1,47 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class FormClosedException extends FrameworkException { + /** + * The constructor + * + * @param $classArray Class throwing the exception + * @param $code Code number for the exception + * @return void + */ + public function __construct (array $classArray, $code) { + // Add a message around the missing class + $message = sprintf("[%s:%d] Could not add form element %s because form is closed.", + $classArray[0]->__toString(), + $this->getLine(), + $classArray[1] + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/helper/class_FormGroupClosedException.php b/inc/classes/exceptions/helper/class_FormGroupClosedException.php new file mode 100644 index 00000000..92a6e438 --- /dev/null +++ b/inc/classes/exceptions/helper/class_FormGroupClosedException.php @@ -0,0 +1,46 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class FormGroupClosedException extends FrameworkException { + /** + * The constructor + * + * @param $classArray Class throwing the exception + * @param $code Code number for the exception + * @return void + */ + public function __construct (array $classArray, $code) { + // Add a message around the missing class + $message = sprintf("[%s:%d] Could not add sub group %s because no form group has been opened before.", + $classArray[0]->__toString(), + $this->getLine(), + $classArray[1] + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/helper/class_FormOpenedException.php b/inc/classes/exceptions/helper/class_FormOpenedException.php new file mode 100644 index 00000000..aab6078d --- /dev/null +++ b/inc/classes/exceptions/helper/class_FormOpenedException.php @@ -0,0 +1,47 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class FormOpenedException extends FrameworkException { + /** + * The constructor + * + * @param $helperInstance Class throwing the exception + * @param $code Code number for the exception + * @return void + */ + public function __construct (BaseHelper $helperInstance, $code) { + // Add a message around the missing class + $message = sprintf("[%s:%d] Form is not yet closed. Close it with method %s::addFormTag() and add no parameters.", + $helperInstance->__toString(), + $this->getLine(), + $helperInstance->__toString() + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/helper/class_HelperGroupAlreadyCreatedException.php b/inc/classes/exceptions/helper/class_HelperGroupAlreadyCreatedException.php new file mode 100644 index 00000000..0f14f170 --- /dev/null +++ b/inc/classes/exceptions/helper/class_HelperGroupAlreadyCreatedException.php @@ -0,0 +1,46 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HelperGroupAlreadyCreatedException extends FrameworkException { + /** + * The constructor + * + * @param $msgArray Array containing exception data + * @param $code Code number for the exception + * @return void + */ + public function __construct (array $msgArray, $code) { + // Add a message around the missing class + $message = sprintf("[%s:%d] Group %s already opened before.", + $msgArray[0]->__toString(), + $this->getLine(), + $msgArray[1] + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/helper/class_HelperNoPreviousOpenedSubGroupException.php b/inc/classes/exceptions/helper/class_HelperNoPreviousOpenedSubGroupException.php new file mode 100644 index 00000000..b6b78f61 --- /dev/null +++ b/inc/classes/exceptions/helper/class_HelperNoPreviousOpenedSubGroupException.php @@ -0,0 +1,46 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HelperNoPreviousOpenedSubGroupException extends FrameworkException { + /** + * The constructor + * + * @param $msgArray Array containing exception data + * @param $code Code number for the exception + * @return void + */ + public function __construct (array $msgArray, $code) { + // Add a message around the missing class + $message = sprintf("[%s:%d] Sub group not opened before. Raw text follows: %s", + $msgArray[0]->__toString(), + $this->getLine(), + $msgArray[1] + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/helper/class_HelperSubGroupAlreadyCreatedException.php b/inc/classes/exceptions/helper/class_HelperSubGroupAlreadyCreatedException.php new file mode 100644 index 00000000..efdfff94 --- /dev/null +++ b/inc/classes/exceptions/helper/class_HelperSubGroupAlreadyCreatedException.php @@ -0,0 +1,46 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HelperSubGroupAlreadyCreatedException extends FrameworkException { + /** + * The constructor + * + * @param $msgArray Array containing exception data + * @param $code Code number for the exception + * @return void + */ + public function __construct (array $msgArray, $code) { + // Add a message around the missing class + $message = sprintf("[%s:%d] Sub group %s already opened before.", + $msgArray[0]->__toString(), + $this->getLine(), + $msgArray[1] + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/helper/class_InvalidFormNameException.php b/inc/classes/exceptions/helper/class_InvalidFormNameException.php new file mode 100644 index 00000000..70e1c3dc --- /dev/null +++ b/inc/classes/exceptions/helper/class_InvalidFormNameException.php @@ -0,0 +1,45 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class InvalidFormNameException extends FrameworkException { + /** + * The constructor + * + * @param $helperInstance Class throwing the exception + * @param $code Code number for the exception + * @return void + */ + public function __construct (BaseHelper $helperInstance, $code) { + // Add a message around the missing class + $message = sprintf("[%s:%d] Form name not set.", + $helperInstance->__toString(), + $this->getLine() + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/helper/class_NoGroupOpenedException.php b/inc/classes/exceptions/helper/class_NoGroupOpenedException.php new file mode 100644 index 00000000..2946a8b5 --- /dev/null +++ b/inc/classes/exceptions/helper/class_NoGroupOpenedException.php @@ -0,0 +1,46 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NoGroupOpenedException extends FrameworkException { + /** + * The constructor + * + * @param $msgArray Array containing exception data + * @param $code Code number for the exception + * @return void + */ + public function __construct (array $msgArray, $code) { + // Add a message around the missing class + $message = sprintf("[%s:%d] Group not opened before. Raw text follows: %s", + $msgArray[0]->__toString(), + $this->getLine(), + $msgArray[1] + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/helper/class_UserInstanceMissingException.php b/inc/classes/exceptions/helper/class_UserInstanceMissingException.php new file mode 100644 index 00000000..218968bc --- /dev/null +++ b/inc/classes/exceptions/helper/class_UserInstanceMissingException.php @@ -0,0 +1,46 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class UserInstanceMissingException extends FrameworkException { + /** + * The constructor + * + * @param $classArray Array with class instance and registry key + * @param $code Code number for the exception + * @return void + */ + public function __construct (array $classArray, $code) { + // Add a message around the missing class + $message = sprintf("[%s:%d] Registry key %s does not include a class with implemented interface Manageable(User|Guest).", + $classArray[0]->__toString(), + $this->getLine(), + $classArray[1] + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/io/.htaccess b/inc/classes/exceptions/io/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/exceptions/io/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/exceptions/io/class_DirPointerNotOpenedException.php b/inc/classes/exceptions/io/class_DirPointerNotOpenedException.php new file mode 100644 index 00000000..5b0293ee --- /dev/null +++ b/inc/classes/exceptions/io/class_DirPointerNotOpenedException.php @@ -0,0 +1,42 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class DirPointerNotOpenedException extends FrameworkException { + /** + * The constructor + * + * @param $path Message from the exception + * @param $code Code number for the exception + * @return void + */ + public function __construct ($path, $code) { + // Add a message around the missing class + $message = sprintf("Für den Pfad %s konnte kein Pointer initialisiert werden.", $path); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/io/class_FileNotFoundException.php b/inc/classes/exceptions/io/class_FileNotFoundException.php new file mode 100644 index 00000000..ea31a49f --- /dev/null +++ b/inc/classes/exceptions/io/class_FileNotFoundException.php @@ -0,0 +1,49 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * @todo Rename this class to FileIoException + * @deprecated + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class FileNotFoundException extends FrameworkException { + /** + * The constructor + * + * @param $fqfn Full-qualified file name of (maybe) missing file + * @param $code Code number for the exception + * @return void + */ + public function __construct ($fqfn, $code) { + // Add a message around the missing class + $message = sprintf("The requested file %s was not found.", + $fqfn + ); + + // Set extra data + $this->setExtraData(basename($fqfn)); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/io/class_FilePointerNotOpenedException.php b/inc/classes/exceptions/io/class_FilePointerNotOpenedException.php new file mode 100644 index 00000000..37300a52 --- /dev/null +++ b/inc/classes/exceptions/io/class_FilePointerNotOpenedException.php @@ -0,0 +1,42 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class FilePointerNotOpenedException extends FrameworkException { + /** + * The constructor + * + * @param $fqfn Full-qualified file name of (maybe) missing file + * @param $code Code number for the exception + * @return void + */ + public function __construct ($fqfn, $code) { + // Add a message around the missing class + $message = sprintf("Not able to initialize a pointer for the file %s. Maybe the file is missing.", $fqfn); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/io/class_FileReadProtectedException.php b/inc/classes/exceptions/io/class_FileReadProtectedException.php new file mode 100644 index 00000000..4e8a0e66 --- /dev/null +++ b/inc/classes/exceptions/io/class_FileReadProtectedException.php @@ -0,0 +1,42 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class FileReadProtectedException extends FrameworkException { + /** + * The constructor + * + * @param $fileName File which cannot be read from + * @param $code Code number for the exception + * @return void + */ + public function __construct ($fileName, $code) { + // Add a message around the missing class + $message = sprintf("File %s is read-protected. Please set read access rights (CHMOD).", $fileName); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/io/class_InvalidDataLengthException.php b/inc/classes/exceptions/io/class_InvalidDataLengthException.php new file mode 100644 index 00000000..a1ef85ad --- /dev/null +++ b/inc/classes/exceptions/io/class_InvalidDataLengthException.php @@ -0,0 +1,47 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class InvalidDataLengthException extends FrameworkException { + /** + * The constructor + * + * @param $msgArray Message from the exception + * @param $code Code number for the exception + * @return void + */ + public function __construct (array $msgArray, $code) { + // Add a message around the missing class + $message = sprintf("[%s:%d] Eine unerwartete Datenlänge von %s Byte ist aufgetreten. %s wurden erwartet!", + $msgArray[0]->__toString(), + $this->getLine(), + $msgArray[1], + $msgArray[2] + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/io/class_InvalidDirectoryResourceException.php b/inc/classes/exceptions/io/class_InvalidDirectoryResourceException.php new file mode 100644 index 00000000..71a7f9c0 --- /dev/null +++ b/inc/classes/exceptions/io/class_InvalidDirectoryResourceException.php @@ -0,0 +1,45 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class InvalidDirectoryResourceException extends FrameworkException { + /** + * The constructor + * + * @param $class Class throwing this exception + * @param $code Code number for the exception + * @return void + */ + public function __construct (FrameworkInterface $class, $code) { + // Add a message around the missing class + $message = sprintf("[%s:%d] Has an invalid directory resource.", + $class->__toString(), + $this->getLine() + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/io/class_InvalidMD5ChecksumException.php b/inc/classes/exceptions/io/class_InvalidMD5ChecksumException.php new file mode 100644 index 00000000..2e5104a0 --- /dev/null +++ b/inc/classes/exceptions/io/class_InvalidMD5ChecksumException.php @@ -0,0 +1,47 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class InvalidMD5ChecksumException extends FrameworkException { + /** + * The constructor + * + * @param $msgArray Message from the exception + * @param $code Code number for the exception + * @return void + */ + public function __construct (array $msgArray, $code) { + // Add a message around the missing class + $message = sprintf("[%s:%d] Die MD5-Prüfsummen %s und %s stimmen nicht überein!", + $msgArray[0]->__toString(), + $this->getLine(), + $msgArray[1], + $msgArray[2] + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/io/class_PathIsEmptyException.php b/inc/classes/exceptions/io/class_PathIsEmptyException.php new file mode 100644 index 00000000..6747f785 --- /dev/null +++ b/inc/classes/exceptions/io/class_PathIsEmptyException.php @@ -0,0 +1,45 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class PathIsEmptyException extends FrameworkException { + /** + * The constructor + * + * @param $class Class throwing this exception + * @param $code Code number for the exception + * @return void + */ + public function __construct (FrameworkInterface $class, $code) { + // Add a message around the missing class + $message = sprintf("[%s:%d] Directory path is empty.", + $class->__toString(), + $this->getLine() + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/io/class_PathIsNoDirectoryException.php b/inc/classes/exceptions/io/class_PathIsNoDirectoryException.php new file mode 100644 index 00000000..7f908b10 --- /dev/null +++ b/inc/classes/exceptions/io/class_PathIsNoDirectoryException.php @@ -0,0 +1,42 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class PathIsNoDirectoryException extends FrameworkException { + /** + * The constructor + * + * @param $message Message from the exception + * @param $code Code number for the exception + * @return void + */ + public function __construct ($path, $code) { + // Add a message around the missing class + $message = sprintf("Der angegebene Pfad %s ist ungütig (kein Pfad).", $path); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/io/class_PathReadProtectedException.php b/inc/classes/exceptions/io/class_PathReadProtectedException.php new file mode 100644 index 00000000..b5dd9355 --- /dev/null +++ b/inc/classes/exceptions/io/class_PathReadProtectedException.php @@ -0,0 +1,42 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class PathReadProtectedException extends FrameworkException { + /** + * The constructor + * + * @param $message Message from the exception + * @param $code Code number for the exception + * @return void + */ + public function __construct ($path, $code) { + // Add a message around the missing class + $message = sprintf("Der Pfad %s ist lese-geschützt. Bitte Zugriffsrechte (CHMOD) zum Lesen setzen.", $path); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/language/.htaccess b/inc/classes/exceptions/language/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/exceptions/language/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/exceptions/language/class_InvalidLanguagePathStringException.php b/inc/classes/exceptions/language/class_InvalidLanguagePathStringException.php new file mode 100644 index 00000000..19be0cdc --- /dev/null +++ b/inc/classes/exceptions/language/class_InvalidLanguagePathStringException.php @@ -0,0 +1,46 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class InvalidLanguagePathStringException extends FrameworkException { + /** + * The constructor + * + * @param $classArray Array holding exception data + * @param $code Code number for the exception + * @return void + */ + public function __construct (array $classArray, $code) { + // Add a message around the missing class + $message = sprintf("[%s:%d] %s is not a string with path!", + $classArray[0]->__toString(), + $this->getLine(), + $classArray[1] + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/language/class_LanguagePathIsEmptyException.php b/inc/classes/exceptions/language/class_LanguagePathIsEmptyException.php new file mode 100644 index 00000000..557d32db --- /dev/null +++ b/inc/classes/exceptions/language/class_LanguagePathIsEmptyException.php @@ -0,0 +1,45 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class LanguagePathIsEmptyException extends FrameworkException { + /** + * The constructor + * + * @param $class Class throwing this exception + * @param $code Code number for the exception + * @return void + */ + public function __construct (FrameworkInterface $class, $code) { + // Add a message around the missing class + $message = sprintf("[%s:%d] Language base path is empty.", + $class->__toString(), + $this->getLine() + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/language/class_LanguagePathIsNoDirectoryException.php b/inc/classes/exceptions/language/class_LanguagePathIsNoDirectoryException.php new file mode 100644 index 00000000..b17823d2 --- /dev/null +++ b/inc/classes/exceptions/language/class_LanguagePathIsNoDirectoryException.php @@ -0,0 +1,46 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class LanguagePathIsNoDirectoryException extends FrameworkException { + /** + * The constructor + * + * @param $classArray Array holding exception data + * @param $code Code number for the exception + * @return void + */ + public function __construct (array $classArray, $code) { + // Add a message around the missing class + $message = sprintf("[%s:%d] Der Sprach-Basispfad %s existiert nicht oder ist eine Datei!", + $classArray[0]->__toString(), + $this->getLine(), + $classArray[1] + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/language/class_LanguagePathReadProtectedException.php b/inc/classes/exceptions/language/class_LanguagePathReadProtectedException.php new file mode 100644 index 00000000..0938f778 --- /dev/null +++ b/inc/classes/exceptions/language/class_LanguagePathReadProtectedException.php @@ -0,0 +1,46 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class LanguagePathReadProtectedException extends FrameworkException { + /** + * The constructor + * + * @param $class Array holding exception data + * @param $code Code number for the exception + * @return void + */ + public function __construct (array $classArray, $code) { + // Add a message around the missing class + $message = sprintf("[%s:%d] Base language path %s is read-protected. Please change access rights (CHMOD).", + $classArray[0]->__toString(), + $this->getLine(), + $classArray[1] + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/language/class_MissingFileIoHandlerException.php b/inc/classes/exceptions/language/class_MissingFileIoHandlerException.php new file mode 100644 index 00000000..6a844db9 --- /dev/null +++ b/inc/classes/exceptions/language/class_MissingFileIoHandlerException.php @@ -0,0 +1,45 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class MissingFileIoHandlerException extends FrameworkException { + /** + * The constructor + * + * @param $class Class throwing this exception + * @param $code Code number for the exception + * @return void + */ + public function __construct (FrameworkInterface $class, $code) { + // Add a message around the missing class + $message = sprintf("[%s:%d] File i/o sub-system not initialized!", + $class->__toString(), + $this->getLine() + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/language/class_MissingLanguageHandlerException.php b/inc/classes/exceptions/language/class_MissingLanguageHandlerException.php new file mode 100644 index 00000000..a4a41319 --- /dev/null +++ b/inc/classes/exceptions/language/class_MissingLanguageHandlerException.php @@ -0,0 +1,45 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class MissingLanguageHandlerException extends FrameworkException { + /** + * The constructor + * + * @param $class Class throwing this exception + * @param $code Code number for the exception + * @return void + */ + public function __construct (FrameworkInterface $class, $code) { + // Add a message around the missing class + $message = sprintf("[%s:%d] Language sub-system not initialized!", + $class->__toString(), + $this->getLine() + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/main/.htaccess b/inc/classes/exceptions/main/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/exceptions/main/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/exceptions/main/class_AssertionException.php b/inc/classes/exceptions/main/class_AssertionException.php new file mode 100644 index 00000000..270eb8fb --- /dev/null +++ b/inc/classes/exceptions/main/class_AssertionException.php @@ -0,0 +1,39 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class AssertionException extends FrameworkException { + /** + * The constructor + * + * @param $message Message from the exception + * @param $code Code number for the exception + * @return void + */ + public function __construct ($message, $code) { + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/main/class_ClassMismatchException.php b/inc/classes/exceptions/main/class_ClassMismatchException.php new file mode 100644 index 00000000..51497b46 --- /dev/null +++ b/inc/classes/exceptions/main/class_ClassMismatchException.php @@ -0,0 +1,45 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ClassMismatchException extends FrameworkException { + /** + * The constructor + * + * @param $classArray Array holding the exception informations + * @param $code Code number for the exception + * @return void + */ + public function __construct (array $classArray, $code) { + // Add a message around the missing class + $message = sprintf("The class %s does not match class %s.", + $classArray[0], + $classArray[1] + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/main/class_ClassNotFoundException.php b/inc/classes/exceptions/main/class_ClassNotFoundException.php new file mode 100644 index 00000000..3a7b995c --- /dev/null +++ b/inc/classes/exceptions/main/class_ClassNotFoundException.php @@ -0,0 +1,51 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * @todo Rename this class to NoClassException + * @deprecated + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ClassNotFoundException extends FrameworkException { + /** + * The constructor + * + * @param $msgArray Message from the exception + * @param $code Code number for the exception + * @return void + */ + public function __construct (array $msgArray, $code) { + // Add a message around the missing class + $message = sprintf("[%s:%d] Internal class %s not found.", + $msgArray[0]->__toString(), + $this->getLine(), + $msgArray[1] + ); + + // Set extra data + $this->setExtraData($msgArray[1]); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/main/class_ConfigEntryIsEmptyException.php b/inc/classes/exceptions/main/class_ConfigEntryIsEmptyException.php new file mode 100644 index 00000000..c0d60e28 --- /dev/null +++ b/inc/classes/exceptions/main/class_ConfigEntryIsEmptyException.php @@ -0,0 +1,45 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ConfigEntryIsEmptyException extends FrameworkException { + /** + * The constructor + * + * @param $class Class throwing this exception + * @param $code Code number for the exception + * @return void + */ + public function __construct (FrameworkConfiguration $class, $code) { + // Add a message around the missing class + $message = sprintf("[%s:%d] Empty configuration entry provided!", + $class->__toString(), + $this->getLine() + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/main/class_ConfigEntryNotFoundException.php b/inc/classes/exceptions/main/class_ConfigEntryNotFoundException.php new file mode 100644 index 00000000..76be0f13 --- /dev/null +++ b/inc/classes/exceptions/main/class_ConfigEntryNotFoundException.php @@ -0,0 +1,51 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * @todo Rename this class to NoFoundEntryException + * @deprecated + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ConfigEntryNotFoundException extends FrameworkException { + /** + * The constructor + * + * @param $classArray Array with exception data + * @param $code Code number for the exception + * @return void + */ + public function __construct (array $classArray, $code) { + // Add a message around the missing class + $message = sprintf("[%s:%d] Configuration entry %s not found.", + $classArray[0], + $this->getLine(), + $classArray[1] + ); + + // Set extra data + $this->setExtraData($classArray[1].":".$this->getLine()); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/main/class_DimNotFoundInArrayException.php b/inc/classes/exceptions/main/class_DimNotFoundInArrayException.php new file mode 100644 index 00000000..1e11cceb --- /dev/null +++ b/inc/classes/exceptions/main/class_DimNotFoundInArrayException.php @@ -0,0 +1,50 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class DimNotFoundInArrayException extends FrameworkException { + /** + * The constructor + * + * @param $class Class throwing the exception + * @param $code Code number for the exception + * @return void + */ + public function __construct (FrameworkInterface $class, $code) { + if (is_object($class)) { + // Add a message around the missing class + $message = sprintf("[%s:%d] Dimensions not found in array, array is invalid!", + $class->__toString(), + $this->getLine() + ); + } else { + // No class given + $message = sprintf("Please provide a class for %s", __CLASS__); + } + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/main/class_EmptyVariableException.php b/inc/classes/exceptions/main/class_EmptyVariableException.php new file mode 100644 index 00000000..188969cf --- /dev/null +++ b/inc/classes/exceptions/main/class_EmptyVariableException.php @@ -0,0 +1,46 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class EmptyVariableException extends FrameworkException { + /** + * The constructor + * + * @param $msgArray Message array holding all needed data + * @param $code Code number for the exception + * @return void + */ + public function __construct (array $msgArray, $code) { + // Add a message around the missing class + $message = sprintf("[%s:%d] Variable %s is not set.", + $msgArray[0]->__toString(), + $this->getLine(), + $msgArray[1] + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/main/class_ExceptionNotFoundException.php b/inc/classes/exceptions/main/class_ExceptionNotFoundException.php new file mode 100644 index 00000000..42dc611e --- /dev/null +++ b/inc/classes/exceptions/main/class_ExceptionNotFoundException.php @@ -0,0 +1,48 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * @todo Is this exception still needed??? + * @deprecated + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ExceptionNotFoundException extends FrameworkException { + /** + * The constructor + * + * @param $classArray Array with exception data + * @param $code Code number for the exception + * @return void + */ + public function __construct (array $classArray, $code) { + // Add a message around the missing class + $message = sprintf("[%s:%d] Exception %s not found.", + $classArray[0], + $this->getLine(), + $classArray[1] + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/main/class_FatalErrorException.php b/inc/classes/exceptions/main/class_FatalErrorException.php new file mode 100644 index 00000000..2c4b880b --- /dev/null +++ b/inc/classes/exceptions/main/class_FatalErrorException.php @@ -0,0 +1,40 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class FatalErrorException extends FrameworkException { + /** + * The constructor + * + * @param $message Message from the exception + * @param $code Code number for the exception + * @return void + */ + public function __construct ($message, $code) { + die($message); + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/main/class_GetterNotFoundException.php b/inc/classes/exceptions/main/class_GetterNotFoundException.php new file mode 100644 index 00000000..9a918c3e --- /dev/null +++ b/inc/classes/exceptions/main/class_GetterNotFoundException.php @@ -0,0 +1,48 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * @todo This class is no longer needed! + * @deprecated + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class GetterNotFoundException extends FrameworkException { + /** + * The constructor + * + * @param $message Message from the exception + * @param $code Code number for the exception + * @return void + */ + public function __construct (array $dataArray, $code) { + // Add a message around the missing class + $message = sprintf("[%s:%d] Getter-Methode für Attribut %s nicht gefunden.", + $dataArray[0]->__toString(), + $this->getLine(), + $dataArray[1] + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/main/class_InvalidArrayCountException.php b/inc/classes/exceptions/main/class_InvalidArrayCountException.php new file mode 100644 index 00000000..3703f1ad --- /dev/null +++ b/inc/classes/exceptions/main/class_InvalidArrayCountException.php @@ -0,0 +1,48 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class InvalidArrayCountException extends FrameworkException { + /** + * The constructor + * + * @param $array Message from the exception + * @param $code Code number for the exception + * @return void + */ + public function __construct (array $array, $code) { + // Add a message around the missing class + $message = sprintf("[%s:%d] %s hat %d Elemente, soll aber %d enthalten!", + $array[0]->__toString(), + $this->getLine(), + $array[1], + $array[2], + $array[3] + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/main/class_InvalidCommandException.php b/inc/classes/exceptions/main/class_InvalidCommandException.php new file mode 100644 index 00000000..d55a167f --- /dev/null +++ b/inc/classes/exceptions/main/class_InvalidCommandException.php @@ -0,0 +1,50 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class InvalidCommandException extends FrameworkException { + /** + * The constructor + * + * @param $message Message from the exception + * @param $code Code number for the exception + * @return void + */ + public function __construct (array $msgArray, $code) { + // Add a message around the missing class + $message = sprintf("[%s:%d] Invalid command %s (class %s) detected.", + $msgArray[0]->__toString(), + $this->getLine(), + $msgArray[1], + $msgArray[0]->getClassName() + ); + + // Set extra data + $this->setExtraData($msgArray[0]->getClassName().":".$this->getLine()); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/main/class_InvalidCommandInstanceException.php b/inc/classes/exceptions/main/class_InvalidCommandInstanceException.php new file mode 100644 index 00000000..34a4d249 --- /dev/null +++ b/inc/classes/exceptions/main/class_InvalidCommandInstanceException.php @@ -0,0 +1,46 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class InvalidCommandInstanceException extends FrameworkException { + /** + * The constructor + * + * @param $message Message from the exception + * @param $code Code number for the exception + * @return void + */ + public function __construct (array $msgArray, $code) { + // Add a message around the missing class + $message = sprintf("[%s:%d] Invalid command %s detected.", + $msgArray[0]->__toString(), + $this->getLine(), + $msgArray[1] + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/main/class_InvalidInterfaceException.php b/inc/classes/exceptions/main/class_InvalidInterfaceException.php new file mode 100644 index 00000000..93958ed2 --- /dev/null +++ b/inc/classes/exceptions/main/class_InvalidInterfaceException.php @@ -0,0 +1,46 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class InvalidInterfaceException extends FrameworkException { + /** + * The constructor + * + * @param $classArray Array with exception data + * @param $code Code number for the exception + * @return void + */ + public function __construct (array $classArray, $code) { + // Add a message around the missing class + $message = sprintf("[%s:%d] Object does not implement expected interface %s.", + $classArray[0]->__toString(), + $this->getLine(), + $classArray[1] + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/main/class_InvalidObjectException.php b/inc/classes/exceptions/main/class_InvalidObjectException.php new file mode 100644 index 00000000..7a002d45 --- /dev/null +++ b/inc/classes/exceptions/main/class_InvalidObjectException.php @@ -0,0 +1,45 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class InvalidObjectException extends FrameworkException { + /** + * The constructor + * + * @param $class Class throwing the exception + * @param $code Code number for the exception + * @return void + */ + public function __construct (FrameworkInterface $class, $code) { + // Add a message around the missing class + $message = sprintf("[%s:%d] Object is not allowed here.", + $class->__toString(), + $this->getLine() + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/main/class_MissingArrayElementsException.php b/inc/classes/exceptions/main/class_MissingArrayElementsException.php new file mode 100644 index 00000000..5c3547bc --- /dev/null +++ b/inc/classes/exceptions/main/class_MissingArrayElementsException.php @@ -0,0 +1,57 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class MissingArrayElementsException extends FrameworkException { + /** + * The constructor + * + * @param $classArray Array with exception data + * @param $code Code number for the exception + * @return void + */ + public function __construct (array $classArray, $code) { + // Extract all elements + $elements = ""; + if ((isset($classArray[2])) && (is_array($classArray[2]))) { + // Convert into strings + $elements = implode(", ", $classArray[2]); + } else { + // Invalid data + $elements = "invalid_data"; + } + + // Add a message around the missing class + $message = sprintf("[%s:%d] Array %s() Does not have these elements: %s", + $classArray[0]->__toString(), + $this->getLine(), + $classArray[1], + $elements + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/main/class_MissingDecimalsThousandsSeperatorException.php b/inc/classes/exceptions/main/class_MissingDecimalsThousandsSeperatorException.php new file mode 100644 index 00000000..397e0e8a --- /dev/null +++ b/inc/classes/exceptions/main/class_MissingDecimalsThousandsSeperatorException.php @@ -0,0 +1,45 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class MissingDecimalsThousandsSeperatorException extends FrameworkException { + /** + * The constructor + * + * @param $message Message from the exception + * @param $code Code number for the exception + * @return void + */ + public function __construct ($instance, $code) { + // Add a message around the missing class + $message = sprintf("[%s:%d] Die Dezimal- und Tausendertrenner fehlen!", + $instance->__toString(), + $this->getLine() + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/main/class_MissingMethodException.php b/inc/classes/exceptions/main/class_MissingMethodException.php new file mode 100644 index 00000000..3ef08ac3 --- /dev/null +++ b/inc/classes/exceptions/main/class_MissingMethodException.php @@ -0,0 +1,47 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * @deprecated + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class MissingMethodException extends FrameworkException { + /** + * The constructor + * + * @param $classArray Array holding the exception data + * @param $code Code number for the exception + * @return void + */ + public function __construct (array $classArray, $code) { + // Add a message around the missing class + $message = sprintf("[%s:%d] This class has no method %s()!", + $classArray[0]->__toString(), + $this->getLine(), + $classArray[1] + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/main/class_NoArrayCreatedException.php b/inc/classes/exceptions/main/class_NoArrayCreatedException.php new file mode 100644 index 00000000..77072fa4 --- /dev/null +++ b/inc/classes/exceptions/main/class_NoArrayCreatedException.php @@ -0,0 +1,48 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * @todo This class is no longer needed + * @deprecated + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NoArrayCreatedException extends FrameworkException { + /** + * The constructor + * + * @param $array Message from the exception + * @param $code Code number for the exception + * @return void + */ + public function __construct (array $array, $code) { + // Add a message around the missing class + $message = sprintf("[%s:%d] %s ist kein erstelltes Objekt.", + $array[0]->__toString(), + $this->getLine(), + $array[1] + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/main/class_NoArrayException.php b/inc/classes/exceptions/main/class_NoArrayException.php new file mode 100644 index 00000000..30d312f1 --- /dev/null +++ b/inc/classes/exceptions/main/class_NoArrayException.php @@ -0,0 +1,42 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NoArrayException extends FrameworkException { + /** + * The constructor + * + * @param $message Message from the exception + * @param $code Code number for the exception + * @return void + */ + public function __construct ($string, $code) { + // Add a message around the missing class + $message = sprintf("%s ist kein Array!", + $string + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/main/class_NoObjectException.php b/inc/classes/exceptions/main/class_NoObjectException.php new file mode 100644 index 00000000..541b8498 --- /dev/null +++ b/inc/classes/exceptions/main/class_NoObjectException.php @@ -0,0 +1,46 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * @deprecated + * @see InvalidObjectException + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NoObjectException extends FrameworkException { + /** + * The constructor + * + * @param $string Name of variable + * @param $code Code number for the exception + * @return void + */ + public function __construct ($string, $code) { + // Add a message around the missing class + $message = sprintf("%s ist kein Objekt!", + $string + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/main/class_NullPointerException.php b/inc/classes/exceptions/main/class_NullPointerException.php new file mode 100644 index 00000000..551daa07 --- /dev/null +++ b/inc/classes/exceptions/main/class_NullPointerException.php @@ -0,0 +1,45 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NullPointerException extends FrameworkException { + /** + * The constructor + * + * @param $class Class throwing this exception + * @param $code Code number for the exception + * @return void + */ + public function __construct (FrameworkInterface $class, $code) { + // Add a message around the missing class + $message = sprintf("[%s:%d] An object instance is set to null.", + $class->__toString(), + $this->getLine() + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/main/class_ResponseHeadersAlreadySentException.php b/inc/classes/exceptions/main/class_ResponseHeadersAlreadySentException.php new file mode 100644 index 00000000..f08d6629 --- /dev/null +++ b/inc/classes/exceptions/main/class_ResponseHeadersAlreadySentException.php @@ -0,0 +1,45 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ResponseHeadersAlreadySentException extends FrameworkException { + /** + * The constructor + * + * @param $class Class throwing this exception + * @param $code Code number for the exception + * @return void + */ + public function __construct (FrameworkInterface $class, $code) { + // Add a message around the missing class + $message = sprintf("[%s:%d] Headers are already sent!", + $class->__toString(), + $this->getLine() + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/main/class_VariableIsNotSetException.php b/inc/classes/exceptions/main/class_VariableIsNotSetException.php new file mode 100644 index 00000000..ddcad580 --- /dev/null +++ b/inc/classes/exceptions/main/class_VariableIsNotSetException.php @@ -0,0 +1,47 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class VariableIsNotSetException extends FrameworkException { + /** + * The constructor + * + * @param $array Message from the exception + * @param $code Code number for the exception + * @return void + */ + public function __construct (array $array, $code) { + // Add a message around the missing class + $message = sprintf("[%s:%d] Bei der Initialisierung der Applikation %s wurde keine Variable %s erzeugt.", + $array[0]->__toString(), + $this->getLine(), + $array[1], + $array[2] + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/result/.htaccess b/inc/classes/exceptions/result/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/exceptions/result/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/exceptions/result/class_InvalidDatabaseResultException.php b/inc/classes/exceptions/result/class_InvalidDatabaseResultException.php new file mode 100644 index 00000000..762eb826 --- /dev/null +++ b/inc/classes/exceptions/result/class_InvalidDatabaseResultException.php @@ -0,0 +1,46 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class InvalidDatabaseResultException extends FrameworkException { + /** + * The super constructor for all exceptions + * + * @param $msgArray Error message array + * @param $code Error code + * @return void + */ + public function __construct(array $msgArray, $code) { + // Construct the message + $message = sprintf("[%s:%d] Database instance %s contains invalid entries.", + $msgArray[0]->__toString(), + $this->getLine(), + $msgArray[1]->__toString() + ); + + // Call parent exception constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/result/class_ResultUpdateException.php b/inc/classes/exceptions/result/class_ResultUpdateException.php new file mode 100644 index 00000000..e58ab045 --- /dev/null +++ b/inc/classes/exceptions/result/class_ResultUpdateException.php @@ -0,0 +1,45 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ResultUpdateException extends FrameworkException { + /** + * The super constructor for all exceptions + * + * @param $resultInstance Instance of the failed result update + * @param $code Error code + * @return void + */ + public function __construct(UpdateableResult $resultInstance, $code) { + // Construct the message + $message = sprintf("[%s:%d] Update of result instance has nothing changed.", + $resultInstance->__toString(), + $this->getLine() + ); + + // Call parent exception constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/template/.htaccess b/inc/classes/exceptions/template/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/exceptions/template/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/exceptions/template/class_BasePathIsEmptyException.php b/inc/classes/exceptions/template/class_BasePathIsEmptyException.php new file mode 100644 index 00000000..e4d4e4e6 --- /dev/null +++ b/inc/classes/exceptions/template/class_BasePathIsEmptyException.php @@ -0,0 +1,45 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BasePathIsEmptyException extends FrameworkException { + /** + * The constructor + * + * @param $class Class throwing this exception + * @param $code Code number for the exception + * @return void + */ + public function __construct (FrameworkInterface $class, $code) { + // Add a message around the missing class + $message = sprintf("[%s:%d] Template path is empty.", + $class->__toString(), + $this->getLine() + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/template/class_BasePathIsNoDirectoryException.php b/inc/classes/exceptions/template/class_BasePathIsNoDirectoryException.php new file mode 100644 index 00000000..04d510a0 --- /dev/null +++ b/inc/classes/exceptions/template/class_BasePathIsNoDirectoryException.php @@ -0,0 +1,46 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BasePathIsNoDirectoryException extends FrameworkException { + /** + * The constructor + * + * @param $classArray An array holding our informations + * @param $code Code number for the exception + * @return void + */ + public function __construct (array $classArray, $code) { + // Add a message around the missing class + $message = sprintf("[%s:%d] Der Template-Basispfad %s existiert nicht oder ist eine Datei!", + $classArray[0]->__toString(), + $this->getLine(), + $classArray[1] + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/template/class_BasePathReadProtectedException.php b/inc/classes/exceptions/template/class_BasePathReadProtectedException.php new file mode 100644 index 00000000..6a4d956e --- /dev/null +++ b/inc/classes/exceptions/template/class_BasePathReadProtectedException.php @@ -0,0 +1,46 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BasePathReadProtectedException extends FrameworkException { + /** + * The constructor + * + * @param $classArray An array holding our informations + * @param $code Code number for the exception + * @return void + */ + public function __construct (array $classArray, $code) { + // Add a message around the missing class + $message = sprintf("[%s:%d] Der Template-Basispfad %s ist lesegeschützt! Bitte Zugriffsrechte (CHMOD) ändern.", + $classArray[0]->__toString(), + $this->getLine(), + $classArray[1] + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/template/class_InvalidBasePathStringException.php b/inc/classes/exceptions/template/class_InvalidBasePathStringException.php new file mode 100644 index 00000000..93f875e9 --- /dev/null +++ b/inc/classes/exceptions/template/class_InvalidBasePathStringException.php @@ -0,0 +1,46 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class InvalidBasePathStringException extends FrameworkException { + /** + * The constructor + * + * @param $classArray Array holding exception data + * @param $code Code number for the exception + * @return void + */ + public function __construct (array $classArray, $code) { + // Add a message around the missing class + $message = sprintf("[%s:%d] %s is not a string with a base path!", + $classArray[0]->__toString(), + $this->getLine(), + $classArray[1] + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/template/class_UnexpectedTemplateTypeException.php b/inc/classes/exceptions/template/class_UnexpectedTemplateTypeException.php new file mode 100644 index 00000000..9394348a --- /dev/null +++ b/inc/classes/exceptions/template/class_UnexpectedTemplateTypeException.php @@ -0,0 +1,47 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class UnexpectedTemplateTypeException extends FrameworkException { + /** + * The constructor + * + * @param $msgArray An array holding our informations + * @param $code Code number for the exception + * @return void + */ + public function __construct (array $msgArray, $code) { + // Add a message around the missing class + $message = sprintf("[%s:%d] Der Template-Typ %s entspricht nicht dem erwartetem Template-Typ %s.", + $msgArray[0]->__toString(), + $this->getLine(), + $msgArray[1], + $msgArray[2] + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/template/class_UnsupportedTemplateEngineException.php b/inc/classes/exceptions/template/class_UnsupportedTemplateEngineException.php new file mode 100644 index 00000000..75c81a4f --- /dev/null +++ b/inc/classes/exceptions/template/class_UnsupportedTemplateEngineException.php @@ -0,0 +1,44 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class UnsupportedTemplateEngineException extends FrameworkException { + /** + * The constructor + * + * @param $class Class throwing this class + * @param $code Code number for the exception + * @return void + */ + public function __construct (FrameworkInterface $class, $code) { + // Add a message around the missing class + $message = sprintf("Template-Engine %s not (yet) supported.", + $class->__toString() + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/template/class_ViewHelperNotFoundException.php b/inc/classes/exceptions/template/class_ViewHelperNotFoundException.php new file mode 100644 index 00000000..37b33427 --- /dev/null +++ b/inc/classes/exceptions/template/class_ViewHelperNotFoundException.php @@ -0,0 +1,47 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * @todo Rename this class to NoViewHelperException + * @deprecated + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ViewHelperNotFoundException extends FrameworkException { + /** + * The constructor + * + * @param $msgArray An array holding our informations + * @param $code Code number for the exception + * @return void + */ + public function __construct (array $msgArray, $code) { + // Add a message around the missing class + $message = sprintf("[%s:] View-Helper %s ist ungültig.", + $msgArray[0]->__toString(), + $msgArray[1] + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/user/.htaccess b/inc/classes/exceptions/user/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/exceptions/user/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/exceptions/user/class_AccountPasswordMismatchException.php b/inc/classes/exceptions/user/class_AccountPasswordMismatchException.php new file mode 100644 index 00000000..603f1325 --- /dev/null +++ b/inc/classes/exceptions/user/class_AccountPasswordMismatchException.php @@ -0,0 +1,45 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class AccountPasswordMismatchException extends FrameworkException { + /** + * The super constructor for all exceptions + * + * @param $filterInstance A filterable class instance + * @param $code An optional code for better debugging + * @return void + */ + public function __construct(Filterable $filterInstance, $code) { + // Create the message + $message = sprintf("[%s:%d] Supplied account password did not match with stored.", + $filterInstance->__toString(), + $this->getLine() + ); + + // Make sure everything is assigned properly + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/user/class_UserEmailMissingException.php b/inc/classes/exceptions/user/class_UserEmailMissingException.php new file mode 100644 index 00000000..dcef3708 --- /dev/null +++ b/inc/classes/exceptions/user/class_UserEmailMissingException.php @@ -0,0 +1,46 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class UserEmailMissingException extends FrameworkException { + /** + * The super constructor for all exceptions + * + * @param $msgArray The non-optional message for the exception + * @param $code An optional code for better debugging + * @return void + */ + public function __construct(array $msgArray, $code = 0) { + // Create the message + $message = sprintf("[%s:%d] User email %s was not found.", + $msgArray[0]->__toString(), + $this->getLine(), + $msgArray[1] + ); + + // Make sure everything is assigned properly + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/user/class_UserPasswordMismatchException.php b/inc/classes/exceptions/user/class_UserPasswordMismatchException.php new file mode 100644 index 00000000..04579307 --- /dev/null +++ b/inc/classes/exceptions/user/class_UserPasswordMismatchException.php @@ -0,0 +1,46 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class UserPasswordMismatchException extends FrameworkException { + /** + * The super constructor for all exceptions + * + * @param $msgArray The non-optional message for the exception + * @param $code An optional code for better debugging + * @return void + */ + public function __construct(array $msgArray, $code = 0) { + // Create the message + $message = sprintf("[%s:%d] Supplied password for user %s did not match with stored password.", + $msgArray[0]->__toString(), + $this->getLine(), + $msgArray[1]->getUserName() + ); + + // Make sure everything is assigned properly + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/user/class_UsernameMissingException.php b/inc/classes/exceptions/user/class_UsernameMissingException.php new file mode 100644 index 00000000..9f5e52dd --- /dev/null +++ b/inc/classes/exceptions/user/class_UsernameMissingException.php @@ -0,0 +1,46 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class UsernameMissingException extends FrameworkException { + /** + * The super constructor for all exceptions + * + * @param $msgArray The non-optional message for the exception + * @param $code An optional code for better debugging + * @return void + */ + public function __construct(array $msgArray, $code = 0) { + // Create the message + $message = sprintf("[%s:%d] Username %s was not found.", + $msgArray[0]->__toString(), + $this->getLine(), + $msgArray[1] + ); + + // Make sure everything is assigned properly + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/xml/.htaccess b/inc/classes/exceptions/xml/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/exceptions/xml/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/exceptions/xml/class_InvalidXmlNodeException.php b/inc/classes/exceptions/xml/class_InvalidXmlNodeException.php new file mode 100644 index 00000000..d503ae6f --- /dev/null +++ b/inc/classes/exceptions/xml/class_InvalidXmlNodeException.php @@ -0,0 +1,53 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class InvalidXmlNodeException extends FrameworkException { + /** + * The super constructor for all exceptions + * + * @param $classArray Array holding the exception data + * @param $code Error code + * @return void + */ + public function __construct (array $classArray, $code) { + // Extract attributes + $attributes = "None"; + if ((is_array($classArray[2])) && (count($classArray[2]) > 0)) { + $attributes = implode(", ", $classArray[2]); + } // END - if + + // Construct our message + $message = sprintf("[%s:%d] Invalid XML node found: %s, attributes: %s.", + $classArray[0]->__toString(), + $this->getLine(), + $classArray[1], + $attributes + ); + + // Call parent exception constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/xml/class_XmlNodeMismatchException.php b/inc/classes/exceptions/xml/class_XmlNodeMismatchException.php new file mode 100644 index 00000000..848d542c --- /dev/null +++ b/inc/classes/exceptions/xml/class_XmlNodeMismatchException.php @@ -0,0 +1,47 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class XmlNodeMismatchException extends FrameworkException { + /** + * The super constructor for all exceptions + * + * @param $classArray Array holding the exception data + * @param $code Error code + * @return void + */ + public function __construct (array $classArray, $code) { + // Construct our message + $message = sprintf("[%s:%d] XML nodes mismatch. Given: %s, Expected: %s", + $classArray[0]->__toString(), + $this->getLine(), + $classArray[1], + $classArray[2] + ); + + // Call parent exception constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/xml/class_XmlParserException.php b/inc/classes/exceptions/xml/class_XmlParserException.php new file mode 100644 index 00000000..91d12e53 --- /dev/null +++ b/inc/classes/exceptions/xml/class_XmlParserException.php @@ -0,0 +1,47 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class XmlParserException extends FrameworkException { + /** + * The super constructor for all exceptions + * + * @param $classArray Array holding the exception data + * @param $code Error code + * @return void + */ + public function __construct (array $classArray, $code) { + // Construct our message + $message = sprintf("[%s:%d] XML Error: %s at line %d.", + $classArray[0]->__toString(), + $this->getLine(), + xml_error_string(xml_get_error_code($classArray[1])), + xml_get_current_line_number($classArray[1]) + ); + + // Call parent exception constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/interfaces/.htaccess b/inc/classes/interfaces/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/interfaces/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/interfaces/actions/.htaccess b/inc/classes/interfaces/actions/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/interfaces/actions/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/interfaces/actions/class_PerformableAction.php b/inc/classes/interfaces/actions/class_PerformableAction.php new file mode 100644 index 00000000..ad06b8c5 --- /dev/null +++ b/inc/classes/interfaces/actions/class_PerformableAction.php @@ -0,0 +1,36 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface PerformableAction extends FrameworkInterface { + /** + * Executes the command with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + */ + function execute (Requestable $requestInstance, Responseable $responseInstance); +} + +// +?> diff --git a/inc/classes/interfaces/actions/commands/.htaccess b/inc/classes/interfaces/actions/commands/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/interfaces/actions/commands/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/interfaces/actions/commands/class_Commandable.php b/inc/classes/interfaces/actions/commands/class_Commandable.php new file mode 100644 index 00000000..2bd63f00 --- /dev/null +++ b/inc/classes/interfaces/actions/commands/class_Commandable.php @@ -0,0 +1,36 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface Commandable extends PerformableAction { + /** + * Adds extra filters to the given controller instance + * + * @param $controllerInstance A controller instance + * @param $requestInstance An instance of a class with an Requestable interface + * @return void + */ + function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance); +} + +// +?> diff --git a/inc/classes/interfaces/application/.htaccess b/inc/classes/interfaces/application/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/interfaces/application/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/interfaces/application/class_ManageableApplication.php b/inc/classes/interfaces/application/class_ManageableApplication.php new file mode 100644 index 00000000..ec0e2b65 --- /dev/null +++ b/inc/classes/interfaces/application/class_ManageableApplication.php @@ -0,0 +1,99 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface ManageableApplication extends FrameworkInterface { + /** + * Getter for application's version number + * + * @return $appVersion The application's version number + */ + function getAppVersion (); + /** + * Setter for application's version number + * + * @param $appVersion The application's version number + * @return void + */ + function setAppVersion ($appVersion); + + /** + * Getter for application's human-readable name + * + * @return $appName The application's name readable for humans + */ + function getAppName (); + + /** + * Setter for application's human-readable name + * + * @param $appName The application's name readable for humans + * @return void + */ + function setAppName ($appName); + + /** + * Getter for application's short uni*-like name + * + * @return $shortName The application's name readable for humans + */ + function getAppShortName (); + + /** + * Setter for application's short uni*-like name + * + * @param $shortName The application's name readable for humans + * @return void + */ + function setAppShortName ($shortName); + + /** + * Getter for master template name + * + * @return $masterTemplate Name of the master template + */ + function getMasterTemplate (); + + /** + * Launches the application + * + * @return void + */ + function entryPoint (); + + /** + * Handle the indexed array of fatal messages and puts them out in an + * acceptable fasion + * + * @param $messageList An array of fatal messages + * @return void + */ + function handleFatalMessages (array $messageList); +} + +// [EOF] +?> diff --git a/inc/classes/interfaces/auth/.htaccess b/inc/classes/interfaces/auth/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/interfaces/auth/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/interfaces/auth/class_Authorizeable.php b/inc/classes/interfaces/auth/class_Authorizeable.php new file mode 100644 index 00000000..1ddfad6d --- /dev/null +++ b/inc/classes/interfaces/auth/class_Authorizeable.php @@ -0,0 +1,41 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface Authorizeable extends FrameworkInterface { + /** + * Destroy the authorization data + * + * @return void + */ + function destroyAuthData(); + + /** + * Updates the authorization data and/or sets additional tracking data + * + * @return void + */ + function updateAuthData (); +} + +// +?> diff --git a/inc/classes/interfaces/cache/.htaccess b/inc/classes/interfaces/cache/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/interfaces/cache/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/interfaces/cache/class_Cacheable.php b/inc/classes/interfaces/cache/class_Cacheable.php new file mode 100644 index 00000000..39cb18cc --- /dev/null +++ b/inc/classes/interfaces/cache/class_Cacheable.php @@ -0,0 +1,35 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface Cacheable extends FrameworkInterface { + /** + * Does the specified offset exist in cache? + * + * @param $offset The offsrt we are looking for + * @return $exists Wether the offset exists + */ + function offsetExists ($offset); +} + +// [EOF] +?> diff --git a/inc/classes/interfaces/captcha/.htaccess b/inc/classes/interfaces/captcha/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/interfaces/captcha/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/interfaces/captcha/class_SolveableCaptcha.php b/inc/classes/interfaces/captcha/class_SolveableCaptcha.php new file mode 100644 index 00000000..e21ce4ad --- /dev/null +++ b/inc/classes/interfaces/captcha/class_SolveableCaptcha.php @@ -0,0 +1,41 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface SolveableCaptcha extends FrameworkInterface { + /** + * Initiates the CAPTCHA + * + * @return void + */ + function initiateCaptcha (); + + /** + * Render the CAPTCHA code + * + * @return void + */ + function renderCode (); +} + +// +?> diff --git a/inc/classes/interfaces/class_ b/inc/classes/interfaces/class_ new file mode 100644 index 00000000..b750dd9f --- /dev/null +++ b/inc/classes/interfaces/class_ @@ -0,0 +1,28 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface extends FrameworkInterface { +} + +// +?> diff --git a/inc/classes/interfaces/class_FrameworkInterface.php b/inc/classes/interfaces/class_FrameworkInterface.php new file mode 100644 index 00000000..bffb8743 --- /dev/null +++ b/inc/classes/interfaces/class_FrameworkInterface.php @@ -0,0 +1,37 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface FrameworkInterface { + /** + * Getter for field name + * + * @param $fieldName Field name which we shall get + * @return $fieldValue Field value from the user + * @throws NullPointerException If the result instance is null + */ + function getField ($fieldName); +} + +// +?> diff --git a/inc/classes/interfaces/compressor/.htaccess b/inc/classes/interfaces/compressor/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/interfaces/compressor/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/interfaces/compressor/class_Compressor.php b/inc/classes/interfaces/compressor/class_Compressor.php new file mode 100644 index 00000000..0e8dfcb4 --- /dev/null +++ b/inc/classes/interfaces/compressor/class_Compressor.php @@ -0,0 +1,52 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface Compressor extends FrameworkInterface { + /** + * A compression stream + * + * @param $streamData Mixed non-object stream data + * @return $streamData The compressed stream data + * @throws InvalidObjectException If the stream is an object + */ + function compressStream ($streamData); + + /** + * A decompression stream + * + * @param $streamData Mixed non-object stream data + * @return $streamData The decompressed stream data + * @throws InvalidObjectException If the stream is an object + */ + function decompressStream ($streamData); + + /** + * Getter for the file extension of this compressor + * + * @return $string The compressor's file extension + */ + function getCompressorExtension (); +} + +// [EOF] +?> diff --git a/inc/classes/interfaces/controller/.htaccess b/inc/classes/interfaces/controller/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/interfaces/controller/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/interfaces/controller/class_Controller.php b/inc/classes/interfaces/controller/class_Controller.php new file mode 100644 index 00000000..bf8ae971 --- /dev/null +++ b/inc/classes/interfaces/controller/class_Controller.php @@ -0,0 +1,36 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface Controller extends FrameworkInterface { + /** + * Handles the given request and response + * + * @param $requestInstance An instance of a request class + * @param $responseInstance An instance of a response class + * @return void + */ + function handleRequest (Requestable $requestInstance, Responseable $responseInstance); +} + +// +?> diff --git a/inc/classes/interfaces/criteria/.htaccess b/inc/classes/interfaces/criteria/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/interfaces/criteria/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/interfaces/criteria/class_Criteria.php b/inc/classes/interfaces/criteria/class_Criteria.php new file mode 100644 index 00000000..64ec5ad7 --- /dev/null +++ b/inc/classes/interfaces/criteria/class_Criteria.php @@ -0,0 +1,45 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface Criteria extends FrameworkInterface { + /** + * Add criteria + * + * @param $criteriaKey Criteria key + * @param $criteriaValue Criteria value + * @return void + */ + function addCriteria ($criteriaKey, $criteriaValue); + + /** + * Add configured criteria + * + * @param $criteriaKey Criteria key + * @param $configEntry Configuration entry + * @return void + */ + function addConfiguredCriteria ($criteriaKey, $configEntry); +} + +// +?> diff --git a/inc/classes/interfaces/criteria/extended/.htaccess b/inc/classes/interfaces/criteria/extended/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/interfaces/criteria/extended/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/interfaces/criteria/extended/class_LocalSearchCriteria.php b/inc/classes/interfaces/criteria/extended/class_LocalSearchCriteria.php new file mode 100644 index 00000000..dd09ad5f --- /dev/null +++ b/inc/classes/interfaces/criteria/extended/class_LocalSearchCriteria.php @@ -0,0 +1,28 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface LocalSearchCriteria extends Criteria { +} + +// +?> diff --git a/inc/classes/interfaces/criteria/extended/class_LocalUpdateCriteria.php b/inc/classes/interfaces/criteria/extended/class_LocalUpdateCriteria.php new file mode 100644 index 00000000..c88e0b09 --- /dev/null +++ b/inc/classes/interfaces/criteria/extended/class_LocalUpdateCriteria.php @@ -0,0 +1,28 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface LocalUpdateCriteria extends Criteria { +} + +// +?> diff --git a/inc/classes/interfaces/criteria/extended/class_StoreableCriteria.php b/inc/classes/interfaces/criteria/extended/class_StoreableCriteria.php new file mode 100644 index 00000000..6abde1af --- /dev/null +++ b/inc/classes/interfaces/criteria/extended/class_StoreableCriteria.php @@ -0,0 +1,28 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface StoreableCriteria extends Criteria { +} + +// [EOF] +?> diff --git a/inc/classes/interfaces/crypto/.htaccess b/inc/classes/interfaces/crypto/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/interfaces/crypto/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/interfaces/crypto/class_Cryptable.php b/inc/classes/interfaces/crypto/class_Cryptable.php new file mode 100644 index 00000000..9bb60758 --- /dev/null +++ b/inc/classes/interfaces/crypto/class_Cryptable.php @@ -0,0 +1,55 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface Cryptable extends FrameworkInterface { + /** + * Hashes a string with salt and returns the hash. If an old previous hash + * is supplied the method will use the first X chars of that hash for hashing + * the password. This is useful if you want to check if password is identical + * for authorization purposes. + * + * @param $str Unhashed string + * @param $oldHash A hash from previous hashed string + * @return $hashed The hashed and salted string + */ + function hashString ($str, $oldHash = ""); + + /** + * Encrypt the string with fixed salt + * + * @param $str The unencrypted string + * @return $encrypted Encrypted string + */ + function encryptString ($str); + + /** + * Decrypt the string with fixed salt + * + * @param $encrypted Encrypted string + * @return $str The unencrypted string + */ + function decryptString ($encrypted); +} + +// [EOF] +?> diff --git a/inc/classes/interfaces/database/.htaccess b/inc/classes/interfaces/database/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/interfaces/database/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/interfaces/database/class_FrameworkDatabaseInterface.php b/inc/classes/interfaces/database/class_FrameworkDatabaseInterface.php new file mode 100644 index 00000000..6e3f3d6d --- /dev/null +++ b/inc/classes/interfaces/database/class_FrameworkDatabaseInterface.php @@ -0,0 +1,28 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface FrameworkDatabaseInterface extends FrameworkInterface { +} + +// [EOF] +?> diff --git a/inc/classes/interfaces/database/class_Updateable.php b/inc/classes/interfaces/database/class_Updateable.php new file mode 100644 index 00000000..ba8de80f --- /dev/null +++ b/inc/classes/interfaces/database/class_Updateable.php @@ -0,0 +1,37 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface Updateable extends FrameworkInterface { + /** + * Updates a given field with new value + * + * @param $fieldName Field to update + * @param $fieldValue New value to store + * @return void + * @throws DatabaseUpdateSupportException If this class does not support database updates + */ + function updateDatabaseField ($fieldName, $fieldValue); +} + +// +?> diff --git a/inc/classes/interfaces/database/frontend/.htaccess b/inc/classes/interfaces/database/frontend/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/interfaces/database/frontend/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/interfaces/database/frontend/class_DatabaseFrontendInterface.php b/inc/classes/interfaces/database/frontend/class_DatabaseFrontendInterface.php new file mode 100644 index 00000000..1d3ebe58 --- /dev/null +++ b/inc/classes/interfaces/database/frontend/class_DatabaseFrontendInterface.php @@ -0,0 +1,69 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface DatabaseFrontendInterface extends FrameworkDatabaseInterface { + /** + * Makes sure that the database connection is up and alive + * + * @return void + */ + function connectToDatabase (); + + /** + * Starts a SELECT query on the database by given return type, table name + * and search criteria + * + * @param $resultType Result type ("array", "object" and "indexed" are valid) + * @param $tableName Name of the database table + * @param $criteria Search criteria class + * @return $resultData Result data of the query + * @throws UnsupportedCriteriaException If the criteria is unsupported + * @throws SqlException If an SQL error occurs + */ + function querySelect ($resultType, $tableName, LocalSearchCriteria $criteriaInstance); + + /** + * "Inserts" a data set instance into a local file database folder + * + * @param $dataSetInstance A storeable data set + * @return void + * @throws SqlException If an SQL error occurs + */ + function queryInsertDataSet (StoreableCriteria $dataSetInstance); + + /** + * "Updates" a data set instance with a database layer + * + * @param $dataSetInstance A storeable data set + * @return void + * @throws SqlException If an SQL error occurs + */ + function queryUpdateDataSet (StoreableCriteria $dataSetInstance); +} + +// [EOF] +?> diff --git a/inc/classes/interfaces/database/middleware/.htaccess b/inc/classes/interfaces/database/middleware/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/interfaces/database/middleware/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/interfaces/database/middleware/class_DatabaseConnector.php b/inc/classes/interfaces/database/middleware/class_DatabaseConnector.php new file mode 100644 index 00000000..995f43a4 --- /dev/null +++ b/inc/classes/interfaces/database/middleware/class_DatabaseConnector.php @@ -0,0 +1,28 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface DatabaseConnector extends FrameworkDatabaseInterface { +} + +// [EOF] +?> diff --git a/inc/classes/interfaces/debug/.htaccess b/inc/classes/interfaces/debug/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/interfaces/debug/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/interfaces/debug/class_Debugger.php b/inc/classes/interfaces/debug/class_Debugger.php new file mode 100644 index 00000000..8700229d --- /dev/null +++ b/inc/classes/interfaces/debug/class_Debugger.php @@ -0,0 +1,35 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface Debugger extends FrameworkInterface { + /** + * Outputs the given data + * + * @param $output Debug text for output + * @return void + */ + function outputStream ($output); +} + +// +?> diff --git a/inc/classes/interfaces/discovery/.htaccess b/inc/classes/interfaces/discovery/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/interfaces/discovery/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/interfaces/discovery/class_Discoverable.php b/inc/classes/interfaces/discovery/class_Discoverable.php new file mode 100644 index 00000000..4aa69e80 --- /dev/null +++ b/inc/classes/interfaces/discovery/class_Discoverable.php @@ -0,0 +1,43 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface Discoverable extends FrameworkInterface { + /** + * Discovers the request + * + * @param $requestInstance An instance of a Requestable class + * @return void + */ + function discover (Requestable $requestInstance); + + /** + * Adds the database result in a human-readable format to the helper class + * + * @param $helperInstance An instance of a helper class + * @return void + */ + function addResultsToHelper (HelpableTemplate $helperInstance); +} + +// +?> diff --git a/inc/classes/interfaces/filter/.htaccess b/inc/classes/interfaces/filter/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/interfaces/filter/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/interfaces/filter/class_Filterable.php b/inc/classes/interfaces/filter/class_Filterable.php new file mode 100644 index 00000000..ad2c568c --- /dev/null +++ b/inc/classes/interfaces/filter/class_Filterable.php @@ -0,0 +1,36 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface Filterable extends FrameworkInterface { + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + */ + function execute (Requestable $requestInstance, Responseable $responseInstance); +} + +// +?> diff --git a/inc/classes/interfaces/helper/.htaccess b/inc/classes/interfaces/helper/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/interfaces/helper/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/interfaces/helper/class_HelpableLogin.php b/inc/classes/interfaces/helper/class_HelpableLogin.php new file mode 100644 index 00000000..c1919d2e --- /dev/null +++ b/inc/classes/interfaces/helper/class_HelpableLogin.php @@ -0,0 +1,36 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface HelpableLogin extends FrameworkInterface { + /** + * Execute the login request by given response instance. This instance can + * be used for sending cookies or at least the session id out. + * + * @param $responseInstance An instance of a Responseable class + * @return void + */ + function executeLogin (Responseable $responseInstance); +} + +// +?> diff --git a/inc/classes/interfaces/helper/class_HelpableTemplate.php b/inc/classes/interfaces/helper/class_HelpableTemplate.php new file mode 100644 index 00000000..d0a10f5f --- /dev/null +++ b/inc/classes/interfaces/helper/class_HelpableTemplate.php @@ -0,0 +1,34 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface HelpableTemplate extends FrameworkInterface { + /** + * Flush the content out,e g. to a template variable + * + * @return void + */ + function flushContent (); +} + +// +?> diff --git a/inc/classes/interfaces/io/.htaccess b/inc/classes/interfaces/io/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/interfaces/io/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/interfaces/io/class_Streamable.php b/inc/classes/interfaces/io/class_Streamable.php new file mode 100644 index 00000000..975fbb37 --- /dev/null +++ b/inc/classes/interfaces/io/class_Streamable.php @@ -0,0 +1,28 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface Streamable extends FrameworkInterface { +} + +// +?> diff --git a/inc/classes/interfaces/io/file/.htaccess b/inc/classes/interfaces/io/file/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/interfaces/io/file/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/interfaces/io/file/class_FileInputStreamer.php b/inc/classes/interfaces/io/file/class_FileInputStreamer.php new file mode 100644 index 00000000..ddd44169 --- /dev/null +++ b/inc/classes/interfaces/io/file/class_FileInputStreamer.php @@ -0,0 +1,38 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface FileInputStreamer extends Streamable { + /** + * Reads from a local or remote file + * + * @param $fqfn The file's FQFN we shall load + * @return $array An array containing all read lines + * @throws InvalidArrayCountException If an array has not the + * expected size + * @throws InvalidMD5ChecksumException If two MD5 hashes did not match + */ + function loadFileContents ($fqfn); +} + +// +?> diff --git a/inc/classes/interfaces/io/file/class_FileOutputStreamer.php b/inc/classes/interfaces/io/file/class_FileOutputStreamer.php new file mode 100644 index 00000000..20fa404e --- /dev/null +++ b/inc/classes/interfaces/io/file/class_FileOutputStreamer.php @@ -0,0 +1,38 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface FileOutputStreamer extends Streamable { + /** + * Saves streamed (that are mostly serialized objects) data to files or + * external servers. + * + * @param $fileName The local file's name including full path + * @param $dataArray Array containing the compressor's extension + * and streamed data + * @return void + */ + function saveFile ($fileName, $dataArray); +} + +// +?> diff --git a/inc/classes/interfaces/io/output/.htaccess b/inc/classes/interfaces/io/output/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/interfaces/io/output/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/interfaces/io/output/class_OutputStreamer.php b/inc/classes/interfaces/io/output/class_OutputStreamer.php new file mode 100644 index 00000000..4d8221fc --- /dev/null +++ b/inc/classes/interfaces/io/output/class_OutputStreamer.php @@ -0,0 +1,43 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface OutputStreamer extends Streamable { + /** + * Assigns a variable for output + * + * @param $var The variable we shall assign + * @param $value The value to store in the variable + * @return void + */ + function assignVariable ($var, $value); + + /** + * Output the code + * + * @return void + */ + function output ($outStream=false); +} + +// +?> diff --git a/inc/classes/interfaces/language/.htaccess b/inc/classes/interfaces/language/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/interfaces/language/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/interfaces/language/class_ManageableLanguage.php b/inc/classes/interfaces/language/class_ManageableLanguage.php new file mode 100644 index 00000000..7bae5901 --- /dev/null +++ b/inc/classes/interfaces/language/class_ManageableLanguage.php @@ -0,0 +1,34 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface ManageableLanguage extends FrameworkInterface { + /** + * Initialize the array-object for all later language strings + * + * @return void + */ + function initLanguageStrings(); +} // END - class + +// [EOF] +?> diff --git a/inc/classes/interfaces/login/.htaccess b/inc/classes/interfaces/login/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/interfaces/login/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/interfaces/login/class_LoginableUser.php b/inc/classes/interfaces/login/class_LoginableUser.php new file mode 100644 index 00000000..9bb89ca6 --- /dev/null +++ b/inc/classes/interfaces/login/class_LoginableUser.php @@ -0,0 +1,38 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface LoginableUser extends FrameworkInterface { + /** + * Logins the user with the given request containing the credential. The + * result of the login can be thrown by exception or, if prefered stored + * in a boolean attribute which is then readable by a matching getter. + * + * @param $requestInstance An instance of a Requestable class + * @param $responseInstance An instance of a Responseable class + * @return void + */ + function doLogin (Requestable $requestInstance, Responseable $responseInstance); +} + +// +?> diff --git a/inc/classes/interfaces/mailer/.htaccess b/inc/classes/interfaces/mailer/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/interfaces/mailer/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/interfaces/mailer/class_DeliverableMail.php b/inc/classes/interfaces/mailer/class_DeliverableMail.php new file mode 100644 index 00000000..7e042044 --- /dev/null +++ b/inc/classes/interfaces/mailer/class_DeliverableMail.php @@ -0,0 +1,56 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface DeliverableMail extends FrameworkInterface { + /** + * Adds a user class to the recipient list for current template + * + * @param $userInstance An instance of a user class + * @return void + */ + function addRecipientByUserInstance (ManageableMember $userInstance); + + /** + * Use subject line provided by the (XML) template otherwise a subject line must be set + * + * @return void + */ + function useSubjectFromTemplate (); + + /** + * Deliver email to the recipient(s) + * + * @return void + */ + function deliverEmail (); + + /** + * Send notification to the admin + * + * @return void + */ + function sendAdminNotification (); +} + +// +?> diff --git a/inc/classes/interfaces/reader/.htaccess b/inc/classes/interfaces/reader/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/interfaces/reader/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/interfaces/reader/class_ReadableNews.php b/inc/classes/interfaces/reader/class_ReadableNews.php new file mode 100644 index 00000000..3c54d42e --- /dev/null +++ b/inc/classes/interfaces/reader/class_ReadableNews.php @@ -0,0 +1,34 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface ReadableNews extends FrameworkInterface { + /** + * Initializes the news reader class. This is very reader-dependent + * + * @return void + */ + function initializeReader(); +} + +// +?> diff --git a/inc/classes/interfaces/registration/.htaccess b/inc/classes/interfaces/registration/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/interfaces/registration/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/interfaces/registration/class_UserRegister.php b/inc/classes/interfaces/registration/class_UserRegister.php new file mode 100644 index 00000000..cc15f8e2 --- /dev/null +++ b/inc/classes/interfaces/registration/class_UserRegister.php @@ -0,0 +1,76 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface UserRegister extends FrameworkInterface { + /** + * Encrypt given request key or throws an exception if key was not found in + * request. + * + * @param $requestKey Key in request class + * @return void + */ + function encryptPassword ($requestKey); + + /** + * Perform things like informing assigned affilates about new registration + * before registration + * + * @return void + */ + function doPreRegistration (); + + /** + * Registers the new user account by insterting the request data into the + * database and paying some start credits or throw exceptions if this fails + * + * @return void + */ + function registerNewUser (); + + /** + * Perform things like notifying partner websites after registration is done + * + * @return void + */ + function doPostRegistration (); + + /** + * Do the action which is required after all registration steps are done. + * This can be a simple redirect to another webpage or displaying a message + * to the user. Or this can be a login step into the newly created account. + * + * @return void + */ + function doPostAction (); + + /** + * Adds registration elements to a given dataset instance + * + * @param $criteriaInstance An instance of a storeable criteria + * @return void + */ + function addElementsToDataSet (StoreableCriteria $criteriaInstance); +} + +// +?> diff --git a/inc/classes/interfaces/registry/.htaccess b/inc/classes/interfaces/registry/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/interfaces/registry/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/interfaces/registry/class_Register.php b/inc/classes/interfaces/registry/class_Register.php new file mode 100644 index 00000000..d59051f3 --- /dev/null +++ b/inc/classes/interfaces/registry/class_Register.php @@ -0,0 +1,52 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface Register extends FrameworkInterface { + /** + * Checks wether an instance key was found + * + * @param $instanceKey The key holding an instance in registry + * @return $exists Wether the key exists in registry + */ + function instanceExists ($instanceKey); + + /** + * Adds/overwrites a new instance to the registry at the given key + * + * @param $instanceKey The key to identify the instance + * @param $objectInstance An instance we shall store + * @return void + */ + function addInstance ($instanceKey, Registerable $objectInstance); + + /** + * Gets a registered instance or null if not found + * + * @param $instanceKey The key to identify the instance + * @return $objectInstance An instance we shall store + */ + function getInstance ($instanceKey); +} + +// [EOF] +?> diff --git a/inc/classes/interfaces/registry/class_Registerable.php b/inc/classes/interfaces/registry/class_Registerable.php new file mode 100644 index 00000000..16ed10e2 --- /dev/null +++ b/inc/classes/interfaces/registry/class_Registerable.php @@ -0,0 +1,28 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface Registerable extends FrameworkInterface { +} + +// [EOF] +?> diff --git a/inc/classes/interfaces/request/.htaccess b/inc/classes/interfaces/request/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/interfaces/request/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/interfaces/request/class_Requestable.php b/inc/classes/interfaces/request/class_Requestable.php new file mode 100644 index 00000000..e5f9fa64 --- /dev/null +++ b/inc/classes/interfaces/request/class_Requestable.php @@ -0,0 +1,84 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface Requestable extends FrameworkInterface { + /** + * Prepares the HTTP request data for usage by currently copying + * $_REQUEST into a private attribute. Later on we can add more + * things for initialization here. + * + * @return void + */ + function prepareRequestData (); + + /** + * Checks wether a request element is set + * @param $element Name of the request element we want to check + * @return $isSet Wether the request element is set + * @throws MissingArrayElementsException Thrown if a request element is not set + */ + function isRequestElementSet ($element); + + /** + * Getter for request element or 'null' if element was not found + * + * @param $element Name of the request element we want to check + * @return $value Value of the found request element or 'null' if the + * element was not found + */ + function getRequestElement ($element); + + /** + * Wrapper method for array_key() function for the request data array + * + * @return $array An array containing all array keys to return + */ + function getParameterNames (); + + /** + * Getter for a header element or 'null' if header was not found + * + * @param $headerName Name of the header + * @return $headerValue Value of the header or 'null' if not found + */ + function getHeader ($headerName); + + /** + * Sets wether the request was valid (default: true) + * + * @param $isValid Wether the request is valid + * @return void + */ + function requestIsValid ($isValid = true); + + /** + * Reads a cookie and returns it's value or null if not found + * + * @param $cookieName Name of cookie we shall read + * @return $cookieValue Value of cookie or null if not found + */ + function readCookie ($cookieName); +} + +// +?> diff --git a/inc/classes/interfaces/resolver/.htaccess b/inc/classes/interfaces/resolver/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/interfaces/resolver/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/interfaces/resolver/actions/.htaccess b/inc/classes/interfaces/resolver/actions/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/interfaces/resolver/actions/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/interfaces/resolver/actions/class_ActionResolver.php b/inc/classes/interfaces/resolver/actions/class_ActionResolver.php new file mode 100644 index 00000000..7a12f3d0 --- /dev/null +++ b/inc/classes/interfaces/resolver/actions/class_ActionResolver.php @@ -0,0 +1,51 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface ActionResolver extends Resolver { + /** + * Returns an action instance for the current action + * + * @return $actionInstance An instance of the resolved action + */ + function resolveAction (); + + /** + * Returns an action instance for a given request class + * + * @param $requestInstance An instance of a request class + * @return $actionInstance An instance of the resolved action + */ + function resolveActionByRequest (Requestable $requestInstance); + + /** + * Checks wether the given action is valid + * + * @param $actionName The default action we shall execute + * @return $isValid Wether the given action is valid + * @throws EmptyVariableException Thrown if given action is not set + */ + function isActionValid ($actionName); +} + +// +?> diff --git a/inc/classes/interfaces/resolver/class_Resolver.php b/inc/classes/interfaces/resolver/class_Resolver.php new file mode 100644 index 00000000..376d8627 --- /dev/null +++ b/inc/classes/interfaces/resolver/class_Resolver.php @@ -0,0 +1,28 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface Resolver extends FrameworkInterface { +} + +// +?> diff --git a/inc/classes/interfaces/resolver/commands/.htaccess b/inc/classes/interfaces/resolver/commands/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/interfaces/resolver/commands/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/interfaces/resolver/commands/class_CommandResolver.php b/inc/classes/interfaces/resolver/commands/class_CommandResolver.php new file mode 100644 index 00000000..d7f3976a --- /dev/null +++ b/inc/classes/interfaces/resolver/commands/class_CommandResolver.php @@ -0,0 +1,44 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface CommandResolver extends Resolver { + /** + * Returns an command instance for a given request class + * + * @param $requestInstance An instance of a request class + * @return $commandInstance An instance of the resolved command + */ + function resolveCommandByRequest (Requestable $requestInstance); + + /** + * Checks wether the given command is valid + * + * @param $commandName The default command we shall execute + * @return $isValid Wether the given command is valid + * @throws EmptyVariableException Thrown if given command is not set + */ + function isCommandValid ($commandName); +} + +// +?> diff --git a/inc/classes/interfaces/resolver/controller/.htaccess b/inc/classes/interfaces/resolver/controller/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/interfaces/resolver/controller/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/interfaces/resolver/controller/class_ControllerResolver.php b/inc/classes/interfaces/resolver/controller/class_ControllerResolver.php new file mode 100644 index 00000000..5d2786b6 --- /dev/null +++ b/inc/classes/interfaces/resolver/controller/class_ControllerResolver.php @@ -0,0 +1,34 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface ControllerResolver extends Resolver { + /** + * Resolves the default controller of the given command + * + * @return $controllerInstance A controller instance for the default command + */ + function resolveController (); +} + +// +?> diff --git a/inc/classes/interfaces/response/.htaccess b/inc/classes/interfaces/response/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/interfaces/response/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/interfaces/response/class_Responseable.php b/inc/classes/interfaces/response/class_Responseable.php new file mode 100644 index 00000000..bb798fe6 --- /dev/null +++ b/inc/classes/interfaces/response/class_Responseable.php @@ -0,0 +1,109 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface Responseable extends FrameworkInterface { + /** + * Setter for status + * + * @param $status New response status + * @return void + */ + function setResponseStatus ($status); + + /** + * Add header element + * + * @param $name Name of header element + * @param $value Value of header element + * @return void + */ + function addHeader ($name, $value); + + /** + * "Writes" data to the response body + * + * @param $output Output we shall sent in the HTTP response + * @return void + */ + function writeToBody ($output); + + /** + * Flushs the cached HTTP response to the outer world + * + * @param $force Wether we shall force the output or abort if headers are + * already sent with an exception + * @return void + * @throws ResponseHeadersAlreadySentException Thrown if headers are + * already sent + */ + function flushBuffer ($force = false); + + /** + * Adds a fatal message id to the response. The added messages can then be + * processed and outputed to the world + * + * @param $messageId The message id we shall add + * @return void + */ + function addFatalMessage ($messageId); + + /** + * Adds a cookie to the response + * + * @param $cookieName Cookie's name + * @param $cookieValue Value to store in the cookie + * @param $encrypted Do some extra encryption on the value + * @return void + * @throws ResponseHeadersAlreadySentException If headers are already sent + */ + function addCookie ($cookieName, $cookieValue, $encrypted = false); + + /** + * Redirect to a configured URL. The URL can be absolute or relative. In + * case of relative URL it will be extended automatically. + * + * @param $configEntry The configuration entry which holds our URL + * @return void + * @throws ResponseHeadersAlreadySentException If headers are already sent + */ + function redirectToConfiguredUrl ($configEntry); + + /** + * Expires the given cookie if it is set + * + * @param $cookieName Cookie to expire + * @return void + */ + function expireCookie ($cookieName); + + /** + * Refreshs a given cookie. This will make the cookie live longer + * + * @param $cookieName Cookie to refresh + * @return void + */ + function refreshCookie ($cookieName); +} + +// +?> diff --git a/inc/classes/interfaces/result/.htaccess b/inc/classes/interfaces/result/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/interfaces/result/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/interfaces/result/class_SearchableResult.php b/inc/classes/interfaces/result/class_SearchableResult.php new file mode 100644 index 00000000..c3bf26bf --- /dev/null +++ b/inc/classes/interfaces/result/class_SearchableResult.php @@ -0,0 +1,44 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface SearchableResult extends FrameworkInterface { + /** + * Searches for an entry in the data result and returns it + * + * @param $criteriaInstance The criteria to look inside the data set + * @return $result Found result entry + */ + function searchEntry (LocalSearchCriteria $criteriaInstance); + + /** + * Solver for result index value with call-back method + * + * @param $databaseColumn Database column where the index might be found + * @para $callBack Call-back object for setting the index + * @return void + */ + function solveResultIndex ($databaseColumn, BaseDatabaseWrapper $wrapperInstance, array $callBack); +} + +// [EOF] +?> diff --git a/inc/classes/interfaces/result/class_UpdateableResult.php b/inc/classes/interfaces/result/class_UpdateableResult.php new file mode 100644 index 00000000..42542ed2 --- /dev/null +++ b/inc/classes/interfaces/result/class_UpdateableResult.php @@ -0,0 +1,45 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface UpdateableResult extends FrameworkInterface { + /** + * Adds an update request to the database result for writing it to the + * database layer + * + * @param $criteriaInstance An instance of a updateable criteria + * @return void + * @throws ResultUpdateException If no result was updated + */ + function add2UpdateQueue (LocalUpdateCriteria $criteriaInstance); + + /** + * Adds registration elements to a given dataset instance + * + * @param $criteriaInstance An instance of a storeable criteria + * @return void + */ + function addElementsToDataSet (StoreableCriteria $criteriaInstance); +} + +// [EOF] +?> diff --git a/inc/classes/interfaces/template/.htaccess b/inc/classes/interfaces/template/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/interfaces/template/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/interfaces/template/class_CompileableTemplate.php b/inc/classes/interfaces/template/class_CompileableTemplate.php new file mode 100644 index 00000000..46ffe775 --- /dev/null +++ b/inc/classes/interfaces/template/class_CompileableTemplate.php @@ -0,0 +1,89 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface CompileableTemplate extends FrameworkInterface { + /** + * Assign variables for templates + * + * @param $var The "variable" we want to assign + * @param $value The value we want to store in the variable + * @return void + */ + function assignVariable ($var, $value); + + /** + * Load a specified web template into the engine + * + * @param $template The web template we shall load which is located in + * "html" by default + * @return void + */ + function loadWebTemplate ($template); + + /** + * Load a specified code template into the engine for later compilation + * with other code/web/email templates. + * + * @param $template The code template we shall load which is + * located in "html" by default + * @return void + */ + function loadCodeTemplate ($template); + + /** + * Load a specified email template into the engine + * + * @param $template The email template we shall load which is + * located in "emails" by default + * @return void + */ + function loadEmailTemplate ($template); + + /** + * Compile all variables by inserting their respective values + * + * @return void + */ + function compileVariables (); + + + /** + * Compile all required code/web/email-templates into the current one + * + * @return void + */ + function compileTemplate (); + + /** + * Output the compiled template to the outside world. In case of web + * templates this would be vaild (X)HTML code. And in case of email + * templates this would store a prepared email body inside the template + * engine. + * + * @return void + */ + function output (); +} // END - class + +// [EOF] +?> diff --git a/inc/classes/interfaces/template/view/class_ViewHelper.php b/inc/classes/interfaces/template/view/class_ViewHelper.php new file mode 100644 index 00000000..78e0cf80 --- /dev/null +++ b/inc/classes/interfaces/template/view/class_ViewHelper.php @@ -0,0 +1,35 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface ViewHelper extends FrameworkInterface { + /** + * The execute method for executing the view helper + * + * @param $args Arguments to send to the view helper + * @return mixed Unknown return arguments, or void + */ + function execute (array $args = null); +} + +// [EOF] +?> diff --git a/inc/classes/interfaces/user/.htaccess b/inc/classes/interfaces/user/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/interfaces/user/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/interfaces/user/class_ManageableAccount.php b/inc/classes/interfaces/user/class_ManageableAccount.php new file mode 100644 index 00000000..2dd07067 --- /dev/null +++ b/inc/classes/interfaces/user/class_ManageableAccount.php @@ -0,0 +1,50 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface ManageableAccount extends FrameworkInterface { + /** + * Determines wether the username exists or not + * + * @return $exists Wether the username exists + */ + function ifUsernameExists (); + + /** + * Determines wether the email exists or not + * + * @return $exists Wether the email exists + */ + function ifEmailAddressExists (); + + /** + * Checks if supplied password hash in request matches with stored in + * database. + * + * @param $requestInstance A requestable class instance + * @return $matches Wether the supplied password hash matches + */ + function ifPasswordHashMatches (Requestable $requestInstance); +} + +// +?> diff --git a/inc/classes/interfaces/user/extended/.htaccess b/inc/classes/interfaces/user/extended/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/interfaces/user/extended/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/interfaces/user/extended/class_ManageableGuest.php b/inc/classes/interfaces/user/extended/class_ManageableGuest.php new file mode 100644 index 00000000..be907125 --- /dev/null +++ b/inc/classes/interfaces/user/extended/class_ManageableGuest.php @@ -0,0 +1,28 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface ManageableGuest extends ManageableAccount { +} + +// +?> diff --git a/inc/classes/interfaces/user/extended/class_ManageableMember.php b/inc/classes/interfaces/user/extended/class_ManageableMember.php new file mode 100644 index 00000000..db33c630 --- /dev/null +++ b/inc/classes/interfaces/user/extended/class_ManageableMember.php @@ -0,0 +1,28 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface ManageableMember extends ManageableAccount { +} + +// +?> diff --git a/inc/classes/main/.htaccess b/inc/classes/main/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/actions/.htaccess b/inc/classes/main/actions/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/actions/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/actions/class_ b/inc/classes/main/actions/class_ new file mode 100644 index 00000000..90ff3234 --- /dev/null +++ b/inc/classes/main/actions/class_ @@ -0,0 +1,62 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ???Action extends BaseAction implements Commandable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this action + * + * @return $actionInstance An instance of this action class + */ + public final static function create???Action () { + // Get a new instance + $actionInstance = new ???Action(); + + // Return the instance + return $actionInstance; + } + + /** + * Executes the command with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @todo 0% done + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + $this->partialStub("You have to implement me."); + } +} + +// [EOF] +?> diff --git a/inc/classes/main/actions/class_BaseAction.php b/inc/classes/main/actions/class_BaseAction.php new file mode 100644 index 00000000..a2b1665b --- /dev/null +++ b/inc/classes/main/actions/class_BaseAction.php @@ -0,0 +1,44 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseAction extends BaseFrameworkSystem { + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + + // Clean up a little + $this->removeNumberFormaters(); + $this->removeSystemArray(); + } +} + +// [EOF] +?> diff --git a/inc/classes/main/actions/post_registration/.htaccess b/inc/classes/main/actions/post_registration/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/actions/post_registration/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/actions/post_registration/class_LoginAfterRegistrationAction.php b/inc/classes/main/actions/post_registration/class_LoginAfterRegistrationAction.php new file mode 100644 index 00000000..15fd499a --- /dev/null +++ b/inc/classes/main/actions/post_registration/class_LoginAfterRegistrationAction.php @@ -0,0 +1,83 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class LoginAfterRegistrationAction extends BaseAction implements PerformableAction { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this action + * + * @return $actionInstance An instance of this action class + */ + public final static function createLoginAfterRegistrationAction () { + // Get a new instance + $actionInstance = new LoginAfterRegistrationAction(); + + // Return the instance + return $actionInstance; + } + + /** + * Executes the command with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get a login class from factory + $loginInstance = ObjectFactory::createObjectByConfiguredName('user_login_class'); + + // Login the user by the request instance + $loginInstance->doLogin($requestInstance, $responseInstance); + + // Was the login fine? Then redirect here + if ($loginInstance->ifLoginWasSuccessfull()) { + // Try to redirect here + try { + // Redirect... + $responseInstance->redirectToConfiguredUrl('app_login_url'); + + // Stop here + exit(); + } catch (FrameworkException $e) { + // Something went wrong here! + $responseInstance->addFatalMessage($e->getMessage()); + } + } else { + // Attach error message to the response + $responseInstance->addFatalMessage('failed_login_after_registration'); + } + } +} + +// [EOF] +?> diff --git a/inc/classes/main/actions/web/.htaccess b/inc/classes/main/actions/web/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/actions/web/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/actions/web/class_WebLoginProfileAction.php b/inc/classes/main/actions/web/class_WebLoginProfileAction.php new file mode 100644 index 00000000..09998865 --- /dev/null +++ b/inc/classes/main/actions/web/class_WebLoginProfileAction.php @@ -0,0 +1,77 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class WebLoginProfileAction extends BaseAction implements Commandable, Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this action + * + * @param $resolverInstance An instance of an action resolver + * @return $actionInstance An instance of this action class + */ + public final static function createWebLoginProfileAction (ActionResolver $resolverInstance) { + // Get a new instance + $actionInstance = new WebLoginProfileAction(); + + // Set the resolver instance + $actionInstance->setResolverInstance($resolverInstance); + + // Return the instance + return $actionInstance; + } + + /** + * Executes the command with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Dummy method + } + + /** + * Adds extra filters to the given controller instance + * + * @param $controllerInstance A controller instance + * @param $requestInstance An instance of a class with an Requestable interface + * @return void + */ + public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) { + // Add user status filter here + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_status_filter', array($controllerInstance))); + } +} + +// [EOF] +?> diff --git a/inc/classes/main/application/.htaccess b/inc/classes/main/application/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/application/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/application/class_BaseApplication.php b/inc/classes/main/application/class_BaseApplication.php new file mode 100644 index 00000000..a8d5e5c6 --- /dev/null +++ b/inc/classes/main/application/class_BaseApplication.php @@ -0,0 +1,48 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseApplication extends BaseFrameworkSystem { + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + + // Clean up a little + $this->removeNumberFormaters(); + $this->removeSystemArray(); + + // Get registry instance + $registryInstance = Registry::getRegistry(); + + // Add this instance + $registryInstance->addInstance('application', $this); + } +} + +// [EOF] +?> diff --git a/inc/classes/main/auth/.htaccess b/inc/classes/main/auth/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/auth/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/auth/class_CookieAuth.php b/inc/classes/main/auth/class_CookieAuth.php new file mode 100644 index 00000000..6ef55044 --- /dev/null +++ b/inc/classes/main/auth/class_CookieAuth.php @@ -0,0 +1,126 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class CookieAuth extends BaseFrameworkSystem implements Authorizeable, Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Clean up a little + $this->removeNumberFormaters(); + $this->removeSystemArray(); + } + + /** + * Creates an instance of this class by the given response instance + * + * @param $responseInstance An instance of a Responseable class + * @return $loginInstance An instance of this login class + */ + public final static function createCookieAuth (Responseable $responseInstance) { + // Get a new instance + $loginInstance = new CookieAuth(); + + // Set the response instance + $loginInstance->setResponseInstance($responseInstance); + + // Return the prepared instance + return $loginInstance; + } + + /** + * "Setter" for username auth data + * + * @param $userName The username from request we shall set + * @return void + */ + public function setUserAuth ($userName) { + $this->getResponseInstance()->addCookie('username', $userName); + } + + /** + * "Setter" for password hash auth data + * + * @param $passHash The hashed password from request we shall set + * @return void + */ + public function setPasswordAuth ($passHash) { + $this->getResponseInstance()->addCookie('u_hash', $passHash, true); + } + + /** + * Getter for user auth cookie + * + * @return $userName Username to get from cookie + */ + public function getUserAuth () { + // Get the username from cookie + $userName = $this->getRequestInstance()->readCookie('username'); + + // Return the username + return $userName; + } + + /** + * Getter for password hash auth cookie + * + * @return $passHash Password hash to get from cookie + */ + public function getPasswordAuth () { + // Get the username from cookie + $passHash = $this->getRequestInstance()->readCookie('u_hash'); + + // Return the username + return $passHash; + } + + /** + * Destroy the authorization data + * + * @return void + */ + public function destroyAuthData () { + // Expire both cookies + $this->getResponseInstance()->expireCookie('username'); + $this->getResponseInstance()->expireCookie('u_hash'); + } + + /** + * Updates the authorization data and/or sets additional tracking data + * + * @param $requestInstance An instance of a Requestable class + * @return void + */ + public function updateAuthData () { + $this->getResponseInstance()->refreshCookie('username'); + $this->getResponseInstance()->refreshCookie('u_hash'); + } +} + +// [EOF] +?> diff --git a/inc/classes/main/cache/.htaccess b/inc/classes/main/cache/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/cache/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/cache/class_MemoryCache.php b/inc/classes/main/cache/class_MemoryCache.php new file mode 100644 index 00000000..7e0dfd00 --- /dev/null +++ b/inc/classes/main/cache/class_MemoryCache.php @@ -0,0 +1,114 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class MemoryCache extends BaseFrameworkSystem implements Cacheable { + /** + * The "memory cache" is simply a wrapped object array + */ + private $dataCache = null; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Clean up a little + $this->removeNumberFormaters(); + $this->removeSystemArray(); + } + + /** + * Creates an instance of this class + * + * @return $cacheInstance An instance of this cache class + */ + public final static function createMemoryCache () { + // Get a new instance + $cacheInstance = new MemoryCache(); + + // Initialize the cache + $cacheInstance->initCache(); + + // Return the prepared instance + return $cacheInstance; + } + + /** + * Initialize this cache by creating an object array + * + * @return void + */ + protected function initCache () { + // Now create the "data cache" + $this->dataCache = new FrameworkArrayObject('FakedDataCache'); + } + + /** + * Does the specified offset exist in cache? + * + * @param $offset The offset we are looking for + * @return $exists Wether the offset exists + */ + public final function offsetExists ($offset) { + $exists = $this->dataCache->offsetExists($offset); + return $exists; + } + + /** + * Setter for cache offset + * + * @param $offset The offset we shall set + * @param $data Data to store in cache + * @return void + */ + public final function offsetSet ($offset, $data) { + $this->dataCache->offsetSet($offset, $data); + } + + /** + * Getter for cache offset or "null" if not found + * + * @param $offset The offset we shall set + * @return $data Data to store in cache + */ + public final function offsetGet ($offset) { + // Default is offset not found + $data = null; + + // Is the offset there? + if ($this->offsetExists($offset)) { + // Then get the data from it + $data = $this->dataCache->offsetGet($offset); + } + + // Return data + return $data; + } +} + +// [EOF] +?> diff --git a/inc/classes/main/class_ b/inc/classes/main/class_ new file mode 100644 index 00000000..df220046 --- /dev/null +++ b/inc/classes/main/class_ @@ -0,0 +1,41 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class extends BaseFrameworkSystem { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Clean up a little + $this->removeNumberFormaters(); + $this->removeSystemArray(); + } +} + +// [EOF] +?> diff --git a/inc/classes/main/class_Base b/inc/classes/main/class_Base new file mode 100644 index 00000000..9f3eee9f --- /dev/null +++ b/inc/classes/main/class_Base @@ -0,0 +1,42 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class Base??? extends BaseFrameworkSystem { + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + + // Clean up a little + $this->removeNumberFormaters(); + $this->removeSystemArray(); + } +} + +// [EOF] +?> diff --git a/inc/classes/main/class_BaseFrameworkSystem.php b/inc/classes/main/class_BaseFrameworkSystem.php new file mode 100644 index 00000000..d4eabd79 --- /dev/null +++ b/inc/classes/main/class_BaseFrameworkSystem.php @@ -0,0 +1,1077 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseFrameworkSystem extends stdClass implements FrameworkInterface { + /** + * Instance to an application helper class + */ + private static $applicationInstance = null; + + /** + * The language instance for the template loader + */ + private static $langInstance = null; + + /** + * Debug instance + */ + private static $debugInstance = null; + + /** + * Instance of a request class + */ + private $requestInstance = null; + + /** + * Instance of a response class + */ + private $responseInstance = null; + + /** + * Search criteria instance + */ + private $searchInstance = null; + + /** + * The file I/O instance for the template loader + */ + private $fileIoInstance = null; + + /** + * Resolver instance + */ + private $resolverInstance = null; + + /** + * Template engine instance + */ + private $templateInstance = null; + + /** + * Database result instance + */ + private $resultInstance = null; + + /** + * Instance for user class + */ + private $userInstance = null; + + /** + * A controller instance + */ + private $controllerInstance = null; + + /** + * The real class name + */ + private $realClass = "FrameworkSystem"; + + /** + * Thousands seperator + */ + private $thousands = "."; // German + + /** + * Decimal seperator + */ + private $decimals = ","; // German + + /*********************** + * Exception codes.... * + ***********************/ + + const EXCEPTION_IS_NULL_POINTER = 0x001; + const EXCEPTION_IS_NO_OBJECT = 0x002; + const EXCEPTION_IS_NO_ARRAY = 0x003; + const EXCEPTION_MISSING_METHOD = 0x004; + const EXCEPTION_CLASSES_NOT_MATCHING = 0x005; + const EXCEPTION_INDEX_OUT_OF_BOUNDS = 0x006; + const EXCEPTION_DIMENSION_ARRAY_INVALID = 0x007; + const EXCEPTION_ITEM_NOT_TRADEABLE = 0x008; + const EXCEPTION_ITEM_NOT_IN_PRICE_LIST = 0x009; + const EXCEPTION_GENDER_IS_WRONG = 0x00a; + const EXCEPTION_BIRTH_DATE_IS_INVALID = 0x00b; + const EXCEPTION_EMPTY_STRUCTURES_ARRAY = 0x00c; + const EXCEPTION_HAS_ALREADY_PERSONELL_LIST = 0x00d; + const EXCEPTION_NOT_ENOUGTH_UNEMPLOYEES = 0x00e; + const EXCEPTION_TOTAL_PRICE_NOT_CALCULATED = 0x00f; + const EXCEPTION_HARBOR_HAS_NO_SHIPYARDS = 0x010; + const EXCEPTION_CONTRACT_PARTNER_INVALID = 0x011; + const EXCEPTION_CONTRACT_PARTNER_MISMATCH = 0x012; + const EXCEPTION_CONTRACT_ALREADY_SIGNED = 0x013; + const EXCEPTION_UNEXPECTED_EMPTY_STRING = 0x014; + const EXCEPTION_PATH_NOT_FOUND = 0x015; + const EXCEPTION_INVALID_PATH_NAME = 0x016; + const EXCEPTION_READ_PROTECED_PATH = 0x017; + const EXCEPTION_WRITE_PROTECED_PATH = 0x018; + const EXCEPTION_DIR_POINTER_INVALID = 0x019; + const EXCEPTION_FILE_POINTER_INVALID = 0x01a; + const EXCEPTION_INVALID_DIRECTORY_POINTER = 0x01b; + const EXCEPTION_UNEXPECTED_OBJECT = 0x01c; + const EXCEPTION_LIMIT_ELEMENT_IS_UNSUPPORTED = 0x01d; + const EXCEPTION_GETTER_IS_MISSING = 0x01e; + const EXCEPTION_ARRAY_EXPECTED = 0x01f; + const EXCEPTION_ARRAY_HAS_INVALID_COUNT = 0x020; + const EXCEPTION_ID_IS_INVALID_FORMAT = 0x021; + const EXCEPTION_MD5_CHECKSUMS_MISMATCH = 0x022; + const EXCEPTION_UNEXPECTED_STRING_SIZE = 0x023; + const EXCEPTION_SIMULATOR_ID_INVALID = 0x024; + const EXCEPTION_MISMATCHING_COMPRESSORS = 0x025; + const EXCEPTION_CONTAINER_ITEM_IS_NULL = 0x026; + const EXCEPTION_ITEM_IS_NO_ARRAY = 0x027; + const EXCEPTION_CONTAINER_MAYBE_DAMAGED = 0x028; + const EXCEPTION_INVALID_STRING = 0x029; + const EXCEPTION_VARIABLE_NOT_SET = 0x02a; + const EXCEPTION_ATTRIBUTES_ARE_MISSING = 0x02b; + const EXCEPTION_ARRAY_ELEMENTS_MISSING = 0x02c; + const EXCEPTION_TEMPLATE_ENGINE_UNSUPPORTED = 0x02d; + const EXCEPTION_MISSING_LANGUAGE_HANDLER = 0x02e; + const EXCEPTION_MISSING_FILE_IO_HANDLER = 0x02f; + const EXCEPTION_MISSING_ELEMENT = 0x030; + const EXCEPTION_HEADERS_ALREADY_SENT = 0x031; + const EXCEPTION_DEFAULT_CONTROLLER_GONE = 0x032; + const EXCEPTION_CLASS_NOT_FOUND = 0x033; + const EXCEPTION_REQUIRED_INTERFACE_MISSING = 0x034; + const EXCEPTION_FATAL_ERROR = 0x035; + const EXCEPTION_FILE_NOT_FOUND = 0x036; + const EXCEPTION_ASSERTION_FAILED = 0x037; + const EXCEPTION_FILE_CANNOT_BE_READ = 0x038; + const EXCEPTION_DATABASE_UPDATED_NOT_ALLOWED = 0x039; + + /** + * In the super constructor these system classes shall be ignored or else + * we would get an endless calling loop. + * + *---------------------------------------------------------------------* + * ATTENTION: IF YOU REMOVE ONE OF THEM YOU WILL RUN YOUR SERVER IN AN * + * ENDLESS LOOP !!! * + *---------------------------------------------------------------------* + */ + private $systemClasses = array( + "DebugMiddleware", // Debug middleware output sub-system + "Registry", // Object registry + "ObjectFactory", // Object factory + "DebugWebOutput", // Debug web output sub-system + "WebOutput", // Web output sub-system + "CompressorChannel", // Compressor sub-system + "DebugConsoleOutput", // Debug console output sub-system + "DebugErrorLogOutput", // Debug error_log() output sub-system + "FrameworkDirectoryPointer", // Directory handler sub-system + "NullCompressor", // Null compressor + "Bzip2Compressor", // BZIP2 compressor + "GzipCompressor", // GZIP compressor + ); + + /* No longer used: + */ + + /** + * Private super constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Set real class + $this->setRealClass($className); + + // Initialize the class if class Registry is there + if ((class_exists('Registry')) && (Registry::isInitialized() === false)) { + // Initialize the registry automatically + $this->initInstance(); + } // END - if + } + + /** + * Destructor reached... + * + * @return void + * @todo This is old code. Do we still need this old lost code? + */ + public function __destruct() { + // Is this object already destroyed? + if ($this->__toString() != 'DestructedObject') { + // Destroy all informations about this class but keep some text about it alive + $this->setRealClass('DestructedObject'); + } elseif ((defined('DEBUG_DESTRUCTOR')) && (is_object($this->getDebugInstance()))) { + // Already destructed object + $this->debugOutput(sprintf("[%s:] The object %s is already destroyed.", + __CLASS__, $this->__toString() + )); + } + } + + /** + * The call method where all non-implemented methods end up + * + * @return void + */ + public final function __call ($methodName, $args) { + // Implode all given arguments + $argsString = ""; + if (empty($args)) { + // No arguments + $argsString = "NULL"; + } elseif (is_array($args)) { + // Some arguments are there + foreach ($args as $arg) { + // Add the type + $argsString .= $arg." (".gettype($arg); + + // Add length if type is string + if (gettype($arg) == 'string') $argsString .= ", ".strlen($arg); + + // Closing bracket + $argsString .= "), "; + } // END - foreach + + // Remove last comma + if (substr($argsString, -2, 1) === ",") { + $argsString = substr($argsString, 0, -2); + } // END - if + } else { + // Invalid arguments! + $argsString = sprintf("!INVALID:%s!", $args); + } + + // Output stub message + $this->debugOutput(sprintf("[%s->%s] Stub! Args: %s", + $this->__toString(), + $methodName, + $argsString + )); + + // Return nothing + return null; + } + + /** + * Private initializer for this class + * + * @return void + */ + private final function initInstance () { + // Is this a system class? + if (!in_array($this->__toString(), $this->systemClasses)) { + // Set configuration instance + $this->setConfigInstance(FrameworkConfiguration::getInstance()); + + // Add application helper to our class + $this->systemclasses[] = $this->getConfigInstance()->readConfig('app_helper_class'); + + // Set debug instance + $this->setDebugInstance(DebugMiddleware::createDebugMiddleware($this->getConfigInstance()->readConfig('debug_class'))); + + // Get output instance and set it + $outputInstance = ObjectFactory::createObjectByConfiguredName('web_engine', array($this->getConfigInstance()->readConfig('web_content_type'))); + $this->setWebOutputInstance($outputInstance); + + // Set the compressor channel + $this->setCompressorChannel(CompressorChannel::createCompressorChannel(sprintf("%s%s", + $this->getConfigInstance()->readConfig('base_path'), + $this->getConfigInstance()->readConfig('compressor_base_path') + ))); + + // Initialization done! :D + Registry::isInitialized('OK'); + } elseif ($this->__toString() == 'DebugMiddleware') { + // Set configuration instance + $this->setConfigInstance(FrameworkConfiguration::getInstance()); + } + } + + /** + * Setter for database result instance + * + * @param $resultInstance An instance of a database result class + * @return void + * @todo SearchableResult and UpdateableResult shall have a super interface to use here + */ + protected final function setResultInstance (SearchableResult $resultInstance) { + $this->resultInstance = $resultInstance; + } + + /** + * Getter for database result instance + * + * @return $resultInstance An instance of a database result class + */ + public final function getResultInstance () { + return $this->resultInstance; + } + + /** + * Setter for template engine instances + * + * @param $templateInstance An instance of a template engine class + * @return void + */ + protected final function setTemplateInstance (CompileableTemplate $templateInstance) { + $this->templateInstance = $templateInstance; + } + + /** + * Getter for template engine instances + * + * @return $templateInstance An instance of a template engine class + */ + protected final function getTemplateInstance () { + return $this->templateInstance; + } + + /** + * Setter for search instance + * + * @param $searchInstance Searchable criteria instance + * @return void + */ + public final function setSearchInstance (LocalSearchCriteria $searchInstance) { + $this->searchInstance = $searchInstance; + } + + /** + * Getter for search instance + * + * @return $searchInstance Searchable criteria instance + */ + public final function getSearchInstance () { + return $this->searchInstance; + } + + /** + * Setter for resolver instance + * + * @param $resolverInstance Instance of a command resolver class + * @return void + */ + public final function setResolverInstance (Resolver $resolverInstance) { + $this->resolverInstance = $resolverInstance; + } + + /** + * Getter for resolver instance + * + * @return $resolverInstance Instance of a command resolver class + */ + public final function getResolverInstance () { + return $this->resolverInstance; + } + + /** + * Setter for language instance + * + * @param $configInstance The configuration instance which shall + * be FrameworkConfiguration + * @return void + */ + public final function setConfigInstance (FrameworkConfiguration $configInstance) { + Registry::getRegistry()->addInstance('config', $configInstance); + } + + /** + * Getter for configuration instance + * + * @return $cfgInstance Configuration instance + */ + public final function getConfigInstance () { + $cfgInstance = Registry::getRegistry()->getInstance('config'); + return $cfgInstance; + } + + /** + * Setter for debug instance + * + * @param $debugInstance The instance for debug output class + * @return void + */ + public final function setDebugInstance (DebugMiddleware $debugInstance) { + self::$debugInstance = $debugInstance; + } + + /** + * Getter for debug instance + * + * @return $debugInstance Instance to class DebugConsoleOutput or DebugWebOutput + */ + public final function getDebugInstance () { + return self::$debugInstance; + } + + /** + * Setter for web output instance + * + * @param $webInstance The instance for web output class + * @return void + */ + public final function setWebOutputInstance (OutputStreamer $webInstance) { + Registry::getRegistry()->addInstance('web_output', $webInstance); + } + + /** + * Getter for web output instance + * + * @return $webOutput - Instance to class WebOutput + */ + public final function getWebOutputInstance () { + return Registry::getRegistry()->getInstance('web_output'); + } + + /** + * Setter for database instance + * + * @param $dbInstance The instance for the database connection + * (forced DatabaseConnection) + * @return void + */ + public final function setDatabaseInstance (DatabaseConnection $dbInstance) { + Registry::getRegistry()->addInstance('dbInstance', $dbInstance); + } + + /** + * Getter for database layer + * + * @return $dbInstance The database layer instance + */ + public final function getDatabaseInstance () { + // Default is invalid db instance + $dbInstance = null; + + // Is the registry there and initialized? + if ((class_exists('Registry')) && (Registry::isInitialized() === true)) { + $dbInstance = Registry::getRegistry()->getInstance('dbInstance'); + } // END - if + + // Return instance + return $dbInstance; + } + + /** + * Setter for compressor channel + * + * @param $compressorChannel An instance of CompressorChannel + * @return void + */ + public final function setCompressorChannel (CompressorChannel $compressorChannel) { + Registry::getRegistry()->addInstance('compressor', $compressorChannel); + } + + /** + * Getter for compressor channel + * + * @return $compressor The compressor channel + */ + public final function getCompressorChannel () { + return Registry::getRegistry()->getInstance('compressor'); + } + + /** + * Protected getter for a manageable application helper class + * + * @return $applicationInstance An instance of a manageable application helper class + */ + protected final function getApplicationInstance () { + return self::$applicationInstance; + } + + /** + * Setter for a manageable application helper class + * + * @param $applicationInstance An instance of a manageable application helper class + * @return void + */ + public final function setApplicationInstance (ManageableApplication $applicationInstance) { + self::$applicationInstance = $applicationInstance; + } + + /** + * Setter for request instance + * + * @param $requestInstance An instance of a Requestable class + * @return void + */ + public final function setRequestInstance (Requestable $requestInstance) { + $this->requestInstance = $requestInstance; + } + + /** + * Getter for request instance + * + * @return $requestInstance An instance of a Requestable class + */ + public final function getRequestInstance () { + return $this->requestInstance; + } + + /** + * Setter for response instance + * + * @param $responseInstance An instance of a Responseable class + * @return void + */ + public final function setResponseInstance (Responseable $responseInstance) { + $this->responseInstance = $responseInstance; + } + + /** + * Getter for response instance + * + * @return $responseInstance An instance of a Responseable class + */ + public final function getResponseInstance () { + return $this->responseInstance; + } + + /** + * Getter for $realClass + * + * @return $realClass The name of the real class (not BaseFrameworkSystem) + */ + public final function __toString () { + return $this->realClass; + } + + /** + * Setter for the real class name + * + * @param $realClass Class name (string) + * @return void + */ + public final function setRealClass ($realClass) { + // Cast to string + $realClass = (string) $realClass; + + // Set real class + $this->realClass = $realClass; + } + + /** + * Compare class name of this and given class name + * + * @param $className The class name as string from the other class + * @return boolean The result of comparing both class names + */ + public final function isClass ($className) { + return ($this->__toString() == $className); + } + + /** + * Stub method (only real cabins shall override it) + * + * @return boolean false = is no cabin, true = is a cabin + * @deprecated + */ + public function isCabin () { + return false; + } + + /** + * Stub method for tradeable objects + * + * @return boolean false = is not tradeable by the Merchant class, + * true = is a tradeable object + * @deprecated + */ + public function isTradeable () { + return false; + } + + /** + * Formats computer generated price values into human-understandable formats + * with thousand and decimal seperators. + * + * @param $value The in computer format value for a price + * @param $currency The currency symbol (use HTML-valid characters!) + * @param $decNum Number of decimals after commata + * @return $price The for the current language formated price string + * @throws MissingDecimalsThousandsSeperatorException If decimals or + * thousands seperator + * is missing + */ + public function formatCurrency ($value, $currency = "€", $decNum = 2) { + // Are all required attriutes set? + if ((!isset($this->decimals)) || (!isset($this->thousands))) { + // Throw an exception + throw new MissingDecimalsThousandsSeperatorException($this, self::EXCEPTION_ATTRIBUTES_ARE_MISSING); + } + + // Cast the number + $value = (float) $value; + + // Reformat the US number + $price = sprintf("%s %s", + number_format($value, $decNum, $this->decimals, $this->thousands), + $currency + ); + + // Return as string... + return $price; + } + + /** + * Removes number formating characters + * + * @return void + */ + public final function removeNumberFormaters () { + unset($this->thousands); + unset($this->decimals); + } + + /** + * Private getter for language instance + * + * @return $langInstance An instance to the language sub-system + */ + protected final function getLanguageInstance () { + return self::$langInstance; + } + + /** + * Setter for language instance + * + * @param $langInstance An instance to the language sub-system + * @return void + * @see LanguageSystem + */ + public final function setLanguageInstance (ManageableLanguage $langInstance) { + self::$langInstance = $langInstance; + } + + /** + * Remove the $systemClasses array from memory + * + * @return void + */ + public final function removeSystemArray () { + unset($this->systemClasses); + } + + /** + * Appends a trailing slash to a string + * + * @param $str A string (maybe) without trailing slash + * @return $str A string with an auto-appended trailing slash + */ + public final function addMissingTrailingSlash ($str) { + // Is there a trailing slash? + if (substr($str, -1, 1) != "/") $str .= "/"; + return $str; + } + + /** + * Private getter for file IO instance + * + * @return $fileIoInstance An instance to the file I/O sub-system + */ + protected final function getFileIoInstance () { + return $this->fileIoInstance; + } + + /** + * Setter for file I/O instance + * + * @param $fileIoInstance An instance to the file I/O sub-system + * @return void + */ + public final function setFileIoInstance (FileIoHandler $fileIoInstance) { + $this->fileIoInstance = $fileIoInstance; + } + + /** + * Prepare the template engine (WebTemplateEngine by default) for a given + * application helper instance (ApplicationHelper by default). + * + * @param $appInstance An application helper instance or + * null if we shall use the default + * @return $templateInstance The template engine instance + * @throws NullPointerException If the template engine could not + * be initialized + * @throws UnsupportedTemplateEngineException If $templateInstance is an + * unsupported template engine + * @throws MissingLanguageHandlerException If the language sub-system + * is not yet initialized + * @throws NullPointerException If the discovered application + * instance is still null + */ + protected function prepareTemplateInstance (BaseFrameworkSystem $appInstance=null) { + // Is the application instance set? + if (is_null($appInstance)) { + // Get the current instance + $appInstance = $this->getApplicationInstance(); + + // Still null? + if (is_null($appInstance)) { + // Thrown an exception + throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER); + } // END - if + } // END - if + + // Generate FQFN for all application templates + $fqfn = sprintf("%s%s/%s", + $this->getConfigInstance()->readConfig('application_path'), + strtolower($appInstance->getAppShortName()), + $this->getConfigInstance()->readConfig('tpl_base_path') + ); + + // Are both instances set? + if ($appInstance->getLanguageInstance() === null) { + // Invalid language instance + throw new MissingLanguageHandlerException($appInstance, self::EXCEPTION_MISSING_LANGUAGE_HANDLER); + } elseif ($appInstance->getFileIoInstance() === null) { + // Invalid language instance + throw new MissingFileIoHandlerException($appInstance, self::EXCEPTION_MISSING_FILE_IO_HANDLER); + } + + // Initialize the template engine + $templateInstance = ObjectFactory::createObjectByConfiguredName('template_class', array($fqfn, $appInstance->getLanguageInstance(), $appInstance->getFileIoInstance())); + + // Return the prepared instance + return $templateInstance; + } + + /** + * Debugs this instance by putting out it's full content + * + * @param $message Optional message to show in debug output + * @return void + */ + public final function debugInstance ($message = "") { + // Restore the error handler to avoid trouble with missing array elements or undeclared variables + restore_error_handler(); + + // Init content + $content = ""; + + // Is a message set? + if (!empty($message)) { + // Construct message + $content = sprintf("
Message: %s
\n", $message); + } // END - if + + // Generate the output + $content .= sprintf("
%s
", + trim( + htmlentities( + print_r($this, true) + ) + ) + ); + + // Output it + ApplicationEntryPoint::app_die(sprintf("
%s debug output:
%s
\nLoaded includes:
%s
", + $this->__toString(), + $content, + ClassLoader::getInstance()->getPrintableIncludeList() + )); + } + + /** + * Output a partial stub message for the caller method + * + * @param $message An optional message to display + * @return void + */ + protected function partialStub ($message = "") { + // Get the backtrace + $backtrace = debug_backtrace(); + + // Generate the class::method string + $methodName = "UnknownClass->unknownMethod"; + if ((isset($backtrace[1]['class'])) && (isset($backtrace[1]['function']))) { + $methodName = $backtrace[1]['class']."->".$backtrace[1]['function']; + } // END - if + + // Construct the full message + $stubMessage = sprintf("[%s:] Partial stub!", + $methodName + ); + + // Is the extra message given? + if (!empty($message)) { + // Then add it as well + $stubMessage .= sprintf(" Message: %s", $message); + } // END - if + + // Debug instance is there? + if (!is_null($this->getDebugInstance())) { + // Output stub message + $this->debugOutput($stubMessage); + } else { + // Trigger an error + trigger_error($stubMessage."
\n"); + } + } + + /** + * Outputs a debug backtrace and stops further script execution + * + * @return void + */ + public function debugBackTrace () { + // Sorry, there is no other way getting this nice backtrace + print("
\n");
+		debug_print_backtrace();
+		print("
"); + exit(); + } + + /** + * Outputs a debug message wether to debug instance (should be set!) or dies with or pints the message + * + * @param $message Message we shall send out... + * @param $doPrint Wether we shall print or die here which first is the default + * @return void + */ + public function debugOutput ($message, $doPrint = true) { + // Get debug instance + $debugInstance = $this->getDebugInstance(); + + // Is the debug instance there? + if (is_object($debugInstance)) { + // Use debug output handler + $debugInstance->output($message); + if ($doPrint === false) die(); // Die here if not printed + } else { + // Put directly out + if ($doPrint) { + print($message); + } else { + // DO NOT REWRITE THIS TO app_die() !!! + die($message); + } + } + } + + /** + * Converts e.g. a command from URL to a valid class by keeping out bad characters + * + * @param $str The string, what ever it is needs to be converted + * @return $className Generated class name + */ + public function convertToClassName ($str) { + // Init class name + $className = ""; + + // Convert all dashes in underscores + $str = str_replace("-", "_", $str); + + // Now use that underscores to get classname parts for hungarian style + foreach (explode("_", $str) as $strPart) { + // Make the class name part lower case and first upper case + $className .= ucfirst(strtolower($strPart)); + } // END - foreach + + // Return class name + return $className; + } + + /** + * Marks up the code by adding e.g. line numbers + * + * @param $phpCode Unmarked PHP code + * @return $markedCode Marked PHP code + */ + public function markupCode ($phpCode) { + // Init marked code + $markedCode = ""; + + // Get last error + $errorArray = error_get_last(); + + // Init the code with error message + if (is_array($errorArray)) { + // Get error infos + $markedCode = sprintf("
File: %s, Line: %s, Message: %s, Type: %s
", + basename($errorArray['file']), + $errorArray['line'], + $errorArray['message'], + $errorArray['type'] + ); + } // END - if + + // Add line number to the code + foreach (explode("\n", $phpCode) as $lineNo => $code) { + // Add line numbers + $markedCode .= sprintf("%s: %s\n", + ($lineNo + 1), + htmlentities($code, ENT_QUOTES) + ); + } // END - foreach + + // Return the code + return $markedCode; + } + + /** + * Filter a given GMT timestamp (non Uni* stamp!) to make it look more + * beatiful for web-based front-ends. If null is given a message id + * null_timestamp will be resolved and returned. + * + * @param $timestamp Timestamp to prepare (filter) for display + * @return $readable A readable timestamp + */ + public function doFilterFormatTimestamp ($timestamp) { + // Default value to return + $readable = "???"; + + // Is the timestamp null? + if (is_null($timestamp)) { + // Get a message string + $readable = $this->getLanguageInstance()->getMessage('null_timestamp'); + } else { + switch ($this->getLanguageInstance()->getLanguageCode()) { + case "de": // German format is a bit different to default + // Split the GMT stamp up + $dateTime = explode(" ", $timestamp); + $dateArray = explode("-", $dateTime[0]); + $timeArray = explode(":", $dateTime[1]); + + // Construct the timestamp + $readable = sprintf($this->getConfigInstance()->readConfig('german_date_time'), + $dateArray[0], + $dateArray[1], + $dateArray[2], + $timeArray[0], + $timeArray[1], + $timeArray[2] + ); + break; + + default: // Default is pass-through + $readable = $timestamp; + break; + } + } + + // Return the stamp + return $readable; + } + + /** + * "Getter" for databse entry + * + * @return $entry An array with database entries + * @throws NullPointerException If the database result is not found + * @throws InvalidDatabaseResultException If the database result is invalid + */ + protected final function getDatabaseEntry () { + // Is there an instance? + if (is_null($this->getResultInstance())) { + // Throw an exception here + throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER); + } // END - if + + // Rewind it + $this->getResultInstance()->rewind(); + + // Do we have an entry? + if ($this->getResultInstance()->valid() === false) { + throw new InvalidDatabaseResultException(array($this, $this->getResultInstance()), DatabaseResult::EXCEPTION_INVALID_DATABASE_RESULT); + } // END - if + + // Get next entry + $this->getResultInstance()->next(); + + // Fetch it + $entry = $this->getResultInstance()->current(); + + // And return it + return $entry; + } + + /** + * Getter for field name + * + * @param $fieldName Field name which we shall get + * @return $fieldValue Field value from the user + * @throws NullPointerException If the result instance is null + */ + public final function getField ($fieldName) { + // Default field value + $fieldValue = null; + + // Get result instance + $resultInstance = $this->getResultInstance(); + + // Is this instance null? + if (is_null($resultInstance)) { + // Then the user instance is no longer valid (expired cookies?) + throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER); + } // END - if + + // Get current array + $fieldArray = $resultInstance->current(); + + // Does the field exist? + if (isset($fieldArray[$fieldName])) { + // Get it + $fieldValue = $fieldArray[$fieldName]; + } // END - if + + // Return it + return $fieldValue; + } + + /** + * Protected setter for user instance + * + * @param $userInstance An instance of a user class + * @return void + */ + protected final function setUserInstance (ManageableAccount $userInstance) { + $this->userInstance = $userInstance; + } + + /** + * Getter for user instance + * + * @return $userInstance An instance of a user class + */ + public final function getUserInstance () { + return $this->userInstance; + } + + /** + * Setter for controller instance (this surely breaks a bit the MVC patterm) + * + * @param $controllerInstance An instance of the controller + * @return void + */ + public final function setControllerInstance (Controller $controllerInstance) { + $this->controllerInstance = $controllerInstance; + } + + /** + * Getter for controller instance (this surely breaks a bit the MVC patterm) + * + * @return $controllerInstance An instance of the controller + */ + public final function getControllerInstance () { + return $this->controllerInstance; + } +} + +// [EOF] +?> diff --git a/inc/classes/main/class_FrameworkArrayObject.php b/inc/classes/main/class_FrameworkArrayObject.php new file mode 100644 index 00000000..167423cf --- /dev/null +++ b/inc/classes/main/class_FrameworkArrayObject.php @@ -0,0 +1,53 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class FrameworkArrayObject extends ArrayObject { + /** + * Real class name + */ + private $realClass = ""; + + /** + * Public constructor for setting real class name + * + * @param $className Real class name + * @return void + */ + public function __construct ($className) { + $this->realClass = (string) $className; + } + + /** + * Get real class' name back + * + * @return $realClass The class' real name + */ + public function __toString () { + return $this->realClass; + } +} + +// [EOF] +?> diff --git a/inc/classes/main/commands/.htaccess b/inc/classes/main/commands/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/commands/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/commands/class_ b/inc/classes/main/commands/class_ new file mode 100644 index 00000000..cac39ce2 --- /dev/null +++ b/inc/classes/main/commands/class_ @@ -0,0 +1,64 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ???Command extends BaseCommand implements Commandable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $resolverInstance An instance of a command resolver class + * @return $commandInstance An instance a prepared command class + */ + public final static function create???Command (CommandResolver $resolverInstance) { + // Get new instance + $commandInstance = new ???Command(); + + // Set the application instance + $commandInstance->setResolverInstance($resolverInstance); + + // Return the prepared instance + return $commandInstance; + } + + /** + * Executes the given command with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + } +} + +// [EOF] +?> diff --git a/inc/classes/main/commands/class_BaseCommand.php b/inc/classes/main/commands/class_BaseCommand.php new file mode 100644 index 00000000..7a7cc26c --- /dev/null +++ b/inc/classes/main/commands/class_BaseCommand.php @@ -0,0 +1,62 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseCommand extends BaseFrameworkSystem { + /** + * The controller we need for this command + */ + private $controllerName = ""; + + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } + + /** + * Setter for controller name + * + * @param $controllerName Name of the controller assigned with this command + * @return void + */ + public final function setControllerName ($controllerName) { + $this->controllerName = (string) $controllerName; + } + + /** + * Getter for controller name + * + * @return $controllerName Name of the controller assigned with this command + */ + public final function getControllerName () { + return $this->controllerName; + } +} + +// [EOF] +?> diff --git a/inc/classes/main/commands/image/.htaccess b/inc/classes/main/commands/image/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/commands/image/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/commands/image/class_ImageCodeCaptchaCommand.php b/inc/classes/main/commands/image/class_ImageCodeCaptchaCommand.php new file mode 100644 index 00000000..8c6794d3 --- /dev/null +++ b/inc/classes/main/commands/image/class_ImageCodeCaptchaCommand.php @@ -0,0 +1,98 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ImageCodeCaptchaCommand extends BaseCommand implements Commandable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $resolverInstance An instance of a command resolver class + * @return $commandInstance An instance a prepared command class + */ + public final static function createImageCodeCaptchaCommand (CommandResolver $resolverInstance) { + // Get new instance + $commandInstance = new ImageCodeCaptchaCommand(); + + // Set the application instance + $commandInstance->setResolverInstance($resolverInstance); + + // Return the prepared instance + return $commandInstance; + } + + /** + * Executes the given command with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get the decrypted string from request (previously created by a filter!) + $decryptedCode = $requestInstance->getRequestElement('decrypted'); + + // Get the application instance + $appInstance = $this->getResolverInstance()->getApplicationInstance(); + + // Prepare a template instance + $templateInstance = $this->prepareTemplateInstance($appInstance); + + // Assign variable + $templateInstance->assignVariable('decrypted_code', $decryptedCode); + + // Load the code (pardon, image...) template + $templateInstance->loadCodeTemplate('code_captcha'); + + // Compile the template + $templateInstance->compileTemplate(); + + // Compile all variables + $templateInstance->compileVariables(); + + // Transfer it to the response + $templateInstance->transferToResponse($responseInstance); + } + + /** + * Adds extra filters to the given controller instance + * + * @param $controllerInstance A controller instance + * @param $requestInstance An instance of a class with an Requestable interface + * @return void + */ + public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) { + // Extra filters here... + } +} + +// [EOF] +?> diff --git a/inc/classes/main/commands/web/.htaccess b/inc/classes/main/commands/web/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/commands/web/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/commands/web/class_ b/inc/classes/main/commands/web/class_ new file mode 100644 index 00000000..d5c0bc00 --- /dev/null +++ b/inc/classes/main/commands/web/class_ @@ -0,0 +1,77 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class Web???Command extends BaseCommand implements Commandable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $resolverInstance An instance of a command resolver class + * @return $commandInstance An instance a prepared command class + */ + public final static function createWeb???Command (CommandResolver $resolverInstance) { + // Get new instance + $commandInstance = new Web???Command(); + + // Set the application instance + $commandInstance->setResolverInstance($resolverInstance); + + // Return the prepared instance + return $commandInstance; + } + + /** + * Executes the given command with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @todo 0% done + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + $this->partialStub("Unfinished method."); + } + + /** + * Adds extra filters to the given controller instance + * + * @param $controllerInstance A controller instance + * @param $requestInstance An instance of a class with an Requestable interface + * @return void + */ + public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) { + // Empty for now + } +} + +// [EOF] +?> diff --git a/inc/classes/main/commands/web/class_WebConfirmCommand.php b/inc/classes/main/commands/web/class_WebConfirmCommand.php new file mode 100644 index 00000000..ca44f8b6 --- /dev/null +++ b/inc/classes/main/commands/web/class_WebConfirmCommand.php @@ -0,0 +1,129 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class WebConfirmCommand extends BaseCommand implements Commandable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $resolverInstance An instance of a command resolver class + * @return $commandInstance An instance a prepared command class + */ + public final static function createWebConfirmCommand (CommandResolver $resolverInstance) { + // Get new instance + $commandInstance = new WebConfirmCommand(); + + // Set the application instance + $commandInstance->setResolverInstance($resolverInstance); + + // Return the prepared instance + return $commandInstance; + } + + /** + * Executes the given command with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get the application instance + $appInstance = $this->getResolverInstance()->getApplicationInstance(); + + // Prepare a template instance + $templateInstance = $this->prepareTemplateInstance($appInstance); + + // Assign application data with template engine + $templateInstance->assignApplicationData($appInstance); + + // Assign base URL + $templateInstance->assignConfigVariable('base_url'); + + // Load the master template + $masterTemplate = $appInstance->getMasterTemplate(); + + // Load header template + $templateInstance->loadCodeTemplate('header'); + + // Compile and assign it with a variable + $templateInstance->compileTemplate(); + $templateInstance->assignTemplateWithVariable('header', 'header'); + + // Load footer template + $templateInstance->loadCodeTemplate('footer'); + + // Compile and assign it with a variable + $templateInstance->compileTemplate(); + $templateInstance->assignTemplateWithVariable('footer', 'footer'); + + // Load the home template + $templateInstance->loadCodeTemplate('confirm_link'); + + // Assign the home template with the master template as a content ... ;) + $templateInstance->assignTemplateWithVariable('confirm_link', 'content'); + + // Load the master template + $templateInstance->loadCodeTemplate($masterTemplate); + + // Set title + $templateInstance->assignVariable('title', $this->getLanguageInstance()->getMessage('page_confirm_link_title')); + + // Get user instance + $userInstance = Registry::getRegistry()->getInstance('user'); + + // Set username + $templateInstance->assignVariable('username', $userInstance->getField(UserDatabaseWrapper::DB_COLUMN_USERNAME)); + + // ... and all variables. This should be merged together in a pattern + // to make things easier. A cache mechanism should be added between + // these two calls to cache compiled templates. + $templateInstance->compileVariables(); + + // Get the content back from the template engine and put it in response class + $templateInstance->transferToResponse($responseInstance); + } + + /** + * Adds extra filters to the given controller instance + * + * @param $controllerInstance A controller instance + * @param $requestInstance An instance of a class with an Requestable interface + * @return void + */ + public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) { + // Empty for now + } +} + +// [EOF] +?> diff --git a/inc/classes/main/commands/web/class_WebDoFormCommand.php b/inc/classes/main/commands/web/class_WebDoFormCommand.php new file mode 100644 index 00000000..d34e16f3 --- /dev/null +++ b/inc/classes/main/commands/web/class_WebDoFormCommand.php @@ -0,0 +1,78 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class WebDoFormCommand extends BaseCommand implements Commandable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $resolverInstance An instance of a command resolver class + * @return $commandInstance An instance a prepared command class + */ + public final static function createWebDoFormCommand (CommandResolver $resolverInstance) { + // Get new instance + $commandInstance = new WebDoFormCommand(); + + // Set the application instance + $commandInstance->setResolverInstance($resolverInstance); + + // Return the prepared instance + return $commandInstance; + } + + /** + * Executes the given command with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Should never be executed... + $this->debugBackTrace(); + } + + /** + * Adds extra filters to the given controller instance + * + * @param $controllerInstance A controller instance + * @param $requestInstance An instance of a class with an Requestable interface + * @return void + */ + public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) { + // Empty for now + } + +} + +// [EOF] +?> diff --git a/inc/classes/main/commands/web/class_WebHomeCommand.php b/inc/classes/main/commands/web/class_WebHomeCommand.php new file mode 100644 index 00000000..6aad8cfb --- /dev/null +++ b/inc/classes/main/commands/web/class_WebHomeCommand.php @@ -0,0 +1,120 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class WebHomeCommand extends BaseCommand implements Commandable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $resolverInstance An instance of a command resolver class + * @return $commandInstance An instance a prepared command class + */ + public final static function createWebHomeCommand (CommandResolver $resolverInstance) { + // Get new instance + $commandInstance = new WebHomeCommand(); + + // Set the application instance + $commandInstance->setResolverInstance($resolverInstance); + + // Return the prepared instance + return $commandInstance; + } + + /** + * Executes the given command with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get the application instance + $appInstance = $this->getResolverInstance()->getApplicationInstance(); + + // Prepare a template instance + $templateInstance = $this->prepareTemplateInstance($appInstance); + + // Transfer application data + $templateInstance->assignApplicationData($appInstance); + + // Load the master template + $masterTemplate = $appInstance->getMasterTemplate(); + + // Load header template + $templateInstance->loadCodeTemplate('header'); + + // Compile and assign it with a variable + $templateInstance->compileTemplate(); + $templateInstance->assignTemplateWithVariable('header', 'header'); + + // Load footer template + $templateInstance->loadCodeTemplate('footer'); + + // Compile and assign it with a variable + $templateInstance->compileTemplate(); + $templateInstance->assignTemplateWithVariable('footer', 'footer'); + + // Load the home template + $templateInstance->loadCodeTemplate('home'); + + // Assign the home template with the master template as a content ... ;) + $templateInstance->assignTemplateWithVariable('home', 'content'); + + // Load the master template + $templateInstance->loadCodeTemplate($masterTemplate); + + // Set title + $templateInstance->assignVariable('title', $this->getLanguageInstance()->getMessage('page_home_title')); + + // ... and all variables. This should be merged together in a pattern + // to make things easier. A cache mechanism should be added between + // these two calls to cache compiled templates. + $templateInstance->compileVariables(); + + // Get the content back from the template engine and put it in response class + $templateInstance->transferToResponse($responseInstance); + } + + /** + * Adds extra filters to the given controller instance + * + * @param $controllerInstance A controller instance + * @param $requestInstance An instance of a class with an Requestable interface + * @return void + */ + public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) { + // Empty for now + } +} + +// [EOF] +?> diff --git a/inc/classes/main/commands/web/class_WebLoginAreaCommand.php b/inc/classes/main/commands/web/class_WebLoginAreaCommand.php new file mode 100644 index 00000000..749de174 --- /dev/null +++ b/inc/classes/main/commands/web/class_WebLoginAreaCommand.php @@ -0,0 +1,197 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class WebLoginAreaCommand extends BaseCommand implements Commandable { + /** + * Name of the action + */ + private $actionName = ""; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $resolverInstance An instance of a command resolver class + * @return $commandInstance An instance a prepared command class + */ + public final static function createWebLoginAreaCommand (CommandResolver $resolverInstance) { + // Get new instance + $commandInstance = new WebLoginAreaCommand(); + + // Set the application instance + $commandInstance->setResolverInstance($resolverInstance); + + // Load general data like user status and such + $commandInstance->prepareCommand(); + + // Return the prepared instance + return $commandInstance; + } + + /** + * Prepares some general data which shall be displayed on every page + * + * @return void + * @todo Add some stuff here: Some personal data, app/game related data + */ + protected function prepareCommand () { + } + + /** + * Executes the given command with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get the action instance from registry + $actionInstance = Registry::getRegistry()->getInstance('action'); + + // Do we have an action here? + if ($actionInstance instanceof PerformableAction) { + // Execute the action (shall not output anything, see below why) + $actionInstance->execute($requestInstance, $responseInstance); + } // END - if + + // Get the application instance + $appInstance = $this->getResolverInstance()->getApplicationInstance(); + + // Prepare a template instance + $templateInstance = $this->prepareTemplateInstance($appInstance); + + // Assign base URL + $templateInstance->assignConfigVariable('base_url'); + + // Assign all the application's data with template variables + $templateInstance->assignApplicationData($appInstance); + + // Load the master template + $masterTemplate = $appInstance->getMasterTemplate(); + + // Load header template + $templateInstance->loadCodeTemplate('header'); + + // Compile and assign it with a variable + $templateInstance->compileTemplate(); + $templateInstance->assignTemplateWithVariable('header', 'header'); + + // Load footer template + $templateInstance->loadCodeTemplate('footer'); + + // Compile and assign it with a variable + $templateInstance->compileTemplate(); + $templateInstance->assignTemplateWithVariable('footer', 'footer'); + + // Load the matching template + $templateInstance->loadCodeTemplate('action_' . $this->actionName); + + // Assign the template with the master template as a content ... ;) + $templateInstance->compileTemplate(); + $templateInstance->assignTemplateWithVariable('action_' . $this->actionName, 'login_content'); + + // Load main template + $templateInstance->loadCodeTemplate('login_main'); + + // Assign the main template with the master template as a content ... ;) + $templateInstance->compileTemplate(); + $templateInstance->assignTemplateWithVariable('login_main', 'content'); + + // Load the master template + $templateInstance->loadCodeTemplate($masterTemplate); + + // Set title + $templateInstance->assignVariable('title', $this->getLanguageInstance()->getMessage($this->actionName . '_title')); + + // ... and all variables. This should be merged together in a pattern + // to make things easier. A cache mechanism should be added between + // these two calls to cache compiled templates. + $templateInstance->compileVariables(); + + // Get the content back from the template engine and put it in response class + $templateInstance->transferToResponse($responseInstance); + } + + /** + * Adds extra filters to the given controller instance. An corresponding action class must now exist! + * + * @param $controllerInstance A controller instance + * @param $requestInstance An instance of a class with an Requestable interface + * @return void + */ + public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) { + // Default is no action + $actionInstance = null; + + // Get registry + $registryInstance = Registry::getRegistry(); + + // Get our application instance from the registry + $appInstance = $registryInstance->getInstance('application'); + + // Default action is the one from configuration + $this->actionName = sprintf("%s_login_%s", + str_replace("-", "_", $appInstance->getAppShortName()), + $this->getConfigInstance()->readConfig('login_default_action') + ); + + // Get "action" from request + $actReq = $requestInstance->getRequestElement('action'); + + // Do we have a "action" parameter set? + if ((is_string($actReq)) && (!empty($actReq))) { + // Then use it with prefix + $this->actionName = sprintf("%s_login_%s", + str_replace("-", "_", $appInstance->getAppShortName()), + $actReq + ); + } // END - if + + // Get application instance + $applicationInstance = $this->getResolverInstance()->getApplicationInstance(); + + // Get a resolver + $actionResolver = WebActionResolver::createWebActionResolver($this->actionName, $applicationInstance); + + // Resolve the action + $actionInstance = $actionResolver->resolveAction(); + + // Add more action-specific filters + $actionInstance->addExtraFilters($controllerInstance, $requestInstance); + + // Remember this action in registry + Registry::getRegistry()->addInstance('action', $actionInstance); + } +} + +// [EOF] +?> diff --git a/inc/classes/main/commands/web/class_WebLoginCommand.php b/inc/classes/main/commands/web/class_WebLoginCommand.php new file mode 100644 index 00000000..9726e847 --- /dev/null +++ b/inc/classes/main/commands/web/class_WebLoginCommand.php @@ -0,0 +1,123 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class WebLoginCommand extends BaseCommand implements Commandable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $resolverInstance An instance of a command resolver class + * @return $commandInstance An instance a prepared command class + */ + public final static function createWebLoginCommand (CommandResolver $resolverInstance) { + // Get new instance + $commandInstance = new WebLoginCommand(); + + // Set the application instance + $commandInstance->setResolverInstance($resolverInstance); + + // Return the prepared instance + return $commandInstance; + } + + /** + * Executes the given command with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get the application instance + $appInstance = $this->getResolverInstance()->getApplicationInstance(); + + // Prepare a template instance + $templateInstance = $this->prepareTemplateInstance($appInstance); + + // Assign application data with template engine + $templateInstance->assignApplicationData($appInstance); + + // Assign base URL + $templateInstance->assignConfigVariable('base_url'); + + // Load the master template + $masterTemplate = $appInstance->getMasterTemplate(); + + // Load header template + $templateInstance->loadCodeTemplate('header'); + + // Compile and assign it with a variable + $templateInstance->compileTemplate(); + $templateInstance->assignTemplateWithVariable('header', 'header'); + + // Load footer template + $templateInstance->loadCodeTemplate('footer'); + + // Compile and assign it with a variable + $templateInstance->compileTemplate(); + $templateInstance->assignTemplateWithVariable('footer', 'footer'); + + // Load the home template + $templateInstance->loadCodeTemplate('login_form'); + + // Assign the home template with the master template as a content ... ;) + $templateInstance->assignTemplateWithVariable('login_form', 'content'); + + // Load the master template + $templateInstance->loadCodeTemplate($masterTemplate); + + // Set title + $templateInstance->assignVariable('title', $this->getLanguageInstance()->getMessage('page_login_title')); + + // ... and all variables. This should be merged together in a pattern + // to make things easier. A cache mechanism should be added between + // these two calls to cache compiled templates. + $templateInstance->compileVariables(); + + // Get the content back from the template engine and put it in response class + $templateInstance->transferToResponse($responseInstance); + } + + /** + * Adds extra filters to the given controller instance + * + * @param $controllerInstance A controller instance + * @param $requestInstance An instance of a class with an Requestable interface + * @return void + */ + public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) { + // Empty for now + } +} + +// [EOF] +?> diff --git a/inc/classes/main/commands/web/class_WebLoginFailedCommand.php b/inc/classes/main/commands/web/class_WebLoginFailedCommand.php new file mode 100644 index 00000000..f2b6b810 --- /dev/null +++ b/inc/classes/main/commands/web/class_WebLoginFailedCommand.php @@ -0,0 +1,123 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class WebLoginFailedCommand extends BaseCommand implements Commandable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $resolverInstance An instance of a command resolver class + * @return $commandInstance An instance a prepared command class + */ + public final static function createWebLoginFailedCommand (CommandResolver $resolverInstance) { + // Get new instance + $commandInstance = new WebLoginFailedCommand(); + + // Set the application instance + $commandInstance->setResolverInstance($resolverInstance); + + // Return the prepared instance + return $commandInstance; + } + + /** + * Executes the given command with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get the application instance + $appInstance = $this->getResolverInstance()->getApplicationInstance(); + + // Prepare a template instance + $templateInstance = $this->prepareTemplateInstance($appInstance); + + // Assign application data with template engine + $templateInstance->assignApplicationData($appInstance); + + // Load the master template + $masterTemplate = $appInstance->getMasterTemplate(); + + // Load header template + $templateInstance->loadCodeTemplate('header'); + + // Compile and assign it with a variable + $templateInstance->compileTemplate(); + $templateInstance->assignTemplateWithVariable('header', 'header'); + + // Load footer template + $templateInstance->loadCodeTemplate('footer'); + + // Compile and assign it with a variable + $templateInstance->compileTemplate(); + $templateInstance->assignTemplateWithVariable('footer', 'footer'); + + // Load the login_failed template + $templateInstance->loadCodeTemplate('login_failed'); + + // Assign the login_failed template with the master template as a content ... ;) + $templateInstance->assignTemplateWithVariable('login_failed', 'content'); + + // Load the master template + $templateInstance->loadCodeTemplate($masterTemplate); + + // Set title + $templateInstance->assignVariable('title', $this->getLanguageInstance()->getMessage('login_failed_title')); + + // Assign base URL + $templateInstance->assignConfigVariable('base_url'); + + // ... and all variables. This should be merged together in a pattern + // to make things easier. A cache mechanism should be added between + // these two calls to cache compiled templates. + $templateInstance->compileVariables(); + + // Get the content back from the template engine and put it in response class + $templateInstance->transferToResponse($responseInstance); + } + + /** + * Adds extra filters to the given controller instance + * + * @param $controllerInstance A controller instance + * @param $requestInstance An instance of a class with an Requestable interface + * @return void + */ + public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) { + // Empty for now + } +} + +// [EOF] +?> diff --git a/inc/classes/main/commands/web/class_WebLogoutCommand.php b/inc/classes/main/commands/web/class_WebLogoutCommand.php new file mode 100644 index 00000000..91a9d518 --- /dev/null +++ b/inc/classes/main/commands/web/class_WebLogoutCommand.php @@ -0,0 +1,89 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class WebLogoutCommand extends BaseCommand implements Commandable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $resolverInstance An instance of a command resolver class + * @return $commandInstance An instance a prepared command class + */ + public final static function createWebLogoutCommand (CommandResolver $resolverInstance) { + // Get new instance + $commandInstance = new WebLogoutCommand(); + + // Set the application instance + $commandInstance->setResolverInstance($resolverInstance); + + // Return the prepared instance + return $commandInstance; + } + + /** + * Executes the given command with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get an auth instance for checking and updating the auth cookies + $authInstance = ObjectFactory::createObjectByConfiguredName('auth_method_class', array($responseInstance)); + + // Set request instance + $authInstance->setRequestInstance($requestInstance); + + // Destroy the auth data + $authInstance->destroyAuthData(); + + // Redirect to "logout done" page + $responseInstance->redirectToConfiguredUrl('logout_done_url'); + + // Exit here + exit(); + } + + /** + * Adds extra filters to the given controller instance + * + * @param $controllerInstance A controller instance + * @param $requestInstance An instance of a class with an Requestable interface + * @return void + */ + public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) { + // Empty for now + } +} + +// [EOF] +?> diff --git a/inc/classes/main/commands/web/class_WebLogoutDoneCommand.php b/inc/classes/main/commands/web/class_WebLogoutDoneCommand.php new file mode 100644 index 00000000..8dfdee36 --- /dev/null +++ b/inc/classes/main/commands/web/class_WebLogoutDoneCommand.php @@ -0,0 +1,123 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class WebLogoutDoneCommand extends BaseCommand implements Commandable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $resolverInstance An instance of a command resolver class + * @return $commandInstance An instance a prepared command class + */ + public final static function createWebLogoutDoneCommand (CommandResolver $resolverInstance) { + // Get new instance + $commandInstance = new WebLogoutDoneCommand(); + + // Set the application instance + $commandInstance->setResolverInstance($resolverInstance); + + // Return the prepared instance + return $commandInstance; + } + + /** + * Executes the given command with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get the application instance + $appInstance = $this->getResolverInstance()->getApplicationInstance(); + + // Prepare a template instance + $templateInstance = $this->prepareTemplateInstance($appInstance); + + // Assign application data + $templateInstance->assignApplicationData($appInstance); + + // Load the master template + $masterTemplate = $appInstance->getMasterTemplate(); + + // Load header template + $templateInstance->loadCodeTemplate('header'); + + // Compile and assign it with a variable + $templateInstance->compileTemplate(); + $templateInstance->assignTemplateWithVariable('header', 'header'); + + // Load footer template + $templateInstance->loadCodeTemplate('footer'); + + // Compile and assign it with a variable + $templateInstance->compileTemplate(); + $templateInstance->assignTemplateWithVariable('footer', 'footer'); + + // Load the logout_done template + $templateInstance->loadCodeTemplate('logout_done'); + + // Assign the logout_done template with the master template as a content ... ;) + $templateInstance->assignTemplateWithVariable('logout_done', 'content'); + + // Load the master template + $templateInstance->loadCodeTemplate($masterTemplate); + + // Set title + $templateInstance->assignVariable('title', $this->getLanguageInstance()->getMessage('logout_done_title')); + + // Assign base URL + $templateInstance->assignConfigVariable('base_url'); + + // ... and all variables. This should be merged together in a pattern + // to make things easier. A cache mechanism should be added between + // these two calls to cache compiled templates. + $templateInstance->compileVariables(); + + // Get the content back from the template engine and put it in response class + $templateInstance->transferToResponse($responseInstance); + } + + /** + * Adds extra filters to the given controller instance + * + * @param $controllerInstance A controller instance + * @param $requestInstance An instance of a class with an Requestable interface + * @return void + */ + public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) { + // Empty for now + } +} + +// [EOF] +?> diff --git a/inc/classes/main/commands/web/class_WebRegisterCommand.php b/inc/classes/main/commands/web/class_WebRegisterCommand.php new file mode 100644 index 00000000..c23b6476 --- /dev/null +++ b/inc/classes/main/commands/web/class_WebRegisterCommand.php @@ -0,0 +1,127 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class WebRegisterCommand extends BaseCommand implements Commandable, Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $resolverInstance An instance of a command resolver class + * @return $commandInstance An instance a prepared command class + */ + public final static function createWebRegisterCommand (CommandResolver $resolverInstance) { + // Get new instance + $commandInstance = new WebRegisterCommand(); + + // Set the application instance + $commandInstance->setResolverInstance($resolverInstance); + + // Return the prepared instance + return $commandInstance; + } + + /** + * Executes the given command with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Set request instance as extra instance + Registry::getRegistry()->addInstance('extra', $this); + + // Get the application instance + $appInstance = $this->getResolverInstance()->getApplicationInstance(); + + // Prepare a template instance + $templateInstance = $this->prepareTemplateInstance($appInstance); + + // Assign all the application's data with template variables + $templateInstance->assignApplicationData($appInstance); + + // Assign base URL + $templateInstance->assignConfigVariable('base_url'); + + // Load the master template + $masterTemplate = $appInstance->getMasterTemplate(); + + // Load header template + $templateInstance->loadCodeTemplate('header'); + + // Compile and assign it with a variable + $templateInstance->compileTemplate(); + $templateInstance->assignTemplateWithVariable('header', 'header'); + + // Load footer template + $templateInstance->loadCodeTemplate('footer'); + + // Compile and assign it with a variable + $templateInstance->compileTemplate(); + $templateInstance->assignTemplateWithVariable('footer', 'footer'); + + // Load the register template + $templateInstance->loadCodeTemplate('register_form'); + + // Assign the register template with the master template as a content ... ;) + $templateInstance->compileTemplate(); + $templateInstance->assignTemplateWithVariable('register_form', 'content'); + + // Load the master template + $templateInstance->loadCodeTemplate($masterTemplate); + + // Set title + $templateInstance->assignVariable('title', $this->getLanguageInstance()->getMessage('page_register_title')); + + // ... and all variables. This should be merged together in a pattern + // to make things easier. A cache mechanism should be added between + // these two calls to cache compiled templates. + $templateInstance->compileVariables(); + + // Get the content back from the template engine and put it in response class + $templateInstance->transferToResponse($responseInstance); + } + + /** + * Adds extra filters to the given controller instance + * + * @param $controllerInstance A controller instance + * @param $requestInstance An instance of a class with an Requestable interface + * @return void + */ + public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) { + // Empty class + } +} + +// [EOF] +?> diff --git a/inc/classes/main/commands/web/class_WebResendLinkCommand.php b/inc/classes/main/commands/web/class_WebResendLinkCommand.php new file mode 100644 index 00000000..c66a39b5 --- /dev/null +++ b/inc/classes/main/commands/web/class_WebResendLinkCommand.php @@ -0,0 +1,142 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class WebResendLinkCommand extends BaseCommand implements Commandable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $resolverInstance An instance of a command resolver class + * @return $commandInstance An instance a prepared command class + */ + public final static function createWebResendLinkCommand (CommandResolver $resolverInstance) { + // Get new instance + $commandInstance = new WebResendLinkCommand(); + + // Set the application instance + $commandInstance->setResolverInstance($resolverInstance); + + // Return the prepared instance + return $commandInstance; + } + + /** + * Executes the given command with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @throws InvalidInterfaceException If the user class does not implement ManageableMember + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get user instance from registry + $userInstance = Registry::getRegistry()->getInstance('user'); + + // Does the user instance implement ManageableMember? + if (!$userInstance instanceof ManageableMember) { + // Throw exception here + throw new InvalidInterfaceException(array($userInstance, 'ManageableMember'), self::EXCEPTION_REQUIRED_INTERFACE_MISSING); + } // END - if + + // Get an application instance + $appInstance = $this->getResolverInstance()->getApplicationInstance(); + + // Get a RNG instance (Random Number Generator) + $rngInstance = ObjectFactory::createObjectByConfiguredName('rng_class'); + + // Generate a pseudo-random string + $randomString = $rngInstance->randomString(255); + + // Get a crypto instance + $cryptoInstance = ObjectFactory::createObjectByConfiguredName('crypto_class'); + + // Hash and encrypt the string + $hashedString = $cryptoInstance->hashString($cryptoInstance->encryptString($randomString)); + + // Update the user class + $userInstance->updateDatabaseField(UserDatabaseWrapper::DB_COLUMN_CONFIRM_HASH, $hashedString); + + // Re-set config entry to mailer engine + $this->getConfigInstance()->setConfigEntry('template_class', $this->getConfigInstance()->readConfig('mail_template_class')); + + // Prepare the template engine + $templateInstance = $this->prepareTemplateInstance($appInstance); + + // Assign the application data with the template engine + $templateInstance->assignApplicationData($appInstance); + + // Get a mailer class + $mailerInstance = ObjectFactory::createObjectByConfiguredName('mailer_class', array($templateInstance, $appInstance, 'resend_link')); + + // Set this mailer in our template engine + $templateInstance->setMailerInstance($mailerInstance); + + // Add template variables we shall get + $mailerInstance->addConfigTemplateVariable('base_url'); + $mailerInstance->addConfigTemplateVariable('admin_email'); + $mailerInstance->addValueTemplateVariable('confirm_hash'); + $mailerInstance->addValueTemplateVariable('username'); + $mailerInstance->addValueTemplateVariable('email'); + + // Add the value instance for the confirmation hash + $mailerInstance->addValueInstance('confirm_hash', $userInstance); + $mailerInstance->addValueInstance('username', $userInstance); + $mailerInstance->addValueInstance('email', $userInstance); + + // Add the recipient + $mailerInstance->addRecipientByUserInstance($userInstance); + + // Use subject line from template + $mailerInstance->useSubjectFromTemplate(); + + // Send the email out + $mailerInstance->deliverEmail($responseInstance); + + // Send out notification to admin (depends on settings) + $mailerInstance->sendAdminNotification($responseInstance); + } + + /** + * Adds extra filters to the given controller instance + * + * @param $controllerInstance A controller instance + * @param $requestInstance An instance of a class with an Requestable interface + * @return void + */ + public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) { + // Filter for checking if account is unconfirmed + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_unconfirmed_filter', array($controllerInstance))); + } +} + +// [EOF] +?> diff --git a/inc/classes/main/compressor/.htaccess b/inc/classes/main/compressor/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/compressor/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/compressor/class_Bzip2Compressor.php b/inc/classes/main/compressor/class_Bzip2Compressor.php new file mode 100644 index 00000000..50a4bad2 --- /dev/null +++ b/inc/classes/main/compressor/class_Bzip2Compressor.php @@ -0,0 +1,99 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class Bzip2Compressor extends BaseFrameworkSystem implements Compressor { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor! + parent::__construct(__CLASS__); + } + + /** + * Create a new compressor channel based a given compression handler + * + * @return $cInstance An instance of this class + */ + public final static function createBzip2Compressor () { + // Get new instance + if ((function_exists('bzcompress')) && (function_exists('bzdecompress'))) { + // Compressor can maybe be used + $cInstance = new Bzip2Compressor(); + } else { + // Routines not found! + $cInstance = null; + } + + // Return the compressor instance + return $cInstance; + } + + /** + * BZIP2 compression stream + * + * @param $streamData Mixed non-object stream data + * @return $streamData The compressed stream data + * @throws InvalidObjectException If the stream is an object + */ + public function compressStream ($streamData) { + if (is_object($streamData)) { + // Throw an exception + throw new InvalidObjectException($streamData, self::EXCEPTION_UNEXPECTED_OBJECT); + } + + // Return the compressed stream + return bzcompress($streamData, 1); + } + + /** + * BZIP2 decompression stream + * + * @param $streamData Mixed non-object stream data + * @return $streamData The decompressed stream data + * @throws InvalidObjectException If the stream is an object + */ + public function decompressStream ($streamData) { + if (is_object($streamData)) { + // Throw an exception + throw new InvalidObjectException($streamData, self::EXCEPTION_UNEXPECTED_OBJECT); + } + + // Return the decompressed stream + return bzdecompress($streamData); + } + + /** + * Getter for the file extension of this compressor + * + * @return $string Returns always "bz2" + */ + public final function getCompressorExtension () { + return "bz2"; + } +} + +// [EOF] +?> diff --git a/inc/classes/main/compressor/class_GzipCompressor.php b/inc/classes/main/compressor/class_GzipCompressor.php new file mode 100644 index 00000000..b4a30253 --- /dev/null +++ b/inc/classes/main/compressor/class_GzipCompressor.php @@ -0,0 +1,99 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class GzipCompressor extends BaseFrameworkSystem implements Compressor { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor! + parent::__construct(__CLASS__); + } + + /** + * Create a new compressor channel based a given compression handler + * + * @return $cInstance An instance of this class + */ + public final static function createGzipCompressor () { + // Get new instance + if ((function_exists('gzcompress')) && (function_exists('gzuncompress'))) { + // Compressor can maybe be used + $cInstance = new GzipCompressor(); + } else { + // Routines not found! + $cInstance = null; + } + + // Return the compressor instance + return $cInstance; + } + + /** + * GZIP compression stream + * + * @param $streamData Mixed non-object stream data + * @return $streamData The compressed stream data + * @throws InvalidObjectException If the stream is an object + */ + public function compressStream ($streamData) { + if (is_object($streamData)) { + // Throw an exception + throw new InvalidObjectException($streamData, self::EXCEPTION_UNEXPECTED_OBJECT); + } + + // Return the compressed stream + return gzcompress($streamData, 1); + } + + /** + * GZIP decompression stream + * + * @param $streamData Mixed non-object stream data + * @return $streamData The decompressed stream data + * @throws InvalidObjectException If the stream is an object + */ + public function decompressStream ($streamData) { + if (is_object($streamData)) { + // Throw an exception + throw new InvalidObjectException($streamData, self::EXCEPTION_UNEXPECTED_OBJECT); + } + + // Return the decompressed stream + return gzuncompress($streamData); + } + + /** + * Getter for the file extension of this compressor + * + * @return $string Returns always "gz" + */ + public final function getCompressorExtension () { + return "gz"; + } +} + +// [EOF] +?> diff --git a/inc/classes/main/compressor/class_NullCompressor.php b/inc/classes/main/compressor/class_NullCompressor.php new file mode 100644 index 00000000..24128bc3 --- /dev/null +++ b/inc/classes/main/compressor/class_NullCompressor.php @@ -0,0 +1,93 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NullCompressor extends BaseFrameworkSystem implements Compressor { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor! + parent::__construct(__CLASS__); + } + + /** + * Create a new compressor channel based a given compression handler + * + * @return $cInstance An instance of this class + */ + public final static function createNullCompressor () { + // Get new instance + $cInstance = new NullCompressor(); + + // Return the compressor instance + return $cInstance; + } + + /** + * Null compression stream + * + * @param $streamData Mixed non-object stream data + * @return $streamData The compressed stream data + * @throws InvalidObjectException If the stream is an object + */ + public function compressStream ($streamData) { + if (is_object($streamData)) { + // Throw an exception + throw new InvalidObjectException($streamData, self::EXCEPTION_UNEXPECTED_OBJECT); + } + + // Return the compressed stream + return $streamData; + } + + /** + * Null decompression stream + * + * @param $streamData Mixed non-object stream data + * @return $streamData The decompressed stream data + * @throws InvalidObjectException If the stream is an object + */ + public function decompressStream ($streamData) { + if (is_object($streamData)) { + // Throw an exception + throw new InvalidObjectException($streamData, self::EXCEPTION_UNEXPECTED_OBJECT); + } + + // Return the decompressed stream + return $streamData; + } + + /** + * Getter for the file extension of this compressor + * + * @return $string Returns always "null" + */ + public final function getCompressorExtension () { + return "null"; + } +} + +// [EOF] +?> diff --git a/inc/classes/main/console/.htaccess b/inc/classes/main/console/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/console/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/console/class_ConsoleTools.php b/inc/classes/main/console/class_ConsoleTools.php new file mode 100644 index 00000000..d037d404 --- /dev/null +++ b/inc/classes/main/console/class_ConsoleTools.php @@ -0,0 +1,83 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ConsoleTools extends BaseFrameworkSystem { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Aquires the IP address of this host by reading the /etc/hostname file and solving it + * + * @return $ip The resolved IP address + */ + public static function aquireSelfIPAddress () { + // Local IP by default + $ip = "127.0.0.1"; + + // Get a new instance + $helper = new ConsoleTools(); + + try { + // Get a file pointer + $io = FrameworkFileInputPointer::createFrameworkFileInputPointer("/etc/hostname"); + + // Read the file + $hostname = trim($io->readFromFile()); + $helper->debugOutput(sprintf("[%s:] Our host name is: %s", + $helper->__toString(), + $hostname + )); + + // Close the file + $io->closeFile(); + + // Resolve it + $ipResolved = gethostbyname($hostname); + if (($ipResolved !== false) && ($ipResolved != $hostname)) { + // Okay, this works! + $ip = $ipResolved; + + // Debug message + $helper->debugOutput(sprintf("[%s:] Resolved IP address is: %s\n", + $helper->__toString(), + $ip + )); + } + } catch (FrameworkException $e) { + // Do nothing here + } + + // Return the IP address + return $ip; + } +} + +// [EOF] +?> diff --git a/inc/classes/main/controller/.htaccess b/inc/classes/main/controller/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/controller/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/controller/captcha/.htaccess b/inc/classes/main/controller/captcha/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/controller/captcha/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/controller/captcha/class_ImageCodeCaptchaController.php b/inc/classes/main/controller/captcha/class_ImageCodeCaptchaController.php new file mode 100644 index 00000000..64e1a1a5 --- /dev/null +++ b/inc/classes/main/controller/captcha/class_ImageCodeCaptchaController.php @@ -0,0 +1,84 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ImageCodeCaptchaController extends BaseController implements Controller { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $resolverInstance An instance of a command resolver class + * @return $controllerInstance A prepared instance of this class + */ + public final static function createImageCodeCaptchaController (CommandResolver $resolverInstance) { + // Create the instance + $controllerInstance = new ImageCodeCaptchaController(); + + // Set the command resolver + $controllerInstance->setResolverInstance($resolverInstance); + + // Add filter for checking the "encrypt" string + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('captcha_encrypt_validator_filter', array($controllerInstance))); + + // Return the prepared instance + return $controllerInstance; + } + + /** + * Handles the given request and response + * + * @param $requestInstance An instance of a request class + * @param $responseInstance An instance of a response class + * @return void + */ + public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) { + // Execute pre filters + $this->executePreFilters($requestInstance, $responseInstance); + + // Get the command instance + $commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance); + + // This request was valid! :-D + $requestInstance->requestIsValid(); + + // Execute the command + $commandInstance->execute($requestInstance, $responseInstance); + + // Execute post filters + $this->executePostFilters($requestInstance, $responseInstance); + + // Flush the response out + $responseInstance->flushBuffer(); + } +} + +// [EOF] +?> diff --git a/inc/classes/main/controller/class_ b/inc/classes/main/controller/class_ new file mode 100644 index 00000000..a6cea16e --- /dev/null +++ b/inc/classes/main/controller/class_ @@ -0,0 +1,75 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ???Controller extends BaseController implements Controller { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $resolverInstance An instance of a command resolver class + * @return $controllerInstance A prepared instance of this class + */ + public final static function create???Controller (CommandResolver $resolverInstance) { + // Create the instance + $controllerInstance = new ???Controller(); + + // Set the command resolver + $controllerInstance->setResolverInstance($resolverInstance); + + // Return the prepared instance + return $controllerInstance; + } + + /** + * Handles the given request and response + * + * @param $requestInstance An instance of a request class + * @param $responseInstance An instance of a response class + * @return void + */ + public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) { + // Get the command instance + $commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance); + + // This request was valid! :-D + $requestInstance->requestIsValid(); + + // Execute the command + $commandInstance->execute($requestInstance, $responseInstance); + + // Flush the response out + $responseInstance->flushBuffer(); + } +} + +// [EOF] +?> diff --git a/inc/classes/main/controller/class_BaseController.php b/inc/classes/main/controller/class_BaseController.php new file mode 100644 index 00000000..69fa4d15 --- /dev/null +++ b/inc/classes/main/controller/class_BaseController.php @@ -0,0 +1,112 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseController extends BaseFrameworkSystem implements Registerable { + /** + * Generic filter chains + */ + private $filterChains = array(); + + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + + // Clean up a little + $this->removeNumberFormaters(); + $this->removeSystemArray(); + + // Initialize both filter chains + $this->initFilterChain('pre'); + $this->initFilterChain('post'); + + // Add this controller to the registry + Registry::getRegistry()->addInstance('controller', $this); + } + + /** + * Private method to initialize a given filter chain + * + * @param $filterChain Name of the filter chain + * @return void + */ + private function initFilterChain ($filterChain) { + $this->filterChains[$filterChain] = ObjectFactory::createObjectByConfiguredName('filter_chain_class'); + } + + /** + * Adds a filter to the pre filter chain + * + * @param $filterInstance An instance of a filter + * @return void + */ + public function addPreFilter (Filterable $filterInstance) { + // Add the pre filter + $this->filterChains['pre']->addFilter($filterInstance); + } + + /** + * Adds a filter to the post filter chain + * + * @param $filterInstance An instance of a filter + * @return void + */ + public function addPostFilter (Filterable $filterInstance) { + // Add the post filter + $this->filterChains['post']->addFilter($filterInstance); + } + + /** + * Executes all pre filters + * + * @param $requestInstance An instance of a request class + * @param $responseInstance An instance of a response class + * @return void + */ + protected function executePreFilters (Requestable $requestInstance, Responseable $responseInstance) { + // Execute all pre filters + $this->filterChains['pre']->processFilters($requestInstance, $responseInstance); + } + + /** + * Executes all post filters + * + * @param $requestInstance An instance of a request class + * @param $responseInstance An instance of a response class + * @return void + */ + protected function executePostFilters (Requestable $requestInstance, Responseable $responseInstance) { + // Execute all post filters + $this->filterChains['post']->processFilters($requestInstance, $responseInstance); + } +} + +// [EOF] +?> diff --git a/inc/classes/main/controller/form/.htaccess b/inc/classes/main/controller/form/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/controller/form/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/controller/form/class_WebDoFormController.php b/inc/classes/main/controller/form/class_WebDoFormController.php new file mode 100644 index 00000000..8691c3d2 --- /dev/null +++ b/inc/classes/main/controller/form/class_WebDoFormController.php @@ -0,0 +1,100 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class WebDoFormController extends BaseController implements Controller { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $resolverInstance An instance of a resolver class + * @return $controllerInstance A prepared instance of this class + */ + public final static function createWebDoFormController (CommandResolver $resolverInstance) { + // Create the instance + $controllerInstance = new WebDoFormController(); + + // Set resolver instance + $controllerInstance->setResolverInstance($resolverInstance); + + // We need the controller instance in resolver class so set it here + $resolverInstance->setControllerInstance($controllerInstance); + + // Return the prepared instance + return $controllerInstance; + } + + /** + * Handles the given request and response + * + * @param $requestInstance An instance of a request class + * @param $responseInstance An instance of a response class + * @return void + */ + public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) { + // Get the "form action" + $formAction = $requestInstance->getRequestElement('form'); + + // Get command instance from resolver + $commandInstance = $this->getResolverInstance()->resolveCommand($formAction); + + // Add more filters by the command + $commandInstance->addExtraFilters($this, $requestInstance); + + // Try to run the pre filters, if auth exceptions come through redirect here + try { + // Run the pre filters + $this->executePreFilters($requestInstance, $responseInstance); + } catch (UserAuthorizationException $e) { + // Redirect to main page + $responseInstance->redirectToConfiguredUrl('login_failed_url'); + + // Exit here + exit(); + } + + // Is the request still valid? Post filters shall only be executed of + // the request is valid + if ($requestInstance->isRequestValid()) { + // Execute the command + $commandInstance->execute($requestInstance, $responseInstance); + + // Execute *very* generic ppost filters + $this->executePostFilters($requestInstance, $responseInstance); + } + + // Flush the buffer out + $responseInstance->flushBuffer(); + } +} + +// [EOF] +?> diff --git a/inc/classes/main/controller/image/.htaccess b/inc/classes/main/controller/image/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/controller/image/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/controller/image/class_ImageDefaultController.php b/inc/classes/main/controller/image/class_ImageDefaultController.php new file mode 100644 index 00000000..689cee43 --- /dev/null +++ b/inc/classes/main/controller/image/class_ImageDefaultController.php @@ -0,0 +1,75 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ImageDefaultController extends BaseController implements Controller { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $resolverInstance An instance of a command resolver class + * @return $controllerInstance A prepared instance of this class + */ + public final static function createImageDefaultController (CommandResolver $resolverInstance) { + // Create the instance + $controllerInstance = new ImageDefaultController(); + + // Set the command resolver + $controllerInstance->setResolverInstance($resolverInstance); + + // Return the prepared instance + return $controllerInstance; + } + + /** + * Handles the given request and response + * + * @param $requestInstance An instance of a request class + * @param $responseInstance An instance of a response class + * @return void + */ + public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) { + // Get the command instance + $commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance); + + // This request was valid! :-D + $requestInstance->requestIsValid(); + + // Execute the command + $commandInstance->execute($requestInstance, $responseInstance); + + // Flush the response out + $responseInstance->flushBuffer(); + } +} + +// [EOF] +?> diff --git a/inc/classes/main/controller/login/.htaccess b/inc/classes/main/controller/login/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/controller/login/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/controller/login/class_WebLoginAreaController.php b/inc/classes/main/controller/login/class_WebLoginAreaController.php new file mode 100644 index 00000000..0ad97f05 --- /dev/null +++ b/inc/classes/main/controller/login/class_WebLoginAreaController.php @@ -0,0 +1,106 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class WebLoginAreaController extends BaseController implements Controller { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $resolverInstance An instance of a command resolver class + * @return $controllerInstance A prepared instance of this class + * @todo Add some morer filters to this controller + */ + public final static function createWebLoginAreaController (CommandResolver $resolverInstance) { + // Create the instance + $controllerInstance = new WebLoginAreaController(); + + // Set the command resolver + $controllerInstance->setResolverInstance($resolverInstance); + + // User auth filter + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_auth_filter', array($controllerInstance))); + + // User update filter + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_update_filter', array($controllerInstance))); + + // News fetcher filter + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('news_download_filter', array($controllerInstance))); + + // News proccess/display-preparation + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('news_process_filter', array($controllerInstance))); + + // Return the prepared instance + return $controllerInstance; + } + + /** + * Handles the given request and response + * + * @param $requestInstance An instance of a request class + * @param $responseInstance An instance of a response class + * @return void + */ + public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) { + // Get the command instance from the resolver by sending a request instance to the resolver + $commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance); + + // Add more filters by the command + $commandInstance->addExtraFilters($this, $requestInstance); + + // Try to run the pre filters, if auth exceptions come through redirect here + try { + // Run the pre filters + $this->executePreFilters($requestInstance, $responseInstance); + } catch (UserAuthorizationException $e) { + // Redirect to main page + $responseInstance->redirectToConfiguredUrl('login_failed_url'); + + // Exit here + exit(); + } + + // This request was valid! :-D + $requestInstance->requestIsValid(); + + // Execute the command + $commandInstance->execute($requestInstance, $responseInstance); + + // Run the pre filters + $this->executePostFilters($requestInstance, $responseInstance); + + // Flush the response out + $responseInstance->flushBuffer(); + } +} + +// [EOF] +?> diff --git a/inc/classes/main/controller/web/.htaccess b/inc/classes/main/controller/web/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/controller/web/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/controller/web/class_ b/inc/classes/main/controller/web/class_ new file mode 100644 index 00000000..4e5bdeed --- /dev/null +++ b/inc/classes/main/controller/web/class_ @@ -0,0 +1,85 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class Web???Controller extends BaseController implements Controller { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $resolverInstance An instance of a command resolver class + * @return $controllerInstance A prepared instance of this class + * @todo Add some filters to this controller + */ + public final static function createWeb???Controller (CommandResolver $resolverInstance) { + // Create the instance + $controllerInstance = new Web???Controller(); + + // Set the command resolver + $controllerInstance->setResolverInstance($resolverInstance); + + // Add filters + //$controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_status_confirmed_filter')); + + // Return the prepared instance + return $controllerInstance; + } + + /** + * Handles the given request and response + * + * @param $requestInstance An instance of a request class + * @param $responseInstance An instance of a response class + * @return void + */ + public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) { + // Get the command instance from the resolver by sending a request instance to the resolver + $commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance); + + // Run the pre filters + $this->executePreFilters($requestInstance, $responseInstance); + + // This request was valid! :-D + $requestInstance->requestIsValid(); + + // Execute the command + $commandInstance->execute($requestInstance, $responseInstance); + + // Run the pre filters + $this->executePostFilters($requestInstance, $responseInstance); + + // Flush the response out + $responseInstance->flushBuffer(); + } +} + +// [EOF] +?> diff --git a/inc/classes/main/controller/web/class_WebConfirmController.php b/inc/classes/main/controller/web/class_WebConfirmController.php new file mode 100644 index 00000000..ebdd1508 --- /dev/null +++ b/inc/classes/main/controller/web/class_WebConfirmController.php @@ -0,0 +1,88 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class WebConfirmController extends BaseController implements Controller { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $resolverInstance An instance of a command resolver class + * @return $controllerInstance A prepared instance of this class + * @todo Add some filters to this controller + */ + public final static function createWebConfirmController (CommandResolver $resolverInstance) { + // Create the instance + $controllerInstance = new WebConfirmController(); + + // Set the command resolver + $controllerInstance->setResolverInstance($resolverInstance); + + // Add filters for handling confirmation code and username + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('username_verifier_filter', array($controllerInstance))); + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_unconfirmed_filter', array($controllerInstance))); + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('confirm_code_verifier_filter', array($controllerInstance))); + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_status_confirmed_filter', array($controllerInstance))); + + // Return the prepared instance + return $controllerInstance; + } + + /** + * Handles the given request and response + * + * @param $requestInstance An instance of a request class + * @param $responseInstance An instance of a response class + * @return void + */ + public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) { + // Get the command instance from the resolver by sending a request instance to the resolver + $commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance); + + // Run the pre filters + $this->executePreFilters($requestInstance, $responseInstance); + + // This request was valid! :-D + $requestInstance->requestIsValid(); + + // Execute the command + $commandInstance->execute($requestInstance, $responseInstance); + + // Run the pre filters + $this->executePostFilters($requestInstance, $responseInstance); + + // Flush the response out + $responseInstance->flushBuffer(); + } +} + +// [EOF] +?> diff --git a/inc/classes/main/controller/web/class_WebDefaultController.php b/inc/classes/main/controller/web/class_WebDefaultController.php new file mode 100644 index 00000000..37cf3d9e --- /dev/null +++ b/inc/classes/main/controller/web/class_WebDefaultController.php @@ -0,0 +1,76 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * @todo This controller shall still provide some headlines for sidebars + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class WebDefaultController extends BaseController implements Controller { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $resolverInstance An instance of a command resolver class + * @return $controllerInstance A prepared instance of this class + */ + public final static function createWebDefaultController (CommandResolver $resolverInstance) { + // Create the instance + $controllerInstance = new WebDefaultController(); + + // Set the command resolver + $controllerInstance->setResolverInstance($resolverInstance); + + // Return the prepared instance + return $controllerInstance; + } + + /** + * Handles the given request and response + * + * @param $requestInstance An instance of a request class + * @param $responseInstance An instance of a response class + * @return void + */ + public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) { + // Get the command instance + $commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance); + + // This request was valid! :-D + $requestInstance->requestIsValid(); + + // Execute the command + $commandInstance->execute($requestInstance, $responseInstance); + + // Flush the response out + $responseInstance->flushBuffer(); + } +} + +// [EOF] +?> diff --git a/inc/classes/main/controller/web/class_WebDefaultNewsController.php b/inc/classes/main/controller/web/class_WebDefaultNewsController.php new file mode 100644 index 00000000..8d7255d0 --- /dev/null +++ b/inc/classes/main/controller/web/class_WebDefaultNewsController.php @@ -0,0 +1,88 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class WebDefaultNewsController extends BaseController implements Controller { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $resolverInstance An instance of a command resolver class + * @return $controllerInstance A prepared instance of this class + */ + public final static function createWebDefaultNewsController (CommandResolver $resolverInstance) { + // Create the instance + $controllerInstance = new WebDefaultNewsController(); + + // Set the command resolver + $controllerInstance->setResolverInstance($resolverInstance); + + // Add news filters to this controller + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('news_download_filter', array($controllerInstance))); + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('news_process_filter', array($controllerInstance))); + + // Return the prepared instance + return $controllerInstance; + } + + /** + * Handles the given request and response + * + * @param $requestInstance An instance of a request class + * @param $responseInstance An instance of a response class + * @return void + */ + public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) { + // Get the command instance from the resolver by sending a request instance to the resolver + $commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance); + + // Add more filters by the command + $commandInstance->addExtraFilters($this, $requestInstance); + + // Run the pre filters + $this->executePreFilters($requestInstance, $responseInstance); + + // This request was valid! :-D + $requestInstance->requestIsValid(); + + // Execute the command + $commandInstance->execute($requestInstance, $responseInstance); + + // Run the pre filters + $this->executePostFilters($requestInstance, $responseInstance); + + // Flush the response out + $responseInstance->flushBuffer(); + } +} + +// [EOF] +?> diff --git a/inc/classes/main/controller/web/class_WebLoginController.php b/inc/classes/main/controller/web/class_WebLoginController.php new file mode 100644 index 00000000..f4ce0533 --- /dev/null +++ b/inc/classes/main/controller/web/class_WebLoginController.php @@ -0,0 +1,86 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class WebLoginController extends BaseController implements Controller { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $resolverInstance An instance of a command resolver class + * @return $controllerInstance A prepared instance of this class + * @todo Add some filters to this controller + */ + public final static function createWebLoginController (CommandResolver $resolverInstance) { + // Create the instance + $controllerInstance = new WebLoginController(); + + // Set the command resolver + $controllerInstance->setResolverInstance($resolverInstance); + + // Return the prepared instance + return $controllerInstance; + } + + /** + * Handles the given request and response + * + * @param $requestInstance An instance of a request class + * @param $responseInstance An instance of a response class + * @return void + */ + public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) { + // Get the command instance from the resolver by sending a request instance to the resolver + $commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance); + + // Add more filters by the command + $commandInstance->addExtraFilters($this, $requestInstance); + + // Run the pre filters + $this->executePreFilters($requestInstance, $responseInstance); + + // This request was valid! :-D + $requestInstance->requestIsValid(); + + // Execute the command + $commandInstance->execute($requestInstance, $responseInstance); + + // Run the pre filters + $this->executePostFilters($requestInstance, $responseInstance); + + // Flush the response out + $responseInstance->flushBuffer(); + } +} + +// [EOF] +?> diff --git a/inc/classes/main/controller/web/class_WebLoginFailedController.php b/inc/classes/main/controller/web/class_WebLoginFailedController.php new file mode 100644 index 00000000..5b39ab0f --- /dev/null +++ b/inc/classes/main/controller/web/class_WebLoginFailedController.php @@ -0,0 +1,75 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class WebLoginFailedController extends BaseController implements Controller { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $resolverInstance An instance of a command resolver class + * @return $controllerInstance A prepared instance of this class + */ + public final static function createWebLoginFailedController (CommandResolver $resolverInstance) { + // Create the instance + $controllerInstance = new WebLoginFailedController(); + + // Set the command resolver + $controllerInstance->setResolverInstance($resolverInstance); + + // Return the prepared instance + return $controllerInstance; + } + + /** + * Handles the given request and response + * + * @param $requestInstance An instance of a request class + * @param $responseInstance An instance of a response class + * @return void + */ + public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) { + // Get the command instance + $commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance); + + // This request was valid! :-D + $requestInstance->requestIsValid(); + + // Execute the command + $commandInstance->execute($requestInstance, $responseInstance); + + // Flush the response out + $responseInstance->flushBuffer(); + } +} + +// [EOF] +?> diff --git a/inc/classes/main/controller/web/class_WebLogoutController.php b/inc/classes/main/controller/web/class_WebLogoutController.php new file mode 100644 index 00000000..258d1995 --- /dev/null +++ b/inc/classes/main/controller/web/class_WebLogoutController.php @@ -0,0 +1,82 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * @todo This controller shall still provide some headlines for sidebars + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class WebLogoutController extends BaseController implements Controller { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $resolverInstance An instance of a command resolver class + * @return $controllerInstance A prepared instance of this class + */ + public final static function createWebLogoutController (CommandResolver $resolverInstance) { + // Create the instance + $controllerInstance = new WebLogoutController(); + + // Set the command resolver + $controllerInstance->setResolverInstance($resolverInstance); + + // Add user auth filter (we don't need an update of the user here because it will be redirected) + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_auth_filter', array($controllerInstance))); + + // User status filter + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_status_filter', array($controllerInstance))); + + // Return the prepared instance + return $controllerInstance; + } + + /** + * Handles the given request and response + * + * @param $requestInstance An instance of a request class + * @param $responseInstance An instance of a response class + * @return void + */ + public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) { + // Get the command instance + $commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance); + + // This request was valid! :-D + $requestInstance->requestIsValid(); + + // Execute the command + $commandInstance->execute($requestInstance, $responseInstance); + + // Flush the response out + $responseInstance->flushBuffer(); + } +} + +// [EOF] +?> diff --git a/inc/classes/main/controller/web/class_WebLogoutDoneController.php b/inc/classes/main/controller/web/class_WebLogoutDoneController.php new file mode 100644 index 00000000..58058b10 --- /dev/null +++ b/inc/classes/main/controller/web/class_WebLogoutDoneController.php @@ -0,0 +1,86 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class WebLogoutDoneController extends BaseController implements Controller { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $resolverInstance An instance of a command resolver class + * @return $controllerInstance A prepared instance of this class + * @todo Add some filters to this controller + */ + public final static function createWebLogoutDoneController (CommandResolver $resolverInstance) { + // Create the instance + $controllerInstance = new WebLogoutDoneController(); + + // Set the command resolver + $controllerInstance->setResolverInstance($resolverInstance); + + + // Return the prepared instance + return $controllerInstance; + } + + /** + * Handles the given request and response + * + * @param $requestInstance An instance of a request class + * @param $responseInstance An instance of a response class + * @return void + */ + public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) { + // Get the command instance from the resolver by sending a request instance to the resolver + $commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance); + + // Add more filters by the command + $commandInstance->addExtraFilters($this, $requestInstance); + + // Run the pre filters + $this->executePreFilters($requestInstance, $responseInstance); + + // This request was valid! :-D + $requestInstance->requestIsValid(); + + // Execute the command + $commandInstance->execute($requestInstance, $responseInstance); + + // Run the pre filters + $this->executePostFilters($requestInstance, $responseInstance); + + // Flush the response out + $responseInstance->flushBuffer(); + } +} + +// [EOF] +?> diff --git a/inc/classes/main/controller/web/class_WebRegisterController.php b/inc/classes/main/controller/web/class_WebRegisterController.php new file mode 100644 index 00000000..c848c472 --- /dev/null +++ b/inc/classes/main/controller/web/class_WebRegisterController.php @@ -0,0 +1,86 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class WebRegisterController extends BaseController implements Controller { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $resolverInstance An instance of a command resolver class + * @return $controllerInstance A prepared instance of this class + * @todo Add some filters to this controller + */ + public final static function createWebRegisterController (CommandResolver $resolverInstance) { + // Create the instance + $controllerInstance = new WebRegisterController(); + + // Set the command resolver + $controllerInstance->setResolverInstance($resolverInstance); + + + // Return the prepared instance + return $controllerInstance; + } + + /** + * Handles the given request and response + * + * @param $requestInstance An instance of a request class + * @param $responseInstance An instance of a response class + * @return void + */ + public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) { + // Get the command instance from the resolver by sending a request instance to the resolver + $commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance); + + // Add more filters by the command + $commandInstance->addExtraFilters($this, $requestInstance); + + // Run the pre filters + $this->executePreFilters($requestInstance, $responseInstance); + + // This request was valid! :-D + $requestInstance->requestIsValid(); + + // Execute the command + $commandInstance->execute($requestInstance, $responseInstance); + + // Run the pre filters + $this->executePostFilters($requestInstance, $responseInstance); + + // Flush the response out + $responseInstance->flushBuffer(); + } +} + +// [EOF] +?> diff --git a/inc/classes/main/controller/web/class_WebStatusController.php b/inc/classes/main/controller/web/class_WebStatusController.php new file mode 100644 index 00000000..843e05cd --- /dev/null +++ b/inc/classes/main/controller/web/class_WebStatusController.php @@ -0,0 +1,76 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * @todo This controller shall still provide some headlines for sidebars + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class WebStatusController extends BaseController implements Controller { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $resolverInstance An instance of a command resolver class + * @return $controllerInstance A prepared instance of this class + */ + public final static function createWebStatusController (CommandResolver $resolverInstance) { + // Create the instance + $controllerInstance = new WebStatusController(); + + // Set the command resolver + $controllerInstance->setResolverInstance($resolverInstance); + + // Return the prepared instance + return $controllerInstance; + } + + /** + * Handles the given request and response + * + * @param $requestInstance An instance of a request class + * @param $responseInstance An instance of a response class + * @return void + */ + public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) { + // Get the command instance + $commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance); + + // This request was valid! :-D + $requestInstance->requestIsValid(); + + // Execute the command + $commandInstance->execute($requestInstance, $responseInstance); + + // Flush the response out + $responseInstance->flushBuffer(); + } +} + +// [EOF] +?> diff --git a/inc/classes/main/criteria/.htaccess b/inc/classes/main/criteria/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/criteria/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/criteria/class_DataSetCriteria.php b/inc/classes/main/criteria/class_DataSetCriteria.php new file mode 100644 index 00000000..34715c52 --- /dev/null +++ b/inc/classes/main/criteria/class_DataSetCriteria.php @@ -0,0 +1,187 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class DataSetCriteria extends BaseFrameworkSystem implements StoreableCriteria { + /** + * Table name + */ + private $tableName = ""; + + /** + * Table columns (criteria) to store + */ + private $tableColumns = array(); + + /** + * Unique key + */ + private $uniqueKey = ""; + + /** + * Primary key + */ + private $primaryKey = ""; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct() { + // Call parent constructor + parent::__construct(__CLASS__); + + // Clean up a little + $this->removeNumberFormaters(); + $this->removeSystemArray(); + } + + /** + * Creates an instance of this criteria + * + * @param $tableName Name of the table + * @return $criteriaInstance An instance of this criteria + */ + public final static function createDataSetCriteria ($tableName) { + // Get a new instance + $criteriaInstance = new DataSetCriteria(); + + // Set table name + $criteriaInstance->setTableName($tableName); + + // Return the instance + return $criteriaInstance; + } + + /** + * Add criteria + * + * @param $criteriaKey Criteria key + * @param $criteriaValue Criteria value + * @return void + */ + public function addCriteria ($criteriaKey, $criteriaValue) { + $this->tableColumns[(string) $criteriaKey] = $criteriaValue; + } + + /** + * Add configured criteria + * + * @param $criteriaKey Criteria key + * @param $configEntry Configuration entry + * @return void + */ + public function addConfiguredCriteria ($criteriaKey, $configEntry) { + // Add configuration entry as criteria + $value = $this->getConfigInstance()->readConfig($configEntry); + $this->addCriteria($criteriaKey, $value); + } + + /** + * Setter for table name + * + * @param $tableName Name of the table to set + * @return void + */ + public final function setTableName ($tableName) { + $this->tableName = (string) $tableName; + } + + /** + * Getter for table name + * + * @return $tableName Name of the table to set + */ + public final function getTableName () { + return $this->tableName; + } + + /** + * Setter for unique key + * + * @param $uniqueKey Column to use as unique key + * @return void + */ + public final function setUniqueKey ($uniqueKey) { + $this->uniqueKey = (string) $uniqueKey; + } + + /** + * Getter for unique key + * + * @return $uniqueKey Column to use as unique key + */ + public final function getUniqueKey () { + return $this->uniqueKey; + } + + /** + * Getter for unique key value + * + * @return $uniqueValue Value of the unique key + */ + public final function getUniqueValue () { + return $this->tableColumns[$this->getUniqueKey()]; + } + + /** + * Getter for criteria array + * + * @return $tableColumns + */ + public final function getCriteriaArray () { + return $this->tableColumns; + } + + /** + * Getter for primary key or unique key if not set + * + * @return $primaryKey Primary key or unique key if not set + */ + public final function getPrimaryKey () { + // Get primary key by default + $primaryKey = $this->primaryKey; + + if (empty($primaryKey)) { + // Get uniqueKey + $primaryKey = $this->getUniqueKey(); + } // END - if + + // Return it + return $primaryKey; + } + + /** + * Setter for primary key + * + * @param $primaryKey Primary key to set + * @return void + */ + public final function setPrimaryKey ($primaryKey) { + $this->primaryKey = (string) $primaryKey; + } +} + +// [EOF] +?> diff --git a/inc/classes/main/criteria/class_SearchCriteria.php b/inc/classes/main/criteria/class_SearchCriteria.php new file mode 100644 index 00000000..faeb8be6 --- /dev/null +++ b/inc/classes/main/criteria/class_SearchCriteria.php @@ -0,0 +1,213 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class SearchCriteria extends BaseFrameworkSystem implements LocalSearchCriteria { + /** + * Criteria to handle + */ + private $searchCriteria = array(); + + /** + * Limitation for the search + */ + private $limit = 0; + + /** + * Skip these entries before using them + */ + private $skip = 0; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Clean up a little + $this->removeNumberFormaters(); + $this->removeSystemArray(); + } + + /** + * Create an instance of this class + * + * @return $criteriaInstance An instance of this criteria + */ + public final static function createSearchCriteria () { + // Get a new instance + $criteriaInstance = new SearchCriteria(); + + // Return this instance + return $criteriaInstance; + } + + /** + * Add criteria + * + * @param $criteriaKey Criteria key + * @param $criteriaValue Criteria value + * @return void + */ + public final function addCriteria ($criteriaKey, $criteriaValue) { + $this->searchCriteria[(string)$criteriaKey] = (string)$criteriaValue; + } + + /** + * Add configured criteria + * + * @param $criteriaKey Criteria key + * @param $configEntry Configuration entry + * @return void + */ + public final function addConfiguredCriteria ($criteriaKey, $configEntry) { + // Add the configuration entry as a criteria + $value = $this->getConfigInstance()->readConfig($configEntry); + $this->addCriteria($criteriaKey, $value); + } + + /** + * Setter for limit + * + * @param $limit Search limit + * @return void + * @todo Find a nice casting here. (int) allows until and including 32766. + */ + public final function setLimit ($limit) { + $this->limit = $limit; + } + + /** + * Getter for limit + * + * @return $limit Search limit + */ + public final function getLimit () { + return $this->limit; + } + + /** + * Setter for skip + * + * @param $skip Search skip + * @return void + * @todo Find a nice casting here. (int) allows until and including 32766. + */ + public final function setSkip ($skip) { + $this->skip = $skip; + } + + /** + * Getter for skip + * + * @return $skip Search skip + */ + public final function getSkip () { + return $this->skip; + } + + /** + * "Getter" for a cache key + * + * @return $cacheKey The key suitable for the cache system + */ + public function getCacheKey () { + // Initialize the key + $cacheKey = ""; + + // Now walk through all criterias + foreach ($this->searchCriteria as $criteriaKey => $criteriaValue) { + // Add the value URL encoded to avoid any trouble with special characters + $cacheKey .= sprintf("%s=%s;", + $criteriaKey, + urlencode($criteriaValue) + ); + } + + // Add limit and skip values + $cacheKey .= sprintf("%%limit%%=%s;%%skip%%=%s", + $this->limit, + $this->skip + ); + + // Return the cache key + return $cacheKey; + } + + /** + * Get criteria element or null if not found + * + * @param $criteria The criteria we want to have + * @return $value Wether the value of the critera or null + */ + public function getCriteriaElemnent ($criteria) { + // Default is not found + $value = null; + + // Is the criteria there? + if (isset($this->searchCriteria[$criteria])) { + // Then use it + $value = $this->searchCriteria[$criteria]; + } + + // Return the value + return $value; + } + + /** + * Checks wether given array entry matches + * + * @param $entryArray Array with the entries to find + * @return $matches Wether the entry matches or not + */ + public function ifEntryMatches (array $entryArray) { + // First nothing matches and nothing is counted + $matches = false; + $counted = 0; + + // Walk through all entries + foreach ($entryArray as $key => $entry) { + // Then walk through all search criteria + foreach ($this->searchCriteria as $criteriaKey => $criteriaValue) { + // Is the element found and does it match? + if (($key == $criteriaKey) && ($criteriaValue == $entry)) { + // Then count this one up + $counted++; + } // END - if + } // END - foreach + } // END - foreach + + // Now check if expected criteria counts match + $matches = ($counted == count($this->searchCriteria)); + + // Return the result + return $matches; + } +} + +// [EOF] +?> diff --git a/inc/classes/main/criteria/class_UpdateCriteria.php b/inc/classes/main/criteria/class_UpdateCriteria.php new file mode 100644 index 00000000..af3f6a57 --- /dev/null +++ b/inc/classes/main/criteria/class_UpdateCriteria.php @@ -0,0 +1,104 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class UpdateCriteria extends BaseFrameworkSystem implements LocalUpdateCriteria { + /** + * Criteria to handle + */ + private $updateCriteria = array(); + + /** + * Limitation for the update + */ + private $limit = 0; + + /** + * Skip these entries before using them + */ + private $skip = 0; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Clean up a little + $this->removeNumberFormaters(); + $this->removeSystemArray(); + } + + /** + * Create an instance of this class + * + * @return $criteriaInstance An instance of this criteria + */ + public final static function createUpdateCriteria () { + // Get a new instance + $criteriaInstance = new UpdateCriteria(); + + // Return this instance + return $criteriaInstance; + } + + /** + * Add criteria + * + * @param $criteriaKey Criteria key + * @param $criteriaValue Criteria value + * @return void + */ + public function addCriteria ($criteriaKey, $criteriaValue) { + $this->updateCriteria[$criteriaKey] = $criteriaValue; + } + + /** + * Add configured criteria + * + * @param $criteriaKey Criteria key + * @param $configEntry Configuration entry + * @return void + */ + public function addConfiguredCriteria ($criteriaKey, $configEntry) { + // Add the configuration entry as a criteria + $value = $this->getConfigInstance()->readConfig($configEntry); + $this->addCriteria($criteriaKey, $value); + } + + /** + * Getter for update criteria array + * + * @return $updateCriteria Array holding the update criteria + */ + public final function getUpdateCriteria () { + return $this->updateCriteria; + } +} + +// [EOF] +?> diff --git a/inc/classes/main/crypto/.htaccess b/inc/classes/main/crypto/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/crypto/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/crypto/class_CryptoHelper.php b/inc/classes/main/crypto/class_CryptoHelper.php new file mode 100644 index 00000000..0456e10d --- /dev/null +++ b/inc/classes/main/crypto/class_CryptoHelper.php @@ -0,0 +1,260 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class CryptoHelper extends BaseFrameworkSystem implements Cryptable { + // Exception constants + const EXCEPTION_ENCRYPT_MISSING = 0x1f0; + const EXCEPTION_ENCRYPT_INVALID = 0x1f1; + + /** + * An instance of this own clas + */ + private static $selfInstance = null; + + /** + * Instance of the random number generator + */ + private $rngInstance = null; + + /** + * Salt for hashing operations + */ + private $salt = ""; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Clean up a little + $this->removeNumberFormaters(); + $this->removeSystemArray(); + } + + /** + * Creates an instance of this class + * + * @return $cryptoInstance An instance of this crypto helper class + */ + public final static function createCryptoHelper () { + // Get a new instance + $cryptoInstance = new CryptoHelper(); + + // Initialize the hasher + $cryptoInstance->initHasher(); + + // Return the instance + return $cryptoInstance; + } + + /** + * Get a singleton instance of this class + * + * @return $selfInstance An instance of this crypto helper class + */ + public final static function getInstance () { + // Is no instance there? + if (is_null(self::$selfInstance)) { + // Then get a new one + self::$selfInstance = self::createCryptoHelper(); + } + + // Return the instance + return self::$selfInstance; + } + + /** + * Initializes the hasher for different purposes. + * + * @return void + */ + protected function initHasher () { + // Initialize the random number generator which is required by some crypto methods + $this->rngInstance = ObjectFactory::createObjectByConfiguredName('rng_class'); + + // Generate a salt for the hasher + $this->generateSalt(); + } + + /** + * Generates the salt based on configured length + * + * @return void + */ + private function generateSalt () { + // Get a random string from the RNG + $randomString = $this->rngInstance->randomString(); + + // Get config entry for salt length + $length = $this->getConfigInstance()->readConfig('salt_length'); + + // Keep only defined number of characters + $this->salt = substr(sha1($randomString), -$length, $length); + } + + /** + * Hashes a string with salt and returns the hash. If an old previous hash + * is supplied the method will use the first X chars of that hash for hashing + * the password. This is useful if you want to check if password is identical + * for authorization purposes. + * + * @param $str Unhashed string + * @param $oldHash A hash from previous hashed string + * @return $hashed The hashed and salted string + */ + public function hashString ($str, $oldHash = "") { + // Cast the string + $str = (string) $str; + + // Default is the default salt ;-) + $salt = $this->salt; + + // Is the old password set? + if (!empty($oldHash)) { + // Use the salt from hash, first get length + $length = $this->getConfigInstance()->readConfig('salt_length'); + + // Then extract the X first characters from the hash as our salt + $salt = substr($oldHash, 0, $length); + } // END - if + + // Hash the password with salt + //* DEBUG: */ echo "salt=".$salt."/plain=".$str."
\n"; + $hashed = $salt . md5(sprintf($this->getConfigInstance()->readConfig('hash_mask'), + $salt, + $this->rngInstance->getFixedSalt(), + $str + )); + + // And return it + return $hashed; + } + + /** + * Encrypt the string with fixed salt + * + * @param $str The unencrypted string + * @return $encrypted Encrypted string + */ + public function encryptString ($str) { + // Init crypto module + $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB); + $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND); + + // Get key + if ($this->getConfigInstance()->readConfig('crypt_fixed_salt') === "Y") { + $key = md5($this->rngInstance->getFixedSalt()); + } else { + $key = md5($this->rngInstance->getExtraSalt()); + } + + // Add some "garbage" to the string + switch ($this->rngInstance->randomNumber(0, 8)) { + case 0: + $garbageString = crc32($this->rngInstance->randomString(10))."|".base64_encode($str)."|".crc32($this->rngInstance->randomString(20)); + break; + + case 1: + $garbageString = crc32($this->rngInstance->randomString(10))."|".base64_encode($str)."|".md5($this->rngInstance->randomString(20)); + break; + + case 2: + $garbageString = crc32($this->rngInstance->randomString(10))."|".base64_encode($str)."|".sha1($this->rngInstance->randomString(20)); + break; + + case 3: + $garbageString = md5($this->rngInstance->randomString(10))."|".base64_encode($str)."|".crc32($this->rngInstance->randomString(20)); + break; + + case 4: + $garbageString = md5($this->rngInstance->randomString(10))."|".base64_encode($str)."|".md5($this->rngInstance->randomString(20)); + break; + + case 5: + $garbageString = md5($this->rngInstance->randomString(10))."|".base64_encode($str)."|".sha1($this->rngInstance->randomString(20)); + break; + + case 6: + $garbageString = sha1($this->rngInstance->randomString(10))."|".base64_encode($str)."|".crc32($this->rngInstance->randomString(20)); + break; + + case 7: + $garbageString = sha1($this->rngInstance->randomString(10))."|".base64_encode($str)."|".md5($this->rngInstance->randomString(20)); + break; + + case 8: + $garbageString = sha1($this->rngInstance->randomString(10))."|".base64_encode($str)."|".sha1($this->rngInstance->randomString(20)); + break; + } + + // Encrypt the string + $encrypted = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $garbageString, MCRYPT_MODE_ECB, $iv); + + // Return the string + return $encrypted; + } + + /** + * Decrypt the string with fixed salt + * + * @param $encrypted Encrypted string + * @return $str The unencrypted string + */ + public function decryptString ($encrypted) { + // Init crypto module + $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB); + $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND); + + // Get key + if ($this->getConfigInstance()->readConfig('crypt_fixed_salt') === "Y") { + $key = md5($this->rngInstance->getFixedSalt()); + } else { + $key = md5($this->rngInstance->getExtraSalt()); + } + + // Decrypt the string + $garbageString = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, $encrypted, MCRYPT_MODE_ECB, $iv); + + // Get the real string out + $strArray = explode("|", $garbageString); + + // Does the element count match? + assert(count($strArray) == 3); + + // Decode the string + $str = base64_decode($strArray[1]); + + // Trim trailing nulls away + $str = rtrim($str, "\0"); + + // Return the string + return $str; + } +} + +// [EOF] +?> diff --git a/inc/classes/main/database/.htaccess b/inc/classes/main/database/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/database/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/database/class_ b/inc/classes/main/database/class_ new file mode 100644 index 00000000..1fdbd071 --- /dev/null +++ b/inc/classes/main/database/class_ @@ -0,0 +1,42 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class extends BaseDatabaseFrontend { + /** + * Protected constructor + * + * @return void + */ + protected function __construct($class = __CLASS__) { + // Call parent constructor + parent::__construct($class); + + // Clean up a little + $this->removeNumberFormaters(); + $this->removeSystemArray(); + } +} + +// [EOF] +?> diff --git a/inc/classes/main/database/class_BaseDatabaseFrontend.php b/inc/classes/main/database/class_BaseDatabaseFrontend.php new file mode 100644 index 00000000..57a5d545 --- /dev/null +++ b/inc/classes/main/database/class_BaseDatabaseFrontend.php @@ -0,0 +1,50 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +abstract class BaseDatabaseFrontend extends BaseFrameworkSystem implements DatabaseFrontendInterface { + // Constants for exceptions + const EXCEPTION_SQL_QUERY = 0x140; + + /** + * The limiter instance + */ + private $limitInstance = null; + + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct($className) { + // Call parent constructor + parent::__construct($className); + + // Clean up a little + $this->removeNumberFormaters(); + } +} + +// [EOF] +?> diff --git a/inc/classes/main/database/class_BaseDatabaseWrapper.php b/inc/classes/main/database/class_BaseDatabaseWrapper.php new file mode 100644 index 00000000..e406938b --- /dev/null +++ b/inc/classes/main/database/class_BaseDatabaseWrapper.php @@ -0,0 +1,161 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseDatabaseWrapper extends BaseFrameworkSystem { + /** + * Cache instance + */ + private $cacheInstance = null; + + /** + * Current table name to use + */ + private $tableName = "unknown"; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct($class) { + // Call parent constructor + parent::__construct($class); + + // Initialize the cache instance + $this->initCacheInstance(); + + // Clean up a little + $this->removeNumberFormaters(); + $this->removeSystemArray(); + } + + /** + * Initializes the cache instance with a new object + * + * @return void + */ + private final function initCacheInstance () { + // Set the new instance + $this->cacheInstance = CacheFactory::getFactory()->createConfiguredCache(); + } + + /** + * Do a "select" query on the current table with the given search criteria and + * store it in cache for later usage + * + * @param $criteriaInstance An instance of a Criteria class + * @return $resultInstance An instance of a database result class + */ + public function doSelectByCriteria (Criteria $criteriaInstance) { + // First get a key suitable for our cache and extend it with this class name + $cacheKey = sprintf("%s@%s", + $this->__toString(), + $criteriaInstance->getCacheKey() + ); + + // Does this key exists in cache? + if ($this->cacheInstance->offsetExists($cacheKey)) { + // Then use this result + $result = $cacheInstance->offsetGet($cacheKey); + } else { + // Now it's time to ask the database layer for this select statement + $result = $this->getDatabaseInstance()->doSelectByTableCriteria($this->getTableName(), $criteriaInstance); + + // Cache the result if not null + if (!is_null($result)) { + // A valid result has returned from the database layer + $this->cacheInstance->offsetSet($cacheKey, $result); + } else { + // This invalid result must be wrapped + $result = array( + 'status' => "invalid", + 'exception' => $this->getDatabaseInstance()->getLastException() + ); + } + } + + // Create an instance of a DatabaseResult class with the given result + $resultInstance = DatabaseResult::createDatabaseResult($result); + + // And return the instance + return $resultInstance; + } + + /** + * Count the numbers of rows we shall receive + * + * @param $criteriaInstance An instance of a Criteria class + * @return $numRows Numbers of rows of database entries + */ + public function doSelectCountByCriteria (Criteria $criteriaInstance) { + // Total numbers is zero by default + $numRows = 0; + + // Get the result from above method + $resultInstance = $this->doSelectByCriteria($criteriaInstance); + + // Was that query fine? + if ($resultInstance->ifStatusIsOkay()) { + // Then get the number of rows + $numRows = $resultInstance->getAffectedRows(); + } // END - if + + // Return the result + return $numRows; + } + + /** + * Setter for table name + * + * @param $tableName Name of table name to set + * @return void + */ + protected final function setTableName ($tableName) { + $this->tableName = (string) $tableName; + } + + /** + * Getter for table name + * + * @return $tableName Name of table name to set + */ + protected final function getTableName () { + return $this->tableName; + } + + /** + * Getter for primary key used in wrapped table + * + * @return $primaryKey Primary key used in wrapped table + */ + public final function getPrimaryKeyValue () { + // Get the table name and a database instance and ask for it + $primaryKey = $this->getDatabaseInstance()->getPrimaryKeyOfTable($this->getTableName()); + + // Return value + return $primaryKey; + } +} + +// [EOF] +?> diff --git a/inc/classes/main/database/databases/.htaccess b/inc/classes/main/database/databases/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/database/databases/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/database/databases/class_LocalFileDatabase.php b/inc/classes/main/database/databases/class_LocalFileDatabase.php new file mode 100644 index 00000000..dc4371ef --- /dev/null +++ b/inc/classes/main/database/databases/class_LocalFileDatabase.php @@ -0,0 +1,611 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontendInterface { + + // Constants for MySQL backward-compatiblity (PLEASE FIX THEM!) + const DB_CODE_TABLE_MISSING = 0x100; + const DB_CODE_TABLE_UNWRITEABLE = 0x101; + const DB_CODE_DATA_FILE_CORRUPT = 0x102; + + /** + * Save path for "file database" + */ + private $savePath = ""; + + /** + * The file's extension + */ + private $fileExtension = "serialized"; + + /** + * The last read file's name + */ + private $lastFile = ""; + + /** + * The last read file's content including header information + */ + private $lastContents = array(); + + /** + * Wether the "connection is already up + */ + private $alreadyConnected = false; + + /** + * Last error message + */ + private $lastError = ""; + + /** + * Last exception + */ + private $lastException = null; + + /** + * Table information array + */ + private $tableInfo = array(); + + /** + * Element for index + */ + private $indexKey = "__idx"; + + /** + * The protected constructor. Do never instance from outside! You need to + * set a local file path. The class will then validate it. + * + * @return void + */ + protected function __construct() { + // Call parent constructor + parent::__construct(__CLASS__); + + // Clean up a little + $this->removeNumberFormaters(); + $this->removeSystemArray(); + } + + /** + * Create an object of LocalFileDatabase and set the save path for local files. + * This method also validates the given file path. + * + * @param $savePath The local file path string + * @param $ioInstance The input/output handler. This + * should be FileIoHandler + * @return $dbInstance An instance of LocalFileDatabase + */ + public final static function createLocalFileDatabase ($savePath, FileIoHandler $ioInstance) { + // Get an instance + $dbInstance = new LocalFileDatabase(); + + // Set save path and IO instance + $dbInstance->setSavePath($savePath); + $dbInstance->setFileIoInstance($ioInstance); + + // "Connect" to the database + $dbInstance->connectToDatabase(); + + // Return database instance + return $dbInstance; + } + + /** + * Setter for save path + * + * @param $savePath The local save path where we shall put our serialized classes + * @return void + */ + public final function setSavePath ($savePath) { + // Secure string + $savePath = (string) $savePath; + + // Set save path + $this->savePath = $savePath; + } + + /** + * Getter for save path + * + * @return $savePath The local save path where we shall put our serialized classes + */ + public final function getSavePath () { + return $this->savePath; + } + + /** + * Getter for last error message + * + * @return $lastError Last error message + */ + public final function getLastError () { + return $this->lastError; + } + + /** + * Getter for last exception + * + * @return $lastException Last thrown exception + */ + public final function getLastException () { + return $this->lastException; + } + + /** + * Setter for the last read file + * + * @param $fqfn The FQFN of the last read file + * @return void + */ + private final function setLastFile ($fqfn) { + // Cast string and set it + $this->lastFile = (string) $fqfn; + } + + /** + * Reset the last error and exception instance. This should be done after + * a successfull "query" + * + * @return void + */ + private final function resetLastError () { + $this->lastError = ""; + $this->lastException = null; + } + + /** + * Getter for last read file + * + * @return $lastFile The last read file's name with full path + */ + public final function getLastFile () { + return $this->lastFile; + } + + /** + * Setter for contents of the last read file + * + * @param $contents An array with header and data elements + * @return void + */ + private final function setLastFileContents (array $contents) { + // Set array + $this->lastContents = $contents; + } + + /** + * Getter for last read file's content as an array + * + * @return $lastContent The array with elements 'header' and 'data'. + */ + public final function getLastContents () { + return $this->lastContents; + } + + /** + * Getter for file extension + * + * @return $fileExtension The array with elements 'header' and 'data'. + */ + public final function getFileExtension () { + return $this->fileExtension; + } + + /** + * Getter for index key + * + * @return $indexKey Index key + */ + public final function getIndexKey () { + return $this->indexKey; + } + + /** + * Reads a local data file and returns it's contents in an array + * + * @param $fqfn The FQFN for the requested file + * @return $dataArray + */ + private function getDataArrayFromFile ($fqfn) { + // Get a file pointer + $fileInstance = FrameworkFileInputPointer::createFrameworkFileInputPointer($fqfn); + + // Get the raw data and BASE64-decode it + $compressedData = base64_decode($fileInstance->readLinesFromFile()); + + // Close the file and throw the instance away + $fileInstance->closeFile(); + unset($fileInstance); + + // Decompress it + $serializedData = $this->getCompressorChannel()->getCompressor()->decompressStream($compressedData); + + // Unserialize it + $dataArray = unserialize($serializedData); + + // Finally return it + return $dataArray; + } + + /** + * Writes data array to local file + * + * @param $fqfn The FQFN of the local file + * @param $dataArray An array with all the data we shall write + * @return void + */ + private function writeDataArrayToFqfn ($fqfn, array $dataArray) { + // Get a file pointer instance + $fileInstance = FrameworkFileOutputPointer::createFrameworkFileOutputPointer($fqfn, 'w'); + + // Serialize and compress it + $compressedData = $this->getCompressorChannel()->getCompressor()->compressStream(serialize($dataArray)); + + // Write this data BASE64 encoded to the file + $fileInstance->writeToFile(base64_encode($compressedData)); + + // Close the file pointer + $fileInstance->closeFile(); + } + + /** + * Getter for table information file contents or an empty if info file was not created + * + * @param $dataSetInstance An instance of a database set class + * @return $infoArray An array with all table informations + */ + private function getContentsFromTableInfoFile (StoreableCriteria $dataSetInstance) { + // Default content is no data + $infoArray = array(); + + // Create FQFN for getting the table information file + $fqfn = $this->getSavePath() . $dataSetInstance->getTableName() . '/info.' . $this->getFileExtension(); + + // Get the file contents + try { + $infoArray = $this->getDataArrayFromFile($fqfn); + } catch (FileNotFoundException $e) { + // Not found, so ignore it here + } + + // ... and return it + return $infoArray; + } + + /** + * Creates the table info file from given dataset instance + * + * @param $dataSetInstance An instance of a database set class + * @return void + */ + private function createTableInfoFile (StoreableCriteria $dataSetInstance) { + // Create FQFN for creating the table information file + $fqfn = $this->getSavePath() . $dataSetInstance->getTableName() . '/info.' . $this->getFileExtension(); + + // Get the data out from dataset in a local array + $this->tableInfo[$dataSetInstance->getTableName()] = array( + 'primary' => $dataSetInstance->getPrimaryKey(), + 'created' => time(), + 'last_updated' => time() + ); + + // Write the data to the file + $this->writeDataArrayToFqfn($fqfn, $this->tableInfo[$dataSetInstance->getTableName()]); + } + + /** + * Updates the primary key information or creates the table info file if not found + * + * @param $dataSetInstance An instance of a database set class + * @return void + */ + private function updatePrimaryKey (StoreableCriteria $dataSetInstance) { + // Get the information array from lower method + $infoArray = $this->getContentsFromTableInfoFile($dataSetInstance); + + // Is the primary key there? + if (!isset($this->tableInfo['primary'])) { + // Then create the info file + $this->createTableInfoFile($dataSetInstance); + } elseif (($this->getConfigInstance()->readConfig('db_update_primary_forced') === "Y") && ($dataSetInstance->getPrimaryKey() != $this->tableInfo['primary'])) { + // Set the array element + $this->tableInfo[$dataSetInstance->getTableName()]['primary'] = $dataSetInstance->getPrimaryKey(); + + // Update the entry + $this->updateTableInfoFile($dataSetInstance); + } + } + + /** + * Makes sure that the database connection is alive + * + * @return void + * @todo Do some checks on the database directory and files here + */ + public function connectToDatabase () { + } + + /** + * Starts a SELECT query on the database by given return type, table name + * and search criteria + * + * @param $resultType Result type ("array", "object" and "indexed" are valid) + * @param $tableName Name of the database table + * @param $criteria Local search criteria class + * @return $resultData Result data of the query + * @throws UnsupportedCriteriaException If the criteria is unsupported + * @throws SqlException If an "SQL error" occurs + */ + public function querySelect ($resultType, $tableName, LocalSearchCriteria $criteriaInstance) { + // The result is null by any errors + $resultData = null; + + // Create full path name + $pathName = $this->getSavePath() . $tableName . '/'; + + // A "select" query is not that easy on local files, so first try to + // find the "table" which is in fact a directory on the server + try { + // Get a directory pointer instance + $directoryInstance = FrameworkDirectoryPointer::createFrameworkDirectoryPointer($pathName); + + // Initialize the result data, this need to be rewritten e.g. if a local file cannot be read + $resultData = array( + 'status' => "ok", + 'rows' => array() + ); + + // Initialize limit/skip + $limitFound = 0; + $skipFound = 0; + $idx = 1; + + // Read the directory with some exceptions + while (($dataFile = $directoryInstance->readDirectoryExcept(array(".", "..", ".htaccess", ".svn", "info." . $this->getFileExtension()))) && ($limitFound < $criteriaInstance->getLimit())) { + // Does the extension match? + if (substr($dataFile, -(strlen($this->getFileExtension()))) !== $this->getFileExtension()) { + // Skip this file! + continue; + } // END - if + + // Read the file + $dataArray = $this->getDataArrayFromFile($pathName . $dataFile); + + // Is this an array? + if (is_array($dataArray)) { + // Search in the criteria with FMFW (First Matches, First Wins) + foreach ($dataArray as $key => $value) { + // Get criteria element + $criteria = $criteriaInstance->getCriteriaElemnent($key); + + // Is the criteria met? + if ((!is_null($criteria)) && ($criteria == $value)) { + + // Shall we skip this entry? + if ($criteriaInstance->getSkip() > 0) { + // We shall skip some entries + if ($skipFound < $criteriaInstance->getSkip()) { + // Skip this entry + $skipFound++; + break; + } // END - if + } // END - if + + // Set id number + $dataArray[$this->getIndexKey()] = $idx; + + // Entry found! + $resultData['rows'][] = $dataArray; + + // Count found entries up + $limitFound++; + break; + } // END - if + } // END - foreach + } else { + // Throw an exception here + throw new SqlException(array($this, sprintf("File '%s' contains invalid data.", $dataFile), self::DB_CODE_DATA_FILE_CORRUPT), self::EXCEPTION_SQL_QUERY); + } + + // Count entry up + $idx++; + } // END - while + + // Close directory and throw the instance away + $directoryInstance->closeDirectory(); + unset($directoryInstance); + + // Reset last error message and exception + $this->resetLastError(); + } catch (PathIsNoDirectoryException $e) { + // Path not found means "table not found" for real databases... + $this->lastException = $e; + $this->lastError = $e->getMessage(); + + // So throw an SqlException here with faked error message + throw new SqlException (array($this, sprintf("Table '%s' not found", $tableName), self::DB_CODE_TABLE_MISSING), self::EXCEPTION_SQL_QUERY); + } catch (FrameworkException $e) { + // Catch all exceptions and store them in last error + $this->lastException = $e; + $this->lastError = $e->getMessage(); + } + + // Return the gathered result + return $resultData; + } + + /** + * "Inserts" a data set instance into a local file database folder + * + * @param $dataSetInstance A storeable data set + * @return void + * @throws SqlException If an SQL error occurs + */ + public function queryInsertDataSet (StoreableCriteria $dataSetInstance) { + // Create full path name + $fqfn = sprintf("%s%s/%s.%s", + $this->getSavePath(), + $dataSetInstance->getTableName(), + md5($dataSetInstance->getUniqueValue()), + $this->getFileExtension() + ); + + // Try to save the request away + try { + // Write the data away + $this->writeDataArrayToFqfn($fqfn, $dataSetInstance->getCriteriaArray()); + + // Update the primary key + $this->updatePrimaryKey($dataSetInstance); + + // Reset last error message and exception + $this->resetLastError(); + } catch (FrameworkException $e) { + // Catch all exceptions and store them in last error + $this->lastException = $e; + $this->lastError = $e->getMessage(); + + // Throw an SQL exception + throw new SqlException (array($this, sprintf("Cannot write data to table '%s'", $tableName), self::DB_CODE_TABLE_UNWRITEABLE), self::EXCEPTION_SQL_QUERY); + } + } + + /** + * "Updates" a data set instance with a database layer + * + * @param $dataSetInstance A storeable data set + * @return void + * @throws SqlException If an SQL error occurs + */ + public function queryUpdateDataSet (StoreableCriteria $dataSetInstance) { + // Create full path name + $pathName = $this->getSavePath() . $dataSetInstance->getTableName() . '/'; + + // Try all the requests + try { + // Get a file pointer instance + $directoryInstance = FrameworkDirectoryPointer::createFrameworkDirectoryPointer($pathName); + + // Initialize limit/skip + $limitFound = 0; + $skipFound = 0; + + // Get the criteria array from the dataset + $criteriaArray = $dataSetInstance->getCriteriaArray(); + + // Get search criteria + $searchInstance = $dataSetInstance->getSearchInstance(); + + // Read the directory with some exceptions + while (($dataFile = $directoryInstance->readDirectoryExcept(array(".", "..", ".htaccess", ".svn", "info." . $this->getFileExtension()))) && ($limitFound < $searchInstance->getLimit())) { + // Does the extension match? + if (substr($dataFile, -(strlen($this->getFileExtension()))) !== $this->getFileExtension()) { + // Skip this file! + continue; + } + + // Open this file for reading + $dataArray = $this->getDataArrayFromFile($pathName . $dataFile); + + // Is this an array? + if (is_array($dataArray)) { + // Search in the criteria with FMFW (First Matches, First Wins) + foreach ($dataArray as $key => $value) { + // Get criteria element + $criteria = $searchInstance->getCriteriaElemnent($key); + + // Is the criteria met? + if ((!is_null($criteria)) && ($criteria == $value)) { + + // Shall we skip this entry? + if ($searchInstance->getSkip() > 0) { + // We shall skip some entries + if ($skipFound < $searchInstance->getSkip()) { + // Skip this entry + $skipFound++; + break; + } // END - if + } // END - if + + // Entry found, so update it + foreach ($criteriaArray as $criteriaKey => $criteriaValue) { + $dataArray[$criteriaKey] = $criteriaValue; + } // END - foreach + + // Write the data to a local file + $this->writeDataArrayToFqfn($pathName . $dataFile, $dataArray); + + // Count it + $limitFound++; + break; + } // END - if + } // END - foreach + } // END - if + } // END - while + + // Close the file pointer + $directoryInstance->closeDirectory(); + + // Update the primary key + $this->updatePrimaryKey($dataSetInstance); + + // Reset last error message and exception + $this->resetLastError(); + } catch (FrameworkException $e) { + // Catch all exceptions and store them in last error + $this->lastException = $e; + $this->lastError = $e->getMessage(); + + // Throw an SQL exception + throw new SqlException (array($this, sprintf("Cannot write data to table '%s'", $dataSetInstance->getTableName()), self::DB_CODE_TABLE_UNWRITEABLE), self::EXCEPTION_SQL_QUERY); + } + } + + /** + * Getter for primary key of specified table or if not found null will be + * returned. This must be database-specific. + * + * @param $tableName Name of the table we need the primary key from + * @return $primaryKey Primary key column of the given table + */ + public function getPrimaryKeyOfTable ($tableName) { + // Default key is null + $primaryKey = null; + + // Does the table information exist? + if (isset($this->tableInfo[$tableName])) { + // Then return the primary key + $primaryKey = $this->tableInfo[$tableName]['primary']; + } // END - if + + // Return the column + return $primaryKey; + } +} + +// [EOF] +?> diff --git a/inc/classes/main/database/wrapper/.htaccess b/inc/classes/main/database/wrapper/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/database/wrapper/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/database/wrapper/class_NewsDatabaseWrapper.php b/inc/classes/main/database/wrapper/class_NewsDatabaseWrapper.php new file mode 100644 index 00000000..9a87e6a7 --- /dev/null +++ b/inc/classes/main/database/wrapper/class_NewsDatabaseWrapper.php @@ -0,0 +1,56 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NewsDatabaseWrapper extends BaseDatabaseWrapper { + // Constants for database table names + const DB_TABLE_NEWS = "news"; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct() { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this database wrapper by a provided user class + * + * @return $wrapperInstance An instance of the created wrapper class + */ + public final static function createNewsDatabaseWrapper () { + // Get a new instance + $wrapperInstance = new NewsDatabaseWrapper(); + + // Set (primary!) table name + $wrapperInstance->setTableName(self::DB_TABLE_NEWS); + + // Return the instance + return $wrapperInstance; + } +} + +// [EOF] +?> diff --git a/inc/classes/main/database/wrapper/class_PaymentsDatabaseWrapper.php b/inc/classes/main/database/wrapper/class_PaymentsDatabaseWrapper.php new file mode 100644 index 00000000..52f36461 --- /dev/null +++ b/inc/classes/main/database/wrapper/class_PaymentsDatabaseWrapper.php @@ -0,0 +1,59 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class PaymentsDatabaseWrapper extends BaseDatabaseWrapper { + // Constants for exceptions + const EXCEPTION_CLIENT_USERNAME_NOT_FOUND = 0x180; + + // Constants for database table names + const DB_TABLE_PAYMENTS = "payments"; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct() { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this database wrapper by a provided user class + * + * @return $wrapperInstance An instance of the created wrapper class + */ + public final static function createPaymentsDatabaseWrapper () { + // Get a new instance + $wrapperInstance = new PaymentsDatabaseWrapper(); + + // Set (primary!) table name + $wrapperInstance->setTableName(self::DB_TABLE_PAYMENTS); + + // Return the instance + return $wrapperInstance; + } +} + +// [EOF] +?> diff --git a/inc/classes/main/database/wrapper/class_UserDatabaseWrapper.php b/inc/classes/main/database/wrapper/class_UserDatabaseWrapper.php new file mode 100644 index 00000000..503fbadb --- /dev/null +++ b/inc/classes/main/database/wrapper/class_UserDatabaseWrapper.php @@ -0,0 +1,118 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class UserDatabaseWrapper extends BaseDatabaseWrapper { + // Constants for exceptions + const EXCEPTION_CLIENT_USERNAME_NOT_FOUND = 0x180; + + // Constants for database columns + const DB_COLUMN_USERID = "userid"; + const DB_COLUMN_USERNAME = "username"; + const DB_COLUMN_EMAIL = "email"; + const DB_COLUMN_CONFIRM_HASH = "confirm_hash"; + const DB_COLUMN_USER_STATUS = "user_status"; + + // Constants for database table names + const DB_TABLE_USER = "user"; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct() { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this database wrapper by a provided user class + * + * @return $wrapperInstance An instance of the created wrapper class + */ + public final static function createUserDatabaseWrapper () { + // Get a new instance + $wrapperInstance = new UserDatabaseWrapper(); + + // Set (primary!) table name + $wrapperInstance->setTableName(self::DB_TABLE_USER); + + // Return the instance + return $wrapperInstance; + } + + /** + * Getter for index key + * + * @return $indexKey Index key + */ + public final function getIndexKey () { + return $this->getDatabaseInstance()->getIndexKey(); + } + + /** + * Handles inserting the registration data from a registration instance into the database + * + * @param $registrationInstance An instance of a registration class + * @return void + */ + public function insertRegistrationObject (UserRegister $registrationInstance) { + // Generate a data set for the request + $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_USER)); + + // Set the primary key + $dataSetInstance->setUniqueKey('username'); + + // Add registration elements to the dataset + $registrationInstance->addElementsToDataSet($dataSetInstance); + + // "Insert" this request instance completely into the database + $this->getDatabaseInstance()->queryInsertDataSet($dataSetInstance); + } + + /** + * Updates an user database entry with given result + * + * @param $resultInstance An instance of a Updateable database result + * @return void + */ + public function doUpdateByResult (UpdateableResult $resultInstance) { + // Generate a data set object + $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_USER)); + + // Add all update criteria to the database set + $resultInstance->addElementsToDataSet($dataSetInstance); + + // Add seach criteria + $dataSetInstance->setSearchInstance($resultInstance->getSearchInstance()); + + // Set the primary key + $dataSetInstance->setUniqueKey('username'); + + // "Update" this request with the database + $this->getDatabaseInstance()->queryUpdateDataSet($dataSetInstance); + } +} + +// [EOF] +?> diff --git a/inc/classes/main/database/wrapper/class_UserPointsDatabaseWrapper.php b/inc/classes/main/database/wrapper/class_UserPointsDatabaseWrapper.php new file mode 100644 index 00000000..0a8af18e --- /dev/null +++ b/inc/classes/main/database/wrapper/class_UserPointsDatabaseWrapper.php @@ -0,0 +1,56 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class UserPointsDatabaseWrapper extends BaseDatabaseWrapper { + // Constants for database table names + const DB_TABLE_USER_POINTS = "user_points"; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct() { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this database wrapper by a provided user class + * + * @return $wrapperInstance An instance of the created wrapper class + */ + public final static function createUserPointsDatabaseWrapper () { + // Get a new instance + $wrapperInstance = new UserPointsDatabaseWrapper(); + + // Set (primary!) table name + $wrapperInstance->setTableName(self::DB_TABLE_USER_POINTS); + + // Return the instance + return $wrapperInstance; + } +} + +// [EOF] +?> diff --git a/inc/classes/main/debug/.htaccess b/inc/classes/main/debug/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/debug/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/debug/class_DebugConsoleOutput.php b/inc/classes/main/debug/class_DebugConsoleOutput.php new file mode 100644 index 00000000..08e6d426 --- /dev/null +++ b/inc/classes/main/debug/class_DebugConsoleOutput.php @@ -0,0 +1,84 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class DebugConsoleOutput extends BaseFrameworkSystem implements Debugger, OutputStreamer, Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $debugInstance The prepared debug instance + */ + public final static function createDebugConsoleOutput () { + // Get a new instance + $debugInstance = new DebugConsoleOutput(); + + // Return it + return $debugInstance; + } + + /** + * Outputs the given data without HTML tags + * + * @param $output The HTML'ed output + * @return void + */ + public final function outputStream ($output) { + print(html_entity_decode(strip_tags(stripslashes($output)))); + } + + /** + * Assigns a variable for output + * + * @param $var The variable we shall assign + * @param $value The value to store in the variable + * @return void + */ + public final function assignVariable ($var, $value) { + // Empty stub! + trigger_error(__METHOD__.": Stub!"); + } + + /** + * Output the code + * + * @return void + */ + public final function output ($outStream=false) { + // Empty output will be silently ignored + if ($outStream !== false) { + $this->outputStream($outStream); + } + } +} + +// [EOF] +?> diff --git a/inc/classes/main/debug/class_DebugErrorLogOutput.php b/inc/classes/main/debug/class_DebugErrorLogOutput.php new file mode 100644 index 00000000..0d30d4f5 --- /dev/null +++ b/inc/classes/main/debug/class_DebugErrorLogOutput.php @@ -0,0 +1,93 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class DebugErrorLogOutput extends BaseFrameworkSystem implements Debugger, OutputStreamer { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $debugInstance The prepared debug instance + */ + public final static function createDebugErrorLogOutput () { + // Get a new instance + $debugInstance = new DebugErrorLogOutput(); + + // Return it + return $debugInstance; + } + + /** + * Outputs the given data without HTML tags + * + * @param $output The HTML'ed output + * @return void + */ + public final function outputStream ($output) { + // Split multiple lines into and array to put them out line-by-line + $errorLines = explode("\n", $output); + foreach ($errorLines as $err) { + $err = trim($err); + // Log only none-empty lines + if (!empty($err)) { + // Log this line + error_log(html_entity_decode(strip_tags($err)), 0); + } + } + } + + /** + * Assigns a variable for output + * + * @param $var The variable we shall assign + * @param $value The value to store in the variable + * @return void + */ + public final function assignVariable ($var, $value) { + // Empty stub! + trigger_error(__METHOD__.": Stub!"); + } + + /** + * Output the code + * + * @return void + */ + public final function output ($outStream=false) { + // Empty output will be silently ignored + if ($outStream !== false) { + $this->outputStream($outStream); + } + } +} + +// [EOF] +?> diff --git a/inc/classes/main/debug/class_DebugWebOutput.php b/inc/classes/main/debug/class_DebugWebOutput.php new file mode 100644 index 00000000..433f68e8 --- /dev/null +++ b/inc/classes/main/debug/class_DebugWebOutput.php @@ -0,0 +1,86 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class DebugWebOutput extends BaseFrameworkSystem implements Debugger, OutputStreamer { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $debugInstance The prepared debug instance + */ + public final static function createDebugWebOutput () { + // Get a new instance + $debugInstance = new DebugWebOutput(); + + // Return it + return $debugInstance; + } + + /** + * Outputs the given data directly + * + * @param $output The HTML output + * @return void + */ + public final function outputStream ($output) { + // Strip out
+ $output = str_replace("
", "", $output); + print(stripslashes($output)."
\n"); + } + + /** + * Assigns a variable for output + * + * @param $var The variable we shall assign + * @param $value The value to store in the variable + * @return void + */ + public final function assignVariable ($var, $value) { + // Empty stub! + trigger_error(__METHOD__.": Stub!"); + } + + /** + * Output the code + * + * @return void + */ + public final function output ($outStream=false) { + // Empty output will be silently ignored + if ($outStream !== false) { + $this->outputStream($outStream); + } + } +} + +// [EOF] +?> diff --git a/inc/classes/main/discovery/.htaccess b/inc/classes/main/discovery/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/discovery/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/discovery/class_ b/inc/classes/main/discovery/class_ new file mode 100644 index 00000000..890d6502 --- /dev/null +++ b/inc/classes/main/discovery/class_ @@ -0,0 +1,78 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ???Discovery extends BaseDiscovery implements Discoverable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Clean up a little + $this->removeNumberFormaters(); + $this->removeSystemArray(); + } + + /** + * Create an instance of this class + * + * @return $discoveryInstance An instance of this discovery class + */ + public final static function create???Discovery () { + // Get an instance of this class + $discoveryInstance = new ???Discovery(); + + // Return the prepared instance + return $discoveryInstance; + } + + /** + * Discovers the request + * + * @param $requestInstance An instance of a Requestable class + * @return void + * @todo 0% done + */ + public function discover (Requestable $requestInstance) { + $this->partialStub("Please implement this method."); + } + + /** + * Adds the database result in a human-readable format to the helper class + * + * @param $helperInstance An instance of a helper class + * @return void + * @todo 0% done + */ + public function addResultsToHelper (HelpableTemplate $helperInstance) { + $this->partialStub("Please implement this method."); + } +} + +// [EOF] +?> diff --git a/inc/classes/main/discovery/class_BaseDiscovery.php b/inc/classes/main/discovery/class_BaseDiscovery.php new file mode 100644 index 00000000..48164e14 --- /dev/null +++ b/inc/classes/main/discovery/class_BaseDiscovery.php @@ -0,0 +1,66 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseDiscovery extends BaseFrameworkSystem { + /** + * Action name for payment discovery + */ + private $actionName = ""; + + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + + // Clean up a little + $this->removeNumberFormaters(); + $this->removeSystemArray(); + } + + /** + * Protected setter for action name + * + * @param $actionName Action name to set + * @return void + */ + protected final function setActionName ($actionName) { + $this->actionName = (string) $actionName; + } + + /** + * Private getter for action name + * + * @return $actionName Action name to set + */ + protected final function getActionName () { + return $this->actionName; + } +} + +// [EOF] +?> diff --git a/inc/classes/main/discovery/payment/.htaccess b/inc/classes/main/discovery/payment/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/discovery/payment/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/discovery/payment/class_LocalPaymentDiscovery.php b/inc/classes/main/discovery/payment/class_LocalPaymentDiscovery.php new file mode 100644 index 00000000..129dd3b1 --- /dev/null +++ b/inc/classes/main/discovery/payment/class_LocalPaymentDiscovery.php @@ -0,0 +1,94 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class LocalPaymentDiscovery extends BaseDiscovery implements Discoverable, Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Clean up a little + $this->removeNumberFormaters(); + $this->removeSystemArray(); + } + + /** + * Create an instance of this class + * + * @param $filterInstance An instance of a filter + * @return $discoveryInstance An instance of this discovery class + */ + public final static function createLocalPaymentDiscovery (Filterable $filterInstance) { + // Get an instance of this class + $discoveryInstance = new LocalPaymentDiscovery(); + + // Set the action from filter + $discoveryInstance->setActionName($filterInstance->getActionName()); + + // Return the prepared instance + return $discoveryInstance; + } + + /** + * Discovers the request + * + * @param $requestInstance An instance of a Requestable class + * @return void + */ + public function discover (Requestable $requestInstance) { + // Now get a search criteria and set app name and payment action as search critera + $criteriaInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class'); + $criteriaInstance->addCriteria("app_name", $requestInstance->getRequestElement('app')); + $criteriaInstance->addCriteria("payment_action", $this->getActionName().'_action'); + $criteriaInstance->setLimit(1); + + // Get a wrapper instance + $wrapperInstance = ObjectFactory::createObjectByConfiguredName('payment_db_wrapper_class'); + + // Get result back + $resultInstance = $wrapperInstance->doSelectByCriteria($criteriaInstance); + + // Set the result instance + $this->setResultInstance($resultInstance); + } + + /** + * Adds the database result in a human-readable format to the helper class + * + * @param $helperInstance An instance of a helper class + * @return void + * @todo 0% done + */ + public function addResultsToHelper (HelpableTemplate $helperInstance) { + // Undone part + } +} + +// [EOF] +?> diff --git a/inc/classes/main/factories/.htaccess b/inc/classes/main/factories/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/factories/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/factories/cache/.htaccess b/inc/classes/main/factories/cache/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/factories/cache/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/factories/cache/class_CacheFactory.php b/inc/classes/main/factories/cache/class_CacheFactory.php new file mode 100644 index 00000000..2938b874 --- /dev/null +++ b/inc/classes/main/factories/cache/class_CacheFactory.php @@ -0,0 +1,74 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class CacheFactory extends BaseFactory { + /** + * Singleton instance + */ + private static $selfInstance = null; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Singleton getter for this class + * + * @return $selfInstance An instance of this class + */ + public final static function getFactory () { + // Is the instance null? + if (is_null(self::$selfInstance)) { + // Set a new one + self::$selfInstance = new CacheFactory(); + } + + // Return the instance + return self::$selfInstance; + } + + /** + * Creates a configured cache instance + * + * @return $cacheInstance An instance of the configured cache + */ + public function createConfiguredCache () { + // Read the config entry + $cacheType = $this->getConfigInstance()->readConfig('cache_class'); + + // And get a new instance + $cacheInstance = ObjectFactory::createObjectByName($cacheType); + + // Return the instance + return $cacheInstance; + } +} + +// [EOF] +?> diff --git a/inc/classes/main/factories/class_BaseFactory.php b/inc/classes/main/factories/class_BaseFactory.php new file mode 100644 index 00000000..3fd5510c --- /dev/null +++ b/inc/classes/main/factories/class_BaseFactory.php @@ -0,0 +1,66 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseFactory extends BaseFrameworkSystem { + /** + * An instance of the real factory class + */ + private $realFactoryInstance = null; + + /** + * Protected constructor + * + * @param $className Name of the real class (not BaseFactory) + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + + // Clean up a little + $this->removeNumberFormaters(); + $this->removeSystemArray(); + } + + /** + * Setter for the *real* factory instance + * + * @param $realFactoryInstance An instance of the real factory class + * @return void + */ + public final function setRealFactoryInstance (BaseFrameworkSystem $realFactoryInstance) { + $this->realFactoryInstance = $realFactoryInstance; + } + + /** + * Getter for the *real* factory instance + * + * @return $realFactoryInstance An instance of the real factory class + */ + protected final function getRealFactoryInstance () { + return $this->realFactoryInstance; + } +} + +// [EOF] +?> diff --git a/inc/classes/main/factories/objects/.htaccess b/inc/classes/main/factories/objects/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/factories/objects/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/factories/objects/class_ObjectFactory.php b/inc/classes/main/factories/objects/class_ObjectFactory.php new file mode 100644 index 00000000..0848e79f --- /dev/null +++ b/inc/classes/main/factories/objects/class_ObjectFactory.php @@ -0,0 +1,111 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ObjectFactory extends BaseFactory { + /** + * Total objects generated + */ + private static $total = 0; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates a new object given by the name or throws an exception if + * the class was not found. No parameters for the object are currently + * supported. + * + * @param $className Name of the class we shall construct + * @param $args Arguments in an indexed array + * @return $objectInstance An instance of the requested object + * @throws ClassNotFoundException If the requested class was not found + * @throws EmptyVariableException If a variable is empty unexpectly + */ + public final static function createObjectByName ($className, array $args=array()) { + // Is the class name valid and is the class there? + if (empty($className)) { + // First get an instance of this factory + $factoryInstance = new ObjectFactory(); + + // Throw an exception here + throw new EmptyVariableException(array($factoryInstance, 'className'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); + } elseif (!class_exists($className)) { + // First get an instance of this factory + $factoryInstance = new ObjectFactory(); + + // Then throw an exception + throw new ClassNotFoundException(array($factoryInstance, $className), self::EXCEPTION_CLASS_NOT_FOUND); + } + + // Create method name + $methodName = sprintf("create%s", + $className + ); + + // Run the user function + $objectInstance = call_user_func_array(array($className, $methodName), $args); + + // Count generated objects up + self::$total++; + + // Return the prepared instance + return $objectInstance; + } + + /** + * Creates an object by it's configured name + * + * @param $configEnttry Configuration entry to read + * @param $args Arguments in an indexed array + * @return $objectInstance An instance of the requested object + */ + public final static function createObjectByConfiguredName ($configEntry, array $args=array()) { + // Read the configuration entry + $className = FrameworkConfiguration::getInstance()->readConfig($configEntry); + + // Send this to the other factory... + $objectInstance = self::createObjectByName($className, $args); + + // Return the instance + return $objectInstance; + } + + /** + * Static getter for total object count + * + * @return $total Total amount of generated objects + */ + public final static function getTotal () { + return self::$total; + } +} + +// [EOF] +?> diff --git a/inc/classes/main/factories/web/.htaccess b/inc/classes/main/factories/web/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/factories/web/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/factories/web/class_WebNewsFactory.php b/inc/classes/main/factories/web/class_WebNewsFactory.php new file mode 100644 index 00000000..1dace4e9 --- /dev/null +++ b/inc/classes/main/factories/web/class_WebNewsFactory.php @@ -0,0 +1,84 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class WebNewsFactory extends BaseFactory { + /** + * Instance of a request class + */ + private $requestInstance = null; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Singleton getter for a special factory instance depending on the given + * request + * + * @param $requestInstance An instance of a request class + * @return $factoryInstance An instance of a WebNewsFactory class + */ + public final static function createFactoryByRequest (Requestable $requestInstance) { + // Set default news reader class + $configEntry = "news_reader_class"; + + // Get "page" + $page = $requestInstance->getRequestElement('page'); + + // Is "page" used? + if (!empty($page)) { + // Then add it + $configEntry = sprintf("news_reader_%s_class", $page); + + // Get "action" + $action = $requestInstance->getRequestElement('action'); + + // Is it also there? + if (!empty($action)) { + // Then use both for config entry + $configEntry = sprintf("news_reader_%s_%s_class", $page, $action); + } // END - if + } // END - if + + // Get the news reader class name from config + $className = $requestInstance->getConfigInstance()->readConfig($configEntry); + + // Once we have that name, try to load initialize it + $newsInstance = ObjectFactory::createObjectByName($className, array($requestInstance)); + + // Initialize the reader + $newsInstance->initializeReader(); + + // Return the prepared factory instance + return $newsInstance; + } +} + +// [EOF] +?> diff --git a/inc/classes/main/filter/.htaccess b/inc/classes/main/filter/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/filter/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/filter/auth/.htaccess b/inc/classes/main/filter/auth/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/filter/auth/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/filter/auth/class_UserAuthFilter.php b/inc/classes/main/filter/auth/class_UserAuthFilter.php new file mode 100644 index 00000000..c2b0ac42 --- /dev/null +++ b/inc/classes/main/filter/auth/class_UserAuthFilter.php @@ -0,0 +1,141 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class UserAuthFilter extends BaseFilter implements Filterable { + // Exception constants + const EXCEPTION_AUTH_DATA_INVALID = 0x1b0; + + /** + * The login method we shall choose + */ + private $authMethod = ""; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @param $controllerInstance An instance of a Controller class + * @return $filterInstance An instance of this filter class + */ + public final static function createUserAuthFilter (Controller $controllerInstance) { + // Get a new instance + $filterInstance = new UserAuthFilter(); + + // Set the controller + $filterInstance->setControllerInstance($controllerInstance); + + // Set default auth method + $filterInstance->setDefaultAuthMethod(); + + // Return the instance + return $filterInstance; + } + + /** + * Setter for default login method from config + * + * @return void + */ + protected function setDefaultAuthMethod () { + $this->authMethod = $this->getConfigInstance()->readConfig('auth_method_class'); + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @throws UserAuthorizationException If the auth login was not found or if it was invalid + * @throws UserPasswordMismatchException If the supplied password hash does not match + * @throws ClassNotFoundException If the user (guest/member) class was not found + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Then get an auth instance for checking and updating the auth cookies + $authInstance = ObjectFactory::createObjectByName($this->authMethod, array($responseInstance)); + + // Set request instance + $authInstance->setRequestInstance($requestInstance); + + // Now, get the auth data for comparison + $authLogin = $authInstance->getUserAuth(); + $authHash = $authInstance->getPasswordAuth(); + + // If one is empty stop here + if ((empty($authLogin)) || (empty($authHash))) { + // Destroy the auth data + $authInstance->destroyAuthData(); + + // Mark the request as invalid + $requestInstance->requestIsValid(false); + + // Add fatal message + $responseInstance->addFatalMessage('auth_data_incomplete'); + + // Stop here + throw new UserAuthorizationException($this, self::EXCEPTION_AUTH_DATA_INVALID); + } // END - if + + // Regular user account + $className = $this->getConfigInstance()->readConfig('user_class'); + $methodName = 'createMemberByUserName'; + + // Now, try to get a user or guest instance + if ($authLogin == $this->getConfigInstance()->readConfig('guest_login_user')) { + // Set class + $className = $this->getConfigInstance()->readConfig('guest_class'); + $methodName = 'createGuestByUserName'; + } // END - if + + // Does the guest class exist? + if (!class_exists($className)) { + // Then abort here + throw new ClassNotFoundException (array($this, $className), self::EXCEPTION_CLASS_NOT_FOUND); + } // END - if + + // Now try the dynamic login + $userInstance = call_user_func_array(array($className, $methodName), array($authLogin)); + + // Is the password correct? + if ($userInstance->getPasswordHash() !== $authHash) { + // Mismatching password + throw new UserPasswordMismatchException(array($this, $userInstance), BaseUser::EXCEPTION_USER_PASS_MISMATCH); + } // END - if + + // Remember auth and user instances in registry + Registry::getRegistry()->addInstance('auth', $authInstance); + Registry::getRegistry()->addInstance('user', $userInstance); + } +} + +// [EOF] +?> diff --git a/inc/classes/main/filter/change/.htaccess b/inc/classes/main/filter/change/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/filter/change/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/filter/change/class_EmailChangeFilter.php b/inc/classes/main/filter/change/class_EmailChangeFilter.php new file mode 100644 index 00000000..bc481dd7 --- /dev/null +++ b/inc/classes/main/filter/change/class_EmailChangeFilter.php @@ -0,0 +1,125 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class EmailChangeFilter extends BaseFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @param $controllerInstance An instance of a Controller class + * @return $filterInstance An instance of this filter class + */ + public final static function createEmailChangeFilter (Controller $controllerInstance) { + // Get a new instance + $filterInstance = new EmailChangeFilter(); + + // Set the controller + $filterInstance->setControllerInstance($controllerInstance); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @todo Implement email change of the user here. HINT: Use the User class! + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get both emails + $email1 = $requestInstance->getRequestElement('email1'); + $email2 = $requestInstance->getRequestElement('email2'); + + // Is only first email set? + if ((!empty($email1)) && (empty($email2))) { + // Request is invalid! + $requestInstance->requestIsValid(false); + + // Email 2 is empty + $responseInstance->addFatalMessage('email2_empty'); + + // Stop processing here + return false; + } // END - if + + // Is only second email set? + if ((empty($email1)) && (!empty($email2))) { + // Request is invalid! + $requestInstance->requestIsValid(false); + + // Email 1 is empty + $responseInstance->addFatalMessage('email1_empty'); + + // Stop processing here + return false; + } // END - if + + // Do both match? + if ($email1 != $email2) { + // Request is invalid! + $requestInstance->requestIsValid(false); + + // Emails are mismatching + $responseInstance->addFatalMessage('emails_mismatch'); + + // Stop processing here + return false; + } // END - if + + // Are email and confirmation empty? + if ((empty($email1)) && (empty($email2))) { + // No email change required! + return true; + } // END - if + + // Now, get a user instance for comparison + $userInstance = Registry::getRegistry()->getInstance('user'); + + // Get the email field + $userEmail = $userInstance->getField('email'); + + // Are they different? + if ($userEmail == $email1) { + // Nothing has been changed is fine... + return true; + } // END - if + + // Update the "new_email" field + $this->partialStub("Unfinished part."); + } +} + +// [EOF] +?> diff --git a/inc/classes/main/filter/change/class_PasswordChangeFilter.php b/inc/classes/main/filter/change/class_PasswordChangeFilter.php new file mode 100644 index 00000000..e7b8b505 --- /dev/null +++ b/inc/classes/main/filter/change/class_PasswordChangeFilter.php @@ -0,0 +1,116 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class PasswordChangeFilter extends BaseFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @param $controllerInstance An instance of a controller class + * @return $filterInstance An instance of this filter class + */ + public final static function createPasswordChangeFilter (Controller $controllerInstance) { + // Get a new instance + $filterInstance = new PasswordChangeFilter(); + + // Set the controller + $filterInstance->setControllerInstance($controllerInstance); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @todo Finished updating user password hash here. HINT: Use the User class again. + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get both passwords + $pass1 = $requestInstance->getRequestElement('pass1'); + $pass2 = $requestInstance->getRequestElement('pass2'); + + // Is only first email set? + if ((!empty($pass1)) && (empty($pass2))) { + // Request is invalid! + $requestInstance->requestIsValid(false); + + // Email 2 is empty + $responseInstance->addFatalMessage('pass2_empty'); + + // Stop processing here + return false; + } // END - if + + // Is only second pass set? + if ((empty($pass1)) && (!empty($pass2))) { + // Request is invalid! + $requestInstance->requestIsValid(false); + + // Email 1 is empty + $responseInstance->addFatalMessage('pass1_empty'); + + // Stop processing here + return false; + } // END - if + + // Are password and confirmation empty? + if ((empty($pass1)) && (empty($pass2))) { + // Don't change password here + return true; + } // END - if + + // Do both match? + if ($pass1 != $pass2) { + // Request is invalid! + $requestInstance->requestIsValid(false); + + // Emails are mismatching + $responseInstance->addFatalMessage('pass_mismatch'); + + // Stop processing here + return false; + } // END - if + + // Now, get a user instance for comparison + $userInstance = Registry::getRegistry()->getInstance('user'); + + // Update the "password" field + $this->partialStub("Unfinished part."); + } +} + +// [EOF] +?> diff --git a/inc/classes/main/filter/checkboxes/.htaccess b/inc/classes/main/filter/checkboxes/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/filter/checkboxes/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/filter/checkboxes/class_RulesAcceptedFilter.php b/inc/classes/main/filter/checkboxes/class_RulesAcceptedFilter.php new file mode 100644 index 00000000..03b769a2 --- /dev/null +++ b/inc/classes/main/filter/checkboxes/class_RulesAcceptedFilter.php @@ -0,0 +1,80 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class RulesAcceptedFilter extends BaseFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @param $controllerInstance An instance of a Controller class + * @return $filterInstance An instance of this filter class + */ + public final static function createRulesAcceptedFilter (Controller $controllerInstance) { + // Get a new instance + $filterInstance = new RulesAcceptedFilter(); + + // Set the controller + $filterInstance->setControllerInstance($controllerInstance); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get the "rules" value from request + $rules = $requestInstance->getRequestElement('rules'); + + // Was the "rules" value found in form? And is it set? + if (is_null($rules)) { + // Not found in form so stop processing here + $requestInstance->requestIsValid(false); + + // Add a message to the response + $responseInstance->addFatalMessage('rules_unchecked'); + + // Skip further processing + return false; + } + } +} + +// [EOF] +?> diff --git a/inc/classes/main/filter/class_ b/inc/classes/main/filter/class_ new file mode 100644 index 00000000..bd14a20d --- /dev/null +++ b/inc/classes/main/filter/class_ @@ -0,0 +1,67 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ???Filter extends BaseFrameworkSystem implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @param $controllerInstance An instance of a Controller class + * @return $filterInstance An instance of this filter class + */ + public final static function create???Filter (Controller $controllerInstance) { + // Get a new instance + $filterInstance = new ???Filter(); + + // Set the controller + $filterInstance->setControllerInstance($controllerInstance); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @todo 0% done + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Implement this! + $this->partialStub("Please implement this method."); + } +} + +// [EOF] +?> diff --git a/inc/classes/main/filter/class_AbstractFilterDecorator.php b/inc/classes/main/filter/class_AbstractFilterDecorator.php new file mode 100644 index 00000000..e003ce26 --- /dev/null +++ b/inc/classes/main/filter/class_AbstractFilterDecorator.php @@ -0,0 +1,87 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +abstract class AbstractFilterDecorator extends BaseFrameworkSystem implements Filterable { + /** + * The decorated filter instance + */ + private $filterInstance = null; + + /** + * Protected constructor + * + * @param $className Name of the real class' name + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + + // Clean up a little + $this->removeNumberFormaters(); + $this->removeSystemArray(); + } + + /** + * Setter for the decorated filter instance + * + * @param $filterInstance An instance of a filter + * @return void + */ + protected final function setFilterInstance (Filterable $filterInstance) { + $this->filterInstance = $filterInstance; + } + + /** + * Getter for the decorated filter instance + * + * @return $filterInstance An instance of a filter + */ + protected final function getFilterInstance () { + return $this->filterInstance; + } + + /** + * Execute the inner filter + * + * @param $requestInstance An instance of a request class + * @param $responseInstance An instance of a response class + * @return void + */ + public final function execute (Requestable $requestInstance, Responseable $responseInstance) { + $this->getFilterInstance()->execute($requestInstance, $responseInstance); + } + + + /** + * Do the execution of the filter + * + * @param $requestInstance An instance of a request class + * @param $responseInstance An instance of a response class + * @return void + */ + abstract public function doExecute (Requestable $requestInstance, Responseable $responseInstance); +} + +// [EOF] +?> diff --git a/inc/classes/main/filter/class_BaseFilter.php b/inc/classes/main/filter/class_BaseFilter.php new file mode 100644 index 00000000..0f3a4781 --- /dev/null +++ b/inc/classes/main/filter/class_BaseFilter.php @@ -0,0 +1,45 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseFilter extends BaseFrameworkSystem { + // Exception constants + const EXCEPTION_FILTER_CHAIN_ABORTED = 0x1a0; + + /** + * Protected constructor + * + * @param $className Name of the filter class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + + // Clean up a little + $this->removeNumberFormaters(); + $this->removeSystemArray(); + } +} + +// [EOF] +?> diff --git a/inc/classes/main/filter/class_FilterChain.php b/inc/classes/main/filter/class_FilterChain.php new file mode 100644 index 00000000..b3825dab --- /dev/null +++ b/inc/classes/main/filter/class_FilterChain.php @@ -0,0 +1,92 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class FilterChain extends BaseFrameworkSystem { + /** + * All filters together + */ + private $filters = array(); + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Clean up a little + $this->removeNumberFormaters(); + $this->removeSystemArray(); + } + + /** + * Creates an instance of this class + * + * @return $chainInstance An instance of this class + */ + public final static function createFilterChain () { + // Get a new instance + $chainInstance = new FilterChain(); + + // Return the prepared instance + return $chainInstance; + } + + /** + * Add a new filter + * + * @param $filerInstance An instance of a filter class + * @return void + */ + public final function addFilter (Filterable $filterInstance) { + $this->filters[] = $filterInstance; + } + + /** + * Process all added filters + * + * @param $requestInstance An instance of a request class + * @param $responseInstance An instance of a response class + * @return void + */ + public function processFilters (Requestable $requestInstance, Responseable $responseInstance) { + // Run all filters + //* DEBUG */ echo "COUNT=".count($this->filters)."
\n"; + foreach ($this->filters as $filterInstance) { + // Try to execute this filter + try { + //* DEBUG */ echo "FILTER: ".$filterInstance->__toString().": Processing started.
\n"; + $filterInstance->execute($requestInstance, $responseInstance); + //* DEBUG */ echo "FILTER: ".$filterInstance->__toString().": Processing ended.
\n"; + } catch (FilterChainException $e) { + // This exception can be thrown to just skip any further processing + break; + } + } // END - foreach + } +} + +// [EOF] +?> diff --git a/inc/classes/main/filter/crypto/.htaccess b/inc/classes/main/filter/crypto/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/filter/crypto/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/filter/crypto/class_CaptchaEncryptFilter.php b/inc/classes/main/filter/crypto/class_CaptchaEncryptFilter.php new file mode 100644 index 00000000..3a20eb29 --- /dev/null +++ b/inc/classes/main/filter/crypto/class_CaptchaEncryptFilter.php @@ -0,0 +1,94 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class CaptchaEncryptFilter extends BaseFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @param $controllerInstance An instance of a Controller class + * @return $filterInstance An instance of this filter class + */ + public final static function createCaptchaEncryptFilter (Controller $controllerInstance) { + // Get a new instance + $filterInstance = new CaptchaEncryptFilter(); + + // Set the controller + $filterInstance->setControllerInstance($controllerInstance); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @throws EncryptMissingException If the "encrypt" value is not set + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get "encrypt" string barely from the request + $encryptRequest = $requestInstance->getRequestElement('encrypt'); + + // Is it there? + if (is_null($encryptRequest)) { + // Not found, so request is invalid + $requestInstance->requestIsValid(false); + + // Throw exception + throw new EncryptMissingException($this, CryptoHelper::EXCEPTION_ENCRYPT_MISSING); + } // END - if + + // Decode it fully + $encryptDecoded = base64_decode(str_replace(" ", "+", urldecode($encryptRequest))); + + // Get a crypto helper and decrypt the string + $decryptedString = ObjectFactory::createObjectByConfiguredName('crypto_class')->decryptString($encryptDecoded); + + // Is it the expected length? + if (strlen($decryptedString) != $this->getConfigInstance()->readConfig('captcha_string_length')) { + // Not found, so request is invalid + $requestInstance->requestIsValid(false); + + // Throw exception + throw new EncryptInvalidLengthException($this, CryptoHelper::EXCEPTION_ENCRYPT_INVALID); + } // END - if + + // Write it to the request + $requestInstance->setRequestElement('decrypted', $decryptedString); + } +} + +// [EOF] +?> diff --git a/inc/classes/main/filter/decorator/.htaccess b/inc/classes/main/filter/decorator/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/filter/decorator/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/filter/guest/.htaccess b/inc/classes/main/filter/guest/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/filter/guest/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/filter/guest/class_UserNameIsGuestFilter.php b/inc/classes/main/filter/guest/class_UserNameIsGuestFilter.php new file mode 100644 index 00000000..20155ac3 --- /dev/null +++ b/inc/classes/main/filter/guest/class_UserNameIsGuestFilter.php @@ -0,0 +1,74 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class UserNameIsGuestFilter extends BaseFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @param $controllerInstance An instance of a Controller class + * @return $filterInstance An instance of this filter class + */ + public final static function createUserNameIsGuestFilter (Controller $controllerInstance) { + // Get a new instance + $filterInstance = new UserNameIsGuestFilter(); + + // Set the controller + $filterInstance->setControllerInstance($controllerInstance); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get username from request + $userName = $requestInstance->getRequestElement('username'); + + // Does the user name match the guest login? + if ($userName == $this->getConfigInstance()->readConfig('guest_login_user')) { + // Then set the password to the configured password + $requestInstance->setRequestElement('pass1', $this->getConfigInstance()->readConfig('guest_login_passwd')); + $requestInstance->setRequestElement('pass2', $this->getConfigInstance()->readConfig('guest_login_passwd')); + } // END - if + } +} + +// [EOF] +?> diff --git a/inc/classes/main/filter/news/.htaccess b/inc/classes/main/filter/news/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/filter/news/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/filter/news/class_NewsDownloadFilter.php b/inc/classes/main/filter/news/class_NewsDownloadFilter.php new file mode 100644 index 00000000..8799398e --- /dev/null +++ b/inc/classes/main/filter/news/class_NewsDownloadFilter.php @@ -0,0 +1,71 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NewsDownloadFilter extends BaseFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @param $controllerInstance An instance of a Controller class + * @return $filterInstance An instance of this filter class + */ + public final static function createNewsDownloadFilter (Controller $controllerInstance) { + // Get a new instance + $filterInstance = new NewsDownloadFilter(); + + // Set the controller + $filterInstance->setControllerInstance($controllerInstance); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get a news instance + $newsInstance = WebNewsFactory::createFactoryByRequest($requestInstance); + + // Store the news instance in registry + Registry::getRegistry()->addInstance('news', $newsInstance); + } +} + +// [EOF] +?> diff --git a/inc/classes/main/filter/news/class_NewsProcessFilter.php b/inc/classes/main/filter/news/class_NewsProcessFilter.php new file mode 100644 index 00000000..5ecb0960 --- /dev/null +++ b/inc/classes/main/filter/news/class_NewsProcessFilter.php @@ -0,0 +1,66 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NewsProcessFilter extends BaseFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @param $controllerInstance An instance of a Controller class + * @return $filterInstance An instance of this filter class + */ + public final static function createNewsProcessFilter (Controller $controllerInstance) { + // Get a new instance + $filterInstance = new NewsProcessFilter(); + + // Set the controller + $filterInstance->setControllerInstance($controllerInstance); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @todo Unfinished stub, add functionality here + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + } +} + +// [EOF] +?> diff --git a/inc/classes/main/filter/null/.htaccess b/inc/classes/main/filter/null/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/filter/null/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/filter/null/class_NullFilter.php b/inc/classes/main/filter/null/class_NullFilter.php new file mode 100644 index 00000000..3dd83829 --- /dev/null +++ b/inc/classes/main/filter/null/class_NullFilter.php @@ -0,0 +1,66 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NullFilter extends BaseFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @param $controllerInstance An instance of a Controller class + * @return $filterInstance An instance of this filter class + */ + public final static function createNullFilter (Controller $controllerInstance) { + // Get a new instance + $filterInstance = new NullFilter(); + + // Set the controller + $filterInstance->setControllerInstance($controllerInstance); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Not implemented, just passing through + } +} + +// [EOF] +?> diff --git a/inc/classes/main/filter/payment/.htaccess b/inc/classes/main/filter/payment/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/filter/payment/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/filter/payment/class_PaymentDiscoveryFilter.php b/inc/classes/main/filter/payment/class_PaymentDiscoveryFilter.php new file mode 100644 index 00000000..38fb46e1 --- /dev/null +++ b/inc/classes/main/filter/payment/class_PaymentDiscoveryFilter.php @@ -0,0 +1,135 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class PaymentDiscoveryFilter extends BaseFilter implements Filterable { + /** + * Action name for payment discovery + */ + private $actionName = ""; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @param $actionInstance A performable action + * @return $filterInstance An instance of this filter class + * @throws NullPointerException If the resolver is not set + */ + public final static function createPaymentDiscoveryFilter (PerformableAction $actionInstance) { + // Get a new instance + $filterInstance = new PaymentDiscoveryFilter(); + + // Get resolver from action + $resolverInstance = $actionInstance->getResolverInstance(); + + // Is the resolver set? + if (is_null($resolverInstance)) { + // Throw an exception here + throw new NullPointerException($filterInstance, self::EXCEPTION_IS_NULL_POINTER); + } // END - if + + // Get the action name from resolver + $actionName = $resolverInstance->getActionName(); + + // Store it away in this class + $filterInstance->setActionName($actionName); + + // Return the instance + return $filterInstance; + } + + /** + * Protected setter for action name + * + * @param $actionName Action name to set + * @return void + */ + protected final function setActionName ($actionName) { + $this->actionName = (string) $actionName; + } + + /** + * Getter for action name + * + * @return $actionName Action name to set + */ + public final function getActionName () { + return $this->actionName; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @todo 0% done + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Try to get real discovery class + try { + // Get an instance from the object factory + $discoveryInstance = ObjectFactory::createObjectByConfiguredName($this->getActionName().'_payment_discovery', array($this)); + + // Call the discovery method + $discoveryInstance->discover($requestInstance); + + // Remember this instance if all wents fine + Registry::getRegistry()->addInstance('payments', $discoveryInstance); + } catch (ConfigEntryNotFoundException $e) { + // Something bad happend + $requestInstance->requestIsValid(false); + + // Add a message to the response + $responseInstance->addFatalMessage('payment_config_entry_error'); + $responseInstance->addFatalMessagePlain($e->getMessage()); + + // Abort here + return false; + } catch (ClassNotFoundException $e) { + // Something bad happend + $requestInstance->requestIsValid(false); + + // Add a message to the response + $responseInstance->addFatalMessage('payment_class_error'); + $responseInstance->addFatalMessagePlain($e->getMessage()); + + // Abort here + return false; + } + } +} + +// [EOF] +?> diff --git a/inc/classes/main/filter/update/.htaccess b/inc/classes/main/filter/update/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/filter/update/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/filter/update/class_UserStatusConfimedUpdateFilter.php b/inc/classes/main/filter/update/class_UserStatusConfimedUpdateFilter.php new file mode 100644 index 00000000..a7e409b0 --- /dev/null +++ b/inc/classes/main/filter/update/class_UserStatusConfimedUpdateFilter.php @@ -0,0 +1,78 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class UserStatusConfimedUpdateFilter extends BaseFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @param $controllerInstance An instance of a Controller class + * @return $filterInstance An instance of this filter class + */ + public final static function createUserStatusConfimedUpdateFilter (Controller $controllerInstance) { + // Get a new instance + $filterInstance = new UserStatusConfimedUpdateFilter(); + + // Set the controller + $filterInstance->setControllerInstance($controllerInstance); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get user instance from registry + $userInstance = Registry::getRegistry()->getInstance('user'); + + // Get "confirmed" status from config + $confirmed = $this->getConfigInstance()->readConfig('user_status_confirmed'); + + // Update the user status to "confirmed" here + $userInstance->updateDatabaseField(UserDatabaseWrapper::DB_COLUMN_USER_STATUS, $confirmed); + + // Wipe out the confirm hash for extra security + $userInstance->updateDatabaseField(UserDatabaseWrapper::DB_COLUMN_CONFIRM_HASH, ""); + + // Write all updates to the database + $userInstance->flushPendingUpdates(); + } +} + +// [EOF] +?> diff --git a/inc/classes/main/filter/update/class_UserUpdateFilter.php b/inc/classes/main/filter/update/class_UserUpdateFilter.php new file mode 100644 index 00000000..69c62d80 --- /dev/null +++ b/inc/classes/main/filter/update/class_UserUpdateFilter.php @@ -0,0 +1,78 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class UserUpdateFilter extends BaseFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @param $controllerInstance An instance of a Controller class + * @return $filterInstance An instance of this filter class + */ + public final static function createUserUpdateFilter (Controller $controllerInstance) { + // Get a new instance + $filterInstance = new UserUpdateFilter(); + + // Set the controller + $filterInstance->setControllerInstance($controllerInstance); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @todo Add more user updates here + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get user instance from registry + $userInstance = Registry::getRegistry()->getInstance('user'); + + // Now update last activity + $userInstance->updateLastActivity($requestInstance); + + // Update auth data as well + $authInstance = Registry::getRegistry()->getInstance('auth'); + $authInstance->updateAuthData(); + + // Write all updates to the database + $userInstance->flushPendingUpdates(); + } +} + +// [EOF] +?> diff --git a/inc/classes/main/filter/validator/.htaccess b/inc/classes/main/filter/validator/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/filter/validator/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/filter/validator/class_EmailValidatorFilter.php b/inc/classes/main/filter/validator/class_EmailValidatorFilter.php new file mode 100644 index 00000000..6183b33b --- /dev/null +++ b/inc/classes/main/filter/validator/class_EmailValidatorFilter.php @@ -0,0 +1,172 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class EmailValidatorFilter extends BaseFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @param $controllerInstance An instance of a Controller class + * @return $filterInstance An instance of this filter class + */ + public final static function createEmailValidatorFilter (Controller $controllerInstance) { + // Get a new instance + $filterInstance = new EmailValidatorFilter(); + + // Set the controller + $filterInstance->setControllerInstance($controllerInstance); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get Email from request + $email = $requestInstance->getRequestElement('email'); + + // Is the Email set? + if ((is_null($email)) || ($this->getConfigInstance()->readConfig('register_email_unique') === "Y")) { + // Try it again + $email1 = $requestInstance->getRequestElement('email1'); + $email2 = $requestInstance->getRequestElement('email2'); + + // Is the email still not set? + if ((is_null($email1)) || (is_null($email2))) { + // Not found in form so stop the filtering process + $requestInstance->requestIsValid(false); + + // Add a message to the response + $responseInstance->addFatalMessage('email_unset'); + + // Abort here + return false; + } elseif ((empty($email1)) || (empty($email2))) { + // Email is empty + $requestInstance->requestIsValid(false); + + // Is the email empty? + if (empty($email1)) { + // Add a message to the response + $responseInstance->addFatalMessage('email1_empty'); + } // END - if + + // Is the confirmation empty? + if (empty($email2)) { + // Add a message to the response + $responseInstance->addFatalMessage('email2_empty'); + } // END - if + + // Abort here + return false; + } elseif ($this->ifEmailIsTaken($email1)) { + // Email is already taken + $requestInstance->requestIsValid(false); + + // Add a message to the response + $responseInstance->addFatalMessage('email_taken'); + + // Abort here + return false; + } elseif ($email1 != $email2) { + // Emails didn't match + $requestInstance->requestIsValid(false); + + // Add a message to the response + $responseInstance->addFatalMessage('emails_mismatch'); + + // Abort here + return false; + } // END - elseif + } elseif (empty($email)) { + // Empty field! + $requestInstance->requestIsValid(false); + + // Add a message to the response + $responseInstance->addFatalMessage('email_empty'); + + // Abort here + return false; + } // END - elseif + } + + /** + * Check wether the email as already been taken + * + * @param $email Email to check for existence + * @return $alreadyTaken Wether the email has been taken + */ + private function ifEmailIsTaken ($email) { + // Default is already taken + $alreadyTaken = true; + + // Initialize instance + $userInstance = null; + + // Get a registry instance + $registry = Registry::getRegistry(); + + // Is the user already there? + if ($registry->instanceExists('user')) { + // Use the instance for checking for the email + $userInstance = $registry->getInstance('user'); + $userInstance->setEmailAddress($email); + } else { + // If this instance is created then the username *does* exist + $userInstance = call_user_func_array(array($this->getConfigInstance()->readConfig('user_class'), 'createMemberByEmail'), array($email)); + + // Remember this user instance in our registry for later usage + $registry->addInstance('user', $userInstance); + } + + // Does the email exist? + if ($userInstance->ifEmailAddressExists() === false) { + // This email has not being used yet + $alreadyTaken = false; + } + + // Return the result + return $alreadyTaken; + } +} + +// [EOF] +?> diff --git a/inc/classes/main/filter/validator/class_PasswordValidatorFilter.php b/inc/classes/main/filter/validator/class_PasswordValidatorFilter.php new file mode 100644 index 00000000..2591f1ea --- /dev/null +++ b/inc/classes/main/filter/validator/class_PasswordValidatorFilter.php @@ -0,0 +1,107 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class PasswordValidatorFilter extends BaseFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @param $controllerInstance An instance of a Controller class + * @return $filterInstance An instance of this filter class + */ + public final static function createPasswordValidatorFilter (Controller $controllerInstance) { + // Get a new instance + $filterInstance = new PasswordValidatorFilter(); + + // Set the controller + $filterInstance->setControllerInstance($controllerInstance); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get passwords + $password1 = $requestInstance->getRequestElement('pass1'); + $password2 = $requestInstance->getRequestElement('pass2'); + + // Is the password still not set? + if ((is_null($password1)) || (is_null($password2))) { + // Not found in form so stop the filtering process + $requestInstance->requestIsValid(false); + + // Add a message to the response + $responseInstance->addFatalMessage('password_unset'); + + // Abort here + return false; + } elseif ((empty($password1)) || (empty($password2))) { + // Password is empty + $requestInstance->requestIsValid(false); + + // Is the password empty? + if (empty($password1)) { + // Add a message to the response + $responseInstance->addFatalMessage('pass1_empty'); + } // END - if + + // Is the confirmation empty? + if (empty($password2)) { + // Add a message to the response + $responseInstance->addFatalMessage('pass2_empty'); + } // END - if + + // Abort here + return false; + } elseif ($password1 != $password2) { + // Passwords didn't match + $requestInstance->requestIsValid(false); + + // Add a message to the response + $responseInstance->addFatalMessage('pass_mismatch'); + + // Abort here + return false; + } // END - elseif + } +} + +// [EOF] +?> diff --git a/inc/classes/main/filter/validator/class_UserNameValidatorFilter.php b/inc/classes/main/filter/validator/class_UserNameValidatorFilter.php new file mode 100644 index 00000000..8d0445fe --- /dev/null +++ b/inc/classes/main/filter/validator/class_UserNameValidatorFilter.php @@ -0,0 +1,142 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class UserNameValidatorFilter extends BaseFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @param $controllerInstance An instance of a Controller class + * @return $filterInstance An instance of this filter class + */ + public final static function createUserNameValidatorFilter (Controller $controllerInstance) { + // Get a new instance + $filterInstance = new UserNameValidatorFilter(); + + // Set the controller + $filterInstance->setControllerInstance($controllerInstance); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get username from request + $userName = $requestInstance->getRequestElement('username'); + + // Is the username set? + if (is_null($userName)) { + // Not found in form so stop the filtering process + $requestInstance->requestIsValid(false); + + // Add a message to the response + $responseInstance->addFatalMessage('username_unset'); + + // Abort here + return false; + } elseif (empty($userName)) { + // Empty field! + $requestInstance->requestIsValid(false); + + // Add a message to the response + $responseInstance->addFatalMessage('username_empty'); + + // Abort here + return false; + } elseif ($this->ifUserNameIsTaken($userName)) { + // Username is already taken + $requestInstance->requestIsValid(false); + + // Add a message to the response + $responseInstance->addFatalMessage('username_taken'); + + // Abort here + return false; + } + } + + /** + * Check wether the username as already been taken + * + * @param $userName Username to check for existence + * @return $alreadyTaken Wether the username has been taken + */ + private function ifUserNameIsTaken ($userName) { + // Default is already taken + $alreadyTaken = true; + + // Initialize instance + $userInstance = null; + + // Get a registry instance + $registry = Registry::getRegistry(); + + // Is the user already there? + if ($registry->instanceExists('user')) { + // Use the instance for checking for the email + $userInstance = $registry->getInstance('user'); + $userInstance->setUserName($userName); + } else { + // If this instance is created then the username *does* exist + try { + // Get a new instance + $userInstance = call_user_func_array(array($this->getConfigInstance()->readConfig('user_class'), 'createMemberByUsername'), array($userName)); + + // Remember this user instance in our registry for later usage + $registry->addInstance('user', $userInstance); + } catch (UsernameMissingException $e) { + // User was not found + } + } + + // Does the username exist? + if ((is_null($userInstance)) || ($userInstance->ifUsernameExists() === false)) { + // This username is still available + $alreadyTaken = false; + } // END - if + + // Return the result + return $alreadyTaken; + } +} + +// [EOF] +?> diff --git a/inc/classes/main/filter/verifier/.htaccess b/inc/classes/main/filter/verifier/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/filter/verifier/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/filter/verifier/class_AccountPasswordVerifierFilter.php b/inc/classes/main/filter/verifier/class_AccountPasswordVerifierFilter.php new file mode 100644 index 00000000..44fdcfc9 --- /dev/null +++ b/inc/classes/main/filter/verifier/class_AccountPasswordVerifierFilter.php @@ -0,0 +1,113 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class AccountPasswordVerifierFilter extends BaseFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @param $controllerInstance An instance of a Controller class + * @return $filterInstance An instance of this filter class + */ + public final static function createAccountPasswordVerifierFilter (Controller $controllerInstance) { + // Get a new instance + $filterInstance = new AccountPasswordVerifierFilter(); + + // Set the controller + $filterInstance->setControllerInstance($controllerInstance); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @throws AccountPasswordMismatchException If the account password does not match + * @todo Rewrite handling of different password fields + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get password + $password = $requestInstance->getRequestElement('pass_old'); + + // Is the password still not set? + if (is_null($password)) { + // Get password from alternative location + $password = $requestInstance->getRequestElement('password'); + + // Is the password still not set? + if (is_null($password)) { + // Not found in form so stop the filtering process + $requestInstance->requestIsValid(false); + + // Add a message to the response + $responseInstance->addFatalMessage('password_unset'); + + // Abort here + return false; + } // END - if + } // END - if + + if (empty($password)) { + // Password is empty + $requestInstance->requestIsValid(false); + + // Add a message to the response + $responseInstance->addFatalMessage('password_empty'); + + // Abort here + return false; + } + + // Get a user instance + $userInstance = Registry::getRegistry()->getInstance('user'); + + // Get current hash + $currentHash = $userInstance->getField('pass_hash'); + + // Get an encryption helper and encrypt the password + $passHash = ObjectFactory::createObjectByConfiguredName('crypto_class')->hashString($password, $currentHash); + + // Does it match? + if ($currentHash != $passHash) { + // Throw an exception here to stop the proccessing + throw new AccountPasswordMismatchException($this, BaseUser::EXCEPTION_USER_PASS_MISMATCH); + } // END - if + } +} + +// [EOF] +?> diff --git a/inc/classes/main/filter/verifier/class_ConfirmCodeVerifierFilter.php b/inc/classes/main/filter/verifier/class_ConfirmCodeVerifierFilter.php new file mode 100644 index 00000000..09a13d01 --- /dev/null +++ b/inc/classes/main/filter/verifier/class_ConfirmCodeVerifierFilter.php @@ -0,0 +1,112 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ConfirmCodeVerifierFilter extends BaseFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @param $controllerInstance An instance of a Controller class + * @return $filterInstance An instance of this filter class + */ + public final static function createConfirmCodeVerifierFilter (Controller $controllerInstance) { + // Get a new instance + $filterInstance = new ConfirmCodeVerifierFilter(); + + // Set the controller + $filterInstance->setControllerInstance($controllerInstance); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @throws NullPointerException If the user instance from registry is null + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get confirmation code from request + $confirmCode = $requestInstance->getRequestElement('confirm'); + + // Is this code set? + if (is_null($confirmCode)) { + // Is not in request + $requestInstance->requestIsValid(false); + + // Add a message to the response + $responseInstance->addFatalMessage('confirm_code_unset'); + + // Abort here + return false; + } elseif (empty($confirmCode)) { + // Email is empty + $requestInstance->requestIsValid(false); + + // Add a message to the response + $responseInstance->addFatalMessage('confirm_code_empty'); + + // Abort here + return false; + } + + // Get a user instance from registry + $userInstance = Registry::getRegistry()->getInstance('user'); + + // Is the instance there? + if (is_null($userInstance)) { + // Throw an exception here + throw new NullPointerException ($this, self::EXCEPTION_IS_NULL_POINTER); + } // END - if + + // Get the confirm code from user for comparison + $userCode = $userInstance->getField(UserDatabaseWrapper::DB_COLUMN_CONFIRM_HASH); + + // Do we have the same code or different? + if ($userCode != $confirmCode) { + // Email is empty + $requestInstance->requestIsValid(false); + + // Redirect to error page + $responseInstance->redirectToConfiguredUrl('confirm_code_invalid_url'); + + // Stop processing here + exit(); + } // END - if + } +} + +// [EOF] +?> diff --git a/inc/classes/main/filter/verifier/class_GraphicalCodeCaptchaVerifierFilter.php b/inc/classes/main/filter/verifier/class_GraphicalCodeCaptchaVerifierFilter.php new file mode 100644 index 00000000..27fe8a35 --- /dev/null +++ b/inc/classes/main/filter/verifier/class_GraphicalCodeCaptchaVerifierFilter.php @@ -0,0 +1,126 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class GraphicalCodeCaptchaVerifierFilter extends BaseFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @param $controllerInstance An instance of a Controller class + * @return $filterInstance An instance of this filter class + */ + public final static function createGraphicalCodeCaptchaVerifierFilter (Controller $controllerInstance) { + // Get a new instance + $filterInstance = new GraphicalCodeCaptchaVerifierFilter(); + + // Set the controller + $filterInstance->setControllerInstance($controllerInstance); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get the captcha code + $captchaCode = $requestInstance->getRequestElement('c_code'); + + // Is this set? + if (is_null($captchaCode)) { + // Not set so request is invalid + $requestInstance->requestIsValid(false); + + // Add fatal message + $responseInstance->addFatalMessage('captcha_code_unset'); + + // Skip further processing + return false; + } elseif (empty($captchaCode)) { + // Empty value so request is invalid + $requestInstance->requestIsValid(false); + + // Add fatal message + $responseInstance->addFatalMessage('captcha_code_empty'); + + // Skip further processing + return false; + } + + // Get the hash as well + $captchaHash = $requestInstance->getRequestElement('hash'); + + // Is this set? + if (is_null($captchaHash)) { + // Not set so request is invalid + $requestInstance->requestIsValid(false); + + // Add fatal message + $responseInstance->addFatalMessage('captcha_hash_unset'); + + // Skip further processing + return false; + } elseif (empty($captchaHash)) { + // Empty value so request is invalid + $requestInstance->requestIsValid(false); + + // Add fatal message + $responseInstance->addFatalMessage('captcha_hash_empty'); + + // Skip further processing + return false; + } + + // Now, both are set hash the given one. First get a crypto instance + $cryptoInstance = ObjectFactory::createObjectByConfiguredName('crypto_class'); + + // Then hash the code + $hashedCode = $cryptoInstance->hashString($captchaCode, $captchaHash); + + // Is this CAPTCHA valid? + if ($hashedCode != $captchaHash) { + // Not the same so request is invalid + $requestInstance->requestIsValid(false); + + // Add fatal message + $responseInstance->addFatalMessage('captcha_hash_mismatch'); + } // END - not the same! + } +} + +// [EOF] +?> diff --git a/inc/classes/main/filter/verifier/class_PasswordGuestVerifierFilter.php b/inc/classes/main/filter/verifier/class_PasswordGuestVerifierFilter.php new file mode 100644 index 00000000..abe338d3 --- /dev/null +++ b/inc/classes/main/filter/verifier/class_PasswordGuestVerifierFilter.php @@ -0,0 +1,88 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class PasswordGuestVerifierFilter extends BaseFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @param $controllerInstance An instance of a Controller class + * @return $filterInstance An instance of this filter class + */ + public final static function createPasswordGuestVerifierFilter (Controller $controllerInstance) { + // Get a new instance + $filterInstance = new PasswordGuestVerifierFilter(); + + // Set the controller + $filterInstance->setControllerInstance($controllerInstance); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get password + $password = $requestInstance->getRequestElement('passwd'); + + // Is the password still not set? + if (is_null($password)) { + // Not found in form so stop the filtering process + $requestInstance->requestIsValid(false); + + // Add a message to the response + $responseInstance->addFatalMessage('password_unset'); + + // Abort here + return false; + } elseif (empty($password)) { + // Password is empty + $requestInstance->requestIsValid(false); + + // Add a message to the response + $responseInstance->addFatalMessage('password_empty'); + + // Abort here + return false; + } + } +} + +// [EOF] +?> diff --git a/inc/classes/main/filter/verifier/class_PasswordVerifierFilter.php b/inc/classes/main/filter/verifier/class_PasswordVerifierFilter.php new file mode 100644 index 00000000..cea7d210 --- /dev/null +++ b/inc/classes/main/filter/verifier/class_PasswordVerifierFilter.php @@ -0,0 +1,88 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class PasswordVerifierFilter extends BaseFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @param $controllerInstance An instance of a Controller class + * @return $filterInstance An instance of this filter class + */ + public final static function createPasswordVerifierFilter (Controller $controllerInstance) { + // Get a new instance + $filterInstance = new PasswordVerifierFilter(); + + // Set the controller + $filterInstance->setControllerInstance($controllerInstance); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get password + $password = $requestInstance->getRequestElement('pass'); + + // Is the password still not set? + if (is_null($password)) { + // Not found in form so stop the filtering process + $requestInstance->requestIsValid(false); + + // Add a message to the response + $responseInstance->addFatalMessage('password_unset'); + + // Abort here + return false; + } elseif (empty($password)) { + // Password is empty + $requestInstance->requestIsValid(false); + + // Add a message to the response + $responseInstance->addFatalMessage('password_empty'); + + // Abort here + return false; + } + } +} + +// [EOF] +?> diff --git a/inc/classes/main/filter/verifier/class_UserGuestVerifierFilter.php b/inc/classes/main/filter/verifier/class_UserGuestVerifierFilter.php new file mode 100644 index 00000000..8e2b952f --- /dev/null +++ b/inc/classes/main/filter/verifier/class_UserGuestVerifierFilter.php @@ -0,0 +1,145 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class UserGuestVerifierFilter extends BaseFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @param $controllerInstance An instance of a Controller class + * @return $filterInstance An instance of this filter class + */ + public final static function createUserGuestVerifierFilter (Controller $controllerInstance) { + // Get a new instance + $filterInstance = new UserGuestVerifierFilter(); + + // Set the controller + $filterInstance->setControllerInstance($controllerInstance); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get username from request + $userName = $requestInstance->getRequestElement('user'); + + // Is the username set? + if (is_null($userName)) { + // Not found in form so stop the filtering process + $requestInstance->requestIsValid(false); + + // Add a message to the response + $responseInstance->addFatalMessage('username_guest_unset'); + + // Abort here + return false; + } elseif (empty($userName)) { + // Empty field! + $requestInstance->requestIsValid(false); + + // Add a message to the response + $responseInstance->addFatalMessage('username_guest_empty'); + + // Abort here + return false; + } elseif ($this->ifUserGuestIsTaken($userName) === false) { + // Username is already taken + $requestInstance->requestIsValid(false); + + // Add a message to the response + $responseInstance->addFatalMessage('username_guest_not_found'); + + // Abort here + return false; + } + + // Set the element for compatiblity reasons + $requestInstance->setRequestElement('username', $userName); + } + + /** + * Check wether the username as already been taken + * + * @param $userName Username to check for existence + * @return $alreadyTaken Wether the username has been taken + */ + private function ifUserGuestIsTaken ($userName) { + // Default is already taken + $alreadyTaken = true; + + // Initialize instance + $userInstance = null; + + // Get a registry instance + $registry = Registry::getRegistry(); + + // Is the user already there? + if ($registry->instanceExists('user')) { + // Use the instance for checking for the email + $userInstance = $registry->getInstance('user'); + $userInstance->setUserGuest($userName); + } else { + // If this instance is created then the username *does* exist + try { + // Get a new instance + $userInstance = call_user_func_array(array($this->getConfigInstance()->readConfig('guest_class'), 'createGuestByUsername'), array($userName)); + + // Remember this user instance in our registry for later usage + $registry->addInstance('user', $userInstance); + } catch (UsernameMissingException $e) { + // User was not found + } + } + + // Does the username exist? + if ((is_null($userInstance)) || ($userInstance->ifUsernameExists() === false)) { + // This username is still available + $alreadyTaken = false; + } + + // Return the result + return $alreadyTaken; + } +} + +// [EOF] +?> diff --git a/inc/classes/main/filter/verifier/class_UserNameVerifierFilter.php b/inc/classes/main/filter/verifier/class_UserNameVerifierFilter.php new file mode 100644 index 00000000..a3b12a98 --- /dev/null +++ b/inc/classes/main/filter/verifier/class_UserNameVerifierFilter.php @@ -0,0 +1,142 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class UserNameVerifierFilter extends BaseFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @param $controllerInstance An instance of a Controller class + * @return $filterInstance An instance of this filter class + */ + public final static function createUserNameVerifierFilter (Controller $controllerInstance) { + // Get a new instance + $filterInstance = new UserNameVerifierFilter(); + + // Set the controller + $filterInstance->setControllerInstance($controllerInstance); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get username from request + $userName = $requestInstance->getRequestElement('username'); + + // Is the username set? + if (is_null($userName)) { + // Not found in form so stop the filtering process + $requestInstance->requestIsValid(false); + + // Add a message to the response + $responseInstance->addFatalMessage('username_unset'); + + // Abort here + return false; + } elseif (empty($userName)) { + // Empty field! + $requestInstance->requestIsValid(false); + + // Add a message to the response + $responseInstance->addFatalMessage('username_empty'); + + // Abort here + return false; + } elseif ($this->ifUserNameIsTaken($userName) === false) { + // Username is already taken + $requestInstance->requestIsValid(false); + + // Add a message to the response + $responseInstance->addFatalMessage('username_not_found'); + + // Abort here + return false; + } + } + + /** + * Check wether the username as already been taken + * + * @param $userName Username to check for existence + * @return $alreadyTaken Wether the username has been taken + */ + private function ifUserNameIsTaken ($userName) { + // Default is already taken + $alreadyTaken = true; + + // Initialize instance + $userInstance = null; + + // Get a registry instance + $registry = Registry::getRegistry(); + + // Is the user already there? + if ($registry->instanceExists('user')) { + // Use the instance for checking for the email + $userInstance = $registry->getInstance('user'); + $userInstance->setUserName($userName); + } else { + // If this instance is created then the username *does* exist + try { + // Get a new instance + $userInstance = call_user_func_array(array($this->getConfigInstance()->readConfig('user_class'), 'createMemberByUsername'), array($userName)); + + // Remember this user instance in our registry for later usage + $registry->addInstance('user', $userInstance); + } catch (UsernameMissingException $e) { + // User was not found + } + } + + // Does the username exist? + if ((is_null($userInstance)) || ($userInstance->ifUsernameExists() === false)) { + // This username is still available + $alreadyTaken = false; + } // END - if + + // Return the result + return $alreadyTaken; + } +} + +// [EOF] +?> diff --git a/inc/classes/main/filter/verifier/class_UserStatusVerifierFilter.php b/inc/classes/main/filter/verifier/class_UserStatusVerifierFilter.php new file mode 100644 index 00000000..a058aa04 --- /dev/null +++ b/inc/classes/main/filter/verifier/class_UserStatusVerifierFilter.php @@ -0,0 +1,78 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class UserStatusVerifierFilter extends BaseFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @param $controllerInstance An instance of a Controller class + * @return $filterInstance An instance of this filter class + */ + public final static function createUserStatusVerifierFilter (Controller $controllerInstance) { + // Get a new instance + $filterInstance = new UserStatusVerifierFilter(); + + // Set the controller + $filterInstance->setControllerInstance($controllerInstance); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get a user instance for comparison + $userInstance = Registry::getRegistry()->getInstance('user'); + + // Is the user account confirmed? + if (($userInstance->getField(UserDatabaseWrapper::DB_COLUMN_USER_STATUS) != $this->getConfigInstance()->readConfig('user_status_confirmed')) && ($userInstance->getField(UserDatabaseWrapper::DB_COLUMN_USER_STATUS) != $this->getConfigInstance()->readConfig('user_status_guest'))) { + // Request is invalid! + $requestInstance->requestIsValid(false); + + // Redirect to configured URL + $responseInstance->redirectToConfiguredUrl('login_user_status_url'); + + // Stop processing here + exit(); + } // END - if + } +} + +// [EOF] +?> diff --git a/inc/classes/main/filter/verifier/class_UserUnconfirmedVerifierFilter.php b/inc/classes/main/filter/verifier/class_UserUnconfirmedVerifierFilter.php new file mode 100644 index 00000000..0845c85b --- /dev/null +++ b/inc/classes/main/filter/verifier/class_UserUnconfirmedVerifierFilter.php @@ -0,0 +1,96 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class UserUnconfirmedVerifierFilter extends BaseFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @param $controllerInstance An instance of a Controller class + * @return $filterInstance An instance of this filter class + */ + public final static function createUserUnconfirmedVerifierFilter (Controller $controllerInstance) { + // Get a new instance + $filterInstance = new UserUnconfirmedVerifierFilter(); + + // Set the controller + $filterInstance->setControllerInstance($controllerInstance); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get member class + $userClass = $this->getConfigInstance()->readConfig('user_class'); + + // Get a user instance for comparison + $userInstance = call_user_func_array(array($userClass, 'createMemberByRequest'), array($requestInstance)); + + // Is the email address valid? + if ($userInstance->ifEmailAddressExists() === false) { + // Request is invalid! + $requestInstance->requestIsValid(false); + + // Redirect to configured URL + $responseInstance->redirectToConfiguredUrl('user_unconfirmed_email_missing_url'); + + // Stop processing here + exit(); + } // END - if + + // Is the user account confirmed? + if ($userInstance->getField(UserDatabaseWrapper::DB_COLUMN_USER_STATUS) != $this->getConfigInstance()->readConfig('user_status_unconfirmed')) { + // Request is invalid! + $requestInstance->requestIsValid(false); + + // Redirect to configured URL + $responseInstance->redirectToConfiguredUrl('user_not_unconfirmed_url'); + + // Stop processing here + exit(); + } // END - if + + // Add this instance to registry + Registry::getRegistry()->addInstance('user', $userInstance); + } +} + +// [EOF] +?> diff --git a/inc/classes/main/helper/.htaccess b/inc/classes/main/helper/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/helper/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/helper/captcha/.htaccess b/inc/classes/main/helper/captcha/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/helper/captcha/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/helper/captcha/class_ b/inc/classes/main/helper/captcha/class_ new file mode 100644 index 00000000..5dca7ba2 --- /dev/null +++ b/inc/classes/main/helper/captcha/class_ @@ -0,0 +1,78 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ???Captcha extends BaseCaptcha implements SolveableCaptcha { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this captcha class + * + * @param $templateInstance An instance of a template engine + * @param $extraInstance An extra instance, just for better hash data + * @return $captchaInstance An instance of this captcha class + */ + public final static function create???Captcha (CompileableTemplate $templateInstance, FrameworkInterface $extraInstance = null) { + // Get a new instance + $captchaInstance = new ???Captcha(); + + // Set template instance + $captchaInstance->setTemplateInstance($templateInstance); + + // Initialize the RNG + $captchaInstance->initializeRandomNumberGenerator($extraInstance); + + // Return the instance + return $captchaInstance; + } + + /** + * Initiates the CAPTCHA + * + * @return void + * @todo 0% done + */ + public function initiateCaptcha () { + $this->partialStub("Please implement this method."); + } + + /** + * Render the CAPTCHA code + * + * @return void + * @todo 0% done + */ + public function renderCode () { + $this->partialStub("Please implement this method."); + } +} + +// [EOF] +?> diff --git a/inc/classes/main/helper/captcha/class_BaseCaptcha.php b/inc/classes/main/helper/captcha/class_BaseCaptcha.php new file mode 100644 index 00000000..8cb138ef --- /dev/null +++ b/inc/classes/main/helper/captcha/class_BaseCaptcha.php @@ -0,0 +1,87 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseCaptcha extends BaseHelper { + /** + * A helper instance for the form + */ + private $helperInstance = null; + + /** + * Instance of an RNG + */ + private $rngInstance = null; + + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } + + /** + * Initializes the random number generator (RNG) + * + * @param $extraInstance An extra instance, just for better hash data + * @return void + */ + protected final function initializeRandomNumberGenerator (FrameworkInterface $extraInstance = null) { + // Get an RNG from factory + $this->rngInstance = ObjectFactory::createObjectByConfiguredName('rng_class', array($extraInstance)); + } + + /** + * Getter for RNG instance + * + * @return $rngInstance An instance of a random number generator (RNG) + */ + public final function getRngInstance () { + return $this->rngInstance; + } + + /** + * Setter for helper instance + * + * @param $helperInstance An instance of a helper class + * @return void + */ + protected final function setHelperInstance (HelpableTemplate $helperInstance) { + $this->helperInstance = $helperInstance; + } + + /** + * Getter for helper instance + * + * @return $helperInstance An instance of a helper class + */ + public final function getHelperInstance () { + return $this->helperInstance; + } +} + +// [EOF] +?> diff --git a/inc/classes/main/helper/captcha/images/.htaccess b/inc/classes/main/helper/captcha/images/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/helper/captcha/images/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/helper/captcha/images/class_ImageHelper.php b/inc/classes/main/helper/captcha/images/class_ImageHelper.php new file mode 100644 index 00000000..fa8bd859 --- /dev/null +++ b/inc/classes/main/helper/captcha/images/class_ImageHelper.php @@ -0,0 +1,391 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ImageHelper extends BaseCaptcha implements HelpableTemplate { + /** + * The image type + */ + private $imageType = "png"; + + /** + * The image name + */ + private $imageName = ""; + + /** + * Width of the image in pixel + */ + private $width = 0; + + /** + * Height of the image in pixel + */ + private $height = 0; + + /** + * Array for background color values + */ + private $backgroundColor = array( + 'red' => 0, + 'green' => 0, + 'blue' => 0 + ); + + /** + * Array for foreground color values + */ + private $foregroundColor = array( + 'red' => 0, + 'green' => 0, + 'blue' => 0 + ); + + /** + * All image strings + */ + private $imageStrings = array(); + + /** + * Current string name + */ + private $currString = ""; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates the helper class + * + * @param $templateInstance An instance of a template engine + * @param $imageType Type of the image + * @return $helperInstance A preparedf instance of this helper + */ + public final static function createImageHelper (CompileableTemplate $templateInstance, $imageType) { + // Get new instance + $helperInstance = new ImageHelper(); + + // Set template instance + $helperInstance->setTemplateInstance($templateInstance); + + // Set image type (blindly) + $helperInstance->setImageType($imageType); + + // Initialize RNG + $helperInstance->initializeRandomNumberGenerator($templateInstance); + + // Return the prepared instance + return $helperInstance; + } + + /** + * Setter for image type + * + * @param $imageType Type of the image + * @return void + */ + protected final function setImageType ($imageType) { + $this->imageType = (string) $imageType; + } + + /** + * Getter for image name + * + * @return $imageType Type of the image + */ + public final function getImageType () { + return $this->imageType; + } + + /** + * Setter for base image + * + * @param $baseImage A base image template + * @return void + */ + public final function setBaseImage ($baseImage) { + $this->baseImage = (string) $baseImage; + } + + /** + * Getter for base image + * + * @return $baseImage A base image template + */ + public final function getBaseImage () { + return $this->baseImage; + } + + /** + * Setter for image name + * + * @param $imageName Name of the image + * @return void + */ + public final function setImageName ($imageName) { + $this->imageName = (string) $imageName; + } + + /** + * Getter for image name + * + * @return $imageName Name of the image + */ + protected final function getImageName () { + return $this->imageName; + } + + /** + * Setter for image width + * + * @param $width Width of the image + * @return void + */ + public final function setWidth ($width) { + $this->width = (int) $width; + } + + /** + * Getter for image width + * + * @return $width Width of the image + */ + public final function getWidth () { + return $this->width; + } + + /** + * Setter for image height + * + * @param $height Height of the image + * @return void + */ + public final function setHeight ($height) { + $this->height = (int) $height; + } + + /** + * Getter for image height + * + * @return $height Height of the image + */ + public final function getHeight () { + return $this->height; + } + + /** + * Setter for RGB of background color + * + * @param $red Color value for red + * @param $green Color value for green + * @param $blue Color value for blue + * @return void + */ + public final function setBackgroundColorRedGreenBlue ($red, $green, $blue) { + // Random numbers? + if ($red === "rand") { + $red = $this->getRngInstance()->randomNumber(0, 255); + } // END - if + if ($green === "rand") { + $green = $this->getRngInstance()->randomNumber(0, 255); + } // END - if + if ($blue === "rand") { + $blue = $this->getRngInstance()->randomNumber(0, 255); + } // END - if + + $this->backgroundColor['red'] = (int) $red; + $this->backgroundColor['green'] = (int) $green; + $this->backgroundColor['blue'] = (int) $blue; + } + + /** + * Setter for RGB of foreground color + * + * @param $red Color value for red + * @param $green Color value for green + * @param $blue Color value for blue + * @return void + */ + public final function setForegroundColorRedGreenBlue ($red, $green, $blue) { + // Random numbers? + if ($red === "rand") { + $red = $this->getRngInstance()->randomNumber(0, 255); + } // END - if + if ($green === "rand") { + $green = $this->getRngInstance()->randomNumber(0, 255); + } // END - if + if ($blue === "rand") { + $blue = $this->getRngInstance()->randomNumber(0, 255); + } // END - if + + $this->foregroundColor['red'] = (int) $red; + $this->foregroundColor['green'] = (int) $green; + $this->foregroundColor['blue'] = (int) $blue; + } + + /** + * Adds an image string to the buffer by the given string name + * + * @param $stringName String name (identifier) + */ + public function addTextLine ($stringName) { + // Create the image string + $this->imageStrings[$stringName] = array( + 'x' => "", + 'y' => "", + 'size' => "", + 'string' => "" + ); + + // Set current string name + $this->currString = $stringName; + } + + /** + * Setter for image message string + * + * @param $imageString A message to display in image + * @return void + */ + public final function setImageString ($imageString) { + $this->imageStrings[$this->currString]['string'] = (string) $imageString; + } + + /** + * Getter for image message string + * + * @return $imageString A message to display in image + */ + public final function getImageString () { + return $this->imageStrings[$this->currString]['string']; + } + + /** + * Setter for X/Y coordinates for strings + * + * @param $x X coordinate + * @param $y Y coordinate + * @return void + */ + public final function setCoord ($x, $y) { + $this->imageStrings[$this->currString]['x'] = (int) $x; + $this->imageStrings[$this->currString]['y'] = (int) $y; + } + + /** + * Getter for X coordinate + * + * @return $x X coordinate + */ + public final function getX () { + return $this->imageStrings[$this->currString]['x']; + } + + /** + * Getter for Y coordinate + * + * @return $y Y coordinate + */ + public final function getY () { + return $this->imageStrings[$this->currString]['y']; + } + + /** + * Setter for font size + * + * @param $fontSize Font size for strings + * @return void + */ + public final function setFontSize ($fontSize) { + // Random font size? + if ($fontSize === "rand") { + $fontSize = $this->getRngInstance()->randomNumber(4, 9); + } // END - if + + $this->imageStrings[$this->currString]['size'] = (int) $fontSize; + } + + /** + * Getter for font size + * + * @return $fontSize Font size for strings + */ + public final function getFontSize () { + return $this->imageStrings[$this->currString]['size']; + } + + /** + * Flushs the content out + * + * @return void + */ + public function flushContent () { + // Get a template instance + $templateInstance = $this->getTemplateInstance(); + + // Get the base image + $templateInstance->loadCodeTemplate($this->getBaseImage()); + + // Assign all the image values with the template + $templateInstance->assignVariable('image_name' , $this->getImageName()); + $templateInstance->assignVariable('image_type' , $this->getImageType()); + $templateInstance->assignVariable('image_width' , $this->getWidth()); + $templateInstance->assignVariable('image_height' , $this->getHeight()); + $templateInstance->assignVariable('image_bg_red' , $this->backgroundColor['red']); + $templateInstance->assignVariable('image_bg_green', $this->backgroundColor['green']); + $templateInstance->assignVariable('image_bg_blue' , $this->backgroundColor['blue']); + $templateInstance->assignVariable('image_fg_red' , $this->foregroundColor['red']); + $templateInstance->assignVariable('image_fg_green', $this->foregroundColor['green']); + $templateInstance->assignVariable('image_fg_blue' , $this->foregroundColor['blue']); + + // Add all strings + foreach ($this->imageStrings as $id => $imageString) { + // Set current string id to keep this helper in sync with template engine + $this->currString = $id; + + // Set variable group + $templateInstance->setVariableGroup($id); + + // Add group variables + $templateInstance->addGroupVariable('image_x' , $this->getX()); + $templateInstance->addGroupVariable('image_y' , $this->getY()); + $templateInstance->addGroupVariable('image_size' , $this->getFontSize()); + $templateInstance->addGroupVariable('image_string', $this->getImageString()); + } // END - foreach + + // Get the raw content + $imageContent = $templateInstance->getRawTemplateData(); + + // Transfer all to the template engine + $templateInstance->renderXmlContent($imageContent); + } +} + +// [EOF] +?> diff --git a/inc/classes/main/helper/captcha/web/.htaccess b/inc/classes/main/helper/captcha/web/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/helper/captcha/web/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/helper/captcha/web/class_GraphicalCodeCaptcha.php b/inc/classes/main/helper/captcha/web/class_GraphicalCodeCaptcha.php new file mode 100644 index 00000000..37a206ca --- /dev/null +++ b/inc/classes/main/helper/captcha/web/class_GraphicalCodeCaptcha.php @@ -0,0 +1,157 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class GraphicalCodeCaptcha extends BaseCaptcha implements SolveableCaptcha { + /** + * Hash of the CAPTCHA string + */ + private $hashedString = ""; + + /** + * Encrypted string + */ + private $encryptedString = ""; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this captcha class + * + * @param $helperInstance An instance of a helper class + * @param $extraInstance An extra instance, just for better hash data + * @return $captchaInstance An instance of this captcha class + */ + public final static function createGraphicalCodeCaptcha (HelpableTemplate $helperInstance, FrameworkInterface $extraInstance = null) { + // Get a new instance + $captchaInstance = new GraphicalCodeCaptcha(); + + // Set template instance + $captchaInstance->setHelperInstance($helperInstance); + + // Initialize the RNG + $captchaInstance->initializeRandomNumberGenerator($extraInstance); + + // Return the instance + return $captchaInstance; + } + + /** + * Initiates the CAPTCHA + * + * @return void + */ + public function initiateCaptcha () { + // Get total length + $captchaLength = $this->getConfigInstance()->readConfig('captcha_string_length'); + + // Get max string length + $strLength = $this->getConfigInstance()->readConfig('random_string_length'); + + // Calculate starting position based on random place + $start = $this->getRngInstance()->randomNumber(0, ($strLength - $captchaLength)); + + // Test it + assert($start >= 0); + + // Generate a random string for confirmation + $randomString = $this->getRngInstance()->randomString($strLength); + + // Encode the string with BASE64 + $base64String = base64_encode($randomString); + + // Make this string a bit more readable for humans + $captchaString = substr($base64String, $start, $captchaLength); + + // Get all characters we want to replace + $searchChars = $this->getConfigInstance()->readConfig('captcha_search_chars'); + + // Get fixed salt and use it as "replacement characters" + $replaceChars = $this->getRngInstance()->getExtraSalt(); + + // Remove any plus, equals or slashes + for ($searchIdx = 0; $searchIdx < strlen($searchChars); $searchIdx++) { + // Get search character + $search = substr($searchChars, $searchIdx, 1); + + // Random array index + $charIdx = $this->getRngInstance()->randomNumber(0, (strlen($replaceChars) - 1)); + + // Get replacement + $replace = substr($replaceChars, $charIdx, 1); + + // Replace character + $captchaString = str_replace($search, $replace, $captchaString, $captchaLength); + } // END - foreach + + // Get crypto instance + $cryptoInstance = ObjectFactory::createObjectByConfiguredName('crypto_class'); + + // Hash the CAPTCHA code for later comparison + $this->hashedString = $cryptoInstance->hashString($captchaString); + + // Encrypt the string for later usage + $this->encryptedString = $cryptoInstance->encryptString($captchaString); + } + + /** + * Render the CAPTCHA code + * + * @return void + */ + public function renderCode () { + // Get helper instance + $helperInstance = $this->getHelperInstance(); + + // Get template instance + $templateInstance = $helperInstance->getTemplateInstance(); + + // Load a template for this CAPTCHA + $templateInstance->loadCodeTemplate('captch_graphic_code'); + + // Rename variable + $templateInstance->renameVariable('captcha_code', $helperInstance->getFormName().'_captcha'); + $templateInstance->renameVariable('captcha_hash', $helperInstance->getFormName().'_hash'); + $templateInstance->renameVariable('encrypted_code', $helperInstance->getFormName().'_encrypt'); + + // Assign variables + $templateInstance->assignVariable($helperInstance->getFormName().'_encrypt', urlencode(base64_encode($this->encryptedString))); + $templateInstance->assignVariable($helperInstance->getFormName().'_hash', $this->hashedString); + + // Compile the template + $templateInstance->compileTemplate(); + + // Get the content back + $this->addContent($templateInstance->getRawTemplateData()); + } +} + +// [EOF] +?> diff --git a/inc/classes/main/helper/class_ b/inc/classes/main/helper/class_ new file mode 100644 index 00000000..94f912f8 --- /dev/null +++ b/inc/classes/main/helper/class_ @@ -0,0 +1,63 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ???Helper extends BaseHelper { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set part description + $this->setObjectDescription(""); + } + + /** + * Creates the helper class + * + * @return $helperInstance A prepared instance of this helper + */ + public final static function create???Helper () { + // Get new instance + $helperInstance = new ???Helper(); + + // Return the prepared instance + return $helperInstance; + } + + /** + * Flush the content out,e g. to a template variable + * + * @return void + * @todo 0% done + */ + public function flushContent () { + $this->partialStub("Please implement this method."); + } +} + +// [EOF] +?> diff --git a/inc/classes/main/helper/class_BaseHelper.php b/inc/classes/main/helper/class_BaseHelper.php new file mode 100644 index 00000000..b4e893f4 --- /dev/null +++ b/inc/classes/main/helper/class_BaseHelper.php @@ -0,0 +1,503 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseHelper extends BaseFrameworkSystem { + /** + * Instance to the class which provides field values + */ + private $valueInstance = null; + + /** + * Rendered content created by the helper class + */ + private $content = ""; + + /** + * Array with groups + */ + private $groups = array(); + + /** + * Array with sub group + */ + private $subGroups = array(); + + /** + * Previously opened group + */ + private $previousGroupId = ""; + + /** + * Previously opened sub group + */ + private $previousSubGroupId = ""; + + /** + * Total counter for groups and sub groups + */ + private $totalCounter = 0; + + // Exception constants + const EXCEPTION_XML_PARSER_ERROR = 0x1e0; + const EXCEPTION_XML_NODE_UNKNOWN = 0x1e1; + const EXCEPTION_XML_NODE_MISMATCH = 0x1e2; + const EXCEPTION_GROUP_NOT_OPENED = 0x1e3; + const EXCEPTION_GROUP_ALREADY_FOUND = 0x1e4; + const EXCEPTION_SUB_GROUP_ALREADY_FOUND = 0x1e5; + const EXCEPTION_NO_PREVIOUS_SUB_GROUP_OPENED = 0x1e6; + const EXCEPTION_NO_PREVIOUS_GROUP_OPENED = 0x1e7; + + /** + * Protected constructor + * + * @param $className Real name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + + // Clean up a little + $this->removeNumberFormaters(); + $this->removeSystemArray(); + } + + /** + * Adds content directly + * + * @param $newContent New content to add + * @return void + */ + protected final function addContent ($newContent) { + $this->content .= (string) trim($newContent)."\n"; + } + + /** + * Add header content to the helper + * + * @param $content Content to to the base + * @return void + */ + protected function addHeaderContent ($content) { + // Add the header content + $this->groups['header']['content'] = (string) trim($content); + } + + /** + * Add footer content to the helper + * + * @param $content Content to to the base + * @return void + */ + protected function addFooterContent ($content) { + // Add the footer content + $this->groups['footer']['content'] = (string) trim($content); + } + + /** + * Adds content to the previously opened group or sub group. If a sub group + * was found it will be taken. If no group/sub group is opened at the moment + * the code will be passed to addContent(). + * + * @param $newContent New content to add + * @return void + */ + protected final function addContentToPreviousGroup ($newContent) { + // Check for sub/group + if ($this->ifSubGroupOpenedPreviously()) { + // Get sub group id + $subGroupId = $this->getPreviousSubGroupId(); + + // Add the content + $this->subGroups[$subGroupId]['content'] .= $newContent; + } elseif ($this->ifGroupOpenedPreviously()) { + // Get group id + $groupId = $this->getPreviousGroupId(); + + // Add the content + $this->groups[$groupId]['content'] .= $newContent; + } else { + // Add it directly + $this->addContent($newContent); + } + } + + /** + * Getter for content + * + * @return $content The rendered content by this helper + */ + protected final function getContent () { + return $this->content; + } + + /** + * Assigns a field from the value instance with a template variable + * + * @param $fieldName Name of the field to assign + * @return void + */ + public function assignField ($fieldName) { + // Get the value from value instance + $fieldValue = $this->getValueField($fieldName); + + // Assign it with a template variable + $this->getTemplateInstance()->assignVariable('block_' . $fieldName, $fieldValue); + } + + /** + * Assigns a field from the value instance with a template variable but + * parses its content through a given filter method of the value instance + * + * @param $fieldName Name of the field to assign + * @param $filterMethod Method name to call of the value instance + * @return void + * @todo Rewrite this method using a helper class for filtering data + */ + public function assignFieldWithFilter ($fieldName, $filterMethod) { + // Get the value + $fieldValue = $this->getValueField($fieldName); + + // Now filter it through the value through the filter method + $filteredValue = call_user_func_array(array($this, 'doFilter' . $this->convertToClassName($filterMethod)), array($fieldValue)); + + // Assign it with a template variable + $this->getTemplateInstance()->assignVariable('block_' . $fieldName, $filteredValue); + } + + /** + * Pre-fetches field default values from the given registry key instance into this class + * + * @param $registryKey Registry key which holds an object with values + * @param $extraKey Extra value instance key used if registryKey is null + * @return void + * @throws NullPointerException If recovery of requested value instance failed + */ + public function prefetchValueInstance ($registryKey, $extraKey = null) { + // Get the required instance + $this->valueInstance = Registry::getRegistry()->getInstance($registryKey); + + // Is the value instance valid? + if (is_null($this->valueInstance)) { + // Try to create it "from scratch", by first init extra instance + $extraInstance = null; + + // Shall we get an extra instance? + if (!is_null($extraKey)) { + // Get the extra instance. + $extraInstance = Registry::getRegistry()->getInstance($extraKey); + } // END - if + + // Get the requested instance + try { + $this->valueInstance = ObjectFactory::createObjectByConfiguredName($registryKey . '_class', array($extraInstance)); + + } catch (FrameworkException $e) { + // Okay, nothing found so throw a null pointer exception here + throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER); + } + } // END - if + } + + /** + * Opens a helper group with given group id and content or throws an + * exception if that group is already found regardless if it is open or + * closed. + * + * @param $groupId Group id to open + * @param $content Initial content to add to the group + * @param $tag HTML tag used to open this group + * @return void + * @throws HelperGroupAlreadyCreatedException If the group was already created before + */ + protected function openGroupByIdContent ($groupId, $content, $tag) { + //* DEBUG: */ echo "OPEN:groupId={$groupId},content=
".htmlentities($content)."
\n"; + // Is the group already there? + if (isset($this->groups[$groupId])) { + // Then throw an exception here + throw new HelperGroupAlreadyCreatedException(array($this, $groupId), self::EXCEPTION_GROUP_ALREADY_FOUND); + } // END - if + + // Count one up + $this->totalCounter++; + + // Add the group to the stack + $this->groups[$this->totalCounter] = $groupId; + $this->groups[$groupId]['opened'] = true; + $this->groups[$groupId]['content'] = sprintf("%s\n", $groupId, strlen($content), $tag, $content); + $this->groups[$groupId]['tag'] = $tag; + + // Mark this group as previously opened + $this->setPreviousGroupId($groupId); + } + + /** + * Closes the previously opened group by added given content to it or + * throws an exception if no previous group was opened + * + * @param $content Content for previously opened group, or empty to use tag of opener + * @return void + * @throws HelperNoPreviousOpenedGroupException If no previously opened group was found + */ + public function closePreviousGroupByContent ($content = "") { + // Check if any sub group was opened before + if ($this->ifSubGroupOpenedPreviously()) { + // Close it automatically + $this->closePreviousSubGroupByContent(); + } // END - if + + // Check if any group was opened before + if ($this->ifGroupOpenedPreviously() === false) { + // Then throw an exception + throw new HelperNoPreviousOpenedGroupException(array($this, $content), self::EXCEPTION_NO_PREVIOUS_SUB_GROUP_OPENED); + } // END - if + + // Get previous group + $groupId = $this->getPreviousGroupId(); + + // Is the content empty? + if ((empty($content)) && (!empty($this->groups[$groupId]['tag']))) { + // Get it from opener + $content = sprintf("", $groupId, $this->groups[$groupId]['tag']); + } // END - if + + // Add content to it and mark it as closed + $this->groups[$groupId]['content'] .= sprintf("%s\n", $groupId, strlen($content), $this->groups[$groupId]['tag'], $content); + $this->groups[$groupId]['opened'] = false; + + // Mark previous group as closed + $this->setPreviousGroupId(""); + //* DEBUG: */ echo "CLOSE:groupId={$groupId}
\n"; + } + + /** + * Opens a helper sub group with given group id and content or throws an + * exception if that sub group is already found regardless if it is open or + * closed. + * + * @param $subGroupId Sub group id to open + * @param $content Initial content to add to the sub group + * @param $tag HTML tag used to open this group + * @return void + * @throws HelperSubGroupAlreadyCreatedException If the sub group was already created before + */ + protected function openSubGroupByIdContent ($subGroupId, $content, $tag) { + //* DEBUG: */ echo "OPEN:subGroupId={$subGroupId},content=".htmlentities($content)."
\n"; + // Is the group already there? + if (isset($this->subGroups[$subGroupId])) { + // Then throw an exception here + throw new HelperSubGroupAlreadyCreatedException(array($this, $subGroupId), self::EXCEPTION_SUB_GROUP_ALREADY_FOUND); + } // END - if + + // Count one up + $this->totalCounter++; + + // Add the group to the stack + $this->subGroups[$this->totalCounter] = $subGroupId; + $this->subGroups[$subGroupId]['opened'] = true; + $this->subGroups[$subGroupId]['content'] = sprintf("%s\n", $subGroupId, strlen($content), $tag, $content); + $this->subGroups[$subGroupId]['tag'] = $tag; + + // Mark this group as previously opened + $this->setPreviousSubGroupId($subGroupId); + } + + /** + * Closes the previously opened sub group by added given content to it or + * throws an exception if no previous sub group was opened + * + * @param $content Content for previously opened sub group, or leave empty to use div/span of openener + * @return void + * @throws HelperNoPreviousOpenedSubGroupException If no previously opened sub group was found + */ + public function closePreviousSubGroupByContent ($content = "") { + // Check if any sub group was opened before + if ($this->ifSubGroupOpenedPreviously() === false) { + // Then throw an exception + throw new HelperNoPreviousOpenedSubGroupException(array($this, $content), self::EXCEPTION_NO_PREVIOUS_SUB_GROUP_OPENED); + } // END - if + + // Get previous sub group + $subGroupId = $this->getPreviousSubGroupId(); + + // Is the content empty? + if ((empty($content)) && (!empty($this->subGroups[$subGroupId]['tag']))) { + // Get it from opener + $content = sprintf("", $subGroupId, $this->subGroups[$subGroupId]['tag']); + } // END - if + + // Add content to it and mark it as closed + $this->subGroups[$subGroupId]['content'] .= sprintf("%s\n", $subGroupId, strlen($content), $this->subGroups[$subGroupId]['tag'], $content); + $this->subGroups[$subGroupId]['opened'] = false; + + // Mark previous sub group as closed + $this->setPreviousSubGroupId(""); + //* DEBUG: */ echo "CLOSE:subGroupId={$subGroupId}
\n"; + } + + /** + * Renders all group and sub group in their order + * + * @return $content Rendered HTML content + */ + public function renderContent () { + // Initialize content + $content = ""; + + // Is header content there? + if (isset($this->groups['header'])) { + // Then add it + $content .= $this->groups['header']['content']."\n"; + } // END - if + + // Initiate content + $content .= $this->getContent(); + + // Now "walk" through all groups and sub-groups + for ($idx = 1; $idx <= $this->totalCounter; $idx++) { + // Is this a group and is it closed? + if ((isset($this->groups[$idx])) && ($this->groups[$this->groups[$idx]]['opened'] === false)) { + // Then add it's content + $groupContent = trim($this->groups[$this->groups[$idx]]['content']); + //* DEBUG: */ echo "group={$this->groups[$idx]},content=
".htmlentities($groupContent)."

\n"; + $content .= $groupContent; + } elseif ((isset($this->subGroups[$idx])) && ($this->subGroups[$this->subGroups[$idx]]['opened'] === false)) { + // Then add it's content + $subGroupContent = $this->subGroups[$this->subGroups[$idx]]['content']; + //* DEBUG: */ echo "subgroup={$this->subGroups[$idx]},content=
".htmlentities($subGroupContent)."

\n"; + $content .= trim($subGroupContent); + } else { + // Something went wrong + $this->debugInstance(__METHOD__."(): Something unexpected happened here."); + } + } // END - for + + // Is footer content there? + if (isset($this->groups['footer'])) { + // Then add it + $content .= $this->groups['footer']['content']."\n"; + } // END - if + + // Return it + //* DEBUG: */ echo "content=
".htmlentities($content)."
(".strlen($content).")
\n"; + return $content; + } + + /** + * Checks wether the specified group is opened + * + * @param $groupId Id of group to check + * @return $isOpened Wether the specified group is open + */ + protected function ifGroupIsOpened ($groupId) { + // Is the group open? + $isOpened = ((isset($this->groups[$groupId])) && ($this->groups[$groupId]['opened'] === true)); + + // Return status + return $isOpened; + } + + /** + * Getter for direct field values + * + * @param $fieldName Name of the field we shall fetch + * @return $fieldValue Value from field + */ + public function getValueField ($fieldName) { + // Get the field value + $fieldValue = call_user_func_array(array($this->valueInstance, 'getField'), array($fieldName)); + + // Return it + return $fieldValue; + } + + /** + * Getter for value instance + * + * @return $valueInstance Instance of the class holding our values + */ + public final function getValueInstance () { + return $this->valueInstance; + } + + /** + * Check wether a group was opened previously + * + * @return $groupOpened Wether any group was opened before + */ + protected final function ifGroupOpenedPreviously () { + $groupOpened = (!empty($this->previousGroupId)); + return $groupOpened; + } + + /** + * Check wether a group was opened previously + * + * @return $subGroupOpened Wether any group was opened before + */ + protected final function ifSubGroupOpenedPreviously () { + $subGroupOpened = (!empty($this->previousSubGroupId)); + return $subGroupOpened; + } + + /** + * Getter for previous group id + * + * @return $previousGroupId Id of previously opened group + */ + protected final function getPreviousGroupId () { + return $this->previousGroupId; + } + + /** + * Setter for previous group id + * + * @param $previousGroupId Id of previously opened group + * @return void + */ + protected final function setPreviousGroupId ($previousGroupId) { + $this->previousGroupId = (string) $previousGroupId; + } + + /** + * Getter for previous sub group id + * + * @return $previousSubGroupId Id of previously opened sub group + */ + protected final function getPreviousSubGroupId () { + return $this->previousSubGroupId; + } + + /** + * Setter for previous sub group id + * + * @param $previousSubGroupId Id of previously opened sub group + * @return void + */ + protected final function setPreviousSubGroupId ($previousSubGroupId) { + $this->previousSubGroupId = (string) $previousSubGroupId; + } +} + +// [EOF] +?> diff --git a/inc/classes/main/helper/login/.htaccess b/inc/classes/main/helper/login/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/helper/login/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/helper/login/class_BaseLoginHelper.php b/inc/classes/main/helper/login/class_BaseLoginHelper.php new file mode 100644 index 00000000..8fdd13d7 --- /dev/null +++ b/inc/classes/main/helper/login/class_BaseLoginHelper.php @@ -0,0 +1,38 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseLoginHelper extends BaseHelper { + /** + * Protected constructor + * + * @param $className Real name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } +} + +// [EOF] +?> diff --git a/inc/classes/main/helper/web/.htaccess b/inc/classes/main/helper/web/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/helper/web/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/helper/web/blocks/.htaccess b/inc/classes/main/helper/web/blocks/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/helper/web/blocks/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/helper/web/blocks/class_WebBlockHelper.php b/inc/classes/main/helper/web/blocks/class_WebBlockHelper.php new file mode 100644 index 00000000..48b32d83 --- /dev/null +++ b/inc/classes/main/helper/web/blocks/class_WebBlockHelper.php @@ -0,0 +1,151 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class WebBlockHelper extends BaseWebHelper implements HelpableTemplate { + /** + * Name of the block + */ + private $blockName = ""; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates the helper class + * + * @param $templateInstance An instance of a template engine + * @param $blockName Name of the block we shall generate + * @return $helperInstance A prepared instance of this helper + */ + public final static function createWebBlockHelper (CompileableTemplate $templateInstance, $blockName) { + // Get new instance + $helperInstance = new WebBlockHelper(); + + // Set template instance + $helperInstance->setTemplateInstance($templateInstance); + + // Set block name + $helperInstance->setBlockName($blockName); + + // Return the prepared instance + return $helperInstance; + } + + /** + * Setter for block name + * + * @param $blockName Name of the block we shall generate + * @return void + */ + protected final function setBlockName ($blockName) { + $this->blockName = (string) $blockName; + } + + /** + * Getter for block name + * + * @return $blockName Name of the block we shall generate + */ + public final function getBlockName () { + return $this->blockName; + } + + /** + * Checks wether include registration date in this block + * + * @return $withRegistration Wether with registration date + */ + public function ifIncludeRegistrationStamp () { + $withRegistration = ($this->getConfigInstance()->readConfig('block_shows_registration') === "Y"); + return $withRegistration; + } + + /** + * Assignes a template variable with a message from a given message id + * + * @param $templateVariable Template variable to assign + * @param $messageId Message id to load an assign + * @return void + */ + public function assignMessageField ($templateVariable, $messageId) { + // Get message + $message = $this->getLanguageInstance()->getMessage($messageId); + + // And assign it + $this->getTemplateInstance()->assignVariable($templateVariable, $message); + } + + /** + * Assigns a link field with a given value + * + * @param $linkField "Link field" (variable) to assign + * @param $actionValue Action value to assign + * @return void + */ + public function assignLinkFieldWithAction ($linkField, $actionValue) { + $this->getTemplateInstance()->assignVariable($linkField . '_action', $actionValue); + } + + /** + * "Filter" method for translating the raw user status into something human-readable + * + * @param $userStatus Raw user status from database layer + * @return $translated Translated user status + */ + protected function doFilterUserStatusTranslator ($userStatus) { + // Generate message id + $messageId = 'user_status_' . strtolower($userStatus); + + // Get that message + $translated = $this->getLanguageInstance()->getMessage($messageId); + + // Return it + return $translated; + } + + /** + * Flush the content out,e g. to a template variable + * + * @return void + */ + public function flushContent () { + // Get template instance + $templateInstance = $this->getTemplateInstance(); + + // Get the template named like this block + $templateInstance->loadCodeTemplate("block_" . $this->getBlockName()); + + // Transfer it to the template instance + $templateInstance->assignVariable($this->getBlockName(), $templateInstance->getRawTemplateData()); + } +} + +// [EOF] +?> diff --git a/inc/classes/main/helper/web/class_ b/inc/classes/main/helper/web/class_ new file mode 100644 index 00000000..635066ac --- /dev/null +++ b/inc/classes/main/helper/web/class_ @@ -0,0 +1,76 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class Web???Helper extends BaseWebHelper implements HelpableTemplate { + /** + * Name of the ??? + */ + private $???Name = ""; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set part description + $this->setObjectDescription(""); + } + + /** + * Creates the helper class + * + * @param $templateInstance An instance of a template engine + * @param $???Name Name of the ??? we shall generate + * @return $helperInstance A prepared instance of this helper + */ + public final static function createWeb???Helper (CompileableTemplate $templateInstance, $???Name) { + // Get new instance + $helperInstance = new Web???Helper(); + + // Set template instance + $helperInstance->setTemplateInstance($templateInstance); + + // Set ??? name + $helperInstance->set???Name($???Name); + + // Return the prepared instance + return $helperInstance; + } + + /** + * Flush the content out,e g. to a template variable + * + * @return void + * @todo 0% done + */ + public function flushContent () { + $this->partialStub("Please implement this method."); + } +} + +// [EOF] +?> diff --git a/inc/classes/main/helper/web/class_BaseWebHelper.php b/inc/classes/main/helper/web/class_BaseWebHelper.php new file mode 100644 index 00000000..0da3e0a1 --- /dev/null +++ b/inc/classes/main/helper/web/class_BaseWebHelper.php @@ -0,0 +1,210 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseWebHelper extends BaseHelper { + /** + * Protected constructor + * + * @param $className The real class name + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } + + /** + * Checks wether the registration requires a valid email address + * + * @return $required Wether the email address is required + */ + public function ifRegisterRequiresEmailVerification () { + $required = ($this->getConfigInstance()->readConfig('register_requires_email') === "Y"); + return $required; + } + + /** + * Checks wether profile data shall be asked + * + * @return $required Wether profile shall be asked + */ + public function ifRegisterIncludesProfile () { + $required = ($this->getConfigInstance()->readConfig('register_includes_profile') === "Y"); + return $required; + } + + /** + * Checks wether personal data shall be asked + * + * @return $required Wether personal data shall be asked + */ + public function ifRegisterIncludesPersonaData () { + $required = ($this->getConfigInstance()->readConfig('register_personal_data') === "Y"); + return $required; + } + + /** + * Checks wether for birthday shall be asked + * + * @return $required Wether birthday shall be asked + */ + public function ifProfileIncludesBirthDay () { + $required = ($this->getConfigInstance()->readConfig('profile_includes_birthday') === "Y"); + return $required; + } + + /** + * Checks wether email addresses can only be once used + * + * @return $isUnique + */ + public function ifEmailMustBeUnique () { + $isUnique = ($this->getConfigInstance()->readConfig('register_email_unique') === "Y"); + return $isUnique; + } + + /** + * Checks wether the specified chat protocol is enabled in this form + * + * @return $required Wether the specified chat protocol is enabled + */ + public function ifChatEnabled ($chatProtocol) { + $required = ($this->getConfigInstance()->readConfig(sprintf("chat_enabled_%s", $chatProtocol)) == "Y"); + return $required; + } + + /** + * Checks wether login is enabled or disabled + * + * @return $isEnabled Wether the login is enabled or disabled + */ + public function ifLoginIsEnabled () { + $isEnabled = ($this->getConfigInstance()->readConfig('login_enabled') === "Y"); + return $isEnabled; + } + + /** + * Checks wether login shall be done by username + * + * @return $isEnabled Wether the login shall be done by username + */ + public function ifLoginWithUsername () { + $isEnabled = ($this->getConfigInstance()->readConfig('login_type') == "username"); + return $isEnabled; + } + + /** + * Checks wether login shall be done by email + * + * @return $isEnabled Wether the login shall be done by email + */ + public function ifLoginWithEmail () { + $isEnabled = ($this->getConfigInstance()->readConfig('login_type') == "email"); + return $isEnabled; + } + + /** + * Checks wether guest login is allowed + * + * @return $isAllowed Wether guest login is allowed + */ + public function ifGuestLoginAllowed () { + $isAllowed = ($this->getConfigInstance()->readConfig('guest_login_allowed') === "Y"); + return $isAllowed; + } + + /** + * Checks wether the email address change must be confirmed + * + * @return $requireConfirm Wether email change must be confirmed + */ + public function ifEmailChangeRequireConfirmation () { + $requireConfirm = ($this->getConfigInstance()->readConfig('email_change_confirmation') === "Y"); + return $requireConfirm; + } + + /** + * Checks wether the rules has been updated + * + * @return $rulesUpdated Wether rules has been updated + * @todo Implement check if rules have been changed + */ + public function ifRulesHaveChanged () { + return false; + } + + /** + * Checks wether email change is allowed + * + * @return $emailChange Wether changing email address is allowed + */ + public function ifEmailChangeAllowed () { + $emailChange = ($this->getConfigInstance()->readConfig('email_change_allowed') === "Y"); + return $emailChange; + } + + /** + * Checks wether the user account is unconfirmed + * + * @return $isUnconfirmed Wether the user account is unconfirmed + */ + public function ifUserAccountUnconfirmed () { + $isUnconfirmed = ($this->getValueField(UserDatabaseWrapper::DB_COLUMN_USER_STATUS) === $this->getConfigInstance()->readConfig('user_status_unconfirmed')); + return $isUnconfirmed; + } + + /** + * Checks wether the user account is locked + * + * @return $isUnconfirmed Wether the user account is locked + */ + public function ifUserAccountLocked () { + $isUnconfirmed = ($this->getValueField(UserDatabaseWrapper::DB_COLUMN_USER_STATUS) === $this->getConfigInstance()->readConfig('user_status_locked')); + return $isUnconfirmed; + } + + /** + * Checks wether the user account is a guest + * + * @return $isUnconfirmed Wether the user account is a guest + */ + public function ifUserAccountGuest () { + $isUnconfirmed = ($this->getValueField(UserDatabaseWrapper::DB_COLUMN_USER_STATUS) === $this->getConfigInstance()->readConfig('user_status_guest')); + return $isUnconfirmed; + } + + /** + * Checks wether the refill page is active which should be not the default + * on non-web applications. + * + * @return $refillActive Wether the refill page is active + */ + public function ifRefillPageActive () { + $refillActive = ($this->getConfigInstance()->readConfig('refill_page_active') === "Y"); + return $refillActive; + } +} + +// [EOF] +?> diff --git a/inc/classes/main/helper/web/forms/.htaccess b/inc/classes/main/helper/web/forms/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/helper/web/forms/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/helper/web/forms/class_WebFormHelper.php b/inc/classes/main/helper/web/forms/class_WebFormHelper.php new file mode 100644 index 00000000..1fffb7af --- /dev/null +++ b/inc/classes/main/helper/web/forms/class_WebFormHelper.php @@ -0,0 +1,779 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class WebFormHelper extends BaseWebHelper implements HelpableTemplate { + /** + * Wether the form tag is opened (keep at false or else your forms will + * never work!) + */ + private $formOpened = false; + + /** + * Name of the form + */ + private $formName = ""; + + /** + * Wether form tag is enabled (default: true) + */ + private $formEnabled = true; + + // Class Constants + const EXCEPTION_FORM_NAME_INVALID = 0x120; + const EXCEPTION_CLOSED_FORM = 0x121; + const EXCEPTION_OPENED_FORM = 0x122; + const EXCEPTION_UNEXPECTED_CLOSED_GROUP = 0x123; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates the helper class with the given template engine instance and form name + * + * @param $templateInstance An instance of a valid template engine + * @param $formName Name of the form + * @param $formId Value for "id" attribute (default: $formName) + * @param $withForm Wether include the form tag + * @return $helperInstance A preparedf instance of this helper + */ + public final static function createWebFormHelper (CompileableTemplate $templateInstance, $formName, $formId = false, $withForm = true) { + // Get new instance + $helperInstance = new WebFormHelper(); + + // Set template instance + $helperInstance->setTemplateInstance($templateInstance); + + // Is the form id not set? + if ($formId === false) { + // Use form id from form name + $formId = $formName; + } // END - if + + // Set form name + $helperInstance->setFormName($formName); + + // A form-less field may say "false" here... + if ($withForm === true) { + // Create the form + $helperInstance->addFormTag($formName, $formId); + } else { + // Disable form + $helperInstance->enableForm(false); + } + + // Return the prepared instance + return $helperInstance; + } + + /** + * Add the form tag or close it an already opened form tag + * + * @param $formName Name of the form (default: false) + * @param $formId Id of the form (attribute "id"; default: false) + * @return void + * @throws InvalidFormNameException If the form name is invalid (=false) + * @todo Add some unique PIN here to bypass problems with some browser and/or extensions + */ + public function addFormTag ($formName = false, $formId = false) { + // When the form is not yet opened at least form name must be valid + if (($this->formOpened === false) && ($formName === false)) { + // Thrown an exception + throw new InvalidFormNameException ($this, self::EXCEPTION_FORM_NAME_INVALID); + } // END - if + + // Close the form is default + $formContent = ""; + + // Check wether we shall open or close the form + if (($this->formOpened === false) && ($this->formEnabled === true)) { + // Add HTML code + $formContent = sprintf("
getConfigInstance()->readConfig('base_url'), + $this->getConfigInstance()->readConfig('form_action'), + $this->getConfigInstance()->readConfig('form_method'), + $this->getConfigInstance()->readConfig('form_target') + ); + + // Add form id as well + $formContent .= sprintf(" id=\"%s_form\"", + $formId + ); + + // Add close bracket + $formContent .= ">"; + + // Open the form and remeber the form name + $this->formOpened = true; + + // Add it to the content + $this->addHeaderContent($formContent); + } else { + // Add the hidden field required to identify safely this form + $this->addInputHiddenField('form', $this->getFormName()); + + // Is a group open? + if ($this->ifGroupOpenedPreviously()) { + // Then automatically close it here + $this->addFormGroup(); + } // END - if + + // Simply close it + $this->formOpened = false; + + // Add it to the content + $this->addFooterContent($formContent); + } + } + + /** + * Add a text input tag to the form or throw an exception if it is not yet + * opened. The field's name will be set as id. + * + * @param $fieldName Input field name + * @param $fieldValue Input default value (default: empty) + * @return void + * @throws FormClosedException If the form is not yet opened + */ + public function addInputTextField ($fieldName, $fieldValue = "") { + // Is the form opened? + if (($this->formOpened === false) && ($this->formEnabled === true)) { + // Throw an exception + throw new FormClosedException (array($this, $fieldName), self::EXCEPTION_CLOSED_FORM); + } // END - if + + // Generate the content + $inputContent = sprintf("", + $fieldName, + $fieldName, + $fieldValue + ); + + // And add it maybe with a "li" tag + $this->addContentToPreviousGroup($inputContent); + } + + /** + * Add a text input tag to the form with pre-loaded default value + * + * @param $fieldName Input field name + * @return void + */ + public function addInputTextFieldWithDefault ($fieldName) { + // Get the value from instance + $fieldValue = $this->getValueField($fieldName); + //* DEBUG: */ echo __METHOD__.":".$fieldName."=".$fieldValue."
\n"; + + // Add the text field + $this->addInputTextField($fieldName, $fieldValue); + } + + /** + * Add a password input tag to the form or throw an exception if it is not + * yet opened. The field's name will be set as id. + * + * @param $fieldName Input field name + * @param $fieldValue Input default value (default: empty) + * @return void + * @throws FormClosedException If the form is not yet opened + */ + public function addInputPasswordField ($fieldName, $fieldValue = "") { + // Is the form opened? + if (($this->formOpened === false) && ($this->formEnabled === true)) { + // Throw an exception + throw new FormClosedException (array($this, $fieldName), self::EXCEPTION_CLOSED_FORM); + } // END - if + + // Generate the content + $inputContent = sprintf("", + $fieldName, + $fieldName, + $fieldValue + ); + + // And add it + $this->addContentToPreviousGroup($inputContent); + } + + /** + * Add a hidden input tag to the form or throw an exception if it is not + * yet opened. The field's name will be set as id. + * + * @param $fieldName Input field name + * @param $fieldValue Input default value (default: empty) + * @return void + * @throws FormClosedException If the form is not yet opened + */ + public function addInputHiddenField ($fieldName, $fieldValue = "") { + // Is the form opened? + if (($this->formOpened === false) && ($this->formEnabled === true)) { + // Throw an exception + throw new FormClosedException (array($this, $fieldName), self::EXCEPTION_CLOSED_FORM); + } // END - if + + // Generate the content + $inputContent = sprintf("", + $fieldName, + $fieldValue + ); + + // And add it + $this->addContentToPreviousGroup($inputContent); + } + + /** + * Add a hidden input tag to the form with pre-loaded default value + * + * @param $fieldName Input field name + * @return void + */ + public function addInputHiddenFieldWithDefault ($fieldName) { + // Get the value from instance + $fieldValue = $this->getValueField($fieldName); + //* DEBUG: */ echo __METHOD__.":".$fieldName."=".$fieldValue."
\n"; + + // Add the text field + $this->addInputHiddenField($fieldName, $fieldValue); + } + + /** + * Add a hidden input tag to the form with configuration value + * + * @param $fieldName Input field name + * @param $prefix Prefix for configuration without trailing _ + * @return void + */ + public function addInputHiddenConfiguredField ($fieldName, $prefix) { + // Get the value from instance + $fieldValue = $this->getConfigInstance()->readConfig("{$prefix}_{$fieldName}"); + //* DEBUG: */ echo __METHOD__.":".$fieldName."=".$fieldValue."
\n"; + + // Add the text field + $this->addInputHiddenField($fieldName, $fieldValue); + } + + /** + * Add a checkbox input tag to the form or throw an exception if it is not + * yet opened. The field's name will be set as id. + * + * @param $fieldName Input field name + * @param $fieldChecked Wether the field is checked (defaut: checked) + * @return void + * @throws FormClosedException If the form is not yet opened + */ + public function addInputCheckboxField ($fieldName, $fieldChecked = true) { + // Is the form opened? + if (($this->formOpened === false) && ($this->formEnabled === true)) { + // Throw an exception + throw new FormClosedException (array($this, $fieldName), self::EXCEPTION_CLOSED_FORM); + } // END - if + + // Set wether the check box is checked... + $checked = " checked=\"checked\""; + if ($fieldChecked === false) $checked = " "; + + // Generate the content + $inputContent = sprintf("", + $fieldName, + $fieldName, + $checked + ); + + // And add it + $this->addContentToPreviousGroup($inputContent); + } + + /** + * Add a reset input tag to the form or throw an exception if it is not + * yet opened. The field's name will be set as id. + * + * @param $buttonText Text displayed on the button + * @return void + * @throws FormClosedException If the form is not yet opened + */ + public function addInputResetButton ($buttonText) { + // Is the form opened? + if (($this->formOpened === false) && ($this->formEnabled === true)) { + // Throw an exception + throw new FormClosedException (array($this, "reset"), self::EXCEPTION_CLOSED_FORM); + } // END - if + + // Generate the content + $inputContent = sprintf("", + $this->getFormName(), + $buttonText + ); + + // And add it + $this->addContentToPreviousGroup($inputContent); + } + + /** + * Add a reset input tag to the form or throw an exception if it is not + * yet opened. The field's name will be set as id. + * + * @param $buttonText Text displayed on the button + * @return void + * @throws FormClosedException If the form is not yet opened + */ + public function addInputSubmitButton ($buttonText) { + // Is the form opened? + if (($this->formOpened === false) && ($this->formEnabled === true)) { + // Throw an exception + throw new FormClosedException (array($this, "submit"), self::EXCEPTION_CLOSED_FORM); + } // END - if + + // Generate the content + $inputContent = sprintf("", + $this->getFormName(), + $this->getFormName(), + $buttonText + ); + + // And add it + $this->addContentToPreviousGroup($inputContent); + } + + /** + * Add a form group or close an already opened and open a new one + * + * @param $groupId Name of the group or last opened if empty + * @param $groupText Text including HTML to show above this group + * @return void + * @throws FormClosedException If no form has been opened before + * @throws EmptyVariableException If $groupId is not set + */ + public function addFormGroup ($groupId = "", $groupText = "") { + // Is a form opened? + if (($this->formOpened === false) && ($this->formEnabled === true)) { + // Throw exception here + throw new FormClosedException(array($this, $groupId), self::EXCEPTION_CLOSED_FORM); + } // END - if + + // At least the group name should be set + if ((empty($groupId)) && ($this->ifGroupOpenedPreviously() === false)) { + // Throw exception here + throw new EmptyVariableException(array($this, 'groupId'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); + } elseif (empty($groupId)) { + // Close the last opened + $groupId = $this->getPreviousGroupId(); + } + + // Same group to open? + if (($this->ifGroupOpenedPreviously() === false) && ($groupId === $this->getPreviousGroupId())) { + // Abort here silently + return false; + } // END - if + + // Initialize content with closing div by default + $content = " \n"; + + // Is this group opened? + if ($this->ifGroupOpenedPreviously() === false) { + // Begin the div/span blocks + $content = sprintf(" +
+ + %s + +
", + $groupId, + $groupId, + $groupId, + $groupText, + $groupId + ); + + // Switch the state + $this->openGroupByIdContent($groupId, $content, "div"); + } else { + // Is a sub group opened? + if ($this->ifSubGroupOpenedPreviously()) { + // Close it here + $this->addFormSubGroup(); + } // END - if + + // Get previous group id + $prevGroupId = $this->getPreviousGroupId(); + + // Switch the state + $this->closePreviousGroupByContent($content); + + // All call it again if group name is not empty + if ((!empty($groupId)) && ($groupId != $prevGroupId)) { + //* DEBUG: */ echo $groupId."/".$prevGroupId."
\n"; + $this->addFormGroup($groupId, $groupText); + } // END - if + } + } + + /** + * Add a form sub group or close an already opened and open a new one or + * throws an exception if no group has been opened before or if sub group + * name is empty. + * + * @param $subGroupId Name of the group or last opened if empty + * @param $subGroupText Text including HTML to show above this group + * @return void + * @throws FormFormClosedException If no group has been opened before + * @throws EmptyVariableException If $subGroupId is not set + */ + public function addFormSubGroup ($subGroupId = "", $subGroupText = "") { + // Is a group opened? + if ($this->ifGroupOpenedPreviously() === false) { + // Throw exception here + throw new FormFormClosedException(array($this, $subGroupId), self::EXCEPTION_UNEXPECTED_CLOSED_GROUP); + } // END - if + + // At least the sub group name should be set + if ((empty($subGroupId)) && ($this->ifSubGroupOpenedPreviously() === false)) { + // Throw exception here + throw new EmptyVariableException(array($this, 'subGroupId'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); + } elseif (empty($subGroupId)) { + // Close the last opened + $subGroupId = $this->getPreviousSubGroupId(); + } + + // Same sub group to open? + if (($this->ifSubGroupOpenedPreviously() === false) && ($subGroupId == $this->getPreviousSubGroupId())) { + // Abort here silently + return false; + } // END - if + + // Initialize content with closing div by default + $content = "
\n
"; + + // Is this group opened? + if ($this->ifSubGroupOpenedPreviously() === false) { + // Begin the span block + $content = sprintf(" +
+ + %s + +
", + $subGroupId, + $subGroupId, + $subGroupId, + $subGroupText, + $subGroupId + ); + + // Switch the state and remeber the name + $this->openSubGroupByIdContent($subGroupId, $content, "div"); + } else { + // Get previous sub group id + $prevSubGroupId = $this->getPreviousSubGroupId(); + + // Switch the state + $this->closePreviousSubGroupByContent($content); + + // All call it again if sub group name is not empty + if ((!empty($subGroupId)) && ($subGroupId != $prevSubGroupId)) { + $this->addFormSubGroup($subGroupId, $subGroupText); + } // END - if + } + } + + /** + * Add text surrounded by a span block when there is a group opened before + * or else by a div block. + * + * @param $fieldName Field name + * @param $fieldText Text for the field + * @return void + * @throws FormClosedException If the form is not yet opened + */ + public function addFieldText ($fieldName, $fieldText) { + // Is the form opened? + if (($this->formOpened === false) && ($this->formEnabled === true)) { + // Throw an exception + throw new FormClosedException (array($this, $fieldName), self::EXCEPTION_CLOSED_FORM); + } // END - if + + // Set the block type + $block = "div"; + if ($this->ifGroupOpenedPreviously()) $block = "span"; + + // Generate the content + $inputContent = sprintf(" <%s id=\"%s_text\"> + %s + ", + $block, + $fieldName, + $fieldText, + $block + ); + + // And add it + $this->addContentToPreviousGroup($inputContent); + } + + /** + * Add text (notes) surrounded by a div block. Still opened groups or sub + * groups will be automatically closed. + * + * @param $noteId Id for this note + * @param $formNotes The form notes we shell addd + * @return void + * @throws FormClosedException If the form is not yet opened + */ + public function addFormNote ($noteId, $formNotes) { + // Is the form opened? + if (($this->formOpened === false) && ($this->formEnabled === true)) { + // Throw an exception + throw new FormClosedException (array($this, "form_notes"), self::EXCEPTION_CLOSED_FORM); + } // END - if + + // Generate the content + $inputContent = sprintf("
+ %s +
", + $noteId, + $formNotes + ); + + // And add it + $this->addContentToPreviousGroup($inputContent); + } + + /** + * Adds a selection box as a sub group to the form. Do not box this into + * another sub group. Sub-sub groups are not (yet) supported. + * + * @param $selectId Id of the selection box + * @param $firstEntry Content to be added as first non-selectable entry + * @return void + * @throws FormClosedException If the form is not yet opened + */ + public function addInputSelectField ($selectId, $firstEntry) { + // Is the form group opened? + if (($this->formOpened === false) && ($this->formEnabled === true)) { + // Throw an exception + throw new FormClosedException (array($this, "form_notes"), self::EXCEPTION_CLOSED_FORM); + } // END - if + + // Shall we close or open the sub group? + if (($this->ifSubGroupOpenedPreviously() === false) && ($this->getPreviousSubGroupId() !== $selectId)) { + // Initialize first entry (which might be non-selectable if content is provided + if (!empty($firstEntry)) { + // Add selection around it + $firstEntry = sprintf("\n", + $firstEntry + ); + } // END - if + + // Construct the opening select tag + $content = sprintf(""); + } + } + + /** + * Adds a non-selectable sub option to a previously added selection box. + * This method does *not* validate if there is already a sub option added + * with the same name. We need to finish this here! + * + * @param $subName Name of the sub action + * @param $subValue Value of the sub action + * @return void + * @throws HelperNoPreviousOpenedSubGroupException If no previously opened sub group was found + * @todo Add checking if sub option is already added + */ + public function addSelectSubOption ($subName, $subValue) { + // Is there a sub group (shall be a selection box!) + if ($this->ifSubGroupOpenedPreviously() === false) { + // Then throw an exception here + throw new HelperNoPreviousOpenedSubGroupException(array($this, $content), self::EXCEPTION_NO_PREVIOUS_SUB_GROUP_OPENED); + } // END - if + + // Render the content + $content = sprintf("\n", + $subName, + $subValue + ); + + // Add the content to the previously opened sub group + $this->addContentToPreviousGroup($content); + } + + /** + * Adds a selectable option to a previously added selection box. This method + * does *not* validate if there is already a sub option added with the same + * name. We need to finish this here! + * + * @param $optionName Name of the sub action + * @param $optionValue Value of the sub action + * @return void + * @throws HelperNoPreviousOpenedSubGroupException If no previously opened sub group was found + * @todo Add checking if sub option is already added + */ + public function addSelectOption ($optionName, $optionValue) { + // Is there a sub group (shall be a selection box!) + if ($this->ifSubGroupOpenedPreviously() === false) { + // Then throw an exception here + throw new HelperNoPreviousOpenedSubGroupException(array($this, $content), self::EXCEPTION_NO_PREVIOUS_SUB_GROUP_OPENED); + } // END - if + + // Render the content + $content = sprintf("\n", + $optionName, + $optionName, + $optionValue + ); + + // Add the content to the previously opened sub group + $this->addContentToPreviousGroup($content); + } + + /** + * Adds a pre-configured CAPTCHA + * + * @return void + */ + public function addCaptcha () { + // Get last executed pre filter + $extraInstance = Registry::getRegistry()->getInstance('extra'); + + // Get a configured instance + $captchaInstance = ObjectFactory::createObjectByConfiguredName($this->getFormName().'_captcha', array($this, $extraInstance)); + + // Initiate the CAPTCHA + $captchaInstance->initiateCaptcha(); + + // Render the CAPTCHA code + $captchaInstance->renderCode(); + + // Get the content and add it to the helper + $this->addContentToPreviousGroup($captchaInstance->renderContent()); + } + + /** + * Enables/disables the form tag usage + * + * @param $formEnabled Wether form is enabled or disabled + * @return void + */ + public final function enableForm ($formEnabled = true) { + $this->formEnabled = (bool) $formEnabled; + } + + /** + * Setter for form name + * + * @param $formName Name of this form + * @return void + */ + public final function setFormName ($formName) { + $this->formName = (string) $formName; + } + + /** + * Getter for form name + * + * @return $formName Name of this form + */ + public final function getFormName () { + return $this->formName; + } + + /** + * Checks wether the registration requires a valid email address + * + * @return $required Wether the email address is required + */ + public function ifRegisterRequiresEmailVerification () { + $required = ($this->getConfigInstance()->readConfig('register_requires_email') === "Y"); + return $required; + } + + /** + * Checks wether profile data shall be asked + * + * @return $required Wether profile data shall be asked + */ + public function ifRegisterIncludesProfile () { + $required = ($this->getConfigInstance()->readConfig('register_includes_profile') === "Y"); + return $required; + } + + /** + * Checks wether this form is secured by a CAPTCHA + * + * @return $isSecured Wether this form is secured by a CAPTCHA + */ + public function ifFormSecuredWithCaptcha () { + $isSecured = ($this->getConfigInstance()->readConfig($this->getFormName().'_captcha_secured') === "Y"); + return $isSecured; + } + + /** + * Flushs the content out (not yet secured against open forms, etc.!) or + * close the form automatically + * + * @return void + * @throws FormOpenedException If the form is still open + */ + public function flushContent () { + // Is the form still open? + if (($this->formOpened === true) && ($this->formEnabled === true)) { + // Close the form automatically + $this->addFormTag(); + } elseif ($this->formEnabled === false) { + if ($this->ifSubGroupOpenedPreviously()) { + // Close sub group + $this->addFormSubGroup(); + } elseif ($this->ifGroupOpenedPreviously()) { + // Close group + $this->addFormGroup(); + } + } + + // Send content to template engine + //* DEBUG: */ echo __METHOD__.": form=".$this->getFormName().", size=".strlen($this->renderContent())."
\n"; + $this->getTemplateInstance()->assignVariable($this->getFormName(), $this->renderContent()); + } +} + +// [EOF] +?> diff --git a/inc/classes/main/helper/web/links/.htaccess b/inc/classes/main/helper/web/links/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/helper/web/links/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/helper/web/links/class_WebLinkHelper.php b/inc/classes/main/helper/web/links/class_WebLinkHelper.php new file mode 100644 index 00000000..1a238a6d --- /dev/null +++ b/inc/classes/main/helper/web/links/class_WebLinkHelper.php @@ -0,0 +1,289 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class WebLinkHelper extends BaseWebHelper implements HelpableTemplate { + /** + * Name of the link + */ + private $linkName = ""; + + /** + * Base of the link + */ + private $linkBase = ""; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates the helper class + * + * @param $templateInstance An instance of a template engine + * @param $linkName Name of the link we shall generate + * @param $linkBase Link base for all generated links + * @return $helperInstance A prepared instance of this helper + */ + public final static function createWebLinkHelper (CompileableTemplate $templateInstance, $linkName, $linkBase) { + // Get new instance + $helperInstance = new WebLinkHelper(); + + // Set template instance + $helperInstance->setTemplateInstance($templateInstance); + + // Set link name + $helperInstance->setLinkName($linkName); + + // Set link base + $helperInstance->setLinkBase($linkBase); + + // Add default group + $helperInstance->openGroupByIdContent('main', "", ""); + + // Return the prepared instance + return $helperInstance; + } + + /** + * Renders the link content (HTML code) with given link text and optional + * extra content + * + * @param $linkText Link text to set in link + * @param $extraContent Optional extra HTML content + * @return $linkContent Rendered text link content + */ + private function renderLinkContentWithTextExtraContent ($linkText, $extraContent="") { + // Construct link content + $linkContent = sprintf("%s", + $this->getLinkBase(), + $extraContent, + $linkText, + $linkText + ); + + // Return it + return $linkContent; + } + + /** + * Setter for link name + * + * @param $linkName Name of the link we shall generate + * @return void + */ + protected final function setLinkName ($linkName) { + $this->linkName = (string) $linkName; + } + + /** + * Getter for link name + * + * @return $linkName Name of the link we shall generate + */ + public final function getLinkName () { + return $this->linkName; + } + + /** + * Setter for link base + * + * @param $linkBase Base of the link we shall generate + * @return void + */ + protected final function setLinkBase ($linkBase) { + $this->linkBase = (string) $linkBase; + } + + /** + * Getter for link base + * + * @return $linkBase Base of the link we shall generate + */ + public final function getLinkBase () { + return $this->linkBase; + } + + /** + * Flush the content out,e g. to a template variable + * + * @return void + * @todo Completely unimplemented + */ + public function flushContent () { + // Is a previous opened group still open? + if ($this->ifGroupOpenedPreviously()) { + // Then close it + $this->closePreviousGroupByContent(""); + } // END - if + + // Get the content + $content = $this->renderContent(); + + // Get template engine + $templateInstance = $this->getTemplateInstance(); + + // Add content to variable + $templateInstance->assignVariable($this->getLinkName(), $content); + } + + /** + * Adds a link group (like the form group is) with some raw language to the + * helper. + * + * @param $groupId Id string of the group + * @param $groupText Text for this group to add + * @param $groupCode Code to open and close groups + * @return void + */ + public function addLinkGroup ($groupId, $groupText, $groupCode = "div") { + // Is a group with that name open? + if ($this->ifGroupOpenedPreviously()) { + // Then close it here + $this->closePreviousGroupByContent(""); + } // END - if + + // Generate the group content + $content = sprintf("<{$groupCode} id=\"group_%s_%s\">%s", + $this->getLinkName(), + $groupId, + $groupText + ); + + // Open the new group + $this->openGroupByIdContent($groupId, $content, $groupCode); + } + + /** + * Adds text (note) to the previously opened group or throws an exception + * if no previous group was opened. + * + * @param $groupId Group id to set + * @param $groupNote Note to be added to a group + * @param $groupCode Code to open and close groups + * @return void + * @throws NoGroupOpenedException If no previous group was opened + */ + public function addLinkNote ($groupId, $groupNote, $groupCode = "div") { + // Check if a previous group was opened + if ($this->ifGroupOpenedPreviously() === false) { + // No group was opened before! + throw new NoGroupOpenedException(array($this, $groupNote), self::EXCEPTION_GROUP_NOT_OPENED); + } // END - if + + // Is a previous sub group open? + if ($this->ifSubGroupOpenedPreviously()) { + // Then close it + $this->closePreviousSubGroupByContent(""); + } // END - if + + // Generate the group content + $content = sprintf("<{$groupCode} id=\"subgroup_%s_%s\">%s", + $this->getLinkName(), + $groupId, + $groupNote + ); + + // Open the sub group + $this->openSubGroupByIdContent($groupId, $content, $groupCode); + } + + /** + * Adds a link to the previously opened group or throws an exception if no group has been opened + * + * @param $linkAction Action (action=xxx) value for the link + * @param $linkText Link text and title (title="xxx") for the link + * @return void + * @throws NoGroupOpenedException If no previous group was opened + */ + public function addActionLink ($linkAction, $linkText) { + // Check if a previous group was opened + if ($this->ifGroupOpenedPreviously() === false) { + // No group was opened before! + throw new NoGroupOpenedException(array($this, $linkAction."(".$linkText.")"), self::EXCEPTION_GROUP_NOT_OPENED); + } // END - if + + // Default parameter seperator is & + $seperator = "&"; + + // Is there a question mark in? + $linkArray = explode("?", $this->getLinkBase()); + if (count($linkArray) == 0) { + // No question mark + $seperator = "?"; + } // END - if + + // Prepare action + $action = sprintf("%saction=%s", + $seperator, + $linkAction + ); + + // Renders the link content + $linkContent = $this->renderLinkContentWithTextExtraContent($linkText, $action); + + // Add the content to the previous group + $this->addContentToPreviousGroup($linkContent); + } + + /** + * Adds a link to the previously opened group with a text from language system + * + * @param $linkAction Action (action=xxx) value for the link + * @param $languageId Language id string to use + * @return void + */ + public function addActionLinkById ($linkAction, $languageId) { + // Resolve the language string + $languageResolved = $this->getLanguageInstance()->getMessage($languageId); + + // Add the action link + $this->addActionLink($linkAction, $languageResolved); + } + + /** + * Adds a default link (no extra parameters) to the content with specified + * language id string. + * + * @param $languageId Language id string to use + * @return void + */ + public function addLinkWithTextById ($languageId) { + // Resolve the language string + $languageResolved = $this->getLanguageInstance()->getMessage($languageId); + + // Now add the link + $linkContent = $this->renderLinkContentWithTextExtraContent($languageResolved); + + // Add the content to the previous group + $this->addContentToPreviousGroup($linkContent); + } +} + +// [EOF] +?> diff --git a/inc/classes/main/images/.htaccess b/inc/classes/main/images/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/images/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/images/class_ b/inc/classes/main/images/class_ new file mode 100644 index 00000000..69b41005 --- /dev/null +++ b/inc/classes/main/images/class_ @@ -0,0 +1,53 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ???Image extends BaseImage { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this image class + * + * @return $imageInstance An instance of this image class + */ + public final static function create???Image() { + // Get a new instance + $imageInstance = new ???Image(); + + // Set image type + $imageInstance->setImageType("???"); + + // Return the instance + return $imageInstance; + } +} + +// [EOF] +?> diff --git a/inc/classes/main/images/class_BaseImage.php b/inc/classes/main/images/class_BaseImage.php new file mode 100644 index 00000000..7f667cde --- /dev/null +++ b/inc/classes/main/images/class_BaseImage.php @@ -0,0 +1,549 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseImage extends BaseFrameworkSystem implements Registerable { + /** + * Image type + */ + private $imageType = ""; + + /** + * Width of the image + */ + private $width = ""; + + /** + * Height of the image + */ + private $height = ""; + + /** + * Background color in RGB + */ + private $backgroundColor = array( + 'red' => "", + 'green' => "", + 'blue' => "" + ); + + /** + * Foreground color in RGB + */ + private $foregroundColor = array( + 'red' => "", + 'green' => "", + 'blue' => "" + ); + + /** + * Current choosen color array + */ + private $colorMode = ""; + + /** + * Image resource + */ + private $imageResource = null; + + /** + * Image name + */ + private $imageName = ""; + + /** + * String name + */ + private $stringName = ""; + + /** + * Groupable image strings? + */ + private $groupable = "single"; + + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + + // Clean up a little + $this->removeNumberFormaters(); + $this->removeSystemArray(); + } + + /** + * Private setter for all colors + * + * @param $colorMode Wether background or foreground color + * @param $colorChannel Red, green or blue channel? + * @param $colorValue Value to set + */ + private final function setColor ($colorMode, $colorChannel, $colorValue) { + // Construct the eval() command + $eval = sprintf("\$this->%s['%s'] = \"%s\";", + $colorMode, + $colorChannel, + $colorValue + ); + + // Run the command + //* DEBUG: */ echo "mode={$colorMode}, channel={$colorChannel}, value={$colorValue}
\n"; + eval($eval); + } + + /** + * Setter for image width + * + * @param $width Width of the image + * @return void + */ + public final function setWidth ($width) { + $this->width = $width; + } + + /** + * Getter for image width + * + * @return $width Width of the image + */ + public final function getWidth () { + return $this->width; + } + + /** + * Setter for image height + * + * @param $height Height of the image + * @return void + */ + public final function setHeight ($height) { + $this->height = $height; + } + + /** + * Getter for image height + * + * @return $height Height of the image + */ + public final function getHeight () { + return $this->height; + } + + /** + * Finish the type handling (unused at the moment) + * + * @return void + * @todo Find something usefull for this method. + */ + public function finishType () { + // Empty at the momemt + } + + /** + * Prepares the class for resolution (unused at the moment) + * + * @return void + * @todo Find something usefull for this method. + */ + public function initResolution () { + // Empty at the momemt + } + + /** + * Finish resolution handling (unused at the moment) + * + * @return void + * @todo Find something usefull for this method. + */ + public function finishResolution () { + // Empty at the momemt + } + + /** + * Prepares the class for base (unused at the moment) + * + * @return void + * @todo Find something usefull for this method. + */ + public function initBase () { + // Empty at the momemt + } + + /** + * Finish base handling (unused at the moment) + * + * @return void + * @todo Find something usefull for this method. + */ + public function finishBase () { + // Empty at the momemt + } + + /** + * Prepares the class for background color + * + * @return void + */ + public function initBackgroundColor () { + $this->colorMode = "backgroundColor"; + } + + /** + * Finish background color handling + * + * @return void + * @todo Find something usefull for this method. + */ + public function finishBackgroundColor () { + // Empty at the moment + } + + /** + * Prepares the class for foreground color + * + * @return void + */ + public function initForegroundColor () { + $this->colorMode = "foregroundColor"; + } + + /** + * Finish foreground color handling + * + * @return void + * @todo Find something usefull for this method. + */ + public function finishForegroundColor () { + // Empty at the moment + } + + /** + * Prepares the class for string (unused at the moment) + * + * @param $groupable Wether this image string is groupable or single + * @return void + * @todo Find something usefull for this method. + */ + public function initImageString ($groupable = "single") { + $this->groupable = $groupable; + } + + /** + * Finish string handling (unused at the moment) + * + * @return void + * @todo Find something usefull for this method. + */ + public function finishImageString () { + // Empty at the momemt + } + + /** + * Setter for red color + * + * @param $red Red color value + * @return void + */ + public final function setRed ($red) { + // Get array name + $arrayName = $this->colorMode; + + // Set image color + $this->setColor($arrayName, 'red', $red); + } + + /** + * Setter for green color + * + * @param $green Green color value + * @return void + */ + public final function setGreen ($green) { + // Get array name + $arrayName = $this->colorMode; + + // Set image color + $this->setColor($arrayName, 'green', $green); + } + + /** + * Setter for blue color + * + * @param $blue Blue color value + * @return void + */ + public final function setBlue ($blue) { + // Get array name + $arrayName = $this->colorMode; + + // Set image color + $this->setColor($arrayName, 'blue', $blue); + } + + /** + * Setter for image string + * + * @param $string String to set in image + * @return void + */ + public final function setString ($string) { + $this->imageString = (string) $string; + } + + /** + * Getter for image string + * + * @return $string String to set in image + */ + public final function getString () { + return $this->imageString; + } + + /** + * Setter for image type + * + * @param $imageType Type to set in image + * @return void + */ + protected final function setImageType ($imageType) { + $this->imageType = (string) $imageType; + } + + /** + * Getter for image type + * + * @return $imageType Type to set in image + */ + public final function getImageType () { + return $this->imageType; + } + + /** + * Setter for image name + * + * @param $name Name of the image + * @return void + */ + public final function setImageName ($name) { + $this->imageName = (string) $name; + } + + /** + * Getter for image name + * + * @return $name Name of the image + */ + public final function getImageName () { + return $this->imageName; + } + + /** + * Getter for image resource + * + * @return $imageResource An image resource from imagecreatetruecolor() function + */ + public final function getImageResource() { + return $this->imageResource; + } + + /** + * Setter for X coordinate + * + * @param $x X coordinate + * @return void + */ + public final function setX ($x) { + $this->x = $x; + } + + /** + * Getter for X coordinate + * + * @return $x X coordinate + */ + public final function getX () { + return $this->x; + } + + /** + * Setter for Y coordinate + * + * @param $y Y coordinate + * @return void + */ + public final function setY ($y) { + $this->y = $y; + } + + /** + * Getter for Y coordinate + * + * @return $y Y coordinate + */ + public final function getY () { + return $this->y; + } + + /** + * Setter for font size + * + * @param $fontSize Font size for strings + * @return void + */ + public final function setFontSize ($fontSize) { + $this->fontSize = $fontSize; + } + + /** + * Getter for font size + * + * @return $fontSize Font size for strings + */ + public final function getFontSize () { + return $this->fontSize; + } + + /** + * Setter for string name + * + * @param $stringName String name to set + * @return void + */ + public final function setStringName($stringName) { + $this->stringName = $stringName; + } + + /** + * Finish this image by producing it + * + * @return void + */ + public function finishImage () { + // Get template instance + $templateInstance = $this->getTemplateInstance(); + + // Compile width and height + $width = $templateInstance->compileRawCode($this->getWidth()); + $height = $templateInstance->compileRawCode($this->getHeight()); + + // Set both again + $this->setWidth($width); + $this->setHeight($height); + + // Get a image resource + $this->imageResource = imagecreatetruecolor($width, $height); + + // Compile background colors + $red = $templateInstance->compileRawCode($this->backgroundColor['red']); + $green = $templateInstance->compileRawCode($this->backgroundColor['green']); + $blue = $templateInstance->compileRawCode($this->backgroundColor['blue']); + + // Set all back + $this->initBackgroundColor(); + $this->setRed($red); + $this->setGreen($green); + $this->setBlue($blue); + + // Get a pointer for background color + $backColor = imagecolorallocate($this->getImageResource(), $red, $green, $blue); + + // Fill the image + imagefill($this->getImageResource(), 0, 0, $backColor); + + // Compile foreground colors + $red = $templateInstance->compileRawCode($this->foregroundColor['red']); + $green = $templateInstance->compileRawCode($this->foregroundColor['green']); + $blue = $templateInstance->compileRawCode($this->foregroundColor['blue']); + + // Set all fore + $this->initForegroundColor(); + $this->setRed($red); + $this->setGreen($green); + $this->setBlue($blue); + + // Get a pointer for foreground color + $foreColor = imagecolorallocate($this->getImageResource(), $red, $green, $blue); + + switch ($this->groupable) { + case "single": // Single image string + // Compile image string + $imageString = $templateInstance->compileRawCode($this->getString()); + + // Set it back + $this->setString($imageString); + + // Compile X/Y coordinates and font size + $x = $templateInstance->compileRawCode($this->getX()); + $y = $templateInstance->compileRawCode($this->getY()); + $size = $templateInstance->compileRawCode($this->getFontSize()); + + // Set the image string + imagestring($this->getImageResource(), $size, $x, $y, $imageString, $foreColor); + break; + + case "groupable": // More than one string allowed + // Walk through all groups + foreach ($templateInstance->getVariableGroups() as $group => $set) { + // Set the group + $templateInstance->setVariableGroup($group, false); + + // Compile image string + $imageString = $templateInstance->compileRawCode($this->getString()); + + // Compile X/Y coordinates and font size + $x = $templateInstance->compileRawCode($this->getX()); + $y = $templateInstance->compileRawCode($this->getY()); + $size = $templateInstance->compileRawCode($this->getFontSize()); + + // Set the image string + //* DEBUG: */ echo __METHOD__.": size={$size}, x={$x}, y={$y}, string={$imageString}
\n"; + imagestring($this->getImageResource(), $size, $x, $y, $imageString, $foreColor); + } // END - foreach + break; + } + + // You need finishing in your image class! + } + + /** + * Getter for full created image content + * + * @return $imageContent The raw image content + */ + public function getContent () { + // Get cache file name + $cacheFile = $this->getTemplateInstance()->getImageCacheFqfn(); + + // Load the content + $imageContent = file_get_contents($cacheFile); + + // And return it + return $imageContent; + } +} +// [EOF] +?> diff --git a/inc/classes/main/images/extended/.htaccess b/inc/classes/main/images/extended/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/images/extended/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/images/extended/class_PngImage.php b/inc/classes/main/images/extended/class_PngImage.php new file mode 100644 index 00000000..8b033209 --- /dev/null +++ b/inc/classes/main/images/extended/class_PngImage.php @@ -0,0 +1,79 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class PngImage extends BaseImage { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this image class + * + * @param $templateInstance A template instance + * @return $imageInstance An instance of this image class + */ + public final static function createPngImage(CompileableTemplate $templateInstance) { + // Get a new instance + $imageInstance = new PngImage(); + + // Set template instance + $imageInstance->setTemplateInstance($templateInstance); + + // Set image type + $imageInstance->setImageType('png'); + + // Return the instance + return $imageInstance; + } + + /** + * Finish this image by producing it + * + * @return void + */ + public function finishImage () { + // Call parent method + parent::finishImage(); + + // Get a file name for our image + $cacheFile = $this->getTemplateInstance()->getImageCacheFqfn(); + + // Does it exist? + if (file_exists($cacheFile)) { + // Remove it + @unlink($cacheFile); + } // END - if + + // Finish the image and send it to a cache file + imagepng($this->getImageResource(), $cacheFile, 9, PNG_ALL_FILTERS); + } +} + +// [EOF] +?> diff --git a/inc/classes/main/io/.htaccess b/inc/classes/main/io/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/io/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/io/class_FileIoStream.php b/inc/classes/main/io/class_FileIoStream.php new file mode 100644 index 00000000..7e257be4 --- /dev/null +++ b/inc/classes/main/io/class_FileIoStream.php @@ -0,0 +1,226 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class FileIoStream extends BaseFrameworkSystem implements FileInputStreamer, FileOutputStreamer { + /** + * Protected constructor + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Clean-up a little + $this->removeNumberFormaters(); + $this->removeSystemArray(); + } + + /** + * Create a file IO stream. This is a class for performing all actions + * on files like creating, deleting and loading them. + * + * @return $ioInstance An instance of FileIoStream + */ + public final static function createFileIoStream () { + // Create new instance + $ioInstance = new FileIoStream(); + + // Return the instance + return $ioInstance; + } + + /** + * Saves data to a given local file + * + * @param $fileName The file name for the to be saved file + * @param $dataArray The data we shall store to the file + * @return void + * @see FileOutputStreamer + */ + public final function saveFile ($fileName, $dataArray) { + // Try it five times + $dirName = ""; $fileInstance = null; + for ($idx = 0; $idx < 5; $idx++) { + // Get a file output pointer + try { + $fileInstance = FrameworkFileOutputPointer::createFrameworkFileOutputPointer($fileName, 'w'); + } catch (FilePointerNotOpenedException $e) { + // Create missing directory + $dirName = dirname($fileName); + for ($idx2 = 0; $idx2 < (2 - $idx); $idx2++) { + $dirName = dirname($dirName); + } + // Try to create it + @mkdir($dirName); + } + } + + // Write a header information for validation purposes + $fileInstance->writeToFile(sprintf("@head^%s:%s:%s:%s\n", + $dataArray[0], + time(), + strlen($dataArray[1]), + md5($dataArray[1]) + )); + + // Encode the (maybe) binary stream with Base64 + $b64Stream = base64_encode($dataArray[1]); + + // write the data line by line + $line = str_repeat(" ", 50); $idx = 0; + while (strlen($line) == 50) { + // Get 50 chars or less + $line = substr($b64Stream, $idx, 50); + + // Save it to the stream + $fileInstance->writeToFile(sprintf("@data^%s:%s\n", + $line, + md5($line) + )); + + // Advance to the next 50-chars block + $idx += 50; + } + + // Close the file + $fileInstance->closeFile(); + } + + /** + * Reads from a local file + * + * @param $fqfn The full-qualified file-name which we shall load + * @return $array An array with the element 'header' and 'data' + * @see FileInputStreamer + */ + public final function loadFileContents ($fqfn) { + // Initialize some variables and arrays + $inputBuffer = ""; + $lastBuffer = ""; + $header = array(); + $data = array(); + $readData = ""; // This will contain our read data + + // Get a file input handler + $fileInstance = FrameworkFileInputPointer::createFrameworkFileInputPointer($fqfn); + + // Read all it's contents (we very and transparently decompress it below) + while ($readRawLine = $fileInstance->readFromFile()) { + // Add the read line to the buffer + $inputBuffer .= $readRawLine; + + // Break infinite loop maybe caused by the input handler + if ($lastBuffer == $inputBuffer) break; + + // Remember last read line for avoiding possible infinite loops + $lastBuffer = $inputBuffer; + } + + // Close directory handle + $fileInstance->closeFile(); + + // Convert it into an array + $inputBuffer = explode("\n", $inputBuffer); + + // Now process the read lines and verify it's content + foreach ($inputBuffer as $rawLine) { + // Trim it a little but not the leading spaces/tab-stops + $rawLine = rtrim($rawLine); + + // Analyze this line + if (substr($rawLine, 0, 5) == "@head") { + // Header found, so let's extract it + $header = explode("^", $rawLine); + $header = trim($header[1]); + + // Now we must convert it again into an array + $header = explode(":", $header); + + // Is the header (maybe) valid? + if (count($header) != 4) { + // Throw an exception + throw new InvalidArrayCountException(array($this, 'header', count($header), 4), self::EXCEPTION_ARRAY_HAS_INVALID_COUNT); + } + } elseif (substr($rawLine, 0, 5) == "@data") { + // Is a data line! + $data = explode("^", $rawLine); + $data = $data[1]; + + // First element is the data, second the MD5 checksum + $data = explode(":", $data); + + // Validate the read line + if (count($data) == 2) { + if (md5($data[0]) != $data[1]) { + // MD5 hash did not match! + throw new InvalidMD5ChecksumException(array($this, md5($data[0]), $data[1]), self::EXCEPTION_MD5_CHECKSUMS_MISMATCH); + } + } else { + // Invalid count! + throw new InvalidArrayCountException(array($this, "data", count($data), 2), self::EXCEPTION_ARRAY_HAS_INVALID_COUNT); + } + + // Add this to the readData string + $readData .= $data[0]; + } else { + // Other raw lines than header/data tagged lines and re-add the new-line char + $readData .= $rawLine."\n"; + } + } + + // Was raw lines read and no header/data? + if ((!empty($readData)) && (count($header) == 0) && (count($data) == 0)) { + // Return raw lines back + return $readData; + } + + // Was a header found? + if (count($header) != 4) { + // Throw an exception + throw new InvalidArrayCountException(array($this, 'header', count($header), 4), self::EXCEPTION_ARRAY_HAS_INVALID_COUNT); + } + + // Decode all from Base64 + $readData = @base64_decode($readData); + + // Does the size match? + if (strlen($readData) != $header[2]) { + // Size did not match + throw new InvalidDataLengthException(array($this, strlen($readData), $header[2]), self::EXCEPTION_UNEXPECTED_STRING_SIZE); + } + + // Validate the decoded data with the final MD5 hash + if (md5($readData) != $header[3]) { + // MD5 hash did not match! + throw new InvalidMD5ChecksumException(array($this, md5($readData), $header[3]), self::EXCEPTION_MD5_CHECKSUMS_MISMATCH); + } + + // Return all in an array + return array( + 'header' => $header, + 'data' => $readData + ); + } +} + +// [EOF] +?> diff --git a/inc/classes/main/io/class_FrameworkDirectoryPointer.php b/inc/classes/main/io/class_FrameworkDirectoryPointer.php new file mode 100644 index 00000000..ccbb545e --- /dev/null +++ b/inc/classes/main/io/class_FrameworkDirectoryPointer.php @@ -0,0 +1,240 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class FrameworkDirectoryPointer extends BaseFrameworkSystem { + /** + * The current path we are working in + */ + private $pathName = ""; + + /** + * The directory pointer + */ + private $dirPointer = null; + + /** + * Protected constructor + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Clean-up a little + $this->removeNumberFormaters(); + $this->removeSystemArray(); + } + + /** + * Destructor for cleaning purposes, etc + */ + public function __destruct() { + // Is there a resource pointer? Then we have to close the directory here! + if (is_resource($this->getPointer())) { + // Try to close a directory + $this->closeDirectory(); + } + + // Call the parent destructor + parent::__destruct(); + } + + /** + * Create a directory pointer based on the given path. The path will also + * be verified here. + * + * @param $pathName The path name we shall pass + * to opendir() + * @param $inConstructor If we are in de/con-structor + * or from somewhere else + * @throws PathIsEmptyException If the provided path name + * is empty + * @throws InvalidPathStringException If the provided path name is + * not a string + * @throws PathIsNoDirectoryException If the provided path name is + * not valid + * @throws PathReadProtectedException If the provided path name is + * read-protected + * @throws DirPointerNotOpened If opendir() returns not a + * directory resource + * @return $pointerInstance A prepared instance of + * FrameworkDirectoryPointer + */ + public final static function createFrameworkDirectoryPointer ($pathName, $inConstructor = false) { + // Some pre-sanity checks... + if (is_null($pathName)) { + // No pathname given + if ($inConstructor) { + return null; + } else { + throw new PathIsEmptyException(null, self::EXCEPTION_UNEXPECTED_EMPTY_STRING); + } + } elseif (!is_string($pathName)) { + // Is not a string + if ($inConstructor) { + return null; + } else { + throw new InvalidPathStringException(null, self::EXCEPTION_INVALID_STRING); + } + } elseif (!is_dir($pathName)) { + // Not a directory + if ($inConstructor) { + return null; + } else { + throw new PathIsNoDirectoryException($pathName, self::EXCEPTION_INVALID_PATH_NAME); + } + } elseif (!is_readable($pathName)) { + // Not readable + if ($inConstructor) { + return null; + } else { + throw new PathReadProtectedException($pathName, self::EXCEPTION_READ_PROTECED_PATH); + } + } + + // Try to open a handler + $dirPointer = @opendir($pathName); + if (!is_resource($dirPointer)) { + // Something bad happend + if ($inConstructor) { + return null; + } else { + throw new DirPointerNotOpenedException($pathName, self::EXCEPTION_DIR_POINTER_INVALID); + } + } + + // Create new instance + $pointerInstance = new FrameworkDirectoryPointer(); + + // Set directory pointer and path name + $pointerInstance->setPointer($dirPointer); + $pointerInstance->setPathName($pathName); + + // Return the instance + return $pointerInstance; + } + + /** + * Read raw lines of data from a directory pointer and return the data + * + * @return string Directory and/or file names read from the current + * directory pointer + */ + public function readRawDirectory () { + // Read data from the directory pointer and return it + return readdir($this->getPointer()); + } + + /** + * Read lines from the current directory pointer except some parts + * + * @param $except Some parts of a directory we want to ignore. + * Valid: dirs + * Other values will be silently ignored + * @return string Directory and/or file names read from the current + * directory pointer + */ + public function readDirectoryExcept ($except = "") { + if ((empty($except)) || (!is_array($except)) || (count($except) == 0)) { + // No exception given, so read all data + return $this->readRawDirectory(); + } + + // Read a raw line... + $rawLine = $this->readRawDirectory(); + + // Shall we exclude directories? + if ((!is_null($rawLine)) && ($rawLine !== false) && (in_array($rawLine, $except))) { + // Exclude this part + return $this->readDirectoryExcept($except); + } elseif ((!is_null($rawLine)) && ($rawLine !== false)) { + // Return read data + return $rawLine; + } + + // End pointer reached + return null; + } + + /** + * Close a directory source and set it's instance to null and the path name + * to empty + * + * @return void + */ + public function closeDirectory () { + // Close the directory pointer and reset the instance variable + @closedir($this->getPointer()); + $this->setPointer(null); + $this->setPathName(""); + } + + /** + * Setter for the directory pointer + * + * @param $dirPointer The directory resource + * @return void + */ + public final function setPointer ($dirPointer) { + // Sanity-check if pointer is a valid directory resource + if (is_resource($dirPointer) || is_null($dirPointer)) { + // Is a valid resource + $this->dirPointer = $dirPointer; + } else { + // Throw exception + throw new InvalidDirectoryResourceException($this, self::EXCEPTION_INVALID_DIRECTORY_POINTER); + } + } + + /** + * Getter for the directory pointer + * + * @return $dirPointer The directory pointer which shall be a valid + * directory resource + */ + public final function getPointer () { + return $this->dirPointer; + } + + /** + * Setter for path name + * + * @param $pathName The new path name + * @return void + */ + public final function setPathName ($pathName) { + $pathName = (string) $pathName; + $this->pathName = $pathName; + } + + /** + * Getter for path name + * + * @return $pathName The current path name + */ + public final function getPathName () { + return $this->pathName; + } +} + +// [EOF] +?> diff --git a/inc/classes/main/io/class_FrameworkFileInputPointer.php b/inc/classes/main/io/class_FrameworkFileInputPointer.php new file mode 100644 index 00000000..35376e96 --- /dev/null +++ b/inc/classes/main/io/class_FrameworkFileInputPointer.php @@ -0,0 +1,223 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class FrameworkFileInputPointer extends BaseFrameworkSystem { + /** + * The current file we are working in + */ + private $fileName = ""; + + /** + * The file pointer + */ + private $filePointer = null; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Clean-up a little + $this->removeNumberFormaters(); + $this->removeSystemArray(); + } + + /** + * Destructor for cleaning purposes, etc + * + * @return void + */ + public final function __destruct() { + // Is there a resource pointer? Then we have to close the file here! + if (is_resource($this->getPointer())) { + // Try to close a file + $this->closeFile(); + } + + // Call the parent destructor + parent::__destruct(); + } + + /** + * Create a file pointer based on the given file. The file will also + * be verified here. + * + * @param $fileName The file name we shall pass to fopen() + * @throws FileIsEmptyException If the provided file name is empty. + * @throws FilePointerNotOpenedException If fopen() returns not a + * file resource + * @return void + */ + public final static function createFrameworkFileInputPointer ($fileName) { + // Some pre-sanity checks... + if ((is_null($fileName)) || (empty($fileName))) { + // No filename given + throw new FileIsEmptyException(null, self::EXCEPTION_UNEXPECTED_EMPTY_STRING); + } elseif (!file_exists($fileName)) { + // File does not exist! + throw new FileNotFoundException($fileName, self::EXCEPTION_FILE_NOT_FOUND); + } elseif (!is_readable($fileName)) { + // File does not exist! + throw new FileReadProtectedException($fileName, self::EXCEPTION_FILE_CANNOT_BE_READ); + } + + // Try to open a handler + $filePointer = @fopen($fileName, 'rb'); + if ((is_null($filePointer)) || ($filePointer === false)) { + // Something bad happend + throw new FilePointerNotOpenedException ($fileName, self::EXCEPTION_FILE_POINTER_INVALID); + } // END - if + + // Create new instance + $pointerInstance = new FrameworkFileInputPointer(); + + // Set file pointer and file name + $pointerInstance->setPointer($filePointer); + $pointerInstance->setFileName($fileName); + + // Return the instance + return $pointerInstance; + } + + /** + * Read data a file pointer + * + * @return mixed The result of fread() + * @throws NullPointerException If the file pointer instance + * is not set by setPointer() + * @throws InvalidFileResourceException If there is being set + * an invalid file resource + */ + public function readFromFile () { + if (is_null($this->getPointer())) { + // Pointer not initialized + throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER); + } elseif (!is_resource($this->getPointer())) { + // Pointer is not a valid resource! + throw new InvalidFileResourceException($this, self::EXCEPTION_INVALID_DIRECTORY_POINTER); + } + + // Read data from the file pointer and return it + return fread($this->getPointer(), 1024); + } + + /** + * Read lines from a file pointer + * + * @return mixed The result of fread() + * @throws NullPointerException If the file pointer instance + * is not set by setPointer() + * @throws InvalidFileResourceException If there is being set + * an invalid file resource + */ + public function readLinesFromFile () { + if (is_null($this->getPointer())) { + // Pointer not initialized + throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER); + } elseif (!is_resource($this->getPointer())) { + // Pointer is not a valid resource! + throw new InvalidFileResourceException($this, self::EXCEPTION_INVALID_DIRECTORY_POINTER); + } + + // Read data from the file pointer and return it + return fgets($this->getPointer(), 1024); + } + + /** + * Close a file source and set it's instance to null and the file name + * to empty + * + * @return void + * @throws NullPointerException If the file pointer instance + * is not set by setPointer() + * @throws InvalidFileResourceException If there is being set + */ + public function closeFile () { + if (is_null($this->getPointer())) { + // Pointer not initialized + throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER); + } elseif (!is_resource($this->getPointer())) { + // Pointer is not a valid resource! + throw new InvalidFileResourceException($this, self::EXCEPTION_INVALID_DIRECTORY_POINTER); + } + + // Close the file pointer and reset the instance variable + @fclose($this->getPointer()); + $this->setPointer(null); + $this->setFileName(""); + } + + /** + * Setter for the file pointer + * + * @param $filePointer File resource + * @return void + */ + public final function setPointer ($filePointer) { + // Sanity-check if pointer is a valid file resource + if (is_resource($filePointer) || is_null($filePointer)) { + // Is a valid resource + $this->filePointer = $filePointer; + } else { + // Throw exception + throw new InvalidFileResourceException($this, self::EXCEPTION_INVALID_DIRECTORY_POINTER); + } + } + + /** + * Getter for the file pointer + * + * @return $filePointer The file pointer which shall be a valid + * file resource + */ + public final function getPointer () { + return $this->filePointer; + } + + /** + * Setter for file name + * + * @param $fileName The new file name + * @return void + */ + public final function setFileName ($fileName) { + $fileName = (string) $fileName; + $this->fileName = $fileName; + } + + /** + * Getter for file name + * + * @return $fileName The current file name + */ + public final function getFileName () { + return $this->fileName; + } +} + +// [EOF] +?> diff --git a/inc/classes/main/io/class_FrameworkFileOutputPointer.php b/inc/classes/main/io/class_FrameworkFileOutputPointer.php new file mode 100644 index 00000000..84c8ed40 --- /dev/null +++ b/inc/classes/main/io/class_FrameworkFileOutputPointer.php @@ -0,0 +1,193 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class FrameworkFileOutputPointer extends BaseFrameworkSystem { + /** + * The current file we are working in + */ + private $fileName = ""; + + /** + * The file pointer + */ + private $filePointer = null; + + /** + * Protected constructor + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Clean-up a little + $this->removeNumberFormaters(); + $this->removeSystemArray(); + } + + /** + * Destructor for cleaning purposes, etc + */ + public final function __destruct() { + // Is there a resource pointer? Then we have to close the file here! + if (is_resource($this->getPointer())) { + // Try to close a file + $this->closeFile(); + } + + // Call the parent destructor + parent::__destruct(); + } + + /** + * Create a file pointer based on the given file. The file will also + * be verified here. + * + * @param $fileName The file name we shall pass to fopen() + * @param $mode The output mode ('w', 'a' are valid) + * @throws FileIsEmptyException If the provided file name is empty. + * @throws FilePointerNotOpened If fopen() returns not a file + * resource + * @return void + */ + public final static function createFrameworkFileOutputPointer ($fileName, $mode) { + // Some pre-sanity checks... + if (is_null($fileName)) { + // No filename given + throw new FileIsEmptyException(null, self::EXCEPTION_UNEXPECTED_EMPTY_STRING); + } + + // Try to open a handler + $filePointer = @fopen($fileName, $mode); + if (($filePointer === null) || ($filePointer === false)) { + // Something bad happend + throw new FilePointerNotOpenedException ($fileName, self::EXCEPTION_FILE_POINTER_INVALID); + } + + // Create new instance + $pointerInstance = new FrameworkFileOutputPointer(); + + // Set file pointer and file name + $pointerInstance->setPointer($filePointer); + $pointerInstance->setFileName($fileName); + + // Return the instance + return $pointerInstance; + } + + /** + * Write data to a file pointer + * + * @param $dataStream The data stream we shall write to the file + * @return mixed The result of fwrite() + * @throws NullPointerException If the file pointer instance + * is not set by setPointer() + * @throws InvalidFileResourceException If there is being set + * an invalid file resource + */ + public function writeToFile ($dataStream) { + if (is_null($this->getPointer())) { + // Pointer not initialized + throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER); + } elseif (!is_resource($this->getPointer())) { + // Pointer is not a valid resource! + throw new InvalidFileResourceException($this, self::EXCEPTION_INVALID_DIRECTORY_POINTER); + } + + // Read data from the file pointer and return it + return fwrite($this->getPointer(), $dataStream); + } + + /** + * Close a file source and set it's instance to null and the file name + * to empty + * + * @return void + * @throws NullPointerException If the file pointer instance + * is not set by setPointer() + * @throws InvalidFileResourceException If there is being set + */ + public function closeFile () { + if (is_null($this->getPointer())) { + // Pointer not initialized + throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER); + } elseif (!is_resource($this->getPointer())) { + // Pointer is not a valid resource! + throw new InvalidFileResourceException($this, self::EXCEPTION_INVALID_DIRECTORY_POINTER); + } + + // Close the file pointer and reset the instance variable + @fclose($this->getPointer()); + $this->setPointer(null); + $this->setFileName(""); + } + + /** + * Setter for the file pointer + * + * @param $filePointer File resource + * @return void + */ + public final function setPointer ($filePointer) { + // Sanity-check if pointer is a valid file resource + if (is_resource($filePointer) || is_null($filePointer)) { + // Is a valid resource + $this->filePointer = $filePointer; + } else { + // Throw exception + throw new InvalidFileResourceException($this, self::EXCEPTION_INVALID_DIRECTORY_POINTER); + } + } + + /** + * Getter for the file pointer + * + * @return $filePointer The file pointer which shall be a valid + * file resource + */ + public final function getPointer () { + return $this->filePointer; + } + + /** + * Setter for file name + * + * @param $fileName The new file name + * @return void + */ + public final function setFileName ($fileName) { + $fileName = (string) $fileName; + $this->fileName = $fileName; + } + + /** + * Getter for file name + * + * @return $fileName The current file name + */ + public final function getFileName () { + return $this->fileName; + } +} + +// [EOF] +?> diff --git a/inc/classes/main/language/.htaccess b/inc/classes/main/language/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/language/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/language/class_LanguageSystem.php b/inc/classes/main/language/class_LanguageSystem.php new file mode 100644 index 00000000..befccdb1 --- /dev/null +++ b/inc/classes/main/language/class_LanguageSystem.php @@ -0,0 +1,183 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class LanguageSystem extends BaseFrameworkSystem implements ManageableLanguage { + /** + * The full-qualified base path for the language include files + */ + private $basePath = ""; + + /** + * The 2-char language code + */ + private $langCode = "xx"; // This will later be overwritten! + + /** + * The array-object for all language strings + */ + private $langStrings = null; + + /** + * An instance of this class + */ + private static $thisInstance = null; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Clean up a little + $this->removeNumberFormaters(); + $this->removeSystemArray(); + } + + /** + * Creates an instance of the class LanguageSystem and prepares it for usage + * + * @param $basePath The local base path for all language strings + * @return $langInstance An instance of LanguageSystem + * @throws LanguagePathIsEmptyException If the provided $basePath is empty + * @throws InvalidLanguagePathStringException If $basePath is no string + * @throws LanguagePathIsNoDirectoryException If $basePath is no + * directory or not found + * @throws LanguagePathReadProtectedException If $basePath is + * read-protected + */ + public final static function createLanguageSystem ($basePath) { + // Get a new instance + $langInstance = new LanguageSystem(); + + // Is the base path valid? + if (empty($basePath)) { + // Language path is empty + throw new LanguagePathIsEmptyException($langInstance, self::EXCEPTION_UNEXPECTED_EMPTY_STRING); + } elseif (!is_string($basePath)) { + // Is not a string + throw new InvalidLanguagePathStringException(array($langInstance, $basePath), self::EXCEPTION_INVALID_STRING); + } elseif (!is_dir($basePath)) { + // Is not a path + throw new LanguagePathIsNoDirectoryException(array($langInstance, $basePath), self::EXCEPTION_INVALID_PATH_NAME); + } elseif (!is_readable($basePath)) { + // Is not readable + throw new LanguagePathReadProtectedException(array($langInstance, $basePath), self::EXCEPTION_READ_PROTECED_PATH); + } + + // Set the base path + $langInstance->setBasePath($basePath); + + // Initialize the variable stack + $langInstance->initLanguageStrings(); + + // Set language code from default config + $langInstance->setLanguageCode(FrameworkConfiguration::getInstance()->readConfig('default_lang')); + + // Remember this instance + self::$thisInstance = $langInstance; + + // Return the prepared instance + return $langInstance; + } + + /** + * Singleton getter for this instance + * + * @return $thisInstance An instance of this class + */ + public final static function getInstance () { + return self::$thisInstance; + } + + /** + * Setter for base path + * + * @param $basePath The local base path for all templates + * @return void + */ + protected final function setBasePath ($basePath) { + // And set it + $this->basePath = (string) $basePath; + } + + /** + * Setter for language code + * + * @param $langCode The language code for the current application + * @return void + */ + protected final function setLanguageCode ($langCode) { + // Cast it + $langCode = (string) $langCode; + + // And set it (only 2 chars) + $this->langCode = substr($langCode, 0, 2); + } + + /** + * Initialize the array-object for all later language strings + * + * @return void + */ + public function initLanguageStrings () { + $this->langStrings = new FrameworkArrayObject("FakedLanguageStrings"); + } + + /** + * Getter for language code + * + * @return $langCode The language code for the current application + */ + public final function getLanguageCode () { + return $this->langCode; + } + + /** + * Get the plain message from the cache variable for the given message id + * + * @param $messageId The message id we shall find in the cache variable + * @return $messageText The plain message text + */ + public function getMessage ($messageId) { + // Default is missing message text + $messageText = sprintf("!%s!", + $messageId + ); + + // Try to look it up in the cache variable + if ($this->langStrings->offsetExists($messageId)) { + // Return the message string + $messageText = $this->langStrings->offsetGet($messageId); + } + + // Return the text + return $messageText; + } +} + +// [EOF] +?> diff --git a/inc/classes/main/mailer/.htaccess b/inc/classes/main/mailer/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/mailer/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/mailer/class_ b/inc/classes/main/mailer/class_ new file mode 100644 index 00000000..5cf368f8 --- /dev/null +++ b/inc/classes/main/mailer/class_ @@ -0,0 +1,70 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ???Mailer extends BaseMailer implements DeliverableMail { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this mailer class + * + * @return $mailerInstance An instance of this mailer class + */ + public final static function create???Mailer () { + // Get a new instance + $mailerInstance = new ???Mailer(); + + // Return the instance + return $mailerInstance; + } + + /** + * Deliver email to the recipient(s) + * + * @return void + * @todo 0% done + */ + public function deliverEmail() { + $this->partialStub("You have to implement this method."); + } + + /** + * Send notification to the admin + * + * @return void + * @todo 0% done + */ + public function sendAdminNotification() { + $this->partialStub("You have to implement this method."); + } +} + +// [EOF] +?> diff --git a/inc/classes/main/mailer/class_BaseMailer.php b/inc/classes/main/mailer/class_BaseMailer.php new file mode 100644 index 00000000..4230fbc4 --- /dev/null +++ b/inc/classes/main/mailer/class_BaseMailer.php @@ -0,0 +1,214 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseMailer extends BaseFrameworkSystem { + /** + * Iterateable list of recipients + */ + private $recipientList = array(); + + /** + * Template name + */ + private $templateName = ""; + + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + + // Clean up a little + $this->removeNumberFormaters(); + $this->removeSystemArray(); + } + + /** + * Loads a text or HTML template depending on configuration into the template engine + * + * @param $templateName Name of the template we shall load + * @return void + */ + protected final function loadTemplate ($templateName) { + // Set template name + $this->setTemplateName($templateName); + + // Get configuration entry + $templatePrefix = $this->getConfigInstance()->readConfig('email_tpl_' . $templateName); + + // Load this email template + $this->getTemplateInstance()->loadEmailTemplate($templatePrefix . '_' . $templateName); + } + + /** + * Adds a user class to the recipient list for current template + * + * @param $userInstance An instance of a user class + * @return void + */ + public function addRecipientByUserInstance (ManageableMember $userInstance) { + // Get template name + $templateName = $this->getTemplateName(); + + // Is the list initialized? + if (!isset($this->recipientList[$templateName]['recipients'])) { + // Then initialize it here + $this->recipientList[$templateName]['recipients'] = array(); + } // END - if + + // Add it as a recipient + $this->recipientList[$templateName]['recipients'][] = $userInstance; + } + + /** + * Adds a template variable (just the name) to the recipient list in given section of current template + * + * @param $section Section can be "config" or "value" currently + * @param $variableName Template variable name to add + * @return void + */ + private final function addTemplateVariable ($section, $variableName) { + // Get template name + $templateName = $this->getTemplateName(); + + // Generate full section name + $sectionName = $section . '_vars'; + + // Is the list initialized? + if (!isset($this->recipientList[$templateName][$sectionName])) { + // Then initialize it here + $this->recipientList[$templateName][$sectionName] = array(); + } // END - if + + // Add the variable to the list + $this->recipientList[$templateName][$sectionName][$variableName] = 'OK'; + } + + /** + * Adds a config template variable to the recipient list of current template + * + * @param $variableName Template variable name to add + * @return void + */ + public final function addConfigTemplateVariable ($variableName) { + $this->addTemplateVariable("config", $variableName); + } + + /** + * Adds a "value" template variable to the recipient list of current template + * + * @param $variableName Template variable name to add + * @return void + */ + public final function addValueTemplateVariable ($variableName) { + $this->addTemplateVariable("value", $variableName); + } + + /** + * Adds a value instance for a given variable name. It should be set! + * + * @param $variableName Template variable we want to assign a value instance + * @param $valueInstance An object instance which can provide "field values" + * @return void + */ + public final function addValueInstance ($variableName, FrameworkInterface $valueInstance) { + $this->recipientList[$this->getTemplateName()]['values'][$variableName] = $valueInstance; + } + + /** + * Protected setter for template name + * + * @param $templateName Name of email template + * @return void + */ + public final function setTemplateName ($templateName) { + $this->templateName = (string) $templateName; + } + + /** + * Protected getter for template name + * + * @return $templateName Name of email template + */ + protected final function getTemplateName () { + return $this->templateName; + } + + /** + * Setter for subject line + * + * @param $subjectLine Subject line to set + * @return void + */ + public final function setSubjectLine ($subjectLine) { + $this->recipientList[$this->getTemplateName()]['subject'] = (string) $subjectLine; + } + + /** + * Getter for subject line or null if not found + * + * @return $subjectLine Subject line to set + */ + public final function getSubjectLine () { + // Default subject is null + $subjectLine = null; + + // Get template name + $templateName = $this->getTemplateName(); + + // Does the subject line exist? + if ((!empty($templateName)) && (isset($this->recipientList[$templateName]['subject']))) { + // Then use it + $subjectLine = $this->recipientList[$templateName]['subject']; + } // END - if + + // Return it + return $subjectLine; + } + + /** + * Use subject line provided by the (XML) template otherwise a subject line must be set + * + * @return void + */ + public function useSubjectFromTemplate () { + // Set the subject line + $this->setSubjectLine("{?subject?}"); + } + + /** + * Getter for recipient list array + * + * @return $recipientList Array with reciepients + */ + public final function getRecipientList () { + return $this->recipientList; + } +} + +// [EOF] +?> diff --git a/inc/classes/main/mailer/debug/.htaccess b/inc/classes/main/mailer/debug/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/mailer/debug/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/mailer/debug/class_DebugMailer.php b/inc/classes/main/mailer/debug/class_DebugMailer.php new file mode 100644 index 00000000..14bdd412 --- /dev/null +++ b/inc/classes/main/mailer/debug/class_DebugMailer.php @@ -0,0 +1,175 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class DebugMailer extends BaseMailer implements DeliverableMail { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this mailer class + * + * @param $templateInstance A template instance + * @param $appInstance An application helper class + * @param $templateName Name of email template to set + * @return $mailerInstance An instance of this mailer class + */ + public final static function createDebugMailer (CompileableTemplate $templateInstance, ManageableApplication $appInstance, $templateName) { + // Get a new instance + $mailerInstance = new DebugMailer(); + + // Set template instance + $mailerInstance->setTemplateInstance($templateInstance); + + // Set application instance + $mailerInstance->setApplicationInstance($appInstance); + + // Set template name + $mailerInstance->setTemplateName('resend_link'); + + // Return the instance + return $mailerInstance; + } + + /** + * Deliver email to the recipient(s) + * + * @return void + * @throws InvalidInterfaceException If the recipient instance does not implement ManageableMember + */ + public function deliverEmail () { + // Get template instance + $templateInstance = $this->getTemplateInstance(); + + // "Deliver" all emails + foreach ($this->getRecipientList() as $templateName => $recipientList) { + // Walk through all recipients and "sent", or better print, it out + foreach ($recipientList['recipients'] as $recipientInstance) { + // The recipient should be a user instance, right? + if (!$recipientInstance instanceof ManageableMember) { + // Invalid entry found! + throw new InvalidInterfaceException(array($this, 'ManageableMember'), self::EXCEPTION_REQUIRED_INTERFACE_MISSING); + } + + // User class found, so entry is valid, first load the template + $this->loadTemplate($templateName); + + // Set subject line + $templateInstance->assignVariable('subject', $this->getSubjectLine()); + + // Walk through all variables, first config to assign them + foreach ($recipientList['config_vars'] as $variable => $dummy) { + // Load the config value and set it + $templateInstance->assignConfigVariable($variable); + } // END - if + + // Now do the same with the values but ask the "value instance" instead! + foreach ($recipientList['value_vars'] as $variable => $dummy) { + // Is the value instance there? + if (!isset($recipientList['values'][$variable])) { + // Throw exception + throw new NullPointerException ($this, self::EXCEPTION_IS_NULL_POINTER); + } // END - if + + // Get the field from the value instance + $fieldValue = $recipientList['values'][$variable]->getField($variable); + + // Set it in template engine + $templateInstance->assignVariable($variable, $fieldValue); + } + + // Render the content + $templateInstance->renderXmlContent(); + + // Get responce instance + $responseInstance = $this->getApplicationInstance()->getResponseInstance(); + + // Transfer the data to the response + $this->getTemplateInstance()->transferToResponse($responseInstance); + } // END - foreach + } // END - foreach + } + + /** + * Send notification to the admin + * + * @return void + * @todo 0% done + */ + public function sendAdminNotification () { + // Unfinished work + } + + /** + * Invokes the mail delivery process which will prepare the output of the message in a code template + * + * @return void + */ + public function invokeMailDelivery () { + // Get template instance + $templateInstance = $this->getTemplateInstance(); + + // Get the compiled message and set it as new template variable + $message = $templateInstance->getCompiledData(); + $templateInstance->assignVariable('message', $message); + + // Load the code template + $templateInstance->loadCodeTemplate('mail_debug'); + + // Compile the template + $templateInstance->compileTemplate(); + + // Assign this template with variable + $templateInstance->assignTemplateWithVariable('mail_debug', 'content'); + + // Load header template + $templateInstance->loadCodeTemplate('header'); + + // Compile and assign it with a variable + $templateInstance->compileTemplate(); + $templateInstance->assignTemplateWithVariable('header', 'header'); + + // Load footer template + $templateInstance->loadCodeTemplate('footer'); + + // Compile and assign it with a variable + $templateInstance->compileTemplate(); + $templateInstance->assignTemplateWithVariable('footer', 'footer'); + + // Load the master template + $templateInstance->loadCodeTemplate($this->getApplicationInstance()->getMasterTemplate()); + + // Then compile it again + $templateInstance->compileVariables(); + } +} + +// [EOF] +?> diff --git a/inc/classes/main/output/.htaccess b/inc/classes/main/output/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/output/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/output/class_ConsoleOutput.php b/inc/classes/main/output/class_ConsoleOutput.php new file mode 100644 index 00000000..51f5dcaf --- /dev/null +++ b/inc/classes/main/output/class_ConsoleOutput.php @@ -0,0 +1,115 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ConsoleOutput extends BaseFrameworkSystem implements OutputStreamer { + /** + * The instance for the singleton design pattern + */ + private static $consoleInstance = null; + + /** + * Assigned variables + */ + private $vars = array(); + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Create a new web output system and set the content type + * + * @param $contentType A valid content-type + * @return $debugInstance An instance of this middleware class + */ + public final static function createConsoleOutput ($contentType) { + // Cast the content-type to string + $contentType = (string) $contentType; + $contentType = trim($contentType); + + // Get instance + self::$consoleInstance = new ConsoleOutput(); + + // Set the content type + if (!empty($contentType)) { + @header(sprintf("Content-type: %s", + $contentType + )); + } + + // Return instance + return self::$consoleInstance; + } + + /** + * Getter for an instance of this class + * + * @return $consoleInstance An instance of this class + */ + public final static function getInstance() { + if (is_null(self::$consoleInstance)) { + $contentType = FrameworkConfiguration::getInstance()->readConfig('web_content_type'); + self::$consoleInstance = ConsoleOutput::createConsoleOutput($contentType); + } + return self::$consoleInstance; + } + + /** + * Output the code + * + * @param $outStream Something we shall sent to the console + * @return void + */ + public final function output ($outStream=false) { + if ($outStream === false) { + // Output something here... + foreach ($this->vars as $var => $value) { + $this->output("var=".$var.", value=".$value.""); + } + } else { + // Output it to the console + printf("%s\n", trim(html_entity_decode(strip_tags(stripslashes($outStream))))); + } + } + + /** + * Assigns a variable for output + * + * @param $var The variable we shall assign + * @param $value The value to store in the variable + * @return void + */ + public function assignVariable ($var, $value) { + $this->vars[$var] = $value; + } +} + +// [EOF] +?> diff --git a/inc/classes/main/output/class_WebOutput.php b/inc/classes/main/output/class_WebOutput.php new file mode 100644 index 00000000..e82c0b7a --- /dev/null +++ b/inc/classes/main/output/class_WebOutput.php @@ -0,0 +1,92 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class WebOutput extends BaseFrameworkSystem implements OutputStreamer, Registerable { + /** + * The instance for the singleton design pattern + */ + private static $webInstance = null; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Create a new web output system and set the content type + * + * @param $contentType A valid content-type + * @return $debugInstance An instance of this middleware class + */ + public final static function createWebOutput ($contentType) { + // Is there no instance? + if (is_null(self::$webInstance)) { + // Cast the content-type to string and trim it + $contentType = (string) $contentType; + $contentType = trim($contentType); + + // Set the content type + if (!empty($contentType)) { + @header(sprintf("Content-type: %s", + $contentType + )); + } + + // Get a new instance and set it + self::$webInstance = new WebOutput(); + } + + // Return instance + return self::$webInstance; + } + + /** + * Assigns a variable for output + * + * @param $var The variable we shall assign + * @param $value The value to store in the variable + * @return void + */ + public function assignVariable($var, $value) { + // Stub message because we don't have it here + trigger_error(__METHOD__.": Stub!"); + } + + /** + * Output the code + * + * @return void + */ + public final function output ($outStream=false) { + print(stripslashes($outStream)); + } +} + +// [EOF] +?> diff --git a/inc/classes/main/points/.htaccess b/inc/classes/main/points/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/points/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/points/class_UserPoints.php b/inc/classes/main/points/class_UserPoints.php new file mode 100644 index 00000000..e7b636f4 --- /dev/null +++ b/inc/classes/main/points/class_UserPoints.php @@ -0,0 +1,93 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class UserPoints extends BaseFrameworkSystem implements Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Clean up a little + $this->removeNumberFormaters(); + $this->removeSystemArray(); + } + + /** + * Creates an instance of this points class + * + * @param $userInstance An instance of a user class + * @return $pointsInstance An instance of this class + */ + public final static function createUserPoints (ManageableAccount $userInstance) { + // Get a new instance + $pointsInstance = new UserPoints(); + + // Set user instance + $pointsInstance->setUserInstance($userInstance); + + // Return instance + return $pointsInstance; + } + + /** + * Checks wether the user has the required amount of points left for the specified action + * + * @param $action The action or configuration entry plus prefix the user wants to perform + * @return $hasRequired Wether the user has the required points + * @todo Finish loading part of points + */ + public function ifUserHasRequiredPoints ($action) { + // Default is that everyone is poor... ;-) + $hasRequired = false; + + // Get the required points entry + $requiredPoints = $this->getConfigInstance()->readConfig($action . '_action_points'); + + // Get a wrapper instance + $wrapperInstance = ObjectFactory::createObjectByConfiguredName('user_points_db_wrapper_class'); + + // Now get a search criteria and set the user's name as criteria + $criteriaInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class'); + $criteriaInstance->addCriteria("points_uid", $this->getUserInstance()->getUserName()); + $criteriaInstance->setLimit(1); + + // Get result back + $resultInstance = $wrapperInstance->doSelectByCriteria($criteriaInstance); + + // Do we have an entry? + if ($resultInstance->next()) { + // @TODO Load points here + $this->partialStub("Load points here for comparison."); + } // END - if + + // Return the result + return $hasRequired; + } +} + +// [EOF] +?> diff --git a/inc/classes/main/reader/.htaccess b/inc/classes/main/reader/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/reader/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/reader/class_DefaultNewsReader.php b/inc/classes/main/reader/class_DefaultNewsReader.php new file mode 100644 index 00000000..b0dbac67 --- /dev/null +++ b/inc/classes/main/reader/class_DefaultNewsReader.php @@ -0,0 +1,87 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class DefaultNewsReader extends BaseFrameworkSystem implements ReadableNews, Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Clean up a little + $this->removeNumberFormaters(); + $this->removeSystemArray(); + } + + /** + * Creates an instance of this reader by a provided request instance + * + * @param $requestInstance An instance of a Requestable class + * @return $readerInstance An instance of this reader class + */ + public final static function createDefaultNewsReader (Requestable $requestInstance) { + // Get a new instance + $readerInstance = new DefaultNewsReader(); + + // Set request instance + $readerInstance->setRequestInstance($requestInstance); + + // Return prepared instance + return $readerInstance; + } + + /** + * Initializes this reader class by pre-fetching news depending on "page" + * (outside or login area), which amount of news and how much to skip + * + * @return void + */ + public function initializeReader () { + // Get "page" for saving some calls + $page = $this->getRequestInstance()->getRequestElement('page'); + + // First get a wrapper instance + $wrapperInstance = ObjectFactory::createObjectByConfiguredName('news_db_wrapper_class'); + + // Next create a searchable criteria instance + $criteriaInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class'); + + // Add the page as criteria to it at lease + $criteriaInstance->addCriteria("page", $page); + + // Add limitation from config + $criteriaInstance->setLimit($this->getConfigInstance()->readConfig("news_{$page}_limit")); + + // Get a resultInstance back from the database + $resultInstance = $wrapperInstance->doSelectByCriteria($criteriaInstance); + + // Save that resultInstance in this class + $this->setResultInstance($resultInstance); + } +} + +// [EOF] +?> diff --git a/inc/classes/main/registration/.htaccess b/inc/classes/main/registration/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/registration/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/registration/class_BaseRegistration.php b/inc/classes/main/registration/class_BaseRegistration.php new file mode 100644 index 00000000..1ebf7e5b --- /dev/null +++ b/inc/classes/main/registration/class_BaseRegistration.php @@ -0,0 +1,105 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseRegistration extends BaseFrameworkSystem { + /** + * Pre-registration filter chain + */ + private $preRegistrationFilter = null; + + /** + * Pre-registration filter chain + */ + private $postRegistrationFilter = null; + + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + + // Clean up a little + $this->removeNumberFormaters(); + $this->removeSystemArray(); + } + + /** + * Initialize filters. This must be done before you can use them + * + * @return void + */ + protected function initFilterChains () { + // Pre/post-registration filters + $this->preRegistrationFilter = ObjectFactory::createObjectByConfiguredName('filter_chain_class'); + $this->postRegistrationFilter = ObjectFactory::createObjectByConfiguredName('filter_chain_class'); + } + + /** + * Adds a filter to the pre filter chain + * + * @param $filterInstance An instance of a filter + * @return void + */ + public function addPreFilter (Filterable $filterInstance) { + // Add the pre filter + $this->preRegistrationFilter->addFilter($filterInstance); + } + + /** + * Adds a filter to the post filter chain + * + * @param $filterInstance An instance of a filter + * @return void + */ + public function addPostFilter (Filterable $filterInstance) { + // Add the post filter + $this->postRegistrationFilter->addFilter($filterInstance); + } + + /** + * Executes all pre filters + * + * @return void + */ + protected function executePreFilters () { + // Execute all pre filters + $this->preRegistrationFilter->processFilters($this->getRequestInstance(), $this->getResponseInstance()); + } + + /** + * Executes all post filters + * + * @return void + */ + protected function executePostFilters () { + // Execute all post filters + $this->postRegistrationFilter->processFilters($this->getRequestInstance(), $this->getResponseInstance()); + } +} + +// [EOF] +?> diff --git a/inc/classes/main/registry/.htaccess b/inc/classes/main/registry/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/registry/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/registry/class_Registry.php b/inc/classes/main/registry/class_Registry.php new file mode 100644 index 00000000..9a8b6483 --- /dev/null +++ b/inc/classes/main/registry/class_Registry.php @@ -0,0 +1,132 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class Registry extends BaseFrameworkSystem implements Register { + /** + * Instance of this class + */ + private static $selfInstance = null; + + /** + * Wether the registry is initialized + */ + private static $initialized = false; + + /** + * Instance registry + */ + private $instanceRegistry = array(); + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Clean up a little + $this->removeNumberFormaters(); + $this->removeSystemArray(); + } + + /** + * Singleton getter for self instance + * + * @return $selfInstance Instance of this class + */ + public final static function getRegistry () { + // Is an instance there? + if (is_null(self::$selfInstance)) { + // Not yet, so create one + self::$selfInstance = new Registry(); + } + + // Return the instance + return self::$selfInstance; + } + + /** + * Checks or sets wether the registry has been initialized. This had only be done once + * + * @param $initialized Wether the registry is initialized + * @return $initialized Wether the registry is initialized + */ + public final static function isInitialized ($initialized = null) { + if (is_null($initialized)) { + // Get status if initialized + return self::$initialized; + } elseif (!is_null($initialized)) { + // Registry is initialized! + self::$initialized = true; + } + } + + /** + * Checks wether an instance key was found + * + * @param $instanceKey The key holding an instance in registry + * @return $exists Wether the key exists in registry + */ + public function instanceExists ($instanceKey) { + // Does this key exists? + $exists = (isset($this->instanceRegistry[$instanceKey])); + + // Return the result + return $exists; + } + + /** + * Adds/overwrites a new instance to the registry at the given key + * + * @param $instanceKey The key to identify the instance + * @param $objectInstance An instance we shall store + * @return void + */ + public function addInstance ($instanceKey, Registerable $objectInstance) { + $this->instanceRegistry[$instanceKey] = $objectInstance; + } + + /** + * Gets a registered instance or null if not found + * + * @param $instanceKey The key to identify the instance + * @return $objectInstance An instance we shall store + */ + public function getInstance ($instanceKey) { + // By default the instance is not in registry + $objectInstance = null; + + // Is the instance there? + if ($this->instanceExists($instanceKey)) { + $objectInstance = $this->instanceRegistry[$instanceKey]; + } + + // Return the result + return $objectInstance; + } +} + +// [EOF] +?> diff --git a/inc/classes/main/request/.htaccess b/inc/classes/main/request/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/request/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/request/class_HttpRequest.php b/inc/classes/main/request/class_HttpRequest.php new file mode 100644 index 00000000..0538512a --- /dev/null +++ b/inc/classes/main/request/class_HttpRequest.php @@ -0,0 +1,208 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HttpRequest extends BaseFrameworkSystem implements Requestable { + /** + * Array for the request data + */ + private $requestData = array(); + + /** + * Wether this request is valid and can be further processed. The default is + * valid so make sure your intercepting filters sets this attribute to false + * when they need to intercept the data flow. + */ + private $requestIsValid = true; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Clean up a little + $this->removeNumberFormaters(); + $this->removeSystemArray(); + } + + /** + * Creates an instance of this class and prepares it a little + * + * @return $httpInstance An instance of this class + */ + public final static function createHttpRequest () { + // Create an instance + $httpInstance = new HttpRequest(); + + // Prepare the HTTP request data for usage + $httpInstance->prepareRequestData(); + + // Return the prepared instance + return $httpInstance; + } + + /** + * Prepares the HTTP request data for usage by currently copying + * $_REQUEST into a private attribute. Later on we can add more + * things for initialization here. + * + * @return void + */ + public function prepareRequestData () { + // Copy GET then POST data + $this->requestData = array_merge($_GET, $_POST); + } + + /** + * Checks wether a request element is set + * @param $element Name of the request element we want to check + * @return $isSet Wether the request element is set + */ + public function isRequestElementSet ($element) { + // Is this element found? + $isSet = isset($this->requestData[$element]); + + // Return result + return $isSet; + } + + /** + * Getter for request element or 'null' if element was not found + * + * @param $element Name of the request element we want to check + * @return $value Value of the found request element or 'null' if the + * element was not found + */ + public function getRequestElement ($element) { + // Initialize value + $value = null; + + // Is the element set? + if ($this->isRequestElementSet($element)) { + // Get the bare value + $value = $this->requestData[$element]; + + // Secure it against attacks + $value = htmlentities(strip_tags($value), ENT_QUOTES); + } // END - if + + // Return the element's value + return $value; + } + + /** + * Setter for request elements + * + * @param $element Request element to se + * @param $value Value to set + * @return void + */ + public function setRequestElement ($element, $value) { + $this->requestData[$element] = $value; + } + + /** + * Wrapper method for array_key() function for the request data array + * + * @return $array An array containing all array keys to return + */ + public function getParameterNames () { + return array_keys($this->requestData); + } + + /** + * Getter for a header element or 'null' if header was not found + * + * @param $headerName Name of the header + * @return $headerValue Value of the header or 'null' if not found + */ + public function getHeader ($headerName) { + // Default return value on error + $headerValue = null; + + // Construct the name + $name = 'HTTP_' . strtolower(str_replace('-', '_', $headerName)); + + // Does this header exist? + if (isset($_SERVER[$name])) { + $headerValue = $_SERVER[$name]; + } // END - if + + // Return the value + return $headerValue; + } + + /** + * Getter for request method. This getter might be useful for security filters + * + * @return $requestMethod Used request method + */ + public final function getRequestMethod () { + return $_SERVER['REQUEST_METHOD']; + } + + /** + * Sets wether the request was valid (default: true) + * + * @param $isValid Wether the request is valid + * @return void + */ + public final function requestIsValid ($isValid = true) { + $this->requestIsValid = (bool) $isValid; + } + + /** + * Returns wether this request is valid + * + * @return $requestIsValid Wether this request is valid + */ + public final function isRequestValid () { + return $this->requestIsValid; + } + + /** + * Reads a cookie and returns it's value or null if not found + * + * @param $cookieName Name of cookie we shall read + * @return $cookieValue Value of cookie or null if not found + */ + public final function readCookie ($cookieName) { + // Default is no cookie with that name found + $cookieValue = null; + + // Is the cookie set? + if (isset($_COOKIE[$cookieName])) { + // Then get it + $cookieValue = $_COOKIE[$cookieName]; + } // END - if + + // Return the value + return $cookieValue; + } +} + +// [EOF] +?> diff --git a/inc/classes/main/resolver/.htaccess b/inc/classes/main/resolver/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/resolver/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/resolver/action/.htaccess b/inc/classes/main/resolver/action/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/resolver/action/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/resolver/action/class_BaseActionResolver.php b/inc/classes/main/resolver/action/class_BaseActionResolver.php new file mode 100644 index 00000000..7e462cc5 --- /dev/null +++ b/inc/classes/main/resolver/action/class_BaseActionResolver.php @@ -0,0 +1,134 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseActionResolver extends BaseResolver { + /** + * Prefix for local, remote or other resolver + */ + private $actionPrefix = ""; + + /** + * Validated action name + */ + private $actionName = ""; + + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } + + /** + * Setter for action prefix + * + * @param $actionPrefix Last validated actionPrefix + * @return void + */ + protected final function setActionPrefix ($actionPrefix) { + $this->actionPrefix = $actionPrefix; + } + + /** + * Setter for action name + * + * @param $actionName Last validated action name + * @return void + */ + protected final function setActionName ($actionName) { + $this->actionName = (string) $actionName; + } + + /** + * Getter for action name + * + * @return $actionName Last validated action name + */ + public final function getActionName () { + return $this->actionName; + } + + /** + * Checks wether the given action is valid + * + * @param $actionName The default action we shall execute + * @return $isValid Wether the given action is valid + * @throws EmptyVariableException Thrown if given action is not set + */ + public function isActionValid ($actionName) { + // By default nothing shall be valid + $isValid = false; + + // Is a action set? + if (empty($actionName)) { + // Then thrown an exception here + throw new EmptyVariableException(array($this, 'actionName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); + } // END - if + + // Now, let us create the full name of the action class + $this->setClassName(sprintf("%s%sAction", + $this->actionPrefix, + $this->convertToClassName($actionName) + )); + + // Is this class already loaded? + if (class_exists($this->getClassName())) { + // This class does exist. :-) + $isValid = true; + } // END - if + + // Set action name + $this->setActionName($actionName); + + // Return the result + return $isValid; + } + + /** + * "Loads" current action and instances it if not yet cached + * + * @return $actionInstance A loaded action instance + */ + protected function loadAction () { + // Init action instance + $actionInstance = null; + + // Create action class name + $this->setClassName(sprintf("Web%sAction", + $this->convertToClassName($this->getActionName()) + )); + + // Initiate the action + $actionInstance = ObjectFactory::createObjectByName($this->getClassName(), array($this)); + + // Return the result + return $actionInstance; + } +} + +// [EOF] +?> diff --git a/inc/classes/main/resolver/action/web/.htaccess b/inc/classes/main/resolver/action/web/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/resolver/action/web/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/resolver/action/web/class_WebActionResolver.php b/inc/classes/main/resolver/action/web/class_WebActionResolver.php new file mode 100644 index 00000000..6276b11d --- /dev/null +++ b/inc/classes/main/resolver/action/web/class_WebActionResolver.php @@ -0,0 +1,147 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class WebActionResolver extends BaseActionResolver implements ActionResolver { + /** + * Last successfull resolved action + */ + private $lastActionInstance = ""; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set prefix to "Web" + $this->setActionPrefix("Web"); + } + + /** + * Creates an instance of a Web action resolver with a given default action + * + * @param $actionName The default action we shall execute + * @param $appInstance An instance of a manageable application helper class + * @return $resolverInstance The prepared action resolver instance + * @throws EmptyVariableException Thrown if default action is not set + * @throws InvalidActionException Thrown if default action is invalid + */ + public final static function createWebActionResolver ($actionName, ManageableApplication $appInstance) { + // Create the new instance + $resolverInstance = new WebActionResolver(); + + // Is the variable $actionName set and the action is valid? + if (empty($actionName)) { + // Then thrown an exception here + throw new EmptyVariableException(array($resolverInstance, 'defaultAction'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); + } elseif ($resolverInstance->isActionValid($actionName) === false) { + // Invalid action found + throw new InvalidActionException(array($resolverInstance, $actionName), self::EXCEPTION_INVALID_ACTION); + } + + // Set the application instance + $resolverInstance->setApplicationInstance($appInstance); + + // Return the prepared instance + return $resolverInstance; + } + + /** + * Returns an action instance for a given request class or null if + * it was not found + * + * @param $requestInstance An instance of a request class + * @return $actionInstance An instance of the resolved action + * @throws InvalidActionException Thrown if $actionName is + * invalid + * @throws InvalidActionInstanceException Thrown if $actionInstance + * is an invalid instance + */ + public function resolveActionByRequest (Requestable $requestInstance) { + // Init variables + $actionName = ""; + $actionInstance = null; + + // This goes fine so let's resolv the action + $actionName = $requestInstance->getRequestElement('action'); + + // Is the action empty? Then fall back to default action + if (empty($actionName)) $actionName = $this->getConfigInstance()->readConfig('default_action'); + + // Check if action is valid + if ($this->isActionValid($actionName) === false) { + // This action is invalid! + throw new InvalidActionException(array($this, $actionName), self::EXCEPTION_INVALID_ACTION); + } // END - if + + // Get the action + $actionInstance = $this->loadAction(); + + // And validate it + if ((!is_object($actionInstance)) || (!$actionInstance instanceof Actionable)) { + // This action has an invalid instance! + throw new InvalidActionInstanceException(array($this, $actionName), self::EXCEPTION_INVALID_ACTION); + } // END - if + + // Set last action + $this->lastActionInstance = $actionInstance; + + // Return the resolved action instance + return $actionInstance; + } + + /** + * Resolves the action by its direct name and returns an instance of its class + * + * @return $actionInstance An instance of the action class + * @throws InvalidActionException Thrown if $actionName is invalid + */ + public function resolveAction () { + // Initiate the instance variable + $actionInstance = null; + + // Get action name + $actionName = $this->getActionName(); + + // Is the action empty? Then fall back to default action + if (empty($actionName)) $actionName = $this->getConfigInstance()->readConfig('default_action'); + + // Check if action is valid + if ($this->isActionValid($actionName) === false) { + // This action is invalid! + throw new InvalidActionException(array($this, $actionName), self::EXCEPTION_INVALID_ACTION); + } + + // Get the action + $actionInstance = $this->loadAction(); + + // Return the instance + return $actionInstance; + } +} + +// [EOF] +?> diff --git a/inc/classes/main/resolver/class_BaseResolver.php b/inc/classes/main/resolver/class_BaseResolver.php new file mode 100644 index 00000000..07e19662 --- /dev/null +++ b/inc/classes/main/resolver/class_BaseResolver.php @@ -0,0 +1,71 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseResolver extends BaseFrameworkSystem { + /** + * Class name + */ + private $className = ""; + + // Exception constants + const EXCEPTION_INVALID_COMMAND = 0x1d0; + const EXCEPTION_INVALID_CONTROLLER = 0x1d1; + const EXCEPTION_INVALID_ACTION = 0x1d2; + + /** + * Protected constructor + * + * @param $className Real name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + + // Clean up a little + $this->removeNumberFormaters(); + $this->removeSystemArray(); + } + + /** + * Setter for class name + * + * @param $className Name of the class + * @return void + */ + protected final function setClassName ($className) { + $this->className = $className; + } + + /** + * Getter for class name + * + * @return $className Name of the class + */ + public final function getClassName () { + return $this->className; + } +} + +// [EOF] +?> diff --git a/inc/classes/main/resolver/command/.htaccess b/inc/classes/main/resolver/command/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/resolver/command/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/resolver/command/class_BaseCommandResolver.php b/inc/classes/main/resolver/command/class_BaseCommandResolver.php new file mode 100644 index 00000000..4900c617 --- /dev/null +++ b/inc/classes/main/resolver/command/class_BaseCommandResolver.php @@ -0,0 +1,113 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseCommandResolver extends BaseResolver { + /** + * Prefix for local, remote or other resolver + */ + private $commandPrefix = ""; + + /** + * Validated command name + */ + private $commandName = ""; + + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } + + /** + * Setter for command prefix + * + * @param $commandPrefix Last validated commandPrefix + * @return void + */ + protected final function setCommandPrefix ($commandPrefix) { + $this->commandPrefix = $commandPrefix; + } + + /** + * Setter for command name + * + * @param $commandName Last validated command name + * @return void + */ + protected final function setCommandName ($commandName) { + $this->commandName = $commandName; + } + + /** + * Getter for command name + * + * @return $commandName Last validated command name + */ + protected final function getCommandName () { + return $this->commandName; + } + + /** + * Checks wether the given command is valid + * + * @param $commandName The default command we shall execute + * @return $isValid Wether the given command is valid + * @throws EmptyVariableException Thrown if given command is not set + */ + public function isCommandValid ($commandName) { + // By default nothing shall be valid + $isValid = false; + + // Is a command set? + if (empty($commandName)) { + // Then thrown an exception here + throw new EmptyVariableException(array($this, 'commandName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); + } + + // Now, let us create the full name of the command class + $this->setClassName(sprintf("%s%sCommand", + $this->commandPrefix, + $this->convertToClassName($commandName) + )); + + // Is this class already loaded? + if (class_exists($this->getClassName())) { + // This class does exist. :-) + $isValid = true; + } // END - if + + // Set command name + $this->setCommandName($commandName); + + // Return the result + return $isValid; + } +} + +// [EOF] +?> diff --git a/inc/classes/main/resolver/command/image/.htaccess b/inc/classes/main/resolver/command/image/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/resolver/command/image/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/resolver/command/image/class_ImageCommandResolver.php b/inc/classes/main/resolver/command/image/class_ImageCommandResolver.php new file mode 100644 index 00000000..dc104e6a --- /dev/null +++ b/inc/classes/main/resolver/command/image/class_ImageCommandResolver.php @@ -0,0 +1,178 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ImageCommandResolver extends BaseCommandResolver implements CommandResolver { + /** + * Last successfull resolved command + */ + private $lastCommandInstance = null; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set prefix to "Image" + $this->setCommandPrefix("Image"); + } + + /** + * Creates an instance of a Image command resolver with a given default command + * + * @param $commandName The default command we shall execute + * @param $appInstance An instance of a manageable application helper class + * @return $resolverInstance The prepared command resolver instance + * @throws EmptyVariableException Thrown if default command is not set + * @throws InvalidCommandException Thrown if default command is invalid + */ + public final static function createImageCommandResolver ($commandName, ManageableApplication $appInstance) { + // Create the new instance + $resolverInstance = new ImageCommandResolver(); + + // Is the variable $commandName set and the command is valid? + if (empty($commandName)) { + // Then thrown an exception here + throw new EmptyVariableException(array($resolverInstance, 'commandName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); + } elseif ($resolverInstance->isCommandValid($commandName) === false) { + // Invalid command found + throw new InvalidCommandException(array($resolverInstance, $commandName), self::EXCEPTION_INVALID_COMMAND); + } + + // Set the application instance + $resolverInstance->setApplicationInstance($appInstance); + + // Return the prepared instance + return $resolverInstance; + } + + /** + * Returns an command instance for a given request class or null if + * it was not found + * + * @param $requestInstance An instance of a request class + * @return $commandInstance An instance of the resolved command + * @throws InvalidCommandException Thrown if $commandName is + * invalid + * @throws InvalidCommandInstanceException Thrown if $commandInstance + * is an invalid instance + */ + public function resolveCommandByRequest (Requestable $requestInstance) { + // Init variables + $commandName = ""; + $commandInstance = null; + + // This goes fine so let's resolv the command + $commandName = $requestInstance->getRequestElement('page'); + + // Is the command empty? Then fall back to default command + if (empty($commandName)) $commandName = $this->getConfigInstance()->readConfig('default_image_command'); + + // Check if command is valid + if ($this->isCommandValid($commandName) === false) { + // This command is invalid! + throw new InvalidCommandException(array($this, $commandName), self::EXCEPTION_INVALID_COMMAND); + } // END - if + + // Get the command + $commandInstance = $this->loadCommand($commandName); + + // And validate it + if ((!is_object($commandInstance)) || (!$commandInstance instanceof Commandable)) { + // This command has an invalid instance! + throw new InvalidCommandInstanceException(array($this, $commandName), self::EXCEPTION_INVALID_COMMAND); + } // END - if + + // Set last command + $this->lastCommandInstance = $commandInstance; + + // Return the resolved command instance + return $commandInstance; + } + + /** + * Resolves the command by its direct name and returns an instance of its class + * + * @param $commandName The direct command name we shall resolve + * @return $commandInstance An instance of the command class + * @throws InvalidCommandException Thrown if $commandName is invalid + */ + public function resolveCommand ($commandName) { + // Initiate the instance variable + $commandInstance = null; + + // Is the command empty? Then fall back to default command + if (empty($commandName)) $commandName = $this->getConfigInstance()->readConfig('default_image_command'); + + // Check if command is valid + if ($this->isCommandValid($commandName) === false) { + // This command is invalid! + throw new InvalidCommandException(array($this, $commandName), self::EXCEPTION_INVALID_COMMAND); + } + + // Get the command + $commandInstance = $this->loadCommand($commandName); + + // Return the instance + return $commandInstance; + } + + /** + * "Loads" a given command and instances it if not yet cached + * + * @param $commandName A command name we shall look for + * @return $commandInstance A loaded command instance + * @throws InvalidCommandException Thrown if even the default + * command class is missing (bad!) + */ + private function loadCommand ($commandName) { + // Cache default command + $defaultCommand = $this->getConfigInstance()->readConfig('default_image_command'); + + // Init command instance + $commandInstance = null; + + // Create command class name + $this->setClassName(sprintf("Image%sCommand", + $this->convertToClassName($commandName) + )); + + // Is this class loaded? + if (!class_exists($this->getClassName())) { + // Class not found, so throw an exception + throw new InvalidCommandException(array($this, $defaultCommand), self::EXCEPTION_INVALID_COMMAND); + } // END - if + + // Initiate the command + $commandInstance = ObjectFactory::createObjectByName($this->getClassName(), array($this)); + + // Return the result + return $commandInstance; + } +} + +// [EOF] +?> diff --git a/inc/classes/main/resolver/command/web/.htaccess b/inc/classes/main/resolver/command/web/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/resolver/command/web/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/resolver/command/web/class_ b/inc/classes/main/resolver/command/web/class_ new file mode 100644 index 00000000..48080866 --- /dev/null +++ b/inc/classes/main/resolver/command/web/class_ @@ -0,0 +1,178 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class Web???CommandResolver extends BaseCommandResolver implements CommandResolver { + /** + * Last successfull resolved command + */ + private $lastCommandInstance = null; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set prefix to "Web" + $this->setCommandPrefix("Web"); + } + + /** + * Creates an instance of a Web command resolver with a given default command + * + * @param $commandName The default command we shall execute + * @param $appInstance An instance of a manageable application helper class + * @return $resolverInstance The prepared command resolver instance + * @throws EmptyVariableException Thrown if the default command is not set + * @throws InvalidCommandException Thrown if the default command is invalid + */ + public final static function createWeb???CommandResolver ($commandName, ManageableApplication $appInstance) { + // Create the new instance + $resolverInstance = new Web???CommandResolver(); + + // Is the variable $commandName set and the command is valid? + if (empty($commandName)) { + // Then thrown an exception here + throw new EmptyVariableException(array($resolverInstance, 'commandName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); + } elseif ($resolverInstance->isCommandValid($commandName) === false) { + // Invalid command found + throw new InvalidCommandException(array($resolverInstance, $commandName), self::EXCEPTION_INVALID_COMMAND); + } + + // Set the application instance + $resolverInstance->setApplicationInstance($appInstance); + + // Return the prepared instance + return $resolverInstance; + } + + /** + * Returns an command instance for a given request class or null if + * it was not found + * + * @param $requestInstance An instance of a request class + * @return $commandInstance An instance of the resolved command + * @throws InvalidCommandException Thrown if $commandName is + * invalid + * @throws InvalidCommandInstanceException Thrown if $commandInstance + * is an invalid instance + */ + public function resolveCommandByRequest (Requestable $requestInstance) { + // Init variables + $commandName = ""; + $commandInstance = null; + + // This goes fine so let's resolv the command + $commandName = $requestInstance->getRequestElement('page'); + + // Is the command empty? Then fall back to default command + if (empty($commandName)) $commandName = $this->getConfigInstance()->readConfig('default_web_command'); + + // Check if the command is valid + if ($this->isCommandValid($commandName) === false) { + // This command is invalid! + throw new InvalidCommandException(array($this, $commandName), self::EXCEPTION_INVALID_COMMAND); + } // END - if + + // Get the command + $commandInstance = $this->loadCommand($commandName); + + // And validate it + if ((!is_object($commandInstance)) || (!$commandInstance instanceof Commandable)) { + // This command has an invalid instance! + throw new InvalidCommandInstanceException(array($this, $commandName), self::EXCEPTION_INVALID_COMMAND); + } // END - if + + // Set last command + $this->lastCommandInstance = $commandInstance; + + // Return the resolved command instance + return $commandInstance; + } + + /** + * Resolves the command by its direct name and returns an instance of its class + * + * @param $commandName The direct command name we shall resolve + * @return $commandInstance An instance of the command class + * @throws InvalidCommandException Thrown if $commandName is invalid + */ + public function resolveCommand ($commandName) { + // Initiate the instance variable + $commandInstance = null; + + // Is the command empty? Then fall back to default command + if (empty($commandName)) $commandName = $this->getConfigInstance()->readConfig('default_web_command'); + + // Check if the command is valid + if ($this->isCommandValid($commandName) === false) { + // This command is invalid! + throw new InvalidCommandException(array($this, $commandName), self::EXCEPTION_INVALID_COMMAND); + } + + // Get the command + $commandInstance = $this->loadCommand($commandName); + + // Return the instance + return $commandInstance; + } + + /** + * "Loads" a given command and instances it if not yet cached + * + * @param $commandName A command name we shall look for + * @return $commandInstance A loaded command instance + * @throws InvalidCommandException Thrown if even the default + * command class is missing (bad!) + */ + private function loadCommand ($commandName) { + // Cache default command + $defaultCommand = $this->getConfigInstance()->readConfig('default_web_command'); + + // Init command instance + $commandInstance = null; + + // Create command class name + $this->setClassName(sprintf("Web%sCommand", + $this->convertToClassName($commandName) + )); + + // Is this class loaded? + if (!class_exists($this->getClassName())) { + // Class not found, so throw an exception + throw new InvalidCommandException(array($this, $defaultCommand), self::EXCEPTION_INVALID_COMMAND); + } // END - if + + // Initiate the command + $commandInstance = ObjectFactory::createObjectByName($this->getClassName(), array($this)); + + // Return the result + return $commandInstance; + } +} + +// [EOF] +?> diff --git a/inc/classes/main/resolver/command/web/class_WebCommandResolver.php b/inc/classes/main/resolver/command/web/class_WebCommandResolver.php new file mode 100644 index 00000000..42ae37a8 --- /dev/null +++ b/inc/classes/main/resolver/command/web/class_WebCommandResolver.php @@ -0,0 +1,178 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class WebCommandResolver extends BaseCommandResolver implements CommandResolver { + /** + * Last successfull resolved command + */ + private $lastCommandInstance = null; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set prefix to "Web" + $this->setCommandPrefix("Web"); + } + + /** + * Creates an instance of a Web command resolver with a given default command + * + * @param $commandName The default command we shall execute + * @param $appInstance An instance of a manageable application helper class + * @return $resolverInstance The prepared command resolver instance + * @throws EmptyVariableException Thrown if default command is not set + * @throws InvalidCommandException Thrown if default command is invalid + */ + public final static function createWebCommandResolver ($commandName, ManageableApplication $appInstance) { + // Create the new instance + $resolverInstance = new WebCommandResolver(); + + // Is the variable $commandName set and the command is valid? + if (empty($commandName)) { + // Then thrown an exception here + throw new EmptyVariableException(array($resolverInstance, 'commandName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); + } elseif ($resolverInstance->isCommandValid($commandName) === false) { + // Invalid command found + throw new InvalidCommandException(array($resolverInstance, $commandName), self::EXCEPTION_INVALID_COMMAND); + } + + // Set the application instance + $resolverInstance->setApplicationInstance($appInstance); + + // Return the prepared instance + return $resolverInstance; + } + + /** + * Returns an command instance for a given request class or null if + * it was not found + * + * @param $requestInstance An instance of a request class + * @return $commandInstance An instance of the resolved command + * @throws InvalidCommandException Thrown if $commandName is + * invalid + * @throws InvalidCommandInstanceException Thrown if $commandInstance + * is an invalid instance + */ + public function resolveCommandByRequest (Requestable $requestInstance) { + // Init variables + $commandName = ""; + $commandInstance = null; + + // This goes fine so let's resolv the command + $commandName = $requestInstance->getRequestElement('page'); + + // Is the command empty? Then fall back to default command + if (empty($commandName)) $commandName = $this->getConfigInstance()->readConfig('default_web_command'); + + // Check if command is valid + if ($this->isCommandValid($commandName) === false) { + // This command is invalid! + throw new InvalidCommandException(array($this, $commandName), self::EXCEPTION_INVALID_COMMAND); + } // END - if + + // Get the command + $commandInstance = $this->loadCommand($commandName); + + // And validate it + if ((!is_object($commandInstance)) || (!$commandInstance instanceof Commandable)) { + // This command has an invalid instance! + throw new InvalidCommandInstanceException(array($this, $commandName), self::EXCEPTION_INVALID_COMMAND); + } // END - if + + // Set last command + $this->lastCommandInstance = $commandInstance; + + // Return the resolved command instance + return $commandInstance; + } + + /** + * Resolves the command by its direct name and returns an instance of its class + * + * @param $commandName The direct command name we shall resolve + * @return $commandInstance An instance of the command class + * @throws InvalidCommandException Thrown if $commandName is invalid + */ + public function resolveCommand ($commandName) { + // Initiate the instance variable + $commandInstance = null; + + // Is the command empty? Then fall back to default command + if (empty($commandName)) $commandName = $this->getConfigInstance()->readConfig('default_web_command'); + + // Check if command is valid + if ($this->isCommandValid($commandName) === false) { + // This command is invalid! + throw new InvalidCommandException(array($this, $commandName), self::EXCEPTION_INVALID_COMMAND); + } + + // Get the command + $commandInstance = $this->loadCommand($commandName); + + // Return the instance + return $commandInstance; + } + + /** + * "Loads" a given command and instances it if not yet cached + * + * @param $commandName A command name we shall look for + * @return $commandInstance A loaded command instance + * @throws InvalidCommandException Thrown if even the default + * command class is missing (bad!) + */ + private function loadCommand ($commandName) { + // Cache default command + $defaultCommand = $this->getConfigInstance()->readConfig('default_web_command'); + + // Init command instance + $commandInstance = null; + + // Create command class name + $this->setClassName(sprintf("Web%sCommand", + $this->convertToClassName($commandName) + )); + + // Is this class loaded? + if (!class_exists($this->getClassName())) { + // Class not found, so throw an exception + throw new InvalidCommandException(array($this, $defaultCommand), self::EXCEPTION_INVALID_COMMAND); + } // END - if + + // Initiate the command + $commandInstance = ObjectFactory::createObjectByName($this->getClassName(), array($this)); + + // Return the result + return $commandInstance; + } +} + +// [EOF] +?> diff --git a/inc/classes/main/resolver/controller/.htaccess b/inc/classes/main/resolver/controller/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/resolver/controller/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/resolver/controller/class_BaseControllerResolver.php b/inc/classes/main/resolver/controller/class_BaseControllerResolver.php new file mode 100644 index 00000000..a667fe6c --- /dev/null +++ b/inc/classes/main/resolver/controller/class_BaseControllerResolver.php @@ -0,0 +1,126 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseControllerResolver extends BaseResolver { + /** + * Prefix for local, remote or other resolver + */ + private $controllerPrefix = ""; + + /** + * Validated controller name + */ + private $controllerName = ""; + + /** + * Protected constructor + * + * @param $className Name of the real class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } + + /** + * Setter for controller prefix + * + * @param $controllerPrefix Last validated controllerPrefix + * @return void + */ + protected final function setControllerPrefix ($controllerPrefix) { + $this->controllerPrefix = $controllerPrefix; + } + + /** + * Setter for controller name + * + * @param $controllerName Last validated controller name + * @return void + */ + protected final function setControllerName ($controllerName) { + $this->controllerName = $controllerName; + } + + /** + * Getter for controller name + * + * @return $controllerName Last validated controller name + */ + public final function getControllerName () { + return $this->controllerName; + } + + /** + * Checks wether the given controller is valid + * + * @param $controllerName The default controller we shall execute + * @return $isValid Wether the given controller is valid + * @throws EmptyVariableException Thrown if given controller is not set + * @throws DefaultControllerException Thrown if default controller was not found + */ + public function isControllerValid ($controllerName) { + // By default nothing shall be valid + $isValid = false; + + // Is a controller set? + if (empty($controllerName)) { + // Then thrown an exception here + throw new EmptyVariableException(array($this, 'controllerName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); + } // END - if + + // Now, let us create the full name of the controller class + $this->setClassName(sprintf("%s%sController", + $this->controllerPrefix, + $this->convertToClassName($controllerName) + )); + + // Try it hard to get an controller + while ($isValid === false) { + // Is this class already loaded? + if (class_exists($this->getClassName())) { + // This class does exist. :-) + $isValid = true; + } elseif (($this->getClassName() != $this->controllerPrefix.'DefaultController') && ($this->getClassName() != $this->controllerPrefix.'DefaultNewsController')) { + // Do we have news? + if ($this->getConfigInstance()->readConfig('page_with_news') == $this->getApplicationInstance()->getRequestInstance()->getRequestElement('page')) { + // Yes, display news in home then set default controller with news + $this->setClassName($this->controllerPrefix . 'DefaultNewsController'); + } else { + // No news at home page or non-news page + $this->setClassName($this->controllerPrefix . 'DefaultController'); + } + } else { + // All is tried, give it up here + throw new DefaultControllerException($this, self::EXCEPTION_DEFAULT_CONTROLLER_GONE); + } + } // END - while + + // Return the result + return $isValid; + } +} + +// [EOF] +?> diff --git a/inc/classes/main/resolver/controller/image/.htaccess b/inc/classes/main/resolver/controller/image/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/resolver/controller/image/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/resolver/controller/image/class_ImageControllerResolver.php b/inc/classes/main/resolver/controller/image/class_ImageControllerResolver.php new file mode 100644 index 00000000..39d88d16 --- /dev/null +++ b/inc/classes/main/resolver/controller/image/class_ImageControllerResolver.php @@ -0,0 +1,161 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ImageControllerResolver extends BaseControllerResolver implements ControllerResolver { + /** + * Last successfull resolved controller (name) + */ + private $lastControllerName = ""; + + /** + * Last successfull resolved controller (instance) + */ + private $lastControllerInstance = null; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set prefix to "Image" + $this->setControllerPrefix("Image"); + } + + /** + * Creates an instance of a resolver class with a given command + * + * @param $controllerName The controller we shall resolve + * @param $appInstance An instance of a manageable application helper class + * @return $resolverInstance The prepared controller resolver instance + * @throws EmptyVariableException Thrown if default command is not set + * @throws InvalidControllerException Thrown if default controller is invalid + */ + public final static function createImageControllerResolver ($controllerName, ManageableApplication $appInstance) { + // Create the new instance + $resolverInstance = new ImageControllerResolver(); + + // Is the variable $controllerName set and the command is valid? + if (empty($controllerName)) { + // Then thrown an exception here + throw new EmptyVariableException(array($resolverInstance, 'commandName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); + } elseif ($resolverInstance->isControllerValid($controllerName) === false) { + // Invalid command found + throw new InvalidControllerException(array($resolverInstance, $controllerName), self::EXCEPTION_INVALID_CONTROLLER); + } + + // Set the application instance + $resolverInstance->setApplicationInstance($appInstance); + + // Set command name + $resolverInstance->setControllerName($controllerName); + + // Return the prepared instance + return $resolverInstance; + } + + /** + * Resolves the default controller of the given command + * + * @return $controllerInstance A controller instance for the default + * command + * @throws InvalidControllerInstanceException Thrown if $controllerInstance + * is invalid + */ + public function resolveController () { + // Init variables + $controllerName = ""; + $controllerInstance = null; + + // Get the command name + $controllerName = $this->getControllerName(); + + // Get the command + $controllerInstance = $this->loadController($controllerName); + + // And validate it + if ((!is_object($controllerInstance)) || (!$controllerInstance instanceof Controller)) { + // This command has an invalid instance! + throw new InvalidControllerInstanceException(array($this, $controllerName), self::EXCEPTION_INVALID_CONTROLLER); + } // END - if + + // Set last controller + $this->lastControllerInstance = $controllerInstance; + + // Return the maybe resolved instance + return $controllerInstance; + } + + /** + * "Loads" a given controller and instances it if not yet cached. If the + * controller was not found one of the default controllers will be used + * depending on wether news shall be displayed. + * + * @param $controllerName A controller name we shall look for + * @return $controllerInstance A loaded controller instance + * @throws InvalidControllerException Thrown if even the requested + * controller class is missing (bad!) + */ + private function loadController ($controllerName) { + // Cache default command + $defaultController = $this->getConfigInstance()->readConfig('default_image_command'); + + // Init controller instance + $controllerInstance = null; + + // Default controller + $this->setClassName($defaultController); + + // Generate the class name + //* DEBUG: */ echo __METHOD__.": Controller=".$controllerName; + if ($controllerName != $defaultController) { + // Create controller class name + $this->setClassName(sprintf("Image%sController", + $this->convertToClassName($controllerName) + )); + } // END - if + //* DEBUG: */ echo ", controller=".$this->getClassName()."
\n"; + + // Is this class loaded? + if (!class_exists($this->getClassName())) { + // Class not found, so or throw an exception + throw new InvalidControllerException(array($this, $controllerName), self::EXCEPTION_INVALID_CONTROLLER); + } // END - if + + // Initiate the resolver and controller + $resolverInstance = ObjectFactory::createObjectByConfiguredName('image_cmd_resolver_class', array($controllerName, $this->getApplicationInstance())); + $controllerInstance = ObjectFactory::createObjectByName($this->getClassName(), array($resolverInstance)); + + // Remove resolver + unset($resolverInstance); + + // Return the result + return $controllerInstance; + } +} + +// [EOF] +?> diff --git a/inc/classes/main/resolver/controller/web/.htaccess b/inc/classes/main/resolver/controller/web/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/resolver/controller/web/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/resolver/controller/web/class_WebControllerResolver.php b/inc/classes/main/resolver/controller/web/class_WebControllerResolver.php new file mode 100644 index 00000000..53780060 --- /dev/null +++ b/inc/classes/main/resolver/controller/web/class_WebControllerResolver.php @@ -0,0 +1,182 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class WebControllerResolver extends BaseControllerResolver implements ControllerResolver { + /** + * Last successfull resolved controller (name) + */ + private $lastControllerName = ""; + + /** + * Last successfull resolved controller (instance) + */ + private $lastControllerInstance = null; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set prefix to "Web" + $this->setControllerPrefix("Web"); + } + + /** + * Creates an instance of a resolver class with a given command + * + * @param $controllerName The controller we shall resolve + * @param $appInstance An instance of a manageable application helper class + * @return $resolverInstance The prepared controller resolver instance + * @throws EmptyVariableException Thrown if default command is not set + * @throws InvalidControllerException Thrown if default controller is invalid + */ + public final static function createWebControllerResolver ($controllerName, ManageableApplication $appInstance) { + // Create the new instance + $resolverInstance = new WebControllerResolver(); + + // Is the variable $controllerName set and the command is valid? + if (empty($controllerName)) { + // Then thrown an exception here + throw new EmptyVariableException(array($resolverInstance, 'commandName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); + } elseif ($resolverInstance->isControllerValid($controllerName) === false) { + // Invalid command found + throw new InvalidControllerException(array($resolverInstance, $controllerName), self::EXCEPTION_INVALID_CONTROLLER); + } + + // Set the application instance + $resolverInstance->setApplicationInstance($appInstance); + + // Set command name + $resolverInstance->setControllerName($controllerName); + + // Return the prepared instance + return $resolverInstance; + } + + /** + * Resolves the default controller of the given command + * + * @return $controllerInstance A controller instance for the default + * command + * @throws InvalidControllerInstanceException Thrown if $controllerInstance + * is invalid + */ + public function resolveController () { + // Init variables + $controllerName = ""; + $controllerInstance = null; + + // Get the command name + $controllerName = $this->getControllerName(); + + // Get the command + $controllerInstance = $this->loadController($controllerName); + + // And validate it + if ((!is_object($controllerInstance)) || (!$controllerInstance instanceof Controller)) { + // This command has an invalid instance! + throw new InvalidControllerInstanceException(array($this, $controllerName), self::EXCEPTION_INVALID_CONTROLLER); + } // END - if + + // Set last controller + $this->lastControllerInstance = $controllerInstance; + + // Return the maybe resolved instance + return $controllerInstance; + } + + /** + * "Loads" a given controller and instances it if not yet cached. If the + * controller was not found one of the default controllers will be used + * depending on wether news shall be displayed. + * + * @param $controllerName A controller name we shall look for + * @return $controllerInstance A loaded controller instance + * @throws InvalidControllerException Thrown if even the requested + * controller class is missing (bad!) + */ + private function loadController ($controllerName) { + // Cache default command + $defaultController = $this->getConfigInstance()->readConfig('default_web_command'); + + // Init controller instance + $controllerInstance = null; + + // Default controller + $this->setClassName('WebDefaultController'); + + // Generate the class name + //* DEBUG: */ echo __METHOD__.": Controller=".$controllerName; + if ($controllerName != $defaultController) { + // Create controller class name + $this->setClassName(sprintf("Web%sController", + $this->convertToClassName($controllerName) + )); + } elseif ($this->getConfigInstance()->readConfig('page_with_news') == $this->getApplicationInstance()->getRequestInstance()->getRequestElement('page')) { + // Yes, display news in home then set default controller with news + $this->setClassName('WebDefaultNewsController'); + } else { + // No news at home page or non-news page + $this->setClassName('WebDefaultController'); + } + //* DEBUG: */ echo ", controller=".$this->getClassName()."
\n"; + + // Is this class loaded? + if (!class_exists($this->getClassName())) { + // Throw an exception here + throw new InvalidControllerException(array($this, $controllerName), self::EXCEPTION_INVALID_CONTROLLER); + } // END - if + + // Set default resolver config name + $resolverConfigEntry = ""; + + // Try to read a config entry for our resolver including controller name... ;-) + try { + // Create the resolver name + $resolverConfigEntry = sprintf("web_cmd_%s_resolver_class", strtolower($controllerName)); + + // Get the config, this will throw an exception if there is no special command resolver + $resolverClass = $this->getConfigInstance()->readConfig($resolverConfigEntry); + } catch (ConfigEntryNotFoundException $e) { + // Use default resolver entry + $resolverConfigEntry = "web_cmd_resolver_class"; + } + + // Initiate the resolver and controller + $resolverInstance = ObjectFactory::createObjectByConfiguredName($resolverConfigEntry, array($controllerName, $this->getApplicationInstance())); + $controllerInstance = ObjectFactory::createObjectByName($this->getClassName(), array($resolverInstance)); + + // Remove resolver (we don't need it anymore) + unset($resolverInstance); + + // Return the result + return $controllerInstance; + } +} + +// [EOF] +?> diff --git a/inc/classes/main/response/.htaccess b/inc/classes/main/response/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/response/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/response/class_BaseResponse.php b/inc/classes/main/response/class_BaseResponse.php new file mode 100644 index 00000000..1bbf5748 --- /dev/null +++ b/inc/classes/main/response/class_BaseResponse.php @@ -0,0 +1,211 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * The extended headers are taken from phpMyAdmin setup tool, written by + * Michal Cihar , licensed under GNU GPL 2.0. + */ +class BaseResponse extends BaseFrameworkSystem { + /** + * Response status + */ + private $responseStatus = "200 OK"; + + /** + * Array with all headers + */ + private $responseHeaders = array(); + + /** + * Cookies we shall sent out + */ + private $cookies = array(); + + /** + * Body of the response + */ + private $responseBody = ""; + + /** + * Instance of the template engine + */ + private $templateInstance = null; + + /** + * Fatal resolved messages from filters and so on + */ + private $fatalMessages = array(); + + /** + * Protected constructor + * + * @param $className Name of the concrete response + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + + // Clean up a little + $this->removeNumberFormaters(); + $this->removeSystemArray(); + } + + /** + * Setter for status + * + * @param $status New response status + * @return void + */ + public final function setResponseStatus ($status) { + $this->responseStatus = (string) $status; + } + + /** + * Add header element + * + * @param $name Name of header element + * @param $value Value of header element + * @return void + */ + public final function addHeader ($name, $value) { + $this->responseHeaders[$name] = $value; + } + + /** + * Reset the header array + * + * @return void + */ + public final function resetResponseHeaders () { + $this->responseHeaders = array(); + } + + /** + * "Writes" data to the response body + * + * @param $output Output we shall sent in the HTTP response + * @return void + */ + public final function writeToBody ($output) { + $this->responseBody .= $output; + } + + /** + * Sets the response body to something new + * + * @param $output Output we shall sent in the HTTP response + * @return void + */ + public final function setResponseBody ($output) { + $this->responseBody = $output; + } + + /** + * Adds a fatal message id to the response. The added messages can then be + * processed and outputed to the world + * + * @param $messageId The message id we shall add + * @return void + */ + public final function addFatalMessage ($messageId) { + // Adds the resolved message id to the fatal message list + $this->fatalMessages[] = $this->getApplicationInstance()->getLanguageInstance()->getMessage($messageId); + } + + /** + * Adds a plain fatal message id to the response + * + * @param $message The plain message we shall add + * @return void + */ + public final function addFatalMessagePlain ($message) { + // Adds the resolved message id to the fatal message list + $this->fatalMessages[] = $message; + } + + /** + * Flushs the cached HTTP response to the outer world + * + * @param $force Wether we shall force the output or abort if headers are + * already sent with an exception + * @return void + * @throws ResponseHeadersAlreadySentException Thrown if headers are + * already sent + */ + public function flushBuffer ($force = false) { + if ((headers_sent()) && ($force === false)) { + // Headers are already sent! + throw new ResponseHeadersAlreadySentException($this, self::EXCEPTION_HEADERS_ALREADY_SENT); + } elseif (!headers_sent()) { + // Send headers out + header("HTTP/1.1 {$this->responseStatus}"); + + // Used later + $now = gmdate('D, d M Y H:i:s') . ' GMT'; + + // General header for no caching + $this->addHeader('Expired', $now); // RFC2616 - Section 14.21 + $this->addHeader('Last-Modified', $now); + $this->addHeader('Cache-Control', 'no-store, no-cache, must-revalidate, pre-check=0, post-check=0, max-age=0'); // HTTP/1.1 + $this->addHeader('Pragma', 'no-cache'); // HTTP/1.0 + + // Define the charset to be used + //$this->addHeader('Content-type:', sprintf("text/html; charset=%s", $this->getConfigInstance()->readConfig('header_charset'))); + + // Send all headers + foreach ($this->responseHeaders as $name => $value) { + header("{$name}: {$value}"); + //* DEBUG: */ echo "{$name}: {$value}
\n"; + } // END - foreach + + // Send cookies out? + if (count($this->cookies) > 0) { + // Send all cookies + $cookieString = implode(" ", $this->cookies); + header("Set-Cookie: {$cookieString}"); + + // Remove them all + $this->cookies = array(); + } // END - if + } + + // Are there some error messages? + if (count($this->fatalMessages) == 0) { + // Flush the output to the world + $this->getWebOutputInstance()->output($this->responseBody); + } else { + // Display all error messages + $this->getApplicationInstance()->handleFatalMessages($this->fatalMessages); + + // Send the error messages out to the world + $this->getWebOutputInstance()->output($this->responseBody); + } + + // Clear response header and body + $this->setResponseBody(""); + $this->resetResponseHeaders(); + } +} + +// [EOF] +?> diff --git a/inc/classes/main/response/http/.htaccess b/inc/classes/main/response/http/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/response/http/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/response/http/class_HttpResponse.php b/inc/classes/main/response/http/class_HttpResponse.php new file mode 100644 index 00000000..50bf2deb --- /dev/null +++ b/inc/classes/main/response/http/class_HttpResponse.php @@ -0,0 +1,211 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * The extended headers are taken from phpMyAdmin setup tool, written by + * Michal Cihar , licensed under GNU GPL 2.0. + */ +class HttpResponse extends BaseResponse implements Responseable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an object of this class + * + * @param $appInstance An instance of a manageable application + * @return $responseInstance A prepared instance of this class + */ + public final static function createHttpResponse (ManageableApplication $appInstance) { + // Get a new instance + $responseInstance = new HttpResponse(); + + // Set the application instance + $responseInstance->setApplicationInstance($appInstance); + + // Initialize the template engine here + $responseInstance->initTemplateEngine($appInstance); + + // Return the prepared instance + return $responseInstance; + } + + /** + * Initializes the template engine instance + * + * @param $appInstance An instance of a manageable application + * @return void + */ + public final function initTemplateEngine (ManageableApplication $appInstance) { + $this->setTemplateInstance($this->prepareTemplateInstance($appInstance)); + } + + /** + * Adds a cookie to the response + * + * @param $cookieName Cookie's name + * @param $cookieValue Value to store in the cookie + * @param $encrypted Do some extra encryption on the value + * @param $expires Timestamp of expiration (default: configured) + * @return void + * @throws ResponseHeadersAlreadySentException If headers are already sent + * @todo Encryption of cookie data not yet supported. + * @todo Why are these parameters conflicting? + * @todo If the return statement is removed and setcookie() commented out, + * @todo this will send only one cookie out, the first one. + */ + public function addCookie ($cookieName, $cookieValue, $encrypted = false, $expires = null) { + //* DEBUG: */ echo $cookieName."=".$cookieValue."
\n"; + // Are headers already sent? + if (headers_sent()) { + // Throw an exception here + //* DEBUG: */ return; + throw new ResponseHeadersAlreadySentException($this, self::EXCEPTION_HEADERS_ALREADY_SENT); + } // END - if + + // Shall we encrypt the cookie? + if ($encrypted === true) { + } // END - if + + // For slow browsers set the cookie array element first + $_COOKIE[$cookieName] = $cookieValue; + + // Get all config entries + if (is_null($expires)) { + $expires = (time() + $this->getConfigInstance()->readConfig('cookie_expire')); + } // END - if + + $path = $this->getConfigInstance()->readConfig('cookie_path'); + $domain = $this->getConfigInstance()->readConfig('cookie_domain'); + + setcookie($cookieName, $cookieValue, $expires); + //, $path, $domain, (isset($_SERVER['HTTPS'])) + return; + + // Now construct the full header + $cookieString = $cookieName . "=" . $cookieValue . "; "; + $cookieString .= "expires=" . date("D, d-F-Y H:i:s", $expires) . " GMT"; + // $cookieString .= "; path=".$path."; domain=".$domain; + + // Set the cookie as a header + $this->cookies[$cookieName] = $cookieString; + } + + /** + * Redirect to a configured URL. The URL can be absolute or relative. In + * case of relative URL it will be extended automatically. + * + * @param $configEntry The configuration entry which holds our URL + * @return void + * @throws ResponseHeadersAlreadySentException If headers are already sent + */ + public function redirectToConfiguredUrl ($configEntry) { + // Is the header not yet sent? + if (headers_sent()) { + // Throw an exception here + throw new ResponseHeadersAlreadySentException($this, self::EXCEPTION_HEADERS_ALREADY_SENT); + } // END - if + + // Assign application data + $this->getTemplateInstance()->assignApplicationData($this->getApplicationInstance()); + + // Get the url from config + $url = $this->getConfigInstance()->readConfig($configEntry); + + // Compile the URL + $url = $this->getTemplateInstance()->compileRawCode($url); + + // Do we have a "http" in front of the URL? + if (substr(strtolower($url), 0, 4) != "http") { + // Is there a / in front of the relative URL? + if (substr($url, 0, 1) == "/") $url = substr($url, 1); + + // No, then extend it with our base URL + $url = $this->getConfigInstance()->readConfig('base_url') . "/" . $url; + } // END - if + + // Add redirect header + $this->addHeader("Location", $url); + + // Set correct response status + $this->setResponseStatus("301 Moved Permanently"); + + // Clear the body + $this->setResponseBody(""); + + // Flush the result + $this->flushBuffer(); + + // All done here... + exit(); + } + + /** + * Expires the given cookie if it is set + * + * @param $cookieName Cookie to expire + * @return void + */ + public function expireCookie ($cookieName) { + // Is the cookie there? + if (isset($_COOKIE[$cookieName])) { + // Then expire it with 20 minutes past + $this->addCookie($cookieName, "", false, (time() - 1200)); + + // Remove it from array + unset($_COOKIE[$cookieName]); + } // END - if + } + + /** + * Refreshs a given cookie. This will make the cookie live longer + * + * @param $cookieName Cookie to refresh + * @return void + */ + public function refreshCookie ($cookieName) { + // Only update existing cookies + if (isset($_COOKIE[$cookieName])) { + // Update the cookie + $this->addCookie($cookieName, $_COOKIE[$cookieName], false); + } // END - if + } + + /** + * Getter for default command + * + * @return $defaultCommand Default command for this response + */ + public function getDefaultCommand () { + $defaultCommand = $this->getConfigInstance()->readConfig('default_web_command'); + return $defaultCommand; + } +} + +// [EOF] +?> diff --git a/inc/classes/main/response/image/.htaccess b/inc/classes/main/response/image/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/response/image/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/response/image/class_ImageResponse.php b/inc/classes/main/response/image/class_ImageResponse.php new file mode 100644 index 00000000..c03e6ea6 --- /dev/null +++ b/inc/classes/main/response/image/class_ImageResponse.php @@ -0,0 +1,268 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * The extended headers are taken from phpMyAdmin setup tool, written by + * Michal Cihar , licensed under GNU GPL 2.0. + */ +class ImageResponse extends BaseResponse implements Responseable { + /** + * Instance of the image + */ + private $imageInstance = null; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an object of this class + * + * @param $appInstance An instance of a manageable application + * @return $responseInstance A prepared instance of this class + */ + public final static function createImageResponse (ManageableApplication $appInstance) { + // Get a new instance + $responseInstance = new ImageResponse(); + + // Set the application instance + $responseInstance->setApplicationInstance($appInstance); + + // Initialize the template engine here + $responseInstance->initTemplateEngine($appInstance); + + // Return the prepared instance + return $responseInstance; + } + + /** + * Initializes the template engine instance + * + * @param $appInstance An instance of a manageable application + * @return void + */ + public final function initTemplateEngine (ManageableApplication $appInstance) { + // Get config instance + $cfg = $this->getConfigInstance(); + + // Set new template engine + $cfg->setConfigEntry('template_class' , $cfg->readConfig('image_template_class')); + $cfg->setConfigEntry('raw_template_extension' , ".img"); + $cfg->setConfigEntry('code_template_extension', ".itp"); + $cfg->setConfigEntry('tpl_base_path' , "templates/images/"); + $cfg->setConfigEntry('code_template_type' , "image"); + + // Get a prepared instance + $this->setTemplateInstance($this->prepareTemplateInstance($appInstance)); + } + + /** + * Adds a cookie to the response + * + * @param $cookieName Cookie's name + * @param $cookieValue Value to store in the cookie + * @param $encrypted Do some extra encryption on the value + * @param $expires Timestamp of expiration (default: configured) + * @return void + * @throws ResponseHeadersAlreadySentException If headers are already sent + * @todo Encryption of cookie data not yet supported. + * @todo Why are these parameters conflicting? + * @todo If the return statement is removed and setcookie() commented out, + * @todo this will send only one cookie out, the first one. + */ + public function addCookie ($cookieName, $cookieValue, $encrypted = false, $expires = null) { + // Are headers already sent? + if (headers_sent()) { + // Throw an exception here + throw new ResponseHeadersAlreadySentException($this, self::EXCEPTION_HEADERS_ALREADY_SENT); + } // END - if + + // Shall we encrypt the cookie? + if ($encrypted === true) { + } // END - if + + // For slow browsers set the cookie array element first + $_COOKIE[$cookieName] = $cookieValue; + + // Get all config entries + if (is_null($expires)) { + $expires = (time() + $this->getConfigInstance()->readConfig('cookie_expire')); + } // END - if + + $path = $this->getConfigInstance()->readConfig('cookie_path'); + $domain = $this->getConfigInstance()->readConfig('cookie_domain'); + + setcookie($cookieName, $cookieValue, $expires); + //, $path, $domain, (isset($_SERVER['HTTPS'])) + return; + + // Now construct the full header + $cookieString = $cookieName . "=" . $cookieValue . "; "; + $cookieString .= "expires=" . date("D, d-F-Y H:i:s", $expires) . " GMT"; + // $cookieString .= "; path=".$path."; domain=".$domain; + + // Set the cookie as a header + $this->cookies[$cookieName] = $cookieString; + } + + /** + * Redirect to a configured URL. The URL can be absolute or relative. In + * case of relative URL it will be extended automatically. + * + * @param $configEntry The configuration entry which holds our URL + * @return void + * @throws ResponseHeadersAlreadySentException If headers are already sent + */ + public function redirectToConfiguredUrl ($configEntry) { + // Is the header not yet sent? + if (headers_sent()) { + // Throw an exception here + throw new ResponseHeadersAlreadySentException($this, self::EXCEPTION_HEADERS_ALREADY_SENT); + } // END - if + + // Assign application data + $this->getTemplateInstance()->assignApplicationData($this->getApplicationInstance()); + + // Get the url from config + $url = $this->getConfigInstance()->readConfig($configEntry); + + // Compile the URL + $url = $this->getTemplateInstance()->compileRawCode($url); + + // Do we have a "http" in front of the URL? + if (substr(strtolower($url), 0, 4) != "http") { + // Is there a / in front of the relative URL? + if (substr($url, 0, 1) == "/") $url = substr($url, 1); + + // No, then extend it with our base URL + $url = $this->getConfigInstance()->readConfig('base_url') . "/" . $url; + } // END - if + + // Add redirect header + $this->addHeader("Location", $url); + + // Set correct response status + $this->setResponseStatus("301 Moved Permanently"); + + // Clear the body + $this->setResponseBody(""); + + // Flush the result + $this->flushBuffer(); + + // All done here... + exit(); + } + + /** + * Flushs the cached HTTP response to the outer world + * + * @param $force Wether we shall force the output or abort if headers are + * already sent with an exception + * @return void + */ + public function flushBuffer ($force = false) { + // Finish the image + $this->getImageInstance()->finishImage(); + + // Get image content + $content = $this->getImageInstance()->getContent(); + + // Set it as response body + $this->setResponseBody($content); + + // Set content type + $this->addHeader('Content-type', "image/".$this->getImageInstance()->getImageType()); + + // Call parent method + parent::flushBuffer($force); + } + + /** + * Expires the given cookie if it is set + * + * @param $cookieName Cookie to expire + * @return void + */ + public function expireCookie ($cookieName) { + // Is the cookie there? + if (isset($_COOKIE[$cookieName])) { + // Then expire it with 20 minutes past + $this->addCookie($cookieName, "", false, (time() - 1200)); + + // Remove it from array + unset($_COOKIE[$cookieName]); + } // END - if + } + + /** + * Refreshs a given cookie. This will make the cookie live longer + * + * @param $cookieName Cookie to refresh + * @return void + */ + public function refreshCookie ($cookieName) { + // Only update existing cookies + if (isset($_COOKIE[$cookieName])) { + // Update the cookie + $this->addCookie($cookieName, $_COOKIE[$cookieName], false); + } // END - if + } + + /** + * Setter for image instanxe + * + * @param $imageInstance An instance of an image + * @return void + */ + public final function setImageInstance (BaseImage $imageInstance) { + $this->imageInstance = $imageInstance; + } + + /** + * Getter for image instanxe + * + * @return $imageInstance An instance of an image + */ + public final function getImageInstance () { + return $this->imageInstance; + } + + /** + * Getter for default command + * + * @return $defaultCommand Default command for this response + */ + public function getDefaultCommand () { + $defaultCommand = $this->getConfigInstance()->readConfig('default_image_command'); + return $defaultCommand; + } +} + +// [EOF] +?> diff --git a/inc/classes/main/result/.htaccess b/inc/classes/main/result/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/result/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/result/class_DatabaseResult.php b/inc/classes/main/result/class_DatabaseResult.php new file mode 100644 index 00000000..94fe3b5d --- /dev/null +++ b/inc/classes/main/result/class_DatabaseResult.php @@ -0,0 +1,404 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class DatabaseResult extends BaseFrameworkSystem implements SearchableResult, UpdateableResult, SeekableIterator { + // Exception constants + const EXCEPTION_INVALID_DATABASE_RESULT = 0x1c0; + const EXCEPTION_RESULT_UPDATE_FAILED = 0x1c1; + + /** + * Current position in array + */ + private $currentPos = -1; + + /** + * Current row + */ + private $currentRow = null; + + /** + * Result array + */ + private $resultArray = array(); + + /** + * Array of out-dated entries + */ + private $outDated = array(); + + /** + * Affected rows + */ + private $affectedRows = 0; + + /** + * Found value + */ + private $foundValue = ""; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Clean up a little + $this->removeNumberFormaters(); + $this->removeSystemArray(); + } + + /** + * Creates an instance of this result by a provided result array + * + * @param $resultArray The array holding the result from query + * @return $resultInstance An instance of this class + */ + public final static function createDatabaseResult (array $resultArray) { + // Get a new instance + $resultInstance = new DatabaseResult(); + + // Set the result array + $resultInstance->setResultArray($resultArray); + + // Return the instance + return $resultInstance; + } + + /** + * Setter for result array + * + * @param $resultArray The array holding the result from query + * @return void + */ + protected final function setResultArray (array $resultArray) { + $this->resultArray = $resultArray; + } + + /** + * Updates the current entry by given update criteria + * + * @param $updateInstance An instance of an Updateable criteria + * @return void + */ + private function updateCurrentEntryByCriteria (LocalUpdateCriteria $updateInstance) { + // Get the current entry key + $entryKey = $this->key(); + + // Now get the update criteria array and update all entries + foreach ($updateInstance->getUpdateCriteria() as $criteriaKey => $criteriaValue) { + // Update data + $this->resultArray['rows'][$entryKey][$criteriaKey] = $criteriaValue; + + // Mark it as out-dated + $this->outDated[$criteriaKey] = 1; + } // END - foreach + } + + /** + * "Iterator" method next() to advance to the next valid entry. This method + * does also check if result is invalid + * + * @return $nextValid Wether the next entry is valid + */ + public function next () { + // Default is not valid + $nextValid = false; + + // Is the result valid? + if ($this->valid()) { + // Next entry found, so count one up and cache it + $this->currentPos++; + $this->currentRow = $this->resultArray['rows'][$this->currentPos]; + $nextValid = true; + } // END - if + + // Return the result + return $nextValid; + } + + /** + * Seeks for to a specified position + * + * @param $index Index to seek for + * @return void + */ + public function seek ($index) { + // Rewind to beginning + $this->rewind(); + + // Search for the entry + while ($this->currentPos < $index && ($this->valid())) { + // Continue on + $this->next(); + } // END - while + } + + /** + * Gives back the current position or null if not found + * + * @return $current Current element to give back + */ + public function current () { + // Default is not found + $current = null; + + // Does the current enty exist? + if (isset($this->resultArray['rows'][$this->currentPos])) { + // Then get it + $current = $this->resultArray['rows'][$this->currentPos]; + } // END - if + + // Return the result + return $current; + } + + /** + * Checks if next() and rewind will give a valid result + * + * @return $isValid Wether the next/rewind entry is valid + */ + public function valid () { + // By default nothing is valid + $isValid = false; + + // Check if + if (($this->ifStatusIsOkay()) && (isset($this->resultArray['rows'][($this->currentPos + 1)])) && (isset($this->resultArray['rows'][0]))) { + // All fine! + $isValid = true; + } // END - if + + // Return the result + return $isValid; + } + + /** + * Determines wether the status of the query was fine ("ok") + * + * @return $ifStatusOkay Wether the status of the query was okay + */ + public function ifStatusIsOkay () { + return ((isset($this->resultArray['status'])) && ($this->resultArray['status'] === "ok")); + } + + /** + * Gets the current key of iteration + * + * @return $currentPos Key from iterator + */ + public function key () { + return $this->currentPos; + } + + /** + * Rewind to the beginning and clear array $currentRow + * + * @return void + */ + public function rewind () { + $this->currentPos = -1; + $this->currentRow = array(); + } + + /** + * Searches for an entry in data result and returns it + * + * @param $criteriaInstance The criteria to look inside the data set + * @return $result Found result entry + * @todo 0% done + */ + public function searchEntry (LocalSearchCriteria $criteriaInstance) { + die(__METHOD__.": Unfinished!"); + } + + /** + * Adds an update request to the database result for writing it to the + * database layer + * + * @param $criteriaInstance An instance of a updateable criteria + * @return void + * @throws ResultUpdateException If no result was updated + */ + public function add2UpdateQueue (LocalUpdateCriteria $criteriaInstance) { + // Rewind the pointer + $this->rewind(); + + // Get search criteria + $searchInstance = $criteriaInstance->getSearchInstance(); + + // And start looking for the result + $foundEntries = 0; + while (($this->valid()) && ($foundEntries < $searchInstance->getLimit())) { + // Get next entry + $this->next(); + $currentEntry = $this->current(); + + // Is this entry found? + if ($searchInstance->ifEntryMatches($currentEntry)) { + // Update this entry + $this->updateCurrentEntryByCriteria($criteriaInstance); + + // Count one up + $foundEntries++; + } // END - if + } // END - while + + // Set affected rows + $this->setAffectedRows($foundEntries); + + // If no entry is found/updated throw an exception + if ($foundEntries == 0) { + // Throw an exception here + throw new ResultUpdateException($this, self::EXCEPTION_RESULT_UPDATE_FAILED); + } // END - if + + // Set search instance + $this->setSearchInstance($searchInstance); + } + + /** + * Setter for affected rows + * + * @param $rows Number of affected rows + * @return void + */ + public final function setAffectedRows ($rows) { + $this->affectedRows = $rows; + } + + /** + * Getter for affected rows + * + * @return $rows Number of affected rows + */ + public final function getAffectedRows () { + return $this->affectedRows; + } + + /** + * Getter for found value of previous found() call + * + * @return $foundValue Found value of previous found() call + */ + public final function getFoundValue () { + return $this->foundValue; + } + + /** + * Checks wether we have out-dated entries or not + * + * @return $needsUpdate Wether we have out-dated entries + */ + public function ifDataNeedsFlush () { + $needsUpdate = (count($this->outDated) > 0); + return $needsUpdate; + } + + /** + * Adds registration elements to a given dataset instance + * + * @param $criteriaInstance An instance of a storeable criteria + * @return void + */ + public function addElementsToDataSet (StoreableCriteria $criteriaInstance) { + // Walk only through out-dated columns + foreach ($this->outDated as $key => $dummy) { + // Does this key exist? + //* DEBUG: */ echo "outDated: {$key}
\n"; + if ($this->find($key)) { + // Then update it + $criteriaInstance->addCriteria($key, $this->getFoundValue()); + } // END - if + } // END - foreach + } + + /** + * Find a key inside the result array + * + * @param $key The key we shall find + * @return $found Wether the key was found or not + */ + public function find ($key) { + // By default nothing is found + $found = false; + + // Rewind the pointer + $this->rewind(); + + // Walk through all entries + while ($this->valid()) { + // Advance to next entry + $this->next(); + + // Get the whole array + $currentEntry = $this->current(); + + // Is the element there? + if (isset($currentEntry[$key])) { + // Okay, found! + $found = true; + + // So "cache" it + $this->foundValue = $currentEntry[$key]; + + // And stop searching + break; + } // END - if + } // END - while + + // Return the result + return $found; + } + + /** + * Solver for result index value with call-back method + * + * @param $databaseColumn Database column where the index might be found + * @param $wrapperInstance The wrapper instance to ask for array element + * @para $callBack Call-back object for setting the index; + * 0=object instance,1=method name + * @return void +4 * @todo Find a caching way without modifying the result array + */ + public function solveResultIndex ($databaseColumn, BaseDatabaseWrapper $wrapperInstance, array $callBack) { + // By default nothing is found + $indexValue = 0; + + // Is the element in result itself found? + if ($this->find($databaseColumn)) { + // Use this value + $indexValue = $this->getFoundValue(); + } elseif ($this->find($wrapperInstance->getIndexKey())) { + // Use this value + $indexValue = $this->getFoundValue(); + } + + // Set the index + call_user_func_array($callBack, array($indexValue)); + } +} + +// [EOF] +?> diff --git a/inc/classes/main/rng/.htaccess b/inc/classes/main/rng/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/rng/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/rng/class_RandomNumberGenerator.php b/inc/classes/main/rng/class_RandomNumberGenerator.php new file mode 100644 index 00000000..93ba3988 --- /dev/null +++ b/inc/classes/main/rng/class_RandomNumberGenerator.php @@ -0,0 +1,180 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class RandomNumberGenerator extends BaseFrameworkSystem { + /** + * Prime number for better pseudo random numbers + */ + private $prime = 0; + + /** + * Add this calculated number to the rng + */ + private $extraNumber = 0; + + /** + * Extra salt for secured hashing + */ + private $extraSalt = ""; + + /** + * Fixed salt for secured hashing + */ + private $fixedSalt = ""; + + /** + * Maximum length for random string + */ + private $rndStrLen = 0; + + /** + * Protected constructor + * + * @param $className Name of this class + * @return void + */ + protected function __construct ($className = __CLASS__) { + // Call parent constructor + parent::__construct($className); + + // Clean up a little + $this->removeNumberFormaters(); + $this->removeSystemArray(); + } + + /** + * Creates an instance of this class + * + * @param $extraInstance An extra instance for more salt (default: null) + * @return $rngInstance An instance of this random number generator + */ + public final static function createRandomNumberGenerator (FrameworkInterface $extraInstance = null) { + // Get a new instance + $rngInstance = new RandomNumberGenerator(); + + // Initialize the RNG now + $rngInstance->initRng($extraInstance); + + // Return the instance + return $rngInstance; + } + + /** + * Initializes the random number generator + * + * @param $extraInstance An extra instance for more salt (default: null) + * @return void + * @todo Add site key for stronger salt! + */ + protected function initRng ($extraInstance) { + // Get the prime number from config + $this->prime = $this->getConfigInstance()->readConfig('math_prime'); + + // Calculate the extra number which is always the same unless you give + // a better prime number + $this->extraNumber = ($this->prime * $this->prime / (pi() ^ 2)); + + // Seed mt_rand() + mt_srand((double) sqrt(microtime() * 100000000 * $this->extraNumber)); + + // Set the server IP to cluster + $serverIp = "cluster"; + + // Do we have a single server? + if ($this->getConfigInstance()->readConfig('is_single_server') === "Y") { + // Then use that IP for extra security + $serverIp = getenv('SERVER_ADDR'); + } // END - if + + // Yet-another fixed salt. This is not dependend on server software or date + if ($extraInstance instanceof FrameworkInterface) { + // With extra instance information + $this->fixedSalt = sha1($serverIp . ":" . $extraInstance->__toString() . ":" . serialize($this->getDatabaseInstance()->getConnectionData())); + } else { + // Without extra information + $this->fixedSalt = sha1($serverIp . ":" . serialize($this->getDatabaseInstance()->getConnectionData())); + } + + // One-way data we need for "extra-salting" the random number + $this->extraSalt = sha1($this->fixedSalt . ":" . getenv('SERVER_SOFTWARE') . ":" . $this->getConfigInstance()->readConfig('date_key') . $this->getConfigInstance()->readConfig('base_url')); + + // Get config entry for max salt length + $this->rndStrLen = $this->getConfigInstance()->readConfig('rnd_str_length'); + } + + /** + * Makes a pseudo-random string useable for salts + * + * @param $length Length of the string, default: 128 + * @return $randomString The pseudo-random string + */ + public function randomString ($length = -1) { + // Is the number <1, then fix it to default length + if ($length < 1) $length = $this->rndStrLen; + + // Initialize the string + $randomString = ""; + + // And generate it + for ($idx = 0; $idx < $length; $idx++) { + // Add a random character and add it to our string + $randomString .= chr($this->randomNumber(0, 255)); + } + + // Return the random string a little mixed up + return str_shuffle($randomString); + } + + /** + * Generate a pseudo-random integer number in a given range + * + * @param $min Min value to generate + * @param $max Max value to generate + * @return $num Pseudo-random number + * @todo I had a better random number generator here but now it is somewhere lost :( + */ + public function randomNumber ($min, $max) { + return mt_rand($min, $max); + } + + /** + * Getter for extra salt + * + * @return $extraSalt + */ + public final function getExtraSalt () { + return $this->extraSalt; + } + + /** + * Getter for fixed salt + * + * @return $fixedSalt + */ + public final function getFixedSalt () { + return $this->fixedSalt; + } +} + +// [EOF] +?> diff --git a/inc/classes/main/template/.htaccess b/inc/classes/main/template/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/template/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/template/class_BaseTemplateEngine.php b/inc/classes/main/template/class_BaseTemplateEngine.php new file mode 100644 index 00000000..8690db6f --- /dev/null +++ b/inc/classes/main/template/class_BaseTemplateEngine.php @@ -0,0 +1,1299 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseTemplateEngine extends BaseFrameworkSystem { + /** + * The local path name where all templates and sub folders for special + * templates are stored. We will internally determine the language plus + * "html" for web templates or "emails" for email templates + */ + private $basePath = ""; + + /** + * Template type + */ + private $templateType = "html"; + + /** + * The extension for web and email templates (not compiled templates) + */ + private $templateExtension = ".tpl"; + + /** + * The extension for code templates (not compiled templates) + */ + private $codeExtension = ".ctp"; + + /** + * Path relative to $basePath and language code for compiled code-templates + */ + private $compileOutputPath = "templates/_compiled"; + + /** + * The raw (maybe uncompiled) template + */ + private $rawTemplateData = ""; + + /** + * Template data with compiled-in variables + */ + private $compiledData = ""; + + /** + * The last loaded template's FQFN for debugging the engine + */ + private $lastTemplate = ""; + + /** + * The variable stack for the templates + */ + private $varStack = array(); + + /** + * Loaded templates for recursive protection and detection + */ + private $loadedTemplates = array(); + + /** + * Compiled templates for recursive protection and detection + */ + private $compiledTemplates = array(); + + /** + * Loaded raw template data + */ + private $loadedRawData = null; + + /** + * Raw templates which are linked in code templates + */ + private $rawTemplates = null; + + /** + * A regular expression for variable=value pairs + */ + private $regExpVarValue = '/([\w_]+)(="([^"]*)"|=([\w_]+))?/'; + + /** + * A regular expression for filtering out code tags + * + * E.g.: {?template:variable=value;var2=value2;[...]?} + */ + private $regExpCodeTags = '/\{\?([a-z_]+)(:("[^"]+"|[^?}]+)+)?\?\}/'; + + /** + * Loaded helpers + */ + private $helpers = array(); + + /** + * Current variable group + */ + private $currGroup = 'general'; + + /** + * All template groups except "general" + */ + private $varGroups = array(); + + // Exception codes for the template engine + const EXCEPTION_TEMPLATE_TYPE_IS_UNEXPECTED = 0x110; + const EXCEPTION_TEMPLATE_CONTAINS_INVALID_VAR = 0x111; + const EXCEPTION_INVALID_VIEW_HELPER = 0x112; + + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + + // Clean up a little + $this->removeNumberFormaters(); + $this->removeSystemArray(); + } + + /** + * Search for a variable in the stack + * + * @param $var The variable we are looking for + * @return $idx FALSE means not found, >=0 means found on a specific index + */ + private function isVariableAlreadySet ($var) { + // First everything is not found + $found = false; + + // Is the group there? + if (isset($this->varStack[$this->currGroup])) { + // Now search for it + foreach ($this->varStack[$this->currGroup] as $idx => $currEntry) { + //* DEBUG: */ echo __METHOD__.":currGroup={$this->currGroup},idx={$idx},currEntry={$currEntry['name']},var={$var}
\n"; + // Is the entry found? + if ($currEntry['name'] == $var) { + // Found! + //* DEBUG: */ echo __METHOD__.":FOUND!
\n"; + $found = $idx; + break; + } // END - if + } // END - foreach + } // END - if + + // Return the current position + return $found; + } + + /** + * Return a content of a variable or null if not found + * + * @param $var The variable we are looking for + * @return $content Content of the variable or null if not found + */ + protected function readVariable ($var) { + // First everything is not found + $content = null; + + // Get variable index + $found = $this->isVariableAlreadySet($var); + + // Is the variable found? + if ($found !== false) { + // Read it + $found = $this->varStack[$this->currGroup][$found]['value']; + } // END - if + + //* DEBUG: */ echo __METHOD__.": group=".$this->currGroup.",var=".$var.", found=".$found."
\n"; + + // Return the current position + return $found; + } + + /** + * Add a variable to the stack + * + * @param $var The variable we are looking for + * @param $value The value we want to store in the variable + * @return void + */ + private function addVariable ($var, $value) { + // Set general variable group + $this->setVariableGroup('general'); + + // Add it to the stack + $this->addGroupVariable($var, $value); + } + + /** + * Returns all variables of current group or empty array + * + * @return $result Wether array of found variables or empty array + */ + private function readCurrentGroup () { + // Default is not found + $result = array(); + + // Is the group there? + if (isset($this->varStack[$this->currGroup])) { + // Then use it + $result = $this->varStack[$this->currGroup]; + } // END - if + + // Return result + return $result; + } + + /** + * Settter for variable group + * + * @param $groupName Name of variable group + * @param $add Wether add this group + * @retur4n void + */ + public function setVariableGroup ($groupName, $add = true) { + // Set group name + //* DEBIG: */ echo __METHOD__.": currGroup=".$groupName."
\n"; + $this->currGroup = $groupName; + + // Skip group 'general' + if (($groupName != 'general') && ($add === true)) { + $this->varGroups[$groupName] = 'OK'; + } // END - if + } + + + /** + * Adds a variable to current group + * + * @param $var Variable to set + * @param $value Value to store in variable + * @return void + */ + public function addGroupVariable ($var, $value) { + //* DEBUG: */ echo __METHOD__.": group=".$this->currGroup.", var=".$var.", value=".$value."
\n"; + + // Get current variables in group + $currVars = $this->readCurrentGroup(); + + // Append our variable + $currVars[] = array( + 'name' => $var, + 'value' => $value + ); + + // Add it to the stack + $this->varStack[$this->currGroup] = $currVars; + } + + /** + * Modify an entry on the stack + * + * @param $var The variable we are looking for + * @param $value The value we want to store in the variable + * @return void + */ + private function modifyVariable ($var, $value) { + // Get index for variable + $idx = $this->isVariableAlreadySet($var); + + // Is the variable set? + if ($idx !== false) { + // Then modify it + $this->varStack[$this->currGroup][$idx]['value'] = $value; + } // END - if + } + + /** + * Setter for template type. Only "html", "emails" and "compiled" should + * be sent here + * + * @param $templateType The current template's type + * @return void + */ + private final function setTemplateType ($templateType) { + $this->templateType = (string) $templateType; + } + + /** + * Setter for the last loaded template's FQFN + * + * @param $template The last loaded template + * @return void + */ + private final function setLastTemplate ($template) { + $this->lastTemplate = (string) $template; + } + + /** + * Getter for the last loaded template's FQFN + * + * @return $template The last loaded template + */ + private final function getLastTemplate () { + return $this->lastTemplate; + } + + /** + * Setter for base path + * + * @param $basePath The local base path for all templates + * @return void + */ + public final function setBasePath ($basePath) { + // And set it + $this->basePath = (string) $basePath; + } + + /** + * Getter for base path + * + * @return $basePath The local base path for all templates + */ + public final function getBasePath () { + // And set it + return $this->basePath; + } + + /** + * Setter for template extension + * + * @param $templateExtension The file extension for all uncompiled + * templates + * @return void + */ + public final function setRawTemplateExtension ($templateExtension) { + // And set it + $this->templateExtension = (string) $templateExtension; + } + + /** + * Setter for code template extension + * + * @param $codeExtension The file extension for all uncompiled + * templates + * @return void + */ + public final function setCodeTemplateExtension ($codeExtension) { + // And set it + $this->codeExtension = (string) $codeExtension; + } + + /** + * Getter for template extension + * + * @return $templateExtension The file extension for all uncompiled + * templates + */ + public final function getRawTemplateExtension () { + // And set it + return $this->templateExtension; + } + + /** + * Getter for code-template extension + * + * @return $codeExtension The file extension for all code- + * templates + */ + public final function getCodeTemplateExtension () { + // And set it + return $this->codeExtension; + } + + /** + * Setter for path of compiled templates + * + * @param $compileOutputPath The local base path for all compiled + * templates + * @return void + */ + public final function setCompileOutputPath ($compileOutputPath) { + // And set it + $this->compileOutputPath = (string) $compileOutputPath; + } + + /** + * Getter for template type + * + * @return $templateType The current template's type + */ + public final function getTemplateType () { + return $this->templateType; + } + + /** + * Assign (add) a given variable with a value + * + * @param $var The variable we are looking for + * @param $value The value we want to store in the variable + * @return void + * @throws EmptyVariableException If the variable name is left empty + */ + public final function assignVariable ($var, $value) { + // Trim spaces of variable name + $var = trim($var); + + // Empty variable found? + if (empty($var)) { + // Throw an exception + throw new EmptyVariableException(array($this, 'var'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); + } // END - if + + // First search for the variable if it was already added + $idx = $this->isVariableAlreadySet($var); + + // Was it found? + if ($idx === false) { + // Add it to the stack + //* DEBUG: */ echo "ADD: ".$var."
\n"; + $this->addVariable($var, $value); + } elseif (!empty($value)) { + // Modify the stack entry + //* DEBUG: */ echo "MOD: ".$var."
\n"; + $this->modifyVariable($var, $value); + } + } + + /** + * Removes a given variable + * + * @param $var The variable we are looking for + * @return void + */ + public final function removeVariable ($var) { + // First search for the variable if it was already added + $idx = $this->isVariableAlreadySet($var); + + // Was it found? + if ($idx !== false) { + // Remove this variable + $this->varStack->offsetUnset($idx); + } + } + + /** + * Private setter for raw template data + * + * @param $rawTemplateData The raw data from the template + * @return void + */ + protected final function setRawTemplateData ($rawTemplateData) { + // And store it in this class + //* DEBUG: */ echo __METHOD__.":".$this->getUniqueId().": ".strlen($rawTemplateData)." Bytes set.
\n"; + //* DEBUG: */ echo $this->currGroup." variables: ".count($this->varStack[$this->currGroup]).", groups=".count($this->varStack)."
\n"; + $this->rawTemplateData = (string) $rawTemplateData; + } + + /** + * Getter for raw template data + * + * @return $rawTemplateData The raw data from the template + */ + public final function getRawTemplateData () { + //* DEBUG: */ echo __METHOD__.":".$this->getUniqueId().": ".strlen($this->rawTemplateData)." Bytes read.
\n"; + return $this->rawTemplateData; + } + + /** + * Private setter for compiled templates + * + * @return void + */ + private final function setCompiledData ($compiledData) { + // And store it in this class + //* DEBUG: */ echo __METHOD__.":".$this->getUniqueId().": ".strlen($compiledData)." Bytes set.
\n"; + $this->compiledData = (string) $compiledData; + } + + /** + * Getter for compiled templates + * + * @return $compiledData Compiled template data + */ + public final function getCompiledData () { + //* DEBUG: */ echo __METHOD__.":".$this->getUniqueId().": ".strlen($this->compiledData)." Bytes read.
\n"; + return $this->compiledData; + } + + /** + * Private loader for all template types + * + * @param $template The template we shall load + * @return void + */ + private function loadTemplate ($template) { + // Get extension for the template + $ext = $this->getRawTemplateExtension(); + + // If we shall load a code-template we need to switch the file extension + if ($this->getTemplateType() == $this->getConfigInstance()->readConfig('code_template_type')) { + // Switch over to the code-template extension + $ext = $this->getCodeTemplateExtension(); + } // END - if + + // Construct the FQFN for the template by honoring the current language + $fqfn = sprintf("%s%s/%s/%s%s", + $this->getBasePath(), + $this->getLanguageInstance()->getLanguageCode(), + $this->getTemplateType(), + (string) $template, + $ext + ); + + // Load the raw template data + $this->loadRawTemplateData($fqfn); + } + + /** + * A private loader for raw template names + * + * @param $fqfn The full-qualified file name for a template + * @return void + */ + private function loadRawTemplateData ($fqfn) { + // Get a input/output instance from the middleware + $ioInstance = $this->getFileIoInstance(); + + // Some debug code to look on the file which is being loaded + //* DEBUG: */ echo __METHOD__.": FQFN=".$fqfn."
\n"; + + // Load the raw template + $rawTemplateData = $ioInstance->loadFileContents($fqfn); + + // Store the template's contents into this class + $this->setRawTemplateData($rawTemplateData); + + // Remember the template's FQFN + $this->setLastTemplate($fqfn); + } + + /** + * Try to assign an extracted template variable as a "content" or 'config' + * variable. + * + * @param $varName The variable's name (shall be content orconfig) by + * default + * @param $var The variable we want to assign + */ + private function assignTemplateVariable ($varName, $var) { + // Is it not a config variable? + if ($varName != 'config') { + // Regular template variables + $this->assignVariable($var, ""); + } else { + // Configuration variables + $this->assignConfigVariable($var); + } + } + + /** + * Extract variables from a given raw data stream + * + * @param $rawData The raw template data we shall analyze + * @return void + */ + private function extractVariablesFromRawData ($rawData) { + // Cast to string + $rawData = (string) $rawData; + + // Search for variables + @preg_match_all('/\$(\w+)(\[(\w+)\])?/', $rawData, $variableMatches); + + // Did we find some variables? + if ((is_array($variableMatches)) && (count($variableMatches) == 4) && (count($variableMatches[0]) > 0)) { + // Initialize all missing variables + foreach ($variableMatches[3] as $key => $var) { + // Variable name + $varName = $variableMatches[1][$key]; + + // Workarround: Do not assign empty variables + if (!empty($var)) { + // Try to assign it, empty strings are being ignored + $this->assignTemplateVariable($varName, $var); + } // END - if + } // END - foreach + } // END - if + } + + /** + * Main analysis of the loaded template + * + * @param $templateMatches Found template place-holders, see below + * @return void + * + *--------------------------------- + * Structure of $templateMatches: + *--------------------------------- + * [0] => Array - An array with all full matches + * [1] => Array - An array with left part (before the ":") of a match + * [2] => Array - An array with right part of a match including ":" + * [3] => Array - An array with right part of a match excluding ":" + */ + private function analyzeTemplate (array $templateMatches) { + // Backup raw template data + $backup = $this->getRawTemplateData(); + + // Initialize some arrays + if (is_null($this->loadedRawData)) { $this->loadedRawData = array(); $this->rawTemplates = array(); } + + // Load all requested templates + foreach ($templateMatches[1] as $template) { + + // Load and compile only templates which we have not yet loaded + // RECURSIVE PROTECTION! BE CAREFUL HERE! + if ((!isset($this->loadedRawData[$template])) && (!in_array($template, $this->loadedTemplates))) { + + // Template not found, but maybe variable assigned? + //* DEBUG: */ echo __METHOD__.":template={$template}
\n"; + if ($this->isVariableAlreadySet($template) !== false) { + // Use that content here + $this->loadedRawData[$template] = $this->readVariable($template); + + // Recursive protection: + $this->loadedTemplates[] = $template; + } elseif (isset($this->varStack['config'][$template])) { + // Use that content here + $this->loadedRawData[$template] = $this->varStack['config'][$template]; + + // Recursive protection: + $this->loadedTemplates[] = $template; + } else { + // Then try to search for code-templates + try { + // Load the code template and remember it's contents + $this->loadCodeTemplate($template); + $this->loadedRawData[$template] = $this->getRawTemplateData(); + + // Remember this template for recursion detection + // RECURSIVE PROTECTION! + $this->loadedTemplates[] = $template; + } catch (FileNotFoundException $e) { + // Even this is not done... :/ + $this->rawTemplates[] = $template; + } catch (FilePointerNotOpenedException $e) { + // Even this is not done... :/ + $this->rawTemplates[] = $template; + } + } + } // END - if + } // END - foreach + + // Restore the raw template data + $this->setRawTemplateData($backup); + } + + /** + * Compile a given raw template code and remember it for later usage + * + * @param $code The raw template code + * @param $template The template's name + * @return void + */ + private function compileCode ($code, $template) { + // Is this template already compiled? + if (in_array($template, $this->compiledTemplates)) { + // Abort here... + return; + } // END - if + + // Remember this template being compiled + $this->compiledTemplates[] = $template; + + // Compile the loaded code in five steps: + // + // 1. Backup current template data + $backup = $this->getRawTemplateData(); + + // 2. Set the current template's raw data as the new content + $this->setRawTemplateData($code); + + // 3. Compile the template data + $this->compileTemplate(); + + // 4. Remember it's contents + $this->loadedRawData[$template] = $this->getRawTemplateData(); + + // 5. Restore the previous raw content from backup variable + $this->setRawTemplateData($backup); + } + + /** + * Insert all given and loaded templates by running through all loaded + * codes and searching for their place-holder in the main template + * + * @param $templateMatches See method analyzeTemplate() + * @return void + */ + private function insertAllTemplates (array $templateMatches) { + // Run through all loaded codes + foreach ($this->loadedRawData as $template => $code) { + + // Search for the template + $foundIndex = array_search($template, $templateMatches[1]); + + // Lookup the matching template replacement + if (($foundIndex !== false) && (isset($templateMatches[0][$foundIndex]))) { + + // Get the current raw template + $rawData = $this->getRawTemplateData(); + + // Replace the space holder with the template code + $rawData = str_replace($templateMatches[0][$foundIndex], $code, $rawData); + + // Set the new raw data + $this->setRawTemplateData($rawData); + } // END - if + } // END - foreach + } + + /** + * Load all extra raw templates + * + * @return void + */ + private function loadExtraRawTemplates () { + // Are there some raw templates we need to load? + if (count($this->rawTemplates) > 0) { + // Try to load all raw templates + foreach ($this->rawTemplates as $key => $template) { + try { + // Load the template + $this->loadWebTemplate($template); + + // Remember it's contents + $this->rawTemplates[$template] = $this->getRawTemplateData(); + + // Remove it from the loader list + unset($this->rawTemplates[$key]); + + // Remember this template for recursion detection + // RECURSIVE PROTECTION! + $this->loadedTemplates[] = $template; + } catch (FileNotFoundException $e) { + // This template was never found. We silently ignore it + unset($this->rawTemplates[$key]); + } catch (FilePointerNotOpenedException $e) { + // This template was never found. We silently ignore it + unset($this->rawTemplates[$key]); + } + } // END - foreach + } // END - if + } + + /** + * Assign all found template variables + * + * @param $varMatches An array full of variable/value pairs. + * @return void + * @todo Unfinished work or don't die here. + */ + private function assignAllVariables (array $varMatches) { + // Search for all variables + foreach ($varMatches[1] as $key => $var) { + + // Detect leading equals + if (substr($varMatches[2][$key], 0, 1) == "=") { + // Remove and cast it + $varMatches[2][$key] = (string) substr($varMatches[2][$key], 1); + } + + // Do we have some quotes left and right side? Then it is free text + if ((substr($varMatches[2][$key], 0, 1) == "\"") && (substr($varMatches[2][$key], -1, 1) == "\"")) { + // Free string detected! Which we can assign directly + $this->assignVariable($var, $varMatches[3][$key]); + } elseif (!empty($varMatches[2][$key])) { + // Non-string found so we need some deeper analysis... + die("Deeper analysis not yet implemented!"); + } + + } // for ($varMatches ... + } + /** + * Compiles all loaded raw templates + * + * @param $templateMatches See method analyzeTemplate() for details + * @return void + */ + private function compileRawTemplateData (array $templateMatches) { + // Are some code-templates found which we need to compile? + if (count($this->loadedRawData) > 0) { + + // Then compile all! + foreach ($this->loadedRawData as $template => $code) { + + // Is this template already compiled? + if (in_array($template, $this->compiledTemplates)) { + // Then skip it + continue; + } + + // Search for the template + $foundIndex = array_search($template, $templateMatches[1]); + + // Lookup the matching variable data + if (($foundIndex !== false) && (isset($templateMatches[3][$foundIndex]))) { + + // Split it up with another reg. exp. into variable=value pairs + preg_match_all($this->regExpVarValue, $templateMatches[3][$foundIndex], $varMatches); + + // Assign all variables + $this->assignAllVariables($varMatches); + + } // END - if (isset($templateMatches ... + + // Compile the loaded template + $this->compileCode($code, $template); + + } // END - foreach ($this->loadedRawData ... + + // Insert all templates + $this->insertAllTemplates($templateMatches); + + } // END - if (count($this->loadedRawData) ... + } + + /** + * Inserts all raw templates into their respective variables + * + * @return void + */ + private function insertRawTemplates () { + // Load all templates + foreach ($this->rawTemplates as $template => $content) { + // Set the template as a variable with the content + $this->assignVariable($template, $content); + } + } + + /** + * Finalizes the compilation of all template variables + * + * @return void + */ + private function finalizeVariableCompilation () { + // Get the content + $content = $this->getRawTemplateData(); + //* DEBUG: */ echo __METHOD__.": content before=".strlen($content)." (".md5($content).")
\n"; + + // Walk through all variables + foreach ($this->varStack['general'] as $currEntry) { + //* DEBUG: */ echo __METHOD__.": name=".$currEntry['name'].", value=
".htmlentities($currEntry['value'])."
\n"; + // Replace all [$var] or {?$var?} with the content + // Old behaviour, will become obsolete! + $content = str_replace("\$content[".$currEntry['name']."]", $currEntry['value'], $content); + + // Yet another old way + $content = str_replace("[".$currEntry['name']."]", $currEntry['value'], $content); + + // The new behaviour + $content = str_replace("{?".$currEntry['name']."?}", $currEntry['value'], $content); + } // END - for + + //* DEBUG: */ echo __METHOD__.": content after=".strlen($content)." (".md5($content).")
\n"; + + // Set the content back + $this->setRawTemplateData($content); + } + + /** + * Load a specified web template into the engine + * + * @param $template The web template we shall load which is located in + * "html" by default + * @return void + */ + public function loadWebTemplate ($template) { + // Set template type + $this->setTemplateType($this->getConfigInstance()->readConfig('web_template_type')); + + // Load the special template + $this->loadTemplate($template); + } + + /** + * Assign a given congfiguration variable with a value + * + * @param $var The configuration variable we want to assign + * @return void + */ + public function assignConfigVariable ($var) { + // Sweet and simple... + //* DEBUG: */ echo __METHOD__.":var={$var}
\n"; + $this->varStack['config'][$var] = $this->getConfigInstance()->readConfig($var); + } + + /** + * Load a specified email template into the engine + * + * @param $template The email template we shall load which is located in + * "emails" by default + * @return void + */ + public function loadEmailTemplate ($template) { + // Set template type + $this->setTemplateType($this->getConfigInstance()->readConfig('email_template_type')); + + // Load the special template + $this->loadTemplate($template); + } + + /** + * Load a specified code template into the engine + * + * @param $template The code template we shall load which is + * located in "code" by default + * @return void + */ + public function loadCodeTemplate ($template) { + // Set template type + $this->setTemplateType($this->getConfigInstance()->readConfig('code_template_type')); + + // Load the special template + $this->loadTemplate($template); + } + + /** + * Compile all variables by inserting their respective values + * + * @return void + * @todo Make this code some nicer... + */ + public final function compileVariables () { + // Initialize the $content array + $validVar = $this->getConfigInstance()->readConfig('tpl_valid_var'); + $dummy = array(); + + // Iterate through all general variables + foreach ($this->varStack['general'] as $currVariable) { + // Transfer it's name/value combination to the $content array + //* DEBUG: */ echo $currVariable['name']."=
".htmlentities($currVariable['value'])."
\n"; + $dummy[$currVariable['name']] = $currVariable['value']; + }// END - if + + // Set the new variable (don't remove the second dollar!) + $$validVar = $dummy; + + // Prepare all configuration variables + $config = null; + if (isset($this->varStack['config'])) { + $config = $this->varStack['config']; + } // END - if + + // Remove some variables + unset($idx); + unset($currVariable); + + // Run the compilation twice to get content from helper classes in + $cnt = 0; + while ($cnt < 3) { + // Finalize the compilation of template variables + $this->finalizeVariableCompilation(); + + // Prepare the eval() command for comiling the template + $eval = sprintf("\$result = \"%s\";", + addslashes($this->getRawTemplateData()) + ); + + // This loop does remove the backslashes (\) in PHP parameters + while (strpos($eval, ""))); + $evalMiddle = stripslashes($evalMiddle); + + // Remove the middle part from right one + $evalRight = substr($evalRight, (strpos($evalRight, "?>") + 2)); + + // And put all together + $eval = sprintf("%s<%%php %s %%>%s", $evalLeft, $evalMiddle, $evalRight); + } // END - while + + // Prepare PHP code for eval() command + $eval = str_replace( + "<%php", "\";", + str_replace( + "%>", "\n\$result .= \"", $eval + ) + ); + + // Run the constructed command. This will "compile" all variables in + @eval($eval); + + // Goes something wrong? + if (!isset($result)) { + // Output eval command + $this->debugOutput(sprintf("Failed eval() code:
%s
", $this->markupCode($eval, true)), true); + + // Output backtrace here + $this->debugBackTrace(); + } // END - if + + // Set raw template data + $this->setRawTemplateData($result); + $cnt++; + } // END - while + + // Final variable assignment + $this->finalizeVariableCompilation(); + + // Set the new content + $this->setCompiledData($this->getRawTemplateData()); + } + + /** + * Compile all required templates into the current loaded one + * + * @return void + * @throws UnexpectedTemplateTypeException If the template type is + * not "code" + * @throws InvalidArrayCountException If an unexpected array + * count has been found + */ + public function compileTemplate () { + // We will only work with template type "code" from configuration + if ($this->getTemplateType() != $this->getConfigInstance()->readConfig('code_template_type')) { + // Abort here + throw new UnexpectedTemplateTypeException(array($this, $this->getTemplateType(), $this->getConfigInstance()->readConfig('code_template_type')), self::EXCEPTION_TEMPLATE_TYPE_IS_UNEXPECTED); + } // END - if + + // Get the raw data. + $rawData = $this->getRawTemplateData(); + + // Remove double spaces and trim leading/trailing spaces + $rawData = trim(str_replace(" ", " ", $rawData)); + + // Search for raw variables + $this->extractVariablesFromRawData($rawData); + + // Search for code-tags which are {? ?} + preg_match_all($this->regExpCodeTags, $rawData, $templateMatches); + + // Analyze the matches array + if ((is_array($templateMatches)) && (count($templateMatches) == 4) && (count($templateMatches[0]) > 0)) { + // Entries are found: + // + // The main analysis + $this->analyzeTemplate($templateMatches); + + // Compile raw template data + $this->compileRawTemplateData($templateMatches); + + // Are there some raw templates left for loading? + $this->loadExtraRawTemplates(); + + // Are some raw templates found and loaded? + if (count($this->rawTemplates) > 0) { + + // Insert all raw templates + $this->insertRawTemplates(); + + // Remove the raw template content as well + $this->setRawTemplateData(""); + + } // END - if + + } // END - if($templateMatches ... + } + + /** + * A old deprecated method + * + * @return void + * @deprecated + * @see BaseTemplateEngine::transferToResponse + */ + public function output () { + // Check which type of template we have + switch ($this->getTemplateType()) { + case "html": // Raw HTML templates can be send to the output buffer + // Quick-N-Dirty: + $this->getWebOutputInstance()->output($this->getCompiledData()); + break; + + default: // Unknown type found + // Construct message + $msg = sprintf("[%s->%s] Unknown/unsupported template type %s detected.", + $this->__toString(), + __FUNCTION__, + $this->getTemplateType() + ); + + // Write the problem to the world... + $this->debugOutput($msg); + break; + } + } + + /** + * Loads a given view helper (by name) + * + * @param $helperName The helper's name + * @return void + * @throws ViewHelperNotFoundException If the given view helper was not found + */ + protected function loadViewHelper ($helperName) { + // Make first character upper case, rest low + $helperName = ucfirst($helperName); + + // Is this view helper loaded? + if (!isset($this->helpers[$helperName])) { + // Create a class name + $className = "{$helperName}ViewHelper"; + + // Does this class exists? + if (!class_exists($className)) { + // Abort here! + throw new ViewHelperNotFoundException(array($this, $helperName), self::EXCEPTION_INVALID_VIEW_HELPER); + } // END - if + + // Generate new instance + $eval = sprintf("\$this->helpers[%s] = %s::create%s();", + $helperName, + $className, + $className + ); + + // Run the code + eval($eval); + } // END - if + + // Return the requested instance + return $this->helpers[$helperName]; + } + + /** + * Assigns the last loaded raw template content with a given variable + * + * @param $templateName Name of the template we want to assign + * @param $variableName Name of the variable we want to assign + * @return void + */ + public function assignTemplateWithVariable ($templateName, $variableName) { + // Get the content from last loaded raw template + $content = $this->getRawTemplateData(); + + // Assign the variable + $this->assignVariable($variableName, $content); + + // Purge raw content + $this->setRawTemplateData(""); + } + + /** + * Transfers the content of this template engine to a given response instance + * + * @param $responseInstance An instance of a response class + * @return void + */ + public function transferToResponse (Responseable $responseInstance) { + // Get the content and set it in response class + $responseInstance->writeToBody($this->getCompiledData()); + } + + /** + * Assigns all the application data with template variables + * + * @param $appInstance A manageable application instance + * @return void + */ + public function assignApplicationData (ManageableApplication $appInstance) { + // Get long name and assign it + $this->assignVariable('app_full_name' , $appInstance->getAppName()); + + // Get short name and assign it + $this->assignVariable('app_short_name', $appInstance->getAppShortName()); + + // Get version number and assign it + $this->assignVariable('app_version' , $appInstance->getAppVersion()); + + // Assign extra application-depending data + $appInstance->assignExtraTemplateData($this); + } + + /** + * "Compiles" a variable by replacing {?var?} with it's content + * + * @param $rawCode Raw code to compile + * @return $rawCode Compile code with inserted variable value + */ + public function compileRawCode ($rawCode) { + // Find the variables + //* DEBUG: */ echo "rawCode=
".htmlentities($rawCode)."
\n"; + preg_match_all($this->regExpVarValue, $rawCode, $varMatches); + + // Compile all variables + //* DEBUG: */ echo "
".print_r($varMatches, true)."
"; + foreach ($varMatches[0] as $match) { + // Add variable tags around it + $varCode = "{?".$match."?}"; + + // Is the variable found in code? (safes some calls) + if (strpos($rawCode, $varCode) !== false) { + // Replace the variable with it's value, if found + //* DEBUG: */ echo __METHOD__.": match=".$match."
\n"; + $rawCode = str_replace($varCode, $this->readVariable($match), $rawCode); + } // END - if + } // END - foreach + + // Return the compiled data + return $rawCode; + } + + /** + * Getter for variable group array + * + * @return $vargroups All variable groups + */ + public final function getVariableGroups () { + return $this->varGroups; + } + + /** + * Renames a variable in code and in stack + * + * @param $oldName Old name of variable + * @param $newName New name of variable + * @return void + */ + public function renameVariable ($oldName, $newName) { + //* DEBUG: */ echo __METHOD__.": oldName={$oldName}, newName={$newName}
\n"; + // Get raw template code + $rawData = $this->getRawTemplateData(); + + // Replace it + $rawData = str_replace($oldName, $newName, $rawData); + + // Set the code back + $this->setRawTemplateData($rawData); + } + + /** + * Renders the given XML content + * + * @param $content Valid XML content or if not set the current loaded raw content + * @return void + * @throws XmlParserException If an XML error was found + */ + public final function renderXmlContent ($content = null) { + // Is the content set? + if (is_null($content)) { + // Get current content + $content = $this->getRawTemplateData(); + } // END - if + + // Convert all to UTF8 + $content = recode("html..utf8", $content); + + // Get an XML parser + $xmlParser = xml_parser_create(); + + // Force case-folding to on + xml_parser_set_option($xmlParser, XML_OPTION_CASE_FOLDING, true); + + // Set object + xml_set_object($xmlParser, $this); + + // Set handler call-backs + xml_set_element_handler($xmlParser, 'startElement', 'endElement'); + xml_set_character_data_handler($xmlParser, 'characterHandler'); + + // Now parse the XML tree + if (!xml_parse($xmlParser, $content)) { + // Error found in XML! + //die("
".htmlentities($content)."
"); + throw new XmlParserException(array($this, $xmlParser), BaseHelper::EXCEPTION_XML_PARSER_ERROR); + } // END - if + + // Free the parser + xml_parser_free($xmlParser); + } +} + +// [EOF] +?> diff --git a/inc/classes/main/template/image/.htaccess b/inc/classes/main/template/image/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/template/image/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/template/image/class_ImageTemplateEngine.php b/inc/classes/main/template/image/class_ImageTemplateEngine.php new file mode 100644 index 00000000..68d1cbef --- /dev/null +++ b/inc/classes/main/template/image/class_ImageTemplateEngine.php @@ -0,0 +1,472 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ImageTemplateEngine extends BaseTemplateEngine implements CompileableTemplate { + /** + * Main nodes in the XML tree ('image' is ignored) + */ + private $mainNodes = array("base", "type", "resolution", "background-color", "foreground-color", "image-string"); + + /** + * Sub nodes in the XML tree + */ + private $subNodes = array("name", "string-name", "x", "y", "font-size", "width", "height", "red", "green", "blue", "text"); + + /** + * Image instance + */ + private $imageInstance = null; + + /** + * Current main node + */ + private $currMainNode = ""; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of the class TemplateEngine and prepares it for usage + * + * @param $basePath The local base path for all templates + * @param $langInstance An instance of LanguageSystem (default) + * @param $ioInstance An instance of FileIoHandler (default, middleware!) + * @return $tplInstance An instance of TemplateEngine + * @throws BasePathIsEmptyException If the provided $basePath is empty + * @throws InvalidBasePathStringException If $basePath is no string + * @throws BasePathIsNoDirectoryException If $basePath is no + * directory or not found + * @throws BasePathReadProtectedException If $basePath is + * read-protected + */ + public final static function createImageTemplateEngine ($basePath, ManageableLanguage $langInstance, FileIoHandler $ioInstance) { + // Get a new instance + $tplInstance = new ImageTemplateEngine(); + + // Is the base path valid? + if (empty($basePath)) { + // Base path is empty + throw new BasePathIsEmptyException($tplInstance, self::EXCEPTION_UNEXPECTED_EMPTY_STRING); + } elseif (!is_string($basePath)) { + // Is not a string + throw new InvalidBasePathStringException(array($tplInstance, $basePath), self::EXCEPTION_INVALID_STRING); + } elseif (!is_dir($basePath)) { + // Is not a path + throw new BasePathIsNoDirectoryException(array($tplInstance, $basePath), self::EXCEPTION_INVALID_PATH_NAME); + } elseif (!is_readable($basePath)) { + // Is not readable + throw new BasePathReadProtectedException(array($tplInstance, $basePath), self::EXCEPTION_READ_PROTECED_PATH); + } + + // Get configuration instance + $cfgInstance = FrameworkConfiguration::getInstance(); + + // Set the base path + $tplInstance->setBasePath($basePath); + + // Set the language and IO instances + $tplInstance->setLanguageInstance($langInstance); + $tplInstance->setFileIoInstance($ioInstance); + + // Set template extensions + $tplInstance->setRawTemplateExtension($cfgInstance->readConfig('raw_template_extension')); + $tplInstance->setCodeTemplateExtension($cfgInstance->readConfig('code_template_extension')); + + // Absolute output path for compiled templates + $tplInstance->setCompileOutputPath($cfgInstance->readConfig('base_path') . $cfgInstance->readConfig('compile_output_path')); + + // Return the prepared instance + return $tplInstance; + } + + /** + * Getter for current main node + * + * @return $currMainNode Current main node + */ + public final function getCurrMainNode () { + return $this->currMainNode; + } + + /** + * Getter for main node array + * + * @return $mainNodes Array with valid main node names + */ + public final function getMainNodes () { + return $this->mainNodes; + } + + /** + * Getter for sub node array + * + * @return $subNodes Array with valid sub node names + */ + public final function getSubNodes () { + return $this->subNodes; + } + + /** + * Handles the start element of an XML resource + * + * @param $resource XML parser resource (currently ignored) + * @param $element The element we shall handle + * @param $attributes All attributes + * @return void + * @throws InvalidXmlNodeException If an unknown/invalid XML node name was found + */ + public function startElement ($resource, $element, array $attributes) { + // Initial method name which will never be called... + $methodName = 'initImage'; + + // Make the element name lower-case + $element = strtolower($element); + + // Is the element a main node? + //* DEBUG: */ echo "START: >".$element."<
\n"; + if (in_array($element, $this->mainNodes)) { + // Okay, main node found! + $methodName = 'setImage' . $this->convertToClassName($element); + } elseif (in_array($element, $this->subNodes)) { + // Sub node found + $methodName = 'setImageProperty' . $this->convertToClassName($element); + } elseif ($element != 'image') { + // Invalid node name found + throw new InvalidXmlNodeException(array($this, $element, $attributes), BaseHelper::EXCEPTION_XML_NODE_UNKNOWN); + } + + // Call method + //* DEBUG: */ echo "call: ".$methodName."
\n"; + call_user_func_array(array($this, $methodName), $attributes); + } + + /** + * Ends the main or sub node by sending out the gathered data + * + * @param $resource An XML resource pointer (currently ignored) + * @param $nodeName Name of the node we want to finish + * @return void + * @throws XmlNodeMismatchException If current main node mismatches the closing one + */ + protected function endElement ($resource, $nodeName) { + // Make all lower-case + $nodeName = strtolower($nodeName); + + // Does this match with current main node? + //* DEBUG: */ echo "END: >".$nodeName."<
\n"; + if (($nodeName != $this->getCurrMainNode()) && (in_array($nodeName, $this->getMainNodes()))) { + // Did not match! + throw new XmlNodeMismatchException (array($this, $nodeName, $this->getCurrMainNode()), BaseHelper::EXCEPTION_XML_NODE_MISMATCH); + } elseif (in_array($nodeName, $this->getSubNodes())) { + // Silently ignore sub nodes + return; + } + + // Construct method name + $methodName = 'finish' . $this->convertToClassName($nodeName); + + // Call the corresponding method + call_user_func_array(array($this->imageInstance, $methodName), array()); + } + + /** + * Currently not used + * + * @param $resource XML parser resource (currently ignored) + * @param $characters Characters to handle + * @return void + * @todo Find something usefull with this! + */ + protected function characterHandler ($resource, $characters) { + // Trim all spaces away + $characters = trim($characters); + + // Is this string empty? + if (empty($characters)) { + // Then skip it silently + return false; + } // END - if + + // Unfinished work! + $this->partialStub("Handling extra characters is not yet supported!"); + } + + /** + * Intializes the image + * + * @return void + * @todo Add cache creation here + */ + private function initImage () { + // Unfinished work! + } + + /** + * Set the image type + * + * @param $imageType Code fragment or direct value holding the image type + * @return void + */ + private function setImageType ($imageType) { + // Set group to general + $this->setVariableGroup('general'); + + // Try to compile it first to get the value from variable stack + $imageType = $this->compileRawCode($imageType); + + // Now make a class name of it + $className = $this->convertToClassName($imageType.'_image'); + + // And try to initiate it + $this->imageInstance = ObjectFactory::createObjectByName($className, array($this)); + + // Set current main node to type + $this->currMainNode = 'type'; + } + + /** + * "Setter" for resolution, we first need to collect the resolution from the + * sub-nodes. So first, this method will prepare an array for it + * + * @return void + */ + private function setImageResolution () { + // Call the image class + $this->imageInstance->initResolution(); + + // Current main node is resolution + $this->currMainNode = 'resolution'; + } + + /** + * "Setter" for base information. For more details see above method! + * + * @return void + * @see ImageTemplateEngine::setImageResolution + */ + private function setImageBase () { + // Call the image class + $this->imageInstance->initBase(); + + // Current main node is resolution + $this->currMainNode = 'base'; + } + + /** + * "Setter" for background-color. For more details see above method! + * + * @return void + * @see ImageTemplateEngine::setImageResolution + */ + private function setImageBackgroundColor () { + // Call the image class + $this->imageInstance->initBackgroundColor(); + + // Current main node is background-color + $this->currMainNode = 'background-color'; + } + + /** + * "Setter" for foreground-color. For more details see above method! + * + * @return void + * @see ImageTemplateEngine::setImageResolution + */ + private function setImageForegroundColor () { + // Call the image class + $this->imageInstance->initForegroundColor(); + + // Current main node is foreground-color + $this->currMainNode = 'foreground-color'; + } + + /** + * "Setter" for image-string. For more details see above method! + * + * @param $groupable Wether this image string is groupable + * @return void + * @see ImageTemplateEngine::setImageResolution + */ + private function setImageImageString ($groupable = 'single') { + // Call the image class + $this->imageInstance->initImageString($groupable); + + // Current main node is foreground-color + $this->currMainNode = 'image-string'; + } + + /** + * Setter for image name + * + * @param $imageName Name of the image + * @return void + */ + private function setImagePropertyName ($imageName) { + // Call the image class + $this->imageInstance->setImageName($imageName); + } + + /** + * Setter for image width + * + * @param $width Width of the image or variable + * @return void + */ + private function setImagePropertyWidth ($width) { + // Call the image class + $this->imageInstance->setWidth($width); + } + + /** + * Setter for image height + * + * @param $height Height of the image or variable + * @return void + */ + private function setImagePropertyHeight ($height) { + // Call the image class + $this->imageInstance->setHeight($height); + } + + /** + * Setter for image red color + * + * @param $red Red color value + * @return void + */ + private function setImagePropertyRed ($red) { + // Call the image class + $this->imageInstance->setRed($red); + } + + /** + * Setter for image green color + * + * @param $green Green color value + * @return void + */ + private function setImagePropertyGreen ($green) { + // Call the image class + $this->imageInstance->setGreen($green); + } + + /** + * Setter for image blue color + * + * @param $blue Blue color value + * @return void + */ + private function setImagePropertyBlue ($blue) { + // Call the image class + $this->imageInstance->setBlue($blue); + } + + /** + * Setter for string name (identifier) + * + * @param $stringName String name (identifier) + * @return void + */ + private function setImagePropertyStringName ($stringName) { + // Call the image class + $this->imageInstance->setStringName($stringName); + } + + /** + * Setter for font size + * + * @param $fontSize Size of the font + * @return void + */ + private function setImagePropertyFontSize ($fontSize) { + // Call the image class + $this->imageInstance->setFontSize($fontSize); + } + + /** + * Setter for image string + * + * @param $imageString Image string to set + * @return void + */ + private function setImagePropertyText ($imageString) { + // Call the image class + $this->imageInstance->setString($imageString); + } + + /** + * Setter for X coordinate + * + * @param $x X coordinate + * @return void + */ + private function setImagePropertyX ($x) { + // Call the image class + $this->imageInstance->setX($x); + } + + /** + * Setter for Y coordinate + * + * @param $y Y coordinate + * @return void + */ + private function setImagePropertyY ($y) { + // Call the image class + $this->imageInstance->setY($y); + } + + /** + * Getter for image cache file (FQFN) + * + * @return $fqfn Full-qualified file name of the image cache + */ + public function getImageCacheFqfn () { + // Get the FQFN ready + $fqfn = $this->getBasePath().'_cache/' . md5($this->imageInstance->getImageName().":".$this->__toString().":".$this->imageInstance->__toString()) . "." . $this->imageInstance->getImageType(); + + // Return it + return $fqfn; + } + + /** + * Outputs the image to the world + * + * @param $responseInstance An instance of a Responseable class + * @return void + */ + public function transferToResponse (Responseable $responseInstance) { + // Set the image instance + $responseInstance->setImageInstance($this->imageInstance); + } +} + +// [EOF] +?> diff --git a/inc/classes/main/template/mail/.htaccess b/inc/classes/main/template/mail/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/template/mail/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/template/mail/class_MailTemplateEngine.php b/inc/classes/main/template/mail/class_MailTemplateEngine.php new file mode 100644 index 00000000..8fcd0f9e --- /dev/null +++ b/inc/classes/main/template/mail/class_MailTemplateEngine.php @@ -0,0 +1,357 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class MailTemplateEngine extends BaseTemplateEngine implements CompileableTemplate { + /** + * Main nodes in the XML tree + */ + private $mainNodes = array("mail-data"); + + /** + * Sub nodes in the XML tree + */ + private $subNodes = array("subject-line", "sender-address", "recipient-address", "message"); + + /** + * Mailer instance + */ + private $mailerInstance = null; + + /** + * Current main node + */ + private $currMainNode = ""; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of the class TemplateEngine and prepares it for usage + * + * @param $basePath The local base path for all templates + * @param $langInstance An instance of LanguageSystem (default) + * @param $ioInstance An instance of FileIoHandler (default, middleware!) + * @return $tplInstance An instance of TemplateEngine + * @throws BasePathIsEmptyException If the provided $basePath is empty + * @throws InvalidBasePathStringException If $basePath is no string + * @throws BasePathIsNoDirectoryException If $basePath is no + * directory or not found + * @throws BasePathReadProtectedException If $basePath is + * read-protected + */ + public final static function createMailTemplateEngine ($basePath, ManageableLanguage $langInstance, FileIoHandler $ioInstance) { + // Get a new instance + $tplInstance = new MailTemplateEngine(); + + // Is the base path valid? + if (empty($basePath)) { + // Base path is empty + throw new BasePathIsEmptyException($tplInstance, self::EXCEPTION_UNEXPECTED_EMPTY_STRING); + } elseif (!is_string($basePath)) { + // Is not a string + throw new InvalidBasePathStringException(array($tplInstance, $basePath), self::EXCEPTION_INVALID_STRING); + } elseif (!is_dir($basePath)) { + // Is not a path + throw new BasePathIsNoDirectoryException(array($tplInstance, $basePath), self::EXCEPTION_INVALID_PATH_NAME); + } elseif (!is_readable($basePath)) { + // Is not readable + throw new BasePathReadProtectedException(array($tplInstance, $basePath), self::EXCEPTION_READ_PROTECED_PATH); + } + + // Get configuration instance + $cfgInstance = FrameworkConfiguration::getInstance(); + + // Set the base path + $tplInstance->setBasePath($basePath); + + // Set the language and IO instances + $tplInstance->setLanguageInstance($langInstance); + $tplInstance->setFileIoInstance($ioInstance); + + // Set template extensions + $tplInstance->setRawTemplateExtension($cfgInstance->readConfig('raw_template_extension')); + $tplInstance->setCodeTemplateExtension($cfgInstance->readConfig('code_template_extension')); + + // Absolute output path for compiled templates + $tplInstance->setCompileOutputPath($cfgInstance->readConfig('base_path') . $cfgInstance->readConfig('compile_output_path')); + + // Return the prepared instance + return $tplInstance; + } + + /** + * Getter for current main node + * + * @return $currMainNode Current main node + */ + public final function getCurrMainNode () { + return $this->currMainNode; + } + + /** + * Getter for main node array + * + * @return $mainNodes Array with valid main node names + */ + public final function getMainNodes () { + return $this->mainNodes; + } + + /** + * Getter for sub node array + * + * @return $subNodes Array with valid sub node names + */ + public final function getSubNodes () { + return $this->subNodes; + } + + /** + * Handles the start element of an XML resource + * + * @param $resource XML parser resource (currently ignored) + * @param $element The element we shall handle + * @param $attributes All attributes + * @return void + * @throws InvalidXmlNodeException If an unknown/invalid XML node name was found + */ + protected function startElement ($resource, $element, array $attributes) { + // Initial method name which will never be called... + $methodName = 'initEmail'; + + // Make the element name lower-case + $element = strtolower($element); + + // Is the element a main node? + //* DEBUG: */ echo "START: >".$element."<
\n"; + if (in_array($element, $this->getMainNodes())) { + // Okay, main node found! + $methodName = 'setEmail' . $this->convertToClassName($element); + } elseif (in_array($element, $this->getSubNodes())) { + // Sub node found + $methodName = 'setEmailProperty' . $this->convertToClassName($element); + } elseif ($element != 'text-mail') { + // Invalid node name found + throw new InvalidXmlNodeException(array($this, $element, $attributes), BaseHelper::EXCEPTION_XML_NODE_UNKNOWN); + } + + // Call method + //* DEBUG: */ echo "call: ".$methodName."
\n"; + call_user_func_array(array($this, $methodName), $attributes); + } + + /** + * Ends the main or sub node by sending out the gathered data + * + * @param $resource An XML resource pointer (currently ignored) + * @param $nodeName Name of the node we want to finish + * @return void + * @throws XmlNodeMismatchException If current main node mismatches the closing one + */ + protected function endElement ($resource, $nodeName) { + // Make all lower-case + $nodeName = strtolower($nodeName); + + // Does this match with current main node? + //* DEBUG: */ echo "END: >".$nodeName."<
\n"; + if (($nodeName != $this->getCurrMainNode()) && (in_array($nodeName, $this->getMainNodes()))) { + // Did not match! + throw new XmlNodeMismatchException (array($this, $nodeName, $this->getCurrMainNode()), BaseHelper::EXCEPTION_XML_NODE_MISMATCH); + } elseif (in_array($nodeName, $this->getSubNodes())) { + // Silently ignore sub nodes + return; + } + + // Construct method name + $methodName = 'finish' . $this->convertToClassName($nodeName); + + // Call the corresponding method + call_user_func_array(array($this, $methodName), array()); + } + + /** + * Adds the message text to the template engine + * + * @param $resource XML parser resource (currently ignored) + * @param $characters Characters to handle + * @return void + */ + protected function characterHandler ($resource, $characters) { + // Trim all spaces away + $characters = trim($characters); + + // Is this string empty? + if (empty($characters)) { + // Then skip it silently + return false; + } // END - if + + // Add the message now + $this->assignVariable('message', $characters); + } + + /** + * Intializes the mail + * + * @return void + * @todo Add cache creation here + */ + private function initEmail () { + // Unfinished work! + } + + /** + * Setter for mail data node + * + * @return void + * @todo Should we call back the mailer class here? + */ + private function setEmailMailData () { + // Set current main node + $this->currMainNode = 'mail-data'; + } + + /** + * Setter for sender address property + * + * @param $senderAddress Sender address to set in email + * @return void + */ + private function setEmailPropertySenderAddress ($senderAddress) { + // Set the template variable + $this->assignVariable('sender', $senderAddress); + } + + /** + * Setter for recipient address property + * + * @param $recipientAddress Recipient address to set in email + * @return void + */ + private function setEmailPropertyRecipientAddress ($recipientAddress) { + // Set the template variable + $this->assignVariable('recipient', $recipientAddress); + } + + /** + * Setter for subject line property + * + * @param $subjectLine Subject line to set in email + * @return void + */ + private function setEmailPropertySubjectLine ($subjectLine) { + // Set the template variable + $this->assignVariable('subject', $subjectLine); + } + + /** + * Method stub to avoid output + * + * @return void + */ + private function setEmailPropertyMessage () { + // Empty for now + } + + /** + * Gets the template variable "message", stores it back as raw template data + * and compiles all variables so the mail message got prepared for output + * + * @return void + */ + private function finishMailData () { + // Get the message and set it as new raw template data back + $message = $this->readVariable('message'); + $this->setRawTemplateData($message); + + // Get some variables to compile + //$sender = $this->compileRawCode($this->readVariable('sender')); + //$this->assignVariable('sender', $sender); + + // Then compile all variables + $this->compileVariables(); + } + + /** + * Invokes the final mail process + * + * @return void + */ + private function finishTextMail () { + $this->getMailerInstance()->invokeMailDelivery(); + } + + /** + * Getter for image cache file (FQFN) + * + * @return $fqfn Full-qualified file name of the image cache + * @todo 0% done + */ + public function getMailCacheFqfn () { + // Initialize FQFN + $fqfn = ""; + $this->debugBackTrace(); + + // Return it + return $fqfn; + } + + /** + * Setter for mailer instance + * + * @param $mailerInstance A mailer instance + * @return void + */ + public final function setMailerInstance (DeliverableMail $mailerInstance) { + $this->mailerInstance = $mailerInstance; + } + + /** + * Getter for mailer instance + * + * @return $mailerInstance A mailer instance + */ + protected final function getMailerInstance () { + return $this->mailerInstance; + } + + /** + * Outputs the mail to the world. This should only the mailer debug class do! + * + * @param $responseInstance An instance of a Responseable class + * @return void + */ + public function transferToResponse (Responseable $responseInstance) { + $responseInstance->writeToBody($this->getCompiledData()); + } +} + +// [EOF] +?> diff --git a/inc/classes/main/template/web/.htaccess b/inc/classes/main/template/web/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/template/web/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/template/web/class_WebTemplateEngine.php b/inc/classes/main/template/web/class_WebTemplateEngine.php new file mode 100644 index 00000000..61a6bbb1 --- /dev/null +++ b/inc/classes/main/template/web/class_WebTemplateEngine.php @@ -0,0 +1,92 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class WebTemplateEngine extends BaseTemplateEngine implements CompileableTemplate { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of the class TemplateEngine and prepares it for usage + * + * @param $basePath The local base path for all templates + * @param $langInstance An instance of LanguageSystem (default) + * @param $ioInstance An instance of FileIoHandler (default, middleware!) + * @return $tplInstance An instance of TemplateEngine + * @throws BasePathIsEmptyException If the provided $basePath is empty + * @throws InvalidBasePathStringException If $basePath is no string + * @throws BasePathIsNoDirectoryException If $basePath is no + * directory or not found + * @throws BasePathReadProtectedException If $basePath is + * read-protected + */ + public final static function createWebTemplateEngine ($basePath, ManageableLanguage $langInstance, FileIoHandler $ioInstance) { + // Get a new instance + $tplInstance = new WebTemplateEngine(); + + // Is the base path valid? + if (empty($basePath)) { + // Base path is empty + throw new BasePathIsEmptyException($tplInstance, self::EXCEPTION_UNEXPECTED_EMPTY_STRING); + } elseif (!is_string($basePath)) { + // Is not a string + throw new InvalidBasePathStringException(array($tplInstance, $basePath), self::EXCEPTION_INVALID_STRING); + } elseif (!is_dir($basePath)) { + // Is not a path + throw new BasePathIsNoDirectoryException(array($tplInstance, $basePath), self::EXCEPTION_INVALID_PATH_NAME); + } elseif (!is_readable($basePath)) { + // Is not readable + throw new BasePathReadProtectedException(array($tplInstance, $basePath), self::EXCEPTION_READ_PROTECED_PATH); + } + + // Get configuration instance + $cfgInstance = FrameworkConfiguration::getInstance(); + + // Set the base path + $tplInstance->setBasePath($basePath); + + // Set the language and IO instances + $tplInstance->setLanguageInstance($langInstance); + $tplInstance->setFileIoInstance($ioInstance); + + // Set template extensions + $tplInstance->setRawTemplateExtension($cfgInstance->readConfig('raw_template_extension')); + $tplInstance->setCodeTemplateExtension($cfgInstance->readConfig('code_template_extension')); + + // Absolute output path for compiled templates + $tplInstance->setCompileOutputPath($cfgInstance->readConfig('base_path') . $cfgInstance->readConfig('compile_output_path')); + + // Return the prepared instance + return $tplInstance; + } +} + +// [EOF] +?> diff --git a/inc/classes/main/user/.htaccess b/inc/classes/main/user/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/user/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/user/class_BaseUser.php b/inc/classes/main/user/class_BaseUser.php new file mode 100644 index 00000000..b00a0730 --- /dev/null +++ b/inc/classes/main/user/class_BaseUser.php @@ -0,0 +1,340 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseUser extends BaseFrameworkSystem { + // Exception constances + const EXCEPTION_USERNAME_NOT_FOUND = 0x150; + const EXCEPTION_USER_EMAIL_NOT_FOUND = 0x151; + const EXCEPTION_USER_PASS_MISMATCH = 0x152; + + /** + * Username of current user + */ + private $userName = ""; + + /** + * User id of current user + */ + private $userId = 0; + + /** + * Email of current user + */ + private $email = ""; + + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + + // Clean up a little + $this->removeNumberFormaters(); + $this->removeSystemArray(); + } + + /** + * Setter for username + * + * @param $userName The username to set + * @return void + */ + public final function setUserName ($userName) { + $this->userName = (string) $userName; + } + + /** + * Getter for username + * + * @return $userName The username to get + */ + public final function getUserName () { + return $this->userName; + } + + /** + * Setter for user id + * + * @param $userId The user id to set + * @return void + * @todo Find a way of casting here. "(int)" might destroy the user id > 32766 + */ + public final function setUserId ($userId) { + $this->userId = $userId; + } + + /** + * Getter for user id + * + * @return $userId The user id to get + */ + public final function getUserId () { + return $this->userId; + } + + /** + * Setter for email + * + * @param $email The email to set + * @return void + */ + protected final function setEmail ($email) { + $this->email = (string) $email; + } + + /** + * Getter for email + * + * @return $email The email to get + */ + public final function getEmail () { + return $this->email; + } + + /** + * Determines wether the username exists or not + * + * @return $exists Wether the username exists + */ + public function ifUsernameExists () { + // By default the username does not exist + $exists = false; + + // Is a previous result there? + if (is_null($this->getResultInstance())) { + // Get a UserDatabaseWrapper instance + $wrapperInstance = ObjectFactory::createObjectByConfiguredName('user_db_wrapper_class'); + + // Create a search criteria + $criteriaInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class'); + + // Add the username as a criteria and set limit to one entry + $criteriaInstance->addCriteria(UserDatabaseWrapper::DB_COLUMN_USERNAME, $this->getUserName()); + $criteriaInstance->setLimit(1); + + // Get a search result + $resultInstance = $wrapperInstance->doSelectByCriteria($criteriaInstance); + + // Set the index "solver" + $resultInstance->solveResultIndex(UserDatabaseWrapper::DB_COLUMN_USERID, $wrapperInstance, array($this, 'setUserId')); + + // And finally set it + $this->setResultInstance($resultInstance); + } // END - if + + // Rewind it + $this->getResultInstance()->rewind(); + + // Search for it + if ($this->getResultInstance()->next()) { + // Entry found + $exists = true; + } // END - if + + // Return the status + return $exists; + } + + /** + * Determines wether the email exists or not + * + * @return $exists Wether the email exists + */ + public function ifEmailAddressExists () { + // By default the email does not exist + $exists = false; + + // Is a previous result there? + if (is_null($this->getResultInstance())) { + // Get a UserDatabaseWrapper instance + $wrapperInstance = ObjectFactory::createObjectByConfiguredName('user_db_wrapper_class'); + + // Create a search criteria + $criteriaInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class'); + + // Add the username as a criteria and set limit to one entry + $criteriaInstance->addCriteria(UserDatabaseWrapper::DB_COLUMN_EMAIL, $this->getEmail()); + $criteriaInstance->setLimit(1); + + // Get a search result + $resultInstance = $wrapperInstance->doSelectByCriteria($criteriaInstance); + + // Set the index "solver" + $resultInstance->solveResultIndex(UserDatabaseWrapper::DB_COLUMN_USERID, $wrapperInstance, array($this, 'setUserId')); + + // And finally set it + $this->setResultInstance($resultInstance); + } // END - if + + // Rewind it + $this->getResultInstance()->rewind(); + + // Search for it + if ($this->getResultInstance()->next()) { + // Entry found + $exists = true; + + // Is the username set? + if ($this->getUserName() == "") { + // Get current entry + $currEntry = $this->getResultInstance()->current(); + + // Set the username + $this->setUserName($currEntry['username']); + } // END - if + } // END - if + + // Return the status + return $exists; + } + + /** + * Checks if supplied password hash in request matches with the stored in + * database. + * + * @param $requestInstance A requestable class instance + * @return $matches Wether the supplied password hash matches + */ + public function ifPasswordHashMatches (Requestable $requestInstance) { + // By default nothing matches... ;) + $matches = false; + + // Is a previous result there? + if (is_null($this->getResultInstance())) { + // Get a UserDatabaseWrapper instance + $wrapperInstance = ObjectFactory::createObjectByConfiguredName('user_db_wrapper_class'); + + // Create a search criteria + $criteriaInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class'); + + // Add the username as a criteria and set limit to one entry + $criteriaInstance->addCriteria(UserDatabaseWrapper::DB_COLUMN_USERNAME, $this->getUserName()); + $criteriaInstance->setLimit(1); + + // Get a search result + $resultInstance = $wrapperInstance->doSelectByCriteria($criteriaInstance); + + // Set the index "solver" + $resultInstance->solveResultIndex(UserDatabaseWrapper::DB_COLUMN_USERID, $wrapperInstance, array($this, 'setUserId')); + + // And finally set it + $this->setResultInstance($resultInstance); + } // END - if + + // Rewind it + $this->getResultInstance()->rewind(); + + // Search for it + if ($this->getResultInstance()->find('pass_hash')) { + // So does the hashes match? + //* DEBUG: */ echo $requestInstance->getRequestElement('pass_hash')."/".$entry['pass_hash']; + $matches = ($requestInstance->getRequestElement('pass_hash') === $this->getResultInstance()->getFoundValue()); + } // END - if + + // Return the status + return $matches; + } + + /** + * "Getter" for user's password hash + * + * @return $passHash User's password hash from database result + */ + public final function getPasswordHash () { + // Default is missing password hash + $passHash = null; + + // Get a database entry + $entry = $this->getDatabaseEntry(); + + // Is the password hash there? + if (isset($entry['pass_hash'])) { + // Get it + $passHash = $entry['pass_hash']; + } // END - if + + // And return the hash + return $passHash; + } + + /** + * Getter for primary key value + * + * @return $primaryValue Value of the primary key based on database type + */ + public final function getPrimaryKey () { + // Get a user database wrapper + $wrapperInstance = ObjectFactory::createObjectByConfiguredName('user_db_wrapper_class'); + + // Get the primary key back from the wrapper + $primaryKey = $wrapperInstance->getPrimaryKeyValue(); + + // Get that field + $primaryValue = $this->getField($primaryKey); + + // Return the value + return $primaryValue; + } + + /** + * Updates a given field with new value + * + * @param $fieldName Field to update + * @param $fieldValue New value to store + * @return void + * @throws DatabaseUpdateSupportException If this class does not support database updates + */ + public function updateDatabaseField ($fieldName, $fieldValue) { + // Is updating database fields allowed by interface? + if (!$this instanceof Updateable) { + // Update not supported! + throw new DatabaseUpdateSupportException($this, self::EXCEPTION_DATABASE_UPDATED_NOT_ALLOWED); + } // END - if + + // Get a critieria instance + $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class'); + + // Add search criteria + $searchInstance->addCriteria(UserDatabaseWrapper::DB_COLUMN_USERNAME, $this->getUserName()); + $searchInstance->setLimit(1); + + // Now get another criteria + $updateInstance = ObjectFactory::createObjectByConfiguredName('update_criteria_class'); + + // And add our both entries + $updateInstance->addCriteria($fieldName, $fieldValue); + + // Add the search criteria for searching for the right entry + $updateInstance->setSearchInstance($searchInstance); + + // Remember the update in database result + $this->getResultInstance()->add2UpdateQueue($updateInstance); + } +} + +// [EOF] +?> diff --git a/inc/classes/main/user/guest/.htaccess b/inc/classes/main/user/guest/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/user/guest/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/user/guest/class_Guest.php b/inc/classes/main/user/guest/class_Guest.php new file mode 100644 index 00000000..2362921b --- /dev/null +++ b/inc/classes/main/user/guest/class_Guest.php @@ -0,0 +1,107 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class Guest extends BaseUser implements ManageableGuest, Registerable { + // Exceptions + const EXCEPTION_USERNAME_NOT_FOUND = 0x170; + const EXCEPTION_USER_EMAIL_NOT_FOUND = 0x171; + const EXCEPTION_USER_PASS_MISMATCH = 0x172; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this user class by a provided username. This + * factory method will check if username is already taken and if not so it + * will throw an exception. + * + * @param $userName Username we need a class instance for + * @return $userInstance An instance of this user class + * @throws UsernameMissingException If the username does not exist + */ + public final static function createGuestByUsername ($userName) { + // Get a new instance + $userInstance = new Guest(); + + // Set the username + $userInstance->setUserName($userName); + + // Check if username exists + if ($userInstance->ifUsernameExists() === false) { + // Throw an exception here + throw new UsernameMissingException(array($userInstance, $userName), self::EXCEPTION_USERNAME_NOT_FOUND); + } // END - if + + // Return the instance + return $userInstance; + } + + /** + * Creates an instance of this user class by a provided email address. This + * factory method will not check if email address is there. + * + * @param $email Email address of the user + * @return $userInstance An instance of this user class + */ + public final static function createGuestByEmail ($email) { + // Get a new instance + $userInstance = new Guest(); + + // Set the username + $userInstance->setEmail($email); + + // Return the instance + return $userInstance; + } + + /** + * Updates the last activity timestamp and last performed action in the + * database result. You should call flushPendingUpdates() to flush these updates + * to the database layer. + * + * @param $requestInstance A requestable class instance + * @return void + */ + public function updateLastActivity (Requestable $requestInstance) { + // No activity will be logged for guest accounts + } + + /** + * Flushs all pending updates to the database layer + * + * @return void + */ + public function flushPendingUpdates () { + // No updates will be flushed to database! + } +} + +// [EOF] +?> diff --git a/inc/classes/main/user/member/.htaccess b/inc/classes/main/user/member/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/main/user/member/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/user/member/class_Member.php b/inc/classes/main/user/member/class_Member.php new file mode 100644 index 00000000..b67ad88b --- /dev/null +++ b/inc/classes/main/user/member/class_Member.php @@ -0,0 +1,175 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class Member extends BaseUser implements ManageableMember, Registerable, Updateable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Destructor to always flush updates + * + * @return void + */ + public function __destruct () { + // Flush any updated entries to the database + $this->flushPendingUpdates(); + + // Call parent destructor + parent::__destruct(); + } + + /** + * Creates an instance of this user class by a provided username. This + * factory method will check if username is already taken and if not so it + * will throw an exception. + * + * @param $userName Username we need a class instance for + * @return $userInstance An instance of this user class + * @throws UsernameMissingException If the username does not exist + */ + public final static function createMemberByUsername ($userName) { + // Get a new instance + $userInstance = new Member(); + + // Set the username + $userInstance->setUserName($userName); + + // Check if username exists + if ($userInstance->ifUsernameExists() === false) { + // Throw an exception here + throw new UsernameMissingException(array($userInstance, $userName), self::EXCEPTION_USERNAME_NOT_FOUND); + } // END - if + + // Return the instance + return $userInstance; + } + + /** + * Creates an instance of this user class by a provided email address. This + * factory method will not check if email address is there. + * + * @param $email Email address of the user + * @return $userInstance An instance of this user class + */ + public final static function createMemberByEmail ($email) { + // Get a new instance + $userInstance = new Member(); + + // Set the username + $userInstance->setEmail($email); + + // Return the instance + return $userInstance; + } + + /** + * Creates a user by a given request instance + * + * @param $requestInstance An instance of a Requestable class + * @return $userInstance An instance of this user class + * @todo Add more ways over creating user classes + */ + public final static function createMemberByRequest (Requestable $requestInstance) { + // Determine if by email or username + if (!is_null($requestInstance->getRequestElement('username'))) { + // Username supplied + $userInstance = self::createMemberByUserName($requestInstance->getRequestElement('username')); + } elseif (!is_null($requestInstance->getRequestElement('email'))) { + // Email supplied + $userInstance = self::createMemberByEmail($requestInstance->getRequestElement('email')); + } else { + // Unsupported mode + $userInstance = new Member(); + $userInstance->partialStub("We need to add more ways of creating user classes here."); + $userInstance->debugBackTrace(); + exit(); + } + + // Return the prepared instance + return $userInstance; + } + + /** + * Updates the last activity timestamp and last performed action in the + * database result. You should call flushPendingUpdates() to flush these updates + * to the database layer. + * + * @param $requestInstance A requestable class instance + * @return void + */ + public function updateLastActivity (Requestable $requestInstance) { + // Set last action + $lastAction = $requestInstance->getRequestElement('action'); + + // If there is no action use the default on + if (is_null($lastAction)) { + $lastAction = $this->getConfigInstance()->readConfig('login_default_action'); + } // END - if + + // Get a critieria instance + $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class'); + + // Add search criteria + $searchInstance->addCriteria(UserDatabaseWrapper::DB_COLUMN_USERNAME, $this->getUserName()); + $searchInstance->setLimit(1); + + // Now get another criteria + $updateInstance = ObjectFactory::createObjectByConfiguredName('update_criteria_class'); + + // And add our both entries + $updateInstance->addCriteria("last_activity", date("Y-m-d H:i:s", time())); + $updateInstance->addCriteria("last_action", $lastAction); + + // Add the search criteria for searching for the right entry + $updateInstance->setSearchInstance($searchInstance); + + // Remember the update in database result + $this->getResultInstance()->add2UpdateQueue($updateInstance); + } + + /** + * Flushs all pending updates to the database layer + * + * @return void + */ + public function flushPendingUpdates () { + // Do we have data to update? + if ($this->getResultInstance()->ifDataNeedsFlush()) { + // Get a database wrapper + $wrapperInstance = ObjectFactory::createObjectByConfiguredName('user_db_wrapper_class'); + + // Yes, then send the whole result to the database layer + $wrapperInstance->doUpdateByResult($this->getResultInstance()); + } // END - if + } +} + +// [EOF] +?> diff --git a/inc/classes/middleware/.htaccess b/inc/classes/middleware/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/middleware/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/middleware/class_BaseMiddleware.php b/inc/classes/middleware/class_BaseMiddleware.php new file mode 100644 index 00000000..48e7b1c2 --- /dev/null +++ b/inc/classes/middleware/class_BaseMiddleware.php @@ -0,0 +1,42 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseMiddleware extends BaseFrameworkSystem { + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + + // Clean up a little + $this->removeNumberFormaters(); + $this->removeSystemArray(); + } +} + +// [EOF] +?> diff --git a/inc/classes/middleware/compressor/.htaccess b/inc/classes/middleware/compressor/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/middleware/compressor/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/middleware/compressor/class_CompressorChannel.php b/inc/classes/middleware/compressor/class_CompressorChannel.php new file mode 100644 index 00000000..6d3ede25 --- /dev/null +++ b/inc/classes/middleware/compressor/class_CompressorChannel.php @@ -0,0 +1,129 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class CompressorChannel extends BaseMiddleware implements Registerable { + /** + * Real compressor instance + */ + private $compressor = null; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor! + parent::__construct(__CLASS__); + } + + /** + * Create a new compressor channel based a given base directory where + * we shall look for compressor classes + * + * @param $baseDir Directory which holds our compressor classes + * @return $cInstance A prepared instance of this class + */ + public final static function createCompressorChannel ($baseDir) { + // Get new instance + $cInstance = new CompressorChannel(); + + // Is the compressor handler set? + if ( + (is_null($cInstance->getCompressor())) + || (!is_object($cInstance->getCompressor())) + || (!method_exists($cInstance->getCompressor(), 'compressStream')) + || (!method_exists($cInstance->getCompressor(), 'decompressStream')) + ) { + // Get a directory pointer + $dirPointer = FrameworkDirectoryPointer::createFrameworkDirectoryPointer($baseDir); + + // Read all directories but no sub directories + while ($dir = $dirPointer->readDirectoryExcept(array("..", ".", ".htaccess", ".svn"))) { + // Is this a class file? + if ((substr($dir, 0, 6) == "class_") && (substr($dir, -4, 4) == ".php")) { + // Get the compressor's name. That's why you must name + // your files like your classes and also that's why you + // must keep on class in one file. + $className = substr($dir, 6, -4); + + // Get an instance from our object factory + $tempInstance = ObjectFactory::createObjectByName($className); + + // Set the compressor + $cInstance->setCompressor($tempInstance); + + // No more searches required because we have found a valid compressor stream + break; + } // END - if + } // END - while + + // Close the directory + $dirPointer->closeDirectory(); + } // END - if + + // Check again if there is a compressor + if ( + (is_null($cInstance->getCompressor())) + || (!is_object($cInstance->getCompressor())) + || (!method_exists($cInstance->getCompressor(), 'compressStream')) + || (!method_exists($cInstance->getCompressor(), 'decompressStream')) + ) { + // Set the null compressor handler. This should not be configureable! + $cInstance->setCompressor(ObjectFactory::createObjectByName('NullCompressor')); + } // END - if + + // Return the compressor instance + return $cInstance; + } + + /** + * Getter for compressor instance + * + * @return $compressor The compressor instance + */ + public final function getCompressor () { + return $this->compressor; + } + + /** + * Setter for compressor + * + * @param $compressorInstance The compressor instance we shall use + * @return void + */ + public final function setCompressor (Compressor $compressorInstance) { + $this->compressor = $compressorInstance; + } + + /** + * Getter for the file extension of the current compressor + */ + public final function getCompressorExtension () { + // Get compressor extension from current compressor + return $this->getCompressor()->getCompressorExtension(); + } +} + +// [EOF] +?> diff --git a/inc/classes/middleware/database/.htaccess b/inc/classes/middleware/database/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/middleware/database/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/middleware/database/class_DatabaseConnection.php b/inc/classes/middleware/database/class_DatabaseConnection.php new file mode 100644 index 00000000..6f0a4e1e --- /dev/null +++ b/inc/classes/middleware/database/class_DatabaseConnection.php @@ -0,0 +1,186 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class DatabaseConnection extends BaseMiddleware implements DatabaseConnector, Registerable { + /** + * Array for connection data + */ + private $connectData = array( + 'login' => "", + 'pass' => "", + 'dbase' => "", + 'host' => "" + ); + + // The real database layer + private $dbLayer = null; + + // An instance of this class + private static $thisInstance = null; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct() { + // Call parent constructor + parent::__construct(__CLASS__); + } + + // Create new database connection layer + public final static function createDatabaseConnection (DebugMiddleware $debugInstance, DatabaseFrontendInterface $dbLayer) { + // Get instance + $dbInstance = new DatabaseConnection(); + + // Set debug output handler + $dbInstance->setDebugInstance($debugInstance); + + // Set database layer + $dbInstance->setDatabaseLayer($dbLayer); + + // Set db instance + self::$thisInstance = $dbInstance; + + // Return instance + return $dbInstance; + } + + // Get an instance of this class + public final static function getInstance () { + return self::$thisInstance; + } + + // Public setter for database connection + public final function setConnectionData ($login, $pass, $dbase, $host="localhost") { + // Transfer connection data + $this->connectData['login'] = (string) $login; + $this->connectData['pass'] = (string) $pass; + $this->connectData['dbase'] = (string) $dbase; + $this->connectData['host'] = (string) $host; + } + + /** + * Getter for connection data + * + * @return $connectData Connection data stored with this clas + */ + public final function getConnectionData () { + return $this->connectData; + } + + /** + * Setter for the real database layer + * @param $dbLayer An instance of the real database layer + * @return void + */ + public final function setDatabaseLayer (DatabaseFrontendInterface $dbLayer) { + $this->dbLayer = $dbLayer; + } + + /** + * Getter for index key + * + * @return $indexKey Index key + */ + public final function getIndexKey () { + return $this->dbLayer->getIndexKey(); + } + + /** + * Runs a "select" statement on the database layer with given table name + * and criteria. If this doesn't fail the result will be returned + * + * @param $tableName Name of the "table" we shall query + * @param $criteriaInstance An instance of a Criteria class + * @return $result The result as an array + */ + public function doSelectByTableCriteria ($tableName, Criteria $criteriaInstance) { + // Connect to the database + $this->dbLayer->connectToDatabase(); + + // Get result from query + $result = $this->dbLayer->querySelect("array", $tableName, $criteriaInstance); + + // Return the result + return $result; + } + + /** + * Getter for last exception + * + * @return $exceptionInstance Last thrown exception + */ + public final function getLastException () { + $exceptionInstance = $this->dbLayer->getLastException(); + return $exceptionInstance; + } + + /** + * "Inserts" a data set instance into a local file database folder + * + * @param $dataSetInstance A storeable data set + * @return void + */ + public function queryInsertDataSet (StoreableCriteria $dataSetInstance) { + // Connect to the database + $this->dbLayer->connectToDatabase(); + + // Ask the database layer + $this->dbLayer->queryInsertDataSet($dataSetInstance); + } + + /** + * "Updates" a data set instance with a database layer + * + * @param $dataSetInstance A storeable data set + * @return void + */ + public function queryUpdateDataSet (StoreableCriteria $dataSetInstance) { + // Connect to the database + $this->dbLayer->connectToDatabase(); + + // Ask the database layer + $this->dbLayer->queryUpdateDataSet($dataSetInstance); + } + + /** + * Getter for primary key column of specified table name + * + * @param $tableName Name of table we need the primary key column from + * @return $primaryKey Primary key column of requested table + */ + public function getPrimaryKeyOfTable ($tableName) { + // Connect to the database + $this->dbLayer->connectToDatabase(); + + // Ask the database layer + $primaryKey = $this->dbLayer->getPrimaryKeyOfTable($tableName); + + // Return the value + return $primaryKey; + } +} + +// [EOF] +?> diff --git a/inc/classes/middleware/debug/.htaccess b/inc/classes/middleware/debug/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/middleware/debug/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/middleware/debug/class_DebugMiddleware.php b/inc/classes/middleware/debug/class_DebugMiddleware.php new file mode 100644 index 00000000..8ee7e083 --- /dev/null +++ b/inc/classes/middleware/debug/class_DebugMiddleware.php @@ -0,0 +1,119 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class DebugMiddleware extends BaseMiddleware implements Registerable { + /** + * The concrete output instance + */ + private $outputInstance = null; + + /** + * An instance of this class + */ + private static $thisInstance = null; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set own instance + self::$thisInstance = $this; + } + + /** + * Create a new debug output system. + * If no output is given this class is currently being used for back-fall. + * This fall-back mechanism will become deprecated very soon. + * + * @param $debuggerClass The class name which we shall use for + * registering the *real* debug output + * @return $debugInstance An instance of this middleware class + */ + public final static function createDebugMiddleware ($debuggerClass) { + // Create an instance if this middleware + $debugInstance = new DebugMiddleware(); + + // Is there a valid output instance provided? + if ((!is_null($debuggerClass)) && (is_object($debuggerClass)) && ($debuggerClass instanceof OutputStreamer)) { + // Use the given output instance + $debugInstance->setOutputInstance($debuggerClass); + } elseif ((!is_null($debuggerClass)) && (is_string($debuggerClass)) && (class_exists($debuggerClass))) { + // A name for a debug output class has been provided so we try to get it + $debuggerInstance = ObjectFactory::createObjectByName($debuggerClass); + + // Set this as output class + $debugInstance->setOutputInstance($debuggerInstance); + } + + // Return instance + return $debugInstance; + } + + /** + * Getter for an instance of this class + * + * @return $thisInstance An instance of this class + */ + public final static function getInstance() { + return self::$thisInstance; + } + + /** + * Setter for output instance + * + * @param $outputInstance The debug output instance + * @return void + */ + public final function setOutputInstance (OutputStreamer $outputInstance) { + $this->outputInstance = $outputInstance; + } + + /** + * This method shall send debug output which can be HTML code for the + * browser or debug lines for a log file, etc. to the registered debug + * output instance. + * + * @param $outStream Data we shall "stream" out to the world + * @return void + */ + public final function output ($outStream) { + // Is the output stream set + if (empty($outStream)) { + // Initialization phase + return; + } // END - if + + // Use the output instance + $this->outputInstance->outputStream($outStream); + } +} + +// [EOF] +?> diff --git a/inc/classes/middleware/io/.htaccess b/inc/classes/middleware/io/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/middleware/io/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/middleware/io/class_FileIoHandler.php b/inc/classes/middleware/io/class_FileIoHandler.php new file mode 100644 index 00000000..db579790 --- /dev/null +++ b/inc/classes/middleware/io/class_FileIoHandler.php @@ -0,0 +1,150 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class FileIoHandler extends BaseMiddleware { + /** + * The *real* file input class we shall use for reading data + */ + private $inputStream = null; + + /** + * The *real* file output class we shall use for reading data + */ + private $outputStream = null; + + /** + * An instance of this class + */ + private static $thisInstance = null; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set own instance + self::$thisInstance = $this; + } + + /** + * Creates an instance of this class and prepares the IO system. This is + * being done by setting the default file IO class + * + * @return $ioInstance A prepared instance of FilIOHandler + */ + public final static function createFileIoHandler () { + // Get instance + $ioHandler = new FileIoHandler(); + + // Set the *real* file IO instances (both the same) + $ioHandler->setInputStream(ObjectFactory::createObjectByConfiguredName('file_input_class')); + $ioHandler->setOutputStream(ObjectFactory::createObjectByConfiguredName('file_output_class')); + + // Return instance + return $ioHandler; + } + + /** + * Getter for an instance of this class + * + * @return $thisInstance An instance of this class + */ + public final static function getInstance () { + return self::$thisInstance; + } + + /** + * Setter for the *real* file input instance + * + * @param $inputStream The *real* file-input class + * @return void + */ + public final function setInputStream (FileInputStreamer $inputStream) { + $this->inputStream = $inputStream; + } + + /** + * Getter for the *real* file input instance + * + * @return $inputStream The *real* file-input class + */ + public final function getInputStream () { + return $this->inputStream; + } + + /** + * Setter for the *real* file output instance + * + * @param $outputStream The *real* file-output class + * @return void + */ + public final function setOutputStream (FileOutputStreamer $outputStream) { + $this->outputStream = $outputStream; + } + + /** + * Getter for the *real* file output instance + * + * @return $outputStream The *real* file-output class + */ + public final function getOutputStream () { + return $this->outputStream; + } + + /** + * Saves a file with data by using the current output stream + * + * @param $fileName Name of the file + * @param $dataArray Array with file contents + * @return void + * @see FileOutputStreamer + */ + public function saveFile ($fileName, $dataArray) { + // Get output stream + $outInstance = $this->getOutputStream(); + + // Send the fileName and dataArray to the output handler + $outInstance->saveFile($fileName, $dataArray); + } + + /** Loads data from a file over the input handler + * + * @return $array Array with the file contents + * @see FileInputStreamer + */ + public function loadFileContents ($fqfn) { + // Get output stream + $inInstance = $this->getInputStream(); + + // Read from the input handler + return $inInstance->loadFileContents($fqfn); + } +} + +// [EOF] +?> diff --git a/inc/classes/third_party/.htaccess b/inc/classes/third_party/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/third_party/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/third_party/akismet/.htaccess b/inc/classes/third_party/akismet/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/third_party/akismet/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/third_party/akismet/akismet.class.php b/inc/classes/third_party/akismet/akismet.class.php new file mode 100644 index 00000000..021447ec --- /dev/null +++ b/inc/classes/third_party/akismet/akismet.class.php @@ -0,0 +1,388 @@ +Usage + * + * $comment = array( + * 'author' => 'viagra-test-123', + * 'email' => 'test@example.com', + * 'website' => 'http://www.example.com/', + * 'body' => 'This is a test comment', + * 'permalink' => 'http://yourdomain.com/yourblogpost.url', + * ); + * + * $akismet = new Akismet('http://www.yourdomain.com/', 'YOUR_WORDPRESS_API_KEY', $comment); + * + * if($akismet->errorsExist()) { + * echo"Couldn't connected to Akismet server!"; + * } else { + * if($akismet->isSpam()) { + * echo"Spam detected"; + * } else { + * echo"yay, no spam!"; + * } + * } + * + * + * @author Bret Kuhns {@link www.miphp.net} + * @link http://www.miphp.net/blog/view/new_akismet_class/ + * @version 0.3.4 + * @license http://www.opensource.org/licenses/mit-license.php MIT License + */ + + + +// Error constants +define("AKISMET_SERVER_NOT_FOUND", 0); +define("AKISMET_RESPONSE_FAILED", 1); +define("AKISMET_INVALID_KEY", 2); + + + +// Base class to assist in error handling between Akismet classes +class AkismetObject { + var $errors = array(); + + + /** + * Add a new error to the errors array in the object + * + * @param String $name A name (array key) for the error + * @param String $string The error message + * @return void + */ + // Set an error in the object + function setError($name, $message) { + $this->errors[$name] = $message; + } + + + /** + * Return a specific error message from the errors array + * + * @param String $name The name of the error you want + * @return mixed Returns a String if the error exists, a false boolean if it does not exist + */ + function getError($name) { + if($this->isError($name)) { + return $this->errors[$name]; + } else { + return false; + } + } + + + /** + * Return all errors in the object + * + * @return String[] + */ + function getErrors() { + return (array)$this->errors; + } + + + /** + * Check if a certain error exists + * + * @param String $name The name of the error you want + * @return boolean + */ + function isError($name) { + return isset($this->errors[$name]); + } + + + /** + * Check if any errors exist + * + * @return boolean + */ + function errorsExist() { + return (count($this->errors) > 0); + } + + +} + + + + + +// Used by the Akismet class to communicate with the Akismet service +class AkismetHttpClient extends AkismetObject { + var $akismetVersion = '1.1'; + var $con; + var $host; + var $port; + var $apiKey; + var $blogUrl; + var $errors = array(); + + + // Constructor + function AkismetHttpClient($host, $blogUrl, $apiKey, $port = 80) { + $this->host = $host; + $this->port = $port; + $this->blogUrl = $blogUrl; + $this->apiKey = $apiKey; + } + + + // Use the connection active in $con to get a response from the server and return that response + function getResponse($request, $path, $type = "post", $responseLength = 1160) { + $this->_connect(); + + if($this->con && !$this->isError(AKISMET_SERVER_NOT_FOUND)) { + $request = + strToUpper($type)." /{$this->akismetVersion}/$path HTTP/1.1\r\n" . + "Host: ".((!empty($this->apiKey)) ? $this->apiKey."." : null)."{$this->host}\r\n" . + "Content-Type: application/x-www-form-urlencoded; charset=utf-8\r\n" . + "Content-Length: ".strlen($request)."\r\n" . + "User-Agent: Akismet PHP4 Class\r\n" . + "\r\n" . + $request + ; + $response = ""; + + @fwrite($this->con, $request); + + while(!feof($this->con)) { + $response .= @fgets($this->con, $responseLength); + } + + $response = explode("\r\n\r\n", $response, 2); + return $response[1]; + } else { + $this->setError(AKISMET_RESPONSE_FAILED, "The response could not be retrieved."); + } + + $this->_disconnect(); + } + + + // Connect to the Akismet server and store that connection in the instance variable $con + function _connect() { + if(!($this->con = @fsockopen($this->host, $this->port))) { + $this->setError(AKISMET_SERVER_NOT_FOUND, "Could not connect to akismet server."); + } + } + + + // Close the connection to the Akismet server + function _disconnect() { + @fclose($this->con); + } + + +} + + + + + +// The controlling class. This is the ONLY class the user should instantiate in +// order to use the Akismet service! +class Akismet extends AkismetObject { + var $apiPort = 80; + var $akismetServer = 'rest.akismet.com'; + var $akismetVersion = '1.1'; + var $http; + + var $ignore = array( + 'HTTP_COOKIE', + 'HTTP_X_FORWARDED_FOR', + 'HTTP_X_FORWARDED_HOST', + 'HTTP_MAX_FORWARDS', + 'HTTP_X_FORWARDED_SERVER', + 'REDIRECT_STATUS', + 'SERVER_PORT', + 'PATH', + 'DOCUMENT_ROOT', + 'SERVER_ADMIN', + 'QUERY_STRING', + 'PHP_SELF', + 'argv' + ); + + var $blogUrl = ""; + var $apiKey = ""; + var $comment = array(); + + + /** + * Constructor + * + * Set instance variables, connect to Akismet, and check API key + * + * @param String $blogUrl The URL to your own blog + * @param String $apiKey Your wordpress API key + * @param String[] $comment A formatted comment array to be examined by the Akismet service + * @return Akismet + */ + function Akismet($blogUrl, $apiKey, $comment = array()) { + $this->blogUrl = $blogUrl; + $this->apiKey = $apiKey; + $this->setComment($comment); + + // Connect to the Akismet server and populate errors if they exist + $this->http = new AkismetHttpClient($this->akismetServer, $blogUrl, $apiKey); + if($this->http->errorsExist()) { + $this->errors = array_merge($this->errors, $this->http->getErrors()); + } + + // Check if the API key is valid + if(!$this->_isValidApiKey($apiKey)) { + $this->setError(AKISMET_INVALID_KEY, "Your Akismet API key is not valid."); + } + } + + + /** + * Query the Akismet and determine if the comment is spam or not + * + * @return boolean + */ + function isSpam() { + $response = $this->http->getResponse($this->_getQueryString(), 'comment-check'); + + return ($response == "true"); + } + + + /** + * Submit this comment as an unchecked spam to the Akismet server + * + * @return void + */ + function submitSpam() { + $this->http->getResponse($this->_getQueryString(), 'submit-spam'); + } + + + /** + * Submit a false-positive comment as "ham" to the Akismet server + * + * @return void + */ + function submitHam() { + $this->http->getResponse($this->_getQueryString(), 'submit-ham'); + } + + + /** + * Manually set the comment value of the instantiated object. + * + * @param Array $comment + * @return void + */ + function setComment($comment) { + $this->comment = $comment; + if(!empty($comment)) { + $this->_formatCommentArray(); + $this->_fillCommentValues(); + } + } + + + /** + * Returns the current value of the object's comment array. + * + * @return Array + */ + function getComment() { + return $this->comment; + } + + + /** + * Check with the Akismet server to determine if the API key is valid + * + * @access Protected + * @param String $key The Wordpress API key passed from the constructor argument + * @return boolean + */ + function _isValidApiKey($key) { + $keyCheck = $this->http->getResponse("key=".$this->apiKey."&blog=".$this->blogUrl, 'verify-key'); + + return ($keyCheck == "valid"); + } + + + /** + * Format the comment array in accordance to the Akismet API + * + * @access Protected + * @return void + */ + function _formatCommentArray() { + $format = array( + 'type' => 'comment_type', + 'author' => 'comment_author', + 'email' => 'comment_author_email', + 'website' => 'comment_author_url', + 'body' => 'comment_content' + ); + + foreach($format as $short => $long) { + if(isset($this->comment[$short])) { + $this->comment[$long] = $this->comment[$short]; + unset($this->comment[$short]); + } + } + } + + + /** + * Fill any values not provided by the developer with available values. + * + * @return void + */ + function _fillCommentValues() { + if(!isset($this->comment['user_ip'])) { + $this->comment['user_ip'] = ($_SERVER['REMOTE_ADDR'] != getenv('SERVER_ADDR')) ? $_SERVER['REMOTE_ADDR'] : getenv('HTTP_X_FORWARDED_FOR'); + } + if(!isset($this->comment['user_agent'])) { + $this->comment['user_agent'] = $_SERVER['HTTP_USER_AGENT']; + } + if(!isset($this->comment['referrer'])) { + $this->comment['referrer'] = $_SERVER['HTTP_REFERER']; + } + if(!isset($this->comment['blog'])) { + $this->comment['blog'] = $this->blogUrl; + } + } + + + /** + * Build a query string for use with HTTP requests + * + * @access Protected + * @return String + */ + function _getQueryString() { + foreach($_SERVER as $key => $value) { + if(!in_array($key, $this->ignore)) { + if($key == 'REMOTE_ADDR') { + $this->comment[$key] = $this->comment['user_ip']; + } else { + $this->comment[$key] = $value; + } + } + } + + $query_string = ''; + + foreach($this->comment as $key => $data) { + $query_string .= $key . '=' . urlencode(stripslashes($data)) . '&'; + } + + return $query_string; + } + + +} +?> \ No newline at end of file diff --git a/inc/classes/third_party/api/.htaccess b/inc/classes/third_party/api/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/third_party/api/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/third_party/api/primusportal/.htaccess b/inc/classes/third_party/api/primusportal/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/third_party/api/primusportal/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/third_party/api/primusportal/class_PrimeraApi.php b/inc/classes/third_party/api/primusportal/class_PrimeraApi.php new file mode 100644 index 00000000..fba74634 --- /dev/null +++ b/inc/classes/third_party/api/primusportal/class_PrimeraApi.php @@ -0,0 +1,240 @@ +payPrimera($PayReceiver, $PayAmount, $PayDescription); + * + * Wobei $PayReicer der Username des Empfängers bei + * Primusportal.de ist. $PayAmount ist der gerundete( !! ) Betrag an Primera, + * die der Empfänger erhalten soll. $PayDescription ist eine von Ihnen + * festgelegte kurze Beschreibung. Die Länge dieses Textes darf 100 Zeichen + * nicht überschreiten. Beispiel: + * $status = $Interface->payPrimera("garbage", 10000, "Auszahlung IhreSeite.de - ID: 12345"); + * 3. Überprüfung des Status (Rückgabecode): + * CODE: + * if (!$status) { + * // Ein Fehler ist aufgetreten + * // Fehlerbehandlung hier einfügen... + * }else { + * // Auszahlung erfolgreich durchgeführt + * // Führen Sie hier Ihre Datenbankabfragen durch, um die Auszahlung zu + * // bestätigen... + * } + * + * Die komplette Rückgabe des Interfaces wird als assoziatives Array in der Klassen- + * variable __data gespeichert: + * __data => array("status" => Rückgabecode (PI_DONE, PI_SENDER_ERROR, ...), + * "statustext" => Status in Worten (z.B.: "Transaktion erfolgreich durchgeführt"), + * ") + * + * + * @author Andreas Schmidt + * @author Roland Haeder + * @version 1.0 - beta + * @copyright (c) 2007 by Primusportal.de + * @copyright (c) 2008 by Roland Haeder + */ +class PrimeraApi { + /** + * Fehler - Interfacebenutzer + */ + const PI_ERROR = -1; + + /** + * Statuscode für erfolgreich ausgeführte Transaktion + */ + const PI_DONE = 200; + + /** + * Fehler - User existiert nicht oder ist gesperrt + */ + const PI_RECEIVER_ERROR = 301; + + /** + * Sender-Account Fehler (User nicht existent, gesperrt, ...) + */ + const PI_SENDER_ERROR = 401; + + /** + * Betrag fehler + */ + const PI_AMOUNT_ERROR = 501; + + /** + * Zu wenig Primera + */ + const PI_TOO_LESS_PRIMERA = 502; + + /** + * User nicht aktiv oder existiert nicht + */ + const PI_USER_CHECK_ERROR = 601; + + /** + * User aktiv + */ + const PI_USER_CHECK_OK = 602; + + /** + * Primerastand erfolgreich geholt + */ + const PI_GET_PRIMERA_DONE = 701; + + /** + * URL für das Interface auf dem Primusserver: + */ + private $host = "www.primusportal.de"; + private $path = "/transfer.interface.2.0.php"; + + private $errno = 0; + private $err = ""; + + private $seperator = ":"; + + private $username = ""; + private $password = ""; + + private $data = array(); + + /** + * Konstruktor + */ + public function __construct ($PPUsername, $PPPassword) { + // Call parent constructor + parent::__construct(); + + // Clean up a little + $this->removeSystemArray(); + $this->removeNumberFormaters(); + + // Set data (DEPRECATED!) + $this->username = $PPUsername; + $this->password = $PPPassword; + } + + /** + * Anfrage senden und Rückgabecode in Variable speichern + */ + function queryApi ( $data = array() ) { + $fp = fsockopen($this->host, 80, $this->errno, $this->_err); + if (!$fp) return false; + + $data["PrimusInterface_Username"] = base64_encode($this->username); + $data["PrimusInterface_Password"] = base64_encode(md5($this->password)); + + // POST-Daten übermitteln: + $data = http_build_query($data, '', '&'); + + fputs($fp, "POST {$this->path}HTTP/1.1\r\n"); + fputs($fp, "Host: {$this->host}\r\n"); + fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n"); + fputs($fp, "Content-length: ". strlen($data) ."\r\n"); + fputs($fp, "Connection: close\r\n\r\n"); + fputs($fp, $data); + + $return = ""; + while (!feof($fp)) { + $return.=fgets($fp,128); + } + + $content = explode("", $return); + return $content[1]; + } + + /** + * Funktion parst die Rückgabe vom Transferskript: + */ + function parseContent ( $content ) { + $x = explode("\n", $content); + $return = array(); + foreach($x as $currentLine) { + $line_exploded = explode(":", $currentLine,2); + if (count($line_exploded) > 1) { + $return[$line_exploded[0]] = $line_exploded[1]; + } + } + return $return; + } + + /** + * @param int/string $Receiver UserID / Username des Empfängers + * @param int$Amount Betrag in ganzzahligen Primera + * @param string $Description Beschreibung (Sichtbar in Einzelauflistung) + */ + public function payPrimera ($Receiver, $Amount, $Description = "") { + $valid = false; + $PostData = array("PrimusInterface_Action" => "Pay", + "PrimusInterface_Receiver" => base64_encode($Receiver), + "PrimusInterface_Amount" => base64_encode($Amount), + "PrimusInterface_Description" => base64_encode($Description) ); + + $PostReturn = $this->parseContent( $this->queryApi($PostData) ); + + $this->data = $PostReturn; + if ($PostReturn["status"] == "200") { + $valid = true; + } + return $valid; + } + + /** + * Überprüft den Status eines Primus-Users + * - existiert der User + * - ist er aktiv + * @param string/int $User Userid / Username + */ + function CheckPrimusUser($User) { + $valid = false; + $PostData = array("PrimusInterface_Action"=> "CheckPrimusUser", + "PrimusInterface_CheckPrimusUser" => $User); + + $PostReturn = $this->parseContent( $this->queryApi($PostData) ); + + $this->data = $PostReturn; + + if ($PostReturn["status"] == self::PI_USER_CHECK_OK) { + $valid = true; + } + return $valid; + } + + /** + * Die Funktion liefer den aktuellen Primerastand + */ + function getPrimera() { + $primera = false; + $PostData = array( "PrimusInterface_Action" => "GetPrimera" ); + $PostReturn = $this->parseContent( $this->queryApi($PostData) ); + + $this->data = $PostReturn; + if ($PostReturn["status"] == self::PI_GET_PRIMERA_DONE) { + $primera = $PostReturn["primera"]; + } + return $primera; + } +} + +// [EOF] +?> \ No newline at end of file diff --git a/inc/classes/third_party/api/wernisportal/.htaccess b/inc/classes/third_party/api/wernisportal/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/third_party/api/wernisportal/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/third_party/api/wernisportal/class_WernisApi.php b/inc/classes/third_party/api/wernisportal/class_WernisApi.php new file mode 100644 index 00000000..cdda5d45 --- /dev/null +++ b/inc/classes/third_party/api/wernisportal/class_WernisApi.php @@ -0,0 +1,416 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class WernisApi extends BaseFrameworkSystem { + /** + * Static base API URL + */ + private static $apiUrl = "http://www.wds66.com/api/"; + + /** + * API Wernis amount + */ + private $wernis_amount = 0; + + /** + * API username + */ + private $w_id = 0; + + /** + * API Wernis password (not account password!) + */ + private $w_md5 = ""; + + /** + * Nickname of the user + */ + private $w_nick = ""; + + /** + * Wernis amount of the user + */ + private $w_amount = 0; + + /** + * Array with status informations + */ + private $statusArray = array(); + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Clean up a little + $this->removeNumberFormaters(); + $this->removeSystemArray(); + } + + /** + * Creates an instance of this API class + * + * @param $cfg Configuration array + * @return $apiInstance An instance of this API class + */ + public final static function createWernisApi (array $cfg) { + // Create a new instance + $apiInstance = new WernisApi(); + + // Fix missing + if (!isset($cfg['api_url'])) $cfg['api_url'] = self::$apiUrl; + + // Konfiguration uebertragen + $apiInstance->setCoonfigArray($cfg); + + // Return the instance + return $apiInstance; + } + + /** + * Setter for gamer data + * + * @param $w_id Username (id) of the gamer + * @param $w_pwd Clear password of the gamer + * @return void + */ + public function setUser ($w_id, $w_pwd) { + // Set username (id) + $this->w_id = $w_id; + + // Hash clear password and set it + $this->w_md5 = md5($w_pwd); + } + + /************************************************ + * The following methods are not yet rewritten! * + ************************************************/ + + public function einziehen ($amount) { + // amount auf Gueltigkeit pruefen + $amount = isset($amount) ? $amount+0 : 0; + + if ($amount < $this->config['mineinsatz']) { + $this->setStatusMessage('low_stakes', sprintf("Dein Einsatz muss mindestens %d Wernis betragen.", $this->config['mineinsatz'])); + return false; + } + + // Abfrage senden + return $this->executeWithdraw($amount); + } + + public function verschicken ($amount) { + // amount auf Gueltigkeit pruefen + $amount = isset($amount) ? $amount+0 : 0; + + if ($amount < $this->config['mineinsatz']) { + $this->setStatusMessage('low_stakes', sprintf("Dein Einsatz muss mindestens %d Wernis betragen.", $this->config['mineinsatz'])); + return false; + } + + // Abfrage senden + return $this->executePayout($amount); + } + + // Script abbrechen mit Zurueck-Buttom + public function ende () { + global $_CONFIG; + include "templates/zurueck.html"; + include "templates/fuss.html"; + die(); + } + + // Fehlermeldung ausgeben und beenden + public function error () { + print "
Fehler im Spiel: ".$this->getErrorMessage()."

\n"; + $this->ende(); + } + + // Sets a status message and code + public function setStatusMessage ($msg, $status) { + $this->statusArray['message'] = $msg; + $this->statusArray['status'] = $status; + } + + // Get the status message + public function getErrorMessage () { + if (isset($this->statusArray['message'])) { + // Use raw message + return $this->statusArray['message']; + } else { + // Fall-back to status + return sprintf("Fehler-Code %s ist keiner Nachricht zugewiesen.", $this->getErrorCode()); + } + } + + // Get the status code + public function getErrorCode () { + if (isset($this->statusArray['status'])) { + // Use raw message + return $this->statusArray['status']; + } else { + // Something bad happend + return 'unknown'; + } + } + + // Sends out a request to the API and returns it's result + private function sendRequest ($scriptName, array $requestData = array()) { + // Is the requestData an array? + if (!is_array($requestData)) { + // Then abort here! + return array( + 'status' => "failed_general", + 'message' => "API-Daten in config sind ungültig!" + ); + } + + // Is the API id and MD5 hash there? + if ((empty($this->config['wernis_api_id'])) || (empty($this->config['wernis_api_key']))) { + // Abort here... + return array( + 'status' => "failed_general", + 'message' => "API-Daten in config.php sind leer!" + ); + } + + // Construct the request string + $requestString = $this->config['api_url'] . $scriptName."?api_id=".$this->config['wernis_api_id']."&api_key=".$this->config['wernis_api_key']; + foreach ($requestData as $key => $value) { + $requestString .= "&".$key."=".$value; + } + + // Get the raw response from the lower function + $response = $this->sendRawRequest($requestString); + + // Check the response header if all is fine + if (strpos($response[0], "200") === false) { + // Something bad happend... :( + return array( + 'status' => "request_error", + 'message' => sprintf("Servermeldung %s von WDS66-API erhalten.", $response[0]) + ); + } + + // All (maybe) fine so remove the response header from server + $response = $response[(count($response) - 1)]; + + // Prepare the returning result for higher functions + if (substr($response, 0, 1) == "&") { + // Remove the leading & (which can be used in Flash) + $response = substr($response, 1); + } + + // Bring back the response + $data = explode("=", $response); + + // Default return array (should not stay empty) + $return = array(); + + // We use only the first two entries (which shall be fine) + if ($data[0] === "error") { + // The request has failed... :( + switch ($data[1]) { + case "404": // Invalid API ID + case "AUTH": // Authorization has failed + $return = array( + 'status' => "auth_failed", + 'message' => "API-Daten scheinen nicht zu stimmen! (Access Denied)" + ); + break; + + case "LOCKED": // User account is locked! + case "PASS": // Bad passphrase entered + case "USER": // Missing account or invalid password + $return = array( + 'status' => "user_failed", + 'message' => "Dein eingegebener WDS66-Username stimmt nicht, ist gesperrt oder du hast ein falsches Passwort eingegeben." + ); + break; + + case "OWN": // Transfer to own account + $return = array( + 'status' => "own_failed", + 'message' => "Du darfst dein eigenes Spiel leider nicht spielen." + ); + break; + + case "AMOUNT": // Amount is depleted + $return = array( + 'status' => "amount_failed", + 'message' => "Dein Guthaben reicht nicht aus, um das Spiel zu spielen." + ); + break; + + case "AMOUNT-SEND": // API amount is depleted + $return = array( + 'status' => "api_amount_failed", + 'message' => "Nicht genügend Guthaben auf dem API-Account." + ); + break; + + default: // Unknown error (maybe new?) + $return = array( + 'status' => "request_failed", + 'message' => sprintf("Unbekannter Fehler %s von API erhalten.", $data[1]) + ); + break; + } + } else { + // All fine here + $return = array( + 'status' => "OK", + 'response' => $response + ); + } + + // Return the result + return $return; + } + + // Widthdraw this amount + private function executeWithdraw ($amount) { + // First all fails... + $result = false; + + // Prepare the purpose + $purpose = "\"Bube oder Dame\"-Einsatz gesetzt."; + + // Prepare the request data + $requestData = array( + 'sub_request' => "receive", + 't_uid' => $this->w_id, + 't_md5' => $this->w_md5, + 'r_uid' => (int)$this->config['wernis_refid'], + 'amount' => (int)$amount, + 'purpose' => urlencode(base64_encode($purpose)) + ); + + // Return the result from the lower functions + $return = $this->sendRequest("book.php", $requestData); + + if ($return['status'] == "OK") { + // All fine! + $result = true; + } else { + // Status failture text + $this->setStatusMessage($return['message'], $return['status']); + } + + // Return result + return $result; + } + + // Payout this amount + private function executePayout ($amount) { + // First all fails... + $result = false; + + // Prepare the purpose + $purpose = "\"Bube oder Dame\"-Gewinn erhalten."; + + // Prepare the request data + $requestData = array( + 'sub_request' => "send", + 't_uid' => $this->w_id, + 't_md5' => $this->w_md5, + 'r_uid' => (int)$this->config['wernis_refid'], + 'amount' => (int)$amount, + 'purpose' => urlencode(base64_encode($purpose)) + ); + + // Return the result from the lower functions + $return = $this->sendRequest("book.php", $requestData); + + if ($return['status'] == "OK") { + // All fine! + $result = true; + } else { + // Status failture text + $this->setStatusMessage($return['message'], $return['status']); + } + + // Return result + return $result; + } + + // Send raw GET request + private function sendRawRequest ($script) { + // Use the hostname from script URL as new hostname + $url = substr($script, 7); + $extract = explode("/", $url); + + // Done extracting the URL :) + $url = $extract[0]; + + // Extract host name + $host = str_replace("http://", "", $url); + if (ereg("/", $host)) $host = substr($host, 0, strpos($host, "/")); + + // Generate relative URL + $script = substr($script, (strlen($url) + 7)); + if (substr($script, 0, 1) == "/") $script = substr($script, 1); + + // Open connection + $fp = @fsockopen($host, 80, $errno, $errdesc, 30); + if (!$fp) { + // Failed! + return array("", "", ""); + } + + // Generate request header + $request = "GET /".trim($script)." HTTP/1.0\r\n"; + $request .= "Host: ".$host."\r\n"; + $request .= sprintf("User-Agent: Bube oder Dame / 1.0 by Quix0r [Spieler: %d]\r\n\r\n", $this->w_id); + + // Initialize array + $response = array(); + + // Write request + fputs($fp, $request); + + // Read response + while(!feof($fp)) { + $response[] = trim(fgets($fp, 1024)); + } + + // Close socket + fclose($fp); + + // Was the request successfull? + if ((!ereg("200 OK", $response[0])) && (empty($response[0]))) { + // Not found / access forbidden + $response = array("", "", ""); + } + + // Return response + return $response; + } +} + +// [EOF] +?> diff --git a/inc/classes/third_party/php_mailer/.htaccess b/inc/classes/third_party/php_mailer/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/third_party/php_mailer/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/third_party/php_mailer/ChangeLog.txt b/inc/classes/third_party/php_mailer/ChangeLog.txt new file mode 100644 index 00000000..377ac5b3 --- /dev/null +++ b/inc/classes/third_party/php_mailer/ChangeLog.txt @@ -0,0 +1,307 @@ +/******************************************************************* +* The http://phpmailer.codeworxtech.com/ website now carries a few * +* advertisements through the Google Adsense network. Please visit * +* the advertiser sites and help us offset some of our costs. * +* Thanks .... * +********************************************************************/ + +ChangeLog + +NOTE: THIS VERSION OF PHPMAILER IS DESIGNED FOR PHP5. IT WILL NOT WORK WITH PHP4. + +Version 2.1 (Wed, June 04 2008) + +** NOTE: WE HAVE A NEW LANGUAGE VARIABLE FOR DIGITALLY SIGNED S/MIME EMAILS. + IF YOU CAN HELP WITH LANGUAGES OTHER THAN ENGLISH AND SPANISH, IT WOULD BE + APPRECIATED. + +* added S/MIME functionality (ability to digitally sign emails) + BIG THANKS TO "sergiocambra" for posting this patch back in November 2007. + The "Signed Emails" functionality adds the Sign method to pass the private key + filename and the password to read it, and then email will be sent with + content-type multipart/signed and with the digital signature attached. +* fully compatible with E_STRICT error level + - Please note: + In about half the test environments this development version was subjected + to, an error was thrown for the date() functions used (line 1565 and 1569). + This is NOT a PHPMailer error, it is the result of an incorrectly configured + PHP5 installation. The fix is to modify your 'php.ini' file and include the + date.timezone = America/New York + directive, to your own server timezone + - If you do get this error, and are unable to access your php.ini file: + In your PHP script, add + date_default_timezone_set('America/Toronto'); + - do not try to use + $myVar = date_default_timezone_get(); + as a test, it will throw an error. +* added ability to define path (mainly for embedded images) + function MsgHTML($message,$basedir='') ... where: + $basedir is the fully qualified path +* fixed MsgHTML() function: + - Embedded Images where images are specified by :// will not be altered or embedded +* fixed the return value of SMTP exit code ( pclose ) +* addressed issue of multibyte characters in subject line and truncating +* added ability to have user specified Message ID + (default is still that PHPMailer create a unique Message ID) +* corrected unidentified message type to 'application/octet-stream' +* fixed chunk_split() multibyte issue (thanks to Colin Brown, et al). +* added check for added attachments +* enhanced conversion of HTML to text in MsgHTML (thanks to "brunny") + +Version 2.1.0beta2 (Sun, Dec 02 2007) +* implemented updated EncodeQP (thanks to coolbru, aka Marcus Bointon) +* finished all testing, all known bugs corrected, enhancements tested +- note: will NOT work with PHP4. + +please note, this is BETA software +** DO NOT USE THIS IN PRODUCTION OR LIVE PROJECTS +INTENDED STRICTLY FOR TESTING + +Version 2.1.0beta1 +please note, this is BETA software +** DO NOT USE THIS IN PRODUCTION OR LIVE PROJECTS +INTENDED STRICTLY FOR TESTING + +Version 2.0.0 rc2 (Fri, Nov 16 2007), interim release +* implements new property to control VERP in class.smtp.php + example (requires instantiating class.smtp.php): + $mail->do_verp = true; +* POP-before-SMTP functionality included, thanks to Richard Davey + (see class.pop3.php & pop3_before_smtp_test.php for examples) +* included example showing how to use PHPMailer with GMAIL +* fixed the missing Cc in SendMail() and Mail() + +****************** +A note on sending bulk emails: + +If the email you are sending is not personalized, consider using the +"undisclosed-recipient:;" strategy. That is, put all of your recipients +in the Bcc field and set the To field to "undisclosed-recipients:;". +It's a lot faster (only one send) and saves quite a bit on resources. +Contrary to some opinions, this will not get you listed in spam engines - +it's a legitimate way for you to send emails. + +A partial example for use with PHPMailer: + +$mail->AddAddress("undisclosed-recipients:;"); +$mail->AddBCC("email1@anydomain.com,email2@anyotherdomain.com,email3@anyalternatedomain.com"); + +Many email service providers restrict the number of emails that can be sent +in any given time period. Often that is between 50 - 60 emails maximum +per hour or per send session. + +If that's the case, then break up your Bcc lists into chunks that are one +less than your limit, and put a pause in your script. +******************* + +Version 2.0.0 rc1 (Thu, Nov 08 2007), interim release +* dramatically simplified using inline graphics ... it's fully automated and requires no user input +* added automatic document type detection for attachments and pictures +* added MsgHTML() function to replace Body tag for HTML emails +* fixed the SendMail security issues (input validation vulnerability) +* enhanced the AddAddresses functionality so that the "Name" portion is used in the email address +* removed the need to use the AltBody method (set from the HTML, or default text used) +* set the PHP Mail() function as the default (still support SendMail, SMTP Mail) +* removed the need to set the IsHTML property (set automatically) +* added Estonian language file by Indrek Päri +* added header injection patch +* added "set" method to permit users to create their own pseudo-properties like 'X-Headers', etc. + example of use: + $mail->set('X-Priority', '3'); + $mail->set('X-MSMail-Priority', 'Normal'); +* fixed warning message in SMTP get_lines method +* added TLS/SSL SMTP support + example of use: + $mail = new PHPMailer(); + $mail->Mailer = "smtp"; + $mail->Host = "smtp.example.com"; + $mail->SMTPSecure = "tls"; // option + //$mail->SMTPSecure = "ssl"; // option + ... + $mail->Send(); +* PHPMailer has been tested with PHP4 (4.4.7) and PHP5 (5.2.7) +* Works with PHP installed as a module or as CGI-PHP +- NOTE: will NOT work with PHP5 in E_STRICT error mode + +Version 1.73 (Sun, Jun 10 2005) +* Fixed denial of service bug: http://www.cybsec.com/vuln/PHPMailer-DOS.pdf +* Now has a total of 20 translations +* Fixed alt attachments bug: http://tinyurl.com/98u9k + +Version 1.72 (Wed, May 25 2004) +* Added Dutch, Swedish, Czech, Norwegian, and Turkish translations. +* Received: Removed this method because spam filter programs like +SpamAssassin reject this header. +* Fixed error count bug. +* SetLanguage default is now "language/". +* Fixed magic_quotes_runtime bug. + +Version 1.71 (Tue, Jul 28 2003) +* Made several speed enhancements +* Added German and Italian translation files +* Fixed HELO/AUTH bugs on keep-alive connects +* Now provides an error message if language file does not load +* Fixed attachment EOL bug +* Updated some unclear documentation +* Added additional tests and improved others + +Version 1.70 (Mon, Jun 20 2003) +* Added SMTP keep-alive support +* Added IsError method for error detection +* Added error message translation support (SetLanguage) +* Refactored many methods to increase library performance +* Hello now sends the newer EHLO message before HELO as per RFC 2821 +* Removed the boundary class and replaced it with GetBoundary +* Removed queue support methods +* New $Hostname variable +* New Message-ID header +* Received header reformat +* Helo variable default changed to $Hostname +* Removed extra spaces in Content-Type definition (#667182) +* Return-Path should be set to Sender when set +* Adds Q or B encoding to headers when necessary +* quoted-encoding should now encode NULs \000 +* Fixed encoding of body/AltBody (#553370) +* Adds "To: undisclosed-recipients:;" when all recipients are hidden (BCC) +* Multiple bug fixes + +Version 1.65 (Fri, Aug 09 2002) +* Fixed non-visible attachment bug (#585097) for Outlook +* SMTP connections are now closed after each transaction +* Fixed SMTP::Expand return value +* Converted SMTP class documentation to phpDocumentor format + +Version 1.62 (Wed, Jun 26 2002) +* Fixed multi-attach bug +* Set proper word wrapping +* Reduced memory use with attachments +* Added more debugging +* Changed documentation to phpDocumentor format + +Version 1.60 (Sat, Mar 30 2002) +* Sendmail pipe and address patch (Christian Holtje) +* Added embedded image and read confirmation support (A. Ognio) +* Added unit tests +* Added SMTP timeout support (*nix only) +* Added possibly temporary PluginDir variable for SMTP class +* Added LE message line ending variable +* Refactored boundary and attachment code +* Eliminated SMTP class warnings +* Added SendToQueue method for future queuing support + +Version 1.54 (Wed, Dec 19 2001) +* Add some queuing support code +* Fixed a pesky multi/alt bug +* Messages are no longer forced to have "To" addresses + +Version 1.50 (Thu, Nov 08 2001) +* Fix extra lines when not using SMTP mailer +* Set WordWrap variable to int with a zero default + +Version 1.47 (Tue, Oct 16 2001) +* Fixed Received header code format +* Fixed AltBody order error +* Fixed alternate port warning + +Version 1.45 (Tue, Sep 25 2001) +* Added enhanced SMTP debug support +* Added support for multiple ports on SMTP +* Added Received header for tracing +* Fixed AddStringAttachment encoding +* Fixed possible header name quote bug +* Fixed wordwrap() trim bug +* Couple other small bug fixes + +Version 1.41 (Wed, Aug 22 2001) +* Fixed AltBody bug w/o attachments +* Fixed rfc_date() for certain mail servers + +Version 1.40 (Sun, Aug 12 2001) +* Added multipart/alternative support (AltBody) +* Documentation update +* Fixed bug in Mercury MTA + +Version 1.29 (Fri, Aug 03 2001) +* Added AddStringAttachment() method +* Added SMTP authentication support + +Version 1.28 (Mon, Jul 30 2001) +* Fixed a typo in SMTP class +* Fixed header issue with Imail (win32) SMTP server +* Made fopen() calls for attachments use "rb" to fix win32 error + +Version 1.25 (Mon, Jul 02 2001) +* Added RFC 822 date fix (Patrice) +* Added improved error handling by adding a $ErrorInfo variable +* Removed MailerDebug variable (obsolete with new error handler) + +Version 1.20 (Mon, Jun 25 2001) +* Added quoted-printable encoding (Patrice) +* Set Version as public and removed PrintVersion() +* Changed phpdoc to only display public variables and methods + +Version 1.19 (Thu, Jun 21 2001) +* Fixed MS Mail header bug +* Added fix for Bcc problem with mail(). *Does not work on Win32* + (See PHP bug report: http://www.php.net/bugs.php?id=11616) +* mail() no longer passes a fifth parameter when not needed + +Version 1.15 (Fri, Jun 15 2001) +[Note: these changes contributed by Patrice Fournier] +* Changed all remaining \n to \r\n +* Bcc: header no longer writen to message except +when sent directly to sendmail +* Added a small message to non-MIME compliant mail reader +* Added Sender variable to change the Sender email +used in -f for sendmail/mail and in 'MAIL FROM' for smtp mode +* Changed boundary setting to a place it will be set only once +* Removed transfer encoding for whole message when using multipart +* Message body now uses Encoding in multipart messages +* Can set encoding and type to attachments 7bit, 8bit +and binary attachment are sent as is, base64 are encoded +* Can set Encoding to base64 to send 8 bits body +through 7 bits servers + +Version 1.10 (Tue, Jun 12 2001) +* Fixed win32 mail header bug (printed out headers in message body) + +Version 1.09 (Fri, Jun 08 2001) +* Changed date header to work with Netscape mail programs +* Altered phpdoc documentation + +Version 1.08 (Tue, Jun 05 2001) +* Added enhanced error-checking +* Added phpdoc documentation to source + +Version 1.06 (Fri, Jun 01 2001) +* Added optional name for file attachments + +Version 1.05 (Tue, May 29 2001) +* Code cleanup +* Eliminated sendmail header warning message +* Fixed possible SMTP error + +Version 1.03 (Thu, May 24 2001) +* Fixed problem where qmail sends out duplicate messages + +Version 1.02 (Wed, May 23 2001) +* Added multiple recipient and attachment Clear* methods +* Added Sendmail public variable +* Fixed problem with loading SMTP library multiple times + +Version 0.98 (Tue, May 22 2001) +* Fixed problem with redundant mail hosts sending out multiple messages +* Added additional error handler code +* Added AddCustomHeader() function +* Added support for Microsoft mail client headers (affects priority) +* Fixed small bug with Mailer variable +* Added PrintVersion() function + +Version 0.92 (Tue, May 15 2001) +* Changed file names to class.phpmailer.php and class.smtp.php to match + current PHP class trend. +* Fixed problem where body not being printed when a message is attached +* Several small bug fixes + +Version 0.90 (Tue, April 17 2001) +* Intial public release diff --git a/inc/classes/third_party/php_mailer/LICENSE b/inc/classes/third_party/php_mailer/LICENSE new file mode 100644 index 00000000..03851a33 --- /dev/null +++ b/inc/classes/third_party/php_mailer/LICENSE @@ -0,0 +1,504 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! + + diff --git a/inc/classes/third_party/php_mailer/README b/inc/classes/third_party/php_mailer/README new file mode 100644 index 00000000..3670fb62 --- /dev/null +++ b/inc/classes/third_party/php_mailer/README @@ -0,0 +1,178 @@ +/******************************************************************* +* The http://phpmailer.codeworxtech.com/ website now carries a few * +* advertisements through the Google Adsense network. Please visit * +* the advertiser sites and help us offset some of our costs. * +* Thanks .... * +********************************************************************/ + +PHPMailer +Full Featured Email Transfer Class for PHP +========================================== + +Version 2.1 (June 04 2008) + +With this release, we are announcing that the development of PHPMailer for PHP5 +will be our focus from this date on. We have implemented all the enhancements +and fixes from the latest release of PHPMailer for PHP4. + +Far more important, though, is that this release of PHPMailer (v2.1) is +fully tested with E_STRICT error checking enabled. + +** NOTE: WE HAVE A NEW LANGUAGE VARIABLE FOR DIGITALLY SIGNED S/MIME EMAILS. + IF YOU CAN HELP WITH LANGUAGES OTHER THAN ENGLISH AND SPANISH, IT WOULD BE + APPRECIATED. + +We have now added S/MIME functionality (ability to digitally sign emails). +BIG THANKS TO "sergiocambra" for posting this patch back in November 2007. +The "Signed Emails" functionality adds the Sign method to pass the private key +filename and the password to read it, and then email will be sent with +content-type multipart/signed and with the digital signature attached. + +A quick note on E_STRICT: + +- In about half the test environments the development version was subjected + to, an error was thrown for the date() functions (used at line 1565 and 1569). + This is NOT a PHPMailer error, it is the result of an incorrectly configured + PHP5 installation. The fix is to modify your 'php.ini' file and include the + date.timezone = America/New York + directive, (for your own server timezone) +- If you do get this error, and are unable to access your php.ini file, there is + a workaround. In your PHP script, add + date_default_timezone_set('America/Toronto'); + + * do NOT try to use + $myVar = date_default_timezone_get(); + as a test, it will throw an error. + +We have also included more example files to show the use of "sendmail", "mail()", +"smtp", and "gmail". + +We are also looking for more programmers to join the volunteer development team. +If you have an interest in this, please let us know. + +Enjoy! + + +Version 2.1.0beta1 & beta2 + +please note, this is BETA software +** DO NOT USE THIS IN PRODUCTION OR LIVE PROJECTS +INTENDED STRICTLY FOR TESTING + +** NOTE: + +As of November 2007, PHPMailer has a new project team headed by industry +veteran Andy Prevost (codeworxtech). The first release in more than two +years will focus on fixes, adding ease-of-use enhancements, provide +basic compatibility with PHP4 and PHP5 using PHP5 backwards compatibility +features. A new release is planned before year-end 2007 that will provide +full compatiblity with PHP4 and PHP5, as well as more bug fixes. + +We are looking for project developers to assist in restoring PHPMailer to +its leadership position. Our goals are to simplify use of PHPMailer, provide +good documentation and examples, and retain backward compatibility to level +1.7.3 standards. + +If you are interested in helping out, visit http://sourceforge.net/phpmailer +and indicate your interest. + +** + +http://phpmailer.sourceforge.net/ + +This software is licenced under the LGPL. Please read LICENSE for information on the +software availability and distribution. + +Class Features: +- Send emails with multiple TOs, CCs, BCCs and REPLY-TOs +- Redundant SMTP servers +- Multipart/alternative emails for mail clients that do not read HTML email +- Support for 8bit, base64, binary, and quoted-printable encoding +- Uses the same methods as the very popular AspEmail active server (COM) component +- SMTP authentication +- Native language support +- Word wrap, and more! + +Why you might need it: + +Many PHP developers utilize email in their code. The only PHP function +that supports this is the mail() function. However, it does not expose +any of the popular features that many email clients use nowadays like +HTML-based emails and attachments. There are two proprietary +development tools out there that have all the functionality built into +easy to use classes: AspEmail(tm) and AspMail. Both of these +programs are COM components only available on Windows. They are also a +little pricey for smaller projects. + +Since I do Linux development I’ve missed these tools for my PHP coding. +So I built a version myself that implements the same methods (object +calls) that the Windows-based components do. It is open source and the +LGPL license allows you to place the class in your proprietary PHP +projects. + + +Installation: + +Copy class.phpmailer.php into your php.ini include_path. If you are +using the SMTP mailer then place class.smtp.php in your path as well. +In the language directory you will find several files like +phpmailer.lang-en.php. If you look right before the .php extension +that there are two letters. These represent the language type of the +translation file. For instance "en" is the English file and "br" is +the Portuguese file. Chose the file that best fits with your language +and place it in the PHP include path. If your language is English +then you have nothing more to do. If it is a different language then +you must point PHPMailer to the correct translation. To do this, call +the PHPMailer SetLanguage method like so: + +// To load the Portuguese version +$mail->SetLanguage("br", "/optional/path/to/language/directory/"); + +That's it. You should now be ready to use PHPMailer! + + +A Simple Example: + +IsSMTP(); // set mailer to use SMTP +$mail->Host = "smtp1.example.com;smtp2.example.com"; // specify main and backup server +$mail->SMTPAuth = true; // turn on SMTP authentication +$mail->Username = "jswan"; // SMTP username +$mail->Password = "secret"; // SMTP password + +$mail->From = "from@example.com"; +$mail->FromName = "Mailer"; +$mail->AddAddress("josh@example.net", "Josh Adams"); +$mail->AddAddress("ellen@example.com"); // name is optional +$mail->AddReplyTo("info@example.com", "Information"); + +$mail->WordWrap = 50; // set word wrap to 50 characters +$mail->AddAttachment("/var/tmp/file.tar.gz"); // add attachments +$mail->AddAttachment("/tmp/image.jpg", "new.jpg"); // optional name +$mail->IsHTML(true); // set email format to HTML + +$mail->Subject = "Here is the subject"; +$mail->Body = "This is the HTML message body in bold!"; +$mail->AltBody = "This is the body in plain text for non-HTML mail clients"; + +if(!$mail->Send()) +{ + echo "Message could not be sent.

"; + echo "Mailer Error: " . $mail->ErrorInfo; + exit; +} + +echo "Message has been sent"; +?> + +CHANGELOG + +See ChangeLog.txt + +Download: http://sourceforge.net/project/showfiles.php?group_id=26031 + +Andy Prevost diff --git a/inc/classes/third_party/php_mailer/class.phpmailer.php b/inc/classes/third_party/php_mailer/class.phpmailer.php new file mode 100644 index 00000000..856faafd --- /dev/null +++ b/inc/classes/third_party/php_mailer/class.phpmailer.php @@ -0,0 +1,1886 @@ +ContentType = 'text/html'; + } else { + $this->ContentType = 'text/plain'; + } + } + + /** + * Sets Mailer to send message using SMTP. + * @return void + */ + public function IsSMTP() { + $this->Mailer = 'smtp'; + } + + /** + * Sets Mailer to send message using PHP mail() function. + * @return void + */ + public function IsMail() { + $this->Mailer = 'mail'; + } + + /** + * Sets Mailer to send message using the $Sendmail program. + * @return void + */ + public function IsSendmail() { + $this->Mailer = 'sendmail'; + } + + /** + * Sets Mailer to send message using the qmail MTA. + * @return void + */ + public function IsQmail() { + $this->Sendmail = '/var/qmail/bin/sendmail'; + $this->Mailer = 'sendmail'; + } + + ///////////////////////////////////////////////// + // METHODS, RECIPIENTS + ///////////////////////////////////////////////// + + /** + * Adds a "To" address. + * @param string $address + * @param string $name + * @return void + */ + public function AddAddress($address, $name = '') { + $cur = count($this->to); + $this->to[$cur][0] = trim($address); + $this->to[$cur][1] = $name; + } + + /** + * Adds a "Cc" address. Note: this function works + * with the SMTP mailer on win32, not with the "mail" + * mailer. + * @param string $address + * @param string $name + * @return void + */ + public function AddCC($address, $name = '') { + $cur = count($this->cc); + $this->cc[$cur][0] = trim($address); + $this->cc[$cur][1] = $name; + } + + /** + * Adds a "Bcc" address. Note: this function works + * with the SMTP mailer on win32, not with the "mail" + * mailer. + * @param string $address + * @param string $name + * @return void + */ + public function AddBCC($address, $name = '') { + $cur = count($this->bcc); + $this->bcc[$cur][0] = trim($address); + $this->bcc[$cur][1] = $name; + } + + /** + * Adds a "Reply-to" address. + * @param string $address + * @param string $name + * @return void + */ + public function AddReplyTo($address, $name = '') { + $cur = count($this->ReplyTo); + $this->ReplyTo[$cur][0] = trim($address); + $this->ReplyTo[$cur][1] = $name; + } + + ///////////////////////////////////////////////// + // METHODS, MAIL SENDING + ///////////////////////////////////////////////// + + /** + * Creates message and assigns Mailer. If the message is + * not sent successfully then it returns false. Use the ErrorInfo + * variable to view description of the error. + * @return bool + */ + public function Send() { + $header = ''; + $body = ''; + $result = true; + + if((count($this->to) + count($this->cc) + count($this->bcc)) < 1) { + $this->SetError($this->Lang('provide_address')); + return false; + } + + /* Set whether the message is multipart/alternative */ + if(!empty($this->AltBody)) { + $this->ContentType = 'multipart/alternative'; + } + + $this->error_count = 0; // reset errors + $this->SetMessageType(); + $header .= $this->CreateHeader(); + $body = $this->CreateBody(); + + if($body == '') { + return false; + } + + /* Choose the mailer */ + switch($this->Mailer) { + case 'sendmail': + $result = $this->SendmailSend($header, $body); + break; + case 'smtp': + $result = $this->SmtpSend($header, $body); + break; + case 'mail': + $result = $this->MailSend($header, $body); + break; + default: + $result = $this->MailSend($header, $body); + break; + //$this->SetError($this->Mailer . $this->Lang('mailer_not_supported')); + //$result = false; + //break; + } + + return $result; + } + + /** + * Sends mail using the $Sendmail program. + * @access public + * @return bool + */ + public function SendmailSend($header, $body) { + if ($this->Sender != '') { + $sendmail = sprintf("%s -oi -f %s -t", escapeshellcmd($this->Sendmail), escapeshellarg($this->Sender)); + } else { + $sendmail = sprintf("%s -oi -t", escapeshellcmd($this->Sendmail)); + } + + if(!@$mail = popen($sendmail, 'w')) { + $this->SetError($this->Lang('execute') . $this->Sendmail); + return false; + } + + fputs($mail, $header); + fputs($mail, $body); + + $result = pclose($mail); + if (version_compare(phpversion(), '4.2.3') == -1) { + $result = $result >> 8 & 0xFF; + } + if($result != 0) { + $this->SetError($this->Lang('execute') . $this->Sendmail); + return false; + } + + return true; + } + + /** + * Sends mail using the PHP mail() function. + * @access public + * @return bool + */ + public function MailSend($header, $body) { + + $to = ''; + for($i = 0; $i < count($this->to); $i++) { + if($i != 0) { $to .= ', '; } + $to .= $this->AddrFormat($this->to[$i]); + } + + $toArr = split(',', $to); + + $params = sprintf("-oi -f %s", $this->Sender); + if ($this->Sender != '' && strlen(ini_get('safe_mode'))< 1) { + $old_from = ini_get('sendmail_from'); + ini_set('sendmail_from', $this->Sender); + if ($this->SingleTo === true && count($toArr) > 1) { + foreach ($toArr as $key => $val) { + $rt = @mail($val, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params); + } + } else { + $rt = @mail($to, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params); + } + } else { + if ($this->SingleTo === true && count($toArr) > 1) { + foreach ($toArr as $key => $val) { + $rt = @mail($val, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params); + } + } else { + $rt = @mail($to, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header); + } + } + + if (isset($old_from)) { + ini_set('sendmail_from', $old_from); + } + + if(!$rt) { + $this->SetError($this->Lang('instantiate')); + return false; + } + + return true; + } + + /** + * Sends mail via SMTP using PhpSMTP (Author: + * Chris Ryan). Returns bool. Returns false if there is a + * bad MAIL FROM, RCPT, or DATA input. + * @access public + * @return bool + */ + public function SmtpSend($header, $body) { + include_once($this->PluginDir . 'class.smtp.php'); + $error = ''; + $bad_rcpt = array(); + + if(!$this->SmtpConnect()) { + return false; + } + + $smtp_from = ($this->Sender == '') ? $this->From : $this->Sender; + if(!$this->smtp->Mail($smtp_from)) { + $error = $this->Lang('from_failed') . $smtp_from; + $this->SetError($error); + $this->smtp->Reset(); + return false; + } + + /* Attempt to send attach all recipients */ + for($i = 0; $i < count($this->to); $i++) { + if(!$this->smtp->Recipient($this->to[$i][0])) { + $bad_rcpt[] = $this->to[$i][0]; + } + } + for($i = 0; $i < count($this->cc); $i++) { + if(!$this->smtp->Recipient($this->cc[$i][0])) { + $bad_rcpt[] = $this->cc[$i][0]; + } + } + for($i = 0; $i < count($this->bcc); $i++) { + if(!$this->smtp->Recipient($this->bcc[$i][0])) { + $bad_rcpt[] = $this->bcc[$i][0]; + } + } + + if(count($bad_rcpt) > 0) { // Create error message + for($i = 0; $i < count($bad_rcpt); $i++) { + if($i != 0) { + $error .= ', '; + } + $error .= $bad_rcpt[$i]; + } + $error = $this->Lang('recipients_failed') . $error; + $this->SetError($error); + $this->smtp->Reset(); + return false; + } + + if(!$this->smtp->Data($header . $body)) { + $this->SetError($this->Lang('data_not_accepted')); + $this->smtp->Reset(); + return false; + } + if($this->SMTPKeepAlive == true) { + $this->smtp->Reset(); + } else { + $this->SmtpClose(); + } + + return true; + } + + /** + * Initiates a connection to an SMTP server. Returns false if the + * operation failed. + * @access public + * @return bool + */ + public function SmtpConnect() { + if($this->smtp == NULL) { + $this->smtp = new SMTP(); + } + + $this->smtp->do_debug = $this->SMTPDebug; + $hosts = explode(';', $this->Host); + $index = 0; + $connection = ($this->smtp->Connected()); + + /* Retry while there is no connection */ + while($index < count($hosts) && $connection == false) { + $hostinfo = array(); + if(eregi('^(.+):([0-9]+)$', $hosts[$index], $hostinfo)) { + $host = $hostinfo[1]; + $port = $hostinfo[2]; + } else { + $host = $hosts[$index]; + $port = $this->Port; + } + + $tls = ($this->SMTPSecure == 'tls'); + $ssl = ($this->SMTPSecure == 'ssl'); + + if($this->smtp->Connect(($ssl ? 'ssl://':'').$host, $port, $this->Timeout)) { + + $hello = ($this->Helo != '' ? $this->Hello : $this->ServerHostname()); + $this->smtp->Hello($hello); + + if($tls) { + if(!$this->smtp->StartTLS()) { + $this->SetError($this->Lang("tls")); + $this->smtp->Reset(); + $connection = false; + } + + //We must resend HELLO after tls negociation + $this->smtp->Hello($hello); + } + + $connection = true; + if($this->SMTPAuth) { + if(!$this->smtp->Authenticate($this->Username, $this->Password)) { + $this->SetError($this->Lang('authenticate')); + $this->smtp->Reset(); + $connection = false; + } + } + } + $index++; + } + if(!$connection) { + $this->SetError($this->Lang('connect_host')); + } + + return $connection; + } + + /** + * Closes the active SMTP session if one exists. + * @return void + */ + public function SmtpClose() { + if($this->smtp != NULL) { + if($this->smtp->Connected()) { + $this->smtp->Quit(); + $this->smtp->Close(); + } + } + } + + /** + * Sets the language for all class error messages. Returns false + * if it cannot load the language file. The default language type + * is English. + * @param string $lang_type Type of language (e.g. Portuguese: "br") + * @param string $lang_path Path to the language file directory + * @access public + * @return bool + */ + function SetLanguage($lang_type = 'en', $lang_path = 'language/') { + if( !(@include $lang_path.'phpmailer.lang-'.$lang_type.'.php') ) { + $this->SetError('Could not load language file'); + return false; + } + $this->language = $PHPMAILER_LANG; + return true; + } + + ///////////////////////////////////////////////// + // METHODS, MESSAGE CREATION + ///////////////////////////////////////////////// + + /** + * Creates recipient headers. + * @access public + * @return string + */ + public function AddrAppend($type, $addr) { + $addr_str = $type . ': '; + $addr_str .= $this->AddrFormat($addr[0]); + if(count($addr) > 1) { + for($i = 1; $i < count($addr); $i++) { + $addr_str .= ', ' . $this->AddrFormat($addr[$i]); + } + } + $addr_str .= $this->LE; + + return $addr_str; + } + + /** + * Formats an address correctly. + * @access public + * @return string + */ + public function AddrFormat($addr) { + if(empty($addr[1])) { + $formatted = $this->SecureHeader($addr[0]); + } else { + $formatted = $this->EncodeHeader($this->SecureHeader($addr[1]), 'phrase') . " <" . $this->SecureHeader($addr[0]) . ">"; + } + + return $formatted; + } + + /** + * Wraps message for use with mailers that do not + * automatically perform wrapping and for quoted-printable. + * Original written by philippe. + * @access public + * @return string + */ + public function WrapText($message, $length, $qp_mode = false) { + $soft_break = ($qp_mode) ? sprintf(" =%s", $this->LE) : $this->LE; + // If utf-8 encoding is used, we will need to make sure we don't + // split multibyte characters when we wrap + $is_utf8 = (strtolower($this->CharSet) == "utf-8"); + + $message = $this->FixEOL($message); + if (substr($message, -1) == $this->LE) { + $message = substr($message, 0, -1); + } + + $line = explode($this->LE, $message); + $message = ''; + for ($i=0 ;$i < count($line); $i++) { + $line_part = explode(' ', $line[$i]); + $buf = ''; + for ($e = 0; $e $length)) { + $space_left = $length - strlen($buf) - 1; + if ($e != 0) { + if ($space_left > 20) { + $len = $space_left; + if ($is_utf8) { + $len = $this->UTF8CharBoundary($word, $len); + } elseif (substr($word, $len - 1, 1) == "=") { + $len--; + } elseif (substr($word, $len - 2, 1) == "=") { + $len -= 2; + } + $part = substr($word, 0, $len); + $word = substr($word, $len); + $buf .= ' ' . $part; + $message .= $buf . sprintf("=%s", $this->LE); + } else { + $message .= $buf . $soft_break; + } + $buf = ''; + } + while (strlen($word) > 0) { + $len = $length; + if ($is_utf8) { + $len = $this->UTF8CharBoundary($word, $len); + } elseif (substr($word, $len - 1, 1) == "=") { + $len--; + } elseif (substr($word, $len - 2, 1) == "=") { + $len -= 2; + } + $part = substr($word, 0, $len); + $word = substr($word, $len); + + if (strlen($word) > 0) { + $message .= $part . sprintf("=%s", $this->LE); + } else { + $buf = $part; + } + } + } else { + $buf_o = $buf; + $buf .= ($e == 0) ? $word : (' ' . $word); + + if (strlen($buf) > $length and $buf_o != '') { + $message .= $buf_o . $soft_break; + $buf = $word; + } + } + } + $message .= $buf . $this->LE; + } + + return $message; + } + + /** + * Finds last character boundary prior to maxLength in a utf-8 + * quoted (printable) encoded string. + * Original written by Colin Brown. + * @access public + * @param string $encodedText utf-8 QP text + * @param int $maxLength find last character boundary prior to this length + * @return int + */ + public function UTF8CharBoundary($encodedText, $maxLength) { + $foundSplitPos = false; + $lookBack = 3; + while (!$foundSplitPos) { + $lastChunk = substr($encodedText, $maxLength - $lookBack, $lookBack); + $encodedCharPos = strpos($lastChunk, "="); + if ($encodedCharPos !== false) { + // Found start of encoded character byte within $lookBack block. + // Check the encoded byte value (the 2 chars after the '=') + $hex = substr($encodedText, $maxLength - $lookBack + $encodedCharPos + 1, 2); + $dec = hexdec($hex); + if ($dec < 128) { // Single byte character. + // If the encoded char was found at pos 0, it will fit + // otherwise reduce maxLength to start of the encoded char + $maxLength = ($encodedCharPos == 0) ? $maxLength : + $maxLength - ($lookBack - $encodedCharPos); + $foundSplitPos = true; + } elseif ($dec >= 192) { // First byte of a multi byte character + // Reduce maxLength to split at start of character + $maxLength = $maxLength - ($lookBack - $encodedCharPos); + $foundSplitPos = true; + } elseif ($dec < 192) { // Middle byte of a multi byte character, look further back + $lookBack += 3; + } + } else { + // No encoded character found + $foundSplitPos = true; + } + } + return $maxLength; + } + + + /** + * Set the body wrapping. + * @access public + * @return void + */ + public function SetWordWrap() { + if($this->WordWrap < 1) { + return; + } + + switch($this->message_type) { + case 'alt': + /* fall through */ + case 'alt_attachments': + $this->AltBody = $this->WrapText($this->AltBody, $this->WordWrap); + break; + default: + $this->Body = $this->WrapText($this->Body, $this->WordWrap); + break; + } + } + + /** + * Assembles message header. + * @access public + * @return string + */ + public function CreateHeader() { + $result = ''; + + /* Set the boundaries */ + $uniq_id = md5(uniqid(time())); + $this->boundary[1] = 'b1_' . $uniq_id; + $this->boundary[2] = 'b2_' . $uniq_id; + + $result .= $this->HeaderLine('Date', $this->RFCDate()); + if($this->Sender == '') { + $result .= $this->HeaderLine('Return-Path', trim($this->From)); + } else { + $result .= $this->HeaderLine('Return-Path', trim($this->Sender)); + } + + /* To be created automatically by mail() */ + if($this->Mailer != 'mail') { + if(count($this->to) > 0) { + $result .= $this->AddrAppend('To', $this->to); + } elseif (count($this->cc) == 0) { + $result .= $this->HeaderLine('To', 'undisclosed-recipients:;'); + } + if(count($this->cc) > 0) { + $result .= $this->AddrAppend('Cc', $this->cc); + } + } + + $from = array(); + $from[0][0] = trim($this->From); + $from[0][1] = $this->FromName; + $result .= $this->AddrAppend('From', $from); + + /* sendmail and mail() extract Cc from the header before sending */ + if((($this->Mailer == 'sendmail') || ($this->Mailer == 'mail')) && (count($this->cc) > 0)) { + $result .= $this->AddrAppend('Cc', $this->cc); + } + + /* sendmail and mail() extract Bcc from the header before sending */ + if((($this->Mailer == 'sendmail') || ($this->Mailer == 'mail')) && (count($this->bcc) > 0)) { + $result .= $this->AddrAppend('Bcc', $this->bcc); + } + + if(count($this->ReplyTo) > 0) { + $result .= $this->AddrAppend('Reply-to', $this->ReplyTo); + } + + /* mail() sets the subject itself */ + if($this->Mailer != 'mail') { + $result .= $this->HeaderLine('Subject', $this->EncodeHeader($this->SecureHeader($this->Subject))); + } + + if($this->MessageID != '') { + $result .= $this->HeaderLine('Message-ID',$this->MessageID); + } else { + $result .= sprintf("Message-ID: <%s@%s>%s", $uniq_id, $this->ServerHostname(), $this->LE); + } + $result .= $this->HeaderLine('X-Priority', $this->Priority); + $result .= $this->HeaderLine('X-Mailer', 'PHPMailer (phpmailer.codeworxtech.com) [version ' . $this->Version . ']'); + + if($this->ConfirmReadingTo != '') { + $result .= $this->HeaderLine('Disposition-Notification-To', '<' . trim($this->ConfirmReadingTo) . '>'); + } + + // Add custom headers + for($index = 0; $index < count($this->CustomHeader); $index++) { + $result .= $this->HeaderLine(trim($this->CustomHeader[$index][0]), $this->EncodeHeader(trim($this->CustomHeader[$index][1]))); + } + //$result .= $this->HeaderLine('MIME-Version', '1.0'); + if (!$this->sign_key_file) { + $result .= $this->HeaderLine('MIME-Version', '1.0'); + $result .= $this->GetMailMIME(); + } + + return $result; + } + + /** + * Returns the message MIME. + * @access public + * @return string + */ + public function GetMailMIME() { + $result = ''; + switch($this->message_type) { + case 'plain': + $result .= $this->HeaderLine('Content-Transfer-Encoding', $this->Encoding); + $result .= sprintf("Content-Type: %s; charset=\"%s\"", $this->ContentType, $this->CharSet); + break; + case 'attachments': + /* fall through */ + case 'alt_attachments': + if($this->InlineImageExists()){ + $result .= sprintf("Content-Type: %s;%s\ttype=\"text/html\";%s\tboundary=\"%s\"%s", 'multipart/related', $this->LE, $this->LE, $this->boundary[1], $this->LE); + } else { + $result .= $this->HeaderLine('Content-Type', 'multipart/mixed;'); + $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"'); + } + break; + case 'alt': + $result .= $this->HeaderLine('Content-Type', 'multipart/alternative;'); + $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"'); + break; + } + + if($this->Mailer != 'mail') { + $result .= $this->LE.$this->LE; + } + + return $result; + } + + /** + * Assembles the message body. Returns an empty string on failure. + * @access public + * @return string + */ + public function CreateBody() { + $result = ''; + + if ($this->sign_key_file) { + $result .= $this->GetMailMIME(); + } + + $this->SetWordWrap(); + + switch($this->message_type) { + case 'alt': + $result .= $this->GetBoundary($this->boundary[1], '', 'text/plain', ''); + $result .= $this->EncodeString($this->AltBody, $this->Encoding); + $result .= $this->LE.$this->LE; + $result .= $this->GetBoundary($this->boundary[1], '', 'text/html', ''); + $result .= $this->EncodeString($this->Body, $this->Encoding); + $result .= $this->LE.$this->LE; + $result .= $this->EndBoundary($this->boundary[1]); + break; + case 'plain': + $result .= $this->EncodeString($this->Body, $this->Encoding); + break; + case 'attachments': + $result .= $this->GetBoundary($this->boundary[1], '', '', ''); + $result .= $this->EncodeString($this->Body, $this->Encoding); + $result .= $this->LE; + $result .= $this->AttachAll(); + break; + case 'alt_attachments': + $result .= sprintf("--%s%s", $this->boundary[1], $this->LE); + $result .= sprintf("Content-Type: %s;%s" . "\tboundary=\"%s\"%s", 'multipart/alternative', $this->LE, $this->boundary[2], $this->LE.$this->LE); + $result .= $this->GetBoundary($this->boundary[2], '', 'text/plain', '') . $this->LE; // Create text body + $result .= $this->EncodeString($this->AltBody, $this->Encoding); + $result .= $this->LE.$this->LE; + $result .= $this->GetBoundary($this->boundary[2], '', 'text/html', '') . $this->LE; // Create the HTML body + $result .= $this->EncodeString($this->Body, $this->Encoding); + $result .= $this->LE.$this->LE; + $result .= $this->EndBoundary($this->boundary[2]); + $result .= $this->AttachAll(); + break; + } + + if($this->IsError()) { + $result = ''; + } else if ($this->sign_key_file) { + $file = tempnam("", "mail"); + $fp = fopen($file, "w"); + fwrite($fp, $result); + fclose($fp); + $signed = tempnam("", "signed"); + + if (@openssl_pkcs7_sign($file, $signed, "file://".$this->sign_key_file, array("file://".$this->sign_key_file, $this->sign_key_pass), null)) { + $fp = fopen($signed, "r"); + $result = fread($fp, filesize($this->sign_key_file)); + fclose($fp); + } else { + $this->SetError($this->Lang("signing").openssl_error_string()); + $result = ''; + } + + unlink($file); + unlink($signed); + } + + return $result; + } + + /** + * Returns the start of a message boundary. + * @access public + */ + public function GetBoundary($boundary, $charSet, $contentType, $encoding) { + $result = ''; + if($charSet == '') { + $charSet = $this->CharSet; + } + if($contentType == '') { + $contentType = $this->ContentType; + } + if($encoding == '') { + $encoding = $this->Encoding; + } + $result .= $this->TextLine('--' . $boundary); + $result .= sprintf("Content-Type: %s; charset = \"%s\"", $contentType, $charSet); + $result .= $this->LE; + $result .= $this->HeaderLine('Content-Transfer-Encoding', $encoding); + $result .= $this->LE; + + return $result; + } + + /** + * Returns the end of a message boundary. + * @access public + */ + public function EndBoundary($boundary) { + return $this->LE . '--' . $boundary . '--' . $this->LE; + } + + /** + * Sets the message type. + * @access public + * @return void + */ + public function SetMessageType() { + if(count($this->attachment) < 1 && strlen($this->AltBody) < 1) { + $this->message_type = 'plain'; + } else { + if(count($this->attachment) > 0) { + $this->message_type = 'attachments'; + } + if(strlen($this->AltBody) > 0 && count($this->attachment) < 1) { + $this->message_type = 'alt'; + } + if(strlen($this->AltBody) > 0 && count($this->attachment) > 0) { + $this->message_type = 'alt_attachments'; + } + } + } + + /* Returns a formatted header line. + * @access public + * @return string + */ + public function HeaderLine($name, $value) { + return $name . ': ' . $value . $this->LE; + } + + /** + * Returns a formatted mail line. + * @access public + * @return string + */ + public function TextLine($value) { + return $value . $this->LE; + } + + ///////////////////////////////////////////////// + // CLASS METHODS, ATTACHMENTS + ///////////////////////////////////////////////// + + /** + * Adds an attachment from a path on the filesystem. + * Returns false if the file could not be found + * or accessed. + * @param string $path Path to the attachment. + * @param string $name Overrides the attachment name. + * @param string $encoding File encoding (see $Encoding). + * @param string $type File extension (MIME) type. + * @return bool + */ + public function AddAttachment($path, $name = '', $encoding = 'base64', $type = 'application/octet-stream') { + if(!@is_file($path)) { + $this->SetError($this->Lang('file_access') . $path); + return false; + } + + $filename = basename($path); + if($name == '') { + $name = $filename; + } + + $cur = count($this->attachment); + $this->attachment[$cur][0] = $path; + $this->attachment[$cur][1] = $filename; + $this->attachment[$cur][2] = $name; + $this->attachment[$cur][3] = $encoding; + $this->attachment[$cur][4] = $type; + $this->attachment[$cur][5] = false; // isStringAttachment + $this->attachment[$cur][6] = 'attachment'; + $this->attachment[$cur][7] = 0; + + return true; + } + + /** + * Attaches all fs, string, and binary attachments to the message. + * Returns an empty string on failure. + * @access public + * @return string + */ + public function AttachAll() { + /* Return text of body */ + $mime = array(); + + /* Add all attachments */ + for($i = 0; $i < count($this->attachment); $i++) { + /* Check for string attachment */ + $bString = $this->attachment[$i][5]; + if ($bString) { + $string = $this->attachment[$i][0]; + } else { + $path = $this->attachment[$i][0]; + } + + $filename = $this->attachment[$i][1]; + $name = $this->attachment[$i][2]; + $encoding = $this->attachment[$i][3]; + $type = $this->attachment[$i][4]; + $disposition = $this->attachment[$i][6]; + $cid = $this->attachment[$i][7]; + + $mime[] = sprintf("--%s%s", $this->boundary[1], $this->LE); + $mime[] = sprintf("Content-Type: %s; name=\"%s\"%s", $type, $name, $this->LE); + $mime[] = sprintf("Content-Transfer-Encoding: %s%s", $encoding, $this->LE); + + if($disposition == 'inline') { + $mime[] = sprintf("Content-ID: <%s>%s", $cid, $this->LE); + } + + $mime[] = sprintf("Content-Disposition: %s; filename=\"%s\"%s", $disposition, $name, $this->LE.$this->LE); + + /* Encode as string attachment */ + if($bString) { + $mime[] = $this->EncodeString($string, $encoding); + if($this->IsError()) { + return ''; + } + $mime[] = $this->LE.$this->LE; + } else { + $mime[] = $this->EncodeFile($path, $encoding); + if($this->IsError()) { + return ''; + } + $mime[] = $this->LE.$this->LE; + } + } + + $mime[] = sprintf("--%s--%s", $this->boundary[1], $this->LE); + + return join('', $mime); + } + + /** + * Encodes attachment in requested format. Returns an + * empty string on failure. + * @access public + * @return string + */ + public function EncodeFile ($path, $encoding = 'base64') { + if(!@$fd = fopen($path, 'rb')) { + $this->SetError($this->Lang('file_open') . $path); + return ''; + } + $magic_quotes = get_magic_quotes_runtime(); + set_magic_quotes_runtime(0); + $file_buffer = file_get_contents($path); + $file_buffer = $this->EncodeString($file_buffer, $encoding); + fclose($fd); + set_magic_quotes_runtime($magic_quotes); + + return $file_buffer; + } + + /** + * Encodes string to requested format. Returns an + * empty string on failure. + * @access public + * @return string + */ + public function EncodeString ($str, $encoding = 'base64') { + $encoded = ''; + switch(strtolower($encoding)) { + case 'base64': + $encoded = chunk_split(base64_encode($str), 76, $this->LE); + break; + case '7bit': + case '8bit': + $encoded = $this->FixEOL($str); + if (substr($encoded, -(strlen($this->LE))) != $this->LE) + $encoded .= $this->LE; + break; + case 'binary': + $encoded = $str; + break; + case 'quoted-printable': + $encoded = $this->EncodeQP($str); + break; + default: + $this->SetError($this->Lang('encoding') . $encoding); + break; + } + return $encoded; + } + + /** + * Encode a header string to best of Q, B, quoted or none. + * @access public + * @return string + */ + public function EncodeHeader ($str, $position = 'text') { + $x = 0; + + switch (strtolower($position)) { + case 'phrase': + if (!preg_match('/[\200-\377]/', $str)) { + /* Can't use addslashes as we don't know what value has magic_quotes_sybase. */ + $encoded = addcslashes($str, "\0..\37\177\\\""); + if (($str == $encoded) && !preg_match('/[^A-Za-z0-9!#$%&\'*+\/=?^_`{|}~ -]/', $str)) { + return ($encoded); + } else { + return ("\"$encoded\""); + } + } + $x = preg_match_all('/[^\040\041\043-\133\135-\176]/', $str, $matches); + break; + case 'comment': + $x = preg_match_all('/[()"]/', $str, $matches); + /* Fall-through */ + case 'text': + default: + $x += preg_match_all('/[\000-\010\013\014\016-\037\177-\377]/', $str, $matches); + break; + } + + if ($x == 0) { + return ($str); + } + + $maxlen = 75 - 7 - strlen($this->CharSet); + /* Try to select the encoding which should produce the shortest output */ + if (strlen($str)/3 < $x) { + $encoding = 'B'; + if (function_exists('mb_strlen') && $this->HasMultiBytes($str)) { + // Use a custom function which correctly encodes and wraps long + // multibyte strings without breaking lines within a character + $encoded = $this->Base64EncodeWrapMB($str); + } else { + $encoded = base64_encode($str); + $maxlen -= $maxlen % 4; + $encoded = trim(chunk_split($encoded, $maxlen, "\n")); + } + } else { + $encoding = 'Q'; + $encoded = $this->EncodeQ($str, $position); + $encoded = $this->WrapText($encoded, $maxlen, true); + $encoded = str_replace('='.$this->LE, "\n", trim($encoded)); + } + + $encoded = preg_replace('/^(.*)$/m', " =?".$this->CharSet."?$encoding?\\1?=", $encoded); + $encoded = trim(str_replace("\n", $this->LE, $encoded)); + + return $encoded; + } + + /** + * Checks if a string contains multibyte characters. + * @access public + * @param string $str multi-byte text to wrap encode + * @return bool + */ + public function HasMultiBytes($str) { + if (function_exists('mb_strlen')) { + return (strlen($str) > mb_strlen($str, $this->CharSet)); + } else { // Assume no multibytes (we can't handle without mbstring functions anyway) + return False; + } + } + + /** + * Correctly encodes and wraps long multibyte strings for mail headers + * without breaking lines within a character. + * Adapted from a function by paravoid at http://uk.php.net/manual/en/function.mb-encode-mimeheader.php + * @access public + * @param string $str multi-byte text to wrap encode + * @return string + */ + public function Base64EncodeWrapMB($str) { + $start = "=?".$this->CharSet."?B?"; + $end = "?="; + $encoded = ""; + + $mb_length = mb_strlen($str, $this->CharSet); + // Each line must have length <= 75, including $start and $end + $length = 75 - strlen($start) - strlen($end); + // Average multi-byte ratio + $ratio = $mb_length / strlen($str); + // Base64 has a 4:3 ratio + $offset = $avgLength = floor($length * $ratio * .75); + + for ($i = 0; $i < $mb_length; $i += $offset) { + $lookBack = 0; + + do { + $offset = $avgLength - $lookBack; + $chunk = mb_substr($str, $i, $offset, $this->CharSet); + $chunk = base64_encode($chunk); + $lookBack++; + } + while (strlen($chunk) > $length); + + $encoded .= $chunk . $this->LE; + } + + // Chomp the last linefeed + $encoded = substr($encoded, 0, -strlen($this->LE)); + return $encoded; + } + + /** + * Encode string to quoted-printable. + * @access public + * @param string $string the text to encode + * @param integer $line_max Number of chars allowed on a line before wrapping + * @return string + */ + public function EncodeQP( $input = '', $line_max = 76, $space_conv = false ) { + $hex = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'); + $lines = preg_split('/(?:\r\n|\r|\n)/', $input); + $eol = "\r\n"; + $escape = '='; + $output = ''; + while( list(, $line) = each($lines) ) { + $linlen = strlen($line); + $newline = ''; + for($i = 0; $i < $linlen; $i++) { + $c = substr( $line, $i, 1 ); + $dec = ord( $c ); + if ( ( $i == 0 ) && ( $dec == 46 ) ) { // convert first point in the line into =2E + $c = '=2E'; + } + if ( $dec == 32 ) { + if ( $i == ( $linlen - 1 ) ) { // convert space at eol only + $c = '=20'; + } else if ( $space_conv ) { + $c = '=20'; + } + } elseif ( ($dec == 61) || ($dec < 32 ) || ($dec > 126) ) { // always encode "\t", which is *not* required + $h2 = floor($dec/16); + $h1 = floor($dec%16); + $c = $escape.$hex[$h2].$hex[$h1]; + } + if ( (strlen($newline) + strlen($c)) >= $line_max ) { // CRLF is not counted + $output .= $newline.$escape.$eol; // soft line break; " =\r\n" is okay + $newline = ''; + // check if newline first character will be point or not + if ( $dec == 46 ) { + $c = '=2E'; + } + } + $newline .= $c; + } // end of for + $output .= $newline.$eol; + } // end of while + return trim($output); + } + + /** + * Encode string to q encoding. + * @access public + * @return string + */ + public function EncodeQ ($str, $position = 'text') { + /* There should not be any EOL in the string */ + $encoded = preg_replace("[\r\n]", '', $str); + + switch (strtolower($position)) { + case 'phrase': + $encoded = preg_replace("/([^A-Za-z0-9!*+\/ -])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded); + break; + case 'comment': + $encoded = preg_replace("/([\(\)\"])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded); + case 'text': + default: + /* Replace every high ascii, control =, ? and _ characters */ + $encoded = preg_replace('/([\000-\011\013\014\016-\037\075\077\137\177-\377])/e', + "'='.sprintf('%02X', ord('\\1'))", $encoded); + break; + } + + /* Replace every spaces to _ (more readable than =20) */ + $encoded = str_replace(' ', '_', $encoded); + + return $encoded; + } + + /** + * Adds a string or binary attachment (non-filesystem) to the list. + * This method can be used to attach ascii or binary data, + * such as a BLOB record from a database. + * @param string $string String attachment data. + * @param string $filename Name of the attachment. + * @param string $encoding File encoding (see $Encoding). + * @param string $type File extension (MIME) type. + * @return void + */ + public function AddStringAttachment($string, $filename, $encoding = 'base64', $type = 'application/octet-stream') { + /* Append to $attachment array */ + $cur = count($this->attachment); + $this->attachment[$cur][0] = $string; + $this->attachment[$cur][1] = $filename; + $this->attachment[$cur][2] = $filename; + $this->attachment[$cur][3] = $encoding; + $this->attachment[$cur][4] = $type; + $this->attachment[$cur][5] = true; // isString + $this->attachment[$cur][6] = 'attachment'; + $this->attachment[$cur][7] = 0; + } + + /** + * Adds an embedded attachment. This can include images, sounds, and + * just about any other document. Make sure to set the $type to an + * image type. For JPEG images use "image/jpeg" and for GIF images + * use "image/gif". + * @param string $path Path to the attachment. + * @param string $cid Content ID of the attachment. Use this to identify + * the Id for accessing the image in an HTML form. + * @param string $name Overrides the attachment name. + * @param string $encoding File encoding (see $Encoding). + * @param string $type File extension (MIME) type. + * @return bool + */ + public function AddEmbeddedImage($path, $cid, $name = '', $encoding = 'base64', $type = 'application/octet-stream') { + + if(!@is_file($path)) { + $this->SetError($this->Lang('file_access') . $path); + return false; + } + + $filename = basename($path); + if($name == '') { + $name = $filename; + } + + /* Append to $attachment array */ + $cur = count($this->attachment); + $this->attachment[$cur][0] = $path; + $this->attachment[$cur][1] = $filename; + $this->attachment[$cur][2] = $name; + $this->attachment[$cur][3] = $encoding; + $this->attachment[$cur][4] = $type; + $this->attachment[$cur][5] = false; + $this->attachment[$cur][6] = 'inline'; + $this->attachment[$cur][7] = $cid; + + return true; + } + + /** + * Returns true if an inline attachment is present. + * @access public + * @return bool + */ + public function InlineImageExists() { + $result = false; + for($i = 0; $i < count($this->attachment); $i++) { + if($this->attachment[$i][6] == 'inline') { + $result = true; + break; + } + } + + return $result; + } + + ///////////////////////////////////////////////// + // CLASS METHODS, MESSAGE RESET + ///////////////////////////////////////////////// + + /** + * Clears all recipients assigned in the TO array. Returns void. + * @return void + */ + public function ClearAddresses() { + $this->to = array(); + } + + /** + * Clears all recipients assigned in the CC array. Returns void. + * @return void + */ + public function ClearCCs() { + $this->cc = array(); + } + + /** + * Clears all recipients assigned in the BCC array. Returns void. + * @return void + */ + public function ClearBCCs() { + $this->bcc = array(); + } + + /** + * Clears all recipients assigned in the ReplyTo array. Returns void. + * @return void + */ + public function ClearReplyTos() { + $this->ReplyTo = array(); + } + + /** + * Clears all recipients assigned in the TO, CC and BCC + * array. Returns void. + * @return void + */ + public function ClearAllRecipients() { + $this->to = array(); + $this->cc = array(); + $this->bcc = array(); + } + + /** + * Clears all previously set filesystem, string, and binary + * attachments. Returns void. + * @return void + */ + public function ClearAttachments() { + $this->attachment = array(); + } + + /** + * Clears all custom headers. Returns void. + * @return void + */ + public function ClearCustomHeaders() { + $this->CustomHeader = array(); + } + + ///////////////////////////////////////////////// + // CLASS METHODS, MISCELLANEOUS + ///////////////////////////////////////////////// + + /** + * Adds the error message to the error container. + * Returns void. + * @access private + * @return void + */ + private function SetError($msg) { + $this->error_count++; + $this->ErrorInfo = $msg; + } + + /** + * Returns the proper RFC 822 formatted date. + * @access private + * @return string + */ + private static function RFCDate() { + $tz = date('Z'); + $tzs = ($tz < 0) ? '-' : '+'; + $tz = abs($tz); + $tz = (int)($tz/3600)*100 + ($tz%3600)/60; + $result = sprintf("%s %s%04d", date('D, j M Y H:i:s'), $tzs, $tz); + + return $result; + } + + /** + * Returns the server hostname or 'localhost.localdomain' if unknown. + * @access private + * @return string + */ + private function ServerHostname() { + if (!empty($this->Hostname)) { + $result = $this->Hostname; + } elseif (isset($_SERVER['SERVER_NAME'])) { + $result = $_SERVER['SERVER_NAME']; + } else { + $result = "localhost.localdomain"; + } + + return $result; + } + + /** + * Returns a message in the appropriate language. + * @access private + * @return string + */ + private function Lang($key) { + if(count($this->language) < 1) { + $this->SetLanguage('en'); // set the default language + } + + if(isset($this->language[$key])) { + return $this->language[$key]; + } else { + return 'Language string failed to load: ' . $key; + } + } + + /** + * Returns true if an error occurred. + * @access public + * @return bool + */ + public function IsError() { + return ($this->error_count > 0); + } + + /** + * Changes every end of line from CR or LF to CRLF. + * @access private + * @return string + */ + private function FixEOL($str) { + $str = str_replace("\r\n", "\n", $str); + $str = str_replace("\r", "\n", $str); + $str = str_replace("\n", $this->LE, $str); + return $str; + } + + /** + * Adds a custom header. + * @access public + * @return void + */ + public function AddCustomHeader($custom_header) { + $this->CustomHeader[] = explode(':', $custom_header, 2); + } + + /** + * Evaluates the message and returns modifications for inline images and backgrounds + * @access public + * @return $message + */ + public function MsgHTML($message,$basedir='') { + preg_match_all("/(src|background)=\"(.*)\"/Ui", $message, $images); + if(isset($images[2])) { + foreach($images[2] as $i => $url) { + // do not change urls for absolute images (thanks to corvuscorax) + if (!preg_match('/^[A-z][A-z]*:\/\//',$url)) { + $filename = basename($url); + $directory = dirname($url); + ($directory == '.')?$directory='':''; + $cid = 'cid:' . md5($filename); + $fileParts = split("\.", $filename); + $ext = $fileParts[1]; + $mimeType = $this->_mime_types($ext); + if ( strlen($basedir) > 1 && substr($basedir,-1) != '/') { $basedir .= '/'; } + if ( strlen($directory) > 1 && substr($basedir,-1) != '/') { $directory .= '/'; } + $this->AddEmbeddedImage($basedir.$directory.$filename, md5($filename), $filename, 'base64', $mimeType); + if ( $this->AddEmbeddedImage($basedir.$directory.$filename, md5($filename), $filename, 'base64',$mimeType) ) { + $message = preg_replace("/".$images[1][$i]."=\"".preg_quote($url, '/')."\"/Ui", $images[1][$i]."=\"".$cid."\"", $message); + } + } + } + } + $this->IsHTML(true); + $this->Body = $message; + $textMsg = trim(strip_tags(preg_replace('/<(head|title|style|script)[^>]*>.*?<\/\\1>/s','',$message))); + if ( !empty($textMsg) && empty($this->AltBody) ) { + $this->AltBody = $textMsg; + } + if ( empty($this->AltBody) ) { + $this->AltBody = 'To view this email message, open the email in with HTML compatibility!' . "\n\n"; + } + } + + /** + * Gets the mime type of the embedded or inline image + * @access public + * @return mime type of ext + */ + public function _mime_types($ext = '') { + $mimes = array( + 'hqx' => 'application/mac-binhex40', + 'cpt' => 'application/mac-compactpro', + 'doc' => 'application/msword', + 'bin' => 'application/macbinary', + 'dms' => 'application/octet-stream', + 'lha' => 'application/octet-stream', + 'lzh' => 'application/octet-stream', + 'exe' => 'application/octet-stream', + 'class' => 'application/octet-stream', + 'psd' => 'application/octet-stream', + 'so' => 'application/octet-stream', + 'sea' => 'application/octet-stream', + 'dll' => 'application/octet-stream', + 'oda' => 'application/oda', + 'pdf' => 'application/pdf', + 'ai' => 'application/postscript', + 'eps' => 'application/postscript', + 'ps' => 'application/postscript', + 'smi' => 'application/smil', + 'smil' => 'application/smil', + 'mif' => 'application/vnd.mif', + 'xls' => 'application/vnd.ms-excel', + 'ppt' => 'application/vnd.ms-powerpoint', + 'wbxml' => 'application/vnd.wap.wbxml', + 'wmlc' => 'application/vnd.wap.wmlc', + 'dcr' => 'application/x-director', + 'dir' => 'application/x-director', + 'dxr' => 'application/x-director', + 'dvi' => 'application/x-dvi', + 'gtar' => 'application/x-gtar', + 'php' => 'application/x-httpd-php', + 'php4' => 'application/x-httpd-php', + 'php3' => 'application/x-httpd-php', + 'phtml' => 'application/x-httpd-php', + 'phps' => 'application/x-httpd-php-source', + 'js' => 'application/x-javascript', + 'swf' => 'application/x-shockwave-flash', + 'sit' => 'application/x-stuffit', + 'tar' => 'application/x-tar', + 'tgz' => 'application/x-tar', + 'xhtml' => 'application/xhtml+xml', + 'xht' => 'application/xhtml+xml', + 'zip' => 'application/zip', + 'mid' => 'audio/midi', + 'midi' => 'audio/midi', + 'mpga' => 'audio/mpeg', + 'mp2' => 'audio/mpeg', + 'mp3' => 'audio/mpeg', + 'aif' => 'audio/x-aiff', + 'aiff' => 'audio/x-aiff', + 'aifc' => 'audio/x-aiff', + 'ram' => 'audio/x-pn-realaudio', + 'rm' => 'audio/x-pn-realaudio', + 'rpm' => 'audio/x-pn-realaudio-plugin', + 'ra' => 'audio/x-realaudio', + 'rv' => 'video/vnd.rn-realvideo', + 'wav' => 'audio/x-wav', + 'bmp' => 'image/bmp', + 'gif' => 'image/gif', + 'jpeg' => 'image/jpeg', + 'jpg' => 'image/jpeg', + 'jpe' => 'image/jpeg', + 'png' => 'image/png', + 'tiff' => 'image/tiff', + 'tif' => 'image/tiff', + 'css' => 'text/css', + 'html' => 'text/html', + 'htm' => 'text/html', + 'shtml' => 'text/html', + 'txt' => 'text/plain', + 'text' => 'text/plain', + 'log' => 'text/plain', + 'rtx' => 'text/richtext', + 'rtf' => 'text/rtf', + 'xml' => 'text/xml', + 'xsl' => 'text/xml', + 'mpeg' => 'video/mpeg', + 'mpg' => 'video/mpeg', + 'mpe' => 'video/mpeg', + 'qt' => 'video/quicktime', + 'mov' => 'video/quicktime', + 'avi' => 'video/x-msvideo', + 'movie' => 'video/x-sgi-movie', + 'doc' => 'application/msword', + 'word' => 'application/msword', + 'xl' => 'application/excel', + 'eml' => 'message/rfc822' + ); + return ( ! isset($mimes[strtolower($ext)])) ? 'application/octet-stream' : $mimes[strtolower($ext)]; + } + + /** + * Set (or reset) Class Objects (variables) + * + * Usage Example: + * $page->set('X-Priority', '3'); + * + * @access public + * @param string $name Parameter Name + * @param mixed $value Parameter Value + * NOTE: will not work with arrays, there are no arrays to set/reset + */ + public function set ( $name, $value = '' ) { + if ( isset($this->$name) ) { + $this->$name = $value; + } else { + $this->SetError('Cannot set or reset variable ' . $name); + return false; + } + } + + /** + * Read a file from a supplied filename and return it. + * + * @access public + * @param string $filename Parameter File Name + */ + public function getFile($filename) { + $return = ''; + if ($fp = fopen($filename, 'rb')) { + while (!feof($fp)) { + $return .= fread($fp, 1024); + } + fclose($fp); + return $return; + } else { + return false; + } + } + + /** + * Strips newlines to prevent header injection. + * @access public + * @param string $str String + * @return string + */ + public function SecureHeader($str) { + $str = trim($str); + $str = str_replace("\r", "", $str); + $str = str_replace("\n", "", $str); + return $str; + } + + /** + * Set the private key file and password to sign the message. + * + * @access public + * @param string $key_filename Parameter File Name + * @param string $key_pass Password for private key + */ + public function Sign($key_filename, $key_pass) { + $this->sign_key_file = $key_filename; + $this->sign_key_pass = $key_pass; + } + +} + +?> diff --git a/inc/classes/third_party/php_mailer/class.pop3.php b/inc/classes/third_party/php_mailer/class.pop3.php new file mode 100644 index 00000000..cac5dfef --- /dev/null +++ b/inc/classes/third_party/php_mailer/class.pop3.php @@ -0,0 +1,393 @@ +pop_conn = 0; + $this->connected = false; + $this->error = null; + } + + /** + * Combination of public events - connect, login, disconnect + * @access public + * @param string $host + * @param integer $port + * @param integer $tval + * @param string $username + * @param string $password + */ + public function Authorise ($host, $port = false, $tval = false, $username, $password, $debug_level = 0) { + $this->host = $host; + + // If no port value is passed, retrieve it + if ($port == false) { + $this->port = $this->POP3_PORT; + } else { + $this->port = $port; + } + + // If no port value is passed, retrieve it + if ($tval == false) { + $this->tval = $this->POP3_TIMEOUT; + } else { + $this->tval = $tval; + } + + $this->do_debug = $debug_level; + $this->username = $username; + $this->password = $password; + + // Refresh the error log + $this->error = null; + + // Connect + $result = $this->Connect($this->host, $this->port, $this->tval); + + if ($result) { + $login_result = $this->Login($this->username, $this->password); + + if ($login_result) { + $this->Disconnect(); + + return true; + } + + } + + // We need to disconnect regardless if the login succeeded + $this->Disconnect(); + + return false; + } + + /** + * Connect to the POP3 server + * @access public + * @param string $host + * @param integer $port + * @param integer $tval + * @return boolean + */ + public function Connect ($host, $port = false, $tval = 30) { + // Are we already connected? + if ($this->connected) { + return true; + } + + /* + On Windows this will raise a PHP Warning error if the hostname doesn't exist. + Rather than supress it with @fsockopen, let's capture it cleanly instead + */ + + set_error_handler(array(&$this, 'catchWarning')); + + // Connect to the POP3 server + $this->pop_conn = fsockopen($host, // POP3 Host + $port, // Port # + $errno, // Error Number + $errstr, // Error Message + $tval); // Timeout (seconds) + + // Restore the error handler + restore_error_handler(); + + // Does the Error Log now contain anything? + if ($this->error && $this->do_debug >= 1) { + $this->displayErrors(); + } + + // Did we connect? + if ($this->pop_conn == false) { + // It would appear not... + $this->error = array( + 'error' => "Failed to connect to server $host on port $port", + 'errno' => $errno, + 'errstr' => $errstr + ); + + if ($this->do_debug >= 1) { + $this->displayErrors(); + } + + return false; + } + + // Increase the stream time-out + + // Check for PHP 4.3.0 or later + if (version_compare(phpversion(), '4.3.0', 'ge')) { + stream_set_timeout($this->pop_conn, $tval, 0); + } else { + // Does not work on Windows + if (substr(PHP_OS, 0, 3) !== 'WIN') { + socket_set_timeout($this->pop_conn, $tval, 0); + } + } + + // Get the POP3 server response + $pop3_response = $this->getResponse(); + + // Check for the +OK + if ($this->checkResponse($pop3_response)) { + // The connection is established and the POP3 server is talking + $this->connected = true; + return true; + } + + } + + /** + * Login to the POP3 server (does not support APOP yet) + * @access public + * @param string $username + * @param string $password + * @return boolean + */ + public function Login ($username = '', $password = '') { + if ($this->connected == false) { + $this->error = 'Not connected to POP3 server'; + + if ($this->do_debug >= 1) { + $this->displayErrors(); + } + } + + if (empty($username)) { + $username = $this->username; + } + + if (empty($password)) { + $password = $this->password; + } + + $pop_username = "USER $username" . $this->CRLF; + $pop_password = "PASS $password" . $this->CRLF; + + // Send the Username + $this->sendString($pop_username); + $pop3_response = $this->getResponse(); + + if ($this->checkResponse($pop3_response)) { + // Send the Password + $this->sendString($pop_password); + $pop3_response = $this->getResponse(); + + if ($this->checkResponse($pop3_response)) { + return true; + } else { + return false; + } + } else { + return false; + } + } + + /** + * Disconnect from the POP3 server + * @access public + */ + public function Disconnect () { + $this->sendString('QUIT'); + + fclose($this->pop_conn); + } + + ///////////////////////////////////////////////// + // Private Methods + ///////////////////////////////////////////////// + + /** + * Get the socket response back. + * $size is the maximum number of bytes to retrieve + * @access private + * @param integer $size + * @return string + */ + private public function getResponse ($size = 128) { + $pop3_response = fgets($this->pop_conn, $size); + + return $pop3_response; + } + + /** + * Send a string down the open socket connection to the POP3 server + * @access private + * @param string $string + * @return integer + */ + private function sendString ($string) { + $bytes_sent = fwrite($this->pop_conn, $string, strlen($string)); + + return $bytes_sent; + } + + /** + * Checks the POP3 server response for +OK or -ERR + * @access private + * @param string $string + * @return boolean + */ + private function checkResponse ($string) { + if (substr($string, 0, 3) !== '+OK') { + $this->error = array( + 'error' => "Server reported an error: $string", + 'errno' => 0, + 'errstr' => '' + ); + + if ($this->do_debug >= 1) { + $this->displayErrors(); + } + + return false; + } else { + return true; + } + + } + + /** + * If debug is enabled, display the error message array + * @access private + */ + private function displayErrors () { + echo '

';
+
+    foreach ($this->error as $single_error) {
+      print_r($single_error);
+    }
+
+    echo '
'; + } + + /** + * Takes over from PHP for the socket warning handler + * @access private + * @param integer $errno + * @param string $errstr + * @param string $errfile + * @param integer $errline + */ + private function catchWarning ($errno, $errstr, $errfile, $errline) { + $this->error[] = array( + 'error' => "Connecting to the POP3 server raised a PHP warning: ", + 'errno' => $errno, + 'errstr' => $errstr + ); + } + + // End of class +} +?> diff --git a/inc/classes/third_party/php_mailer/class.smtp.php b/inc/classes/third_party/php_mailer/class.smtp.php new file mode 100644 index 00000000..b2f0f3c3 --- /dev/null +++ b/inc/classes/third_party/php_mailer/class.smtp.php @@ -0,0 +1,1113 @@ +smtp_conn = 0; + $this->error = null; + $this->helo_rply = null; + + $this->do_debug = 0; + } + + /************************************************************* + * CONNECTION FUNCTIONS * + ***********************************************************/ + + /** + * Connect to the server specified on the port specified. + * If the port is not specified use the default SMTP_PORT. + * If tval is specified then a connection will try and be + * established with the server for that number of seconds. + * If tval is not specified the default is 30 seconds to + * try on the connection. + * + * SMTP CODE SUCCESS: 220 + * SMTP CODE FAILURE: 421 + * @access public + * @return bool + */ + public function Connect($host,$port=0,$tval=30) { + /* set the error val to null so there is no confusion */ + $this->error = null; + + /* make sure we are __not__ connected */ + if($this->connected()) { + /* ok we are connected! what should we do? + * for now we will just give an error saying we + * are already connected + */ + $this->error = array("error" => "Already connected to a server"); + return false; + } + + if(empty($port)) { + $port = $this->SMTP_PORT; + } + + /* connect to the smtp server */ + $this->smtp_conn = fsockopen($host, // the host of the server + $port, // the port to use + $errno, // error number if any + $errstr, // error message if any + $tval); // give up after ? secs + /* verify we connected properly */ + if(empty($this->smtp_conn)) { + $this->error = array("error" => "Failed to connect to server", + "errno" => $errno, + "errstr" => $errstr); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . + ": $errstr ($errno)" . $this->CRLF; + } + return false; + } + + /* sometimes the SMTP server takes a little longer to respond + * so we will give it a longer timeout for the first read + * - Windows still does not have support for this timeout function + */ + if(substr(PHP_OS, 0, 3) != "WIN") + socket_set_timeout($this->smtp_conn, $tval, 0); + + /* get any announcement stuff */ + $announce = $this->get_lines(); + + /* set the timeout of any socket functions at 1/10 of a second */ + //if(function_exists("socket_set_timeout")) + // socket_set_timeout($this->smtp_conn, 0, 100000); + + if($this->do_debug >= 2) { + echo "SMTP -> FROM SERVER:" . $this->CRLF . $announce; + } + + return true; + } + + /** + * Initiate a TSL communication with the server. + * + * SMTP CODE 220 Ready to start TLS + * SMTP CODE 501 Syntax error (no parameters allowed) + * SMTP CODE 454 TLS not available due to temporary reason + * @access public + * @return bool success + */ + public function StartTLS() { + $this->error = null; # to avoid confusion + + if(!$this->connected()) { + $this->error = array("error" => "Called StartTLS() without being connected"); + return false; + } + + fputs($this->smtp_conn,"STARTTLS" . $extra . $this->CRLF); + + $rply = $this->get_lines(); + $code = substr($rply,0,3); + + if($this->do_debug >= 2) { + echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; + } + + if($code != 220) { + $this->error = + array("error" => "STARTTLS not accepted from server", + "smtp_code" => $code, + "smtp_msg" => substr($rply,4)); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF; + } + return false; + } + + //Begin encrypted connection + if(!stream_socket_enable_crypto($this->smtp_conn, true, STREAM_CRYPTO_METHOD_TLS_CLIENT)) { + return false; + } + + return true; + } + + /** + * Performs SMTP authentication. Must be run after running the + * Hello() method. Returns true if successfully authenticated. + * @access public + * @return bool + */ + public function Authenticate($username, $password) { + // Start authentication + fputs($this->smtp_conn,"AUTH LOGIN" . $this->CRLF); + + $rply = $this->get_lines(); + $code = substr($rply,0,3); + + if($code != 334) { + $this->error = + array("error" => "AUTH not accepted from server", + "smtp_code" => $code, + "smtp_msg" => substr($rply,4)); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . + ": " . $rply . $this->CRLF; + } + return false; + } + + // Send encoded username + fputs($this->smtp_conn, base64_encode($username) . $this->CRLF); + + $rply = $this->get_lines(); + $code = substr($rply,0,3); + + if($code != 334) { + $this->error = + array("error" => "Username not accepted from server", + "smtp_code" => $code, + "smtp_msg" => substr($rply,4)); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . + ": " . $rply . $this->CRLF; + } + return false; + } + + // Send encoded password + fputs($this->smtp_conn, base64_encode($password) . $this->CRLF); + + $rply = $this->get_lines(); + $code = substr($rply,0,3); + + if($code != 235) { + $this->error = + array("error" => "Password not accepted from server", + "smtp_code" => $code, + "smtp_msg" => substr($rply,4)); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . + ": " . $rply . $this->CRLF; + } + return false; + } + + return true; + } + + /** + * Returns true if connected to a server otherwise false + * @access public + * @return bool + */ + public function Connected() { + if(!empty($this->smtp_conn)) { + $sock_status = socket_get_status($this->smtp_conn); + if($sock_status["eof"]) { + // hmm this is an odd situation... the socket is + // valid but we are not connected anymore + if($this->do_debug >= 1) { + echo "SMTP -> NOTICE:" . $this->CRLF . + "EOF caught while checking if connected"; + } + $this->Close(); + return false; + } + return true; // everything looks good + } + return false; + } + + /** + * Closes the socket and cleans up the state of the class. + * It is not considered good to use this function without + * first trying to use QUIT. + * @access public + * @return void + */ + public function Close() { + $this->error = null; // so there is no confusion + $this->helo_rply = null; + if(!empty($this->smtp_conn)) { + // close the connection and cleanup + fclose($this->smtp_conn); + $this->smtp_conn = 0; + } + } + + /*************************************************************** + * SMTP COMMANDS * + *************************************************************/ + + /** + * Issues a data command and sends the msg_data to the server + * finializing the mail transaction. $msg_data is the message + * that is to be send with the headers. Each header needs to be + * on a single line followed by a with the message headers + * and the message body being seperated by and additional . + * + * Implements rfc 821: DATA + * + * SMTP CODE INTERMEDIATE: 354 + * [data] + * . + * SMTP CODE SUCCESS: 250 + * SMTP CODE FAILURE: 552,554,451,452 + * SMTP CODE FAILURE: 451,554 + * SMTP CODE ERROR : 500,501,503,421 + * @access public + * @return bool + */ + public function Data($msg_data) { + $this->error = null; // so no confusion is caused + + if(!$this->connected()) { + $this->error = array( + "error" => "Called Data() without being connected"); + return false; + } + + fputs($this->smtp_conn,"DATA" . $this->CRLF); + + $rply = $this->get_lines(); + $code = substr($rply,0,3); + + if($this->do_debug >= 2) { + echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; + } + + if($code != 354) { + $this->error = + array("error" => "DATA command not accepted from server", + "smtp_code" => $code, + "smtp_msg" => substr($rply,4)); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . + ": " . $rply . $this->CRLF; + } + return false; + } + + /* the server is ready to accept data! + * according to rfc 821 we should not send more than 1000 + * including the CRLF + * characters on a single line so we will break the data up + * into lines by \r and/or \n then if needed we will break + * each of those into smaller lines to fit within the limit. + * in addition we will be looking for lines that start with + * a period '.' and append and additional period '.' to that + * line. NOTE: this does not count towards are limit. + */ + + // normalize the line breaks so we know the explode works + $msg_data = str_replace("\r\n","\n",$msg_data); + $msg_data = str_replace("\r","\n",$msg_data); + $lines = explode("\n",$msg_data); + + /* we need to find a good way to determine is headers are + * in the msg_data or if it is a straight msg body + * currently I am assuming rfc 822 definitions of msg headers + * and if the first field of the first line (':' sperated) + * does not contain a space then it _should_ be a header + * and we can process all lines before a blank "" line as + * headers. + */ + $field = substr($lines[0],0,strpos($lines[0],":")); + $in_headers = false; + if(!empty($field) && !strstr($field," ")) { + $in_headers = true; + } + + $max_line_length = 998; // used below; set here for ease in change + + while(list(,$line) = @each($lines)) { + $lines_out = null; + if($line == "" && $in_headers) { + $in_headers = false; + } + // ok we need to break this line up into several smaller lines + while(strlen($line) > $max_line_length) { + $pos = strrpos(substr($line,0,$max_line_length)," "); + + // Patch to fix DOS attack + if(!$pos) { + $pos = $max_line_length - 1; + $lines_out[] = substr($line,0,$pos); + $line = substr($line,$pos); + } else { + $lines_out[] = substr($line,0,$pos); + $line = substr($line,$pos + 1); + } + + /* if we are processing headers we need to + * add a LWSP-char to the front of the new line + * rfc 822 on long msg headers + */ + if($in_headers) { + $line = "\t" . $line; + } + } + $lines_out[] = $line; + + // now send the lines to the server + while(list(,$line_out) = @each($lines_out)) { + if(strlen($line_out) > 0) + { + if(substr($line_out, 0, 1) == ".") { + $line_out = "." . $line_out; + } + } + fputs($this->smtp_conn,$line_out . $this->CRLF); + } + } + + // ok all the message data has been sent so lets get this + // over with aleady + fputs($this->smtp_conn, $this->CRLF . "." . $this->CRLF); + + $rply = $this->get_lines(); + $code = substr($rply,0,3); + + if($this->do_debug >= 2) { + echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; + } + + if($code != 250) { + $this->error = + array("error" => "DATA not accepted from server", + "smtp_code" => $code, + "smtp_msg" => substr($rply,4)); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . + ": " . $rply . $this->CRLF; + } + return false; + } + return true; + } + + /** + * Expand takes the name and asks the server to list all the + * people who are members of the _list_. Expand will return + * back and array of the result or false if an error occurs. + * Each value in the array returned has the format of: + * [ ] + * The definition of is defined in rfc 821 + * + * Implements rfc 821: EXPN + * + * SMTP CODE SUCCESS: 250 + * SMTP CODE FAILURE: 550 + * SMTP CODE ERROR : 500,501,502,504,421 + * @access public + * @return string array + */ + public function Expand($name) { + $this->error = null; // so no confusion is caused + + if(!$this->connected()) { + $this->error = array( + "error" => "Called Expand() without being connected"); + return false; + } + + fputs($this->smtp_conn,"EXPN " . $name . $this->CRLF); + + $rply = $this->get_lines(); + $code = substr($rply,0,3); + + if($this->do_debug >= 2) { + echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; + } + + if($code != 250) { + $this->error = + array("error" => "EXPN not accepted from server", + "smtp_code" => $code, + "smtp_msg" => substr($rply,4)); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . + ": " . $rply . $this->CRLF; + } + return false; + } + + // parse the reply and place in our array to return to user + $entries = explode($this->CRLF,$rply); + while(list(,$l) = @each($entries)) { + $list[] = substr($l,4); + } + + return $list; + } + + /** + * Sends the HELO command to the smtp server. + * This makes sure that we and the server are in + * the same known state. + * + * Implements from rfc 821: HELO + * + * SMTP CODE SUCCESS: 250 + * SMTP CODE ERROR : 500, 501, 504, 421 + * @access public + * @return bool + */ + public function Hello($host="") { + $this->error = null; // so no confusion is caused + + if(!$this->connected()) { + $this->error = array( + "error" => "Called Hello() without being connected"); + return false; + } + + // if a hostname for the HELO was not specified determine + //a suitable one to send + if(empty($host)) { + // we need to determine some sort of appopiate default + // to send to the server + $host = "localhost"; + } + + // Send extended hello first (RFC 2821) + if(!$this->SendHello("EHLO", $host)) + { + if(!$this->SendHello("HELO", $host)) + return false; + } + + return true; + } + + /** + * Sends a HELO/EHLO command. + * @access private + * @return bool + */ + private function SendHello($hello, $host) { + fputs($this->smtp_conn, $hello . " " . $host . $this->CRLF); + + $rply = $this->get_lines(); + $code = substr($rply,0,3); + + if($this->do_debug >= 2) { + echo "SMTP -> FROM SERVER: " . $this->CRLF . $rply; + } + + if($code != 250) { + $this->error = + array("error" => $hello . " not accepted from server", + "smtp_code" => $code, + "smtp_msg" => substr($rply,4)); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . + ": " . $rply . $this->CRLF; + } + return false; + } + + $this->helo_rply = $rply; + + return true; + } + + /** + * Gets help information on the keyword specified. If the keyword + * is not specified then returns generic help, ussually contianing + * A list of keywords that help is available on. This function + * returns the results back to the user. It is up to the user to + * handle the returned data. If an error occurs then false is + * returned with $this->error set appropiately. + * + * Implements rfc 821: HELP [ ] + * + * SMTP CODE SUCCESS: 211,214 + * SMTP CODE ERROR : 500,501,502,504,421 + * @access public + * @return string + */ + public function Help($keyword="") { + $this->error = null; // to avoid confusion + + if(!$this->connected()) { + $this->error = array( + "error" => "Called Help() without being connected"); + return false; + } + + $extra = ""; + if(!empty($keyword)) { + $extra = " " . $keyword; + } + + fputs($this->smtp_conn,"HELP" . $extra . $this->CRLF); + + $rply = $this->get_lines(); + $code = substr($rply,0,3); + + if($this->do_debug >= 2) { + echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; + } + + if($code != 211 && $code != 214) { + $this->error = + array("error" => "HELP not accepted from server", + "smtp_code" => $code, + "smtp_msg" => substr($rply,4)); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . + ": " . $rply . $this->CRLF; + } + return false; + } + + return $rply; + } + + /** + * Starts a mail transaction from the email address specified in + * $from. Returns true if successful or false otherwise. If True + * the mail transaction is started and then one or more Recipient + * commands may be called followed by a Data command. + * + * Implements rfc 821: MAIL FROM: + * + * SMTP CODE SUCCESS: 250 + * SMTP CODE SUCCESS: 552,451,452 + * SMTP CODE SUCCESS: 500,501,421 + * @access public + * @return bool + */ + public function Mail($from) { + $this->error = null; // so no confusion is caused + + if(!$this->connected()) { + $this->error = array( + "error" => "Called Mail() without being connected"); + return false; + } + + $useVerp = ($this->do_verp ? "XVERP" : ""); + fputs($this->smtp_conn,"MAIL FROM:<" . $from . ">" . $useVerp . $this->CRLF); + + $rply = $this->get_lines(); + $code = substr($rply,0,3); + + if($this->do_debug >= 2) { + echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; + } + + if($code != 250) { + $this->error = + array("error" => "MAIL not accepted from server", + "smtp_code" => $code, + "smtp_msg" => substr($rply,4)); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . + ": " . $rply . $this->CRLF; + } + return false; + } + return true; + } + + /** + * Sends the command NOOP to the SMTP server. + * + * Implements from rfc 821: NOOP + * + * SMTP CODE SUCCESS: 250 + * SMTP CODE ERROR : 500, 421 + * @access public + * @return bool + */ + public function Noop() { + $this->error = null; // so no confusion is caused + + if(!$this->connected()) { + $this->error = array( + "error" => "Called Noop() without being connected"); + return false; + } + + fputs($this->smtp_conn,"NOOP" . $this->CRLF); + + $rply = $this->get_lines(); + $code = substr($rply,0,3); + + if($this->do_debug >= 2) { + echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; + } + + if($code != 250) { + $this->error = + array("error" => "NOOP not accepted from server", + "smtp_code" => $code, + "smtp_msg" => substr($rply,4)); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . + ": " . $rply . $this->CRLF; + } + return false; + } + return true; + } + + /** + * Sends the quit command to the server and then closes the socket + * if there is no error or the $close_on_error argument is true. + * + * Implements from rfc 821: QUIT + * + * SMTP CODE SUCCESS: 221 + * SMTP CODE ERROR : 500 + * @access public + * @return bool + */ + public function Quit($close_on_error=true) { + $this->error = null; // so there is no confusion + + if(!$this->connected()) { + $this->error = array( + "error" => "Called Quit() without being connected"); + return false; + } + + // send the quit command to the server + fputs($this->smtp_conn,"quit" . $this->CRLF); + + // get any good-bye messages + $byemsg = $this->get_lines(); + + if($this->do_debug >= 2) { + echo "SMTP -> FROM SERVER:" . $this->CRLF . $byemsg; + } + + $rval = true; + $e = null; + + $code = substr($byemsg,0,3); + if($code != 221) { + // use e as a tmp var cause Close will overwrite $this->error + $e = array("error" => "SMTP server rejected quit command", + "smtp_code" => $code, + "smtp_rply" => substr($byemsg,4)); + $rval = false; + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $e["error"] . ": " . + $byemsg . $this->CRLF; + } + } + + if(empty($e) || $close_on_error) { + $this->Close(); + } + + return $rval; + } + + /** + * Sends the command RCPT to the SMTP server with the TO: argument of $to. + * Returns true if the recipient was accepted false if it was rejected. + * + * Implements from rfc 821: RCPT TO: + * + * SMTP CODE SUCCESS: 250,251 + * SMTP CODE FAILURE: 550,551,552,553,450,451,452 + * SMTP CODE ERROR : 500,501,503,421 + * @access public + * @return bool + */ + public function Recipient($to) { + $this->error = null; // so no confusion is caused + + if(!$this->connected()) { + $this->error = array( + "error" => "Called Recipient() without being connected"); + return false; + } + + fputs($this->smtp_conn,"RCPT TO:<" . $to . ">" . $this->CRLF); + + $rply = $this->get_lines(); + $code = substr($rply,0,3); + + if($this->do_debug >= 2) { + echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; + } + + if($code != 250 && $code != 251) { + $this->error = + array("error" => "RCPT not accepted from server", + "smtp_code" => $code, + "smtp_msg" => substr($rply,4)); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . + ": " . $rply . $this->CRLF; + } + return false; + } + return true; + } + + /** + * Sends the RSET command to abort and transaction that is + * currently in progress. Returns true if successful false + * otherwise. + * + * Implements rfc 821: RSET + * + * SMTP CODE SUCCESS: 250 + * SMTP CODE ERROR : 500,501,504,421 + * @access public + * @return bool + */ + public function Reset() { + $this->error = null; // so no confusion is caused + + if(!$this->connected()) { + $this->error = array( + "error" => "Called Reset() without being connected"); + return false; + } + + fputs($this->smtp_conn,"RSET" . $this->CRLF); + + $rply = $this->get_lines(); + $code = substr($rply,0,3); + + if($this->do_debug >= 2) { + echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; + } + + if($code != 250) { + $this->error = + array("error" => "RSET failed", + "smtp_code" => $code, + "smtp_msg" => substr($rply,4)); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . + ": " . $rply . $this->CRLF; + } + return false; + } + + return true; + } + + /** + * Starts a mail transaction from the email address specified in + * $from. Returns true if successful or false otherwise. If True + * the mail transaction is started and then one or more Recipient + * commands may be called followed by a Data command. This command + * will send the message to the users terminal if they are logged + * in. + * + * Implements rfc 821: SEND FROM: + * + * SMTP CODE SUCCESS: 250 + * SMTP CODE SUCCESS: 552,451,452 + * SMTP CODE SUCCESS: 500,501,502,421 + * @access public + * @return bool + */ + public function Send($from) { + $this->error = null; // so no confusion is caused + + if(!$this->connected()) { + $this->error = array( + "error" => "Called Send() without being connected"); + return false; + } + + fputs($this->smtp_conn,"SEND FROM:" . $from . $this->CRLF); + + $rply = $this->get_lines(); + $code = substr($rply,0,3); + + if($this->do_debug >= 2) { + echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; + } + + if($code != 250) { + $this->error = + array("error" => "SEND not accepted from server", + "smtp_code" => $code, + "smtp_msg" => substr($rply,4)); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . + ": " . $rply . $this->CRLF; + } + return false; + } + return true; + } + + /** + * Starts a mail transaction from the email address specified in + * $from. Returns true if successful or false otherwise. If True + * the mail transaction is started and then one or more Recipient + * commands may be called followed by a Data command. This command + * will send the message to the users terminal if they are logged + * in and send them an email. + * + * Implements rfc 821: SAML FROM: + * + * SMTP CODE SUCCESS: 250 + * SMTP CODE SUCCESS: 552,451,452 + * SMTP CODE SUCCESS: 500,501,502,421 + * @access public + * @return bool + */ + public function SendAndMail($from) { + $this->error = null; // so no confusion is caused + + if(!$this->connected()) { + $this->error = array( + "error" => "Called SendAndMail() without being connected"); + return false; + } + + fputs($this->smtp_conn,"SAML FROM:" . $from . $this->CRLF); + + $rply = $this->get_lines(); + $code = substr($rply,0,3); + + if($this->do_debug >= 2) { + echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; + } + + if($code != 250) { + $this->error = + array("error" => "SAML not accepted from server", + "smtp_code" => $code, + "smtp_msg" => substr($rply,4)); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . + ": " . $rply . $this->CRLF; + } + return false; + } + return true; + } + + /** + * Starts a mail transaction from the email address specified in + * $from. Returns true if successful or false otherwise. If True + * the mail transaction is started and then one or more Recipient + * commands may be called followed by a Data command. This command + * will send the message to the users terminal if they are logged + * in or mail it to them if they are not. + * + * Implements rfc 821: SOML FROM: + * + * SMTP CODE SUCCESS: 250 + * SMTP CODE SUCCESS: 552,451,452 + * SMTP CODE SUCCESS: 500,501,502,421 + * @access public + * @return bool + */ + public function SendOrMail($from) { + $this->error = null; // so no confusion is caused + + if(!$this->connected()) { + $this->error = array( + "error" => "Called SendOrMail() without being connected"); + return false; + } + + fputs($this->smtp_conn,"SOML FROM:" . $from . $this->CRLF); + + $rply = $this->get_lines(); + $code = substr($rply,0,3); + + if($this->do_debug >= 2) { + echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; + } + + if($code != 250) { + $this->error = + array("error" => "SOML not accepted from server", + "smtp_code" => $code, + "smtp_msg" => substr($rply,4)); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . + ": " . $rply . $this->CRLF; + } + return false; + } + return true; + } + + /** + * This is an optional command for SMTP that this class does not + * support. This method is here to make the RFC821 Definition + * complete for this class and __may__ be implimented in the future + * + * Implements from rfc 821: TURN + * + * SMTP CODE SUCCESS: 250 + * SMTP CODE FAILURE: 502 + * SMTP CODE ERROR : 500, 503 + * @access public + * @return bool + */ + public function Turn() { + $this->error = array("error" => "This method, TURN, of the SMTP ". + "is not implemented"); + if($this->do_debug >= 1) { + echo "SMTP -> NOTICE: " . $this->error["error"] . $this->CRLF; + } + return false; + } + + /** + * Verifies that the name is recognized by the server. + * Returns false if the name could not be verified otherwise + * the response from the server is returned. + * + * Implements rfc 821: VRFY + * + * SMTP CODE SUCCESS: 250,251 + * SMTP CODE FAILURE: 550,551,553 + * SMTP CODE ERROR : 500,501,502,421 + * @access public + * @return int + */ + public function Verify($name) { + $this->error = null; // so no confusion is caused + + if(!$this->connected()) { + $this->error = array( + "error" => "Called Verify() without being connected"); + return false; + } + + fputs($this->smtp_conn,"VRFY " . $name . $this->CRLF); + + $rply = $this->get_lines(); + $code = substr($rply,0,3); + + if($this->do_debug >= 2) { + echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; + } + + if($code != 250 && $code != 251) { + $this->error = + array("error" => "VRFY failed on name '$name'", + "smtp_code" => $code, + "smtp_msg" => substr($rply,4)); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . + ": " . $rply . $this->CRLF; + } + return false; + } + return $rply; + } + + /******************************************************************* + * INTERNAL FUNCTIONS * + ******************************************************************/ + + /** + * Read in as many lines as possible + * either before eof or socket timeout occurs on the operation. + * With SMTP we can tell if we have more lines to read if the + * 4th character is '-' symbol. If it is a space then we don't + * need to read anything else. + * @access private + * @return string + */ + private function get_lines() { + $data = ""; + while($str = @fgets($this->smtp_conn,515)) { + if($this->do_debug >= 4) { + echo "SMTP -> get_lines(): \$data was \"$data\"" . + $this->CRLF; + echo "SMTP -> get_lines(): \$str is \"$str\"" . + $this->CRLF; + } + $data .= $str; + if($this->do_debug >= 4) { + echo "SMTP -> get_lines(): \$data is \"$data\"" . $this->CRLF; + } + // if the 4th character is a space then we are done reading + // so just break the loop + if(substr($str,3,1) == " ") { break; } + } + return $data; + } + +} + + + ?> diff --git a/inc/classes/third_party/php_mailer/docs/extending.html b/inc/classes/third_party/php_mailer/docs/extending.html new file mode 100644 index 00000000..f7c3200a --- /dev/null +++ b/inc/classes/third_party/php_mailer/docs/extending.html @@ -0,0 +1,148 @@ + + +Examples using phpmailer + + + + +

Examples using phpmailer

+ +

1. Advanced Example

+

+ +This demonstrates sending out multiple email messages with binary attachments +from a MySQL database with multipart/alternative support.

+ + + + +
+
+require("class.phpmailer.php");
+
+$mail = new phpmailer();
+
+$mail->From     = "list@example.com";
+$mail->FromName = "List manager";
+$mail->Host     = "smtp1.example.com;smtp2.example.com";
+$mail->Mailer   = "smtp";
+
+@MYSQL_CONNECT("localhost","root","password");
+@mysql_select_db("my_company");
+$query  = "SELECT full_name, email, photo FROM employee WHERE id=$id";
+$result = @MYSQL_QUERY($query);
+
+while ($row = mysql_fetch_array ($result))
+{
+    // HTML body
+    $body  = "Hello <font size=\"4\">" . $row["full_name"] . "</font>, <p>";
+    $body .= "<i>Your</i> personal photograph to this message.<p>";
+    $body .= "Sincerely, <br>";
+    $body .= "phpmailer List manager";
+
+    // Plain text body (for mail clients that cannot read HTML)
+    $text_body  = "Hello " . $row["full_name"] . ", \n\n";
+    $text_body .= "Your personal photograph to this message.\n\n";
+    $text_body .= "Sincerely, \n";
+    $text_body .= "phpmailer List manager";
+
+    $mail->Body    = $body;
+    $mail->AltBody = $text_body;
+    $mail->AddAddress($row["email"], $row["full_name"]);
+    $mail->AddStringAttachment($row["photo"], "YourPhoto.jpg");
+
+    if(!$mail->Send())
+        echo "There has been a mail error sending to " . $row["email"] . "<br>";
+
+    // Clear all addresses and attachments for next loop
+    $mail->ClearAddresses();
+    $mail->ClearAttachments();
+}
+
+
+

+ +

2. Extending phpmailer

+

+ +Extending classes with inheritance is one of the most +powerful features of object-oriented +programming. It allows you to make changes to the +original class for your +own personal use without hacking the original +classes. Plus, it is very +easy to do. I've provided an example: + +

+Here's a class that extends the phpmailer class and sets the defaults +for the particular site:
+PHP include file: mail.inc.php +

+ + + + + +
+
+require("class.phpmailer.php");
+
+class my_phpmailer extends phpmailer {
+    // Set default variables for all new objects
+    var $From     = "from@example.com";
+    var $FromName = "Mailer";
+    var $Host     = "smtp1.example.com;smtp2.example.com";
+    var $Mailer   = "smtp";                         // Alternative to IsSMTP()
+    var $WordWrap = 75;
+
+    // Replace the default error_handler
+    function error_handler($msg) {
+        print("My Site Error");
+        print("Description:");
+        printf("%s", $msg);
+        exit;
+    }
+
+    // Create an additional function
+    function do_something($something) {
+        // Place your new code here
+    }
+}
+
+
+ +Now here's a normal PHP page in the site, which will have all the defaults set +above:
+Normal PHP file: mail_test.php +

+ + + + + +
+
+require("mail.inc.php");
+
+// Instantiate your new class
+$mail = new my_phpmailer;
+
+// Now you only need to add the necessary stuff
+$mail->AddAddress("josh@example.com", "Josh Adams");
+$mail->Subject = "Here is the subject";
+$mail->Body    = "This is the message body";
+$mail->AddAttachment("c:/temp/11-10-00.zip", "new_name.zip");  // optional name
+
+if(!$mail->Send())
+{
+   echo "There was an error sending the message";
+   exit;
+}
+
+echo "Message was sent successfully";
+
+
+

+ + + diff --git a/inc/classes/third_party/php_mailer/docs/faq.html b/inc/classes/third_party/php_mailer/docs/faq.html new file mode 100644 index 00000000..54ac1837 --- /dev/null +++ b/inc/classes/third_party/php_mailer/docs/faq.html @@ -0,0 +1,67 @@ + + +PHPMailer FAQ + + + +
+
+

PHPMailer FAQ

+
    + +
  • Q: I'm using the SMTP mailer and I keep on getting a timeout message + well before the X seconds I set it for. What gives?
    + A: PHP versions 4.0.4pl1 and earlier have a bug in which sockets timeout + early. You can fix this by re-compiling PHP 4.0.4pl1 with this fix: + timeoutfix.diff. Otherwise you can wait for the new PHP release.

  • + +
  • Q: I am concerned that using include files will take up too much + processing time on my computer. How can I make it run faster?
    + A: PHP by itself is very fast. Much faster than ASP or JSP running on + the same type of server. This is because it has very little overhead compared + to its competitors and it pre-compiles all of + its code before it runs each script (in PHP4). However, all of + this compiling and re-compiling can take up a lot of valuable + computer resources. However, there are programs out there that compile + PHP code and store it in memory (or on mmaped files) to reduce the + processing immensely. Two of these: APC + (Alternative PHP Cache) and Afterburner + (Win32 download) + are excellent free tools that do just this. If you have the money + you might also try Zend Cache, it is + even faster than the open source varieties. All of these tools make your + scripts run faster while also reducing the load on your server. I have tried + them myself and they are quite stable too.

  • + +
  • Q: What mailer gives me the best performance?
    + A: On a single machine the sendmail (or Qmail) is fastest overall. + Next fastest is mail() to give you the best performance. Both do not have the overhead of SMTP. + If you have you have your mail server on a another machine then + SMTP is your only option, but you do get the benefit of redundant mail servers.
    + If you are running a mailing list with thousands of names, the fastest mailers in order are: SMTP, sendmail (or Qmail), mail().

  • + +
  • Q: When I try to attach a file with on my server I get a + "Could not find {file} on filesystem error". Why is this?
    + A: If you are using a Unix machine this is probably because the user + running your web server does not have read access to the directory in question. If you are using Windows, + then the problem probably is that you have used single backslashes to denote directories (\). + A single backslash has a special meaning to PHP so these are not + valid. Instead use double backslashes ("\\") or a single forward + slash ("/").

  • + +
+ +
+
+ + + diff --git a/inc/classes/third_party/php_mailer/docs/pop3_article.txt b/inc/classes/third_party/php_mailer/docs/pop3_article.txt new file mode 100644 index 00000000..379c44e8 --- /dev/null +++ b/inc/classes/third_party/php_mailer/docs/pop3_article.txt @@ -0,0 +1,39 @@ +This is built for PHP Mailer 1.72 and was not tested with any previous version. It was developed under PHP 4.3.11 (E_ALL). It works under PHP 5 and 5.1 with E_ALL, but not in Strict mode due to var deprecation (but then neither does PHP Mailer either!). It follows the RFC 1939 standard explicitly and is fully commented. + +With that noted, here is how to implement it: +Install the class file + +I didn't want to modify the PHP Mailer classes at all, so you will have to include/require this class along with the base one. It can sit quite happily in the phpmailer-1.72 directory: +[geshi lang=php] require 'phpmailer-1.72/class.phpmailer.php'; require 'phpmailer-1.72/class.pop3.php'; [/geshi] +When you need it, create your POP3 object + +Right before I invoke PHP Mailer I activate the POP3 authorisation. POP3 before SMTP is a process whereby you login to your web hosts POP3 mail server BEFORE sending out any emails via SMTP. The POP3 logon 'verifies' your ability to send email by SMTP, which typically otherwise blocks you. On my web host (Pair Networks) a single POP3 logon is enough to 'verify' you for 90 minutes. Here is some sample PHP code that activates the POP3 logon and then sends an email via PHP Mailer: +[geshi lang=php] Authorise('pop3.example.com', 110, 30, 'mailer', 'password', 1); $mail = new PHPMailer(); $mail->SMTPDebug = 2; $mail->IsSMTP(); $mail->IsHTML(false); $mail->Host = 'relay.example.com'; $mail->From = 'mailer@example.com'; $mail->FromName = 'Example Mailer'; $mail->Subject = 'My subject'; $mail->Body = 'Hello world'; $mail->AddAddress('rich@corephp.co.uk', 'Richard Davey'); if (!$mail->Send()) { echo $mail->ErrorInfo; } ?> [/geshi] + +The PHP Mailer parts of this code should be obvious to anyone who has used PHP Mailer before. One thing to note - you almost certainly will not need to use SMTP Authentication *and* POP3 before SMTP together. The Authorisation method is a proxy method to all of the others within that class. There are Connect, Logon and Disconnect methods available, but I wrapped them in the single Authorisation one to make things easier. +The Parameters + +The Authorise parameters are as follows: +[geshi lang=php]$pop->Authorise('pop3.example.com', 110, 30, 'mailer', 'password', 1);[/geshi] + + 1. pop3.example.com - The POP3 Mail Server Name (hostname or IP address) + 2. 110 - The POP3 Port on which to connect (default is usually 110, but check with your host) + 3. 30 - A connection time-out value (in seconds) + 4. mailer - The POP3 Username required to logon + 5. password - The POP3 Password required to logon + 6. 1 - The class debug level (0 = off, 1+ = debug output is echoed to the browser) + +Final Comments + the Download + +1) This class does not support APOP connections. This is only because I did not have an APOP server to test with, but if you'd like to see that added just contact me. + +2) Opening and closing lots of POP3 connections can be quite a resource/network drain. If you need to send a whole batch of emails then just perform the authentication once at the start, and then loop through your mail sending script. Providing this process doesn't take longer than the verification period lasts on your POP3 server, you should be fine. With my host that period is 90 minutes, i.e. plenty of time. + +3) If you have heavy requirements for this script (i.e. send a LOT of email on a frequent basis) then I would advise seeking out an alternative sending method (direct SMTP ideally). If this isn't possible then you could modify this class so the 'last authorised' date is recorded somewhere (MySQL, Flat file, etc) meaning you only open a new connection if the old one has expired, saving you precious overhead. + +4) There are lots of other POP3 classes for PHP available. However most of them implement the full POP3 command set, where-as this one is purely for authentication, and much lighter as a result. However using any of the other POP3 classes to just logon to your server would have the same net result. At the end of the day, use whatever method you feel most comfortable with. +Download + +Here is the full class file plus my test script: POP_before_SMTP_PHPMailer.zip (4 KB) - Please note that it does not include PHPMailer itself. + +My thanks to Chris Ryan for the inspiration (even if indirectly, via his SMTP class) diff --git a/inc/classes/third_party/php_mailer/docs/use_gmail.txt b/inc/classes/third_party/php_mailer/docs/use_gmail.txt new file mode 100644 index 00000000..3669f5d2 --- /dev/null +++ b/inc/classes/third_party/php_mailer/docs/use_gmail.txt @@ -0,0 +1,45 @@ +getFile('contents.html'); +$body = eregi_replace("[\]",'',$body); + +$mail->IsSMTP(); +$mail->SMTPAuth = true; // enable SMTP authentication +$mail->SMTPSecure = "ssl"; // sets the prefix to the servier +$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server +$mail->Port = 465; // set the SMTP port + +$mail->Username = "yourname@gmail.com"; // GMAIL username +$mail->Password = "password"; // GMAIL password + +$mail->From = "replyto@yourdomain.com"; +$mail->FromName = "Webmaster"; +$mail->Subject = "This is the subject"; +$mail->AltBody = "This is the body when user views in plain text format"; //Text Body +$mail->WordWrap = 50; // set word wrap + +$mail->MsgHTML($body); + +$mail->AddReplyTo("replyto@yourdomain.com","Webmaster"); + +$mail->AddAttachment("/path/to/file.zip"); // attachment +$mail->AddAttachment("/path/to/image.jpg", "new.jpg"); // attachment + +$mail->AddAddress("username@domain.com","First Last"); + +$mail->IsHTML(true); // send as HTML + +if(!$mail->Send()) { + echo "Mailer Error: " . $mail->ErrorInfo; +} else { + echo "Message has been sent"; +} + +?> diff --git a/inc/classes/third_party/php_mailer/examples/contents.html b/inc/classes/third_party/php_mailer/examples/contents.html new file mode 100644 index 00000000..70c7e307 --- /dev/null +++ b/inc/classes/third_party/php_mailer/examples/contents.html @@ -0,0 +1,12 @@ + +
+

+
+ This is a test of PHPMailer v2.0.0 rc1.
+
+This particular example uses HTML, with a <div> tag and inline
+styles.
+
+Also note the use of the PHPMailer at the top with no specific code to handle +including it in the body of the email.
+ diff --git a/inc/classes/third_party/php_mailer/examples/images/bkgrnd.gif b/inc/classes/third_party/php_mailer/examples/images/bkgrnd.gif new file mode 100644 index 0000000000000000000000000000000000000000..bc89624c05de80022126c3b27698290141cdc2d6 GIT binary patch literal 49 zcmZ?wbhEHbexk!5A4Cd4k3E_4PeQqcbuxzI^%8=i$KufQh)c z#<;jL1fts3*3r@N$?e-!=H@@9r|ZMQSZB_77#UUS>o;X)eig(qxCsVQ5DpfX@FM|F;PMlQLwOVc`*xEH)=9I))n?7oU)rl$?^9mY$KB z#mmm&3vwSk%u6FU9K{!xl$Jd%uc)l5uBm-eSKrXs)cmxiRrutn10nIiQDtpSSYQ9Z zpjh%^=;f>7k zOCNN*L0f)*7QxRW3#D~9cc=D!`EB+!bMguZM492)iS7N^B+f zqv?d4uhL{I3jiJ@}a?ebEV&N2l?xD!>cgC5N7&ckgr ze!>pWvUk2pH#gpukGps*OcS&mz7EkuzC+`$saQYDIE4B7R*pxvYfp zG}>bk2oLYi8{>1!-*4{EW{dF1f+!2KK^~Jt;O22CYrFZudfwjNEH>3@!w#*(JJZGB z25sI8!3B{~IV9Sfk$EgBi_g8b=VTzag3zB;reyAuKlJ&0-hOURk0S);_DvJCHdHGy zmWQBA{d;^}e2i;jw;r#GFvgse*V~`P4GXt&0A$Z@ZogLZPmZ=;xx|=3%zi=Ns%J8m zW45!g^{?q2I^5K+REk?~>CM2YMn5aVY5dOOmdj{4?ZdGjU%129F7Y9nA{~Z&aoY|( zTzVYg)$3RlCx7XBqe@fbXF+%}X&Gx4V$+6GGXCIWEY7T`!R;~A{5Svoh2Msz2G!>G zSy3N~uM7+=Aq;S%;Gf!8Fb8EroUFcfmH8Is_PY=3&S^fw8P43U>-F21<=^V%_v!J7 zI&JIzdV+G|{i>~G>cPh+%2h6992SC@mcwPP`V z`{Zuh`h6RXHMb}o)G5iXH|A-UHKb^b@QycxzuxuRxMmCF>bD4EM#INL&L>yjMk*t? z470WR)%Kejn~>7)5(hn^z^G~a{qhgULuC248xxK9+ma8CElU>f5Z}U@E#Xq|B1ZUx zERaPnG2qE^f7P5?t?3(l8m_5-4zJsDBroPdhIn92klSiQRJa%V5&N;(+7R*<86w7S z!)=G|JzTiSqV(3-_wBh>Uw?2RYdaY8Sp1{V1f-hoI!?|Yw{2V%%Q6`nAu$VWoX>`F zVt0&V4bO2`-&bIEXoVL&4%qpzY(UYZxnrGougO4y2vtFas=_Lt9al+kgkNI7)d=mw zukKxJZIa{(B=}ha&1k0JB{;k)bll(+sh@lVtzBueT`%ftdVI>(gfkmv&%%Spo8%Vc zDscygKT9!t?+c9V@x&+F{vloQ>DaO7tFc$Igq2LmonaHZ?G|UkZWW)SUwDt8V&0^x z^=f{zScsWP*~aN>{cC=SXR4WgE8%!{^b3T0ycGgG(bd}k6?(u00s(GA|lPBBr zpL?lf`em(_UvR}6LkZW69%>aP^_F4mf_?|iYy3%WaR9_g?J>vjvewT%#FeyOm5x>v z$1y~8CKtuUn=8};LG8}WWqOC)^6>NaDWmMX;(oO5{L#0UA-VlAqx#6Nsf3@^e#qmV zKWUMFX7!dX2bNf9B8_xetR%0X|IXzf(+)W7; zz?CZJ82Ech!h`meEN_IJ+Wphc*GX0FZ<352-;5h-56RccFET7EI_=Y-ef~uMG2>@x z-M%re$Z1=<&PO*u&Guh|?ecr@PsInsv%`naMmp}YDZh2H>DFL{rvIGFZuB|Qx+)+1 z(|ImCWh=%Q2ujQ7-(c1~%=CU^9`-4FOUA9C#SI3&l&c9=Ls*n3xQF(rOfOH=^ypCXnw7lj`haHgxR9SB=!NR_DWaXE{M8 zYs$lpg!|=oUu{_%F2|;R3TfLKtE88L`Oeg~Af;oJw|+;NZ|4&xO2jMj?J^1j%Xei| zy7V-b9C{}{Bs?8)u6U8wI`pZKU9{Nc(_GU7BQ9HNRlIrrhSIj+AL)PZz;*kj3|pPf zui$G(Mzhcf&570mxzEdkIEX3+w1=OK4PlzAgxidfHj-&*Lm8{?$vqR-T$s z?df(uQ_}EmUJ0Wff8uV|w6(Xnl<<`BJhG*8=sgjx^zzPaIeG3Ru|J2}l94i6Tq4aB zpYP2#dAALouRDdXh+bAZ)^fZY_Z9E1fQ&$jt|s3Zp5^TN{czOAlxIsnNG`1um+pjT z4;3#!Z@5-I_u-e6xp4laTujH;_~UdMUHqa`BsctxP2trXGl^vE-U&oXS84w-t@-IA zn+UriXbfg=ckj8I$!SMl-<;Yn?3InpPIDPpPHkGB!}AqHwUU|yzVBS)6sE6<_a^C! z#k=y1Ux}_ceuk+u9pXu|a~6-kKQh0(+cBi^Wr1E|q4S>)u5s*F)dN2sLvMU^Q)n8U z0)JL!{aGBxn~#qS1YH02B2Unz2FDod_ z3*7j~V6{bK273Z z@O#V`^w3vb|FICv312ti*Fs4D=~g^=dDa3?&)p8{Y-2wws-ppK;*&l(Vb zSUkH=0AfU8FcQ1YlXiF&qUsKAp5dITr$-R!2Kr15RFu;K#ShQ%?+UttrVg!yrHc@~ zD_{;jh~^6B%|~kKQ|l9%;tHmYK3&h1u`+@vfFn&75G~{=Eff?h1T)Ei!A!(U0+~Y$ z?^_B2MU0^Wn*5R!noI_@;{PimH_nI2iI8P5TFVGTLmVM5hFnDlOI%~7$Y3%BIK-gn zT0yAu)B;w_>?%|T1s$KKo*{;QNspK3Fy@GmYwUO#FB)eRcuR;)UWru|2A3582MOeN z>7b}9L_`5v(>Yr1399bF1|)DZ0Kp0XWA7-=B-8b&kn4n73XbeDp5Wh5#S zAy@`IZ-jb(HM*q`sAXUIY>KRfMa~l$4W99`^(-y@6m~kz7!C<2prx~7BGLlU2SSM5 z2z{@xsdHCX~$E^_0Q+Ovd}T zoVw&e_pD)dusQ%q-4m+KX2xkDzo5D6PzR`4bLiA;? z>{lH2vI~e6r`)k)a5&+%B191;`#UH2*RNFH4RK&p!u8dRiP7|9>|l{gYQbuv(P)eb zo{mLBc?}oaikN&m8b6T#N*vQ4pCjhPydVaNTysY<1a@d?>=g?2M_N2=4ZxrTY74P@ zymP*Da_E8CJ%K?>oY4L>{&yEXFOau7MxS1R_=)%&V%&TI5N0aqSb3;I5iA|ZLyQM) zqJ~`T$!D{Jr$-+6j3M4FQ1J(t^QJk*q7aP>Nf*udH+IF8k{<+c9-MA`poQk|(fpc(rnTb4MhcPH1v~e$pE(GHno5)${JY8Vg(=v z_LlCoM`G*q^X4D0)#9h^xFbEO0mUU&Xldx$7U;pXl(7Q({0dm|3zAw-HqZ~Aa?0tl zEA?B6M*oUdBPCrOgKQQdZV?&S_=qEGd51{g7Wd#HvwWCSuo|hNhn3Oe8E!86&ox=H zl0C)>hEph;ixO3rKu|64mp8av$2z_W1#gFHh(cblqhXEAmNZ@xr#v42Ae2+EP?xD* z5nk~t<=jHRPI;uRei&zjVKYG{xFY*tOs8~CPFJ+?C|Pl}P#qPBK?QDJ3X@e9siSWStD?DTG(pySN!k)tieVuyAR7rD^KWO5$tpXgD$91R)uN4x~Gfoe6buaAr{&NOY}t8?B2X zP(RqmezJ@3O9S6#a)|K86gbm7I_Lh#0fV00rM;+W zL+GA_rXLke;uTJqcHxMAvzsTlV=Zw55v2(L(LuO3^32xOJEowW`{rjrHQf$+>J_!Nt|?nI03w>b5H4H&*Sx;3iaM9i{6?`y-(=9^}OE3=HBMX-j?-Vp-(Tu9jb^D eA;^6qUSCghU*BZkzwjaBy(X&(Fa?KtMo1zP`S(Ffh80kLtg_wO?PaBqX+LYpo0nw|955M@PM~ zvb?6I`tR?uJ3F|8gRU4Du@DfvFfi}W&$Lrh%V1!;nwsFBpY`A0wjdzekB`uBaOJPB z#!yhI008*-_@n>;m;eBu005={0E_?tfdBxrv$J>r0N2;ohX4Tl{QU6n@caAw;Nalm z;^NfQ)bH=_b8~ai(b1lso|ToAe}8|c003qP2u&CmK|w)kYHEapgut(_WMpJhQ&V~% zAV(Y=ejp%6M@LLdOq+0U&A-2uU|^V-m|tICMMXto2ncQz6h$;NLNPH_M@M)X8i`(B zgilXBFff#9X-gOwL_|b*9v+imV6UN}l!k^|C@5_c6FxC9V+jeRl$2`?4SgOShg4KO zEG%U@I#enuXEHL%yu6Hidy`&XSt_Uz0000MbVXQnQ*UN;cVTj60B31tGH`BZATlmA zE-+0{CL#a;3;Rh#K~#9!?VV?vn>rSNA-D z0)eryGrqf=Co^Oy($R}fk;DTW-^k;e{>YFb=IltD+Msohimv0zQzxe3#=CbObP=9@Lv&Yg^Zl3)0Mgi*QC(n8&-R0TIPj2K; zzc}st>2~_+>2GdiP(M2Ed2C0Hzkl~u0`<*hAEUMvtuFulAc6Xyqn^gL~;+Gytn@C+5h>Idok2&J&WzhwWk*>r~_(lK$gb?fjTay!r0}Ck5C%!_}qm4(cawdYHiVjY)mgccpq*RIy2U{akW|Bi zpz7y#1vT#}8$umW9c=@s)l@$#auKv~tFtW94r+j;U35NcNZ$VUq2^sKbCyDj(dle? zFG?OaW4Wl>|K3BLcZGUT)=0>RHMrG`yUfz9*puzt(FN}T>SRkkRp{zd2UVz9>GG=4 zDH+k#K%L~bENkg>=THS^R@@$HrfH%oBST&VbzB*K6rc_#&2BaIy0*{NLG_o0bWpUZ zjiC;fQb%PPu!mG_q0Z^SL&H304OE}!%N?iyH9ssgj!qX`E!0AInpf<<<1m#;#b3+r|4g+!558se!goWzzd+@}!)iw}v{2 z?MDt+IXk`Qpw_Jlbc7qQf`eZ?XHquG9YZbmgmq`B2Hbj3o2JR=D{9?p7WlJiOD5D= zk>j|WXY3fN&~553;5tIJr*%;CO9b}lG{2Gwm5TVIviZs$)|F9!e+pkT+8q9+| z46N!2YU|KmZu>8}Abkm*~pHq?ncTh#W6RZE%l(kTO~ zUw7SNMm8uv!Tuzk2FlFLBnn)sV6*hzU)e&QfmprV7zkOe`fnk zr~#{OlVZwK3w16OWmq#w4KiX-8P(0GTp`rrT0tA8B;)ccOOS<5DX^xk;^15hwVDkJ z4U=nSDsoM-x*t&6F-@tKq0XBh^qaSaYIAEs6&N!U`vWy-``9m`T80`h7vJ)A1-UiU zgLR=UJs2IU_5$iSX#IdXP%S~7)?_y0!lY_DsDrhkPHkqaxH4O_^-45z-eW=3;Yg|M+ z$xwJ&OhuZ@*jPqXF%?xuOC_hYa_qY2l;W(q7*vEox#)VRy>yWtY7e!C+C%M8^iX@K zJ=9+QkDz)U$0^!(7^)^oO0tcAX`ClX-s-{}hg0+=1yY8gwx{Mc9*#mz6P2u{RmEyp zXh>~Pb5g2*2_qcGEila)*_ILXpf)LND7QjfI9k;?6a zqmG&Vg;y0DiXn&GO{ush#%tXK!)pT-&NERFD(7J_tqAE7yW>hyd~z(RDG@w)9jM8r z*n(eTxu+PgSJzuZ)eMb8Xj7;NuXnyAYOSC`6GRFs7$Bmm#D;-F4I>Ad5V|gG44jkk zL?ds#q#_k6H4xcIF4C16%^VD+NXWtx7In-SVd#dLwgjlFRVYSvR2M3e zTu*lu$JMp0HV=*xsGg26sZ?=eeH?_yIgYM7}q-i0!Op7m;EQBSp1CC3& zgA`~b=%jH@+)Q%MR4I%-1T@EhN<_-lG(j~>P%RoN5-s=_xnP%;gHSbXNYQuJWq5(SE_+3A|xsVssd0$Qh^TU!Wo2v3I1Bt;2a$heN0ogz!|_LI&^BX z+pcxGHTDcXyxz@h6ARdix@L|53VB3yt>Y#CY<;V6osdawhT3N%DS zT4Z7q++j$rOOzMINQZtSiMlFc0@Y~&Rf5i1l9ClhKIw=*_vQVg;*Xg~Bg_yd4)At@eouyiO4JS%y>~^5G94ayqil9TJT1n9Np?2b$2)_&}%Jjuzd^&+@kR2!qD;}Jr z!|egnL?+6u6@E-8-xAwGEo^i1FS+poR4Z~M8mdt=e=O+)f^I=;JT+ow4mD7@w7fK- ziqFxTphDOuwPjE(4C3YCQ-a#V7%JJtfEu4pS{N3fLTkjhr3j816x4`ZuoI|KY@ZZV z%~Ug}V4hjDw&E*w)E+9aK2J#!Dl0uFaw({)S%gY1LOE2`)bgUe#PLA5CAyK*iH)UD zlTMID0+dGFD20lwxK(MJNI@x76j8joKuvDg5~?Dq;Bk$lF{yDIqU&JGgMX^%IHsjx zEIDH6fa|c_W~dhAYtXyFmtqIP25glqp_0VN!72C{s%aP|E<$xp$AH>msFvo5$ieBY zHbpN~B?nGdP0&auJx_|jE0e-B6G^VBnUQ0FCnw0PNDAXnltz&VTs9~KS%j5%UGf7# zSW=1Ob(ED*6;#+NFbXh=oeLZ&WJjC|_YLw14i008yl%Wlb2DNN0&CG6WN0q9V^e{@ z;Z7^AnGYgLLh2!fDVAw~{t-ZNMK_LeUXoA|kgjDJ$v}-LCq|K}E>$#01(07@Ub2TI zXb65MMT1{QCJ9oSYKkPIFkqvr$*50p5!400Nv5P4WJerUNG%>V;AXhwrXk&f$mGRm zkRQm=AeqsSs4}4L<69{U$$OGeEe8mhi1>Xd5~nOy>+#w3^Azfj5BC|WhqR-`l_K-}Ap6xq14Bx9K~n@7(`;|3!*z$g`7=KYN|NJ)M7W_PhSu zDO>2LC%^dS)mi$UfBx3p$N%WR^3yd&9iM*u%da12U!>sq8y8>w=#TyPs5%fmJi7e$ zXWxAN)kXg86hig!s~^00-hVl5(=VqzfAP1MpS^l~vHZ#pp?df1_1kx!zWiP<8_CO0 z-@Sc(cDMLFD&kik+&_Er^x+4+Y$Ok#J~_Mpfc|nCkvq5VT|D}*myP7n#l72imM>o6 gd)d15PQ7s?<@S(b!Mg+*99Zt_S)X2sM8 zY6#>rQ}5oCd1yLWBS>vengia{43J__iUKvA9G(fcYGIi^1Ize3x2@YndQV!Rd1uI@ z0|rn+Iv8oM7=+lg|rL5G907GeCPGaUMVu8 zajG&HZ@0r16-O&zrEyobPs}o`B2}^(1XmI}=G&KwX3u5nRyX3RPp<^URVQrYuFf%E6kqemwY0Kss(X+{f%9HjyERn}LRuIc(2 z_b1+|g{P9(T;cXp(u+e7*!=kS+#669m$E*5NG7S|l1wi7-GbfVC}m+%PI+9FI97B7TbBXwLdKYe z>9wVoVnSKwnqh+3CYx`@=_Z?L!U<-YT7ISHo^@`)!@X(sBXqGbX~ zD4=%+S_hwb(uqc-jkfuypp2qv=9g-QX~v>$jq0bSnD#m6o^@6#DV&7932CBds>-LN zbuQD4ov^Oj>948sYO609JQAy%b;b&;t%I6+>8)bcaKZ(TU@7GeF_1t39oD*dLkk}e z5rGFOyf6a}I;5*F?z-%@>+ZYo#`|s#Hpt+D2u4W2K?o+Kpu!3O2Q2Ww1Q%@Z!3YThe example file "test_mail.php" contents include:

+
+ +<?php
+
+include_once('../class.phpmailer.php');
+
+$mail = new PHPMailer();
+
+$body = $mail->getFile('contents.html');
+
+$body = eregi_replace("[\]",'',$body);
+$subject = eregi_replace("[\]",'',$subject);
+
+$mail->From = "name@yourdomain.com";
+$mail->FromName = "First Last";
+
+$mail->Subject = "PHPMailer Test Subject";
+
+$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
+
+$mail->MsgHTML($body);
+
+$mail->AddAddress("whoto@otherdomain.com", "John Doe");
+
+if(!$mail->Send()) {
+ echo 'Failed to send mail';
+} else {
+ echo 'Mail sent';
+}
+
+?> +
+
+
+Although you could use full compabitility with PHPMailer 1.7.3, this example +shows how to use the new features. If you view 'contents.html', you will note +that there is a background image used in the <body tag as well as an image used +with a regular <img tag. Here's what the HTML file looks like:
+
+
+ +<body background="images/bkgrnd.gif" style="margin: 0px;">
+<div style="width: 640px; font-family: Arial, Helvetica, sans-serif; font-size: 11px;">
+<div align="center"><img src="images/phpmailer.gif" style="height: 90px; width: 340px"></div><br>
+<br>
+ This is a test of PHPMailer v2.0.0 rc1.<br>
+<br>
+This particular example uses <strong>HTML</strong>, with a <div> tag and inline<br>
+styles.<br>
+<br>
+Also note the use of the PHPMailer at the top with no specific code to handle
+including it in the body of the email.</div>
+</body>
+
+
+
+A few things to notice in the PHP script that generates the email: +
    +
  • the use of $mail->AltBody is completely optional. If not used, PHPMailer + will use the HTML text with htmlentities().
  • +
  • the background= and <img src= images were processed without any directives + or methods from the PHP script
  • +
  • there is no specific code to define the image type ... that is handled + automatically by PHPMailer when it parses the images
  • +
  • we are using a new class method '$mail->MsgHTML($body)' ... that is what will handle the parsing of the images and creating the AltBody text
  • +
+

Of course, you can still use PHPMailer the same way you have in the past. +That provides full compatibility with all existing scripts, while new scripts +can take advantage of the new features.

+

Modify test_mail.php now with your own email address and try it out.

+To see what the email SHOULD look like in your HTML compatible email viewer: click here
+ diff --git a/inc/classes/third_party/php_mailer/examples/pop3_before_smtp_test.php b/inc/classes/third_party/php_mailer/examples/pop3_before_smtp_test.php new file mode 100644 index 00000000..794b2a26 --- /dev/null +++ b/inc/classes/third_party/php_mailer/examples/pop3_before_smtp_test.php @@ -0,0 +1,39 @@ + + +POP before SMTP Test + + + + +
+Authorise('pop3.example.com', 110, 30, 'mailer', 'password', 1);
+
+  $mail = new PHPMailer();
+
+  $mail->IsSMTP();
+  $mail->SMTPDebug = 2;
+  $mail->IsHTML(false);
+
+  $mail->Host     = 'relay.example.com';
+
+  $mail->From     = 'mailer@example.com';
+  $mail->FromName = 'Example Mailer';
+
+  $mail->Subject  =  'My subject';
+  $mail->Body     =  'Hello world';
+  $mail->AddAddress('name@anydomain.com', 'First Last');
+
+  if (!$mail->Send())
+  {
+    echo $mail->ErrorInfo;
+  }
+?>
+
+ + + diff --git a/inc/classes/third_party/php_mailer/examples/test_gmail.php b/inc/classes/third_party/php_mailer/examples/test_gmail.php new file mode 100644 index 00000000..4592efc1 --- /dev/null +++ b/inc/classes/third_party/php_mailer/examples/test_gmail.php @@ -0,0 +1,50 @@ +getFile('contents.html'); +$body = eregi_replace("[\]",'',$body); + +$mail->IsSMTP(); +$mail->SMTPAuth = true; // enable SMTP authentication +$mail->SMTPSecure = "ssl"; // sets the prefix to the servier +$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server +$mail->Port = 465; // set the SMTP port for the GMAIL server + +$mail->Username = "yourusername@gmail.com"; // GMAIL username +$mail->Password = "yourpassword"; // GMAIL password + +$mail->AddReplyTo("yourusername@gmail.com","First Last"); + +$mail->From = "name@yourdomain.com"; +$mail->FromName = "First Last"; + +$mail->Subject = "PHPMailer Test Subject via gmail"; + +//$mail->Body = "Hi,
This is the HTML BODY
"; //HTML Body +$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test +$mail->WordWrap = 50; // set word wrap + +$mail->MsgHTML($body); + +$mail->AddAddress("whoto@otherdomain.com", "John Doe"); + +$mail->AddAttachment("images/phpmailer.gif"); // attachment + +$mail->IsHTML(true); // send as HTML + +if(!$mail->Send()) { + echo "Mailer Error: " . $mail->ErrorInfo; +} else { + echo "Message sent!"; +} + +?> diff --git a/inc/classes/third_party/php_mailer/examples/test_mail.php b/inc/classes/third_party/php_mailer/examples/test_mail.php new file mode 100644 index 00000000..e87056e9 --- /dev/null +++ b/inc/classes/third_party/php_mailer/examples/test_mail.php @@ -0,0 +1,29 @@ +getFile('contents.html'); +$body = eregi_replace("[\]",'',$body); + +$mail->From = "name@yourdomain.com"; +$mail->FromName = "First Last"; + +$mail->Subject = "PHPMailer Test Subject via mail()"; + +$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test + +$mail->MsgHTML($body); + +$mail->AddAddress("whoto@otherdomain.com", "John Doe"); + +$mail->AddAttachment("images/phpmailer.gif"); // attachment + +if(!$mail->Send()) { + echo "Mailer Error: " . $mail->ErrorInfo; +} else { + echo "Message sent!"; +} + +?> diff --git a/inc/classes/third_party/php_mailer/examples/test_sendmail.php b/inc/classes/third_party/php_mailer/examples/test_sendmail.php new file mode 100644 index 00000000..38eb78d5 --- /dev/null +++ b/inc/classes/third_party/php_mailer/examples/test_sendmail.php @@ -0,0 +1,37 @@ +getFile('contents.html'); +$body = eregi_replace("[\]",'',$body); + +$mail->IsSendmail(); // telling the class to use SendMail transport + +$mail->From = "name@yourdomain.com"; +$mail->FromName = "First Last"; + +$mail->Subject = "PHPMailer Test Subject via smtp"; + +$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test + +$mail->MsgHTML($body); + +$mail->AddAddress("whoto@otherdomain.com", "John Doe"); + +$mail->AddAttachment("images/phpmailer.gif"); // attachment + +if(!$mail->Send()) { + echo "Mailer Error: " . $mail->ErrorInfo; +} else { + echo "Message sent!"; +} + +?> diff --git a/inc/classes/third_party/php_mailer/examples/test_smtp.php b/inc/classes/third_party/php_mailer/examples/test_smtp.php new file mode 100644 index 00000000..bc46c672 --- /dev/null +++ b/inc/classes/third_party/php_mailer/examples/test_smtp.php @@ -0,0 +1,39 @@ +getFile('contents.html'); +$body = eregi_replace("[\]",'',$body); + +$mail->IsSMTP(); // telling the class to use SMTP +$mail->Host = "mail.worxteam.com"; // SMTP server + +$mail->From = "name@yourdomain.com"; +$mail->FromName = "First Last"; + +$mail->Subject = "PHPMailer Test Subject via smtp"; + +$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test + +$mail->MsgHTML($body); + +$mail->AddAddress("whoto@otherdomain.com", "John Doe"); + +$mail->AddAttachment("images/phpmailer.gif"); // attachment + +if(!$mail->Send()) { + echo "Mailer Error: " . $mail->ErrorInfo; +} else { + echo "Message sent!"; +} + +?> diff --git a/inc/classes/third_party/php_mailer/language/.htaccess b/inc/classes/third_party/php_mailer/language/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/third_party/php_mailer/language/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/third_party/php_mailer/language/phpmailer.lang-br.php b/inc/classes/third_party/php_mailer/language/phpmailer.lang-br.php new file mode 100644 index 00000000..601d3b81 --- /dev/null +++ b/inc/classes/third_party/php_mailer/language/phpmailer.lang-br.php @@ -0,0 +1,24 @@ + + diff --git a/inc/classes/third_party/php_mailer/language/phpmailer.lang-ca.php b/inc/classes/third_party/php_mailer/language/phpmailer.lang-ca.php new file mode 100644 index 00000000..dbb22985 --- /dev/null +++ b/inc/classes/third_party/php_mailer/language/phpmailer.lang-ca.php @@ -0,0 +1,24 @@ + diff --git a/inc/classes/third_party/php_mailer/language/phpmailer.lang-cz.php b/inc/classes/third_party/php_mailer/language/phpmailer.lang-cz.php new file mode 100644 index 00000000..ae82d2d0 --- /dev/null +++ b/inc/classes/third_party/php_mailer/language/phpmailer.lang-cz.php @@ -0,0 +1,26 @@ + diff --git a/inc/classes/third_party/php_mailer/language/phpmailer.lang-de.php b/inc/classes/third_party/php_mailer/language/phpmailer.lang-de.php new file mode 100644 index 00000000..53c20e13 --- /dev/null +++ b/inc/classes/third_party/php_mailer/language/phpmailer.lang-de.php @@ -0,0 +1,26 @@ + + diff --git a/inc/classes/third_party/php_mailer/language/phpmailer.lang-dk.php b/inc/classes/third_party/php_mailer/language/phpmailer.lang-dk.php new file mode 100644 index 00000000..fe60f314 --- /dev/null +++ b/inc/classes/third_party/php_mailer/language/phpmailer.lang-dk.php @@ -0,0 +1,26 @@ + + */ + +$PHPMAILER_LANG = array(); + +$PHPMAILER_LANG["provide_address"] = 'Du skal indtaste mindst en ' . + 'modtagers emailadresse.'; +$PHPMAILER_LANG["mailer_not_supported"] = ' mailer understøttes ikke.'; +$PHPMAILER_LANG["execute"] = 'Kunne ikke køre: '; +$PHPMAILER_LANG["instantiate"] = 'Kunne ikke initialisere email funktionen.'; +$PHPMAILER_LANG["authenticate"] = 'SMTP fejl: Kunne ikke logge pÃ¥.'; +$PHPMAILER_LANG["from_failed"] = 'Følgende afsenderadresse er forkert: '; +$PHPMAILER_LANG["recipients_failed"] = 'SMTP fejl: Følgende' . + 'modtagere er forkerte: '; +$PHPMAILER_LANG["data_not_accepted"] = 'SMTP fejl: Data kunne ikke accepteres.'; +$PHPMAILER_LANG["connect_host"] = 'SMTP fejl: Kunne ikke tilslutte SMTP serveren.'; +$PHPMAILER_LANG["file_access"] = 'Ingen adgang til fil: '; +$PHPMAILER_LANG["file_open"] = 'Fil fejl: Kunne ikke Ã¥bne filen: '; +$PHPMAILER_LANG["encoding"] = 'Ukendt encode-format: '; +$PHPMAILER_LANG["signing"] = 'Signing Error: '; + +?> diff --git a/inc/classes/third_party/php_mailer/language/phpmailer.lang-en.php b/inc/classes/third_party/php_mailer/language/phpmailer.lang-en.php new file mode 100644 index 00000000..f7d4286d --- /dev/null +++ b/inc/classes/third_party/php_mailer/language/phpmailer.lang-en.php @@ -0,0 +1,25 @@ + diff --git a/inc/classes/third_party/php_mailer/language/phpmailer.lang-es.php b/inc/classes/third_party/php_mailer/language/phpmailer.lang-es.php new file mode 100644 index 00000000..bebf632f --- /dev/null +++ b/inc/classes/third_party/php_mailer/language/phpmailer.lang-es.php @@ -0,0 +1,25 @@ + diff --git a/inc/classes/third_party/php_mailer/language/phpmailer.lang-et.php b/inc/classes/third_party/php_mailer/language/phpmailer.lang-et.php new file mode 100644 index 00000000..3fd55953 --- /dev/null +++ b/inc/classes/third_party/php_mailer/language/phpmailer.lang-et.php @@ -0,0 +1,24 @@ + diff --git a/inc/classes/third_party/php_mailer/language/phpmailer.lang-fi.php b/inc/classes/third_party/php_mailer/language/phpmailer.lang-fi.php new file mode 100644 index 00000000..e2bb497a --- /dev/null +++ b/inc/classes/third_party/php_mailer/language/phpmailer.lang-fi.php @@ -0,0 +1,25 @@ + diff --git a/inc/classes/third_party/php_mailer/language/phpmailer.lang-fo.php b/inc/classes/third_party/php_mailer/language/phpmailer.lang-fo.php new file mode 100644 index 00000000..13b136fc --- /dev/null +++ b/inc/classes/third_party/php_mailer/language/phpmailer.lang-fo.php @@ -0,0 +1,27 @@ + diff --git a/inc/classes/third_party/php_mailer/language/phpmailer.lang-fr.php b/inc/classes/third_party/php_mailer/language/phpmailer.lang-fr.php new file mode 100644 index 00000000..8ef292a5 --- /dev/null +++ b/inc/classes/third_party/php_mailer/language/phpmailer.lang-fr.php @@ -0,0 +1,26 @@ + + diff --git a/inc/classes/third_party/php_mailer/language/phpmailer.lang-hu.php b/inc/classes/third_party/php_mailer/language/phpmailer.lang-hu.php new file mode 100644 index 00000000..8eafba76 --- /dev/null +++ b/inc/classes/third_party/php_mailer/language/phpmailer.lang-hu.php @@ -0,0 +1,25 @@ + diff --git a/inc/classes/third_party/php_mailer/language/phpmailer.lang-it.php b/inc/classes/third_party/php_mailer/language/phpmailer.lang-it.php new file mode 100644 index 00000000..2fb6a5d2 --- /dev/null +++ b/inc/classes/third_party/php_mailer/language/phpmailer.lang-it.php @@ -0,0 +1,30 @@ + +*/ + +$PHPMAILER_LANG = array(); + +$PHPMAILER_LANG["provide_address"] = 'Deve essere fornito almeno un'. + ' indirizzo ricevente'; +$PHPMAILER_LANG["mailer_not_supported"] = 'Mailer non supportato'; +$PHPMAILER_LANG["execute"] = "Impossibile eseguire l'operazione: "; +$PHPMAILER_LANG["instantiate"] = 'Impossibile istanziare la funzione mail'; +$PHPMAILER_LANG["authenticate"] = 'SMTP Error: Impossibile autenticarsi.'; +$PHPMAILER_LANG["from_failed"] = 'I seguenti indirizzi mittenti hanno'. + ' generato errore: '; +$PHPMAILER_LANG["recipients_failed"] = 'SMTP Error: I seguenti indirizzi'. + 'destinatari hanno generato errore: '; +$PHPMAILER_LANG["data_not_accepted"] = 'SMTP Error: Data non accettati dal'. + 'server.'; +$PHPMAILER_LANG["connect_host"] = 'SMTP Error: Impossibile connettersi'. + ' all\'host SMTP.'; +$PHPMAILER_LANG["file_access"] = 'Impossibile accedere al file: '; +$PHPMAILER_LANG["file_open"] = 'File Error: Impossibile aprire il file: '; +$PHPMAILER_LANG["encoding"] = 'Encoding set dei caratteri sconosciuto: '; +$PHPMAILER_LANG["signing"] = 'Signing Error: '; + +?> diff --git a/inc/classes/third_party/php_mailer/language/phpmailer.lang-ja.php b/inc/classes/third_party/php_mailer/language/phpmailer.lang-ja.php new file mode 100644 index 0000000000000000000000000000000000000000..2e188eb6bd02c4aad31aaae571b0448971236451 GIT binary patch literal 2672 zcmcJR?MqZa6vm&=`&V2fu!5An_KJnQNQR^Z5wR@0>PoIIyKCj2f_9QlRy{-?_8bi@VFkC1ZH*%$+-D=9%ZrIdgSH$CXtY#MG?)l$bo8o;q{} zv@4-L^{ZPs`ucerP_Krld+GDkQ~uhtW!J{HtUs<>d4J3$-#X98L9B!MPiPqXc6tkp z8-hb0YYftNnP=XAPce_D10c<)0`ne%WwSD6s{%7$QiKME4end3REz1pY4 zJFvT=2KHjRy$*vET;kZLC^_1BN`tO4b69MhMlEVm<9ZIPeg?kkAkQZ%>WfCSK)nV= z!3tOhb9~>x)+_HUoO8EYjhfdxIQ(EGTWyWCC-hQpX-|MrVBbE2IarRt##D;d)-=kX zN^tt(cxn*8#ZhMn^|HL>d_ShjYB`NO_8e&O-Pgoe6g3Mzl{GTuX2Cjm3al8rd9Ya* z!*1QgV@Vjg)S=KFhzK2(|j`i^C@uM=sDeKufd%^jt^rnmcMxt&64zF~oY+D_FCG>rRlHV9- zr8+9=@wMfMBtFgpr(-^XZ?uL1_XYjI|M%F-DjHYjkCJ~9|7Ql-O?~Xvut*3qMgqN( zXqEM&V!J=1^(k_;TwY!B{bo9iYnlxA+ONksk1mh=du-S(Hb61&TAoYuZZTaut3>k- zW99??oCB8gO2qa@vd;|d-HaKRqwNlJI@h|vg6MI)i|AKG*&fvcIY`#ws&-Ql}#WKh_E5zvw zylH;}j^ifvO!=%X(;frXH&xd?Vt;A9u-FNcfJ^5#8;^e^`yaB~IaDFWf95g8{sO9< B6W;&; literal 0 HcmV?d00001 diff --git a/inc/classes/third_party/php_mailer/language/phpmailer.lang-nl.php b/inc/classes/third_party/php_mailer/language/phpmailer.lang-nl.php new file mode 100644 index 00000000..262b543a --- /dev/null +++ b/inc/classes/third_party/php_mailer/language/phpmailer.lang-nl.php @@ -0,0 +1,25 @@ + diff --git a/inc/classes/third_party/php_mailer/language/phpmailer.lang-no.php b/inc/classes/third_party/php_mailer/language/phpmailer.lang-no.php new file mode 100644 index 00000000..9a253415 --- /dev/null +++ b/inc/classes/third_party/php_mailer/language/phpmailer.lang-no.php @@ -0,0 +1,25 @@ + diff --git a/inc/classes/third_party/php_mailer/language/phpmailer.lang-pl.php b/inc/classes/third_party/php_mailer/language/phpmailer.lang-pl.php new file mode 100644 index 00000000..e2f86ff1 --- /dev/null +++ b/inc/classes/third_party/php_mailer/language/phpmailer.lang-pl.php @@ -0,0 +1,25 @@ + diff --git a/inc/classes/third_party/php_mailer/language/phpmailer.lang-ro.php b/inc/classes/third_party/php_mailer/language/phpmailer.lang-ro.php new file mode 100644 index 00000000..33502171 --- /dev/null +++ b/inc/classes/third_party/php_mailer/language/phpmailer.lang-ro.php @@ -0,0 +1,25 @@ + + */ + +$PHPMAILER_LANG = array(); + +$PHPMAILER_LANG["provide_address"] = 'Trebuie sa adaugati cel putin un recipient (adresa de mail).'; +$PHPMAILER_LANG["mailer_not_supported"] = ' mailer nu este suportat.'; +$PHPMAILER_LANG["execute"] = 'Nu pot executa: '; +$PHPMAILER_LANG["instantiate"] = 'Nu am putut instantia functia mail.'; +$PHPMAILER_LANG["authenticate"] = 'Eroare SMTP: Nu a functionat autentificarea.'; +$PHPMAILER_LANG["from_failed"] = 'Urmatoarele adrese From au dat eroare: '; +$PHPMAILER_LANG["recipients_failed"] = 'Eroare SMTP: Urmatoarele adrese de mail au dat eroare: '; +$PHPMAILER_LANG["data_not_accepted"] = 'Eroare SMTP: Continutul mailului nu a fost acceptat.'; +$PHPMAILER_LANG["connect_host"] = 'Eroare SMTP: Nu m-am putut conecta la adresa SMTP.'; +$PHPMAILER_LANG["file_access"] = 'Nu pot accesa fisierul: '; +$PHPMAILER_LANG["file_open"] = 'Eroare de fisier: Nu pot deschide fisierul: '; +$PHPMAILER_LANG["encoding"] = 'Encodare necunoscuta: '; +$PHPMAILER_LANG["signing"] = 'Signing Error: '; + +?> diff --git a/inc/classes/third_party/php_mailer/language/phpmailer.lang-ru.php b/inc/classes/third_party/php_mailer/language/phpmailer.lang-ru.php new file mode 100644 index 00000000..2e1b1483 --- /dev/null +++ b/inc/classes/third_party/php_mailer/language/phpmailer.lang-ru.php @@ -0,0 +1,26 @@ + + */ + +$PHPMAILER_LANG = array(); + +$PHPMAILER_LANG["provide_address"] = 'Ïîæàëóéñòà, ââåäèòå õîòÿ áû îäèí àäðåñ e-mail ' . + 'ïîëó÷àòåëÿ.'; +$PHPMAILER_LANG["mailer_not_supported"] = ' - ïî÷òîâûé ñåðâåð íå ïîääåðæèâàåòñÿ.'; +$PHPMAILER_LANG["execute"] = 'Íåâîçìîæíî âûïîëíèòü êîìàíäó: '; +$PHPMAILER_LANG["instantiate"] = 'Íåâîçìîæíî çàïóñòèòü ôóíêöèþ mail.'; +$PHPMAILER_LANG["authenticate"] = 'Îøèáêà SMTP: îøèáêà àâòîðèçàöèè.'; +$PHPMAILER_LANG["from_failed"] = 'Íåâåðíûé àäðåñ îòïðàâèòåëÿ: '; +$PHPMAILER_LANG["recipients_failed"] = 'Îøèáêà SMTP: îòïðàâêà ïî ñëåäóþùèì ' . + 'àäðåñàì ïîëó÷àòåëåé íå óäàëàñü: '; +$PHPMAILER_LANG["data_not_accepted"] = 'Îøèáêà SMTP: äàííûå íå ïðèíÿòû.'; +$PHPMAILER_LANG["connect_host"] = 'Îøèáêà SMTP: íå óäàåòñÿ ïîäêëþ÷èòüñÿ ê ñåðâåðó SMTP.'; +$PHPMAILER_LANG["file_access"] = 'Íåò äîñòóïà ê ôàéëó: '; +$PHPMAILER_LANG["file_open"] = 'Ôàéëîâàÿ îøèáêà: íå óäàåòñÿ îòêðûòü ôàéë: '; +$PHPMAILER_LANG["encoding"] = 'Íåèçâåñòíûé âèä êîäèðîâêè: '; +$PHPMAILER_LANG["signing"] = 'Signing Error: '; + +?> + diff --git a/inc/classes/third_party/php_mailer/language/phpmailer.lang-se.php b/inc/classes/third_party/php_mailer/language/phpmailer.lang-se.php new file mode 100644 index 00000000..e61bbb12 --- /dev/null +++ b/inc/classes/third_party/php_mailer/language/phpmailer.lang-se.php @@ -0,0 +1,26 @@ + + */ + +$PHPMAILER_LANG = array(); + +$PHPMAILER_LANG["provide_address"] = 'Du måste ange minst en ' . + 'mottagares e-postadress.'; +$PHPMAILER_LANG["mailer_not_supported"] = ' mailer stöds inte.'; +$PHPMAILER_LANG["execute"] = 'Kunde inte köra: '; +$PHPMAILER_LANG["instantiate"] = 'Kunde inte initiera e-postfunktion.'; +$PHPMAILER_LANG["authenticate"] = 'SMTP fel: Kunde inte autentisera.'; +$PHPMAILER_LANG["from_failed"] = 'Följande avsändaradress är felaktig: '; +$PHPMAILER_LANG["recipients_failed"] = 'SMTP fel: Följande ' . + 'mottagare är felaktig: '; +$PHPMAILER_LANG["data_not_accepted"] = 'SMTP fel: Data accepterades inte.'; +$PHPMAILER_LANG["connect_host"] = 'SMTP fel: Kunde inte ansluta till SMTP-server.'; +$PHPMAILER_LANG["file_access"] = 'Ingen åtkomst till fil: '; +$PHPMAILER_LANG["file_open"] = 'Fil fel: Kunde inte öppna fil: '; +$PHPMAILER_LANG["encoding"] = 'Okänt encode-format: '; +$PHPMAILER_LANG["signing"] = 'Signing Error: '; + +?> diff --git a/inc/classes/third_party/php_mailer/language/phpmailer.lang-tr.php b/inc/classes/third_party/php_mailer/language/phpmailer.lang-tr.php new file mode 100644 index 00000000..c8f388ee --- /dev/null +++ b/inc/classes/third_party/php_mailer/language/phpmailer.lang-tr.php @@ -0,0 +1,26 @@ + diff --git a/inc/classes/third_party/php_mailer/phpdoc/PHPMailer/PHPMailer.html b/inc/classes/third_party/php_mailer/phpdoc/PHPMailer/PHPMailer.html new file mode 100644 index 00000000..87be4024 --- /dev/null +++ b/inc/classes/third_party/php_mailer/phpdoc/PHPMailer/PHPMailer.html @@ -0,0 +1,1475 @@ + + + + + + Docs For Class PHPMailer + + + + +
+

Class PHPMailer

+ + +
+
Description
+ +
+ +

PHPMailer - PHP email transport class

+
    +
  • copyright:

    2001 - 2003 Brent R. Matzelle

  • +
  • author:

    Brent R. Matzelle

  • +
+

+ Located in Program_Root/class.phpmailer.php (line 20) +

+ + +

+	
+			
+
+ + + +
+
Variable Summary
+ +
+
+
+ string + $AltBody +
+
+ string + $Body +
+
+ string + $CharSet +
+
+ string + $ConfirmReadingTo +
+
+ string + $ContentType +
+
+ string + $Encoding +
+
+ string + $ErrorInfo +
+
+ string + $From +
+
+ string + $FromName +
+
+ string + $Helo +
+
+ string + $Host +
+
+ string + $Hostname +
+
+ string + $Mailer +
+
+ string + $Password +
+
+ string + $PluginDir +
+
+ int + $Port +
+
+ int + $Priority +
+
+ string + $Sender +
+
+ string + $Sendmail +
+
+ bool + $SMTPAuth +
+
+ bool + $SMTPDebug +
+
+ bool + $SMTPKeepAlive +
+
+ string + $Subject +
+
+ int + $Timeout +
+
+ string + $Username +
+
+ string + $Version +
+
+ int + $WordWrap +
+
+
+
+ + +
+
Method Summary
+ +
+
+ +
+ void + AddAddress + (string $address, [string $name = ""]) +
+ +
+ bool + AddAttachment + (string $path, [string $name = ""], [string $encoding = "base64"], [string $type = "application/octet-stream"]) +
+ +
+ void + AddBCC + (string $address, [string $name = ""]) +
+ +
+ void + AddCC + (string $address, [string $name = ""]) +
+ +
+ void + AddCustomHeader + (mixed $custom_header) +
+ +
+ bool + AddEmbeddedImage + (string $path, string $cid, [string $name = ""], [string $encoding = "base64"], [string $type = "application/octet-stream"]) +
+ +
+ void + AddReplyTo + (string $address, [string $name = ""]) +
+ +
+ void + AddStringAttachment + (string $string, string $filename, [string $encoding = "base64"], [string $type = "application/octet-stream"]) +
+ +
+ void + ClearAddresses + () +
+ +
+ void + ClearAllRecipients + () +
+ +
+ void + ClearAttachments + () +
+ +
+ void + ClearBCCs + () +
+ +
+ void + ClearCCs + () +
+ +
+ void + ClearCustomHeaders + () +
+ +
+ void + ClearReplyTos + () +
+ +
+ bool + IsError + () +
+ +
+ void + IsHTML + (bool $bool) +
+ +
+ void + IsMail + () +
+ +
+ void + IsQmail + () +
+ +
+ void + IsSendmail + () +
+ +
+ void + IsSMTP + () +
+ +
+ bool + Send + () +
+ +
+ bool + SetLanguage + (string $lang_type, [string $lang_path = ""]) +
+ +
+ void + SmtpClose + () +
+
+
+
+ + +
+
Variables
+ +
+ +
+ +
+ + string + $AltBody + = "" (line 96) + +
+ + +

Sets the text-only body of the message. This automatically sets the email to multipart/alternative. This body can be read by mail clients that do not have HTML email capability such as mutt. Clients that can read HTML will view the normal Body.

+ + + + + +
+ +
+ +
+ + string + $Body + = "" (line 87) + +
+ + +

Sets the Body of the message. This can be either an HTML or text body.

+

If HTML then run IsHTML(true).

+ + + + + +
+ +
+ +
+ + string + $CharSet + = "iso-8859-1" (line 36) + +
+ + +

Sets the CharSet of the message.

+ + + + + +
+ +
+ +
+ + string + $ConfirmReadingTo + = "" (line 134) + +
+ + +

Sets the email address that a reading confirmation will be sent.

+ + + + + +
+ +
+ +
+ + string + $ContentType + = "text/plain" (line 42) + +
+ + +

Sets the Content-type of the message.

+ + + + + +
+ +
+ +
+ + string + $Encoding + = "8bit" (line 49) + +
+ + +

Sets the Encoding of the message. Options for this are "8bit", "7bit", "binary", "base64", and "quoted-printable".

+ + + + + +
+ +
+ +
+ + string + $ErrorInfo + = "" (line 55) + +
+ + +

Holds the most recent mailer error message.

+ + + + + +
+ +
+ +
+ + string + $From + = "root@localhost" (line 61) + +
+ + +

Sets the From email address for the message.

+ + + + + +
+ +
+ +
+ + string + $FromName + = "Root User" (line 67) + +
+ + +

Sets the From name of the message.

+ + + + + +
+ +
+ +
+ + string + $Helo + = "" (line 169) + +
+ + +

Sets the SMTP HELO of the message (Default is $Hostname).

+ + + + + +
+ +
+ +
+ + string + $Host + = "localhost" (line 157) + +
+ + +

Sets the SMTP hosts. All hosts must be separated by a semicolon. You can also specify a different port for each host by using this format: [hostname:port] (e.g. "smtp1.example.com:25;smtp2.example.com").

+

Hosts will be tried in order.

+ + + + + +
+ +
+ +
+ + string + $Hostname + = "" (line 142) + +
+ + +

Sets the hostname to use in Message-Id and Received headers and as default HELO string. If empty, the value returned by SERVER_NAME is used or 'localhost.localdomain'.

+ + + + + +
+ +
+ +
+ + string + $Mailer + = "mail" (line 109) + +
+ + +

Method to send mail: ("mail", "sendmail", or "smtp").

+ + + + + +
+ +
+ +
+ + string + $Password + = "" (line 187) + +
+ + +

Sets SMTP password.

+ + + + + +
+ +
+ +
+ + string + $PluginDir + = "" (line 122) + +
+ + +

Path to PHPMailer plugins. This is now only useful if the SMTP class is in a different directory than the PHP include path.

+ + + + + +
+ +
+ +
+ + int + $Port + = 25 (line 163) + +
+ + +

Sets the default SMTP server port.

+ + + + + +
+ +
+ +
+ + int + $Priority + = 3 (line 30) + +
+ + +

Email priority (1 = High, 3 = Normal, 5 = low).

+ + + + + +
+ +
+ +
+ + string + $Sender + = "" (line 74) + +
+ + +

Sets the Sender email (Return-Path) of the message. If not empty, will be sent via -f to sendmail or as 'MAIL FROM' in smtp mode.

+ + + + + +
+ +
+ +
+ + string + $Sendmail + = "/usr/sbin/sendmail" (line 115) + +
+ + +

Sets the path of the sendmail program.

+ + + + + +
+ +
+ +
+ + bool + $SMTPAuth + = false (line 175) + +
+ + +

Sets SMTP authentication. Utilizes the Username and Password variables.

+ + + + + +
+ +
+ +
+ + bool + $SMTPDebug + = false (line 200) + +
+ + +

Sets SMTP class debugging on or off.

+ + + + + +
+ +
+ +
+ + bool + $SMTPKeepAlive + = false (line 208) + +
+ + +

Prevents the SMTP connection from being closed after each mail sending. If this is set to true then to close the connection requires an explicit call to SmtpClose().

+ + + + + +
+ +
+ +
+ + string + $Subject + = "" (line 80) + +
+ + +

Sets the Subject of the message.

+ + + + + +
+ +
+ +
+ + int + $Timeout + = 10 (line 194) + +
+ + +

Sets the SMTP server timeout in seconds. This function will not work with the win32 version.

+ + + + + +
+ +
+ +
+ + string + $Username + = "" (line 181) + +
+ + +

Sets SMTP username.

+ + + + + +
+ +
+ +
+ + string + $Version + = "1.71" (line 128) + +
+ + +

Holds PHPMailer version.

+ + + + + +
+ +
+ +
+ + int + $WordWrap + = 0 (line 103) + +
+ + +

Sets word wrapping on the body of the message to a given number of characters.

+ + + + + +
+ +
+
+ + +
+
Methods
+ +
+ + +
+ +
+ AddAddress (line 287) +
+ + +

Adds a "To" address.

+ +
+ void + + AddAddress + + (string $address, [string $name = ""]) +
+ +
    +
  • + string + $address
  • +
  • + string + $name
  • +
+ + +
+ +
+ +
+ AddAttachment (line 1000) +
+ + +

Adds an attachment from a path on the filesystem.

+

Returns false if the file could not be found or accessed.

+ +
+ bool + + AddAttachment + + (string $path, [string $name = ""], [string $encoding = "base64"], [string $type = "application/octet-stream"]) +
+ +
    +
  • + string + $path:

    Path to the attachment.

  • +
  • + string + $name:

    Overrides the attachment name.

  • +
  • + string + $encoding:

    File encoding (see $Encoding).

  • +
  • + string + $type:

    File extension (MIME) type.

  • +
+ + +
+ +
+ +
+ AddBCC (line 315) +
+ + +

Adds a "Bcc" address. Note: this function works with the SMTP mailer on win32, not with the "mail" mailer.

+ +
+ void + + AddBCC + + (string $address, [string $name = ""]) +
+ +
    +
  • + string + $address
  • +
  • + string + $name
  • +
+ + +
+ +
+ +
+ AddCC (line 301) +
+ + +

Adds a "Cc" address. Note: this function works with the SMTP mailer on win32, not with the "mail" mailer.

+ +
+ void + + AddCC + + (string $address, [string $name = ""]) +
+ +
    +
  • + string + $address
  • +
  • + string + $name
  • +
+ + +
+ +
+ +
+ AddCustomHeader (line 1525) +
+ + +

Adds a custom header.

+ +
+ void + + AddCustomHeader + + (mixed $custom_header) +
+ + + +
+ +
+ +
+ AddEmbeddedImage (line 1275) +
+ + +

Adds an embedded attachment. This can include images, sounds, and just about any other document. Make sure to set the $type to an image type. For JPEG images use "image/jpeg" and for GIF images use "image/gif".

+ +
+ bool + + AddEmbeddedImage + + (string $path, string $cid, [string $name = ""], [string $encoding = "base64"], [string $type = "application/octet-stream"]) +
+ +
    +
  • + string + $path:

    Path to the attachment.

  • +
  • + string + $cid:

    Content ID of the attachment. Use this to identify the Id for accessing the image in an HTML form.

  • +
  • + string + $name:

    Overrides the attachment name.

  • +
  • + string + $encoding:

    File encoding (see $Encoding).

  • +
  • + string + $type:

    File extension (MIME) type.

  • +
+ + +
+ +
+ +
+ AddReplyTo (line 327) +
+ + +

Adds a "Reply-to" address.

+ +
+ void + + AddReplyTo + + (string $address, [string $name = ""]) +
+ +
    +
  • + string + $address
  • +
  • + string + $name
  • +
+ + +
+ +
+ +
+ AddStringAttachment (line 1248) +
+ + +

Adds a string or binary attachment (non-filesystem) to the list.

+

This method can be used to attach ascii or binary data, such as a BLOB record from a database.

+ +
+ void + + AddStringAttachment + + (string $string, string $filename, [string $encoding = "base64"], [string $type = "application/octet-stream"]) +
+ +
    +
  • + string + $string:

    String attachment data.

  • +
  • + string + $filename:

    Name of the attachment.

  • +
  • + string + $encoding:

    File encoding (see $Encoding).

  • +
  • + string + $type:

    File extension (MIME) type.

  • +
+ + +
+ +
+ +
+ ClearAddresses (line 1329) +
+ + +

Clears all recipients assigned in the TO array. Returns void.

+ +
+ void + + ClearAddresses + + () +
+ + + +
+ +
+ +
+ ClearAllRecipients (line 1362) +
+ + +

Clears all recipients assigned in the TO, CC and BCC array. Returns void.

+ +
+ void + + ClearAllRecipients + + () +
+ + + +
+ +
+ +
+ ClearAttachments (line 1373) +
+ + +

Clears all previously set filesystem, string, and binary attachments. Returns void.

+ +
+ void + + ClearAttachments + + () +
+ + + +
+ +
+ +
+ ClearBCCs (line 1345) +
+ + +

Clears all recipients assigned in the BCC array. Returns void.

+ +
+ void + + ClearBCCs + + () +
+ + + +
+ +
+ +
+ ClearCCs (line 1337) +
+ + +

Clears all recipients assigned in the CC array. Returns void.

+ +
+ void + + ClearCCs + + () +
+ + + +
+ +
+ +
+ ClearCustomHeaders (line 1381) +
+ + +

Clears all custom headers. Returns void.

+ +
+ void + + ClearCustomHeaders + + () +
+ + + +
+ +
+ +
+ ClearReplyTos (line 1353) +
+ + +

Clears all recipients assigned in the ReplyTo array. Returns void.

+ +
+ void + + ClearReplyTos + + () +
+ + + +
+ +
+ +
+ IsError (line 1505) +
+ + +

Returns true if an error occurred.

+ +
+ bool + + IsError + + () +
+ + + +
+ +
+ +
+ IsHTML (line 236) +
+ + +

Sets message type to HTML.

+ +
+ void + + IsHTML + + (bool $bool) +
+ +
    +
  • + bool + $bool
  • +
+ + +
+ +
+ +
+ IsMail (line 255) +
+ + +

Sets Mailer to send message using PHP mail() function.

+ +
+ void + + IsMail + + () +
+ + + +
+ +
+ +
+ IsQmail (line 271) +
+ + +

Sets Mailer to send message using the qmail MTA.

+ +
+ void + + IsQmail + + () +
+ + + +
+ +
+ +
+ IsSendmail (line 263) +
+ + +

Sets Mailer to send message using the $Sendmail program.

+ +
+ void + + IsSendmail + + () +
+ + + +
+ +
+ +
+ IsSMTP (line 247) +
+ + +

Sets Mailer to send message using SMTP.

+ +
+ void + + IsSMTP + + () +
+ + + +
+ +
+ +
+ Send (line 344) +
+ + +

Creates message and assigns Mailer. If the message is not sent successfully then it returns false. Use the ErrorInfo variable to view description of the error.

+ +
+ bool + + Send + + () +
+ + + +
+ +
+ +
+ SetLanguage (line 599) +
+ + +

Sets the language for all class error messages. Returns false if it cannot load the language file. The default language type is English.

+
    +
  • access: public
  • +
+ +
+ bool + + SetLanguage + + (string $lang_type, [string $lang_path = ""]) +
+ +
    +
  • + string + $lang_type:

    Type of language (e.g. Portuguese: "br")

  • +
  • + string + $lang_path:

    Path to the language file directory

  • +
+ + +
+ +
+ +
+ SmtpClose (line 579) +
+ + +

Closes the active SMTP session if one exists.

+ +
+ void + + SmtpClose + + () +
+ + + +
+ +
+
+ +

+ Documention generated on Mon, 28 Jul 2003 23:25:49 -0400 by phpDocumentor 1.2.0 +

+
+ \ No newline at end of file diff --git a/inc/classes/third_party/php_mailer/phpdoc/PHPMailer/SMTP.html b/inc/classes/third_party/php_mailer/phpdoc/PHPMailer/SMTP.html new file mode 100644 index 00000000..4fdecb1b --- /dev/null +++ b/inc/classes/third_party/php_mailer/phpdoc/PHPMailer/SMTP.html @@ -0,0 +1,734 @@ + + + + + + Docs For Class SMTP + + + + +
+

Class SMTP

+ + +
+
Description
+ +
+ +

SMTP is rfc 821 compliant and implements all the rfc 821 SMTP commands except TURN which will always return a not implemented error. SMTP also provides some utility methods for sending mail to an SMTP server.

+
    +
  • author:

    Chris Ryan

  • +
+

+ Located in Program_Root/class.smtp.php (line 24) +

+ + +

+	
+			
+
+ + + +
+
Variable Summary
+ +
+
+
+ string + $CRLF +
+
+ bool + $do_debug +
+
+ int + $SMTP_PORT +
+
+
+
+ + +
+
Method Summary
+ +
+
+ +
+ void + SMTP + () +
+ +
+ bool + Authenticate + (mixed $username, mixed $password) +
+ +
+ void + Close + () +
+ +
+ bool + Connect + (mixed $host, mixed $port, [mixed $tval = 30]) +
+ +
+ bool + Data + (mixed $msg_data) +
+ +
+ string + Expand + (mixed $name) +
+ +
+ bool + Hello + ([mixed $host = ""]) +
+ +
+ string + Help + ([mixed $keyword = ""]) +
+ +
+ bool + Mail + (mixed $from) +
+ +
+ bool + Noop + () +
+ +
+ bool + Quit + ([mixed $close_on_error = true]) +
+ +
+ bool + Recipient + (mixed $to) +
+ +
+ bool + Reset + () +
+ +
+ bool + Send + (mixed $from) +
+ +
+ bool + SendAndMail + (mixed $from) +
+ +
+ bool + SendOrMail + (mixed $from) +
+ +
+ bool + Turn + () +
+ +
+ int + Verify + (mixed $name) +
+
+
+
+ + +
+
Variables
+ +
+ +
+ +
+ + string + $CRLF + = "\r\n" (line 36) + +
+ + +

SMTP reply line ending

+ + + + + +
+ +
+ +
+ + bool + $do_debug + (line 42) + +
+ + +

Sets whether debugging is turned on

+ + + + + +
+ +
+ +
+ + int + $SMTP_PORT + = 25 (line 30) + +
+ + +

SMTP server port

+ + + + + +
+ +
+
+ + +
+
Methods
+ +
+ + +
+ +
+ Constructor SMTP (line 57) +
+ + +

Initialize the class so that the data is in a known state.

+
    +
  • access: public
  • +
+ +
+ void + + SMTP + + () +
+ + + +
+ +
+ +
+ Authenticate (line 144) +
+ + +

Performs SMTP authentication. Must be run after running the Hello() method. Returns true if successfully authenticated.

+
    +
  • access: public
  • +
+ +
+ bool + + Authenticate + + (mixed $username, mixed $password) +
+ + + +
+ +
+ +
+ Close (line 232) +
+ + +

Closes the socket and cleans up the state of the class.

+

It is not considered good to use this function without first trying to use QUIT.

+
    +
  • access: public
  • +
+ +
+ void + + Close + + () +
+ + + +
+ +
+ +
+ Connect (line 82) +
+ + +

Connect to the server specified on the port specified.

+

If the port is not specified use the default SMTP_PORT. If tval is specified then a connection will try and be established with the server for that number of seconds. If tval is not specified the default is 30 seconds to try on the connection.

SMTP CODE SUCCESS: 220 SMTP CODE FAILURE: 421

+
    +
  • access: public
  • +
+ +
+ bool + + Connect + + (mixed $host, mixed $port, [mixed $tval = 30]) +
+ + + +
+ +
+ +
+ Data (line 266) +
+ + +

Issues a data command and sends the msg_data to the server

+

finializing the mail transaction. $msg_data is the message that is to be send with the headers. Each header needs to be on a single line followed by a <CRLF> with the message headers and the message body being seperated by and additional <CRLF>.

Implements rfc 821: DATA <CRLF>

SMTP CODE INTERMEDIATE: 354 [data] <CRLF>.<CRLF> SMTP CODE SUCCESS: 250 SMTP CODE FAILURE: 552,554,451,452 SMTP CODE FAILURE: 451,554 SMTP CODE ERROR : 500,501,503,421

+
    +
  • access: public
  • +
+ +
+ bool + + Data + + (mixed $msg_data) +
+ + + +
+ +
+ +
+ Expand (line 399) +
+ + +

Expand takes the name and asks the server to list all the people who are members of the _list_. Expand will return back and array of the result or false if an error occurs.

+

Each value in the array returned has the format of: [ <full-name> <sp> ] <path> The definition of <path> is defined in rfc 821

Implements rfc 821: EXPN <SP> <string> <CRLF>

SMTP CODE SUCCESS: 250 SMTP CODE FAILURE: 550 SMTP CODE ERROR : 500,501,502,504,421

+
    +
  • return:

    array

  • +
  • access: public
  • +
+ +
+ string + + Expand + + (mixed $name) +
+ + + +
+ +
+ +
+ Hello (line 450) +
+ + +

Sends the HELO command to the smtp server.

+

This makes sure that we and the server are in the same known state.

Implements from rfc 821: HELO <SP> <domain> <CRLF>

SMTP CODE SUCCESS: 250 SMTP CODE ERROR : 500, 501, 504, 421

+
    +
  • access: public
  • +
+ +
+ bool + + Hello + + ([mixed $host = ""]) +
+ + + +
+ +
+ +
+ Help (line 524) +
+ + +

Gets help information on the keyword specified. If the keyword

+

is not specified then returns generic help, ussually contianing A list of keywords that help is available on. This function returns the results back to the user. It is up to the user to handle the returned data. If an error occurs then false is returned with $this->error set appropiately.

Implements rfc 821: HELP [ <SP> <string> ] <CRLF>

SMTP CODE SUCCESS: 211,214 SMTP CODE ERROR : 500,501,502,504,421

+
    +
  • access: public
  • +
+ +
+ string + + Help + + ([mixed $keyword = ""]) +
+ + + +
+ +
+ +
+ Mail (line 576) +
+ + +

Starts a mail transaction from the email address specified in $from. Returns true if successful or false otherwise. If True the mail transaction is started and then one or more Recipient commands may be called followed by a Data command.

+

Implements rfc 821: MAIL <SP> FROM:<reverse-path> <CRLF>

SMTP CODE SUCCESS: 250 SMTP CODE SUCCESS: 552,451,452 SMTP CODE SUCCESS: 500,501,421

+
    +
  • access: public
  • +
+ +
+ bool + + Mail + + (mixed $from) +
+ + + +
+ +
+ +
+ Noop (line 618) +
+ + +

Sends the command NOOP to the SMTP server.

+

Implements from rfc 821: NOOP <CRLF>

SMTP CODE SUCCESS: 250 SMTP CODE ERROR : 500, 421

+
    +
  • access: public
  • +
+ +
+ bool + + Noop + + () +
+ + + +
+ +
+ +
+ Quit (line 661) +
+ + +

Sends the quit command to the server and then closes the socket if there is no error or the $close_on_error argument is true.

+

Implements from rfc 821: QUIT <CRLF>

SMTP CODE SUCCESS: 221 SMTP CODE ERROR : 500

+
    +
  • access: public
  • +
+ +
+ bool + + Quit + + ([mixed $close_on_error = true]) +
+ + + +
+ +
+ +
+ Recipient (line 715) +
+ + +

Sends the command RCPT to the SMTP server with the TO: argument of $to.

+

Returns true if the recipient was accepted false if it was rejected.

Implements from rfc 821: RCPT <SP> TO:<forward-path> <CRLF>

SMTP CODE SUCCESS: 250,251 SMTP CODE FAILURE: 550,551,552,553,450,451,452 SMTP CODE ERROR : 500,501,503,421

+
    +
  • access: public
  • +
+ +
+ bool + + Recipient + + (mixed $to) +
+ + + +
+ +
+ +
+ Reset (line 759) +
+ + +

Sends the RSET command to abort and transaction that is currently in progress. Returns true if successful false otherwise.

+

Implements rfc 821: RSET <CRLF>

SMTP CODE SUCCESS: 250 SMTP CODE ERROR : 500,501,504,421

+
    +
  • access: public
  • +
+ +
+ bool + + Reset + + () +
+ + + +
+ +
+ +
+ Send (line 808) +
+ + +

Starts a mail transaction from the email address specified in

+

$from. Returns true if successful or false otherwise. If True the mail transaction is started and then one or more Recipient commands may be called followed by a Data command. This command will send the message to the users terminal if they are logged in.

Implements rfc 821: SEND <SP> FROM:<reverse-path> <CRLF>

SMTP CODE SUCCESS: 250 SMTP CODE SUCCESS: 552,451,452 SMTP CODE SUCCESS: 500,501,502,421

+
    +
  • access: public
  • +
+ +
+ bool + + Send + + (mixed $from) +
+ + + +
+ +
+ +
+ SendAndMail (line 856) +
+ + +

Starts a mail transaction from the email address specified in

+

$from. Returns true if successful or false otherwise. If True the mail transaction is started and then one or more Recipient commands may be called followed by a Data command. This command will send the message to the users terminal if they are logged in and send them an email.

Implements rfc 821: SAML <SP> FROM:<reverse-path> <CRLF>

SMTP CODE SUCCESS: 250 SMTP CODE SUCCESS: 552,451,452 SMTP CODE SUCCESS: 500,501,502,421

+
    +
  • access: public
  • +
+ +
+ bool + + SendAndMail + + (mixed $from) +
+ + + +
+ +
+ +
+ SendOrMail (line 904) +
+ + +

Starts a mail transaction from the email address specified in

+

$from. Returns true if successful or false otherwise. If True the mail transaction is started and then one or more Recipient commands may be called followed by a Data command. This command will send the message to the users terminal if they are logged in or mail it to them if they are not.

Implements rfc 821: SOML <SP> FROM:<reverse-path> <CRLF>

SMTP CODE SUCCESS: 250 SMTP CODE SUCCESS: 552,451,452 SMTP CODE SUCCESS: 500,501,502,421

+
    +
  • access: public
  • +
+ +
+ bool + + SendOrMail + + (mixed $from) +
+ + + +
+ +
+ +
+ Turn (line 949) +
+ + +

This is an optional command for SMTP that this class does not support. This method is here to make the RFC821 Definition complete for this class and __may__ be implimented in the future

+

Implements from rfc 821: TURN <CRLF>

SMTP CODE SUCCESS: 250 SMTP CODE FAILURE: 502 SMTP CODE ERROR : 500, 503

+
    +
  • access: public
  • +
+ +
+ bool + + Turn + + () +
+ + + +
+ +
+ +
+ Verify (line 971) +
+ + +

Verifies that the name is recognized by the server.

+

Returns false if the name could not be verified otherwise the response from the server is returned.

Implements rfc 821: VRFY <SP> <string> <CRLF>

SMTP CODE SUCCESS: 250,251 SMTP CODE FAILURE: 550,551,553 SMTP CODE ERROR : 500,501,502,421

+
    +
  • access: public
  • +
+ +
+ int + + Verify + + (mixed $name) +
+ + + +
+ +
+
+ +

+ Documention generated on Mon, 28 Jul 2003 23:25:50 -0400 by phpDocumentor 1.2.0 +

+
+ \ No newline at end of file diff --git a/inc/classes/third_party/php_mailer/phpdoc/PHPMailer/_class_phpmailer_php.html b/inc/classes/third_party/php_mailer/phpdoc/PHPMailer/_class_phpmailer_php.html new file mode 100644 index 00000000..f7bde2c7 --- /dev/null +++ b/inc/classes/third_party/php_mailer/phpdoc/PHPMailer/_class_phpmailer_php.html @@ -0,0 +1,60 @@ + + + + + + Docs for page class.phpmailer.php + + + + +
+

Program_Root/class.phpmailer.php

+ + +
+
Description
+ +
+ + +
+
+ + +
+
Classes
+ +
+ + + + + + + + + +
ClassDescription
+ PHPMailer + + PHPMailer - PHP email transport class +
+
+
+ + + + + +

+ Documention generated on Mon, 28 Jul 2003 23:25:49 -0400 by phpDocumentor 1.2.0 +

+
+ \ No newline at end of file diff --git a/inc/classes/third_party/php_mailer/phpdoc/PHPMailer/_class_smtp_php.html b/inc/classes/third_party/php_mailer/phpdoc/PHPMailer/_class_smtp_php.html new file mode 100644 index 00000000..1b7d1b52 --- /dev/null +++ b/inc/classes/third_party/php_mailer/phpdoc/PHPMailer/_class_smtp_php.html @@ -0,0 +1,60 @@ + + + + + + Docs for page class.smtp.php + + + + +
+

Program_Root/class.smtp.php

+ + +
+
Description
+ +
+ + +
+
+ + +
+
Classes
+ +
+ + + + + + + + + +
ClassDescription
+ SMTP + + SMTP is rfc 821 compliant and implements all the rfc 821 SMTP commands except TURN which will always return a not implemented error. SMTP also provides some utility methods for sending mail to an SMTP server. +
+
+
+ + + + + +

+ Documention generated on Mon, 28 Jul 2003 23:25:50 -0400 by phpDocumentor 1.2.0 +

+
+ \ No newline at end of file diff --git a/inc/classes/third_party/php_mailer/phpdoc/blank.html b/inc/classes/third_party/php_mailer/phpdoc/blank.html new file mode 100644 index 00000000..4382bc95 --- /dev/null +++ b/inc/classes/third_party/php_mailer/phpdoc/blank.html @@ -0,0 +1,13 @@ + + + Generated Documentation + + + + +

Generated Documentation

+Welcome to default!
+
+This documentation was generated by phpDocumentor v1.2.0
+ + \ No newline at end of file diff --git a/inc/classes/third_party/php_mailer/phpdoc/classtrees_PHPMailer.html b/inc/classes/third_party/php_mailer/phpdoc/classtrees_PHPMailer.html new file mode 100644 index 00000000..f8a48da6 --- /dev/null +++ b/inc/classes/third_party/php_mailer/phpdoc/classtrees_PHPMailer.html @@ -0,0 +1,28 @@ + + + + + + + + + + + + +

+ +

+

Root class PHPMailer

+ + +

Root class SMTP

+ + +

+ Documention generated on Mon, 28 Jul 2003 23:25:49 -0400 by phpDocumentor 1.2.0 +

+ + \ No newline at end of file diff --git a/inc/classes/third_party/php_mailer/phpdoc/elementindex.html b/inc/classes/third_party/php_mailer/phpdoc/elementindex.html new file mode 100644 index 00000000..7f65a767 --- /dev/null +++ b/inc/classes/third_party/php_mailer/phpdoc/elementindex.html @@ -0,0 +1,734 @@ + + + + + + + + + + + +

Full index

+

Package indexes

+ +
+
+ a + b + c + d + e + f + h + i + m + n + p + q + r + s + t + u + v + w +
+ + +
+
a
+ +
+
+
+
+ $AltBody +
+
+
PHPMailer::$AltBody in class.phpmailer.php
+
Sets the text-only body of the message. This automatically sets the email to multipart/alternative. This body can be read by mail clients that do not have HTML email capability such as mutt. Clients that can read HTML will view the normal Body.
+
+
+ AddAddress +
+
+
PHPMailer::AddAddress() in class.phpmailer.php
+
Adds a "To" address.
+
+
+ AddAttachment +
+
+
PHPMailer::AddAttachment() in class.phpmailer.php
+
Adds an attachment from a path on the filesystem.
+
+
+ AddBCC +
+
+
PHPMailer::AddBCC() in class.phpmailer.php
+
Adds a "Bcc" address. Note: this function works with the SMTP mailer on win32, not with the "mail" mailer.
+
+
+ AddCC +
+
+
PHPMailer::AddCC() in class.phpmailer.php
+
Adds a "Cc" address. Note: this function works with the SMTP mailer on win32, not with the "mail" mailer.
+
+
+ AddCustomHeader +
+
+
PHPMailer::AddCustomHeader() in class.phpmailer.php
+
Adds a custom header.
+
+
+ AddEmbeddedImage +
+
+
PHPMailer::AddEmbeddedImage() in class.phpmailer.php
+
Adds an embedded attachment. This can include images, sounds, and just about any other document. Make sure to set the $type to an image type. For JPEG images use "image/jpeg" and for GIF images use "image/gif".
+
+
+ AddReplyTo +
+
+
PHPMailer::AddReplyTo() in class.phpmailer.php
+
Adds a "Reply-to" address.
+
+
+ AddStringAttachment +
+
+
PHPMailer::AddStringAttachment() in class.phpmailer.php
+
Adds a string or binary attachment (non-filesystem) to the list.
+
+
+ Authenticate +
+
+
SMTP::Authenticate() in class.smtp.php
+
Performs SMTP authentication. Must be run after running the Hello() method. Returns true if successfully authenticated.
+
+
+ +
+
b
+ +
+
+
+
+ $Body +
+
+
PHPMailer::$Body in class.phpmailer.php
+
Sets the Body of the message. This can be either an HTML or text body.
+
+
+ +
+
c
+ +
+
+
+
+ $CharSet +
+
+
PHPMailer::$CharSet in class.phpmailer.php
+
Sets the CharSet of the message.
+
+
+ $ConfirmReadingTo +
+
+
PHPMailer::$ConfirmReadingTo in class.phpmailer.php
+
Sets the email address that a reading confirmation will be sent.
+
+
+ $ContentType +
+
+
PHPMailer::$ContentType in class.phpmailer.php
+
Sets the Content-type of the message.
+
+
+ $CRLF +
+
+
SMTP::$CRLF in class.smtp.php
+
SMTP reply line ending
+
+
+ class.phpmailer.php +
+
+
class.phpmailer.php in class.phpmailer.php
+
+
+ class.smtp.php +
+
+
class.smtp.php in class.smtp.php
+
+
+ ClearAddresses +
+
+
PHPMailer::ClearAddresses() in class.phpmailer.php
+
Clears all recipients assigned in the TO array. Returns void.
+
+
+ ClearAllRecipients +
+
+
PHPMailer::ClearAllRecipients() in class.phpmailer.php
+
Clears all recipients assigned in the TO, CC and BCC array. Returns void.
+
+
+ ClearAttachments +
+
+
PHPMailer::ClearAttachments() in class.phpmailer.php
+
Clears all previously set filesystem, string, and binary attachments. Returns void.
+
+
+ ClearBCCs +
+
+
PHPMailer::ClearBCCs() in class.phpmailer.php
+
Clears all recipients assigned in the BCC array. Returns void.
+
+
+ ClearCCs +
+
+
PHPMailer::ClearCCs() in class.phpmailer.php
+
Clears all recipients assigned in the CC array. Returns void.
+
+
+ ClearCustomHeaders +
+
+
PHPMailer::ClearCustomHeaders() in class.phpmailer.php
+
Clears all custom headers. Returns void.
+
+
+ ClearReplyTos +
+
+
PHPMailer::ClearReplyTos() in class.phpmailer.php
+
Clears all recipients assigned in the ReplyTo array. Returns void.
+
+
+ Close +
+
+
SMTP::Close() in class.smtp.php
+
Closes the socket and cleans up the state of the class.
+
+
+ Connect +
+
+
SMTP::Connect() in class.smtp.php
+
Connect to the server specified on the port specified.
+
+
+ +
+
d
+ +
+
+
+
+ $do_debug +
+
+
SMTP::$do_debug in class.smtp.php
+
Sets whether debugging is turned on
+
+
+ Data +
+
+
SMTP::Data() in class.smtp.php
+
Issues a data command and sends the msg_data to the server
+
+
+ +
+
e
+ +
+
+
+
+ $Encoding +
+
+
PHPMailer::$Encoding in class.phpmailer.php
+
Sets the Encoding of the message. Options for this are "8bit", "7bit", "binary", "base64", and "quoted-printable".
+
+
+ $ErrorInfo +
+
+
PHPMailer::$ErrorInfo in class.phpmailer.php
+
Holds the most recent mailer error message.
+
+
+ Expand +
+
+
SMTP::Expand() in class.smtp.php
+
Expand takes the name and asks the server to list all the people who are members of the _list_. Expand will return back and array of the result or false if an error occurs.
+
+
+ +
+
f
+ +
+
+
+
+ $From +
+
+
PHPMailer::$From in class.phpmailer.php
+
Sets the From email address for the message.
+
+
+ $FromName +
+
+
PHPMailer::$FromName in class.phpmailer.php
+
Sets the From name of the message.
+
+
+ +
+
h
+ +
+
+
+
+ $Helo +
+
+
PHPMailer::$Helo in class.phpmailer.php
+
Sets the SMTP HELO of the message (Default is $Hostname).
+
+
+ $Host +
+
+
PHPMailer::$Host in class.phpmailer.php
+
Sets the SMTP hosts. All hosts must be separated by a semicolon. You can also specify a different port for each host by using this format: [hostname:port] (e.g. "smtp1.example.com:25;smtp2.example.com").
+
+
+ $Hostname +
+
+
PHPMailer::$Hostname in class.phpmailer.php
+
Sets the hostname to use in Message-Id and Received headers and as default HELO string. If empty, the value returned by SERVER_NAME is used or 'localhost.localdomain'.
+
+
+ Hello +
+
+
SMTP::Hello() in class.smtp.php
+
Sends the HELO command to the smtp server.
+
+
+ Help +
+
+
SMTP::Help() in class.smtp.php
+
Gets help information on the keyword specified. If the keyword
+
+
+ +
+
i
+ +
+
+
+
+ IsError +
+
+
PHPMailer::IsError() in class.phpmailer.php
+
Returns true if an error occurred.
+
+
+ IsHTML +
+
+
PHPMailer::IsHTML() in class.phpmailer.php
+
Sets message type to HTML.
+
+
+ IsMail +
+
+
PHPMailer::IsMail() in class.phpmailer.php
+
Sets Mailer to send message using PHP mail() function.
+
+
+ IsQmail +
+
+
PHPMailer::IsQmail() in class.phpmailer.php
+
Sets Mailer to send message using the qmail MTA.
+
+
+ IsSendmail +
+
+
PHPMailer::IsSendmail() in class.phpmailer.php
+
Sets Mailer to send message using the $Sendmail program.
+
+
+ IsSMTP +
+
+
PHPMailer::IsSMTP() in class.phpmailer.php
+
Sets Mailer to send message using SMTP.
+
+
+ +
+
m
+ +
+
+
+
+ $Mailer +
+
+
PHPMailer::$Mailer in class.phpmailer.php
+
Method to send mail: ("mail", "sendmail", or "smtp").
+
+
+ Mail +
+
+
SMTP::Mail() in class.smtp.php
+
Starts a mail transaction from the email address specified in $from. Returns true if successful or false otherwise. If True the mail transaction is started and then one or more Recipient commands may be called followed by a Data command.
+
+
+ +
+
n
+ +
+
+
+
+ Noop +
+
+
SMTP::Noop() in class.smtp.php
+
Sends the command NOOP to the SMTP server.
+
+
+ +
+
p
+ +
+
+
+
+ $Password +
+
+
PHPMailer::$Password in class.phpmailer.php
+
Sets SMTP password.
+
+
+ $PluginDir +
+
+
PHPMailer::$PluginDir in class.phpmailer.php
+
Path to PHPMailer plugins. This is now only useful if the SMTP class is in a different directory than the PHP include path.
+
+
+ $Port +
+
+
PHPMailer::$Port in class.phpmailer.php
+
Sets the default SMTP server port.
+
+
+ $Priority +
+
+
PHPMailer::$Priority in class.phpmailer.php
+
Email priority (1 = High, 3 = Normal, 5 = low).
+
+
+ PHPMailer +
+
+
PHPMailer in class.phpmailer.php
+
PHPMailer - PHP email transport class
+
+
+ +
+
q
+ +
+
+
+
+ Quit +
+
+
SMTP::Quit() in class.smtp.php
+
Sends the quit command to the server and then closes the socket if there is no error or the $close_on_error argument is true.
+
+
+ +
+
r
+ +
+
+
+
+ Recipient +
+
+
SMTP::Recipient() in class.smtp.php
+
Sends the command RCPT to the SMTP server with the TO: argument of $to.
+
+
+ Reset +
+
+
SMTP::Reset() in class.smtp.php
+
Sends the RSET command to abort and transaction that is currently in progress. Returns true if successful false otherwise.
+
+
+ +
+
s
+ +
+
+
+
+ $Sender +
+
+
PHPMailer::$Sender in class.phpmailer.php
+
Sets the Sender email (Return-Path) of the message. If not empty, will be sent via -f to sendmail or as 'MAIL FROM' in smtp mode.
+
+
+ $Sendmail +
+
+
PHPMailer::$Sendmail in class.phpmailer.php
+
Sets the path of the sendmail program.
+
+
+ $SMTPAuth +
+
+
PHPMailer::$SMTPAuth in class.phpmailer.php
+
Sets SMTP authentication. Utilizes the Username and Password variables.
+
+
+ $SMTPDebug +
+
+
PHPMailer::$SMTPDebug in class.phpmailer.php
+
Sets SMTP class debugging on or off.
+
+
+ $SMTPKeepAlive +
+
+
PHPMailer::$SMTPKeepAlive in class.phpmailer.php
+
Prevents the SMTP connection from being closed after each mail sending. If this is set to true then to close the connection requires an explicit call to SmtpClose().
+
+
+ $SMTP_PORT +
+
+
SMTP::$SMTP_PORT in class.smtp.php
+
SMTP server port
+
+
+ $Subject +
+
+
PHPMailer::$Subject in class.phpmailer.php
+
Sets the Subject of the message.
+
+
+ Send +
+
+
SMTP::Send() in class.smtp.php
+
Starts a mail transaction from the email address specified in
+
+
+ Send +
+
+
PHPMailer::Send() in class.phpmailer.php
+
Creates message and assigns Mailer. If the message is not sent successfully then it returns false. Use the ErrorInfo variable to view description of the error.
+
+
+ SendAndMail +
+
+
SMTP::SendAndMail() in class.smtp.php
+
Starts a mail transaction from the email address specified in
+
+
+ SendOrMail +
+
+
SMTP::SendOrMail() in class.smtp.php
+
Starts a mail transaction from the email address specified in
+
+
+ SetLanguage +
+
+
PHPMailer::SetLanguage() in class.phpmailer.php
+
Sets the language for all class error messages. Returns false if it cannot load the language file. The default language type is English.
+
+
+ SMTP +
+
+
SMTP::SMTP() in class.smtp.php
+
Initialize the class so that the data is in a known state.
+
+
+ SMTP +
+
+
SMTP in class.smtp.php
+
SMTP is rfc 821 compliant and implements all the rfc 821 SMTP commands except TURN which will always return a not implemented error. SMTP also provides some utility methods for sending mail to an SMTP server.
+
+
+ SmtpClose +
+
+
PHPMailer::SmtpClose() in class.phpmailer.php
+
Closes the active SMTP session if one exists.
+
+
+ +
+
t
+ +
+
+
+
+ $Timeout +
+
+
PHPMailer::$Timeout in class.phpmailer.php
+
Sets the SMTP server timeout in seconds. This function will not work with the win32 version.
+
+
+ Turn +
+
+
SMTP::Turn() in class.smtp.php
+
This is an optional command for SMTP that this class does not support. This method is here to make the RFC821 Definition complete for this class and __may__ be implimented in the future
+
+
+ +
+
u
+ +
+
+
+
+ $Username +
+
+
PHPMailer::$Username in class.phpmailer.php
+
Sets SMTP username.
+
+
+ +
+
v
+ +
+
+
+
+ $Version +
+
+
PHPMailer::$Version in class.phpmailer.php
+
Holds PHPMailer version.
+
+
+ Verify +
+
+
SMTP::Verify() in class.smtp.php
+
Verifies that the name is recognized by the server.
+
+
+ +
+
w
+ +
+
+
+
+ $WordWrap +
+
+
PHPMailer::$WordWrap in class.phpmailer.php
+
Sets word wrapping on the body of the message to a given number of characters.
+
+
+ +
+ a + b + c + d + e + f + h + i + m + n + p + q + r + s + t + u + v + w +
+ \ No newline at end of file diff --git a/inc/classes/third_party/php_mailer/phpdoc/elementindex_PHPMailer.html b/inc/classes/third_party/php_mailer/phpdoc/elementindex_PHPMailer.html new file mode 100644 index 00000000..e62d5ed6 --- /dev/null +++ b/inc/classes/third_party/php_mailer/phpdoc/elementindex_PHPMailer.html @@ -0,0 +1,731 @@ + + + + + + + + + + + +

[PHPMailer] element index

+All elements +
+
+ a + b + c + d + e + f + h + i + m + n + p + q + r + s + t + u + v + w +
+ + +
+
a
+ +
+
+
+
+ $AltBody +
+
+
PHPMailer::$AltBody in class.phpmailer.php
+
Sets the text-only body of the message. This automatically sets the email to multipart/alternative. This body can be read by mail clients that do not have HTML email capability such as mutt. Clients that can read HTML will view the normal Body.
+
+
+ AddAddress +
+
+
PHPMailer::AddAddress() in class.phpmailer.php
+
Adds a "To" address.
+
+
+ AddAttachment +
+
+
PHPMailer::AddAttachment() in class.phpmailer.php
+
Adds an attachment from a path on the filesystem.
+
+
+ AddBCC +
+
+
PHPMailer::AddBCC() in class.phpmailer.php
+
Adds a "Bcc" address. Note: this function works with the SMTP mailer on win32, not with the "mail" mailer.
+
+
+ AddCC +
+
+
PHPMailer::AddCC() in class.phpmailer.php
+
Adds a "Cc" address. Note: this function works with the SMTP mailer on win32, not with the "mail" mailer.
+
+
+ AddCustomHeader +
+
+
PHPMailer::AddCustomHeader() in class.phpmailer.php
+
Adds a custom header.
+
+
+ AddEmbeddedImage +
+
+
PHPMailer::AddEmbeddedImage() in class.phpmailer.php
+
Adds an embedded attachment. This can include images, sounds, and just about any other document. Make sure to set the $type to an image type. For JPEG images use "image/jpeg" and for GIF images use "image/gif".
+
+
+ AddReplyTo +
+
+
PHPMailer::AddReplyTo() in class.phpmailer.php
+
Adds a "Reply-to" address.
+
+
+ AddStringAttachment +
+
+
PHPMailer::AddStringAttachment() in class.phpmailer.php
+
Adds a string or binary attachment (non-filesystem) to the list.
+
+
+ Authenticate +
+
+
SMTP::Authenticate() in class.smtp.php
+
Performs SMTP authentication. Must be run after running the Hello() method. Returns true if successfully authenticated.
+
+
+ +
+
b
+ +
+
+
+
+ $Body +
+
+
PHPMailer::$Body in class.phpmailer.php
+
Sets the Body of the message. This can be either an HTML or text body.
+
+
+ +
+
c
+ +
+
+
+
+ $CharSet +
+
+
PHPMailer::$CharSet in class.phpmailer.php
+
Sets the CharSet of the message.
+
+
+ $ConfirmReadingTo +
+
+
PHPMailer::$ConfirmReadingTo in class.phpmailer.php
+
Sets the email address that a reading confirmation will be sent.
+
+
+ $ContentType +
+
+
PHPMailer::$ContentType in class.phpmailer.php
+
Sets the Content-type of the message.
+
+
+ $CRLF +
+
+
SMTP::$CRLF in class.smtp.php
+
SMTP reply line ending
+
+
+ class.phpmailer.php +
+
+
class.phpmailer.php in class.phpmailer.php
+
+
+ class.smtp.php +
+
+
class.smtp.php in class.smtp.php
+
+
+ ClearAddresses +
+
+
PHPMailer::ClearAddresses() in class.phpmailer.php
+
Clears all recipients assigned in the TO array. Returns void.
+
+
+ ClearAllRecipients +
+
+
PHPMailer::ClearAllRecipients() in class.phpmailer.php
+
Clears all recipients assigned in the TO, CC and BCC array. Returns void.
+
+
+ ClearAttachments +
+
+
PHPMailer::ClearAttachments() in class.phpmailer.php
+
Clears all previously set filesystem, string, and binary attachments. Returns void.
+
+
+ ClearBCCs +
+
+
PHPMailer::ClearBCCs() in class.phpmailer.php
+
Clears all recipients assigned in the BCC array. Returns void.
+
+
+ ClearCCs +
+
+
PHPMailer::ClearCCs() in class.phpmailer.php
+
Clears all recipients assigned in the CC array. Returns void.
+
+
+ ClearCustomHeaders +
+
+
PHPMailer::ClearCustomHeaders() in class.phpmailer.php
+
Clears all custom headers. Returns void.
+
+
+ ClearReplyTos +
+
+
PHPMailer::ClearReplyTos() in class.phpmailer.php
+
Clears all recipients assigned in the ReplyTo array. Returns void.
+
+
+ Close +
+
+
SMTP::Close() in class.smtp.php
+
Closes the socket and cleans up the state of the class.
+
+
+ Connect +
+
+
SMTP::Connect() in class.smtp.php
+
Connect to the server specified on the port specified.
+
+
+ +
+
d
+ +
+
+
+
+ $do_debug +
+
+
SMTP::$do_debug in class.smtp.php
+
Sets whether debugging is turned on
+
+
+ Data +
+
+
SMTP::Data() in class.smtp.php
+
Issues a data command and sends the msg_data to the server
+
+
+ +
+
e
+ +
+
+
+
+ $Encoding +
+
+
PHPMailer::$Encoding in class.phpmailer.php
+
Sets the Encoding of the message. Options for this are "8bit", "7bit", "binary", "base64", and "quoted-printable".
+
+
+ $ErrorInfo +
+
+
PHPMailer::$ErrorInfo in class.phpmailer.php
+
Holds the most recent mailer error message.
+
+
+ Expand +
+
+
SMTP::Expand() in class.smtp.php
+
Expand takes the name and asks the server to list all the people who are members of the _list_. Expand will return back and array of the result or false if an error occurs.
+
+
+ +
+
f
+ +
+
+
+
+ $From +
+
+
PHPMailer::$From in class.phpmailer.php
+
Sets the From email address for the message.
+
+
+ $FromName +
+
+
PHPMailer::$FromName in class.phpmailer.php
+
Sets the From name of the message.
+
+
+ +
+
h
+ +
+
+
+
+ $Helo +
+
+
PHPMailer::$Helo in class.phpmailer.php
+
Sets the SMTP HELO of the message (Default is $Hostname).
+
+
+ $Host +
+
+
PHPMailer::$Host in class.phpmailer.php
+
Sets the SMTP hosts. All hosts must be separated by a semicolon. You can also specify a different port for each host by using this format: [hostname:port] (e.g. "smtp1.example.com:25;smtp2.example.com").
+
+
+ $Hostname +
+
+
PHPMailer::$Hostname in class.phpmailer.php
+
Sets the hostname to use in Message-Id and Received headers and as default HELO string. If empty, the value returned by SERVER_NAME is used or 'localhost.localdomain'.
+
+
+ Hello +
+
+
SMTP::Hello() in class.smtp.php
+
Sends the HELO command to the smtp server.
+
+
+ Help +
+
+
SMTP::Help() in class.smtp.php
+
Gets help information on the keyword specified. If the keyword
+
+
+ +
+
i
+ +
+
+
+
+ IsError +
+
+
PHPMailer::IsError() in class.phpmailer.php
+
Returns true if an error occurred.
+
+
+ IsHTML +
+
+
PHPMailer::IsHTML() in class.phpmailer.php
+
Sets message type to HTML.
+
+
+ IsMail +
+
+
PHPMailer::IsMail() in class.phpmailer.php
+
Sets Mailer to send message using PHP mail() function.
+
+
+ IsQmail +
+
+
PHPMailer::IsQmail() in class.phpmailer.php
+
Sets Mailer to send message using the qmail MTA.
+
+
+ IsSendmail +
+
+
PHPMailer::IsSendmail() in class.phpmailer.php
+
Sets Mailer to send message using the $Sendmail program.
+
+
+ IsSMTP +
+
+
PHPMailer::IsSMTP() in class.phpmailer.php
+
Sets Mailer to send message using SMTP.
+
+
+ +
+
m
+ +
+
+
+
+ $Mailer +
+
+
PHPMailer::$Mailer in class.phpmailer.php
+
Method to send mail: ("mail", "sendmail", or "smtp").
+
+
+ Mail +
+
+
SMTP::Mail() in class.smtp.php
+
Starts a mail transaction from the email address specified in $from. Returns true if successful or false otherwise. If True the mail transaction is started and then one or more Recipient commands may be called followed by a Data command.
+
+
+ +
+
n
+ +
+
+
+
+ Noop +
+
+
SMTP::Noop() in class.smtp.php
+
Sends the command NOOP to the SMTP server.
+
+
+ +
+
p
+ +
+
+
+
+ $Password +
+
+
PHPMailer::$Password in class.phpmailer.php
+
Sets SMTP password.
+
+
+ $PluginDir +
+
+
PHPMailer::$PluginDir in class.phpmailer.php
+
Path to PHPMailer plugins. This is now only useful if the SMTP class is in a different directory than the PHP include path.
+
+
+ $Port +
+
+
PHPMailer::$Port in class.phpmailer.php
+
Sets the default SMTP server port.
+
+
+ $Priority +
+
+
PHPMailer::$Priority in class.phpmailer.php
+
Email priority (1 = High, 3 = Normal, 5 = low).
+
+
+ PHPMailer +
+
+
PHPMailer in class.phpmailer.php
+
PHPMailer - PHP email transport class
+
+
+ +
+
q
+ +
+
+
+
+ Quit +
+
+
SMTP::Quit() in class.smtp.php
+
Sends the quit command to the server and then closes the socket if there is no error or the $close_on_error argument is true.
+
+
+ +
+
r
+ +
+
+
+
+ Recipient +
+
+
SMTP::Recipient() in class.smtp.php
+
Sends the command RCPT to the SMTP server with the TO: argument of $to.
+
+
+ Reset +
+
+
SMTP::Reset() in class.smtp.php
+
Sends the RSET command to abort and transaction that is currently in progress. Returns true if successful false otherwise.
+
+
+ +
+
s
+ +
+
+
+
+ $Sender +
+
+
PHPMailer::$Sender in class.phpmailer.php
+
Sets the Sender email (Return-Path) of the message. If not empty, will be sent via -f to sendmail or as 'MAIL FROM' in smtp mode.
+
+
+ $Sendmail +
+
+
PHPMailer::$Sendmail in class.phpmailer.php
+
Sets the path of the sendmail program.
+
+
+ $SMTPAuth +
+
+
PHPMailer::$SMTPAuth in class.phpmailer.php
+
Sets SMTP authentication. Utilizes the Username and Password variables.
+
+
+ $SMTPDebug +
+
+
PHPMailer::$SMTPDebug in class.phpmailer.php
+
Sets SMTP class debugging on or off.
+
+
+ $SMTPKeepAlive +
+
+
PHPMailer::$SMTPKeepAlive in class.phpmailer.php
+
Prevents the SMTP connection from being closed after each mail sending. If this is set to true then to close the connection requires an explicit call to SmtpClose().
+
+
+ $SMTP_PORT +
+
+
SMTP::$SMTP_PORT in class.smtp.php
+
SMTP server port
+
+
+ $Subject +
+
+
PHPMailer::$Subject in class.phpmailer.php
+
Sets the Subject of the message.
+
+
+ Send +
+
+
SMTP::Send() in class.smtp.php
+
Starts a mail transaction from the email address specified in
+
+
+ Send +
+
+
PHPMailer::Send() in class.phpmailer.php
+
Creates message and assigns Mailer. If the message is not sent successfully then it returns false. Use the ErrorInfo variable to view description of the error.
+
+
+ SendAndMail +
+
+
SMTP::SendAndMail() in class.smtp.php
+
Starts a mail transaction from the email address specified in
+
+
+ SendOrMail +
+
+
SMTP::SendOrMail() in class.smtp.php
+
Starts a mail transaction from the email address specified in
+
+
+ SetLanguage +
+
+
PHPMailer::SetLanguage() in class.phpmailer.php
+
Sets the language for all class error messages. Returns false if it cannot load the language file. The default language type is English.
+
+
+ SMTP +
+
+
SMTP::SMTP() in class.smtp.php
+
Initialize the class so that the data is in a known state.
+
+
+ SMTP +
+
+
SMTP in class.smtp.php
+
SMTP is rfc 821 compliant and implements all the rfc 821 SMTP commands except TURN which will always return a not implemented error. SMTP also provides some utility methods for sending mail to an SMTP server.
+
+
+ SmtpClose +
+
+
PHPMailer::SmtpClose() in class.phpmailer.php
+
Closes the active SMTP session if one exists.
+
+
+ +
+
t
+ +
+
+
+
+ $Timeout +
+
+
PHPMailer::$Timeout in class.phpmailer.php
+
Sets the SMTP server timeout in seconds. This function will not work with the win32 version.
+
+
+ Turn +
+
+
SMTP::Turn() in class.smtp.php
+
This is an optional command for SMTP that this class does not support. This method is here to make the RFC821 Definition complete for this class and __may__ be implimented in the future
+
+
+ +
+
u
+ +
+
+
+
+ $Username +
+
+
PHPMailer::$Username in class.phpmailer.php
+
Sets SMTP username.
+
+
+ +
+
v
+ +
+
+
+
+ $Version +
+
+
PHPMailer::$Version in class.phpmailer.php
+
Holds PHPMailer version.
+
+
+ Verify +
+
+
SMTP::Verify() in class.smtp.php
+
Verifies that the name is recognized by the server.
+
+
+ +
+
w
+ +
+
+
+
+ $WordWrap +
+
+
PHPMailer::$WordWrap in class.phpmailer.php
+
Sets word wrapping on the body of the message to a given number of characters.
+
+
+ +
+ a + b + c + d + e + f + h + i + m + n + p + q + r + s + t + u + v + w +
+ \ No newline at end of file diff --git a/inc/classes/third_party/php_mailer/phpdoc/errors.html b/inc/classes/third_party/php_mailer/phpdoc/errors.html new file mode 100644 index 00000000..d5781a06 --- /dev/null +++ b/inc/classes/third_party/php_mailer/phpdoc/errors.html @@ -0,0 +1,23 @@ + + + + + + phpDocumentor Parser Errors and Warnings + + + + + Post-parsing
+class.smtp.php
+

class.phpmailer.php

+

Warnings:


+Warning on line 1530 - no @package tag was used in a DocBlock for file C:\dev\phpDocumentor-1.2.0\Classes\class.phpmailer.php
+

class.smtp.php

+

Warnings:


+Warning on line 1039 - no @package tag was used in a DocBlock for file C:\dev\phpDocumentor-1.2.0\Classes\class.smtp.php
+

+ Documention generated on Mon, 28 Jul 2003 23:25:50 -0400 by phpDocumentor 1.2.0 +

+ + \ No newline at end of file diff --git a/inc/classes/third_party/php_mailer/phpdoc/index.html b/inc/classes/third_party/php_mailer/phpdoc/index.html new file mode 100644 index 00000000..f2b2c7aa --- /dev/null +++ b/inc/classes/third_party/php_mailer/phpdoc/index.html @@ -0,0 +1,24 @@ + + + + + + Generated Documentation + + + + + + + + + + + <H2>Frame Alert</H2> + <P>This document is designed to be viewed using the frames feature. + If you see this message, you are using a non-frame-capable web client.</P> + + + \ No newline at end of file diff --git a/inc/classes/third_party/php_mailer/phpdoc/li_PHPMailer.html b/inc/classes/third_party/php_mailer/phpdoc/li_PHPMailer.html new file mode 100644 index 00000000..ec8456a0 --- /dev/null +++ b/inc/classes/third_party/php_mailer/phpdoc/li_PHPMailer.html @@ -0,0 +1,36 @@ + + + + + + + + + + +
PHPMailer
+
+ +
+ +
Description
+
+ Class trees
+ Index of elements
+
+ + + +
Classes
+
PHPMailer
+
SMTP
+
Files
+
class.phpmailer.php
+
class.smtp.php
+ + +
+
+

phpDocumentor v 1.2.0

+ + \ No newline at end of file diff --git a/inc/classes/third_party/php_mailer/phpdoc/media/banner.css b/inc/classes/third_party/php_mailer/phpdoc/media/banner.css new file mode 100644 index 00000000..f2149ebb --- /dev/null +++ b/inc/classes/third_party/php_mailer/phpdoc/media/banner.css @@ -0,0 +1,32 @@ +body +{ + background-color: #CCCCFF; + margin: 0px; + padding: 0px; +} + +/* Banner (top bar) classes */ + +.banner { } + +.banner-menu +{ + clear: both; + padding: .5em; + border-top: 2px solid #6666AA; +} + +.banner-title +{ + text-align: right; + font-size: 20pt; + font-weight: bold; + margin: .2em; +} + +.package-selector +{ + background-color: #AAAADD; + border: 1px solid black; + color: yellow; +} diff --git a/inc/classes/third_party/php_mailer/phpdoc/media/stylesheet.css b/inc/classes/third_party/php_mailer/phpdoc/media/stylesheet.css new file mode 100644 index 00000000..7a811396 --- /dev/null +++ b/inc/classes/third_party/php_mailer/phpdoc/media/stylesheet.css @@ -0,0 +1,133 @@ +a { color: #336699; text-decoration: none; } +a:hover { color: #6699CC; text-decoration: underline; } +a:active { color: #6699CC; text-decoration: underline; } + +body, table { font-family: Georgia, Times New Roman, Times, serif; font-size: 10pt } +p, li { line-height: 140% } +a img { border: 0px; } +dd { margin-left: 0px; padding-left: 1em; } + +/* Page layout/boxes */ + +.info-box {} +.info-box-title { margin: 1em 0em 0em 0em; padding: .25em; font-weight: normal; font-size: 14pt; border: 2px solid #999999; background-color: #CCCCFF } +.info-box-body { border: 1px solid #999999; padding: .5em; } +.nav-bar { font-size: 8pt; white-space: nowrap; text-align: right; padding: .2em; margin: 0em 0em 1em 0em; } + +.oddrow { background-color: #F8F8F8; border: 1px solid #AAAAAA; padding: .5em; margin-bottom: 1em} +.evenrow { border: 1px solid #AAAAAA; padding: .5em; margin-bottom: 1em} + +.page-body { max-width: 800px; margin: auto; } +.tree dl { margin: 0px } + +/* Index formatting classes */ + +.index-item-body { margin-top: .5em; margin-bottom: .5em} +.index-item-description { margin-top: .25em } +.index-item-details { font-weight: normal; font-style: italic; font-size: 8pt } +.index-letter-section { background-color: #EEEEEE; border: 1px dotted #999999; padding: .5em; margin-bottom: 1em} +.index-letter-title { font-size: 12pt; font-weight: bold } +.index-letter-menu { text-align: center; margin: 1em } +.index-letter { font-size: 12pt } + +/* Docbook classes */ + +.description {} +.short-description { font-weight: bold; color: #666666; } +.tags { padding-left: 0em; margin-left: 3em; color: #666666; list-style-type: square; } +.parameters { padding-left: 0em; margin-left: 3em; font-style: italic; list-style-type: square; } +.redefinitions { font-size: 8pt; padding-left: 0em; margin-left: 2em; } +.package { } +.package-title { font-weight: bold; font-size: 14pt; border-bottom: 1px solid black } +.package-details { font-size: 85%; } +.sub-package { font-weight: bold; font-size: 120% } +.tutorial { border-width: thin; border-color: #0066ff } +.tutorial-nav-box { width: 100%; border: 1px solid #999999; background-color: #F8F8F8; } +.nav-button-disabled { color: #999999; } +.nav-button:active, +.nav-button:focus, +.nav-button:hover { background-color: #DDDDDD; outline: 1px solid #999999; text-decoration: none } +.folder-title { font-style: italic } + +/* Generic formatting */ + +.field { font-weight: bold; } +.detail { font-size: 8pt; } +.notes { font-style: italic; font-size: 8pt; } +.separator { background-color: #999999; height: 2px; } +.warning { color: #FF6600; } +.disabled { font-style: italic; color: #999999; } + +/* Code elements */ + +.line-number { } + +.class-table { width: 100%; } +.class-table-header { border-bottom: 1px dotted #666666; text-align: left} +.class-name { color: #000000; font-weight: bold; } + +.method-summary { padding-left: 1em; font-size: 8pt } +.method-header { } +.method-definition { margin-bottom: .3em } +.method-title { font-weight: bold; } +.method-name { font-weight: bold; } +.method-signature { font-size: 85%; color: #666666; margin: .5em 0em } +.method-result { font-style: italic; } + +.var-summary { padding-left: 1em; font-size: 8pt; } +.var-header { } +.var-title { margin-bottom: .3em } +.var-type { font-style: italic; } +.var-name { font-weight: bold; } +.var-default {} +.var-description { font-weight: normal; color: #000000; } + +.include-title { } +.include-type { font-style: italic; } +.include-name { font-weight: bold; } + +.const-title { } +.const-name { font-weight: bold; } + +/* Syntax highlighting */ + +.src-code { border: 1px solid #336699; padding: 1em; background-color: #EEEEEE; } + +.src-comm { color: green; } +.src-id { } +.src-inc { color: #0000FF; } +.src-key { color: #0000FF; } +.src-num { color: #CC0000; } +.src-str { color: #66cccc; } +.src-sym { font-weight: bold; } +.src-var { } + +.src-php { font-weight: bold; } + +.src-doc { color: #009999 } +.src-doc-close-template { color: #0000FF } +.src-doc-coretag { color: #0099FF; font-weight: bold } +.src-doc-inlinetag { color: #0099FF } +.src-doc-internal { color: #6699cc } +.src-doc-tag { color: #0080CC } +.src-doc-template { color: #0000FF } +.src-doc-type { font-style: italic } +.src-doc-var { font-style: italic } + +/* tutorial */ + +.authors { } +.author { font-style: italic; font-weight: bold } +.author-blurb { margin: .5em 0em .5em 2em; font-size: 85%; font-weight: normal; font-style: normal } +.example { border: 1px dashed #999999; background-color: #EEEEEE; padding: .5em } +.listing { border: 1px dashed #999999; background-color: #EEEEEE; padding: .5em; white-space: nowrap } +.release-info { font-size: 85%; font-style: italic; margin: 1em 0em } +.ref-title-box { } +.ref-title { } +.ref-purpose { font-style: italic; color: #666666 } +.ref-synopsis { } +.title { font-weight: bold; margin: 1em 0em 0em 0em; padding: .25em; border: 2px solid #999999; background-color: #CCCCFF } +.cmd-synopsis { margin: 1em 0em } +.cmd-title { font-weight: bold } +.toc { margin-left: 2em; padding-left: 0em } + diff --git a/inc/classes/third_party/php_mailer/phpdoc/packages.html b/inc/classes/third_party/php_mailer/phpdoc/packages.html new file mode 100644 index 00000000..fdf40b0b --- /dev/null +++ b/inc/classes/third_party/php_mailer/phpdoc/packages.html @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/inc/classes/third_party/php_mailer/test/phpmailer_test.php b/inc/classes/third_party/php_mailer/test/phpmailer_test.php new file mode 100644 index 00000000..22d6f42b --- /dev/null +++ b/inc/classes/third_party/php_mailer/test/phpmailer_test.php @@ -0,0 +1,572 @@ +TestCase( $name ); + } + + /** + * Run before each test is started. + */ + function setUp() { + global $global_vars; + global $INCLUDE_DIR; + + $this->Mail = new PHPMailer(); + + $this->Mail->Priority = 3; + $this->Mail->Encoding = "8bit"; + $this->Mail->CharSet = "iso-8859-1"; + $this->Mail->From = "unit_test@phpmailer.sf.net"; + $this->Mail->FromName = "Unit Tester"; + $this->Mail->Sender = ""; + $this->Mail->Subject = "Unit Test"; + $this->Mail->Body = ""; + $this->Mail->AltBody = ""; + $this->Mail->WordWrap = 0; + $this->Mail->Host = $global_vars["mail_host"]; + $this->Mail->Port = 25; + $this->Mail->Helo = "localhost.localdomain"; + $this->Mail->SMTPAuth = false; + $this->Mail->Username = ""; + $this->Mail->Password = ""; + $this->Mail->PluginDir = $INCLUDE_DIR; + $this->Mail->AddReplyTo("no_reply@phpmailer.sf.net", "Reply Guy"); + $this->Mail->Sender = "unit_test@phpmailer.sf.net"; + + if(strlen($this->Mail->Host) > 0) + $this->Mail->Mailer = "smtp"; + else + { + $this->Mail->Mailer = "mail"; + $this->Sender = "unit_test@phpmailer.sf.net"; + } + + global $global_vars; + $this->SetAddress($global_vars["mail_to"], "Test User"); + if(strlen($global_vars["mail_cc"]) > 0) + $this->SetAddress($global_vars["mail_cc"], "Carbon User", "cc"); + } + + /** + * Run after each test is completed. + */ + function tearDown() { + // Clean global variables + $this->Mail = NULL; + $this->ChangeLog = array(); + $this->NoteLog = array(); + } + + + /** + * Build the body of the message in the appropriate format. + * @private + * @returns void + */ + function BuildBody() { + $this->CheckChanges(); + + // Determine line endings for message + if($this->Mail->ContentType == "text/html" || strlen($this->Mail->AltBody) > 0) + { + $eol = "
"; + $bullet = "
  • "; + $bullet_start = "
      "; + $bullet_end = "
    "; + } + else + { + $eol = "\n"; + $bullet = " - "; + $bullet_start = ""; + $bullet_end = ""; + } + + $ReportBody = ""; + + $ReportBody .= "---------------------" . $eol; + $ReportBody .= "Unit Test Information" . $eol; + $ReportBody .= "---------------------" . $eol; + $ReportBody .= "phpmailer version: " . $this->Mail->Version . $eol; + $ReportBody .= "Content Type: " . $this->Mail->ContentType . $eol; + + if(strlen($this->Mail->Host) > 0) + $ReportBody .= "Host: " . $this->Mail->Host . $eol; + + // If attachments then create an attachment list + if(count($this->Mail->attachment) > 0) + { + $ReportBody .= "Attachments:" . $eol; + $ReportBody .= $bullet_start; + for($i = 0; $i < count($this->Mail->attachment); $i++) + { + $ReportBody .= $bullet . "Name: " . $this->Mail->attachment[$i][1] . ", "; + $ReportBody .= "Encoding: " . $this->Mail->attachment[$i][3] . ", "; + $ReportBody .= "Type: " . $this->Mail->attachment[$i][4] . $eol; + } + $ReportBody .= $bullet_end . $eol; + } + + // If there are changes then list them + if(count($this->ChangeLog) > 0) + { + $ReportBody .= "Changes" . $eol; + $ReportBody .= "-------" . $eol; + + $ReportBody .= $bullet_start; + for($i = 0; $i < count($this->ChangeLog); $i++) + { + $ReportBody .= $bullet . $this->ChangeLog[$i][0] . " was changed to [" . + $this->ChangeLog[$i][1] . "]" . $eol; + } + $ReportBody .= $bullet_end . $eol . $eol; + } + + // If there are notes then list them + if(count($this->NoteLog) > 0) + { + $ReportBody .= "Notes" . $eol; + $ReportBody .= "-----" . $eol; + + $ReportBody .= $bullet_start; + for($i = 0; $i < count($this->NoteLog); $i++) + { + $ReportBody .= $bullet . $this->NoteLog[$i] . $eol; + } + $ReportBody .= $bullet_end; + } + + // Re-attach the original body + $this->Mail->Body .= $eol . $eol . $ReportBody; + } + + /** + * Check which default settings have been changed for the report. + * @private + * @returns void + */ + function CheckChanges() { + if($this->Mail->Priority != 3) + $this->AddChange("Priority", $this->Mail->Priority); + if($this->Mail->Encoding != "8bit") + $this->AddChange("Encoding", $this->Mail->Encoding); + if($this->Mail->CharSet != "iso-8859-1") + $this->AddChange("CharSet", $this->Mail->CharSet); + if($this->Mail->Sender != "") + $this->AddChange("Sender", $this->Mail->Sender); + if($this->Mail->WordWrap != 0) + $this->AddChange("WordWrap", $this->Mail->WordWrap); + if($this->Mail->Mailer != "mail") + $this->AddChange("Mailer", $this->Mail->Mailer); + if($this->Mail->Port != 25) + $this->AddChange("Port", $this->Mail->Port); + if($this->Mail->Helo != "localhost.localdomain") + $this->AddChange("Helo", $this->Mail->Helo); + if($this->Mail->SMTPAuth) + $this->AddChange("SMTPAuth", "true"); + } + + /** + * Adds a change entry. + * @private + * @returns void + */ + function AddChange($sName, $sNewValue) { + $cur = count($this->ChangeLog); + $this->ChangeLog[$cur][0] = $sName; + $this->ChangeLog[$cur][1] = $sNewValue; + } + + /** + * Adds a simple note to the message. + * @public + * @returns void + */ + function AddNote($sValue) { + $this->NoteLog[] = $sValue; + } + + /** + * Adds all of the addresses + * @public + * @returns void + */ + function SetAddress($sAddress, $sName = "", $sType = "to") { + switch($sType) + { + case "to": + $this->Mail->AddAddress($sAddress, $sName); + break; + case "cc": + $this->Mail->AddCC($sAddress, $sName); + break; + case "bcc": + $this->Mail->AddBCC($sAddress, $sName); + break; + } + } + + ///////////////////////////////////////////////// + // UNIT TESTS + ///////////////////////////////////////////////// + + /** + * Try a plain message. + */ + function test_WordWrap() { + + $this->Mail->WordWrap = 40; + $my_body = "Here is the main body of this message. It should " . + "be quite a few lines. It should be wrapped at the " . + "40 characters. Make sure that it is."; + $nBodyLen = strlen($my_body); + $my_body .= "\n\nThis is the above body length: " . $nBodyLen; + + $this->Mail->Body = $my_body; + $this->Mail->Subject .= ": Wordwrap"; + + $this->BuildBody(); + $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); + } + + /** + * Try a plain message. + */ + function test_Low_Priority() { + + $this->Mail->Priority = 5; + $this->Mail->Body = "Here is the main body. There should be " . + "a reply to address in this message."; + $this->Mail->Subject .= ": Low Priority"; + $this->Mail->AddReplyTo("nobody@nobody.com", "Nobody (Unit Test)"); + + $this->BuildBody(); + $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); + } + + /** + * Simple plain file attachment test. + */ + function test_Multiple_Plain_FileAttachment() { + + $this->Mail->Body = "Here is the text body"; + $this->Mail->Subject .= ": Plain + Multiple FileAttachments"; + + if(!$this->Mail->AddAttachment("test.png")) + { + $this->assert(false, $this->Mail->ErrorInfo); + return; + } + + if(!$this->Mail->AddAttachment("phpmailer_test.php", "test.txt")) + { + $this->assert(false, $this->Mail->ErrorInfo); + return; + } + + $this->BuildBody(); + $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); + } + + /** + * Simple plain string attachment test. + */ + function test_Plain_StringAttachment() { + + $this->Mail->Body = "Here is the text body"; + $this->Mail->Subject .= ": Plain + StringAttachment"; + + $sAttachment = "These characters are the content of the " . + "string attachment.\nThis might be taken from a ". + "database or some other such thing. "; + + $this->Mail->AddStringAttachment($sAttachment, "string_attach.txt"); + + $this->BuildBody(); + $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); + } + + /** + * Plain quoted-printable message. + */ + function test_Quoted_Printable() { + + $this->Mail->Body = "Here is the main body"; + $this->Mail->Subject .= ": Plain + Quoted-printable"; + $this->Mail->Encoding = "quoted-printable"; + + $this->BuildBody(); + $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); + } + + /** + * Try a plain message. + */ + function test_Html() { + + $this->Mail->IsHTML(true); + $this->Mail->Subject .= ": HTML only"; + + $this->Mail->Body = "This is a test message written in HTML.
    " . + "Go to " . + "http://phpmailer.sourceforge.net/ for new versions of " . + "phpmailer.

    Thank you!"; + + $this->BuildBody(); + $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); + } + + /** + * Simple HTML and attachment test + */ + function test_HTML_Attachment() { + + $this->Mail->Body = "This is the HTML part of the email."; + $this->Mail->Subject .= ": HTML + Attachment"; + $this->Mail->IsHTML(true); + + if(!$this->Mail->AddAttachment("phpmailer_test.php", "test_attach.txt")) + { + $this->assert(false, $this->Mail->ErrorInfo); + return; + } + + $this->BuildBody(); + $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); + } + + /** + * An embedded attachment test. + */ + function test_Embedded_Image() { + + $this->Mail->Body = "Embedded Image: \"phpmailer\"" . + "Here is an image!"; + $this->Mail->Subject .= ": Embedded Image"; + $this->Mail->IsHTML(true); + + if(!$this->Mail->AddEmbeddedImage("test.png", "my-attach", "test.png", + "base64", "image/png")) + { + $this->assert(false, $this->Mail->ErrorInfo); + return; + } + + $this->BuildBody(); + $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); + } + + /** + * An embedded attachment test. + */ + function test_Multi_Embedded_Image() { + + $this->Mail->Body = "Embedded Image: \"phpmailer\"" . + "Here is an image!"; + $this->Mail->Subject .= ": Embedded Image + Attachment"; + $this->Mail->IsHTML(true); + + if(!$this->Mail->AddEmbeddedImage("test.png", "my-attach", "test.png", + "base64", "image/png")) + { + $this->assert(false, $this->Mail->ErrorInfo); + return; + } + + if(!$this->Mail->AddAttachment("phpmailer_test.php", "test.txt")) + { + $this->assert(false, $this->Mail->ErrorInfo); + return; + } + + $this->BuildBody(); + $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); + } + + /** + * Simple multipart/alternative test. + */ + function test_AltBody() { + + $this->Mail->Body = "This is the HTML part of the email."; + $this->Mail->AltBody = "Here is the text body of this message. " . + "It should be quite a few lines. It should be wrapped at the " . + "40 characters. Make sure that it is."; + $this->Mail->WordWrap = 40; + $this->AddNote("This is a mulipart alternative email"); + $this->Mail->Subject .= ": AltBody + Word Wrap"; + + $this->BuildBody(); + $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); + } + + /** + * Simple HTML and attachment test + */ + function test_AltBody_Attachment() { + + $this->Mail->Body = "This is the HTML part of the email."; + $this->Mail->AltBody = "This is the text part of the email."; + $this->Mail->Subject .= ": AltBody + Attachment"; + $this->Mail->IsHTML(true); + + if(!$this->Mail->AddAttachment("phpmailer_test.php", "test_attach.txt")) + { + $this->assert(false, $this->Mail->ErrorInfo); + return; + } + + $this->BuildBody(); + $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); + + $fp = fopen("message.txt", "w"); + fwrite($fp, $this->Mail->CreateHeader() . $this->Mail->CreateBody()); + fclose($fp); + } + + function test_MultipleSend() { + $this->Mail->Body = "Sending two messages without keepalive"; + $this->BuildBody(); + $subject = $this->Mail->Subject; + + $this->Mail->Subject = $subject . ": SMTP 1"; + $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); + + $this->Mail->Subject = $subject . ": SMTP 2"; + $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); + } + + function test_SmtpKeepAlive() { + $this->Mail->Body = "This was done using the SMTP keep-alive."; + $this->BuildBody(); + $subject = $this->Mail->Subject; + + $this->Mail->SMTPKeepAlive = true; + $this->Mail->Subject = $subject . ": SMTP keep-alive 1"; + $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); + + $this->Mail->Subject = $subject . ": SMTP keep-alive 2"; + $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); + $this->Mail->SmtpClose(); + } + + /** + * Tests this denial of service attack: + * http://www.cybsec.com/vuln/PHPMailer-DOS.pdf + */ + function test_DenialOfServiceAttack() { + $this->Mail->Body = "This should no longer cause a denial of service."; + $this->BuildBody(); + + $this->Mail->Subject = str_repeat("A", 998); + $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); + } + + function test_Error() { + $this->Mail->Subject .= ": This should be sent"; + $this->BuildBody(); + $this->Mail->ClearAllRecipients(); // no addresses should cause an error + $this->assert($this->Mail->IsError() == false, "Error found"); + $this->assert($this->Mail->Send() == false, "Send succeeded"); + $this->assert($this->Mail->IsError(), "No error found"); + $this->assertEquals('You must provide at least one ' . + 'recipient email address.', $this->Mail->ErrorInfo); + $this->Mail->AddAddress(get("mail_to")); + $this->assert($this->Mail->Send(), "Send failed"); + } +} + +/** + * Create and run test instance. + */ + +if(isset($HTTP_GET_VARS)) + $global_vars = $HTTP_GET_VARS; +else + $global_vars = $_REQUEST; + +if(isset($global_vars["submitted"])) +{ + echo "Test results:
    "; + $suite = new TestSuite( "phpmailerTest" ); + + $testRunner = new TestRunner; + $testRunner->run($suite); + echo "


    "; +} + +function get($sName) { + global $global_vars; + if(isset($global_vars[$sName])) + return $global_vars[$sName]; + else + return ""; +} + +?> + + + +

    phpmailer Unit Test

    +By entering a SMTP hostname it will automatically perform tests with SMTP. + + + +To Address: "/> +
    +Cc Address: "/> +
    +SMTP Hostname: "/> +

    + + +

  • + + diff --git a/inc/classes/third_party/php_mailer/test/phpunit.php b/inc/classes/third_party/php_mailer/test/phpunit.php new file mode 100644 index 00000000..1d508680 --- /dev/null +++ b/inc/classes/third_party/php_mailer/test/phpunit.php @@ -0,0 +1,376 @@ + +// OntoSys, Inc +// +// $Id: phpunit.php,v 1.1 2002/03/30 19:32:17 bmatzelle Exp $ + +// Copyright (c) 2000 Fred Yankowski + +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, copy, +// modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS +// BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. +// +error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE | + E_CORE_ERROR | E_CORE_WARNING); + +/* +interface Test { + function run(&$aTestResult); + function countTestCases(); +} +*/ + +function trace($msg) { + return; + print($msg); + flush(); +} + + +class Exception { + /* Emulate a Java exception, sort of... */ + var $message; + function Exception($message) { + $this->message = $message; + } + function getMessage() { + return $this->message; + } +} + +class Assert { + function assert($boolean, $message=0) { + if (! $boolean) + $this->fail($message); + } + + function assertEquals($expected, $actual, $message=0) { + if ($expected != $actual) { + $this->failNotEquals($expected, $actual, "expected", $message); + } + } + + function assertRegexp($regexp, $actual, $message=false) { + if (! preg_match($regexp, $actual)) { + $this->failNotEquals($regexp, $actual, "pattern", $message); + } + } + + function failNotEquals($expected, $actual, $expected_label, $message=0) { + // Private function for reporting failure to match. + $str = $message ? ($message . ' ') : ''; + $str .= "($expected_label/actual)
    "; + $htmlExpected = htmlspecialchars($expected); + $htmlActual = htmlspecialchars($actual); + $str .= sprintf("
    %s\n--------\n%s
    ", + $htmlExpected, $htmlActual); + $this->fail($str); + } +} + +class TestCase extends Assert /* implements Test */ { + /* Defines context for running tests. Specific context -- such as + instance variables, global variables, global state -- is defined + by creating a subclass that specializes the setUp() and + tearDown() methods. A specific test is defined by a subclass + that specializes the runTest() method. */ + var $fName; + var $fResult; + var $fExceptions = array(); + + function TestCase($name) { + $this->fName = $name; + } + + function run($testResult=0) { + /* Run this single test, by calling the run() method of the + TestResult object which will in turn call the runBare() method + of this object. That complication allows the TestResult object + to do various kinds of progress reporting as it invokes each + test. Create/obtain a TestResult object if none was passed in. + Note that if a TestResult object was passed in, it must be by + reference. */ + if (! $testResult) + $testResult = $this->_createResult(); + $this->fResult = $testResult; + $testResult->run(&$this); + $this->fResult = 0; + return $testResult; + } + + function countTestCases() { + return 1; + } + + function runTest() { + $name = $this->name(); + // Since isset($this->$name) is false, no way to run defensive checks + $this->$name(); + } + + function setUp() /* expect override */ { + //print("TestCase::setUp()
    \n"); + } + + function tearDown() /* possible override */ { + //print("TestCase::tearDown()
    \n"); + } + + //////////////////////////////////////////////////////////////// + + + function _createResult() /* protected */ { + /* override this to use specialized subclass of TestResult */ + return new TestResult; + } + + function fail($message=0) { + //printf("TestCase::fail(%s)
    \n", ($message) ? $message : ''); + /* JUnit throws AssertionFailedError here. We just record the + failure and carry on */ + $this->fExceptions[] = new Exception(&$message); + } + + function error($message) { + /* report error that requires correction in the test script + itself, or (heaven forbid) in this testing infrastructure */ + printf('ERROR: ' . $message . '
    '); + $this->fResult->stop(); + } + + function failed() { + return count($this->fExceptions); + } + + function getExceptions() { + return $this->fExceptions; + } + + function name() { + return $this->fName; + } + + function runBare() { + $this->setup(); + $this->runTest(); + $this->tearDown(); + } +} + + +class TestSuite /* implements Test */ { + /* Compose a set of Tests (instances of TestCase or TestSuite), and + run them all. */ + var $fTests = array(); + + function TestSuite($classname=false) { + if ($classname) { + // Find all methods of the given class whose name starts with + // "test" and add them to the test suite. We are just _barely_ + // able to do this with PHP's limited introspection... Note + // that PHP seems to store method names in lower case, and we + // have to avoid the constructor function for the TestCase class + // superclass. This will fail when $classname starts with + // "Test" since that will have a constructor method that will + // get matched below and then treated (incorrectly) as a test + // method. So don't name any TestCase subclasses as "Test..."! + if (floor(phpversion()) >= 4) { + // PHP4 introspection, submitted by Dylan Kuhn + $names = get_class_methods($classname); + while (list($key, $method) = each($names)) { + if (preg_match('/^test/', $method) && $method != "testcase") { + $this->addTest(new $classname($method)); + } + } + } + else { + $dummy = new $classname("dummy"); + $names = (array) $dummy; + while (list($key, $value) = each($names)) { + $type = gettype($value); + if ($type == "user function" && preg_match('/^test/', $key) + && $key != "testcase") { + $this->addTest(new $classname($key)); + } + } + } + } + } + + function addTest($test) { + /* Add TestCase or TestSuite to this TestSuite */ + $this->fTests[] = $test; + } + + function run(&$testResult) { + /* Run all TestCases and TestSuites comprising this TestSuite, + accumulating results in the given TestResult object. */ + reset($this->fTests); + while (list($na, $test) = each($this->fTests)) { + if ($testResult->shouldStop()) + break; + $test->run(&$testResult); + } + } + + function countTestCases() { + /* Number of TestCases comprising this TestSuite (including those + in any constituent TestSuites) */ + $count = 0; + reset($fTests); + while (list($na, $test_case) = each($this->fTests)) { + $count += $test_case->countTestCases(); + } + return $count; + } +} + + +class TestFailure { + /* Record failure of a single TestCase, associating it with the + exception(s) that occurred */ + var $fFailedTestName; + var $fExceptions; + + function TestFailure(&$test, &$exceptions) { + $this->fFailedTestName = $test->name(); + $this->fExceptions = $exceptions; + } + + function getExceptions() { + return $this->fExceptions; + } + function getTestName() { + return $this->fFailedTestName; + } +} + + +class TestResult { + /* Collect the results of running a set of TestCases. */ + var $fFailures = array(); + var $fRunTests = 0; + var $fStop = false; + + function TestResult() { } + + function _endTest($test) /* protected */ { + /* specialize this for end-of-test action, such as progress + reports */ + } + + function getFailures() { + return $this->fFailures; + } + + function run($test) { + /* Run a single TestCase in the context of this TestResult */ + $this->_startTest($test); + $this->fRunTests++; + + $test->runBare(); + + /* this is where JUnit would catch AssertionFailedError */ + $exceptions = $test->getExceptions(); + if ($exceptions) + $this->fFailures[] = new TestFailure(&$test, &$exceptions); + $this->_endTest($test); + } + + function countTests() { + return $this->fRunTests; + } + + function shouldStop() { + return $this->fStop; + } + + function _startTest($test) /* protected */ { + /* specialize this for start-of-test actions */ + } + + function stop() { + /* set indication that the test sequence should halt */ + $fStop = true; + } + + function countFailures() { + return count($this->fFailures); + } +} + + +class TextTestResult extends TestResult { + /* Specialize TestResult to produce text/html report */ + function TextTestResult() { + $this->TestResult(); // call superclass constructor + } + + function report() { + /* report result of test run */ + $nRun = $this->countTests(); + $nFailures = $this->countFailures(); + printf("

    %s test%s run
    ", $nRun, ($nRun == 1) ? '' : 's'); + printf("%s failure%s.
    \n", $nFailures, ($nFailures == 1) ? '' : 's'); + if ($nFailures == 0) + return; + + print("

      \n"); + $failures = $this->getFailures(); + while (list($i, $failure) = each($failures)) { + $failedTestName = $failure->getTestName(); + printf("
    1. %s\n", $failedTestName); + + $exceptions = $failure->getExceptions(); + print("
        "); + while (list($na, $exception) = each($exceptions)) + printf("
      • %s\n", $exception->getMessage()); + print("
      "); + } + print("
    \n"); + } + + function _startTest($test) { + printf("%s ", $test->name()); + flush(); + } + + function _endTest($test) { + $outcome = $test->failed() + ? "FAIL" + : "ok"; + printf("$outcome
    \n"); + flush(); + } +} + + +class TestRunner { + /* Run a suite of tests and report results. */ + function run($suite) { + $result = new TextTestResult; + $suite->run($result); + $result->report(); + } +} + +?> diff --git a/inc/classes/third_party/php_mailer/test/test.png b/inc/classes/third_party/php_mailer/test/test.png new file mode 100644 index 0000000000000000000000000000000000000000..02de5a7aa3507dcec1e4349520ba3e8d8f7da4d6 GIT binary patch literal 1280 zcmeAS@N?(olHy`uVBq!ia0vp^tw5~K!2~4N<;e5_DVB6cUq=Rpjs4tz5?O(Kwj^(N z7lt)J7K6`}lP`c2XMsm#F#`j)5C}6~x?A@LD9B#o>FdgViCLDPN5AUi^*W$IwVp1H zAr*7p&f1@M+e+k^|GQka$^gd77pzXAva3|tw#@qU#D{GY+ZFCDwG1cEE579X#FX@$ z>FgwH&r=2B{84unZkVCiZ2N-g>I8;;hdm>XmCd=c^yvZlCI_MawKnqnCmAdw)?ZJ! z(AIo@e{`ec)BgLq2R?8-ZjY0&|8nTZLh)n#dkyMdw0?Bf?~$)c{BwaDo7B9IhZmN_ zh%E0uYH;3Pyt^=vfg$lt&fag6k0_-)7M*|G)$q*c&0lYID|HLld!D2e%F$=%SRuTY%I{2>Z{`vAZ>PV)}|}nN;w+U!QCIM z%dF3Q&h>n}=zwNb};ib(x>mdBz9tFM3#&2Z?-_RqK4ZYm+e055CrlA)a-UVpFR%v^PFVTssrYu_S`qZP4zZaccRhpt_9sylhjwpf+< z?Unnqytf|Oq_caOTOat-{V}jySM+ZLcry9!jFnfUInkZcQYhKM%L?N z&;!?rRVNa)m=6Fgxg2tDuEA9ET|#r_i?D{h*tzce28%w4!-tRgPZEBrw|%nx;k`%s zmfAYKyY+2b?$bqXn&r8-ISa3Ed-Xbga%WV_rQePT^77kD|K`Wu-}?6KQP#RWxwn}c zwyiVVWYOa4alSPF_O^E6V7L1351I46v}`n=eDeF}VulLinF~}7&9IfYQ}efLn#`@T z=<5}~4|Vgtn(q9aBQi8J`g;4eTzYtu=Z+lD zh7)#nVsqqgZL{jmKBw#CAyMYrd^hQ7_PL8!4qsoNfBW0BM@jw%&i;>o+4}Q$48E+4 clFJ|2pD+7py#+`y85}Sb4q9e08zkVlmGw# literal 0 HcmV?d00001 diff --git a/inc/config.php b/inc/config.php new file mode 100644 index 00000000..143ad06c --- /dev/null +++ b/inc/config.php @@ -0,0 +1,288 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +// Load the class from inc/config direktory +@require_once(dirname(__FILE__) . '/classes/interfaces/class_FrameworkInterface.php'); +@require_once(dirname(__FILE__) . '/classes/interfaces/registry/class_Registerable.php'); +@require_once(dirname(__FILE__) . '/config/class_FrameworkConfiguration.php'); + +// Get a new configuration instance +$cfg = FrameworkConfiguration::getInstance(); + +// CFG: SERVER-PATH +$cfg->setConfigEntry('base_path', (dirname(dirname(__FILE__)) . '/')); + +// CFG: BASE-URL +$cfg->setConfigEntry('base_url', $cfg->detectBaseUrl()); + +// CFG: DATABASE-TYPE +$cfg->setConfigEntry('db_type', "local"); + +// CFG: LOCAL-DB-PATH +$cfg->setConfigEntry('local_db_path', $cfg->readConfig('base_path') . "db/"); + +// CFG: TIME-ZONE +$cfg->setDefaultTimezone("Europe/Berlin"); + +// CFG: MAGIC-QUOTES-RUNTIME +$cfg->setMagicQuotesRuntime(false); + +// CFG: CLASS-PREFIX +$cfg->setConfigEntry('class_prefix', "class_"); + +// CFG: CLASS-SUFFIX +$cfg->setConfigEntry('class_suffix', ".php"); + +// CFG: RAW-TEMPLATE-EXTENSION +$cfg->setConfigEntry('raw_template_extension', ".tpl"); + +// CFG: CODE-TEMPLATE-EXTENSION +$cfg->setConfigEntry('code_template_extension', ".ctp"); + +// CFG: SELECTOR-PATH +$cfg->setConfigEntry('selector_path', "selector"); + +// CFG: APPLICATION-HELPER +$cfg->setConfigEntry('app_helper_class', "ApplicationHelper"); + +// CFG: LAUNCH-METHOD +$cfg->setConfigEntry('entry_method', "entryPoint"); + +// CFG: TEMPLATE-BASE-PATH +$cfg->setConfigEntry('tpl_base_path', "templates/"); + +// CFG: LANGUAGE-BASE-PATH +$cfg->setConfigEntry('lang_base_path', "inc/language/"); + +// CFG: COMPRESSOR-BASE-PATH +$cfg->setConfigEntry('compressor_base_path', "inc/classes/main/compressor/"); + +// CFG: APPLICATION-PATH +$cfg->setConfigEntry('application_path', $cfg->readConfig('base_path') . "application/"); + +// CFG: COMPILE-OUTPUT-PATH +$cfg->setConfigEntry('compile_output_path', "templates/_compiled/"); + +// CFG: TEMPLATE-ENGINE +$cfg->setConfigEntry('template_class', "WebTemplateEngine"); + +// CFG: DEBUG-ENGINE +$cfg->setConfigEntry('debug_class', "DebugWebOutput"); + +// CFG: DEFAULT-LANGUAGE +$cfg->setConfigEntry('default_lang', "de"); // A two-char language string: de for german, en for english and so on + +// CFG: WEB-TEMPLATE-TYPE +$cfg->setConfigEntry('web_template_type', "html"); + +// CFG: EMAIL-TEMPLATE-TYPE +$cfg->setConfigEntry('email_template_type', "emails"); + +// CFG: CODE-TEMPLATE-TYPE +$cfg->setConfigEntry('code_template_type', "code"); + +// CFG: WEB-ENGINE +$cfg->setConfigEntry('web_engine', "WebOutput"); + +// CFG: SELECTOR-TEMPLATE-PREFIX +$cfg->setConfigEntry('tpl_selector_prefix', "selector"); + +// CFG: WEB-CONTENT-TYPE +$cfg->setConfigEntry('web_content_type', "text/html"); + +// CFG: VALID-TEMPLATE-VARIABLE +$cfg->setConfigEntry('tpl_valid_var', "content"); + +// CFG: META-AUTHOR +$cfg->setConfigEntry('meta_author', "Roland Häder"); + +// CFG: META-PUBLISHER +$cfg->setConfigEntry('meta_publisher', "Roland Häder"); + +// CFG: META-KEYWORDS +$cfg->setConfigEntry('meta_keywords', "test,test,test"); + +// CFG: META-DESCRIPTION +$cfg->setConfigEntry('meta_description', "A lame description for an application framework"); + +// CFG: SELECTOR-MAIN-TEMPLATE +$cfg->setConfigEntry('selector_main_tpl', "selector_main"); + +// CFG: SELECTOR-APPS-TEMPLATE +$cfg->setConfigEntry('selector_apps_tpl', "selector_apps"); + +// CFG: SELECTOR-NAME +$cfg->setConfigEntry('selector_name', "selector"); + +// CFG: DEFAULT-APPLICATION +$cfg->setConfigEntry('default_application', "selector"); + +// CFG: VERBOSE-LEVEL +$cfg->setConfigEntry('verbose_level', 0); + +// CFG: CACHE-TYPE +$cfg->setConfigEntry('cache_class', "MemoryCache"); + +// CFG: SEARCH-CRITERIA +$cfg->setConfigEntry('search_criteria_class', "SearchCriteria"); + +// CFG: DATASET-CRITERIA +$cfg->setConfigEntry('dataset_criteria_class', "DataSetCriteria"); + +// CFG: UPDATE-CRITERIA +$cfg->setConfigEntry('update_criteria_class', "UpdateCriteria"); + +// CFG: FILE-IO-HANDLER +$cfg->setConfigEntry('file_io_class', "FileIoHandler"); + +// CFG: FILTER-CHAIN +$cfg->setConfigEntry('filter_chain_class', "FilterChain"); + +// CFG: FILE-INPUT-STREAM +$cfg->setConfigEntry('file_input_class', "FileIoStream"); + +// CFG: FILE-OUTPUT-STREAM +$cfg->setConfigEntry('file_output_class', "FileIoStream"); + +// CFG: EMAIL-VALIDATOR-FILTER +$cfg->setConfigEntry('email_validator_filter', "EmailValidatorFilter"); + +// CFG: USERNAME-VALIDATOR-FILTER +$cfg->setConfigEntry('username_validator_filter', "UserNameValidatorFilter"); + +// CFG: USERNAME-IS-GUEST-FILTER +$cfg->setConfigEntry('username_is_guest_filter', "UserNameIsGuestFilter"); + +// CFG: PASSWORD-VALIDATOR-FILTER +$cfg->setConfigEntry('password_validator_filter', "PasswordValidatorFilter"); + +// CFG: RULES-ACCEPTED-FILTER +$cfg->setConfigEntry('rules_accepted_filter', "RulesAcceptedFilter"); + +// CFG: USERNAME-VERIFIER-FILTER +$cfg->setConfigEntry('username_verifier_filter', "UserNameVerifierFilter"); + +// CFG: USER-GUEST-VERIFIER-FILTER +$cfg->setConfigEntry('user_guest_verifier_filter', "UserGuestVerifierFilter"); + +// CFG: EMAIL-VERIFIER-FILTER +$cfg->setConfigEntry('email_verifier_filter', "EmailVerifierFilter"); + +// CFG: PASSWORD-VERIFIER-FILTER +$cfg->setConfigEntry('password_verifier_filter', "PasswordVerifierFilter"); + +// CFG: PASSWD-GUEST-VERIFIER-FILTER +$cfg->setConfigEntry('passwd_guest_verifier_filter', "PasswordGuestVerifierFilter"); + +// CFG: EMAIL-CHANGE-FILTER +$cfg->setConfigEntry('email_change_filter', "EmailChangeFilter"); + +// CFG: PASSWORD-CHANGE-FILTER +$cfg->setConfigEntry('password_change_filter', "PasswordChangeFilter"); + +// CFG: ACCOUNT-PASSWORD-FILTER +$cfg->setConfigEntry('account_password_filter', "AccountPasswordVerifierFilter"); + +// CFG: USER-STATUS-FILTER +$cfg->setConfigEntry('user_status_filter', "UserStatusVerifierFilter"); + +// CFG: USER-UNCONFIRMED-FILTER +$cfg->setConfigEntry('user_unconfirmed_filter', "UserUnconfirmedVerifierFilter"); + +// CFG: CRYPTO-CLASS +$cfg->setConfigEntry('crypto_class', "CryptoHelper"); + +// CFG: RNG-CLASS +$cfg->setConfigEntry('rng_class', "RandomNumberGenerator"); + +// CFG: USER-DB-WRAPPER-CLASS +$cfg->setConfigEntry('user_db_wrapper_class', "UserDatabaseWrapper"); + +// CFG: NEWS-DB-WRAPPER-CLASS +$cfg->setConfigEntry('news_db_wrapper_class', "NewsDatabaseWrapper"); + +// CFG: WEB-CMD-RESOLVER-CLASS +$cfg->setConfigEntry('web_cmd_resolver_class', "WebCommandResolver"); + +// CFG: IMAGE-CMD-RESOLVER-CLASS +$cfg->setConfigEntry('image_cmd_resolver_class', "ImageCommandResolver"); + +// CFG: MAILER-CLASS +$cfg->setConfigEntry('mailer_class', "DebugMailer"); + +// CFG: MATH-PRIME +$cfg->setConfigEntry('math_prime', 591623); + +// CFG: DATE-KEY +$cfg->setConfigEntry('date_key', date("d-m-Y (l-F-T)", time())); + +// CFG: SALT-LENGTH +$cfg->setConfigEntry('salt_length', 10); + +// CFG: RND-STR-LENGTH +$cfg->setConfigEntry('rnd_str_length', 128); + +// CFG: HASH-MASK +$cfg->setConfigEntry('hash_mask', "%1s:%2s:%3s"); // 1=salt, 2=extra salt, 3=plain password + +// CFG: IS-SINGLE-SERVER +$cfg->setConfigEntry('is_single_server', "Y"); + +// CFG: POST-REGISTRATION-ACTION +$cfg->setConfigEntry('post_registration_class', "LoginAfterRegistrationAction"); + +// CFG: USER-CLASS +$cfg->setConfigEntry('user_class', "Member"); + +// CFG: GUEST-CLASS +$cfg->setConfigEntry('guest_class', "Guest"); + +// CFG: COOKIE-EXPIRE +$cfg->setConfigEntry('cookie_expire', (60*60*2)); // Two hours! + +// CFG: COOKIE-PATH +$cfg->setConfigEntry('cookie_path', $cfg->detectScriptPath() . "/"); + +// CFG: COOKIE-DOMAIN +$cfg->setConfigEntry('cookie_domain', $cfg->detectDomain()); // Is mostly the same... + +// CFG: COOKIE-SSL +$cfg->setConfigEntry('cookie_ssl', (isset($_SERVER['HTTPS']))); + +// CFG: CRYPT-FIXED-SALT +$cfg->setConfigEntry('crypt_fixed_salt', "N"); + +// CFG: DB-UPDATE-PRIMARY-FORCED +$cfg->setConfigEntry('db_update_primary_forced', "Y"); + +// CFG: GERMAN-DATE-TIME +$cfg->setConfigEntry('german_date_time', "%3\$s.%2\$s.%1\$s, %4\$s:%5\$s:%6\$s"); + +// CFG: PRODUCT-INSTALL-MODE +$cfg->setConfigEntry('product_install_mode', "debug"); + +// [EOF] +?> diff --git a/inc/config/.htaccess b/inc/config/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/config/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/config/class_FrameworkConfiguration.php b/inc/config/class_FrameworkConfiguration.php new file mode 100644 index 00000000..e3202603 --- /dev/null +++ b/inc/config/class_FrameworkConfiguration.php @@ -0,0 +1,272 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class FrameworkConfiguration implements Registerable { + /** + * The framework's main configuration array which will be initialized with + * hard-coded configuration data and might be overwritten/extended by + * config data from the database. + */ + private $config = array(); + + /** + * The configuration instance itself + */ + private static $cfgInstance = null; + + // Some constants for the configuration system + const EXCEPTION_CONFIG_ENTRY_IS_EMPTY = 0x130; + const EXCEPTION_CONFIG_ENTRY_WAS_NOT_FOUND = 0x131; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Empty for now + } + + /** + * Getter for an instance of this class + * + * @return $cfgInstance An instance of this class + */ + public final static function getInstance () { + // is the instance there? + if (is_null(self::$cfgInstance)) { + // Create a config instance + self::$cfgInstance = new FrameworkConfiguration(); + } // END - if + + return self::$cfgInstance; + } + + /** + * Setter for default time zone (must be correct!) + * + * @param $zone The time-zone string (e.g. Europe/Berlin) + * @return void + */ + public final function setDefaultTimezone ($zone) { + // At least 5.1.0 is required for this! + if (version_compare(phpversion(), "5.1.0")) { + @date_default_timezone_set($zone); + } // END - if + } + + /** + * Setter for runtime magic quotes + */ + public final function setMagicQuotesRuntime ($enableQuotes) { + // Cast it to boolean + $enableQuotes = (boolean) $enableQuotes; + + // Set it + @set_magic_quotes_runtime($enableQuotes); + } + + /** + * A private include loader + * + * @param $arrayObject The array object with all include files + * @return void + */ + private function loadIncludes (ArrayObject $arrayObject) { + // Load only if there are includes defined + if (!is_null($arrayObject)) { + for ($idx = $arrayObject->getIterator(); $idx->valid(); $idx->next()) { + // Get include file + $inc = $idx->current(); + + // Is the file name really set? + if (!empty($inc)) { + // Base path is by default added + $fqfn = $inc; + + // Base path added? (Uni* / Windows) + if ((substr($inc, 0, 1) != "/") && (substr($inc, 1, 1) != ":")) { + // Generate FQFN + $fqfn = sprintf("%s/inc/extra/%s", $this->readConfig('base_path'), $inc); + } // END - if + } // END - if + + // Include them all here + require($fqfn); + } + } // END - if + } + + /** + * Read a configuration element. + * + * @param $cfgEntry The configuration element + * @return $cfgValue The fetched configuration value + * @throws ConfigEntryIsEmptyException If $cfgEntry is empty + * @throws ConfigEntryNotFoundException If a configuration element + * was not found + */ + public function readConfig ($cfgEntry) { + // Cast to string + $cfgEntry = (string) $cfgEntry; + + // Is a valid configuration entry provided? + if (empty($cfgEntry)) { + // Entry is empty + throw new ConfigEntryIsEmptyException($this, self::EXCEPTION_CONFIG_ENTRY_IS_EMPTY); + } elseif (!isset($this->config[$cfgEntry])) { + // Entry was not found! + throw new ConfigEntryNotFoundException(array(__CLASS__, $cfgEntry), self::EXCEPTION_CONFIG_ENTRY_WAS_NOT_FOUND); + } + + // Debug message + if ((defined('DEBUG_CONFIG')) || (defined('DEBUG_ALL'))) { + echo "[".__METHOD__."] Configuration entry ".$cfgEntry." requested.
    \n"; + } // END - if + + // Return the requested value + return $this->config[$cfgEntry]; + } + + /** + * Set a configuration entry. + * + * @param $cfgEntry The configuration entry we want to add/change + * @param $cfgValue The configuration value we want to set + * @return void + * @throws ConfigEntryIsEmptyException If $cfgEntry is empty + */ + public final function setConfigEntry ($cfgEntry, $cfgValue) { + // Cast to string + $cfgEntry = (string) $cfgEntry; + $cfgValue = (string) $cfgValue; + + // Is a valid configuration entry provided? + if (empty($cfgEntry)) { + // Entry is empty + throw new ConfigEntryIsEmptyException($this, self::EXCEPTION_CONFIG_ENTRY_IS_EMPTY); + } // END - if + + // Set the configuration value + $this->config[$cfgEntry] = $cfgValue; + + // Resort the array + ksort($this->config); + } + + /** + * Compatiblity method to return this class' name + * + * @return __CLASS__ This class' name + */ + public function __toString () { + return get_class($this); + } + + /** + * Dectect and return the base URL for all URLs and forms + * + * @return $baseUrl Detected base URL + */ + public function detectBaseUrl() { + // Initialize the URL + $baseUrl = "http"; + + // Do we have HTTPS? + if (isset($_SERVER['HTTPS'])) { + // Add the >s< for HTTPS + $baseUrl .= "s"; + } // END - if + + // Construct the full URL now and secure it against CSRF attacks + $baseUrl = $baseUrl . "://" . $this->detectDomain() . $this->detectScriptPath(); + + // Return the URL + return $baseUrl; + } + + /** + * Detect safely and return the full domain where this script is installed + * + * @return $fullDomain The detected full domain + */ + public function detectDomain () { + // Full domain is localnet.invalid by default + $fullDomain = "localnet.invalid"; + + // Is the server name there? + if (isset($_SERVER['SERVER_NAME'])) { + // Detect the full domain + $fullDomain = htmlentities(strip_tags($_SERVER['SERVER_NAME']), ENT_QUOTES); + } // END - if + + // Return it + return $fullDomain; + } + + /** + * Detect safely the script path without trailing slash which is the part + * between "http://your-domain.invalid/" and "script-name.php" + */ + public function detectScriptPath () { + // Default is empty + $scriptPath = ""; + + // Is the scriptname set? + if (isset($_SERVER['SCRIPT_NAME'])) { + // Get dirname of it + $scriptPath = dirname($_SERVER['SCRIPT_NAME']); + } // END - if + + // Return it + return $scriptPath; + } + + /** + * Getter for field name + * + * @param $fieldName Field name which we shall get + * @return $fieldValue Field value from the user + */ + function getField ($fieldName) { + // Dummy method! + } + + /** + * Updates a given field with new value + * + * @param $fieldName Field to update + * @param $fieldValue New value to store + * @return void + */ + public function updateDatabaseField ($fieldName, $fieldValue) { + // Dummy method! + } +} + +// [EOF] +?> diff --git a/inc/config/config-hubmaster.php b/inc/config/config-hubmaster.php new file mode 100644 index 00000000..0e792b78 --- /dev/null +++ b/inc/config/config-hubmaster.php @@ -0,0 +1,88 @@ + + * @version 0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +// Get the configuration instance +$cfg = FrameworkConfiguration::getInstance(); + +// CFG: HUB-LISTEN-ADDR +$cfg->setConfigEntry('hub_listen_addr', "0.0.0.0"); + +// CFG: HUB-LISTEN-PORT (zero = auto-choose) +$cfg->setConfigEntry('hub_listen_port', 9060); + +// CFG: HUB-MAX-AUTH-TRIES +$cfg->setConfigEntry('hub_max_auth_tries', 3); + +// CFG: HUB-MSG-AUTH-TRIES +$cfg->setConfigEntry('hub_msg_auth_tries', "AUTH_MAX_TRIES"); + +// CFG: HUB-MSG-SPOOFING +$cfg->setConfigEntry('hub_msg_spoofing', "SPOOFING"); + +// CFG: HUB-MSG-AUTH-REPLY +$cfg->setConfigEntry('hub_msg_auth_reply_timeout', "TIMEOUT_AUTH"); + +// CFG: HUB-MSG-BYE +$cfg->setConfigEntry('hub_msg_bye', "BYE"); + +// CFG: HUB-MASTER-IP +$cfg->setConfigEntry('hub_master_ip', "192.168.1.17"); + +// CFG: HUB-MASTER-PORT +$cfg->setConfigEntry('hub_master_port', 9060); + +// CFG: HUB-AUTH-REQUEST +$cfg->setConfigEntry('hub_auth_request', "AUTH"); + +// CFG: HUB-AUTH-REQUEST-TIMEOUT (5 seconds for whole auth procedure shall be fine) +$cfg->setConfigEntry('hub_auth_request_timeout', 5); + +// CFG: HUB-PEER-HELLO +$cfg->setConfigEntry('hub_peer_hello', "HELLO"); + +// CFG: HUB-HELLO-REPLY +$cfg->setConfigEntry('hub_hello_reply', "ELHO"); + +// CFG: HUB-HELLO-TIMEOUT +$cfg->setConfigEntry('hub_hello_timeout', 30); + +// CFG: HUB-HELLO-RETRIES +$cfg->setConfigEntry('hub_hello_retires', 3); + +// CFG: HUB-PEER-PING +$cfg->setConfigEntry('hub_peer_ping', "PING"); + +// CFG: HUB-PING-REPLY +$cfg->setConfigEntry('hub_ping_reply', "PONG"); + +// CFG: HUB-PING-TIMEOUT +$cfg->setConfigEntry('hub_ping_timeout', 10); + +// CFG: HUB-PING-MAXDROPS +$cfg->setConfigEntry('hub_ping_maxdrops', 3); + +// CFG: HUB-PEER-MISS-PONG +$cfg->setConfigEntry('hub_peer_miss_pong', "PONG_MISS"); + +// [EOF] +?> diff --git a/inc/database.php b/inc/database.php new file mode 100644 index 00000000..de0c7d88 --- /dev/null +++ b/inc/database.php @@ -0,0 +1,92 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +// Initialize layer +$layerInstance = null; + +// Get config instance +$cfg = FrameworkConfiguration::getInstance(); + +// Generate FQFN for the database layer +$INC = sprintf("%sinc/database/lib-%s.php", + $cfg->readConfig('base_path'), + $cfg->readConfig('db_type') +); + +// Load the database layer include +if ((file_exists($INC)) && (is_file($INC)) && (is_readable($INC))) { + // Load the layer + require_once($INC); +} else { + // Layer is missing! + ApplicationEntryPoint::app_die(sprintf("[Main:] Database layer is missing! (%s) -> R.I.P.", + $cfg->readConfig('db_type') + )); +} + +// Clean it up +unset($INC); + +// Prepare database instance +try { + $db = DatabaseConnection::createDatabaseConnection(DebugMiddleware::getInstance(), $layerInstance); +} catch (NullPointerException $e) { + ApplicationEntryPoint::app_die(sprintf("[Main:] Database sub-system not initialized for the follwing reason: %s
    \n", + $e->getMessage() + )); +} catch (InvalidDirectoryResourceException $e) { + ApplicationEntryPoint::app_die(sprintf("[Main:] Database sub-system not initialized for the follwing reason: %s
    \n", + $e->getMessage() + )); +} catch (PathIsEmptyException $e) { + ApplicationEntryPoint::app_die(sprintf("[Main:] Database sub-system not initialized for the follwing reason: %s
    \n", + $e->getMessage() + )); +} catch (PathIsNoDirectoryException $e) { + ApplicationEntryPoint::app_die(sprintf("[Main:] Database sub-system not initialized for the follwing reason: %s
    \n", + $e->getMessage() + )); +} catch (PathReadProtectedException $e) { + ApplicationEntryPoint::app_die(sprintf("[Main:] Database sub-system not initialized for the follwing reason: %s
    \n", + $e->getMessage() + )); +} catch (DirPointerNotOpenedException $e) { + ApplicationEntryPoint::app_die(sprintf("[Main:] Database sub-system not initialized for the follwing reason: %s
    \n", + $e->getMessage() + )); +} + +// Is the app variable there and valid? +if (is_object($app)) $app->setDatabaseInstance($db); + +// Datenbankobjekt debuggen +if (defined('DEBUG_DATABASE_OBJ')) { + DebugMiddleware::getInstance()->output(sprintf("The database sub-system does now look like this:
    +
    %s
    \n", + print_r($db, true) + )); +} + +// [EOF] +?> diff --git a/inc/database/.htaccess b/inc/database/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/database/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/database/lib-local.php b/inc/database/lib-local.php new file mode 100644 index 00000000..9e9d5a66 --- /dev/null +++ b/inc/database/lib-local.php @@ -0,0 +1,51 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +// Zum Testen speichern wir in lokale Dateien (LocalFileDatabase) +try { + $layerInstance = LocalFileDatabase::createLocalFileDatabase(FrameworkConfiguration::getInstance()->readConfig('local_db_path'), FileIoHandler::getInstance()); +} catch (SavePathIsEmptyException $e) { + ApplicationEntryPoint::app_die(sprintf("[Main:] Database layer could not be initialized. Reason: %s", + $e->getMessage() + )); +} catch (SavePathNotFoundException $e) { + ApplicationEntryPoint::app_die(sprintf("[Main:] Database layer could not be initialized. Reason: %s", + $e->getMessage() + )); +} catch (SavePathIsNoDirectoryException $e) { + ApplicationEntryPoint::app_die(sprintf("[Main:] Database layer could not be initialized. Reason: %s", + $e->getMessage() + )); +} catch (SavePathReadProtectedException $e) { + ApplicationEntryPoint::app_die(sprintf("[Main:] Database layer could not be initialized. Reason: %s", + $e->getMessage() + )); +} catch (SavePathWriteProtectedException $e) { + ApplicationEntryPoint::app_die(sprintf("[Main:] Database layer could not be initialized. Reason: %s", + $e->getMessage() + )); +} + +// [EOF] +?> diff --git a/inc/file_io.php b/inc/file_io.php new file mode 100644 index 00000000..c141feab --- /dev/null +++ b/inc/file_io.php @@ -0,0 +1,34 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +// Get the instance +$io = ObjectFactory::createObjectByConfiguredName('file_io_class'); + +// Is the app variable there and valid? +if (is_object($app)) $app->setFileIoInstance($io); + +// [EOF] +?> diff --git a/inc/includes.php b/inc/includes.php new file mode 100644 index 00000000..7e3f5c9f --- /dev/null +++ b/inc/includes.php @@ -0,0 +1,86 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +// Get config instance +$cfg = FrameworkConfiguration::getInstance(); + +// Include the class loader function +require(sprintf("%sinc/loader/class_ClassLoader.php", $cfg->readConfig('base_path'))); + +// Does the user has an application specified? +if (!empty($_GET['app'])) { + // Set the application from string + $application = (string) $_GET['app']; +} elseif (!empty($_SERVER['argv'][1])) { + // Set the application from string + $application = (string) $_SERVER['argv'][1]; + $app = explode('=', trim($application)); + if ($app[0] == 'app') { + // Application is valid! + $application = trim($app[1]); + } else { + // Invalid entry found, first must be "app"! + $application = $cfg->readConfig('default_application'); + } +} else { + // Set the "application selector" application + $application = $cfg->readConfig('default_application'); +} + +// Secure it, by keeping out tags +$application = htmlentities(strip_tags($application), ENT_QUOTES); + +// Secure it a little more with a reg.exp. +$application = preg_replace('/([^a-z0-9_-])+/i', "", $application); + +// Set the application name for later usage +$cfg->setConfigEntry('app_name', $application); + +/** + * Autoload-function + * + * @param $className Name of the class to load + * @return void + */ +function __autoload ($className) { + // Try to include this class + ClassLoader::getInstance()->includeClass($className); +} + +/** + * Is the devel package included? + */ +if (is_dir(sprintf("%sdevel", $cfg->readConfig('base_path')))) { + /** + * Load all development includes + */ + ClassLoader::getInstance()->loadClasses('devel'); +} + +// Shall we include additional configs where you can configure some things? Then +// Load matching config +ClassLoader::getInstance()->loadExtraConfigs(); + +// [EOF] +?> diff --git a/inc/language.php b/inc/language.php new file mode 100644 index 00000000..fe8847a3 --- /dev/null +++ b/inc/language.php @@ -0,0 +1,50 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +try { + $lang = LanguageSystem::createLanguageSystem(sprintf("%s%s", + $cfg->readConfig('base_path'), + FrameworkConfiguration::getInstance()->readConfig('lang_base_path') + )); +} catch (LanguagePathIsEmptyException $e) { + ApplicationEntryPoint::app_die(sprintf("[Main:] The language sub-system could not be initialized for the following reason: %s", + $e->getMessage() + )); +} catch (InvalidLanguagePathStringException $e) { + ApplicationEntryPoint::app_die(sprintf("[Main:] The language sub-system could not be initialized for the following reason: %s", + $e->getMessage() + )); +} catch (LanguagePathIsNoDirectoryException $e) { + ApplicationEntryPoint::app_die(sprintf("[Main:] The language sub-system could not be initialized for the following reason: %s", + $e->getMessage() + )); +} catch (LanguagePathReadProtectedException $e) { + ApplicationEntryPoint::app_die(sprintf("[Main:] The language sub-system could not be initialized for the following reason: %s", + $e->getMessage() + )); +} + +// Is the app variable there and valid? +if (is_object($app)) $app->setLanguageInstance($lang); + +// [EOF] +?> diff --git a/inc/language/.htaccess b/inc/language/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/language/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/loader/.htaccess b/inc/loader/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/loader/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/loader/class_ClassLoader.php b/inc/loader/class_ClassLoader.php new file mode 100644 index 00000000..134b8c10 --- /dev/null +++ b/inc/loader/class_ClassLoader.php @@ -0,0 +1,376 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * ---------------------------------- + * 1.2 + * - ClassLoader rewritten to PHP SPL's own RecursiveIteratorIterator class + * 1.1 + * - loadClasses rewritten to fix some notices + * 1.0 + * - Initial release + * ---------------------------------- + */ +class ClassLoader { + /** + * Instance of this class + */ + private static $selfInstance = null; + + /** + * Configuration array + */ + private $cfg = array(); + + /** + * Array with all classes + */ + private $classes = array(); + + /** + * List of loaded classes + */ + private $loadedClasses = array(); + + /** + * Suffix with extension for all class files + */ + private $prefix = "class_"; + + /** + * Suffix with extension for all class files + */ + private $suffix = ".php"; + + /** + * Length of the suffix. Will be overwritten later. + */ + private $suffixLen = 0; + + /** + * Length of the prefix. Will be overwritten later. + */ + private $prefixLen = 0; + + /** + * A list for directory names (no leading/trailing slashes!) which not be scanned by the path scanner + * @see scanLocalPath + */ + private $ignoreList = array(); + + /** + * Debug this class loader? (true = yes, false = no) + */ + private $debug = false; + + /** + * Wether the file list is cached or not + */ + private $listCached = false; + + /** + * Wethe class content has been cached + */ + private $classesCached = false; + + /** + * Filename for the list cache + */ + private $listCacheFQFN = ""; + + /** + * Cache for class content + */ + private $classCacheFQFN = ""; + + /** + * Counter for loaded include files + */ + private $total = 0; + + /** + * The *public* constructor + * + * @param $cfgInstance Configuration class instance + * @return void + */ + public function __construct (FrameworkConfiguration $cfgInstance) { + // Set configuration instance + $this->cfgInstance = $cfgInstance; + + // Construct the FQFN for the cache + if (!defined('DEVELOPER')) { + $this->listCacheFQFN = $this->cfgInstance->readConfig('local_db_path') . "list-" . $this->cfgInstance->readConfig('app_name') . ".cache"; + $this->classCacheFQFN = $this->cfgInstance->readConfig('local_db_path') . "class-" . $this->cfgInstance->readConfig('app_name') . ".cache"; + } // END - if + + // Set suffix and prefix from configuration + $this->suffix = $cfgInstance->readConfig('class_suffix'); + $this->prefix = $cfgInstance->readConfig('class_prefix'); + + // Estimate length of prefix and suffix for substr() function (cache) + $this->suffixLen = strlen($this->suffix); + $this->prefixLen = strlen($this->prefix); + + // Set own instance + self::$selfInstance = $this; + + // Skip here if no dev-mode + if (defined('DEVELOPER')) return; + + // IS the cache there? + if (file_exists($this->listCacheFQFN)) { + // Get content + $cacheContent = file_get_contents($this->listCacheFQFN); + + // And convert it + $this->classes = unserialize($cacheContent); + + // List has been restored from cache! + $this->listCached = true; + } // END - if + + // Does the class cache exist? + if (file_exists($this->classCacheFQFN)) { + // Then include it + require($this->classCacheFQFN); + + // Mark the class cache as loaded + $this->classesCached = true; + } // END - if + } + + /** + * The destructor makes it sure all caches got flushed + * + * @return void + */ + public function __destruct () { + // Skip here if dev-mode + if (defined('DEVELOPER')) return; + + // Skip here if already cached + if ($this->listCached === false) { + // Writes the cache file of our list away + $cacheContent = serialize($this->classes); + file_put_contents($this->listCacheFQFN, $cacheContent); + } // END - if + + // Skip here if already cached + if ($this->classesCached === false) { + // Generate a full-cache of all classes + $cacheContent = ""; + foreach ($this->loadedClasses as $fqfn) { + // Load the file + $cacheContent .= file_get_contents($fqfn); + } // END - foreach + + // And write it away + file_put_contents($this->classCacheFQFN, $cacheContent); + } // END - if + } + + /** + * Getter for an instance of this class + * + * @return $selfInstance An instance of this class + */ + public final static function getInstance () { + // Is the instance there? + if (is_null(self::$selfInstance)) { + // Get a new one + self::$selfInstance = new ClassLoader(FrameworkConfiguration::getInstance()); + } // END - if + + // Return the instance + return self::$selfInstance; + } + + /** + * Scans recursively a local path for class files which must have a prefix and a suffix as given by $this->suffix and $this->prefix + * + * @param $basePath The relative base path to 'base_path' constant for all classes + * @param $ignoreList An optional list (array or string) of directory names which shall be ignored + * @return void + */ + public function loadClasses ($basePath, $ignoreList = array() ) { + // Is a list has been restored from cache, don't read it again + if ($this->listCached === true) { + // Abort here + return; + } + + // Convert string to array + if (!is_array($ignoreList)) $ignoreList = array($ignoreList); + + // Directories which our class loader ignores by default while + // deep-scanning the directory structure. See scanLocalPath() for + // details. + $ignoreList[] = "."; + $ignoreList[] = ".."; + $ignoreList[] = ".htaccess"; + $ignoreList[] = ".svn"; + + // Keep it in class for later usage + $this->ignoreList = $ignoreList; + + // Set base directory which holds all our classes, we should use an + // absolute path here so is_dir(), is_file() and so on will always + // find the correct files and dirs. + $basePath2 = realpath($basePath); + + // If the basePath is false it is invalid + if ($basePath2 === false) { + /* @todo: Do not die here. */ + die("Cannot read {$basePath} !"); + } else { + // Set base path + $basePath = $basePath2; + } + + // Get a new iterator + //* DEBUG: */ echo "Base path: {$basePath}
    \n"; + $iterator = new RecursiveDirectoryIterator($basePath); + $recursive = new RecursiveIteratorIterator($iterator); + foreach ($recursive as $entry) { + // Get filename from iterator + $fileName = $entry->getFileName(); + + // Is this file wanted? + //* DEBUG: */ echo "FOUND:{$fileName}
    \n"; + if ((!in_array($fileName, $this->ignoreList)) && (substr($fileName, 0, $this->prefixLen) == $this->prefix) && (substr($fileName, -$this->suffixLen, $this->suffixLen) == $this->suffix)) { + // Get the FQFN and add it to our class list + $fqfn = $entry->getRealPath(); + //* DEBUG: */ echo "ADD: {$fileName}
    \n"; + $this->classes[$fileName] = $fqfn; + } // END - if + } // END - foreach + } + + /** + * Load extra config files + * + * @return void + */ + public function loadExtraConfigs () { + // Backup old prefix + $oldPrefix = $this->prefix; + + // Set new prefix (temporary!) + $this->prefix = "config-"; + $this->prefixLen = strlen($this->prefix); + + // Set base directory + $basePath = sprintf("%sinc/config/", $this->cfgInstance->readConfig('base_path')); + + // Load all classes from the config directory + $this->loadClasses($basePath); + + // Include these extra configs now + $this->includeExtraConfigs(); + + // Set the prefix back + $this->prefix = $oldPrefix; + $this->prefixLen = strlen($this->prefix); + + } + + /** + * Tries to find the given class in our list. This method ignores silently + * missing classes or interfaces. So if you use class_exists() this method + * does not interrupt your program. + * + * @param $className The class we shall load + * @return void + */ + public function includeClass ($className) { + // Create a name with prefix and suffix + $fileName = $this->prefix . $className . $this->suffix; + + // Now look it up in our index + if (isset($this->classes[$fileName])) { + // File is found so load it only once + //* DEBUG: */ echo "LOAD: ".$fileName." - Start
    \n"; + require($this->classes[$fileName]); + //* DEBUG: */ echo "LOAD: ".$fileName." - End
    \n"; + + // Count this include + $this->total++; + + // Mark this class as loaded + $this->loadedClasses[] = $this->classes[$fileName]; + + // Developer mode excludes caching (better debugging) + if (!defined('DEVELOPER')) { + // Reset cache + $this->classesCached = false; + } // END - if + } // END - if + } + + /** + * Includes all extra config files + * + * @return void + */ + private function includeExtraConfigs () { + // Run through all class names (should not be much) + foreach ($this->classes as $fileName => $fqfn) { + // Is this a config? + if (substr($fileName, 0, $this->prefixLen) == $this->prefix) { + // Then include it + require($fqfn); + + // Remove it from the list + unset($this->classes[$fileName]); + } // END - if + } // END - foreach + } + + /** + * Getter for total include counter + * + * @return $total Total loaded include files + */ + public final function getTotal () { + return $this->total; + } + + /** + * Getter for a printable list of included classes/interfaces/exceptions + * + * @param $includeList A printable include list + */ + public function getPrintableIncludeList () { + // Prepare the list + $includeList = ""; + foreach ($this->loadedClasses as $classFile) { + $includeList .= basename($classFile)."
    \n"; + } // END - foreach + + // And return it + return $includeList; + } +} + +// [EOF] +?> diff --git a/inc/output.php b/inc/output.php new file mode 100644 index 00000000..83c1372c --- /dev/null +++ b/inc/output.php @@ -0,0 +1,32 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +// Get a debugger instance +$debug = DebugMiddleware::createDebugMiddleware(FrameworkConfiguration::getInstance()->readConfig('debug_class')); + +// Empty string should be ignored and used for testing the middleware +DebugMiddleware::getInstance()->output(""); + +// [EOF] +?> diff --git a/inc/selector.php b/inc/selector.php new file mode 100644 index 00000000..d20cbcb0 --- /dev/null +++ b/inc/selector.php @@ -0,0 +1,68 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +// Get config instance +$cfg = FrameworkConfiguration::getInstance(); + +// Try to load these includes in the given order +$configAppIncludes = array( + sprintf("class_%s", $cfg->readConfig('app_helper_class')), // The ApplicationHelper class + "config", // The application's own configuration + "data", // Application data + "init", // The application initializer + "loader", // The application's class loader + "debug", // Some debugging stuff + "exceptions", // The application's own exception handler + "starter", // The application starter (calls entryPoint(), etc.) +); + +// Load them all (try only) +foreach ($configAppIncludes as $inc) { + // Skip starter in test mode + if (($inc == "starter") && (defined('TEST'))) { + // Skip it here + continue; + } + + // Generate a FQFN for the helper class + $fqfn = sprintf("%s%s/%s.php", + $cfg->readConfig('application_path'), + $cfg->readConfig('app_name'), + $inc + ); + + // Does the include file exists? + if ((file_exists($fqfn)) && (is_file($fqfn)) && (is_readable($fqfn))) { + // Load it + require_once($fqfn); + } elseif ($cfg->readConfig('verbose_level') > 0) { + // File is missing + trigger_error(sprintf("Cannot load application script %s.php! File is missing or read-protected.", + $inc + )); + } +} + +// [EOF] +?> diff --git a/templates/.htaccess b/templates/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/templates/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/templates/_compiled/.htaccess b/templates/_compiled/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/templates/_compiled/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/templates/de/.htaccess b/templates/de/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/templates/de/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/templates/de/code/.htaccess b/templates/de/code/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/templates/de/code/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/templates/de/code/emergency_exit.ctp b/templates/de/code/emergency_exit.ctp new file mode 100644 index 00000000..e974daf5 --- /dev/null +++ b/templates/de/code/emergency_exit.ctp @@ -0,0 +1,29 @@ +{?header:title="Problem in application framework detected!"?} + +
    + $content[message] +
    + +
    +
    + File inclusion backtrace: +
    +
    + $content[backtrace] +
    +
    + +
    +
    + Statistics +
    +
    + Total objects: $content[total_objects] +
    +
    + Loaded class files: $content[total_includes] + (Including exception and interfaces.) +
    +
    + +{?footer_msg:footer_msg="Please contact the support and supply the full above message, if you think you are not qualified to fix this problem."?} diff --git a/templates/de/code/footer_msg.ctp b/templates/de/code/footer_msg.ctp new file mode 100644 index 00000000..fb1de363 --- /dev/null +++ b/templates/de/code/footer_msg.ctp @@ -0,0 +1,8 @@ + + +
    + + + diff --git a/templates/de/code/header.ctp b/templates/de/code/header.ctp new file mode 100644 index 00000000..92730260 --- /dev/null +++ b/templates/de/code/header.ctp @@ -0,0 +1,20 @@ + + + + + {?title?} + + + + + + + + + + + + + + +
    diff --git a/templates/de/html/.htaccess b/templates/de/html/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/templates/de/html/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/templates/images/.htaccess b/templates/images/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/templates/images/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/templates/images/_cache/.htaccess b/templates/images/_cache/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/templates/images/_cache/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/templates/images/de/.htaccess b/templates/images/de/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/templates/images/de/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/templates/images/de/image/.htaccess b/templates/images/de/image/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/templates/images/de/image/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/templates/images/de/image/base_image.itp b/templates/images/de/image/base_image.itp new file mode 100644 index 00000000..6501b56f --- /dev/null +++ b/templates/images/de/image/base_image.itp @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/templates/images/de/image/emergency_exit.itp b/templates/images/de/image/emergency_exit.itp new file mode 100644 index 00000000..f8abcd6b --- /dev/null +++ b/templates/images/de/image/emergency_exit.itp @@ -0,0 +1,40 @@ +setImageName("emergency_exit"); +$helper->setBaseImage("base_image"); + +// Set image dimensions +$helper->setWidth(250); +$helper->setHeight(100); + +// Background and foreground color +$helper->setBackgroundColorRedGreenBlue(0xA0, 0x00, 0x30); +$helper->setForegroundColorRedGreenBlue(0xFF, 0xFF, 0xFF); + +// Add header line +$helper->addTextLine("header"); +$helper->setCoord(48, 10); +$helper->setFontSize(5); +$helper->setImageString("Fehler-Code: {?code?}"); + +// Add info line +$helper->addTextLine("info"); +$helper->setCoord(108, 40); +$helper->setFontSize(5); +$helper->setImageString("Info:"); + +// Add extra line +$helper->addTextLine("extra"); +$helper->setCoord(10, 70); +$helper->setFontSize(2); +$helper->setImageString("{?extra?}"); + +// Flush content to the template engine +$helper->flushContent(); + +// Comment this out if image is done +//$this->debugInstance(); + +// [EOF] +?> diff --git a/tests/ConfigTest.php b/tests/ConfigTest.php new file mode 100644 index 00000000..7c70e61b --- /dev/null +++ b/tests/ConfigTest.php @@ -0,0 +1,165 @@ +readConfig('base_path') . 'inc/includes.php'); + +// Load all game classes +require($cfg->readConfig('base_path') . 'inc/classes.php'); + +// Set default application +FrameworkConfiguration::getInstance()->setConfigEntry('default_application', 'ship-simu'); + +// Set testing mode (no starter.php will be loaded!) +define('TEST_MODE', true); + +// Load the PHPUnit framework +require_once('PHPUnit/Framework.php'); + +print (basename(__FILE__).": Init completed.\n\n"); + +/** + * A test case for the configuration sub system + * + * @author Roland Haeder + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * @see http://www.phpunit.de + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ConfigTest extends PHPUnit_Framework_TestCase { + /** + * Tests the exception ConfigEntryNotFoundException if it is being thrown. + * Else the test shall fail + * + * @return void + */ + public function testConfigEntryNotFoundException () { + // Now try the test + $testPassed = false; + try { + // Get a configuration instance + $cfg = FrameworkConfiguration::getInstance(); + + // Now find a configuration variable that does not exist + $dummy = $cfg->readConfig('does_not_exist'); + } catch (ConfigEntryNotFoundException $expected) { + // This exception was expected, so it is fine + $testPassed = true; + } catch (FrameworkException $unexptected) { + // This exception was not expected! + $this->fail(sprintf("Unexpected exception %s detected.", $unexpected->__toString())); + } + + if (!$testPassed) { + // This test went wrong + $this->fail("Test of thrown exception ConfigEntryNotFoundException failed!"); + } + } + + /** + * Tests if the exception ConfigEntryIsEmptyException is being thrown by + * "emulating" an empty configuration variable. + * + * @return void + */ + public function testConfigEntryIsEmptyExceptionRead () { + // Now try the test + $testPassed = false; + try { + // Get a configuration instance + $cfg = FrameworkConfiguration::getInstance(); + + // Try to read an empty configuration variable + $dummy = $cfg->readConfig(""); + } catch (ConfigEntryIsEmptyException $expected) { + // This exception was expected, so it is fine + $testPassed = true; + } catch (FrameworkException $unexptected) { + // This exception was not expected! + $this->fail(sprintf("Unexpected exception %s detected.", $unexpected->__toString())); + } + + if (!$testPassed) { + // This test went wrong + $this->fail("Test of thrown exception ConfigEntryIsEmptyException failed!"); + } + } + + /** + * Tests if the exception ConfigEntryIsEmptyException is being thrown by + * "emulating" an empty configuration variable. + * + * @return void + */ + public function testConfigEntryIsEmptyExceptionWrite () { + // Now try the test + $testPassed = false; + try { + // Get a configuration instance + $cfg = FrameworkConfiguration::getInstance(); + + // Try to read an empty configuration variable + $cfg->setConfigEntry("", 'will_never_be_set'); + } catch (ConfigEntryIsEmptyException $expected) { + // This exception was expected, so it is fine + $testPassed = true; + } catch (FrameworkException $unexptected) { + // This exception was not expected! + $this->fail(sprintf("Unexpected exception %s detected.", $unexpected->__toString())); + } + + if (!$testPassed) { + // This test went wrong + $this->fail("Test of thrown exception ConfigEntryIsEmptyException failed!"); + } + } + + /** + * Tests if a set value can be returned from the configuration sub-system + * + * @return void + */ + public function testWriteReadConfigEntry () { + // Try it here + $value = "This is a test value"; + try { + // Get a configuration instance + $cfg = FrameworkConfiguration::getInstance(); + + // Try to read an empty configuration variable + $cfg->setConfigEntry('test_key', "{$value}"); + + // Read the config entry we have just written + $readValue = $cfg->readConfig('test_key'); + + // Now test the values + $this->assertEquals($value, $readValue); + } catch (FrameworkException $unexptected) { + // This exception was not expected! + $this->fail(sprintf("Unexpected exception %s detected.", $unexpected->__toString())); + } + } +} + +?> diff --git a/tests/RegistryTest.php b/tests/RegistryTest.php new file mode 100644 index 00000000..e4dc50e5 --- /dev/null +++ b/tests/RegistryTest.php @@ -0,0 +1,94 @@ +readConfig('base_path') . 'inc/includes.php'); + +// Load all game classes +require($cfg->readConfig('base_path') . 'inc/classes.php'); + +// Set default application +FrameworkConfiguration::getInstance()->setConfigEntry('default_application', 'ship-simu'); + +// Set testing mode (no starter.php will be loaded!) +define('TEST_MODE', true); + +// Load the PHPUnit framework +require_once('PHPUnit/Framework.php'); + +print (basename(__FILE__).": Init completed.\n\n"); + +/** + * A test case for the registry + * + * @author Roland Haeder + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * @see http://www.phpunit.de + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class RegistryTest extends PHPUnit_Framework_TestCase { + /** + * Tests if we can store an instance to the registry + * + * @return void + */ + public function testInstanceRegistryAdd () { + // Get a registry instance + $registryInstance = Registry::getRegistry(); + + // Create a User instance + $userInstance = Member::createMemberByEmail("webmaster@ship-simu.org"); + + // Now store the instance in the registry + $registryInstance->addInstance('user', $userInstance); + + // Test if the registry key is there + if (!$registryInstance->instanceExists('user')) { + $this->fail("Registry test failed: Cannot locate our user instance in registry!"); + } + } + + /** + * Tests if we can store an instance to the registry + * + * @return void + */ + public function testInstanceRegistryCompare () { + // Get a registry instance + $registryInstance = Registry::getRegistry(); + + // And get it back + $userInstance = $registryInstance->getInstance('user'); + + // Compare both unique keys + $testPassed = ($userInstance instanceof ManageableAccount); + + // Test passed? + if (!$testPassed) { + $this->fail("Registry test failed: Method getInstance() returned a non-object."); + } + } +} + +?> diff --git a/tests/RequestTest.php b/tests/RequestTest.php new file mode 100644 index 00000000..0104f635 --- /dev/null +++ b/tests/RequestTest.php @@ -0,0 +1,102 @@ +readConfig('base_path') . 'inc/includes.php'); + +// Load all game classes +require($cfg->readConfig('base_path') . 'inc/classes.php'); + +// Set default application +FrameworkConfiguration::getInstance()->setConfigEntry('default_application', 'ship-simu'); + +// Set testing mode (no starter.php will be loaded!) +define('TEST_MODE', true); + +// Load the PHPUnit framework +require_once('PHPUnit/Framework.php'); + +print (basename(__FILE__).": Init completed.\n\n"); + +/** + * A test case for faked HTTP requests. This is faked because we *set* + * $_REQUEST here. This should be made better in PHP6... :( + * + * @author Roland Haeder + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * @see http://www.phpunit.de + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class RequestTest extends PHPUnit_Framework_TestCase { + /** + * A non-exist request element is being asked for. null is the expected + * result from the class + * + * @return void + */ + public function testMissingRequestElement () { + // Get a request instance + $requestInstance = HttpRequest::createHttpRequest(); + + // Get the element + $nonExist = $requestInstance->getRequestElement('never_there'); + + // Is this null? + if (!is_null($nonExist)) { + // Is not null! + $this->fail(sprintf("[%s:] Unexpected type %s received from request handler.", + $requestInstance->__toString(), + gettype($nonExists) + )); + } + } + + /** + * Now fake a request array and try the test on it again + * + * @return void + */ + public function testFakeRequestElement () { + // Fake the request here + $_REQUEST = array('test_key' => "test_value"); + + // Again get an instance + $requestInstance = HttpRequest::createHttpRequest(); + + // Get the element + $testValue = $requestInstance->getRequestElement('test_key'); + + // Is it the same? + if ($testValue !== "test_value") { + // Something went wrong + $this->fail(sprintf("[%s] Unexpected value %s (%s) from test key received.", + $requestInstance->__toString(), + $testValue, + gettype($testValue) + )); + } + } +} + +?> diff --git a/tests/Test.php b/tests/Test.php new file mode 100644 index 00000000..7e5a551c --- /dev/null +++ b/tests/Test.php @@ -0,0 +1,54 @@ +readConfig('base_path') . 'inc/includes.php'); + +// Load all game classes +require($cfg->readConfig('base_path') . 'inc/classes.php'); + +// Set default application +FrameworkConfiguration::getInstance()->setConfigEntry('default_application', 'ship-simu'); + +// Set testing mode (no starter.php will be loaded!) +define('TEST_MODE', true); + +// Load the PHPUnit framework +require_once('PHPUnit/Framework.php'); + +print (basename(__FILE__).": Init completed.\n\n"); +die("You need to remove this line (".__LINE__.") and implement this test!\n"); + +/** + * A test case for + * + * @author Roland Haeder + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * @see http://www.phpunit.de + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class Test extends PHPUnit_Framework_TestCase { +} + +?> diff --git a/tests/all-tests.sh b/tests/all-tests.sh new file mode 100644 index 00000000..13c704a6 --- /dev/null +++ b/tests/all-tests.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +find -type f -name "*Test.php" -not -name "Test.php" -exec sh ./unittest.sh {} \; diff --git a/tests/old/contract-test.php b/tests/old/contract-test.php new file mode 100644 index 00000000..fd44cdf3 --- /dev/null +++ b/tests/old/contract-test.php @@ -0,0 +1,612 @@ +readConfig('base_path') . 'inc/includes.php'); + +// Load all game classes +require($cfg->readConfig('base_path') . 'inc/classes.php'); + +// Load file I/O handler +require($cfg->readConfig('base_path') . 'inc/file_io.php'); + +// Load database layer +require($cfg->readConfig('base_path') . 'inc/database.php'); + +// Set default application +FrameworkConfiguration::getInstance()->setConfigEntry('default_application', 'ship-simu'); +$application = 'ship-simu'; + +// Load more includes +require($cfg->readConfig('base_path') . 'application/ship-simu/loader.php'); + +// Wir tun hier so, als waere schon das Reederei-Objekt generiert und wir wollen +// jetzt die Personalliste wiederherstellen +try { + $personell = SimulatorPersonell::createSimulatorPersonellByID('SimulatorPersonell@829292aeca3f6bf78c16e25fc4f75c98'); +} catch (InvalidIDFormatException $e) { + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
    \n", + $e->getMessage() + )); +} catch (InvalidArrayCountException $e) { + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
    \n", + $e->getMessage() + )); +} catch (NullPointerException $e) { + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
    \n", + $e->getMessage() + )); +} catch (NoObjectException $e) { + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
    \n", + $e->getMessage() + )); +} catch (MissingMethodException $e) { + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
    \n", + $e->getMessage() + )); +} catch (FileIsEmptyException $e) { + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
    \n", + $e->getMessage() + )); +} catch (FilePointerNotOpenedException $e) { + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
    \n", + $e->getMessage() + )); +} catch (InvalidArrayCountException $e) { + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
    \n", + $e->getMessage() + )); +} catch (InvalidMD5ChecksumException $e) { + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
    \n", + $e->getMessage() + )); +} catch (InvalidDataLengthException $e) { + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
    \n", + $e->getMessage() + )); +} catch (InvalidSimulatorIDException $e) { + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
    \n", + $e->getMessage() + )); +} catch (MismatchingCompressorsException $e) { + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
    \n", + $e->getMessage() + )); +} catch (ContainerItemIsNullException $e) { + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
    \n", + $e->getMessage() + )); +} catch (ContainerItemIsNoArrayException $e) { + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
    \n", + $e->getMessage() + )); +} catch (ContainerMaybeDamagedException $e) { + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
    \n", + $e->getMessage() + )); +} + +// Personal-Objekt debuggen +if (defined('DEBUG_PERSONELL_OBJ')) { + DebugMiddleware::getInstance()->output(sprintf("The personal object looks like this:
    +
    %s
    \n", + print_r($personell, true) + )); +} + +// Hafen bauen +$harbor = Harbor::createHarbor("Hamburger Hafen"); + +// Name ausgeben +DebugMiddleware::getInstance()->output(sprintf("Der %s ist gegründet worden.
    \n", + $harbor->getHarborName() +)); + +// Hafen-Objekt debuggen +if (defined('DEBUG_HARBOR_OBJ')) { + DebugMiddleware::getInstance()->output(sprintf("Der %s sieht wie folgt aus:
    +
    %s
    \n", + $harbor->getHarborName(), + print_r($harbor, true) + )); +} + +// Haendler gruenden +$merchant = Merchant::createMerchant("Namenlos", $harbor); + +// Array mit Einbauten erstellen +$einbauten = array( + 'parts' => array( // *** Die zu einbauenden Schiffsteile *** + 'Motor' => array( // --- Maschinenraum mit Motor --- + "Ocean-Power 2000", // Bezeichnung + 20000, // Pferdestaerken + 6, // Anzahl Nocken + 2.5, 2, 3.5 // Abmasse (Breite/Hoehe/Laenge) + ), + 'Bridge' => array( // --- Kommandobruecke --- + 26, 2.5, 15 // Abmasse (Breite/Hoehe/Laenge) + ), + 'CarDeck' => array( // --- Autodecks --- + 'amount' => 8, // Anzahl Autodecks (einige liegen hintereinander im selben Deck!) + 'dim' => array( // Abmessung (Breite/Hoehe/Laenge) + 6, 3, 16 + ) + ), + 'TruckDeck' => array( // --- Decks fuer LKW/Busse haben vielleicht ein anderes Belueftgungssystem, etc. --- + 'amount' => 1, // Anzahl der Decks + 'dim' => array( // Abmessung (Breite/Hoehe/Laenge) + 8, 5, 195 // Geht durchs gesamte Schiff! + ) + ), + 'TrainDeck' => array( // --- Decks fuer Zuege haben Schienen... --- + 'amount' => 1, // Anzahl der Decks + 'dim' => array( // Abmessung (Breite/Hoehe/Laenge) + 8, 4, 195 // Geht durchs gesamte Schiff! + ) + ), + 'LuxuryCabin' => array( // --- Luxuskabinen --- + 'amount' => 20, // Anzahl Luxuskabinen im Schiff + 'rooms' => 4, // Raeume: 2 Schlafzimmer, 1 Auffenthaltszimmer, 1 Bad mit Dusche/Toilette/Waschbecken + 'bed' => 3, // Anzahl Betten (1 Doppelbett 2 Einzelbetten, Doppel-/Einzelbetten in getrennte Raeume) + 'dim' => array( // Abmessung der Luxuskabine (Breite/Hoehe/Laenge) + 4, 3, 5 + ), + ), + 'PremierCabin' => array( // --- Mittlere Kabinen --- + 'amount' => 40, // Anzahl + 'rooms' => 2, // Raeume: Schlafzimmer, Bad mit Toilette/Waschbecken + 'bed' => 2, // Anzahl Betten (1 Doppelbett, 1 Einzelbett; gemeinsamer Raum) + 'dim' => array( // Abmessungen der Kabine (Breite/Hoehe/Laenge) + 4, 2.5, 4 + ) + ), + 'LowCabin' => array( // --- Untere Kabinen (befinden sich in den Unterbauten) --- + 'amount' => 90, // Anzahl + 'rooms' => 1, // Raeume: Schlafzimmer, Waschbecken + 'bed' => 2, // Anzahl Betten (2 Etagenbetten) + 'dim' => array( // Abmessungen der Kabine (Breite/Hoehe/Laenge) + 3, 2.5, 4 + ) + ), + 'EconomyCabin' => array( // --- Unterste Kabinen (befinden sich tief unten im Schiffsbauch) --- + 'amount' => 140, // Anzahl + 'rooms' => 1, // Raeume: Schlafzimmer, Waschbecken + 'bed' => 1, // Anzahl Betten (1 Etagenbett) + 'dim' => array( // Abmessungen der Kabine (Breite/Hoehe/Laenge) + 2, 2.5, 2 + ) + ) + ), + 'builds' => array( // *** Welche Oberklasse verwendet werden sollen *** + 'Motor' => "MaschineRoom", + 'Bridge' => "BaseUpperStructure", + 'LuxuryCabin' => "BaseCabin", + 'PremierCabin' => "BaseCabin", + 'LowCabin' => "BaseCabin", + 'EconomyCabin' => "BaseCabin", + 'CarDeck' => "BaseDeck", + 'TrainDeck' => "BaseDeck", + 'TruckDeck' => "BaseDeck" + ) +); + +// Preisliste auffuellen +foreach ($einbauten['parts'] as $key=>$part) { + // Create item array string + $item = ""; + foreach ($part as $idx=>$itemPart) { + if (is_string($itemPart)) { + // String found + $item .= sprintf("\"%s\", ", $itemPart); + } elseif (is_int($itemPart)) { + // Integer found + $item .= sprintf("%d, ", $itemPart); + } elseif (is_float($itemPart)) { + // Float found + $item .= sprintf("%f, ", $itemPart); + } elseif (is_array($itemPart)) { + // Sub-array found + $item .= "array("; + + // Go all items through + foreach ($itemPart as $idx2=>$subPart) { + if (is_int($subPart)) { + // Integer again found + $item .= sprintf("%d, ", $subPart); + } elseif (is_float($subPart)) { + // Float found + $item .= sprintf("%f, ", $subPart); + } else { + // Unsupport part found + die(sprintf("[Main:] Unsupported sub-array element on pos %d in array %s found: %s", $idx2, $idx, $subPart)); + } + } + + // Remove trailing comma + $item = substr($item, 0, -2); + + // Add closing bracket + $item .= "), "; + } else { + // Unsupport part found + die(sprintf("[Main:] Unsupported array element on pos %d: %s", $idx, $itemPart)); + } + } + + // Remove trailing comma + $item = substr($item, 0, -2); + + // Random price + $price = mt_rand(5, 12) * 10000; + + // Give it a try... + try { + // Generate command for adding objects to a price list + $eval = sprintf("\$merchant->addItemToPriceList(%s::create%s(%s), %d);", + $key, + $key, + $item, + $price + ); + + // Debug message + if ((defined('DEBUG_EVAL')) || (defined('DEBUG_ALL'))) DebugMiddleware::getInstance()->output(sprintf("[Main:] Konstruierte PHP-Anweisung:
    %s

    \n", + htmlentities($eval) + )); + + // Run the constructed command + eval($eval); + } catch (ItemNotTradeableException $e) { + die(sprintf("[Main:] Die Preisliste des Händlers %s kann nicht befüllt werden. Grund: %s
    \n", + $merchant->getMerchantName(), + $e->getMessage() + )); + } +} + +// Haendler-Objekt debuggen +if (defined('DEBUG_MERCHANT_OBJ')) { + DebugMiddleware::getInstance()->output(sprintf("Der Händler %s sieht wie folgt aus:
    +
    %s
    \n", + $merchant->getMerchantName(), + print_r($merchant, true) + )); +} + +// Reederei gruenden +$shipping = ShippingCompany::createShippingCompany("Hanseatic Travel Company", $harbor); + +// Firmenschef setzen +try { + $shipping->setCompanyFounder(CompanyEmployee::createCompanyEmployee("Roland", "Häder", "M", 1977, 9, 26, true, 2000)); +} catch (BirthdayInvalidException $e) { + die(sprintf("[Main:] Reederei-Gründer konnte nicht gesetzt werden. Grund: %s
    \n", + $e->getMessage() + )); +} + +// Dann mal ausgeben... +DebugMiddleware::getInstance()->output(sprintf("Die Reederei %s ist von %s %s gegründet worden.
    \n", + $shipping->getCompanyName(), + $shipping->getFounderInstance()->getSurname(), + $shipping->getFounderInstance()->getFamily() +)); + +// Die Reederei stellt Personal ein und bedient sich an der $personell-Instanz +try { + $shipping->recruitRandomEmployees(10, $personell); +} catch (ToMuchEmployeesException $e) { + die(sprintf("[Main:] Die Reederei %s konnte kein Personal einstellen. Grund: %s
    \n", + $shipping->getCompanyName(), + $e->getMessage() + )); +} catch (OutOfBoundsException $e) { + die(sprintf("[Main:] Die Reederei %s konnte kein Personal einstellen. Grund: %s
    \n", + $shipping->getCompanyName(), + $e->getMessage() + )); +} + +// Anzahl Personal ausgeben +DebugMiddleware::getInstance()->output(sprintf("Die Reederei %s hat nun %d weitere Mitarbeiter.
    \n", + $shipping->getCompanyName(), + $shipping->getTotalEmployee() +)); + +// Dann die ersten 3 Werften in den Hafen einbauen und Personal zuweisen +$shipping->createShipyardInHarbor("Werft 1", $harbor); +$shipping->createShipyardInHarbor("Werft 2", $harbor); +$shipping->createShipyardInHarbor("Werft 3", $harbor); + +// In alle Werften sollen Passagierschiffe gebaut werden koennen +try { + $shipping->addShipTypeToAllShipyards("PassengerShip"); +} catch (ClassNotFoundException $e) { + die(sprintf("[Main:] Die Reederei %s kann ihre Werften nicht beschäftigen. Grund: %s
    \n", + $shipping->getCompanyName(), + $e->getMessage() + )); +} catch (ClassMismatchException $e) { + die(sprintf("[Main:] Die Reederei %s kann ihre Werften nicht beschäftigen. Grund: %s
    \n", + $shipping->getCompanyName(), + $e->getMessage() + )); +} catch (NoObjectException $e) { + die(sprintf("[Main:] Die Reederei %s kann ihre Werften nicht beschäftigen. Grund: %s
    \n", + $shipping->getCompanyName(), + $e->getMessage() + )); +} + +// Personal auf die Werften verteilen +try { + $shipping->distributeAllPersonellOnShipyards(); +} catch (NoShipyardsConstructedException $e) { + die(sprintf("[Main:] Die Reederei %s konnte kein Personal den Werften zuteilen. Grund: %s
    \n", + $shipping->getCompanyName(), + $e->getMessage() + )); +} catch (ClassMismatchException $e) { + die(sprintf("[Main:] Die Reederei %s konnte kein Personal den Werften zuteilen. Grund: %s
    \n", + $shipping->getCompanyName(), + $e->getMessage() + )); +} catch (NullPointerException $e) { + die(sprintf("[Main:] Die Reederei %s konnte kein Personal den Werften zuteilen. Grund: %s
    \n", + $shipping->getCompanyName(), + $e->getMessage() + )); +} catch (NoObjectException $e) { + die(sprintf("[Main:] Die Reederei %s konnte kein Personal den Werften zuteilen. Grund: %s
    \n", + $shipping->getCompanyName(), + $e->getMessage() + )); +} + +// Normale Meldung ausgeben +DebugMiddleware::getInstance()->output(sprintf("Die Reederei %s beschäftigt nun ihre %d Mitarbeiter in %d Werft(en):
    \n", + $shipping->getCompanyName(), + $shipping->getTotalEmployee(), + $shipping->getTotalShipyards() +)); + +// Dann nimmt die Reederei ihren ersten Bauauftrag entgegen. +// Sie muss auch sich selber Bauauftraege erteilen! +try { + $shipping->addNewWorksContract(WorksContract::createWorksContract("PassengerShip", "M/S Poseidon", $shipping)); +} catch (ClassNotFoundException $e) { + die(sprintf("[Main:] Der Bauauftrag konnte nicht erstellt werden. Grund: %s
    \n", + $e->getMessage() + )); +} catch (NullPointerException $e) { + die(sprintf("[Main:] Der Bauauftrag konnte nicht erstellt werden. Grund: %s
    \n", + $e->getMessage() + )); +} catch (NoObjectException $e) { + die(sprintf("[Main:] Der Bauauftrag konnte nicht erstellt werden. Grund: %s
    \n", + $e->getMessage() + )); +} catch (MissingMethodException $e) { + die(sprintf("[Main:] Der Bauauftrag konnte nicht erstellt werden. Grund: %s
    \n", + $e->getMessage() + )); +} catch (EmptyStructuresListException $e) { + die(sprintf("[Main:] Der Bauauftrag konnte nicht erstellt werden. Grund: %s
    \n", + $e->getMessage() + )); +} + +// Auftrag-Instanz holen +$contract = $shipping->getLastContractInstance(); + +// Die Reederei hat einen Haendler gewaehlt +try { + $shipping->setMerchantInstance($merchant); +} catch (NullPointerException $e) { + die(sprintf("[Main:] Der Händler %s konnte nicht ausgewählt werden. Grund: %s
    \n", + $merchant->getMerchantName(), + $e->getMessage() + )); +} catch (NoObjectException $e) { + die(sprintf("[Main:] Der Händler %s konnte nicht ausgewählt werden. Grund: %s
    \n", + $merchant->getMerchantName(), + $e->getMessage() + )); +} catch (ClassMismatchException $e) { + die(sprintf("[Main:] Der Händler %s konnte nicht ausgewählt werden. Grund: %s
    \n", + $merchant->getMerchantName(), + $e->getMessage() + )); +} + +// Den Bauauftrag mit der Reederei abgleichen, ob sie den Schiffstyp bauen koennen +try { + $typeValid = $shipping->validateWorksContractShipType($contract); +} catch (NullPointerException $e) { + die(sprintf("[Main:] Die Reederei %s konnte den Bauauftrag nicht validieren. Grund: %s
    \n", + $shipping->getCompanyName(), + $e->getMessage() + )); +} catch (NoObjectException $e) { + die(sprintf("[Main:] Die Reederei %s konnte den Bauauftrag nicht validieren. Grund: %s
    \n", + $shipping->getCompanyName(), + $e->getMessage() + )); +} + +// Kann gebaut werden? +if ($typeValid) { + DebugMiddleware::getInstance()->output(sprintf("Die Reederei %s kann Schiffe vom Typ %s bauen.
    \n", + $shipping->getCompanyName(), + $contract->getShipInstance()->getObjectDescription() + )); +} else { + DebugMiddleware::getInstance()->output(sprintf("Die Reederei %s kann keine Schiffe vom Typ %s bauen!
    \n", + $shipping->getCompanyName(), + $contract->getShipInstance()->getObjectDescription() + )); + exit; +} + +// Dann den Bauauftrag verfeinern +foreach ($einbauten['parts'] as $key=>$part) { + try { + $contract->addContractDetails($key, $einbauten['builds'][$key], $part); + } catch (ShipPartNotConstructableException $e) { + // Output message + die($e->getMessage()); + } catch (ShipNotConstructedException $e) { + // Output message + die($e->getMessage()); + } catch (ItemNotInPriceListException $e) { + die(sprintf("[Main:] Der Artikel %s konnte nicht in der Preisliste gefunden werden. Grund: %s
    \n", + $key, + $e->getMessage() + )); + } catch (InvalidArrayCountException $e) { + die(sprintf("[Main:] Der Artikel %s konnte nicht in der Preisliste gefunden werden. Grund: %s
    \n", + $key, + $e->getMessage() + )); + } +} + +// Reederei-Objekt ausgeben +if (defined('DEBUG_COMPANY_OBJ')) { + DebugMiddleware::getInstance()->output(sprintf("Die Reederei %s sieht wie folgt aus:
    +
    %s
    \n", + $shipping->getCompanyName(), + print_r($shipping, true) + )); +} + +// Clean up a little +unset($einbauten); +unset($part); +unset($eval); +unset($item); +unset($key); +unset($typeValid); + +// Gesamtwert ausgeben +try { + $totalValue = $contract->getTotalPrice(); +} catch (NullPointerException $e) { + die(sprintf("[Main:] Gesamtbestellwert nicht ermittelbar. Grund: %s
    \n", + $e->getMessage() + )); +} catch (NoObjectException $e) { + die(sprintf("[Main:] Gesamtbestellwert nicht ermittelbar. Grund: %s
    \n", + $e->getMessage() + )); +} catch (MissingMethodException $e) { + die(sprintf("[Main:] Gesamtbestellwert nicht ermittelbar. Grund: %s
    \n", + $e->getMessage() + )); +} catch (EmptyStructuresListException $e) { + die(sprintf("[Main:] Gesamtbestellwert nicht ermittelbar. Grund: %s
    \n", + $e->getMessage() + )); +} catch (TotalPriceNotCalculatedException $e) { + die(sprintf("[Main:] Gesamtbestellwert nicht ermittelbar. Grund: %s
    \n", + $e->getMessage() + )); +} + +// Wert ausgeben +DebugMiddleware::getInstance()->output(sprintf("Der Bau der %s wird der Reederei %s voraussichtlich %s kosten.
    \n", + $contract->getShipInstance()->getShipName(), + $shipping->getCompanyName(), + $contract->formatCurrency($totalValue) +)); + +// Clean up a little +unset($totalValue); + +// Den Bauvertrag unterschreiben (damit wird er in den Bau-Queue aufgenommen) +try { + $shipping->signContract($contract, $shipping); +} catch (NullPointerException $e) { + die(sprintf("[Main:] The shipping company %s was not able to sign the contract for the following reason: %s
    \n", + $shipping->getCompanyName(), + $e->getMessage() + )); +} catch (NoObjectException $e) { + die(sprintf("[Main:] The shipping company %s was not able to sign the contract for the following reason: %s
    \n", + $shipping->getCompanyName(), + $e->getMessage() + )); +} catch (MissingMethodException $e) { + die(sprintf("[Main:] The shipping company %s was not able to sign the contract for the following reason: %s
    \n", + $shipping->getCompanyName(), + $e->getMessage() + )); +} catch (InvalidContractPartnerException $e) { + die(sprintf("[Main:] The shipping company %s was not able to sign the contract for the following reason: %s
    \n", + $shipping->getCompanyName(), + $e->getMessage() + )); +} catch (ContractAllreadySignedException $e) { + die(sprintf("[Main:] The shipping company %s was not able to sign the contract for the following reason: %s
    \n", + $shipping->getCompanyName(), + $e->getMessage() + )); +} catch (WrongContractPartnerException $e) { + die(sprintf("[Main:] The shipping company %s was not able to sign the contract for the following reason: %s
    \n", + $shipping->getCompanyName(), + $e->getMessage() + )); +} + +// Meldung ausgeben +if ($contract->isSigned()) { + DebugMiddleware::getInstance()->output(sprintf("Die Reederei %s hat den Bau der %s zugestimmt.
    \n", + $shipping->getCompanyName(), + $contract->getShipInstance()->getShipName() + )); +} else { + DebugMiddleware::getInstance()->output(sprintf("Die Reederei %s hat den Bau der %s abgelehnt.
    \n", + $shipping->getCompanyName(), + $contract->getShipInstance()->getShipName() + )); + exit; +} + +// Auftrag-Objekt ausgeben +if (defined('DEBUG_CONTRACT_OBJ')) { + DebugMiddleware::getInstance()->output(sprintf("Der Bauauftrag sieht wie folgt aus:
    +
    %s
    \n", + print_r($contract, true) + )); +} + +// Erstmal bis hier hin... +//exit(); + +// Anzahl Betten ermitteln +try { + $totalBeds = $contract->getShipInstance()->calcTotalBeds(); +} catch (StructuresOutOfBoundsException $e) { + die(sprintf("[Main:] Anzahl Betten konnten nicht ermittelt werden. Grund: %s
    \n", + $e->getMessage() + )); +} catch (EmptyStructuresListException $e) { + die(sprintf("[Main:] Anzahl Betten konnten nicht ermittelt werden. Grund: %s
    \n", + $e->getMessage() + )); +} + +// Bettenanzahl ausgeben +DebugMiddleware::getInstance()->output(sprintf("Es stehen %d Betten zur Verfügung.", + $totalBeds +)); + +// +?> diff --git a/tests/old/loader-test.php b/tests/old/loader-test.php new file mode 100644 index 00000000..f87b31ae --- /dev/null +++ b/tests/old/loader-test.php @@ -0,0 +1,162 @@ +readConfig('base_path') . 'inc/includes.php'); + +// Load all game classes +require($cfg->readConfig('base_path') . 'inc/classes.php'); + +// Load file I/O handler +require($cfg->readConfig('base_path') . 'inc/file_io.php'); + +// Load database layer +require($cfg->readConfig('base_path') . 'inc/database.php'); + +// Set default application +FrameworkConfiguration::getInstance()->setConfigEntry('default_application', 'ship-simu'); +$application = 'ship-simu'; + +// Load more includes +require($cfg->readConfig('base_path') . 'application/ship-simu/loader.php'); + +// Wir tun hier so, als waere schon das Reederei-Objekt generiert und wir wollen +// jetzt die Personalliste wiederherstellen +try { + $personell = SimulatorPersonell::createSimulatorPersonellByID('SimulatorPersonell@829292aeca3f6bf78c16e25fc4f75c98'); +} catch (InvalidIDFormatException $e) { + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
    \n", + $e->getMessage() + )); +} catch (InvalidArrayCountException $e) { + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
    \n", + $e->getMessage() + )); +} catch (NullPointerException $e) { + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
    \n", + $e->getMessage() + )); +} catch (NoObjectException $e) { + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
    \n", + $e->getMessage() + )); +} catch (MissingMethodException $e) { + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
    \n", + $e->getMessage() + )); +} catch (FileIsEmptyException $e) { + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
    \n", + $e->getMessage() + )); +} catch (FilePointerNotOpenedException $e) { + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
    \n", + $e->getMessage() + )); +} catch (InvalidArrayCountException $e) { + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
    \n", + $e->getMessage() + )); +} catch (InvalidMD5ChecksumException $e) { + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
    \n", + $e->getMessage() + )); +} catch (InvalidDataLengthException $e) { + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
    \n", + $e->getMessage() + )); +} catch (InvalidSimulatorIDException $e) { + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
    \n", + $e->getMessage() + )); +} catch (MismatchingCompressorsException $e) { + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
    \n", + $e->getMessage() + )); +} catch (ContainerItemIsNullException $e) { + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
    \n", + $e->getMessage() + )); +} catch (ContainerItemIsNoArrayException $e) { + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
    \n", + $e->getMessage() + )); +} catch (ContainerMaybeDamagedException $e) { + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
    \n", + $e->getMessage() + )); +} + +// Personal-Objekt debuggen +if (defined('DEBUG_PERSONELL_OBJ')) { + DebugMiddleware::getInstance()->output(sprintf("The personal object looks like this:
    +
    %s
    \n", + print_r($personell, true) + )); +} + +// Erstmal bis hier hin +exit(); + +// Etwas zum Testen... +try { + $personell = SimulatorPersonell::createSimulatorPersonell(20); +} catch (NullPointerException $e) { + die(sprintf("[Main:] Personal list not created for following reason: %s
    \n", + $e->getMessage() + )); +} catch (NoObjectException $e) { + die(sprintf("[Main:] Personal list not created for following reason: %s
    \n", + $e->getMessage() + )); +} catch (MissingMethodException $e) { + die(sprintf("[Main:] Personal list not created for following reason: %s
    \n", + $e->getMessage() + )); +} + +// Personal-Objekt debuggen +if (defined('DEBUG_PERSONELL_OBJ')) { + DebugMiddleware::getInstance()->output(sprintf("The personal object looks like this:
    +
    %s
    \n", + print_r($personell, true) + )); +} + +// Try to save the object (for testing purposes) +try { + $personell->saveObjectToDatabase(); +} catch (NullPointerException $e) { + die(sprintf("[Main:] Object not saved for following reason: %s
    \n", + $e->getMessage() + )); +} catch (NoObjectException $e) { + die(sprintf("[Main:] Object not saved for following reason: %s
    \n", + $e->getMessage() + )); +} catch (InvalidObjectException $e) { + die(sprintf("[Main:] Object not saved for following reason: %s
    \n", + $e->getMessage() + )); +} catch (MissingMethodException $e) { + die(sprintf("[Main:] Object not saved for following reason: %s
    \n", + $e->getMessage() + )); +} catch (UnsupportedLimitationPartException $e) { + die(sprintf("[Main:] Object not saved for following reason: %s
    \n", + $e->getMessage() + )); +} catch (InvalidArrayCountException $e) { + die(sprintf("[Main:] Object not saved for following reason: %s
    \n", + $e->getMessage() + )); +} + +// +?> diff --git a/tests/old/personell-test.php b/tests/old/personell-test.php new file mode 100644 index 00000000..622c2c79 --- /dev/null +++ b/tests/old/personell-test.php @@ -0,0 +1,162 @@ +readConfig('base_path') . 'inc/includes.php'); + +// Load all game classes +require($cfg->readConfig('base_path') . 'inc/classes.php'); + +// Load file I/O handler +require($cfg->readConfig('base_path') . 'inc/file_io.php'); + +// Load database layer +require($cfg->readConfig('base_path') . 'inc/database.php'); + +// Set default application +FrameworkConfiguration::getInstance()->setConfigEntry('default_application', 'ship-simu'); +$application = 'ship-simu'; + +// Load more includes +require($cfg->readConfig('base_path') . 'application/ship-simu/loader.php'); + +// Wir tun hier so, als waere schon das Reederei-Objekt generiert und wir wollen +// jetzt die Personalliste wiederherstellen +try { + $personell = SimulatorPersonell::createSimulatorPersonellByID('SimulatorPersonell@829292aeca3f6bf78c16e25fc4f75c98'); +} catch (InvalidIDFormatException $e) { + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
    \n", + $e->getMessage() + )); +} catch (InvalidArrayCountException $e) { + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
    \n", + $e->getMessage() + )); +} catch (NullPointerException $e) { + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
    \n", + $e->getMessage() + )); +} catch (NoObjectException $e) { + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
    \n", + $e->getMessage() + )); +} catch (MissingMethodException $e) { + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
    \n", + $e->getMessage() + )); +} catch (FileIsEmptyException $e) { + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
    \n", + $e->getMessage() + )); +} catch (FilePointerNotOpenedException $e) { + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
    \n", + $e->getMessage() + )); +} catch (InvalidArrayCountException $e) { + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
    \n", + $e->getMessage() + )); +} catch (InvalidMD5ChecksumException $e) { + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
    \n", + $e->getMessage() + )); +} catch (InvalidDataLengthException $e) { + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
    \n", + $e->getMessage() + )); +} catch (InvalidSimulatorIDException $e) { + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
    \n", + $e->getMessage() + )); +} catch (MismatchingCompressorsException $e) { + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
    \n", + $e->getMessage() + )); +} catch (ContainerItemIsNullException $e) { + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
    \n", + $e->getMessage() + )); +} catch (ContainerItemIsNoArrayException $e) { + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
    \n", + $e->getMessage() + )); +} catch (ContainerMaybeDamagedException $e) { + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
    \n", + $e->getMessage() + )); +} + +// Personal-Objekt debuggen +if (defined('DEBUG_PERSONELL_OBJ')) { + echo sprintf("The personal object looks like this:
    +
    %s
    \n", + print_r($personell, true) + ); +} + +// Erstmal bis hier hin +exit(); + +// Etwas zum Testen... +try { + $personell = SimulatorPersonell::createSimulatorPersonell(20); +} catch (NullPointerException $e) { + die(sprintf("[Main:] Personal list not created for following reason: %s
    \n", + $e->getMessage() + )); +} catch (NoObjectException $e) { + die(sprintf("[Main:] Personal list not created for following reason: %s
    \n", + $e->getMessage() + )); +} catch (MissingMethodException $e) { + die(sprintf("[Main:] Personal list not created for following reason: %s
    \n", + $e->getMessage() + )); +} + +// Personal-Objekt debuggen +if (defined('DEBUG_PERSONELL_OBJ')) { + echo sprintf("The personal object looks like this:
    +
    %s
    \n", + print_r($personell, true) + ); +} + +// Try to save the object (for testing purposes) +try { + $personell->saveObjectToDatabase(); +} catch (NullPointerException $e) { + die(sprintf("[Main:] Object not saved for following reason: %s
    \n", + $e->getMessage() + )); +} catch (NoObjectException $e) { + die(sprintf("[Main:] Object not saved for following reason: %s
    \n", + $e->getMessage() + )); +} catch (InvalidObjectException $e) { + die(sprintf("[Main:] Object not saved for following reason: %s
    \n", + $e->getMessage() + )); +} catch (MissingMethodException $e) { + die(sprintf("[Main:] Object not saved for following reason: %s
    \n", + $e->getMessage() + )); +} catch (UnsupportedLimitationPartException $e) { + die(sprintf("[Main:] Object not saved for following reason: %s
    \n", + $e->getMessage() + )); +} catch (InvalidArrayCountException $e) { + die(sprintf("[Main:] Object not saved for following reason: %s
    \n", + $e->getMessage() + )); +} + +// +?> diff --git a/tests/unittest.sh b/tests/unittest.sh new file mode 100644 index 00000000..18e210c5 --- /dev/null +++ b/tests/unittest.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +FILE=`echo $1 | cut -d "/" -f 2` + +phpunit --wait $FILE -- 2.30.2