From c59dccf46c5d0e3b7f2687370b2b15023b1ecdfe Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Mon, 18 Aug 2008 22:44:14 +0000 Subject: [PATCH] Code syncronized with shipsimu code base --- .gitattributes | 223 ++ application/hub/class_ApplicationHelper.php | 7 +- .../hub/main/class_HubCommandProcessor.php | 6 - application/hub/main/class_HubConnector.php | 6 - application/hub/main/class_HubCoreLoop.php | 6 - application/hub/main/class_HubPeer.php | 6 - clear-cache.sh | 6 + inc/classes.php | 16 +- inc/classes/exceptions/actions/.htaccess | 1 + .../actions/class_InvalidActionException.php | 46 + .../auth/class_UserAuthorizationException.php | 12 +- inc/classes/exceptions/class_ | 4 +- .../exceptions/class_FrameworkException.php | 104 +- .../class_MismatchingCompressorsException.php | 6 +- .../class_ContainerItemIsNoArrayException.php | 13 +- .../class_ContainerItemIsNullException.php | 13 +- .../class_ContainerMaybeDamagedException.php | 13 +- .../class_DefaultControllerException.php | 9 +- .../class_InvalidControllerException.php | 50 + inc/classes/exceptions/crypto/.htaccess | 1 + .../class_EncryptInvalidLengthException.php | 52 + .../crypto/class_EncryptMissingException.php | 48 + inc/classes/exceptions/database/class_ | 39 + .../database/class_DatabaseException.php | 4 +- .../class_DatabaseUpdateSupportException.php | 45 + .../database/general/class_SqlException.php | 8 +- .../class_SavePathIsEmptyException.php | 12 +- .../class_SavePathIsNoDirectoryException.php | 6 +- .../class_SavePathReadProtectedException.php | 6 +- .../class_SavePathWriteProtectedException.php | 6 +- ...class_WrapperUserNameNotFoundException.php | 6 +- .../filter/class_FilterChainException.php | 8 +- .../helper/class_FormClosedException.php | 8 +- .../helper/class_FormGroupClosedException.php | 8 +- .../helper/class_FormOpenedException.php | 12 +- ...ass_HelperGroupAlreadyCreatedException.php | 46 + ...elperNoPreviousOpenedSubGroupException.php | 46 + ..._HelperSubGroupAlreadyCreatedException.php | 46 + .../helper/class_InvalidFormNameException.php | 10 +- .../helper/class_NoGroupOpenedException.php | 46 + .../class_UserInstanceMissingException.php | 8 +- .../io/class_DirPointerNotOpenedException.php | 4 +- .../io/class_FileNotFoundException.php | 47 + .../class_FilePointerNotOpenedException.php | 8 +- .../io/class_FileReadProtectedException.php | 42 + .../io/class_InvalidDataLengthException.php | 18 +- ...lass_InvalidDirectoryResourceException.php | 22 +- .../io/class_InvalidMD5ChecksumException.php | 18 +- .../io/class_PathIsEmptyException.php | 22 +- .../io/class_PathIsNoDirectoryException.php | 10 +- .../io/class_PathReadProtectedException.php | 10 +- ...ass_InvalidLanguagePathStringException.php | 16 +- .../class_LanguagePathIsEmptyException.php | 12 +- ...ass_LanguagePathIsNoDirectoryException.php | 16 +- ...ass_LanguagePathReadProtectedException.php | 16 +- .../class_MissingFileIoHandlerException.php | 10 +- .../class_MissingLanguageHandlerException.php | 10 +- .../main/class_AssertionException.php | 39 + .../main/class_ClassMismatchException.php | 10 +- .../main/class_ClassNotFoundException.php | 13 +- .../class_ConfigEntryIsEmptyException.php | 10 +- .../class_ConfigEntryNotFoundException.php | 16 +- .../class_DimNotFoundInArrayException.php | 14 +- .../main/class_EmptyVariableException.php | 8 +- .../main/class_ExceptionNotFoundException.php | 13 +- .../main/class_FatalErrorException.php | 40 + .../main/class_GetterNotFoundException.php | 10 +- .../main/class_InvalidArrayCountException.php | 6 +- .../main/class_InvalidCommandException.php | 14 +- .../class_InvalidCommandInstanceException.php | 8 +- .../main/class_InvalidControllerException.php | 8 +- .../main/class_InvalidInterfaceException.php | 46 + .../main/class_InvalidObjectException.php | 15 +- .../class_MissingArrayElementsException.php | 13 +- ...ingDecimalsThousandsSeperatorException.php | 8 +- .../main/class_MissingMethodException.php | 14 +- .../main/class_NoArrayCreatedException.php | 6 +- .../main/class_NoArrayException.php | 10 +- .../main/class_NoObjectException.php | 10 +- .../main/class_NullPointerException.php | 12 +- ...ss_ResponseHeadersAlreadySentException.php | 8 +- .../main/class_VariableIsNotSetException.php | 6 +- inc/classes/exceptions/result/.htaccess | 1 + .../class_InvalidDatabaseResultException.php | 46 + .../result/class_ResultUpdateException.php | 45 + .../class_BasePathIsEmptyException.php | 12 +- .../class_BasePathIsNoDirectoryException.php | 16 +- .../class_BasePathReadProtectedException.php | 16 +- .../class_InvalidBasePathStringException.php | 16 +- .../class_UnexpectedTemplateTypeException.php | 8 +- ...ass_UnsupportedTemplateEngineException.php | 12 +- .../class_ViewHelperNotFoundException.php | 10 +- ...class_AccountPasswordMismatchException.php | 45 + .../user/class_UserEmailMissingException.php | 8 +- .../class_UserPasswordMismatchException.php | 8 +- .../user/class_UsernameMissingException.php | 8 +- inc/classes/exceptions/xml/.htaccess | 1 + .../xml/class_InvalidXmlNodeException.php | 53 + .../xml/class_XmlNodeMismatchException.php | 47 + .../xml/class_XmlParserException.php | 47 + inc/classes/interfaces/actions/.htaccess | 1 + .../actions/class_PerformableAction.php | 36 + .../interfaces/actions/commands/.htaccess | 1 + .../actions/commands/class_Commandable.php | 36 + .../class_ManageableApplication.php | 2 +- .../interfaces/auth/class_Authorizeable.php | 9 +- .../interfaces/cache/class_Cacheable.php | 2 +- inc/classes/interfaces/captcha/.htaccess | 1 + .../captcha/class_SolveableCaptcha.php | 41 + inc/classes/interfaces/class_ | 2 +- .../interfaces/class_FrameworkInterface.php | 12 +- .../compressor/class_Compressor.php | 4 +- .../controller/class_Controller.php | 2 +- .../interfaces/criteria/class_Criteria.php | 2 +- .../extended/class_LocalSearchCriteria.php | 2 +- .../extended/class_LocalUpdateCriteria.php | 28 + .../extended/class_StoreableCriteria.php | 4 +- inc/classes/interfaces/crypto/.htaccess | 1 + .../interfaces/crypto/class_Cryptable.php | 55 + .../class_FrameworkDatabaseInterface.php | 20 +- .../interfaces/database/class_Updateable.php | 37 + .../class_DatabaseFrontendInterface.php | 25 +- .../middleware/class_DatabaseConnector.php | 4 +- .../interfaces/debug/class_Debugger.php | 4 +- .../interfaces/filter/class_Filterable.php | 2 +- .../interfaces/helper/class_HelpableLogin.php | 2 +- .../helper/class_HelpableTemplate.php | 34 + .../interfaces/io/class_Streamable.php | 4 +- .../io/file/class_FileInputStreamer.php | 10 +- .../io/file/class_FileOutputStreamer.php | 12 +- .../io/output/class_OutputStreamer.php | 4 +- .../language/class_ManageableLanguage.php | 4 +- .../interfaces/login/class_LoginableUser.php | 2 +- inc/classes/interfaces/mailer/.htaccess | 1 + .../mailer/class_DeliverableMail.php | 56 + .../interfaces/reader/class_ReadableNews.php | 2 +- .../registration/class_UserRegister.php | 2 +- .../interfaces/registry/class_Register.php | 2 +- .../registry/class_Registerable.php | 2 +- .../interfaces/request/class_Requestable.php | 2 +- .../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 + .../response/class_Responseable.php | 12 +- .../result/class_SearchableResult.php | 2 +- .../result/class_UpdateableResult.php | 45 + .../template/class_CompileableTemplate.php | 25 +- .../template/view/class_ViewHelper.php | 4 +- .../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/actions/class_ | 10 +- inc/classes/main/actions/class_BaseAction.php | 4 +- .../class_LoginAfterRegistrationAction.php | 12 +- inc/classes/main/actions/web/.htaccess | 1 + .../web/class_WebLoginLogoutAction.php | 85 + .../web/class_WebLoginProfileAction.php | 77 + inc/classes/main/auth/class_CookieAuth.php | 21 +- inc/classes/main/cache/class_MemoryCache.php | 14 +- inc/classes/main/class_ | 10 +- inc/classes/main/class_Base | 42 + .../main/class_BaseFrameworkSystem.php | 708 ++++--- .../main/class_FrameworkArrayObject.php | 4 +- inc/classes/main/commands/class_ | 19 +- .../main/commands/class_BaseCommand.php | 31 +- inc/classes/main/commands/image/.htaccess | 1 + .../image/class_ImageCodeCaptchaCommand.php | 98 + .../commands/web/class_WebConfirmCommand.php | 129 ++ .../commands/web/class_WebDoFormCommand.php | 37 +- .../commands/web/class_WebHomeCommand.php | 53 +- .../web/class_WebLoginAreaCommand.php | 131 +- .../commands/web/class_WebLoginCommand.php | 123 ++ .../web/class_WebLoginFailedCommand.php | 120 ++ .../web/class_WebLogoutDoneCommand.php | 120 ++ .../commands/web/class_WebRegisterCommand.php | 56 +- .../web/class_WebResendLinkCommand.php | 142 ++ .../main/compressor/class_Bzip2Compressor.php | 8 +- .../main/compressor/class_GzipCompressor.php | 8 +- .../main/compressor/class_NullCompressor.php | 8 +- .../main/console/class_ConsoleTools.php | 12 +- inc/classes/main/controller/captcha/.htaccess | 1 + .../class_ImageCodeCaptchaController.php | 84 + inc/classes/main/controller/class_ | 45 +- .../main/controller/class_BaseController.php | 34 +- .../default/class_WebDefaultController.php | 6 - .../class_WebDefaultNewsController.php | 6 - .../form/class_WebDoFormController.php | 21 +- inc/classes/main/controller/image/.htaccess | 1 + .../image/class_ImageDefaultController.php | 75 + .../login/class_WebLoginAreaController.php | 36 +- inc/classes/main/controller/web/.htaccess | 1 + .../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_WebLogoutDoneController.php | 86 + .../web/class_WebRegisterController.php | 86 + .../web/class_WebStatusController.php | 76 + .../main/criteria/class_DataSetCriteria.php | 49 +- .../main/criteria/class_SearchCriteria.php | 42 +- .../main/criteria/class_UpdateCriteria.php | 104 + .../main/crypto/class_CryptoHelper.php | 146 +- inc/classes/main/database/class_ | 8 +- .../database/class_BaseDatabaseFrontend.php | 39 +- .../database/class_BaseDatabaseWrapper.php | 122 +- .../databases/class_LocalFileDatabase.php | 455 ++-- .../wrapper/class_NewsDatabaseWrapper.php | 56 + .../wrapper/class_UserDatabaseWrapper.php | 107 +- .../class_UserPointsDatabaseWrapper.php | 56 + .../main/debug/class_DebugConsoleOutput.php | 10 +- .../main/debug/class_DebugErrorLogOutput.php | 8 +- .../main/debug/class_DebugWebOutput.php | 12 +- .../main/extended/class_ObjectLimits.php | 6 - .../factories/cache/class_CacheFactory.php | 10 +- .../main/factories/class_BaseFactory.php | 8 +- .../factories/objects/class_ObjectFactory.php | 8 +- .../factories/web/class_WebNewsFactory.php | 8 +- .../main/filter/auth/class_UserAuthFilter.php | 47 +- inc/classes/main/filter/change/.htaccess | 1 + .../filter/change/class_EmailChangeFilter.php | 112 + .../change/class_PasswordChangeFilter.php | 106 + .../checkboxes/class_RulesAcceptedFilter.php | 8 +- inc/classes/main/filter/class_ | 8 +- .../filter/class_AbstractFilterDecorator.php | 2 +- inc/classes/main/filter/class_BaseFilter.php | 4 +- inc/classes/main/filter/class_FilterChain.php | 8 +- inc/classes/main/filter/crypto/.htaccess | 1 + .../crypto/class_CaptchaEncryptFilter.php | 90 + inc/classes/main/filter/guest/.htaccess | 1 + .../guest/class_UserNameIsGuestFilter.php | 70 + .../filter/news/class_NewsDownloadFilter.php | 12 +- .../filter/news/class_NewsProcessFilter.php | 10 +- .../main/filter/null/class_NullFilter.php | 8 +- inc/classes/main/filter/update/.htaccess | 1 + .../class_UserStatusConfimedUpdateFilter.php | 74 + .../filter/update/class_UserUpdateFilter.php | 74 + .../validator/class_EmailValidatorFilter.php | 12 +- .../class_PasswordValidatorFilter.php | 14 +- .../class_UserNameValidatorFilter.php | 12 +- inc/classes/main/filter/verifier/.htaccess | 1 + .../class_AccountPasswordVerifierFilter.php | 100 + .../class_ConfirmCodeVerifierFilter.php | 108 + ...ass_GraphicalCodeCaptchaVerifierFilter.php | 122 ++ .../class_PasswordGuestVerifierFilter.php | 84 + .../verifier/class_PasswordVerifierFilter.php | 84 + .../class_UserGuestVerifierFilter.php | 142 ++ .../verifier/class_UserNameVerifierFilter.php | 139 ++ .../class_UserStatusVerifierFilter.php | 74 + .../class_UserUnconfirmedVerifierFilter.php | 92 + inc/classes/main/helper/captcha/.htaccess | 1 + inc/classes/main/helper/captcha/class_ | 76 + .../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_ | 19 +- inc/classes/main/helper/class_BaseHelper.php | 420 +++- .../helper/login/class_BaseLoginHelper.php | 2 +- inc/classes/main/helper/web/blocks/.htaccess | 1 + .../web/blocks/class_WebBlockHelper.php | 151 ++ inc/classes/main/helper/web/class_ | 75 + .../main/helper/web/class_BaseWebHelper.php | 200 ++ .../main/helper/web/class_WebFormHelper.php | 6 - inc/classes/main/helper/web/forms/.htaccess | 1 + .../helper/web/forms/class_WebFormHelper.php | 786 +++++++ inc/classes/main/helper/web/links/.htaccess | 1 + .../helper/web/links/class_WebLinkHelper.php | 225 ++ 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 | 73 + inc/classes/main/io/class_FileIoStream.php | 12 +- .../io/class_FrameworkDirectoryPointer.php | 9 +- .../io/class_FrameworkFileInputPointer.php | 46 +- .../io/class_FrameworkFileOutputPointer.php | 9 +- .../main/language/class_LanguageSystem.php | 8 +- inc/classes/main/mailer/.htaccess | 1 + inc/classes/main/mailer/class_ | 68 + inc/classes/main/mailer/class_BaseMailer.php | 214 ++ inc/classes/main/mailer/debug/.htaccess | 1 + .../main/mailer/debug/class_DebugMailer.php | 175 ++ .../main/output/class_ConsoleOutput.php | 20 +- inc/classes/main/output/class_WebOutput.php | 10 +- inc/classes/main/points/.htaccess | 1 + inc/classes/main/points/class_UserPoints.php | 92 + .../main/reader/class_DefaultNewsReader.php | 33 +- .../registration/class_BaseRegistration.php | 6 +- inc/classes/main/registry/class_Registry.php | 10 +- .../main/request/class_HttpRequest.php | 30 +- inc/classes/main/resolver/action/.htaccess | 1 + .../action/class_BaseActionResolver.php | 139 ++ .../main/resolver/action/web/.htaccess | 1 + .../action/web/class_WebActionResolver.php | 147 ++ .../main/resolver/class_BaseResolver.php | 112 +- inc/classes/main/resolver/command/.htaccess | 1 + .../command/class_BaseCommandResolver.php | 140 ++ .../main/resolver/command/image/.htaccess | 1 + .../image/class_ImageCommandResolver.php | 178 ++ .../main/resolver/command/web/.htaccess | 1 + .../command/web/class_WebCommandResolver.php | 178 ++ .../main/resolver/controller/.htaccess | 1 + .../class_BaseControllerResolver.php | 129 ++ .../main/resolver/controller/image/.htaccess | 1 + .../image/class_ImageControllerResolver.php | 164 ++ .../main/resolver/controller/web/.htaccess | 1 + .../web/class_WebControllerResolver.php | 170 ++ .../resolver/web/class_WebCommandResolver.php | 6 - .../web/class_WebControllerResolver.php | 6 - .../main/response/class_HttpResponse.php | 57 +- .../main/response/class_ImageResponse.php | 380 ++++ .../main/result/class_DatabaseResult.php | 177 +- .../main/rng/class_RandomNumberGenerator.php | 64 +- .../template/class_BaseTemplateEngine.php | 1289 +++++++++++ .../main/template/class_TemplateEngine.php | 6 - 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/class_BaseUser.php | 294 +++ inc/classes/main/user/class_User.php | 6 - 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 | 174 ++ .../middleware/class_BaseMiddleware.php | 9 +- .../compressor/class_CompressorChannel.php | 12 +- .../database/class_DatabaseConnection.php | 41 +- .../debug/class_DebugMiddleware.php | 24 +- .../middleware/io/class_FileIoHandler.php | 51 +- inc/classes/third_party/.htaccess | 1 + 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 | 71 +- inc/config/class_FrameworkConfiguration.php | 83 +- inc/config/config-hubmaster.php | 2 +- inc/config/config-override.php | 4 +- inc/database.php | 6 +- inc/database/lib-local.php | 12 +- inc/file_io.php | 2 +- inc/includes.php | 4 +- inc/language.php | 2 +- inc/loader/class_ClassLoader.php | 28 +- inc/output.php | 2 +- inc/selector.php | 2 +- index.php | 68 +- package.sh | 16 + pdepend.sh | 10 + 421 files changed, 27222 insertions(+), 2109 deletions(-) create mode 100755 clear-cache.sh create mode 100644 inc/classes/exceptions/actions/.htaccess create mode 100644 inc/classes/exceptions/actions/class_InvalidActionException.php create mode 100644 inc/classes/exceptions/controller/class_InvalidControllerException.php 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/class_ create mode 100644 inc/classes/exceptions/database/general/class_DatabaseUpdateSupportException.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_NoGroupOpenedException.php create mode 100644 inc/classes/exceptions/io/class_FileNotFoundException.php create mode 100644 inc/classes/exceptions/io/class_FileReadProtectedException.php create mode 100644 inc/classes/exceptions/main/class_AssertionException.php create mode 100644 inc/classes/exceptions/main/class_FatalErrorException.php create mode 100644 inc/classes/exceptions/main/class_InvalidInterfaceException.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/user/class_AccountPasswordMismatchException.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/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/captcha/.htaccess create mode 100644 inc/classes/interfaces/captcha/class_SolveableCaptcha.php create mode 100644 inc/classes/interfaces/criteria/extended/class_LocalUpdateCriteria.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/class_Updateable.php create mode 100644 inc/classes/interfaces/helper/class_HelpableTemplate.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/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/result/class_UpdateableResult.php 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/actions/web/.htaccess create mode 100644 inc/classes/main/actions/web/class_WebLoginLogoutAction.php create mode 100644 inc/classes/main/actions/web/class_WebLoginProfileAction.php create mode 100644 inc/classes/main/class_Base 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/class_WebConfirmCommand.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_WebLogoutDoneCommand.php create mode 100644 inc/classes/main/commands/web/class_WebResendLinkCommand.php 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/image/.htaccess create mode 100644 inc/classes/main/controller/image/class_ImageDefaultController.php create mode 100644 inc/classes/main/controller/web/.htaccess 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_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/class_UpdateCriteria.php create mode 100644 inc/classes/main/database/wrapper/class_NewsDatabaseWrapper.php create mode 100644 inc/classes/main/database/wrapper/class_UserPointsDatabaseWrapper.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/crypto/.htaccess create mode 100644 inc/classes/main/filter/crypto/class_CaptchaEncryptFilter.php 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/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/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/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/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/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/points/.htaccess create mode 100644 inc/classes/main/points/class_UserPoints.php 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/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_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/class_ImageResponse.php 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/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/third_party/.htaccess 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 100755 package.sh create mode 100755 pdepend.sh diff --git a/.gitattributes b/.gitattributes index 4bb90f70e..07107c722 100644 --- a/.gitattributes +++ b/.gitattributes @@ -42,6 +42,7 @@ application/hub/main/class_HubPeer.php -text application/hub/middleware/.htaccess -text application/hub/starter.php -text /chat-server.php -text +/clear-cache.sh -text db/.htaccess -text devel/.htaccess -text devel/class_Debug.php -text @@ -55,6 +56,8 @@ 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 @@ -67,10 +70,16 @@ 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 @@ -85,11 +94,17 @@ 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 @@ -104,6 +119,7 @@ inc/classes/exceptions/language/class_LanguagePathReadProtectedException.php -te 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 @@ -112,11 +128,13 @@ inc/classes/exceptions/main/class_DimNotFoundInArrayException.php -text inc/classes/exceptions/main/class_EmptyVariableException.php -text inc/classes/exceptions/main/class_ExceptionNotChangedException.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_InvalidControllerException.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 @@ -127,6 +145,9 @@ 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 @@ -137,16 +158,27 @@ 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/commands/.htaccess -text @@ -159,9 +191,13 @@ 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 @@ -174,6 +210,7 @@ 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 @@ -185,6 +222,8 @@ 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 @@ -195,40 +234,63 @@ 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_CommandResolver.php -text inc/classes/interfaces/resolver/class_ControllerResolver.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/class_ManageableUser.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_WebLoginLogoutAction.php -text +inc/classes/main/actions/web/class_WebLoginProfileAction.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/local/.htaccess -text inc/classes/main/commands/local/class_LocalHomeCommand.php -text inc/classes/main/commands/web/.htaccess -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_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 @@ -236,6 +298,8 @@ 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/default/.htaccess -text @@ -243,11 +307,23 @@ inc/classes/main/controller/default/class_WebDefaultController.php -text inc/classes/main/controller/default/class_WebDefaultNewsController.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_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_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 @@ -257,7 +333,9 @@ 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_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 @@ -276,29 +354,69 @@ 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/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/class_WebFormHelper.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 @@ -306,9 +424,16 @@ 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 @@ -318,20 +443,49 @@ 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_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/resolver/web/.htaccess -text inc/classes/main/resolver/web/class_WebCommandResolver.php -text inc/classes/main/resolver/web/class_WebControllerResolver.php -text inc/classes/main/response/.htaccess -text inc/classes/main/response/class_HttpResponse.php -text +inc/classes/main/response/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/class_TemplateEngine.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/class_User.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 @@ -342,6 +496,73 @@ 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/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 @@ -359,6 +580,8 @@ inc/loader/class_ClassLoader.php -text inc/output.php -text inc/selector.php -text /index.php -text +/package.sh -text +/pdepend.sh -text /rebuild_doc.sh -text templates/.htaccess -text templates/_compiled/.htaccess -text diff --git a/application/hub/class_ApplicationHelper.php b/application/hub/class_ApplicationHelper.php index 2ec172bf8..24aab7c80 100644 --- a/application/hub/class_ApplicationHelper.php +++ b/application/hub/class_ApplicationHelper.php @@ -68,14 +68,9 @@ class ApplicationHelper extends BaseFrameworkSystem implements ManageableApplica // Call parent constructor parent::__construct(__CLASS__); - // Set description - $this->setObjectDescription("Application-Helper"); - - // Create an unique ID - $this->generateUniqueId(); - // Tidy up a little $this->removeSystemArray(); + $this->removeNumberFormaters(); } /** diff --git a/application/hub/main/class_HubCommandProcessor.php b/application/hub/main/class_HubCommandProcessor.php index fa05bf580..0aba7a4eb 100644 --- a/application/hub/main/class_HubCommandProcessor.php +++ b/application/hub/main/class_HubCommandProcessor.php @@ -48,12 +48,6 @@ class HubCommandProcessor extends BaseFrameworkSystem { // Call parent constructor parent::__construct(__CLASS__); - // Set description - $this->setObjectDescription("Hub-Command-Processor"); - - // Set unique ID - $this->generateUniqueId(); - // Tidy up a little $this->removeSystemArray(); $this->removeNumberFormaters(); diff --git a/application/hub/main/class_HubConnector.php b/application/hub/main/class_HubConnector.php index db535f55f..d97759dae 100644 --- a/application/hub/main/class_HubConnector.php +++ b/application/hub/main/class_HubConnector.php @@ -40,12 +40,6 @@ class HubConnector extends BaseFrameworkSystem { // Call parent constructor parent::__construct(__CLASS__); - // Set description - $this->setObjectDescription("Hub-Connector"); - - // Set unique ID - $this->generateUniqueId(); - // Tidy up a little $this->removeSystemArray(); $this->removeNumberFormaters(); diff --git a/application/hub/main/class_HubCoreLoop.php b/application/hub/main/class_HubCoreLoop.php index 3b4328d6b..e2cc62994 100644 --- a/application/hub/main/class_HubCoreLoop.php +++ b/application/hub/main/class_HubCoreLoop.php @@ -107,12 +107,6 @@ class HubCoreLoop extends BaseFrameworkSystem { // Call parent constructor parent::__construct(__CLASS__); - // Set description - $this->setObjectDescription("Hub-Core Loop"); - - // Set unique ID - $this->generateUniqueId(); - // Tidy up a little $this->removeSystemArray(); $this->removeNumberFormaters(); diff --git a/application/hub/main/class_HubPeer.php b/application/hub/main/class_HubPeer.php index 6b74cdd67..c257bf2f7 100644 --- a/application/hub/main/class_HubPeer.php +++ b/application/hub/main/class_HubPeer.php @@ -136,12 +136,6 @@ class HubPeer extends BaseFrameworkSystem { // Call parent constructor parent::__construct(__CLASS__); - // Set description - $this->setObjectDescription("Hub-Peer"); - - // Set unique ID - $this->generateUniqueId(); - // Tidy up a little $this->removeSystemArray(); $this->removeNumberFormaters(); diff --git a/clear-cache.sh b/clear-cache.sh new file mode 100755 index 000000000..54edf120d --- /dev/null +++ b/clear-cache.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +echo "$0: Cleaning up..." +rm -f templates/images/_cache/*.png application/*/templates/images/_cache/*.png + +echo "$0: All done." diff --git a/inc/classes.php b/inc/classes.php index 1c52372f6..5a541c9d0 100644 --- a/inc/classes.php +++ b/inc/classes.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @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 @@ -30,32 +30,32 @@ $lowerClasses = array( ); // Load all classes -foreach ($lowerClasses as $class) { +foreach ($lowerClasses as $className) { // Try to load the framework classes try { - ClassLoader::getInstance()->loadClasses(sprintf("inc/classes/%s/", $class)); + 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", - $class + $className )); } catch (PathIsEmptyException $e) { ApplicationEntryPoint::app_die(sprintf("[Main:] Could not load framework classes from path %s for the follwing reason: %s", - $class + $className )); } catch (PathReadProtectedException $e) { ApplicationEntryPoint::app_die(sprintf("[Main:] Could not load framework classes from path %s for the follwing reason: %s", - $class + $className )); } catch (DirPointerNotOpenedException $e) { ApplicationEntryPoint::app_die(sprintf("[Main:] Could not load framework classes from path %s for the follwing reason: %s", - $class + $className )); } } // Clean up the global namespace unset($lowerClasses[3]); // Applications shall not have any middleware -unset($class); +unset($className); ////// Until here the framework classes are loaded ////// diff --git a/inc/classes/exceptions/actions/.htaccess b/inc/classes/exceptions/actions/.htaccess new file mode 100644 index 000000000..3a4288278 --- /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 000000000..3f6df3099 --- /dev/null +++ b/inc/classes/exceptions/actions/class_InvalidActionException.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 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.", + $msgArray[0]->__toString(), + $this->getLine(), + $msgArray[1] + ); + + // Call parent contructor with message + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/auth/class_UserAuthorizationException.php b/inc/classes/exceptions/auth/class_UserAuthorizationException.php index 5fedd40f3..a5ab08bdc 100644 --- a/inc/classes/exceptions/auth/class_UserAuthorizationException.php +++ b/inc/classes/exceptions/auth/class_UserAuthorizationException.php @@ -1,10 +1,10 @@ * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -19,19 +19,19 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * 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 + * @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", + $message = sprintf("[%s:%d] Authorization has failed. Error code %s", $filterInstance->__toString(), $this->getLine(), $this->getHexCode($code) diff --git a/inc/classes/exceptions/class_ b/inc/classes/exceptions/class_ index 3001d8420..afe1a08b9 100644 --- a/inc/classes/exceptions/class_ +++ b/inc/classes/exceptions/class_ @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -19,7 +19,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program. If not, see . */ class ???Exception extends FrameworkException { /** diff --git a/inc/classes/exceptions/class_FrameworkException.php b/inc/classes/exceptions/class_FrameworkException.php index 2c4039660..3ba2fbec9 100644 --- a/inc/classes/exceptions/class_FrameworkException.php +++ b/inc/classes/exceptions/class_FrameworkException.php @@ -6,7 +6,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -21,7 +21,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program. If not, see . */ abstract class FrameworkException extends ReflectionException { /** @@ -29,11 +29,16 @@ abstract class FrameworkException extends ReflectionException { */ 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 + * @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) { @@ -44,6 +49,19 @@ abstract class FrameworkException extends ReflectionException { $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); } @@ -54,7 +72,14 @@ abstract class FrameworkException extends ReflectionException { * @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); } /** @@ -66,6 +91,58 @@ abstract class FrameworkException extends ReflectionException { 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 * @@ -91,6 +168,25 @@ abstract class FrameworkException extends ReflectionException { // 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/class_MismatchingCompressorsException.php b/inc/classes/exceptions/compressor/class_MismatchingCompressorsException.php index 97c95adc7..1d0acb482 100644 --- a/inc/classes/exceptions/compressor/class_MismatchingCompressorsException.php +++ b/inc/classes/exceptions/compressor/class_MismatchingCompressorsException.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -19,7 +19,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program. If not, see . */ class MismatchingCompressorsException extends FrameworkException { /** @@ -31,7 +31,7 @@ class MismatchingCompressorsException extends FrameworkException { */ 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!", + $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]), diff --git a/inc/classes/exceptions/container/class_ContainerItemIsNoArrayException.php b/inc/classes/exceptions/container/class_ContainerItemIsNoArrayException.php index 062205298..fe6914e79 100644 --- a/inc/classes/exceptions/container/class_ContainerItemIsNoArrayException.php +++ b/inc/classes/exceptions/container/class_ContainerItemIsNoArrayException.php @@ -4,9 +4,10 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (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 @@ -19,19 +20,19 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program. If not, see . */ class ContainerItemIsNoArrayException extends FrameworkException { /** * The constructor * - * @param $message Message from the exception - * @param $code Code number for the exception + * @param $class Class throwing this exception + * @param $code Code number for the exception * @return void */ - public function __construct (BaseFrameworkSystem $class, $code) { + public function __construct (FrameworkInterface $class, $code) { // Add a message around the missing class - $message = sprintf("[%s:%d] Ein Container-Item ist kein Array.", + $message = sprintf("[%s:%d] A container item is not an array.", $class->__toString(), $this->getLine() ); diff --git a/inc/classes/exceptions/container/class_ContainerItemIsNullException.php b/inc/classes/exceptions/container/class_ContainerItemIsNullException.php index 05334ed1d..9d0b40b45 100644 --- a/inc/classes/exceptions/container/class_ContainerItemIsNullException.php +++ b/inc/classes/exceptions/container/class_ContainerItemIsNullException.php @@ -4,9 +4,10 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (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 @@ -19,19 +20,19 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program. If not, see . */ class ContainerItemIsNullException extends FrameworkException { /** * The constructor * - * @param $message Message from the exception - * @param $code Code number for the exception + * @param $class Class throwing this exception + * @param $code Code number for the exception * @return void */ - public function __construct (BaseFrameworkSystem $class, $code) { + public function __construct (FrameworkInterface $class, $code) { // Add a message around the missing class - $message = sprintf("[%s:%d] Ein Container-Item ist auf null gesetzt.", + $message = sprintf("[%s:%d] A container item is null.", $class->__toString(), $this->getLine() ); diff --git a/inc/classes/exceptions/container/class_ContainerMaybeDamagedException.php b/inc/classes/exceptions/container/class_ContainerMaybeDamagedException.php index 33232c08a..f8307b227 100644 --- a/inc/classes/exceptions/container/class_ContainerMaybeDamagedException.php +++ b/inc/classes/exceptions/container/class_ContainerMaybeDamagedException.php @@ -4,9 +4,10 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (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 @@ -19,19 +20,19 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program. If not, see . */ class ContainerMaybeDamagedException extends FrameworkException { /** * The constructor * - * @param $message Message from the exception - * @param $code Code number for the exception + * @param $class Class throwing this exception + * @param $code Code number for the exception * @return void */ - public function __construct (BaseFrameworkSystem $class, $code) { + public function __construct (FrameworkInterface $class, $code) { // Add a message around the missing class - $message = sprintf("[%s:%d] Ein Container ist möglicherweise beschädigt.", + $message = sprintf("[%s:%d] A container is possibly damaged.", $class->__toString(), $this->getLine() ); diff --git a/inc/classes/exceptions/controller/class_DefaultControllerException.php b/inc/classes/exceptions/controller/class_DefaultControllerException.php index 5a93a29cf..e0c891c7b 100644 --- a/inc/classes/exceptions/controller/class_DefaultControllerException.php +++ b/inc/classes/exceptions/controller/class_DefaultControllerException.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -25,8 +25,8 @@ 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 + * @param $resolverInstance An instance of a resolver class + * @param $code An optional code for better debugging * @return void */ public function __construct(ControllerResolver $resolverInstance, $code) { @@ -36,6 +36,9 @@ class DefaultControllerException extends FrameworkException { $this->getLine() ); + // Set extra data + $this->setExtraData($resolverInstance->getClassName().":".$this->getLine()); + // Call parent contructor with message parent::__construct($message, $code); } diff --git a/inc/classes/exceptions/controller/class_InvalidControllerException.php b/inc/classes/exceptions/controller/class_InvalidControllerException.php new file mode 100644 index 000000000..b166455a1 --- /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/crypto/.htaccess b/inc/classes/exceptions/crypto/.htaccess new file mode 100644 index 000000000..3a4288278 --- /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 000000000..4b6314d33 --- /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 000000000..78583c0c1 --- /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/class_ b/inc/classes/exceptions/database/class_ new file mode 100644 index 000000000..1124b1605 --- /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 index 3ff2e019e..ab2eabb05 100644 --- a/inc/classes/exceptions/database/class_DatabaseException.php +++ b/inc/classes/exceptions/database/class_DatabaseException.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -19,7 +19,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program. If not, see . */ class DatabaseException extends FrameworkException { /** 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 000000000..637b9629f --- /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 index 5cd4385c6..6270e9ce4 100644 --- a/inc/classes/exceptions/database/general/class_SqlException.php +++ b/inc/classes/exceptions/database/general/class_SqlException.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -19,7 +19,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program. If not, see . */ class SqlException extends DatabaseException { /** @@ -31,11 +31,11 @@ class SqlException extends DatabaseException { */ public function __construct (array $msgArray, $code) { // Construct the message - $message = sprintf("[%s:%d] SQL error detected. Message from database: %s, code: 0x%s.", + $message = sprintf("[%s:%d] SQL error detected. Message from database: %s, code: %s.", $msgArray[0]->__toString(), $this->getLine(), $msgArray[1], - dechex($msgArray[2]) + $this->getHexCode($msgArray[2]) ); // Call parent constructor diff --git a/inc/classes/exceptions/database/local_file/class_SavePathIsEmptyException.php b/inc/classes/exceptions/database/local_file/class_SavePathIsEmptyException.php index d9de2eef9..06f14ca21 100644 --- a/inc/classes/exceptions/database/local_file/class_SavePathIsEmptyException.php +++ b/inc/classes/exceptions/database/local_file/class_SavePathIsEmptyException.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -19,19 +19,19 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program. If not, see . */ class SavePathIsEmptyException extends DatabaseException { /** * The constructor * - * @param $message Message from the exception - * @param $code Code number for the exception + * @param $class Class throwing this exception + * @param $code Code number for the exception * @return void */ - public function __construct (BaseFrameworkSystem $class, $code) { + public function __construct (FrameworkInterface $class, $code) { // Add a message around the missing class - $message = sprintf("[%s:%d] Der Speicherpfad ist leer.", + $message = sprintf("[%s:%d] Save path is empty.", $class->__toString(), $this->getLine() ); diff --git a/inc/classes/exceptions/database/local_file/class_SavePathIsNoDirectoryException.php b/inc/classes/exceptions/database/local_file/class_SavePathIsNoDirectoryException.php index a3be62a18..a8fb42b62 100644 --- a/inc/classes/exceptions/database/local_file/class_SavePathIsNoDirectoryException.php +++ b/inc/classes/exceptions/database/local_file/class_SavePathIsNoDirectoryException.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -19,7 +19,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program. If not, see . */ class SavePathIsNoDirectoryException extends DatabaseException { /** @@ -31,7 +31,7 @@ class SavePathIsNoDirectoryException extends DatabaseException { */ public function __construct ($path, $code) { // Add a message around the missing class - $message = sprintf("Der angegebene Speicherpfad %s ist ungütig (kein Pfad).", $path); + $message = sprintf("Der angegebene Speicherpfad %s ist ungütig (kein Pfad).", $path); // Call parent constructor parent::__construct($message, $code); diff --git a/inc/classes/exceptions/database/local_file/class_SavePathReadProtectedException.php b/inc/classes/exceptions/database/local_file/class_SavePathReadProtectedException.php index 06ef4b4cd..7a0534b22 100644 --- a/inc/classes/exceptions/database/local_file/class_SavePathReadProtectedException.php +++ b/inc/classes/exceptions/database/local_file/class_SavePathReadProtectedException.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -19,7 +19,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program. If not, see . */ class SavePathReadProtectedException extends DatabaseException { /** @@ -31,7 +31,7 @@ class SavePathReadProtectedException extends DatabaseException { */ 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); + $message = sprintf("Der Pfad %s ist lese-geschützt. Bitte Zugriffsrechte (CHMOD) zum Lesen setzen.", $path); // Call parent constructor parent::__construct($message, $code); diff --git a/inc/classes/exceptions/database/local_file/class_SavePathWriteProtectedException.php b/inc/classes/exceptions/database/local_file/class_SavePathWriteProtectedException.php index a5c57f482..9d7f69934 100644 --- a/inc/classes/exceptions/database/local_file/class_SavePathWriteProtectedException.php +++ b/inc/classes/exceptions/database/local_file/class_SavePathWriteProtectedException.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -19,7 +19,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program. If not, see . */ class SavePathWriteProtectedException extends DatabaseException { /** @@ -31,7 +31,7 @@ class SavePathWriteProtectedException extends DatabaseException { */ 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); + $message = sprintf("Der angegebene Speicherpfad %s ist schreibgeschützt. Bitte Zugriffsrechte (CHMOD) entsprechend setzen.", $path); // Call parent constructor parent::__construct($message, $code); diff --git a/inc/classes/exceptions/database/wrapper/class_WrapperUserNameNotFoundException.php b/inc/classes/exceptions/database/wrapper/class_WrapperUserNameNotFoundException.php index c6014b123..bf3aa4c10 100644 --- a/inc/classes/exceptions/database/wrapper/class_WrapperUserNameNotFoundException.php +++ b/inc/classes/exceptions/database/wrapper/class_WrapperUserNameNotFoundException.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -19,7 +19,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program. If not, see . */ class WrapperUserNameNotFoundException extends DatabaseException { /** @@ -31,7 +31,7 @@ class WrapperUserNameNotFoundException extends DatabaseException { */ 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", + $message = sprintf("[%s:%d] Username %s was not found. Requesting class: %s", $msgArray[0]->__toString(), $this->getLine(), $msgArray[1]->getUserName(), diff --git a/inc/classes/exceptions/filter/class_FilterChainException.php b/inc/classes/exceptions/filter/class_FilterChainException.php index e1bfe10db..b2cbb1092 100644 --- a/inc/classes/exceptions/filter/class_FilterChainException.php +++ b/inc/classes/exceptions/filter/class_FilterChainException.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -19,14 +19,14 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * 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 + * @param $filterInstance Instance of a filter class + * @param $code Exception code for better debugging * @return void */ public function __construct(Filterable $filterInstance, $code) { diff --git a/inc/classes/exceptions/helper/class_FormClosedException.php b/inc/classes/exceptions/helper/class_FormClosedException.php index dd012eb04..59a52ad18 100644 --- a/inc/classes/exceptions/helper/class_FormClosedException.php +++ b/inc/classes/exceptions/helper/class_FormClosedException.php @@ -5,7 +5,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -26,13 +26,13 @@ class FormClosedException extends FrameworkException { /** * The constructor * - * @param $classArray Class throwing the exception - * @param $code Code number for the exception + * @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.", + $message = sprintf("[%s:%d] Could not add form element %s because form is closed.", $classArray[0]->__toString(), $this->getLine(), $classArray[1] diff --git a/inc/classes/exceptions/helper/class_FormGroupClosedException.php b/inc/classes/exceptions/helper/class_FormGroupClosedException.php index 8c56a5d2e..a1e88020c 100644 --- a/inc/classes/exceptions/helper/class_FormGroupClosedException.php +++ b/inc/classes/exceptions/helper/class_FormGroupClosedException.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -25,13 +25,13 @@ class FormGroupClosedException extends FrameworkException { /** * The constructor * - * @param $classArray Class throwing the exception - * @param $code Code number for the exception + * @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.", + $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] diff --git a/inc/classes/exceptions/helper/class_FormOpenedException.php b/inc/classes/exceptions/helper/class_FormOpenedException.php index c2aafbd20..aab6078d5 100644 --- a/inc/classes/exceptions/helper/class_FormOpenedException.php +++ b/inc/classes/exceptions/helper/class_FormOpenedException.php @@ -5,7 +5,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -26,16 +26,16 @@ class FormOpenedException extends FrameworkException { /** * The constructor * - * @param $class Class throwing the exception - * @param $code Code number for the exception + * @param $helperInstance Class throwing the exception + * @param $code Code number for the exception * @return void */ - public function __construct (BaseFrameworkSystem $class, $code) { + 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.", - $class->__toString(), + $helperInstance->__toString(), $this->getLine(), - $class->__toString() + $helperInstance->__toString() ); // Call parent constructor diff --git a/inc/classes/exceptions/helper/class_HelperGroupAlreadyCreatedException.php b/inc/classes/exceptions/helper/class_HelperGroupAlreadyCreatedException.php new file mode 100644 index 000000000..0f14f170d --- /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 000000000..6c257c0b5 --- /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 000000000..efdfff945 --- /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 index 00c36a25f..70e1c3dca 100644 --- a/inc/classes/exceptions/helper/class_InvalidFormNameException.php +++ b/inc/classes/exceptions/helper/class_InvalidFormNameException.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -25,14 +25,14 @@ class InvalidFormNameException extends FrameworkException { /** * The constructor * - * @param $class Class throwing the exception - * @param $code Code number for the exception + * @param $helperInstance Class throwing the exception + * @param $code Code number for the exception * @return void */ - public function __construct (BaseFrameworkSystem $class, $code) { + public function __construct (BaseHelper $helperInstance, $code) { // Add a message around the missing class $message = sprintf("[%s:%d] Form name not set.", - $class->__toString(), + $helperInstance->__toString(), $this->getLine() ); diff --git a/inc/classes/exceptions/helper/class_NoGroupOpenedException.php b/inc/classes/exceptions/helper/class_NoGroupOpenedException.php new file mode 100644 index 000000000..c650070d3 --- /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 index a10957209..e68e8f0f4 100644 --- a/inc/classes/exceptions/helper/class_UserInstanceMissingException.php +++ b/inc/classes/exceptions/helper/class_UserInstanceMissingException.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -25,13 +25,13 @@ class UserInstanceMissingException extends FrameworkException { /** * The constructor * - * @param $classArray Array with class instance and registry key - * @param $code Code number for the exception + * @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 ManageableUser.", + $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] diff --git a/inc/classes/exceptions/io/class_DirPointerNotOpenedException.php b/inc/classes/exceptions/io/class_DirPointerNotOpenedException.php index 12b4d2668..6dc16a4c9 100644 --- a/inc/classes/exceptions/io/class_DirPointerNotOpenedException.php +++ b/inc/classes/exceptions/io/class_DirPointerNotOpenedException.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -31,7 +31,7 @@ class DirPointerNotOpenedException extends FrameworkException { */ 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); + $message = sprintf("Für den Pfad %s konnte kein Pointer initialisiert werden.", $path); // Call parent constructor parent::__construct($message, $code); diff --git a/inc/classes/exceptions/io/class_FileNotFoundException.php b/inc/classes/exceptions/io/class_FileNotFoundException.php new file mode 100644 index 000000000..a0719448b --- /dev/null +++ b/inc/classes/exceptions/io/class_FileNotFoundException.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 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 index 760fca2f9..e7e8bde8f 100644 --- a/inc/classes/exceptions/io/class_FilePointerNotOpenedException.php +++ b/inc/classes/exceptions/io/class_FilePointerNotOpenedException.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -25,13 +25,13 @@ class FilePointerNotOpenedException extends FrameworkException { /** * The constructor * - * @param $fqfn Full-qualified file name of (maybe) missing file - * @param $code Code number for the exception + * @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); + $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); diff --git a/inc/classes/exceptions/io/class_FileReadProtectedException.php b/inc/classes/exceptions/io/class_FileReadProtectedException.php new file mode 100644 index 000000000..f68aebe38 --- /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 index 90d4ae086..47fd5fbcc 100644 --- a/inc/classes/exceptions/io/class_InvalidDataLengthException.php +++ b/inc/classes/exceptions/io/class_InvalidDataLengthException.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -19,23 +19,23 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program. If not, see . */ class InvalidDataLengthException extends FrameworkException { /** * The constructor * - * @param $array Message from the exception - * @param $code Code number for the exception + * @param $msgArray Message from the exception + * @param $code Code number for the exception * @return void */ - public function __construct (array $array, $code) { + 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!", - $array[0]->__toString(), + $message = sprintf("[%s:%d] Eine unerwartete Datenlänge von %s Byte ist aufgetreten. %s wurden erwartet!", + $msgArray[0]->__toString(), $this->getLine(), - $array[1], - $array[2] + $msgArray[1], + $msgArray[2] ); // Call parent constructor diff --git a/inc/classes/exceptions/io/class_InvalidDirectoryResourceException.php b/inc/classes/exceptions/io/class_InvalidDirectoryResourceException.php index 2dbe65cee..71a7f9c0d 100644 --- a/inc/classes/exceptions/io/class_InvalidDirectoryResourceException.php +++ b/inc/classes/exceptions/io/class_InvalidDirectoryResourceException.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -19,26 +19,22 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program. If not, see . */ class InvalidDirectoryResourceException extends FrameworkException { /** * The constructor * - * @param $message Message from the exception - * @param $code Code number for the exception + * @param $class Class throwing this exception + * @param $code Code number for the exception * @return void */ - public function __construct (BaseFrameworkSystem $class, $code) { + public function __construct (FrameworkInterface $class, $code) { // Add a message around the missing class - if (is_null($class)) { - $message = "[???:] Ungütige Verzeichnis-Resource."; - } elseif (is_object($class)) { - $message = sprintf("[%s:%d] Ungütige Verzeichnis-Resource.", - $class->__toString(), - $this->getLine() - ); - } + $message = sprintf("[%s:%d] Has an invalid directory resource.", + $class->__toString(), + $this->getLine() + ); // Call parent constructor parent::__construct($message, $code); diff --git a/inc/classes/exceptions/io/class_InvalidMD5ChecksumException.php b/inc/classes/exceptions/io/class_InvalidMD5ChecksumException.php index d15fbfec7..26a1270a0 100644 --- a/inc/classes/exceptions/io/class_InvalidMD5ChecksumException.php +++ b/inc/classes/exceptions/io/class_InvalidMD5ChecksumException.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -19,23 +19,23 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program. If not, see . */ class InvalidMD5ChecksumException extends FrameworkException { /** * The constructor * - * @param $array Message from the exception - * @param $code Code number for the exception + * @param $msgArray Message from the exception + * @param $code Code number for the exception * @return void */ - public function __construct (array $array, $code) { + 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!", - $array[0]->__toString(), + $message = sprintf("[%s:%d] Die MD5-Prüfsummen %s und %s stimmen nicht überein!", + $msgArray[0]->__toString(), $this->getLine(), - $array[1], - $array[2] + $msgArray[1], + $msgArray[2] ); // Call parent constructor diff --git a/inc/classes/exceptions/io/class_PathIsEmptyException.php b/inc/classes/exceptions/io/class_PathIsEmptyException.php index b8a286846..6747f7858 100644 --- a/inc/classes/exceptions/io/class_PathIsEmptyException.php +++ b/inc/classes/exceptions/io/class_PathIsEmptyException.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -19,26 +19,22 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program. If not, see . */ class PathIsEmptyException extends FrameworkException { /** * The constructor * - * @param $message Message from the exception - * @param $code Code number for the exception + * @param $class Class throwing this exception + * @param $code Code number for the exception * @return void */ - public function __construct (BaseFrameworkSystem $class, $code) { + public function __construct (FrameworkInterface $class, $code) { // Add a message around the missing class - if (is_null($class)) { - $message = "[???:] Der Verzeichnisname ist leer."; - } elseif (is_object($class)) { - $message = sprintf("[%s:%d] Der Verzeichnisname ist leer.", - $class->__toString(), - $this->getLine() - ); - } + $message = sprintf("[%s:%d] Directory path is empty.", + $class->__toString(), + $this->getLine() + ); // Call parent constructor parent::__construct($message, $code); diff --git a/inc/classes/exceptions/io/class_PathIsNoDirectoryException.php b/inc/classes/exceptions/io/class_PathIsNoDirectoryException.php index 2cedc57b1..51222ebc4 100644 --- a/inc/classes/exceptions/io/class_PathIsNoDirectoryException.php +++ b/inc/classes/exceptions/io/class_PathIsNoDirectoryException.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -19,19 +19,19 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * 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 + * @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); + $message = sprintf("Der angegebene Pfad %s ist ungütig (kein Pfad).", $path); // Call parent constructor parent::__construct($message, $code); diff --git a/inc/classes/exceptions/io/class_PathReadProtectedException.php b/inc/classes/exceptions/io/class_PathReadProtectedException.php index 102dae24a..09fed2bf7 100644 --- a/inc/classes/exceptions/io/class_PathReadProtectedException.php +++ b/inc/classes/exceptions/io/class_PathReadProtectedException.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -19,19 +19,19 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * 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 + * @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); + $message = sprintf("Der Pfad %s ist lese-geschützt. Bitte Zugriffsrechte (CHMOD) zum Lesen setzen.", $path); // Call parent constructor parent::__construct($message, $code); diff --git a/inc/classes/exceptions/language/class_InvalidLanguagePathStringException.php b/inc/classes/exceptions/language/class_InvalidLanguagePathStringException.php index 6e02cfe49..9265b3391 100644 --- a/inc/classes/exceptions/language/class_InvalidLanguagePathStringException.php +++ b/inc/classes/exceptions/language/class_InvalidLanguagePathStringException.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -19,22 +19,22 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program. If not, see . */ class InvalidLanguagePathStringException extends FrameworkException { /** * The constructor * - * @param $message Message from the exception - * @param $code Code number for the exception + * @param $classArray Array holding exception data + * @param $code Code number for the exception * @return void */ - public function __construct (BaseFrameworkSystem $class, $code) { + public function __construct (array $classArray, $code) { // Add a message around the missing class - $message = sprintf("[%s:%d] %s ist keine Zeichenkette!", - $class[0]->__toString(), + $message = sprintf("[%s:%d] %s is not a string with path!", + $classArray[0]->__toString(), $this->getLine(), - $class[1] + $classArray[1] ); // Call parent constructor diff --git a/inc/classes/exceptions/language/class_LanguagePathIsEmptyException.php b/inc/classes/exceptions/language/class_LanguagePathIsEmptyException.php index cd38561c3..557d32db1 100644 --- a/inc/classes/exceptions/language/class_LanguagePathIsEmptyException.php +++ b/inc/classes/exceptions/language/class_LanguagePathIsEmptyException.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -19,19 +19,19 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program. If not, see . */ class LanguagePathIsEmptyException extends FrameworkException { /** * The constructor * - * @param $message Message from the exception - * @param $code Code number for the exception + * @param $class Class throwing this exception + * @param $code Code number for the exception * @return void */ - public function __construct (BaseFrameworkSystem $class, $code) { + public function __construct (FrameworkInterface $class, $code) { // Add a message around the missing class - $message = sprintf("[%s:%d] Der Sprachen-Basispfad ist leer.", + $message = sprintf("[%s:%d] Language base path is empty.", $class->__toString(), $this->getLine() ); diff --git a/inc/classes/exceptions/language/class_LanguagePathIsNoDirectoryException.php b/inc/classes/exceptions/language/class_LanguagePathIsNoDirectoryException.php index 9b6b581de..858e73730 100644 --- a/inc/classes/exceptions/language/class_LanguagePathIsNoDirectoryException.php +++ b/inc/classes/exceptions/language/class_LanguagePathIsNoDirectoryException.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -19,22 +19,22 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program. If not, see . */ class LanguagePathIsNoDirectoryException extends FrameworkException { /** * The constructor * - * @param $message Message from the exception - * @param $code Code number for the exception + * @param $classArray Array holding exception data + * @param $code Code number for the exception * @return void */ - public function __construct (BaseFrameworkSystem $class, $code) { + 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!", - $class[0]->__toString(), + $message = sprintf("[%s:%d] Der Sprach-Basispfad %s existiert nicht oder ist eine Datei!", + $classArray[0]->__toString(), $this->getLine(), - $class[1] + $classArray[1] ); // Call parent constructor diff --git a/inc/classes/exceptions/language/class_LanguagePathReadProtectedException.php b/inc/classes/exceptions/language/class_LanguagePathReadProtectedException.php index 9df443e77..2fc786696 100644 --- a/inc/classes/exceptions/language/class_LanguagePathReadProtectedException.php +++ b/inc/classes/exceptions/language/class_LanguagePathReadProtectedException.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -19,22 +19,22 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program. If not, see . */ class LanguagePathReadProtectedException extends FrameworkException { /** * The constructor * - * @param $message Message from the exception - * @param $code Code number for the exception + * @param $class Array holding exception data + * @param $code Code number for the exception * @return void */ - public function __construct (BaseFrameworkSystem $class, $code) { + public function __construct (array $classArray, $code) { // Add a message around the missing class - $message = sprintf("[%s:%d] Der Sprach-Basispfad %s ist lesegeschützt! Bitte Zugriffsrechte (CHMOD) ändern.", - $class[0]->__toString(), + $message = sprintf("[%s:%d] Base language path %s is read-protected. Please change access rights (CHMOD).", + $classArray[0]->__toString(), $this->getLine(), - $class[1] + $classArray[1] ); // Call parent constructor diff --git a/inc/classes/exceptions/language/class_MissingFileIoHandlerException.php b/inc/classes/exceptions/language/class_MissingFileIoHandlerException.php index ea92f6de3..6a844db9a 100644 --- a/inc/classes/exceptions/language/class_MissingFileIoHandlerException.php +++ b/inc/classes/exceptions/language/class_MissingFileIoHandlerException.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -19,17 +19,17 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program. If not, see . */ class MissingFileIoHandlerException extends FrameworkException { /** * The constructor * - * @param $message Message from the exception - * @param $code Code number for the exception + * @param $class Class throwing this exception + * @param $code Code number for the exception * @return void */ - public function __construct (BaseFrameworkSystem $class, $code) { + 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(), diff --git a/inc/classes/exceptions/language/class_MissingLanguageHandlerException.php b/inc/classes/exceptions/language/class_MissingLanguageHandlerException.php index 9511e2169..a4a413198 100644 --- a/inc/classes/exceptions/language/class_MissingLanguageHandlerException.php +++ b/inc/classes/exceptions/language/class_MissingLanguageHandlerException.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -19,17 +19,17 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program. If not, see . */ class MissingLanguageHandlerException extends FrameworkException { /** * The constructor * - * @param $message Message from the exception - * @param $code Code number for the exception + * @param $class Class throwing this exception + * @param $code Code number for the exception * @return void */ - public function __construct (BaseFrameworkSystem $class, $code) { + public function __construct (FrameworkInterface $class, $code) { // Add a message around the missing class $message = sprintf("[%s:%d] Language sub-system not initialized!", $class->__toString(), diff --git a/inc/classes/exceptions/main/class_AssertionException.php b/inc/classes/exceptions/main/class_AssertionException.php new file mode 100644 index 000000000..270eb8fb7 --- /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 index 92364cd3b..32499e3e0 100644 --- a/inc/classes/exceptions/main/class_ClassMismatchException.php +++ b/inc/classes/exceptions/main/class_ClassMismatchException.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -19,19 +19,19 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program. If not, see . */ class ClassMismatchException extends FrameworkException { /** * The constructor * - * @param $message Message from the exception - * @param $code Code number for the exception + * @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("Die Klasse %s ist ungleich %s.", + $message = sprintf("The class %s does not match class %s.", $classArray[0], $classArray[1] ); diff --git a/inc/classes/exceptions/main/class_ClassNotFoundException.php b/inc/classes/exceptions/main/class_ClassNotFoundException.php index 5f037fe43..29f13f24b 100644 --- a/inc/classes/exceptions/main/class_ClassNotFoundException.php +++ b/inc/classes/exceptions/main/class_ClassNotFoundException.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -19,24 +19,27 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * 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 + * @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.", + $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); } diff --git a/inc/classes/exceptions/main/class_ConfigEntryIsEmptyException.php b/inc/classes/exceptions/main/class_ConfigEntryIsEmptyException.php index 29efd8f94..c0d60e28e 100644 --- a/inc/classes/exceptions/main/class_ConfigEntryIsEmptyException.php +++ b/inc/classes/exceptions/main/class_ConfigEntryIsEmptyException.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -19,19 +19,19 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program. If not, see . */ class ConfigEntryIsEmptyException extends FrameworkException { /** * The constructor * - * @param $message Message from the exception - * @param $code Code number for the exception + * @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] Leeren Konfigurationseintrag angegeben!", + $message = sprintf("[%s:%d] Empty configuration entry provided!", $class->__toString(), $this->getLine() ); diff --git a/inc/classes/exceptions/main/class_ConfigEntryNotFoundException.php b/inc/classes/exceptions/main/class_ConfigEntryNotFoundException.php index d42833191..e4ec1b773 100644 --- a/inc/classes/exceptions/main/class_ConfigEntryNotFoundException.php +++ b/inc/classes/exceptions/main/class_ConfigEntryNotFoundException.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -19,27 +19,27 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program. If not, see . */ class ConfigEntryNotFoundException extends FrameworkException { /** * The constructor * - * @param $message Message from the exception - * @param $code Code number for the exception + * @param $classArray Array with exception data + * @param $code Code number for the exception * @return void */ public function __construct (array $classArray, $code) { - // Cast the array - $classArray = (array) $classArray; - // Add a message around the missing class - $message = sprintf("[%s:%d] Konfigurationseintrag %s nicht gefunden.", + $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); } diff --git a/inc/classes/exceptions/main/class_DimNotFoundInArrayException.php b/inc/classes/exceptions/main/class_DimNotFoundInArrayException.php index 25a694c37..7806f9b81 100644 --- a/inc/classes/exceptions/main/class_DimNotFoundInArrayException.php +++ b/inc/classes/exceptions/main/class_DimNotFoundInArrayException.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -19,26 +19,26 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program. If not, see . */ class DimNotFoundInArrayException extends FrameworkException { /** * The constructor * - * @param $message Message from the exception - * @param $code Code number for the exception + * @param $class Class throwing the exception + * @param $code Code number for the exception * @return void */ - public function __construct (BaseFrameworkSystem $class, $code) { + public function __construct (FrameworkInterface $class, $code) { if (is_object($class)) { // Add a message around the missing class - $message = sprintf("[%s:%d] Abmasse konnten nicht extrahiert werden!", + $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__); + $message = sprintf("Please provide a class for %s", __CLASS__); } // Call parent constructor diff --git a/inc/classes/exceptions/main/class_EmptyVariableException.php b/inc/classes/exceptions/main/class_EmptyVariableException.php index 7fa7f48e3..1fae65454 100644 --- a/inc/classes/exceptions/main/class_EmptyVariableException.php +++ b/inc/classes/exceptions/main/class_EmptyVariableException.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -25,13 +25,13 @@ class EmptyVariableException extends FrameworkException { /** * The constructor * - * @param $msgArray Message array holding all needed data - * @param $code Code number for the exception + * @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.", + $message = sprintf("[%s:%d] Variable %s is not set.", $msgArray[0]->__toString(), $this->getLine(), $msgArray[1] diff --git a/inc/classes/exceptions/main/class_ExceptionNotFoundException.php b/inc/classes/exceptions/main/class_ExceptionNotFoundException.php index eed88505a..d3b37c8a4 100644 --- a/inc/classes/exceptions/main/class_ExceptionNotFoundException.php +++ b/inc/classes/exceptions/main/class_ExceptionNotFoundException.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -19,22 +19,19 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program. If not, see . */ class ExceptionNotFoundException extends FrameworkException { /** * The constructor * - * @param $message Message from the exception - * @param $code Code number for the exception + * @param $classArray Array with exception data + * @param $code Code number for the exception * @return void */ public function __construct (array $classArray, $code) { - // Cast the array - $classArray = (array) $classArray; - // Add a message around the missing class - $message = sprintf("[%s:%d] Exception %s nicht gefunden.", + $message = sprintf("[%s:%d] Exception %s not found.", $classArray[0], $this->getLine(), $classArray[1] diff --git a/inc/classes/exceptions/main/class_FatalErrorException.php b/inc/classes/exceptions/main/class_FatalErrorException.php new file mode 100644 index 000000000..2c4b880b2 --- /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 index bcc958f55..5291b0594 100644 --- a/inc/classes/exceptions/main/class_GetterNotFoundException.php +++ b/inc/classes/exceptions/main/class_GetterNotFoundException.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -19,14 +19,14 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * 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 + * @param $message Message from the exception + * @param $code Code number for the exception * @return void */ public function __construct ($dataArray, $code) { @@ -34,7 +34,7 @@ class GetterNotFoundException extends FrameworkException { $dataArray = (array) $dataArray; // Add a message around the missing class - $message = sprintf("[%s:%d] Getter-Methode für Attribut %s nicht gefunden.", + $message = sprintf("[%s:%d] Getter-Methode für Attribut %s nicht gefunden.", $dataArray[0]->__toString(), $this->getLine(), $dataArray[1] diff --git a/inc/classes/exceptions/main/class_InvalidArrayCountException.php b/inc/classes/exceptions/main/class_InvalidArrayCountException.php index 0fc6f6685..a85bebfc9 100644 --- a/inc/classes/exceptions/main/class_InvalidArrayCountException.php +++ b/inc/classes/exceptions/main/class_InvalidArrayCountException.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -19,7 +19,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program. If not, see . */ class InvalidArrayCountException extends FrameworkException { /** @@ -31,7 +31,7 @@ class InvalidArrayCountException extends FrameworkException { */ 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!", + $message = sprintf("[%s:%d] %s hat %d Elemente, soll aber %d enthalten!", $array[0]->__toString(), $this->getLine(), $array[1], diff --git a/inc/classes/exceptions/main/class_InvalidCommandException.php b/inc/classes/exceptions/main/class_InvalidCommandException.php index add16453d..d546cc1e2 100644 --- a/inc/classes/exceptions/main/class_InvalidCommandException.php +++ b/inc/classes/exceptions/main/class_InvalidCommandException.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -25,18 +25,22 @@ class InvalidCommandException extends FrameworkException { /** * The constructor * - * @param $message Message from the exception - * @param $code Code number for the exception + * @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.", + $message = sprintf("[%s:%d] Invalid command %s (class %s) detected.", $msgArray[0]->__toString(), $this->getLine(), - htmlentities(strip_tags($msgArray[1]), ENT_QUOTES) + $msgArray[1], + $msgArray[0]->getClassName() ); + // Set extra data + $this->setExtraData($msgArray[0]->getClassName().":".$this->getLine()); + // Call parent constructor parent::__construct($message, $code); } diff --git a/inc/classes/exceptions/main/class_InvalidCommandInstanceException.php b/inc/classes/exceptions/main/class_InvalidCommandInstanceException.php index 772852644..93cc03a56 100644 --- a/inc/classes/exceptions/main/class_InvalidCommandInstanceException.php +++ b/inc/classes/exceptions/main/class_InvalidCommandInstanceException.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -25,13 +25,13 @@ class InvalidCommandInstanceException extends FrameworkException { /** * The constructor * - * @param $message Message from the exception - * @param $code Code number for the exception + * @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.", + $message = sprintf("[%s:%d] Invalid command %s detected.", $msgArray[0]->__toString(), $this->getLine(), $msgArray[1] diff --git a/inc/classes/exceptions/main/class_InvalidControllerException.php b/inc/classes/exceptions/main/class_InvalidControllerException.php index a3043d7ea..374c167fb 100644 --- a/inc/classes/exceptions/main/class_InvalidControllerException.php +++ b/inc/classes/exceptions/main/class_InvalidControllerException.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -25,13 +25,13 @@ class InvalidControllerInstanceException extends FrameworkException { /** * The constructor * - * @param $msgArray Array with data from the exception point - * @param $code Code number for the exception + * @param $msgArray Array with data from the exception point + * @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 controller %s detected.", + $message = sprintf("[%s:%d] Invalid controller %s detected.", $msgArray[0]->__toString(), $this->getLine(), $msgArray[1] diff --git a/inc/classes/exceptions/main/class_InvalidInterfaceException.php b/inc/classes/exceptions/main/class_InvalidInterfaceException.php new file mode 100644 index 000000000..a7fc71e4d --- /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 .", + $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 index 1b4438b0c..7a002d455 100644 --- a/inc/classes/exceptions/main/class_InvalidObjectException.php +++ b/inc/classes/exceptions/main/class_InvalidObjectException.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -19,22 +19,21 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program. If not, see . */ class InvalidObjectException extends FrameworkException { /** * The constructor * - * @param $message Message from the exception - * @param $code Code number for the exception + * @param $class Class throwing the exception + * @param $code Code number for the exception * @return void */ - public function __construct (BaseFrameworkSystem $class, $code) { + public function __construct (FrameworkInterface $class, $code) { // Add a message around the missing class - $message = sprintf("[%s:%d] Objekte sind nicht erlaubt. (Objekt: %s)", + $message = sprintf("[%s:%d] Object is not allowed here.", $class->__toString(), - $this->getLine(), - $class->getObjectDescription() + $this->getLine() ); // Call parent constructor diff --git a/inc/classes/exceptions/main/class_MissingArrayElementsException.php b/inc/classes/exceptions/main/class_MissingArrayElementsException.php index 890aa2d2c..a59b51432 100644 --- a/inc/classes/exceptions/main/class_MissingArrayElementsException.php +++ b/inc/classes/exceptions/main/class_MissingArrayElementsException.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -19,20 +19,17 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program. If not, see . */ class MissingArrayElementsException extends FrameworkException { /** * The constructor * - * @param $message Message from the exception - * @param $code Code number for the exception + * @param $classArray Array with exception data + * @param $code Code number for the exception * @return void */ public function __construct (array $classArray, $code) { - // Cast the array - $classArray = (array) $classArray; - // Extract all elements $elements = ""; if ((isset($classArray[2])) && (is_array($classArray[2]))) { @@ -44,7 +41,7 @@ class MissingArrayElementsException extends FrameworkException { } // Add a message around the missing class - $message = sprintf("[%s:%d] Das Array %s() keine Elemente %s auf!", + $message = sprintf("[%s:%d] Array %s() Does not have these elements: %s", $classArray[0]->__toString(), $this->getLine(), $classArray[1], diff --git a/inc/classes/exceptions/main/class_MissingDecimalsThousandsSeperatorException.php b/inc/classes/exceptions/main/class_MissingDecimalsThousandsSeperatorException.php index 7c40bfb8c..397e0e8ad 100644 --- a/inc/classes/exceptions/main/class_MissingDecimalsThousandsSeperatorException.php +++ b/inc/classes/exceptions/main/class_MissingDecimalsThousandsSeperatorException.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -19,14 +19,14 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * 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 + * @param $message Message from the exception + * @param $code Code number for the exception * @return void */ public function __construct ($instance, $code) { diff --git a/inc/classes/exceptions/main/class_MissingMethodException.php b/inc/classes/exceptions/main/class_MissingMethodException.php index 65eb60d07..3ef08ac39 100644 --- a/inc/classes/exceptions/main/class_MissingMethodException.php +++ b/inc/classes/exceptions/main/class_MissingMethodException.php @@ -4,9 +4,10 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (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 @@ -19,22 +20,19 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program. If not, see . */ class MissingMethodException extends FrameworkException { /** * The constructor * - * @param $message Message from the exception - * @param $code Code number for the exception + * @param $classArray Array holding the exception data + * @param $code Code number for the exception * @return void */ public function __construct (array $classArray, $code) { - // Cast the array - $classArray = (array) $classArray; - // Add a message around the missing class - $message = sprintf("[%s:%d] Weisst keine Methode %s() auf!", + $message = sprintf("[%s:%d] This class has no method %s()!", $classArray[0]->__toString(), $this->getLine(), $classArray[1] diff --git a/inc/classes/exceptions/main/class_NoArrayCreatedException.php b/inc/classes/exceptions/main/class_NoArrayCreatedException.php index 264d69d54..36dcbba99 100644 --- a/inc/classes/exceptions/main/class_NoArrayCreatedException.php +++ b/inc/classes/exceptions/main/class_NoArrayCreatedException.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -19,7 +19,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program. If not, see . */ class NoArrayCreatedException extends FrameworkException { /** @@ -31,7 +31,7 @@ class NoArrayCreatedException extends FrameworkException { */ public function __construct (array $array, $code) { // Add a message around the missing class - $message = sprintf("[%s:%d] %s ist kein erstelltes Objekt.", + $message = sprintf("[%s:%d] %s ist kein erstelltes Objekt.", $array[0]->__toString(), $this->getLine(), $array[1] diff --git a/inc/classes/exceptions/main/class_NoArrayException.php b/inc/classes/exceptions/main/class_NoArrayException.php index 00f240ea7..2f0c557b7 100644 --- a/inc/classes/exceptions/main/class_NoArrayException.php +++ b/inc/classes/exceptions/main/class_NoArrayException.php @@ -2,7 +2,7 @@ /** * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -17,19 +17,19 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * 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 + * @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!", + $message = sprintf("%s ist kein Array!", $string ); diff --git a/inc/classes/exceptions/main/class_NoObjectException.php b/inc/classes/exceptions/main/class_NoObjectException.php index 1812a16fb..20f6870f4 100644 --- a/inc/classes/exceptions/main/class_NoObjectException.php +++ b/inc/classes/exceptions/main/class_NoObjectException.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (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 @@ -21,19 +21,19 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program. If not, see . */ class NoObjectException extends FrameworkException { /** * The constructor * - * @param $message Message from the exception - * @param $code Code number for the exception + * @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!", + $message = sprintf("%s ist kein Objekt!", $string ); diff --git a/inc/classes/exceptions/main/class_NullPointerException.php b/inc/classes/exceptions/main/class_NullPointerException.php index 42ed410f3..551daa074 100644 --- a/inc/classes/exceptions/main/class_NullPointerException.php +++ b/inc/classes/exceptions/main/class_NullPointerException.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -19,19 +19,19 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program. If not, see . */ class NullPointerException extends FrameworkException { /** * The constructor * - * @param $message Message from the exception - * @param $code Code number for the exception + * @param $class Class throwing this exception + * @param $code Code number for the exception * @return void */ - public function __construct (BaseFrameworkSystem $class, $code) { + public function __construct (FrameworkInterface $class, $code) { // Add a message around the missing class - $message = sprintf("[%s:%d] Eine Instanz/Pointer ist auf null gesetzt.", + $message = sprintf("[%s:%d] An object instance is set to null.", $class->__toString(), $this->getLine() ); diff --git a/inc/classes/exceptions/main/class_ResponseHeadersAlreadySentException.php b/inc/classes/exceptions/main/class_ResponseHeadersAlreadySentException.php index 16e36e165..f08d66298 100644 --- a/inc/classes/exceptions/main/class_ResponseHeadersAlreadySentException.php +++ b/inc/classes/exceptions/main/class_ResponseHeadersAlreadySentException.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -25,11 +25,11 @@ class ResponseHeadersAlreadySentException extends FrameworkException { /** * The constructor * - * @param $message Message from the exception - * @param $code Code number for the exception + * @param $class Class throwing this exception + * @param $code Code number for the exception * @return void */ - public function __construct (BaseFrameworkSystem $class, $code) { + public function __construct (FrameworkInterface $class, $code) { // Add a message around the missing class $message = sprintf("[%s:%d] Headers are already sent!", $class->__toString(), diff --git a/inc/classes/exceptions/main/class_VariableIsNotSetException.php b/inc/classes/exceptions/main/class_VariableIsNotSetException.php index 36372e574..57000be1e 100644 --- a/inc/classes/exceptions/main/class_VariableIsNotSetException.php +++ b/inc/classes/exceptions/main/class_VariableIsNotSetException.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -19,7 +19,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program. If not, see . */ class VariableIsNotSetException extends FrameworkException { /** @@ -31,7 +31,7 @@ class VariableIsNotSetException extends FrameworkException { */ 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.", + $message = sprintf("[%s:%d] Bei der Initialisierung der Applikation %s wurde keine Variable %s erzeugt.", $array[0]->__toString(), $this->getLine(), $array[1], diff --git a/inc/classes/exceptions/result/.htaccess b/inc/classes/exceptions/result/.htaccess new file mode 100644 index 000000000..3a4288278 --- /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 000000000..be1ab5d37 --- /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 000000000..da2ec8f5f --- /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/class_BasePathIsEmptyException.php b/inc/classes/exceptions/template/class_BasePathIsEmptyException.php index 78dd8571a..e4d4e4e6e 100644 --- a/inc/classes/exceptions/template/class_BasePathIsEmptyException.php +++ b/inc/classes/exceptions/template/class_BasePathIsEmptyException.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -19,19 +19,19 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program. If not, see . */ class BasePathIsEmptyException extends FrameworkException { /** * The constructor * - * @param $class An array holding our informations - * @param $code Code number for the exception + * @param $class Class throwing this exception + * @param $code Code number for the exception * @return void */ - public function __construct (BaseFrameworkSystem $class, $code) { + public function __construct (FrameworkInterface $class, $code) { // Add a message around the missing class - $message = sprintf("[%s:%d] Der Template-Basispfad ist leer.", + $message = sprintf("[%s:%d] Template path is empty.", $class->__toString(), $this->getLine() ); diff --git a/inc/classes/exceptions/template/class_BasePathIsNoDirectoryException.php b/inc/classes/exceptions/template/class_BasePathIsNoDirectoryException.php index ab6b7f058..5a109fb6a 100644 --- a/inc/classes/exceptions/template/class_BasePathIsNoDirectoryException.php +++ b/inc/classes/exceptions/template/class_BasePathIsNoDirectoryException.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -19,22 +19,22 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program. If not, see . */ class BasePathIsNoDirectoryException extends FrameworkException { /** * The constructor * - * @param $class An array holding our informations - * @param $code Code number for the exception + * @param $classArray An array holding our informations + * @param $code Code number for the exception * @return void */ - public function __construct (BaseFrameworkSystem $class, $code) { + 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!", - $class[0]->__toString(), + $message = sprintf("[%s:%d] Der Template-Basispfad %s existiert nicht oder ist eine Datei!", + $classArray[0]->__toString(), $this->getLine(), - $class[1] + $classArray[1] ); // Call parent constructor diff --git a/inc/classes/exceptions/template/class_BasePathReadProtectedException.php b/inc/classes/exceptions/template/class_BasePathReadProtectedException.php index 3d1507a3e..c66fd7b29 100644 --- a/inc/classes/exceptions/template/class_BasePathReadProtectedException.php +++ b/inc/classes/exceptions/template/class_BasePathReadProtectedException.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -19,22 +19,22 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program. If not, see . */ class BasePathReadProtectedException extends FrameworkException { /** * The constructor * - * @param $class An array holding our informations - * @param $code Code number for the exception + * @param $classArray An array holding our informations + * @param $code Code number for the exception * @return void */ - public function __construct (BaseFrameworkSystem $class, $code) { + 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.", - $class[0]->__toString(), + $message = sprintf("[%s:%d] Der Template-Basispfad %s ist lesegeschützt! Bitte Zugriffsrechte (CHMOD) ändern.", + $classArray[0]->__toString(), $this->getLine(), - $class[1] + $classArray[1] ); // Call parent constructor diff --git a/inc/classes/exceptions/template/class_InvalidBasePathStringException.php b/inc/classes/exceptions/template/class_InvalidBasePathStringException.php index 9aa3ad4bb..c52a5847b 100644 --- a/inc/classes/exceptions/template/class_InvalidBasePathStringException.php +++ b/inc/classes/exceptions/template/class_InvalidBasePathStringException.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -19,22 +19,22 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program. If not, see . */ class InvalidBasePathStringException extends FrameworkException { /** * The constructor * - * @param $class An array holding our informations - * @param $code Code number for the exception + * @param $classArray Array holding exception data + * @param $code Code number for the exception * @return void */ - public function __construct (BaseFrameworkSystem $class, $code) { + public function __construct (array $classArray, $code) { // Add a message around the missing class - $message = sprintf("[%s:%d] %s ist keine Zeichenkette!", - $class[0]->__toString(), + $message = sprintf("[%s:%d] %s is not a string with a base path!", + $classArray[0]->__toString(), $this->getLine(), - $class[1] + $classArray[1] ); // Call parent constructor diff --git a/inc/classes/exceptions/template/class_UnexpectedTemplateTypeException.php b/inc/classes/exceptions/template/class_UnexpectedTemplateTypeException.php index c761da6af..9a7eb0556 100644 --- a/inc/classes/exceptions/template/class_UnexpectedTemplateTypeException.php +++ b/inc/classes/exceptions/template/class_UnexpectedTemplateTypeException.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -25,13 +25,13 @@ class UnexpectedTemplateTypeException extends FrameworkException { /** * The constructor * - * @param $msgArray An array holding our informations - * @param $code Code number for the exception + * @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.", + $message = sprintf("[%s:%d] Der Template-Typ %s entspricht nicht dem erwartetem Template-Typ %s.", $msgArray[0]->__toString(), $this->getLine(), $msgArray[1], diff --git a/inc/classes/exceptions/template/class_UnsupportedTemplateEngineException.php b/inc/classes/exceptions/template/class_UnsupportedTemplateEngineException.php index 46d15190a..75c81a4f1 100644 --- a/inc/classes/exceptions/template/class_UnsupportedTemplateEngineException.php +++ b/inc/classes/exceptions/template/class_UnsupportedTemplateEngineException.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -19,19 +19,19 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program. If not, see . */ class UnsupportedTemplateEngineException extends FrameworkException { /** * The constructor * - * @param $class An array holding our informations - * @param $code Code number for the exception + * @param $class Class throwing this class + * @param $code Code number for the exception * @return void */ - public function __construct (BaseFrameworkSystem $class, $code) { + public function __construct (FrameworkInterface $class, $code) { // Add a message around the missing class - $message = sprintf("Template-Engine %s wird nicht unterstützt.", + $message = sprintf("Template-Engine %s not (yet) supported.", $class->__toString() ); diff --git a/inc/classes/exceptions/template/class_ViewHelperNotFoundException.php b/inc/classes/exceptions/template/class_ViewHelperNotFoundException.php index 0fe1d0296..0af17cd21 100644 --- a/inc/classes/exceptions/template/class_ViewHelperNotFoundException.php +++ b/inc/classes/exceptions/template/class_ViewHelperNotFoundException.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -19,19 +19,19 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * 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 + * @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.", + $message = sprintf("[%s:] View-Helper %s ist ungültig.", $msgArray[0]->__toString(), $msgArray[1] ); diff --git a/inc/classes/exceptions/user/class_AccountPasswordMismatchException.php b/inc/classes/exceptions/user/class_AccountPasswordMismatchException.php new file mode 100644 index 000000000..603f13257 --- /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 index 3c816e96f..27dbf51b1 100644 --- a/inc/classes/exceptions/user/class_UserEmailMissingException.php +++ b/inc/classes/exceptions/user/class_UserEmailMissingException.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -25,13 +25,13 @@ 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 + * @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.", + $message = sprintf("[%s:%d] User email %s was not found.", $msgArray[0]->__toString(), $this->getLine(), $msgArray[1] diff --git a/inc/classes/exceptions/user/class_UserPasswordMismatchException.php b/inc/classes/exceptions/user/class_UserPasswordMismatchException.php index 2ca954d6f..a5184b37c 100644 --- a/inc/classes/exceptions/user/class_UserPasswordMismatchException.php +++ b/inc/classes/exceptions/user/class_UserPasswordMismatchException.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -25,13 +25,13 @@ 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 + * @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.", + $message = sprintf("[%s:%d] Supplied password for user %s did not match with stored password.", $msgArray[0]->__toString(), $this->getLine(), $msgArray[1]->getUserName() diff --git a/inc/classes/exceptions/user/class_UsernameMissingException.php b/inc/classes/exceptions/user/class_UsernameMissingException.php index 42160ede8..0ab7e9e54 100644 --- a/inc/classes/exceptions/user/class_UsernameMissingException.php +++ b/inc/classes/exceptions/user/class_UsernameMissingException.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -25,13 +25,13 @@ 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 + * @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.", + $message = sprintf("[%s:%d] Username %s was not found.", $msgArray[0]->__toString(), $this->getLine(), $msgArray[1] diff --git a/inc/classes/exceptions/xml/.htaccess b/inc/classes/exceptions/xml/.htaccess new file mode 100644 index 000000000..3a4288278 --- /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 000000000..d503ae6fb --- /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 000000000..848d542cb --- /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 000000000..91d12e538 --- /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/actions/.htaccess b/inc/classes/interfaces/actions/.htaccess new file mode 100644 index 000000000..3a4288278 --- /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 000000000..ad06b8c56 --- /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 000000000..3a4288278 --- /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 000000000..2bd63f00d --- /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/class_ManageableApplication.php b/inc/classes/interfaces/application/class_ManageableApplication.php index cdf7afdc7..ec0e2b651 100644 --- a/inc/classes/interfaces/application/class_ManageableApplication.php +++ b/inc/classes/interfaces/application/class_ManageableApplication.php @@ -9,7 +9,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * diff --git a/inc/classes/interfaces/auth/class_Authorizeable.php b/inc/classes/interfaces/auth/class_Authorizeable.php index 88e383fe3..1ddfad6d7 100644 --- a/inc/classes/interfaces/auth/class_Authorizeable.php +++ b/inc/classes/interfaces/auth/class_Authorizeable.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -28,6 +28,13 @@ interface Authorizeable extends FrameworkInterface { * @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/class_Cacheable.php b/inc/classes/interfaces/cache/class_Cacheable.php index b58c8badd..39cb18cc5 100644 --- a/inc/classes/interfaces/cache/class_Cacheable.php +++ b/inc/classes/interfaces/cache/class_Cacheable.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * diff --git a/inc/classes/interfaces/captcha/.htaccess b/inc/classes/interfaces/captcha/.htaccess new file mode 100644 index 000000000..3a4288278 --- /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 000000000..e21ce4add --- /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_ index 60a8e962c..b750dd9f0 100644 --- a/inc/classes/interfaces/class_ +++ b/inc/classes/interfaces/class_ @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * diff --git a/inc/classes/interfaces/class_FrameworkInterface.php b/inc/classes/interfaces/class_FrameworkInterface.php index 212e03174..bffb8743a 100644 --- a/inc/classes/interfaces/class_FrameworkInterface.php +++ b/inc/classes/interfaces/class_FrameworkInterface.php @@ -5,7 +5,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -20,9 +20,17 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * 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/class_Compressor.php b/inc/classes/interfaces/compressor/class_Compressor.php index c7b725a24..0e8dfcb44 100644 --- a/inc/classes/interfaces/compressor/class_Compressor.php +++ b/inc/classes/interfaces/compressor/class_Compressor.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -19,7 +19,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program. If not, see . */ interface Compressor extends FrameworkInterface { /** diff --git a/inc/classes/interfaces/controller/class_Controller.php b/inc/classes/interfaces/controller/class_Controller.php index 7169d880e..bf8ae9712 100644 --- a/inc/classes/interfaces/controller/class_Controller.php +++ b/inc/classes/interfaces/controller/class_Controller.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * diff --git a/inc/classes/interfaces/criteria/class_Criteria.php b/inc/classes/interfaces/criteria/class_Criteria.php index f6cf6be6f..64ec5ad74 100644 --- a/inc/classes/interfaces/criteria/class_Criteria.php +++ b/inc/classes/interfaces/criteria/class_Criteria.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * diff --git a/inc/classes/interfaces/criteria/extended/class_LocalSearchCriteria.php b/inc/classes/interfaces/criteria/extended/class_LocalSearchCriteria.php index cfb84942a..dd09ad5f8 100644 --- a/inc/classes/interfaces/criteria/extended/class_LocalSearchCriteria.php +++ b/inc/classes/interfaces/criteria/extended/class_LocalSearchCriteria.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * 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 000000000..c88e0b09b --- /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 index 42daaad82..6abde1af2 100644 --- a/inc/classes/interfaces/criteria/extended/class_StoreableCriteria.php +++ b/inc/classes/interfaces/criteria/extended/class_StoreableCriteria.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -19,7 +19,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program. If not, see . */ interface StoreableCriteria extends Criteria { } diff --git a/inc/classes/interfaces/crypto/.htaccess b/inc/classes/interfaces/crypto/.htaccess new file mode 100644 index 000000000..3a4288278 --- /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 000000000..3d6f60000 --- /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 the 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/class_FrameworkDatabaseInterface.php b/inc/classes/interfaces/database/class_FrameworkDatabaseInterface.php index 196616153..846f140d0 100644 --- a/inc/classes/interfaces/database/class_FrameworkDatabaseInterface.php +++ b/inc/classes/interfaces/database/class_FrameworkDatabaseInterface.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -19,23 +19,19 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program. If not, see . */ interface FrameworkDatabaseInterface extends FrameworkInterface { /** * Analyses if a unique ID has already been used or not. This method does * only pass the given ID through to the "real" database layer. * - * @param $uniqueID A unique ID number which shall be checked - * before it will be used - * @param $inConstructor If called from a constructor or from - * somewhere else - * @return $isUnused true = The unique ID was not found in the database, - * false = It is already in use by an other object - * @throws NullPointerException If $dbInstance is null - * @throws NoObjectException If $dbInstance is not an object - * @throws MissingMethodException If the required method - * isUniqueIdUsed() was not found + * @param $uniqueID A unique ID number which shall be checked + * before it will be used + * @param $inConstructor If called from a constructor or from + * somewhere else + * @return $isUnused true = The unique ID was not found in the database, + * false = It is already in use by an other object */ function isUniqueIdUsed ($uniqueID, $inConstructor = false); } diff --git a/inc/classes/interfaces/database/class_Updateable.php b/inc/classes/interfaces/database/class_Updateable.php new file mode 100644 index 000000000..ba8de80fb --- /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/class_DatabaseFrontendInterface.php b/inc/classes/interfaces/database/frontend/class_DatabaseFrontendInterface.php index 7621713a4..1d3ebe58a 100644 --- a/inc/classes/interfaces/database/frontend/class_DatabaseFrontendInterface.php +++ b/inc/classes/interfaces/database/frontend/class_DatabaseFrontendInterface.php @@ -8,7 +8,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -23,21 +23,9 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program. If not, see . */ interface DatabaseFrontendInterface extends FrameworkDatabaseInterface { - /** - * Loads data saved with saveObject from the database and re-creates a - * full object from it. - * If limitObject() was called before a new object ObjectContainer with - * all requested attributes will be returned instead. - * - * @return Object The fully re-created object or instance to - * ObjectContainer - * @deprecated - */ - function loadObject (); - /** * Makes sure that the database connection is up and alive * @@ -66,6 +54,15 @@ interface DatabaseFrontendInterface extends FrameworkDatabaseInterface { * @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/class_DatabaseConnector.php b/inc/classes/interfaces/database/middleware/class_DatabaseConnector.php index 9a56aec30..995f43a45 100644 --- a/inc/classes/interfaces/database/middleware/class_DatabaseConnector.php +++ b/inc/classes/interfaces/database/middleware/class_DatabaseConnector.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -19,7 +19,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program. If not, see . */ interface DatabaseConnector extends FrameworkDatabaseInterface { } diff --git a/inc/classes/interfaces/debug/class_Debugger.php b/inc/classes/interfaces/debug/class_Debugger.php index cce33d045..8700229d8 100644 --- a/inc/classes/interfaces/debug/class_Debugger.php +++ b/inc/classes/interfaces/debug/class_Debugger.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -19,7 +19,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program. If not, see . */ interface Debugger extends FrameworkInterface { /** diff --git a/inc/classes/interfaces/filter/class_Filterable.php b/inc/classes/interfaces/filter/class_Filterable.php index 657dc2aec..ad2c568cb 100644 --- a/inc/classes/interfaces/filter/class_Filterable.php +++ b/inc/classes/interfaces/filter/class_Filterable.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * diff --git a/inc/classes/interfaces/helper/class_HelpableLogin.php b/inc/classes/interfaces/helper/class_HelpableLogin.php index cf5f84f87..c1919d2e1 100644 --- a/inc/classes/interfaces/helper/class_HelpableLogin.php +++ b/inc/classes/interfaces/helper/class_HelpableLogin.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * diff --git a/inc/classes/interfaces/helper/class_HelpableTemplate.php b/inc/classes/interfaces/helper/class_HelpableTemplate.php new file mode 100644 index 000000000..d0a10f5f5 --- /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/class_Streamable.php b/inc/classes/interfaces/io/class_Streamable.php index 2d839a64c..975fbb374 100644 --- a/inc/classes/interfaces/io/class_Streamable.php +++ b/inc/classes/interfaces/io/class_Streamable.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -19,7 +19,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program. If not, see . */ interface Streamable extends FrameworkInterface { } diff --git a/inc/classes/interfaces/io/file/class_FileInputStreamer.php b/inc/classes/interfaces/io/file/class_FileInputStreamer.php index 5dc756b69..ddd441696 100644 --- a/inc/classes/interfaces/io/file/class_FileInputStreamer.php +++ b/inc/classes/interfaces/io/file/class_FileInputStreamer.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -19,18 +19,14 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * 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 + * @param $fqfn The file's FQFN we shall load * @return $array An array containing all read lines - * @throws NullPointerException If an instance is null - * @throws NoObjectException If the instance is not an object - * instance - * @throws MissingMethodException If a required method is missing. * @throws InvalidArrayCountException If an array has not the * expected size * @throws InvalidMD5ChecksumException If two MD5 hashes did not match diff --git a/inc/classes/interfaces/io/file/class_FileOutputStreamer.php b/inc/classes/interfaces/io/file/class_FileOutputStreamer.php index 2862c544f..20fa404e7 100644 --- a/inc/classes/interfaces/io/file/class_FileOutputStreamer.php +++ b/inc/classes/interfaces/io/file/class_FileOutputStreamer.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -19,21 +19,17 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * 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 + * @param $fileName The local file's name including full path + * @param $dataArray Array containing the compressor's extension * and streamed data * @return void - * @throws NullPointerException If an instance is null - * @throws NoObjectException If the instance is not an object - * instance - * @throws MissingMethodException If a required method is missing. */ function saveFile ($fileName, $dataArray); } diff --git a/inc/classes/interfaces/io/output/class_OutputStreamer.php b/inc/classes/interfaces/io/output/class_OutputStreamer.php index 8dff6817d..4d8221fc2 100644 --- a/inc/classes/interfaces/io/output/class_OutputStreamer.php +++ b/inc/classes/interfaces/io/output/class_OutputStreamer.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -19,7 +19,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program. If not, see . */ interface OutputStreamer extends Streamable { /** diff --git a/inc/classes/interfaces/language/class_ManageableLanguage.php b/inc/classes/interfaces/language/class_ManageableLanguage.php index 4d4dfac3e..7bae5901a 100644 --- a/inc/classes/interfaces/language/class_ManageableLanguage.php +++ b/inc/classes/interfaces/language/class_ManageableLanguage.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -19,7 +19,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program. If not, see . */ interface ManageableLanguage extends FrameworkInterface { /** diff --git a/inc/classes/interfaces/login/class_LoginableUser.php b/inc/classes/interfaces/login/class_LoginableUser.php index 107b13387..9bb89ca6b 100644 --- a/inc/classes/interfaces/login/class_LoginableUser.php +++ b/inc/classes/interfaces/login/class_LoginableUser.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * diff --git a/inc/classes/interfaces/mailer/.htaccess b/inc/classes/interfaces/mailer/.htaccess new file mode 100644 index 000000000..3a4288278 --- /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 000000000..7e042044f --- /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/class_ReadableNews.php b/inc/classes/interfaces/reader/class_ReadableNews.php index c38b70200..3c54d42eb 100644 --- a/inc/classes/interfaces/reader/class_ReadableNews.php +++ b/inc/classes/interfaces/reader/class_ReadableNews.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * diff --git a/inc/classes/interfaces/registration/class_UserRegister.php b/inc/classes/interfaces/registration/class_UserRegister.php index 89a6fb220..aa29b1acb 100644 --- a/inc/classes/interfaces/registration/class_UserRegister.php +++ b/inc/classes/interfaces/registration/class_UserRegister.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * diff --git a/inc/classes/interfaces/registry/class_Register.php b/inc/classes/interfaces/registry/class_Register.php index d25fbab5d..37da87618 100644 --- a/inc/classes/interfaces/registry/class_Register.php +++ b/inc/classes/interfaces/registry/class_Register.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * diff --git a/inc/classes/interfaces/registry/class_Registerable.php b/inc/classes/interfaces/registry/class_Registerable.php index 7be47dbc4..16ed10e2b 100644 --- a/inc/classes/interfaces/registry/class_Registerable.php +++ b/inc/classes/interfaces/registry/class_Registerable.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * diff --git a/inc/classes/interfaces/request/class_Requestable.php b/inc/classes/interfaces/request/class_Requestable.php index 1c3d09250..5be733c81 100644 --- a/inc/classes/interfaces/request/class_Requestable.php +++ b/inc/classes/interfaces/request/class_Requestable.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * diff --git a/inc/classes/interfaces/resolver/actions/.htaccess b/inc/classes/interfaces/resolver/actions/.htaccess new file mode 100644 index 000000000..3a4288278 --- /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 000000000..956d2b8cc --- /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 the 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 000000000..376d86274 --- /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 000000000..3a4288278 --- /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 000000000..dd2ff0641 --- /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 the 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 000000000..3a4288278 --- /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 000000000..5d2786b65 --- /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/class_Responseable.php b/inc/classes/interfaces/response/class_Responseable.php index a1fabde81..bb798fe6c 100644 --- a/inc/classes/interfaces/response/class_Responseable.php +++ b/inc/classes/interfaces/response/class_Responseable.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -50,7 +50,7 @@ interface Responseable extends FrameworkInterface { /** * Flushs the cached HTTP response to the outer world * - * @param $foce Wether we shall force the output or abort if headers are + * @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 @@ -95,6 +95,14 @@ interface Responseable extends FrameworkInterface { * @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/class_SearchableResult.php b/inc/classes/interfaces/result/class_SearchableResult.php index 595e5c426..c2c78239e 100644 --- a/inc/classes/interfaces/result/class_SearchableResult.php +++ b/inc/classes/interfaces/result/class_SearchableResult.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * diff --git a/inc/classes/interfaces/result/class_UpdateableResult.php b/inc/classes/interfaces/result/class_UpdateableResult.php new file mode 100644 index 000000000..42542ed23 --- /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/class_CompileableTemplate.php b/inc/classes/interfaces/template/class_CompileableTemplate.php index c0ec28b7d..46ffe7750 100644 --- a/inc/classes/interfaces/template/class_CompileableTemplate.php +++ b/inc/classes/interfaces/template/class_CompileableTemplate.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -19,32 +19,23 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * 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 + * @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); - /** - * Assign a configuration variables for templates - * - * @param $var The configuration "variable" we want to assign - * @param $value The value we want to store in the variable - * @return void - */ - function assignConfigVariable ($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 + * @param $template The web template we shall load which is located in + * "html" by default * @return void */ function loadWebTemplate ($template); @@ -53,7 +44,7 @@ interface CompileableTemplate extends FrameworkInterface { * 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 + * @param $template The code template we shall load which is * located in "html" by default * @return void */ @@ -62,7 +53,7 @@ interface CompileableTemplate extends FrameworkInterface { /** * Load a specified email template into the engine * - * @param $template The email template we shall load which is + * @param $template The email template we shall load which is * located in "emails" by default * @return void */ diff --git a/inc/classes/interfaces/template/view/class_ViewHelper.php b/inc/classes/interfaces/template/view/class_ViewHelper.php index 230d04ebc..78e0cf809 100644 --- a/inc/classes/interfaces/template/view/class_ViewHelper.php +++ b/inc/classes/interfaces/template/view/class_ViewHelper.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -19,7 +19,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program. If not, see . */ interface ViewHelper extends FrameworkInterface { /** diff --git a/inc/classes/interfaces/user/class_ManageableAccount.php b/inc/classes/interfaces/user/class_ManageableAccount.php new file mode 100644 index 000000000..3e8885389 --- /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 the 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 + */ + 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 000000000..3a4288278 --- /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 000000000..be9071252 --- /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 000000000..db33c6306 --- /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/actions/class_ b/inc/classes/main/actions/class_ index 93d4fc521..a34ccda26 100644 --- a/inc/classes/main/actions/class_ +++ b/inc/classes/main/actions/class_ @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -19,7 +19,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program. If not, see . */ class ???Action extends BaseAction implements Commandable { /** @@ -30,12 +30,6 @@ class ???Action extends BaseAction implements Commandable { protected function __construct () { // Call parent constructor parent::__construct(__CLASS__); - - // Set description - $this->setObjectDescription(""); - - // Generate unique key - $this->generateUniqueId(); } /** diff --git a/inc/classes/main/actions/class_BaseAction.php b/inc/classes/main/actions/class_BaseAction.php index 15ba51ef0..0b2cd8186 100644 --- a/inc/classes/main/actions/class_BaseAction.php +++ b/inc/classes/main/actions/class_BaseAction.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -19,7 +19,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program. If not, see . */ class BaseAction extends BaseFrameworkSystem { /** diff --git a/inc/classes/main/actions/post_registration/class_LoginAfterRegistrationAction.php b/inc/classes/main/actions/post_registration/class_LoginAfterRegistrationAction.php index c5f1e8a02..068090ed3 100644 --- a/inc/classes/main/actions/post_registration/class_LoginAfterRegistrationAction.php +++ b/inc/classes/main/actions/post_registration/class_LoginAfterRegistrationAction.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -19,9 +19,9 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program. If not, see . */ -class LoginAfterRegistrationAction extends BaseAction implements Commandable { +class LoginAfterRegistrationAction extends BaseAction implements PerformableAction { /** * Protected constructor * @@ -30,12 +30,6 @@ class LoginAfterRegistrationAction extends BaseAction implements Commandable { protected function __construct () { // Call parent constructor parent::__construct(__CLASS__); - - // Set description - $this->setObjectDescription("Post registration action for logging in"); - - // Generate unique key - $this->generateUniqueId(); } /** diff --git a/inc/classes/main/actions/web/.htaccess b/inc/classes/main/actions/web/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/inc/classes/main/actions/web/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/actions/web/class_WebLoginLogoutAction.php b/inc/classes/main/actions/web/class_WebLoginLogoutAction.php new file mode 100644 index 000000000..bf6554517 --- /dev/null +++ b/inc/classes/main/actions/web/class_WebLoginLogoutAction.php @@ -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 WebLoginLogoutAction extends BaseAction implements Commandable, Registerable { + /** + * 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 createWebLoginLogoutAction () { + // Get a new instance + $actionInstance = new WebLoginLogoutAction(); + + // 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) { + // Shall we logout or display logout page or logout immediately? + if (($this->getConfigInstance()->readConfig('logout_immediate') === "Y") || ($requestInstance->isRequestElementSet('logout'))) { + // 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'); + } // END - if + } + + /** + * 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/actions/web/class_WebLoginProfileAction.php b/inc/classes/main/actions/web/class_WebLoginProfileAction.php new file mode 100644 index 000000000..3ed47c0a8 --- /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_class')); + } +} + +// [EOF] +?> diff --git a/inc/classes/main/auth/class_CookieAuth.php b/inc/classes/main/auth/class_CookieAuth.php index 6b1bf3f06..6ef55044a 100644 --- a/inc/classes/main/auth/class_CookieAuth.php +++ b/inc/classes/main/auth/class_CookieAuth.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -19,7 +19,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program. If not, see . */ class CookieAuth extends BaseFrameworkSystem implements Authorizeable, Registerable { /** @@ -31,12 +31,6 @@ class CookieAuth extends BaseFrameworkSystem implements Authorizeable, Registera // Call parent constructor parent::__construct(__CLASS__); - // Set part description - $this->setObjectDescription("Cookie-based login"); - - // Create unique ID number - $this->generateUniqueId(); - // Clean up a little $this->removeNumberFormaters(); $this->removeSystemArray(); @@ -115,6 +109,17 @@ class CookieAuth extends BaseFrameworkSystem implements Authorizeable, Registera $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/class_MemoryCache.php b/inc/classes/main/cache/class_MemoryCache.php index 4cb7459b6..840519d37 100644 --- a/inc/classes/main/cache/class_MemoryCache.php +++ b/inc/classes/main/cache/class_MemoryCache.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -19,7 +19,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program. If not, see . */ class MemoryCache extends BaseFrameworkSystem implements Cacheable { /** @@ -36,12 +36,6 @@ class MemoryCache extends BaseFrameworkSystem implements Cacheable { // Call parent constructor parent::__construct(__CLASS__); - // Set part description - $this->setObjectDescription("Memory cache"); - - // Create unique ID number - $this->generateUniqueId(); - // Clean up a little $this->removeNumberFormaters(); $this->removeSystemArray(); @@ -70,7 +64,7 @@ class MemoryCache extends BaseFrameworkSystem implements Cacheable { */ protected function initCache () { // Now create the "data cache" - $this->dataCache = new FrameworkArrayObject("FakedDataCache"); + $this->dataCache = new FrameworkArrayObject('FakedDataCache'); } /** @@ -101,7 +95,7 @@ class MemoryCache extends BaseFrameworkSystem implements Cacheable { * @param $offset The offset we shall set * @return $data Data to store in the cache */ - public final function offsetget ($offset) { + public final function offsetGet ($offset) { // Default is offset not found $data = null; diff --git a/inc/classes/main/class_ b/inc/classes/main/class_ index 6a6ff22da..df2200461 100644 --- a/inc/classes/main/class_ +++ b/inc/classes/main/class_ @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -19,7 +19,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program. If not, see . */ class extends BaseFrameworkSystem { /** @@ -31,12 +31,6 @@ class extends BaseFrameworkSystem { // Call parent constructor parent::__construct(__CLASS__); - // Set part description - $this->setObjectDescription(""); - - // Create unique ID number - $this->generateUniqueId(); - // Clean up a little $this->removeNumberFormaters(); $this->removeSystemArray(); diff --git a/inc/classes/main/class_Base b/inc/classes/main/class_Base new file mode 100644 index 000000000..9f3eee9f4 --- /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 index 3484a4eb5..9dd62b4f4 100644 --- a/inc/classes/main/class_BaseFrameworkSystem.php +++ b/inc/classes/main/class_BaseFrameworkSystem.php @@ -5,7 +5,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -32,6 +32,12 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { * The language instance for the template loader */ private static $langInstance = null; + + /** + * Debug instance + */ + private static $debugInstance = null; + /** * Instance of a request class */ @@ -43,19 +49,39 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { private $responseInstance = null; /** - * The real class name + * Search criteria instance */ - private $realClass = "FrameworkSystem"; + private $searchInstance = null; /** - * A human-readable description for this simulator part + * The file I/O instance for the template loader */ - private $objectDescription = "Namenlose Framework-Einheit"; + private $fileIoInstance = null; /** - * The unique ID string for identifying all type of classes + * Resolver instance */ - private $uniqueID = ""; + private $resolverInstance = null; + + /** + * Template engine instance + */ + private $templateInstance = null; + + /** + * Database result instance + */ + private $resultInstance = null; + + /** + * Instance for user class + */ + private $userInstance = null; + + /** + * The real class name + */ + private $realClass = "FrameworkSystem"; /** * Thousands seperator @@ -67,11 +93,6 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { */ private $decimals = ","; // German - /** - * The file I/O instance for the template loader - */ - private $fileIoInstance = null; - /*********************** * Exception codes.... * ***********************/ @@ -124,20 +145,24 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { const EXCEPTION_MISSING_LANGUAGE_HANDLER = 0x02e; const EXCEPTION_MISSING_FILE_IO_HANDLER = 0x02f; const EXCEPTION_MISSING_ELEMENT = 0x030; - const EXCEPTION_INVALID_COMMAND = 0x031; - const EXCEPTION_INVALID_CONTROLLER = 0x032; - const EXCEPTION_HEADERS_ALREADY_SENT = 0x033; - const EXCEPTION_DEFAUL_CONTROLLER_GONE = 0x034; - const EXCEPTION_CLASS_NOT_FOUND = 0x035; - const EXCEPTION_REQUIRED_INTERFACE_MISSING = 0x036; + 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 SHOOT YOUR SERVER!!! * - *--------------------------------------------------------------------* + *---------------------------------------------------------------------* + * 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 @@ -160,40 +185,33 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { /** * Private super constructor * + * @param $className Name of the class * @return void */ - protected function __construct ($class) { + protected function __construct ($className) { // Set real class - $this->setRealClass($class); + $this->setRealClass($className); // Initialize the class if the registry is there if ((class_exists('Registry')) && (Registry::isInitialized() === false)) { $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") { - // Debug message - if ((defined('DEBUG_DESTRUCTOR')) && (is_object($this->getDebugInstance()))) { - $this->getDebugInstance()->output(sprintf("[%s:] Das Objekt %s wird zerstört.
\n", - __CLASS__, $this->__toString() - )); - } - + if ($this->__toString() != 'DestructedObject') { // Destroy all informations about this class but keep some text about it alive - $this->setObjectDescription(sprintf("Entferntes Objekt %s", $this->__toString())); - $this->setRealClass("DestructedObject"); - $this->resetUniqueID(); + $this->setRealClass('DestructedObject'); } elseif ((defined('DEBUG_DESTRUCTOR')) && (is_object($this->getDebugInstance()))) { // Already destructed object - $this->getDebugInstance()->output(sprintf("[%s:] Das Objekt %s wurde bereits zerstört.
\n", + $this->debugOutput(sprintf("[%s:] The object %s is already destroyed.", __CLASS__, $this->__toString() )); } @@ -213,48 +231,27 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { } elseif (is_array($args)) { // Some arguments are there foreach ($args as $arg) { - // Check the type - if (is_bool($arg)) { - // Boolean! - if ($arg) $argsString .= "true(bool)"; else $argsString .= "false(bool)"; - } elseif (is_int($arg)) { - // Integer - $argsString .= $arg."(int)"; - } elseif (is_float($arg)) { - // Floating point - $argsString .= $arg."(float)"; - } elseif ($arg instanceof BaseFrameworkSystem) { - // Own object instance - $argsString .= $arg->__toString()."(Object)"; - } elseif (is_object($arg)) { - // External object - $argsString .= "unknown object(!)"; - } elseif (is_array($arg)) { - // Array - $argsString .= "Array(array)"; - } elseif (is_string($arg)) { - // String - $argsString .= "\"".$arg."\"(string)"; - } elseif (is_null($arg)) { - // Null - $argsString .= "(null)"; - } else { - // Unknown type (please report!) - $argsString .= $arg."(unknown!)"; - } - - // Add comma - $argsString .= ", "; - } + // 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); + if (substr($argsString, -2, 1) === ",") { + $argsString = substr($argsString, 0, -2); + } // END - if } else { // Invalid arguments! $argsString = sprintf("!INVALID:%s!", $args); } - $this->getDebugInstance()->output(sprintf("[%s::%s] Stub! Args: %s", + // Output stub message + $this->debugOutput(sprintf("[%s->%s] Stub! Args: %s", $this->__toString(), $methodName, $argsString @@ -289,13 +286,90 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { ))); // Initialization done! :D - Registry::isInitialized("OK"); - } elseif ($this->__toString() == "DebugMiddleware") { + Registry::isInitialized('OK'); + } elseif ($this->__toString() == 'DebugMiddleware') { // Set configuration instance $this->setConfigInstance(FrameworkConfiguration::createFrameworkConfiguration()); } } + /** + * 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 * @@ -310,29 +384,30 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { /** * Getter for configuration instance * - * @return $cfhInstance - Configuration instance + * @return $cfgInstance Configuration instance */ - protected final function getConfigInstance () { - return Registry::getRegistry()->getInstance('config'); + public final function getConfigInstance () { + $cfgInstance = Registry::getRegistry()->getInstance('config'); + return $cfgInstance; } /** * Setter for debug instance * - * @param $debugInstance The instance for debug output class + * @param $debugInstance The instance for debug output class * @return void */ public final function setDebugInstance (DebugMiddleware $debugInstance) { - Registry::getRegistry()->addInstance('debug', $debugInstance); + self::$debugInstance = $debugInstance; } /** * Getter for debug instance * - * @return $debug - Instance to class DebugConsoleOutput or DebugWebOutput + * @return $debugInstance Instance to class DebugConsoleOutput or DebugWebOutput */ public final function getDebugInstance () { - return Registry::getRegistry()->getInstance('debug'); + return self::$debugInstance; } /** @@ -371,11 +446,16 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { * @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)) { - return Registry::getRegistry()->getInstance('dbInstance'); - } else { - return null; - } + $dbInstance = Registry::getRegistry()->getInstance('dbInstance'); + } // END - if + + // Return instance + return $dbInstance; } /** @@ -477,176 +557,16 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { $this->realClass = $realClass; } - /** - * Generate unique ID from a lot entropy - * - * @return void - */ - public final function generateUniqueId () { - // Is the id set for this class? - if (empty($this->uniqueID)) { - - // Correct missing class name - $corrected = false; - if ($this->__toString() == "") { - $this->setRealClass(__CLASS__); - $corrected = true; - } - - // Cache datbase instance - $db = $this->getDatabaseInstance(); - - // Generate new id - $tempID = false; - while (true) { - // Generate a unique ID number - $tempID = $this->generateIdNumber(); - $isUsed = false; - - // Try to figure out if the ID number is not yet used - try { - // Is this a registry? - if ($this->__toString() == "Registry") { - // Registry, then abort here - break; - } elseif (is_object($db)) { - $isUsed = $db->isUniqueIdUsed($tempID, true); - } - } catch (FrameworkException $e) { - // Catches all and ignores all ;-) - } - - if ( - ( - $tempID !== false - ) && ( - ( - $db === null - ) || ( - ( - is_object($db) - ) && ( - !$isUsed - ) - ) - ) - ) { - // Abort the loop - break; - } - } // END - while - - // Apply the new ID - $this->setUniqueID($tempID); - - // Revert maybe corrected class name - if ($corrected) { - $this->setRealClass(""); - } - - // Remove system classes if we are in a system class - if ((isset($this->systemClasses)) && (in_array($this->__toString(), $this->systemClasses))) { - // This may save some RAM... - $this->removeSystemArray(); - } - } - } - - /** - * Generates a new ID number for classes based from the class' real name, - * the description and some random data - * - * @return $tempID The new (temporary) ID number - */ - private final function generateIdNumber () { - return sprintf("%s@%s", - $this->__toString(), - md5(sprintf("%s:%s:%s:%s:%s:%s", - $this->__toString(), - $this->getObjectDescription(), - time(), - getenv('REMOTE_ADDR'), - getenv('SERVER_ADDR'), - mt_rand() - )) - ); - } - - /** - * Setter for unique ID - * - * @param $uniqueID The newly generated unique ID number - * @return void - */ - private final function setUniqueID ($uniqueID) { - // Cast to string - $uniqueID = (string) $uniqueID; - - // Set the ID number - $this->uniqueID = $uniqueID; - } - - /** - * Getter for unique ID - * - * @return $uniqueID The unique ID of this class - */ - public final function getUniqueID () { - return $this->uniqueID; - } - - /** - * Resets or recreates the unique ID number - * - * @return void - */ - public final function resetUniqueID() { - // Sweet and simple... ;-) - $newUniqueID = $this->generateIdNumber(); - $this->setUniqueID($newUniqueID); - } - - /** - * Getter for simulator description - * - * @return $objectDescription The description of this simulation part - */ - public final function getObjectDescription () { - if (isset($this->objectDescription)) { - return $this->objectDescription; - } else { - return null; - } - } - - /** - * Setter for simulation part description - * - * @param $objectDescription The description as string for this simulation part - * @return void - */ - public final function setObjectDescription ($objectDescription) { - $this->objectDescription = (String) $objectDescription; - } - - /** - * Validate if given object is the same as current - * - * @param $object An object instance for comparison with this class - * @return boolean The result of comparing both's unique ID - */ - public final function equals ($object) { - return ($this->getUniqueID() == $object->getUniqueID()); - } - /** * Compare if both simulation part description and class name matches - * (shall be enougth) + * (shall be enough) * - * @param $itemInstance An object instance to an other class - * @return boolean The result of comparing class name simulation part description + * @param $itemInstance An object instance to an other class + * @return boolean The result of comparing class name simulation part description + * @deprecated */ public function itemMatches ($itemInstance) { + $this->partialStub("Deprecated!"); return ( ( $this->__toString() == $itemInstance->__toString() @@ -659,11 +579,11 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { /** * Compare class name of this and given class name * - * @param $class The class name as string from the other class + * @param $className The class name as string from the other class * @return boolean The result of comparing both class names */ - public final function isClass ($class) { - return ($this->__toString() == $class); + public final function isClass ($className) { + return ($this->__toString() == $className); } /** @@ -756,40 +676,6 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { unset($this->systemClasses); } - /** - * Create a file name and path name from the object's unique ID number. - * The left part of the ID shall always be a valid class name and the - * right part an ID number. - * - * @return $pfn The file name with a prepended path name - * @throws NoArrayCreatedException If explode() fails to create an array - * @throws InvalidArrayCountException If the array contains less or - * more than two elements - */ - public final function getPathFileNameFromObject () { - // Get the main object's unique ID. We use this as a path/filename combination - $pathFile = $this->getUniqueID(); - - // Split it up in path and file name - $pathFile = explode("@", $pathFile); - - // Are there two elements? Index 0 is the path, 1 the file name + global extension - if (!is_array($pathFile)) { - // No array found - throw new NoArrayCreatedException(array($this, "pathFile"), self::EXCEPTION_ARRAY_EXPECTED); - } elseif (count($pathFile) != 2) { - // Invalid ID returned! - throw new InvalidArrayCountException(array($this, "pathFile", count($pathFile), 2), self::EXCEPTION_ARRAY_HAS_INVALID_COUNT); - } - - // Auto-append missing trailing slash - $pathFile[0] = $this->addMissingTrailingSlash($pathFile[0]); - - // Create the file name and return it - $pfn = ($pathFile[0] . $pathFile[1]); - return $pfn; - } - /** * Appends a trailing slash to a string * @@ -822,22 +708,22 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { } /** - * Prepare the template engine (TemplateEngine by default) for a given + * 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 $tplEngine The template engine instance + * @return $templateInstance The template engine instance * @throws NullPointerException If the template engine could not * be initialized - * @throws UnsupportedTemplateEngineException If $tplEngine is an + * @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 prepareTemplateEngine (BaseFrameworkSystem $appInstance=null) { + protected function prepareTemplateInstance (BaseFrameworkSystem $appInstance=null) { // Is the application instance set? if (is_null($appInstance)) { // Get the current instance @@ -847,8 +733,8 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { 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/%s", @@ -868,10 +754,10 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { } // Initialize the template engine - $tplEngine = ObjectFactory::createObjectByConfiguredName('template_class', array($fqfn, $appInstance->getLanguageInstance(), $appInstance->getFileIoInstance())); + $templateInstance = ObjectFactory::createObjectByConfiguredName('template_class', array($fqfn, $appInstance->getLanguageInstance(), $appInstance->getFileIoInstance())); // Return the prepared instance - return $tplEngine; + return $templateInstance; } /** @@ -880,13 +766,24 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { * @return void */ public final function debugInstance () { + // Restore the error handler to avoid trouble with missing array elements or undeclared variables + restore_error_handler(); + // Generate the output $content = sprintf("
%s
", - trim(print_r($this, true)) + trim( + htmlentities( + print_r($this, true) + ) + ) ); // Output it - ApplicationEntryPoint::app_die(sprintf("%s debug output:%s", $this->__toString(), $content)); + ApplicationEntryPoint::app_die(sprintf("%s debug output:
%s
\nLoaded includes:
%s
", + $this->__toString(), + $content, + ClassLoader::getInstance()->getPrintableIncludeList() + )); } /** @@ -900,10 +797,10 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { $backtrace = debug_backtrace(); // Generate the class::method string - $methodName = "UnknownClass::unknownMethod"; + $methodName = "UnknownClass->unknownMethod"; if ((isset($backtrace[1]['class'])) && (isset($backtrace[1]['function']))) { - $methodName = $backtrace[1]['class']."::".$backtrace[1]['function']; - } + $methodName = $backtrace[1]['class']."->".$backtrace[1]['function']; + } // END - if // Construct the full message $stubMessage = sprintf("[%s:] Partial stub!", @@ -913,19 +810,59 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { // Is the extra message given? if (!empty($message)) { // Then add it as well - $stubMessage .= sprintf(" Message: %s", $message); - } + $stubMessage .= sprintf(" Message: %s", $message); + } // END - if // Debug instance is there? if (!is_null($this->getDebugInstance())) { // Output stub message - $this->getDebugInstance()->output($stubMessage); + $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) 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 * @@ -950,16 +887,169 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { } /** - * Outputs a debug backtrace and stops further script execution + * 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()) { + 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 */ - public function debugBacktrace () { - // Sorry, there is no other way getting this nice backtrace - print "
\n";
-		debug_print_backtrace();
-		print "
"; - exit; + 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; } } diff --git a/inc/classes/main/class_FrameworkArrayObject.php b/inc/classes/main/class_FrameworkArrayObject.php index f1daed4b3..e7becaee4 100644 --- a/inc/classes/main/class_FrameworkArrayObject.php +++ b/inc/classes/main/class_FrameworkArrayObject.php @@ -6,7 +6,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -21,7 +21,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program. If not, see . */ class FrameworkArrayObject extends ArrayObject { /** diff --git a/inc/classes/main/commands/class_ b/inc/classes/main/commands/class_ index 778e7d8bb..cac39ce2b 100644 --- a/inc/classes/main/commands/class_ +++ b/inc/classes/main/commands/class_ @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -30,22 +30,13 @@ class ???Command extends BaseCommand implements Commandable { protected function __construct () { // Call parent constructor parent::__construct(__CLASS__); - - // Set special description - $this->setObjectDescription(""); - - // Create unique ID number - $this->generateUniqueId(); - - // Clean up a little - $this->removeSystemArray(); } /** * Creates an instance of this class * - * @param $resolverInstance An instance of a command resolver class - * @return $commandInstance An instance a prepared command 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 @@ -61,8 +52,8 @@ class ???Command extends BaseCommand implements Commandable { /** * 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 + * @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) { diff --git a/inc/classes/main/commands/class_BaseCommand.php b/inc/classes/main/commands/class_BaseCommand.php index 825b2b052..7a7cc26c8 100644 --- a/inc/classes/main/commands/class_BaseCommand.php +++ b/inc/classes/main/commands/class_BaseCommand.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -27,19 +27,15 @@ class BaseCommand extends BaseFrameworkSystem { */ private $controllerName = ""; - /** - * Resolver instance - */ - private $resolverInstance = null; - /** * Protected constructor * + * @param $className Name of the class * @return void */ - protected function __construct ($class) { + protected function __construct ($className) { // Call parent constructor - parent::__construct($class); + parent::__construct($className); } /** @@ -60,25 +56,6 @@ class BaseCommand extends BaseFrameworkSystem { public final function getControllerName () { return $this->controllerName; } - - /** - * Setter for resolver instance - * - * @param $resolverInstance Instance of a command resolver class - * @return void - */ - public final function setResolverInstance (CommandResolver $resolverInstance) { - $this->resolverInstance = $resolverInstance; - } - - /** - * Getter for resolver instance - * - * @return $resolverInstance Instance of a command resolver class - */ - public final function getResolverInstance () { - return $this->resolverInstance; - } } // [EOF] diff --git a/inc/classes/main/commands/image/.htaccess b/inc/classes/main/commands/image/.htaccess new file mode 100644 index 000000000..3a4288278 --- /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 000000000..8c6794d3d --- /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/class_WebConfirmCommand.php b/inc/classes/main/commands/web/class_WebConfirmCommand.php new file mode 100644 index 000000000..db15067cc --- /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 the 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 index cdfd7161a..d34e16f32 100644 --- a/inc/classes/main/commands/web/class_WebDoFormCommand.php +++ b/inc/classes/main/commands/web/class_WebDoFormCommand.php @@ -1,10 +1,10 @@ * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -30,22 +30,13 @@ class WebDoFormCommand extends BaseCommand implements Commandable { protected function __construct () { // Call parent constructor parent::__construct(__CLASS__); - - // Set special description - $this->setObjectDescription("Command for handling forms on a centralized place"); - - // Create unique ID number - $this->generateUniqueId(); - - // Clean up a little - $this->removeSystemArray(); } /** * Creates an instance of this class * - * @param $resolverInstance An instance of a command resolver class - * @return $commandInstance An instance a prepared command 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 @@ -61,16 +52,26 @@ class WebDoFormCommand extends BaseCommand implements Commandable { /** * 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 + * @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... - echo "This should never be executed!
";
-		debug_print_backtrace();
-		die("
Good bye..."); + $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 index 3cc3592cf..14a7a9c6f 100644 --- a/inc/classes/main/commands/web/class_WebHomeCommand.php +++ b/inc/classes/main/commands/web/class_WebHomeCommand.php @@ -1,10 +1,10 @@ * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -30,22 +30,13 @@ class WebHomeCommand extends BaseCommand implements Commandable { protected function __construct () { // Call parent constructor parent::__construct(__CLASS__); - - // Set special description - $this->setObjectDescription("Command for the "home" page"); - - // Create unique ID number - $this->generateUniqueId(); - - // Clean up a little - $this->removeSystemArray(); } /** * Creates an instance of this class * - * @param $resolverInstance An instance of a command resolver class - * @return $commandInstance An instance a prepared command 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 @@ -61,8 +52,8 @@ class WebHomeCommand extends BaseCommand implements Commandable { /** * 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 + * @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) { @@ -70,38 +61,39 @@ class WebHomeCommand extends BaseCommand implements Commandable { $appInstance = $this->getResolverInstance()->getApplicationInstance(); // Prepare a template instance - $templateInstance = $this->prepareTemplateEngine($appInstance); + $templateInstance = $this->prepareTemplateInstance($appInstance); + + // Transfer application data + $templateInstance->assignApplicationData($appInstance); // Load the master template $masterTemplate = $appInstance->getMasterTemplate(); // Load header template - $templateInstance->loadCodeTemplate("header"); + $templateInstance->loadCodeTemplate('header'); // Compile and assign it with a variable $templateInstance->compileTemplate(); - $templateInstance->assignTemplateWithVariable("header", "header"); + $templateInstance->assignTemplateWithVariable('header', 'header'); // Load footer template - $templateInstance->loadCodeTemplate("footer"); + $templateInstance->loadCodeTemplate('footer'); // Compile and assign it with a variable $templateInstance->compileTemplate(); - $templateInstance->assignTemplateWithVariable("footer", "footer"); + $templateInstance->assignTemplateWithVariable('footer', 'footer'); // Load the home template - $templateInstance->loadCodeTemplate("home"); + $templateInstance->loadCodeTemplate('home'); // Assign the home template with the master template as a content ... ;) - $templateInstance->assignTemplateWithVariable("home", "content"); + $templateInstance->assignTemplateWithVariable('home', 'content'); // Load the master template $templateInstance->loadCodeTemplate($masterTemplate); // Set title - $title = ucfirst($requestInstance->getRequestElement("page")); - if (empty($title)) $title = "Home"; - $templateInstance->assignVariable('title', $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 @@ -111,6 +103,17 @@ class WebHomeCommand extends BaseCommand implements Commandable { // Get the content back from the template engine and put it in the 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 index d5f45ec59..9f2c1cfa3 100644 --- a/inc/classes/main/commands/web/class_WebLoginAreaCommand.php +++ b/inc/classes/main/commands/web/class_WebLoginAreaCommand.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -22,6 +22,11 @@ * along with this program. If not, see . */ class WebLoginAreaCommand extends BaseCommand implements Commandable { + /** + * Name of the action + */ + private $actionName = ""; + /** * Protected constructor * @@ -30,22 +35,13 @@ class WebLoginAreaCommand extends BaseCommand implements Commandable { protected function __construct () { // Call parent constructor parent::__construct(__CLASS__); - - // Set special description - $this->setObjectDescription("Command for the "home" page"); - - // Create unique ID number - $this->generateUniqueId(); - - // Clean up a little - $this->removeSystemArray(); } /** * Creates an instance of this class * - * @param $resolverInstance An instance of a command resolver class - * @return $commandInstance An instance a prepared command 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 @@ -54,66 +50,87 @@ class WebLoginAreaCommand extends BaseCommand implements Commandable { // 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 + * @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) { - // Default action is the one from configuration - $action = sprintf("login_%s", $this->getConfigInstance()->readConfig('login_default_action')); + // 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->prepareTemplateEngine($appInstance); + $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"); + $templateInstance->loadCodeTemplate('header'); // Compile and assign it with a variable $templateInstance->compileTemplate(); - $templateInstance->assignTemplateWithVariable("header", "header"); + $templateInstance->assignTemplateWithVariable('header', 'header'); // Load footer template - $templateInstance->loadCodeTemplate("footer"); + $templateInstance->loadCodeTemplate('footer'); // Compile and assign it with a variable $templateInstance->compileTemplate(); - $templateInstance->assignTemplateWithVariable("footer", "footer"); - - // Get "action" from request - $actReq = $requestInstance->getRequestElement("action"); - - // Do we have a "action" parameter set? - if (is_string($actReq)) { - // Then use it with prefix - $action = sprintf("login_%s", $actReq); - } // END - if - - // TODO Do the action somewhere here + $templateInstance->assignTemplateWithVariable('footer', 'footer'); // Load the matching template - $templateInstance->loadCodeTemplate($action); + $templateInstance->loadCodeTemplate('action_' . $this->actionName); // Assign the template with the master template as a content ... ;) - $templateInstance->assignTemplateWithVariable($action, "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('login_{$action}_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 @@ -123,6 +140,50 @@ class WebLoginAreaCommand extends BaseCommand implements Commandable { // Get the content back from the template engine and put it in the 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) { + // Default is no action + $actionInstance = null; + + // Default action is the one from configuration + $this->actionName = sprintf("login_%s", $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("login_%s", $actReq); + } // END - if + + // Get application instance + $applicationInstance = $this->getResolverInstance()->getApplicationInstance(); + + // Try to get an action resolver for the given action + try { + // 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); + } catch (InvalidActionException $e) { + // Silently ignored because no special action was found + } + } } // [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 000000000..e02e2b5b8 --- /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 the 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 000000000..998113348 --- /dev/null +++ b/inc/classes/main/commands/web/class_WebLoginFailedCommand.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 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); + + // 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 the 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_WebLogoutDoneCommand.php b/inc/classes/main/commands/web/class_WebLogoutDoneCommand.php new file mode 100644 index 000000000..15ecb7068 --- /dev/null +++ b/inc/classes/main/commands/web/class_WebLogoutDoneCommand.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 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); + + // 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 the 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 index df5049998..42f9379bb 100644 --- a/inc/classes/main/commands/web/class_WebRegisterCommand.php +++ b/inc/classes/main/commands/web/class_WebRegisterCommand.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -21,7 +21,7 @@ * 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 { +class WebRegisterCommand extends BaseCommand implements Commandable, Registerable { /** * Protected constructor * @@ -30,22 +30,13 @@ class WebRegisterCommand extends BaseCommand implements Commandable { protected function __construct () { // Call parent constructor parent::__construct(__CLASS__); - - // Set special description - $this->setObjectDescription("Command for the registration form"); - - // Create unique ID number - $this->generateUniqueId(); - - // Clean up a little - $this->removeSystemArray(); } /** * Creates an instance of this class * - * @param $resolverInstance An instance of a command resolver class - * @return $commandInstance An instance a prepared command 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 @@ -61,51 +52,55 @@ class WebRegisterCommand extends BaseCommand implements Commandable { /** * 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 + * @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->prepareTemplateEngine($appInstance); + $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"); + $templateInstance->loadCodeTemplate('header'); // Compile and assign it with a variable $templateInstance->compileTemplate(); - $templateInstance->assignTemplateWithVariable("header", "header"); + $templateInstance->assignTemplateWithVariable('header', 'header'); // Load footer template - $templateInstance->loadCodeTemplate("footer"); + $templateInstance->loadCodeTemplate('footer'); // Compile and assign it with a variable $templateInstance->compileTemplate(); - $templateInstance->assignTemplateWithVariable("footer", "footer"); + $templateInstance->assignTemplateWithVariable('footer', 'footer'); // Load the register template - $templateInstance->loadCodeTemplate("register"); + $templateInstance->loadCodeTemplate('register_form'); // Assign the register template with the master template as a content ... ;) $templateInstance->compileTemplate(); - $templateInstance->assignTemplateWithVariable("register", "content"); + $templateInstance->assignTemplateWithVariable('register_form', 'content'); // Load the master template $templateInstance->loadCodeTemplate($masterTemplate); // Set title - $title = ucfirst($requestInstance->getRequestElement("page")); - if (empty($title)) $title = "Register"; - $templateInstance->assignVariable('title', $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 @@ -115,6 +110,17 @@ class WebRegisterCommand extends BaseCommand implements Commandable { // Get the content back from the template engine and put it in the 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 000000000..c6ba2a6c8 --- /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_class')); + } +} + +// [EOF] +?> diff --git a/inc/classes/main/compressor/class_Bzip2Compressor.php b/inc/classes/main/compressor/class_Bzip2Compressor.php index a810a79c4..50a4bad21 100644 --- a/inc/classes/main/compressor/class_Bzip2Compressor.php +++ b/inc/classes/main/compressor/class_Bzip2Compressor.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -30,12 +30,6 @@ class Bzip2Compressor extends BaseFrameworkSystem implements Compressor { protected function __construct () { // Call parent constructor! parent::__construct(__CLASS__); - - // Set description - $this->setObjectDescription("BZIP2 compressor"); - - // Create an unique ID - $this->generateUniqueId(); } /** diff --git a/inc/classes/main/compressor/class_GzipCompressor.php b/inc/classes/main/compressor/class_GzipCompressor.php index 9a4489b19..b4a30253b 100644 --- a/inc/classes/main/compressor/class_GzipCompressor.php +++ b/inc/classes/main/compressor/class_GzipCompressor.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -30,12 +30,6 @@ class GzipCompressor extends BaseFrameworkSystem implements Compressor { protected function __construct () { // Call parent constructor! parent::__construct(__CLASS__); - - // Set description - $this->setObjectDescription("GZIP compressor"); - - // Create an unique ID - $this->generateUniqueId(); } /** diff --git a/inc/classes/main/compressor/class_NullCompressor.php b/inc/classes/main/compressor/class_NullCompressor.php index 38999e189..24128bc3b 100644 --- a/inc/classes/main/compressor/class_NullCompressor.php +++ b/inc/classes/main/compressor/class_NullCompressor.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -30,12 +30,6 @@ class NullCompressor extends BaseFrameworkSystem implements Compressor { protected function __construct () { // Call parent constructor! parent::__construct(__CLASS__); - - // Set description - $this->setObjectDescription("Null compressor"); - - // Create an unique ID - $this->generateUniqueId(); } /** diff --git a/inc/classes/main/console/class_ConsoleTools.php b/inc/classes/main/console/class_ConsoleTools.php index ffd8b8e75..3b49f7216 100644 --- a/inc/classes/main/console/class_ConsoleTools.php +++ b/inc/classes/main/console/class_ConsoleTools.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -30,12 +30,6 @@ class ConsoleTools extends BaseFrameworkSystem { protected function __construct () { // Call parent constructor parent::__construct(__CLASS__); - - // Set description - $this->setObjectDescription("General console tools"); - - // Create an unique ID - $this->generateUniqueId(); } /** @@ -56,7 +50,7 @@ class ConsoleTools extends BaseFrameworkSystem { // Read the file $hostname = trim($io->readFromFile()); - $helper->getDebugInstance()->output(sprintf("[%s:] Our host name is: %s
\n", + $helper->debugOutput(sprintf("[%s:] Our host name is: %s", $helper->__toString(), $hostname )); @@ -71,7 +65,7 @@ class ConsoleTools extends BaseFrameworkSystem { $ip = $ipResolved; // Debug message - $helper->getDebugInstance()->output(sprintf("[%s:] Resolved IP address is: %s
\n", + $helper->debugOutput(sprintf("[%s:] Resolved IP address is: %s\n", $helper->__toString(), $ip )); diff --git a/inc/classes/main/controller/captcha/.htaccess b/inc/classes/main/controller/captcha/.htaccess new file mode 100644 index 000000000..3a4288278 --- /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 000000000..e84fca7a3 --- /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_class')); + + // 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_ index 46459d5d8..a6cea16e3 100644 --- a/inc/classes/main/controller/class_ +++ b/inc/classes/main/controller/class_ @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -21,7 +21,7 @@ * 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 { +class ???Controller extends BaseController implements Controller { /** * Protected constructor * @@ -30,15 +30,44 @@ class Controller extends BaseController implements Controller { 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); - // Set part description - $this->setObjectDescription("Ein spezieller Controller"); + // This request was valid! :-D + $requestInstance->requestIsValid(); - // Create unique ID number - $this->generateUniqueId(); + // Execute the command + $commandInstance->execute($requestInstance, $responseInstance); - // Clean up a little - $this->removeSystemArray(); + // Flush the response out + $responseInstance->flushBuffer(); } } diff --git a/inc/classes/main/controller/class_BaseController.php b/inc/classes/main/controller/class_BaseController.php index 4438cc216..1c4d442f5 100644 --- a/inc/classes/main/controller/class_BaseController.php +++ b/inc/classes/main/controller/class_BaseController.php @@ -6,7 +6,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -23,12 +23,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -class BaseController extends BaseFrameworkSystem { - /** - * Instance of a CommandResolver class - */ - private $resolverInstance = null; - +class BaseController extends BaseFrameworkSystem implements Registerable { /** * Pre filter chain instance */ @@ -42,11 +37,12 @@ class BaseController extends BaseFrameworkSystem { /** * Protected constructor * + * @param $className Name of the class * @return void */ - protected function __construct ($class) { + protected function __construct ($className) { // Call parent constructor - parent::__construct($class); + parent::__construct($className); // Clean up a little $this->removeNumberFormaters(); @@ -55,25 +51,9 @@ class BaseController extends BaseFrameworkSystem { // Initialize both filter chains $this->preFilterChain = ObjectFactory::createObjectByConfiguredName('filter_chain_class'); $this->postFilterChain = ObjectFactory::createObjectByConfiguredName('filter_chain_class'); - } - /** - * Getter for a command resolver instance - * - * @return $resolverInstance An instance of a command resolver class - */ - public final function getResolverInstance () { - return $this->resolverInstance; - } - - /** - * Setter for a command resolver instance - * - * @param $resolverInstance An instance of a command resolver class - * @return void - */ - public final function setResolverInstance (CommandResolver $resolverInstance) { - $this->resolverInstance = $resolverInstance; + // Add this controller to the registry + Registry::getRegistry()->addInstance('controller', $this); } /** diff --git a/inc/classes/main/controller/default/class_WebDefaultController.php b/inc/classes/main/controller/default/class_WebDefaultController.php index ec56fdd9f..7d410ee9f 100644 --- a/inc/classes/main/controller/default/class_WebDefaultController.php +++ b/inc/classes/main/controller/default/class_WebDefaultController.php @@ -30,12 +30,6 @@ class WebWebDefaultController extends BaseController implements Controller { protected function __construct () { // Call parent constructor parent::__construct(__CLASS__); - - // Set part description - $this->setObjectDescription("Default controller for all other requests"); - - // Create unique ID number - $this->generateUniqueId(); } /** diff --git a/inc/classes/main/controller/default/class_WebDefaultNewsController.php b/inc/classes/main/controller/default/class_WebDefaultNewsController.php index fee2d39f0..f4ef9fbc4 100644 --- a/inc/classes/main/controller/default/class_WebDefaultNewsController.php +++ b/inc/classes/main/controller/default/class_WebDefaultNewsController.php @@ -30,12 +30,6 @@ class WebDefaultNewsController extends BaseController implements Controller { protected function __construct () { // Call parent constructor parent::__construct(__CLASS__); - - // Set part description - $this->setObjectDescription("Default controller with news"); - - // Create unique ID number - $this->generateUniqueId(); } /** diff --git a/inc/classes/main/controller/form/class_WebDoFormController.php b/inc/classes/main/controller/form/class_WebDoFormController.php index db7cfb432..e760492fc 100644 --- a/inc/classes/main/controller/form/class_WebDoFormController.php +++ b/inc/classes/main/controller/form/class_WebDoFormController.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -30,12 +30,6 @@ class WebDoFormController extends BaseController implements Controller { protected function __construct () { // Call parent constructor parent::__construct(__CLASS__); - - // Set part description - $this->setObjectDescription("Controller for handling forms"); - - // Create unique ID number - $this->generateUniqueId(); } /** @@ -72,8 +66,17 @@ class WebDoFormController extends BaseController implements Controller { // Get command instance from resolver $commandInstance = $this->getResolverInstance()->resolveCommand($formAction); - // Execute *very* generic pre filters - $this->executePreFilters($requestInstance, $responseInstance); + // 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'); + } // Is the request still valid? Post filters shall only be executed of // the request is valid diff --git a/inc/classes/main/controller/image/.htaccess b/inc/classes/main/controller/image/.htaccess new file mode 100644 index 000000000..3a4288278 --- /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 000000000..689cee43c --- /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/class_WebLoginAreaController.php b/inc/classes/main/controller/login/class_WebLoginAreaController.php index 34893a10f..1a1900c36 100644 --- a/inc/classes/main/controller/login/class_WebLoginAreaController.php +++ b/inc/classes/main/controller/login/class_WebLoginAreaController.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -30,12 +30,6 @@ class WebLoginAreaController extends BaseController implements Controller { protected function __construct () { // Call parent constructor parent::__construct(__CLASS__); - - // Set part description - $this->setObjectDescription("Default controller with news"); - - // Create unique ID number - $this->generateUniqueId(); } /** @@ -51,11 +45,20 @@ class WebLoginAreaController extends BaseController implements Controller { // Set the command resolver $controllerInstance->setResolverInstance($resolverInstance); - // Add some filters to this controller + // User auth filter $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_auth_class')); + + // User update filter + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_update_class')); + + // News fetcher filter $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('news_download_class')); + + // News proccess/display-preparation $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('news_process_class')); + /* @todo: Add some filters to this controller */ + // Return the prepared instance return $controllerInstance; } @@ -68,11 +71,20 @@ class WebLoginAreaController extends BaseController implements Controller { * @return void */ public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) { - // Run the pre filters - $this->executePreFilters($requestInstance, $responseInstance); - // Get the command instance from the resolver by sending a request instance to the resolver - $commandInstance = $this->getResolverInstance()->resolvCommandByRequest($requestInstance); + $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'); + } // This request was valid! :-D $requestInstance->requestIsValid(); diff --git a/inc/classes/main/controller/web/.htaccess b/inc/classes/main/controller/web/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/inc/classes/main/controller/web/.htaccess @@ -0,0 +1 @@ +Deny from all 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 000000000..64c845d01 --- /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_class')); + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_unconfirmed_class')); + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('confirm_code_verifier_class')); + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_status_confirmed_class')); + + // 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 000000000..37cf3d9e7 --- /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 000000000..1f6c0cc28 --- /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_class')); + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('news_process_class')); + + // 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 000000000..f4ce05334 --- /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 000000000..5b39ab0f2 --- /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_WebLogoutDoneController.php b/inc/classes/main/controller/web/class_WebLogoutDoneController.php new file mode 100644 index 000000000..58058b106 --- /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 000000000..c848c4722 --- /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 000000000..843e05cd5 --- /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/class_DataSetCriteria.php b/inc/classes/main/criteria/class_DataSetCriteria.php index 2e76c2f94..34715c52a 100644 --- a/inc/classes/main/criteria/class_DataSetCriteria.php +++ b/inc/classes/main/criteria/class_DataSetCriteria.php @@ -5,7 +5,7 @@ * @see DatabaseFrontendInterface - An interface for database frontends (front-end to the application) * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -38,6 +38,11 @@ class DataSetCriteria extends BaseFrameworkSystem implements StoreableCriteria { */ private $uniqueKey = ""; + /** + * Primary key + */ + private $primaryKey = ""; + /** * Protected constructor * @@ -47,12 +52,6 @@ class DataSetCriteria extends BaseFrameworkSystem implements StoreableCriteria { // Call parent constructor parent::__construct(__CLASS__); - // Set part description - $this->setObjectDescription("Storeable data set for databases"); - - // Create unique ID number - $this->generateUniqueId(); - // Clean up a little $this->removeNumberFormaters(); $this->removeSystemArray(); @@ -61,12 +60,16 @@ class DataSetCriteria extends BaseFrameworkSystem implements StoreableCriteria { /** * Creates an instance of this criteria * - * @return $criteriaInstance An instance of this criteria + * @param $tableName Name of the table + * @return $criteriaInstance An instance of this criteria */ - public final static function createDataSetCriteria () { + public final static function createDataSetCriteria ($tableName) { // Get a new instance $criteriaInstance = new DataSetCriteria(); + // Set table name + $criteriaInstance->setTableName($tableName); + // Return the instance return $criteriaInstance; } @@ -150,6 +153,34 @@ class DataSetCriteria extends BaseFrameworkSystem implements StoreableCriteria { 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 index fc5b1addd..b9f27db7b 100644 --- a/inc/classes/main/criteria/class_SearchCriteria.php +++ b/inc/classes/main/criteria/class_SearchCriteria.php @@ -6,7 +6,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -21,7 +21,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program. If not, see . */ class SearchCriteria extends BaseFrameworkSystem implements LocalSearchCriteria { /** @@ -48,12 +48,6 @@ class SearchCriteria extends BaseFrameworkSystem implements LocalSearchCriteria // Call parent constructor parent::__construct(__CLASS__); - // Set part description - $this->setObjectDescription("Search criteria class"); - - // Create unique ID number - $this->generateUniqueId(); - // Clean up a little $this->removeNumberFormaters(); $this->removeSystemArray(); @@ -109,7 +103,6 @@ class SearchCriteria extends BaseFrameworkSystem implements LocalSearchCriteria /** * Getter for limit * - * @param * @return $limit Search limit */ public final function getLimit () { @@ -129,7 +122,6 @@ class SearchCriteria extends BaseFrameworkSystem implements LocalSearchCriteria /** * Getter for skip * - * @param * @return $skip Search skip */ public final function getSkip () { @@ -183,6 +175,36 @@ class SearchCriteria extends BaseFrameworkSystem implements LocalSearchCriteria // 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 the criteria matches + $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 000000000..af3f6a577 --- /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/class_CryptoHelper.php b/inc/classes/main/crypto/class_CryptoHelper.php index 4ec02ad91..2ebafd8ed 100644 --- a/inc/classes/main/crypto/class_CryptoHelper.php +++ b/inc/classes/main/crypto/class_CryptoHelper.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -19,9 +19,13 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program. If not, see . */ -class CryptoHelper extends BaseFrameworkSystem { +class CryptoHelper extends BaseFrameworkSystem implements Cryptable { + // Exception constants + const EXCEPTION_ENCRYPT_MISSING = 0x1f0; + const EXCEPTION_ENCRYPT_INVALID = 0x1f1; + /** * An instance of this own clas */ @@ -46,12 +50,6 @@ class CryptoHelper extends BaseFrameworkSystem { // Call parent constructor parent::__construct(__CLASS__); - // Set part description - $this->setObjectDescription("Cryptographical helper"); - - // Create unique ID number - $this->generateUniqueId(); - // Clean up a little $this->removeNumberFormaters(); $this->removeSystemArray(); @@ -64,7 +62,7 @@ class CryptoHelper extends BaseFrameworkSystem { */ public final static function createCryptoHelper () { // Get a new instance - $cryptoInstance = self::getInstance(); + $cryptoInstance = new CryptoHelper(); // Initialize the hasher $cryptoInstance->initHasher(); @@ -82,7 +80,7 @@ class CryptoHelper extends BaseFrameworkSystem { // Is no instance there? if (is_null(self::$selfInstance)) { // Then get a new one - self::$selfInstance = new CryptoHelper(); + self::$selfInstance = self::createCryptoHelper(); } // Return the instance @@ -109,7 +107,7 @@ class CryptoHelper extends BaseFrameworkSystem { */ private function generateSalt () { // Get a random string from the RNG - $randomString = $this->rngInstance->makeRandomString(); + $randomString = $this->rngInstance->randomString(); // Get config entry for salt length $length = $this->getConfigInstance()->readConfig('salt_length'); @@ -119,38 +117,138 @@ class CryptoHelper extends BaseFrameworkSystem { } /** - * Hashes a password with salt and returns the hash. If an old previous hash + * 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 the password is * identical for authorization purposes. * - * @param $plainPassword The plain password to use - * @param $oldHash A previously hashed password - * @return $hashed The hashed and salted password + * @param $str Unhashed string + * @param $oldHash A hash from previous hashed string + * @return $hashed The hashed and salted string */ - public function hashPassword ($plainPassword, $oldHash = "") { + 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)) { - // No, then use the current salt - $salt = $this->salt; - } else { + 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->getExtraSalt(), - $plainPassword + $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); + $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/class_ b/inc/classes/main/database/class_ index 504f4ab11..1fdbd071b 100644 --- a/inc/classes/main/database/class_ +++ b/inc/classes/main/database/class_ @@ -5,7 +5,7 @@ * @see DatabaseFrontendInterface - An interface for database frontends (front-end to the application) * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -32,12 +32,6 @@ class extends BaseDatabaseFrontend { // Call parent constructor parent::__construct($class); - // Set part description - $this->setObjectDescription(""); - - // Create unique ID number - $this->generateUniqueId(); - // Clean up a little $this->removeNumberFormaters(); $this->removeSystemArray(); diff --git a/inc/classes/main/database/class_BaseDatabaseFrontend.php b/inc/classes/main/database/class_BaseDatabaseFrontend.php index 2d2e04bdc..57a5d5453 100644 --- a/inc/classes/main/database/class_BaseDatabaseFrontend.php +++ b/inc/classes/main/database/class_BaseDatabaseFrontend.php @@ -5,7 +5,7 @@ * @see DatabaseFrontendInterface - An interface for database frontends (front-end to the application) * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -22,9 +22,9 @@ * 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, LimitableObject { +abstract class BaseDatabaseFrontend extends BaseFrameworkSystem implements DatabaseFrontendInterface { // Constants for exceptions - const EXCEPTION_SQL_QUERY = 0x050; + const EXCEPTION_SQL_QUERY = 0x140; /** * The limiter instance @@ -34,43 +34,16 @@ abstract class BaseDatabaseFrontend extends BaseFrameworkSystem implements Datab /** * Protected constructor * + * @param $className Name of the class * @return void */ - protected function __construct($class) { + protected function __construct($className) { // Call parent constructor - parent::__construct($class); + parent::__construct($className); // Clean up a little $this->removeNumberFormaters(); } - - /** - * Getter for limitation instance - * - * @return $limitInstance The instance to the object ObjectLimits - */ - public final function getLimitInstance () { - return $this->limitInstance; - } - - /** - * Setup limitation for the saving process - * - * @param $limitInstance An instance of ObjectLimits which contains - * elements we shall exclusivly include in - * saving process - * @return void - */ - public final function limitObject (ObjectLimits $limitInstance) { - // Get limitArray for validation - $array = $limitInstance->getLimitArray(); - - // Sanity-check if some limitations are in the object - if ($array->count() > 0) { - // Okay, there is enougth - $this->limitInstance = $limitInstance; - } - } } // [EOF] diff --git a/inc/classes/main/database/class_BaseDatabaseWrapper.php b/inc/classes/main/database/class_BaseDatabaseWrapper.php index 52447117e..e406938b4 100644 --- a/inc/classes/main/database/class_BaseDatabaseWrapper.php +++ b/inc/classes/main/database/class_BaseDatabaseWrapper.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -22,6 +22,16 @@ * 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 * @@ -31,10 +41,120 @@ class BaseDatabaseWrapper extends BaseFrameworkSystem { // 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/class_LocalFileDatabase.php b/inc/classes/main/database/databases/class_LocalFileDatabase.php index 220ad14d2..69ce662f9 100644 --- a/inc/classes/main/database/databases/class_LocalFileDatabase.php +++ b/inc/classes/main/database/databases/class_LocalFileDatabase.php @@ -6,7 +6,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -26,8 +26,9 @@ class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontendInterface { // Constants for MySQL backward-compatiblity (PLEASE FIX THEM!) - const DB_CODE_TABLE_MISSING = 0x010; - const DB_CODE_TABLE_UNWRITEABLE = 0x011; + const DB_CODE_TABLE_MISSING = 0x100; + const DB_CODE_TABLE_UNWRITEABLE = 0x101; + const DB_CODE_DATA_FILE_CORRUPT = 0x102; /** * Save path for "file database" @@ -64,6 +65,11 @@ class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontend */ private $lastException = null; + /** + * Table information array + */ + private $tableInfo = array(); + /** * The protected constructor. Do never instance from outside! You need to * set a local file path. The class will then validate it. @@ -74,13 +80,8 @@ class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontend // Call parent constructor parent::__construct(__CLASS__); - // Set description - $this->setObjectDescription("Class for local file databases"); - - // Create unique ID - $this->generateUniqueId(); - // Clean up a little + $this->removeNumberFormaters(); $this->removeSystemArray(); } @@ -149,58 +150,6 @@ class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontend return $this->lastException; } - /** - * Saves a given object to the local file system by serializing and - * transparently compressing it - * - * @param $object The object we shall save to the local file system - * @return void - */ - public final function saveObject (FrameworkInterface $object) { - // Get a string containing the serialized object. We cannot exchange - // $this and $object here because $object does not need to worry - // about it's limitations... ;-) - $serialized = $this->serializeObject($object); - - // Get a path name plus file name and append the extension - $fqfn = $this->getSavePath() . $object->getPathFileNameFromObject() . "." . $this->getFileExtension(); - - // Save the file to disc we don't care here if the path is there, - // this must be done in later methods. - $this->getFileIoInstance()->saveFile($fqfn, array($this->getCompressorChannel()->getCompressorExtension(), $serialized)); - } - - /** - * Get a serialized string from the given object - * - * @param $object The object we want to serialize and transparently - * compress - * @return $serialized A string containing the serialzed/compressed object - * @see ObjectLimits An object holding limition information - * @see SerializationContainer A special container class for e.g. - * attributes from limited objects - */ - private function serializeObject (FrameworkInterface $object) { - // If there is no limiter instance we serialize the whole object - // otherwise only in the limiter object (ObjectLimits) specified - // attributes summarized in a special container class - if ($this->getLimitInstance() === null) { - // Serialize the whole object. This tribble call is the reason - // why we need a fall-back implementation in CompressorChannel - // of the methods compressStream() and decompressStream(). - $serialized = $this->getCompressorChannel()->getCompressor()->compressStream(serialize($object)); - } else { - // Serialize only given attributes in a special container - $container = SerializationContainer::createSerializationContainer($this->getLimitInstance(), $object); - - // Serialize the container - $serialized = $this->getCompressorChannel()->getCompressor()->compressStream(serialize($container)); - } - - // Return the serialized object string - return $serialized; - } - /** * Analyses if a unique ID has already been used or not by search in the * local database folder. @@ -214,6 +163,7 @@ class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontend * @throws NoArrayCreatedException If explode() fails to create an array * @throws InvalidArrayCountException If the array contains less or * more than two elements + * @deprecated */ public function isUniqueIdUsed ($uniqueID, $inConstructor = false) { // Currently not used... ;-) @@ -228,14 +178,14 @@ class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontend if ($inConstructor) { return false; } else { - throw new NoArrayCreatedException(array($this, "pathFile"), self::EXCEPTION_ARRAY_EXPECTED); + throw new NoArrayCreatedException(array($this, 'pathFile'), self::EXCEPTION_ARRAY_EXPECTED); } } elseif (count($pathFile) != 2) { // Invalid ID returned! if ($inConstructor) { return false; } else { - throw new InvalidArrayCountException(array($this, "pathFile", count($pathFile), 2), self::EXCEPTION_ARRAY_HAS_INVALID_COUNT); + throw new InvalidArrayCountException(array($this, 'pathFile', count($pathFile), 2), self::EXCEPTION_ARRAY_HAS_INVALID_COUNT); } } @@ -261,7 +211,7 @@ class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontend // Initialize the search loop $isValid = false; - while ($dataFile = $dirInstance->readDirectoryExcept(array(".", "..", ".htaccess", ".svn"))) { + while ($dataFile = $dirInstance->readDirectoryExcept(array(".", "..", ".htaccess", ".svn", "info." . $this->getFileExtension()))) { // Generate FQFN for testing $fqfn = sprintf("%s/%s", $pathName, $dataFile); $this->setLastFile($fqfn); @@ -353,175 +303,128 @@ class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontend } /** - * Get cached (last fetched) data from the local file database + * Reads a local data file and returns it's contents in an array * - * @param $uniqueID The ID number for looking up the data - * @return $object The restored object from the maybe compressed - * serialized data - * @throws MismatchingCompressorsException If the compressor from - * the loaded file - * mismatches with the - * current used one. - * @throws NullPointerException If the restored object - * is null - * @throws NoObjectException If the restored "object" - * is not an object instance - * @throws MissingMethodException If the required method - * toString() is missing + * @param $fqfn The FQFN for the requested file + * @return $dataArray */ - public final function getObjectFromCachedData ($uniqueID) { - // Get instance for file handler - $inputHandler = $this->getFileIoInstance(); - - // Get last file's name and contents - $fqfn = $this->repairFQFN($this->getLastFile(), $uniqueID); - $contents = $this->repairContents($this->getLastContents(), $fqfn); - - // Let's decompress it. First we need the instance - $compressInstance = $this->getCompressorChannel(); - - // Is the compressor's extension the same as the one from the data? - if ($compressInstance->getCompressorExtension() != $contents['header'][0]) { - /** - * @todo For now we abort here but later we need to make this a little more dynamic. - */ - throw new MismatchingCompressorsException(array($this, $contents['header'][0], $fqfn, $compressInstance->getCompressorExtension()), self::EXCEPTION_MISMATCHING_COMPRESSORS); - } + private function getDataArrayFromFile ($fqfn) { + // Get a file pointer + $fileInstance = FrameworkFileInputPointer::createFrameworkFileInputPointer($fqfn); - // Decompress the data now - $serialized = $compressInstance->getCompressor()->decompressStream($contents['data']); - - // And unserialize it... - $object = unserialize($serialized); - - // This must become a valid object, so let's check it... - if (is_null($object)) { - // Is null, throw exception - throw new NullPointerException($object, self::EXCEPTION_IS_NULL_POINTER); - } elseif (!is_object($object)) { - // Is not an object, throw exception - throw new NoObjectException($object, self::EXCEPTION_IS_NO_OBJECT); - } elseif (!$object instanceof FrameworkInterface) { - // A highly required method was not found... :-( - throw new MissingMethodException(array($object, '__toString'), self::EXCEPTION_MISSING_METHOD); - } + // 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); - // And return the object - return $object; + // Finally return it + return $dataArray; } /** - * Private method for re-gathering (repairing) the FQFN + * Writes data array to local file * - * @param $fqfn The current FQFN we shall validate - * @param $uniqueID The unique ID number - * @return $fqfn The repaired FQFN when it is empty - * @throws NoArrayCreatedException If explode() has not - * created an array - * @throws InvalidArrayCountException If the array count is not - * as the expected + * @param $fqfn The FQFN of the local file + * @param $dataArray An array with all the data we shall write + * @return void */ - private function repairFQFN ($fqfn, $uniqueID) { - // Cast both strings - $fqfn = (string) $fqfn; - $uniqueID = (string) $uniqueID; - - // Is there pre-cached data available? - if (empty($fqfn)) { - // Split the unique ID up in path and file name - $pathFile = explode("@", $uniqueID); - - // Are there two elements? Index 0 is the path, 1 the file name + global extension - if (!is_array($pathFile)) { - // No array found - throw new NoArrayCreatedException(array($this, "pathFile"), self::EXCEPTION_ARRAY_EXPECTED); - } elseif (count($pathFile) != 2) { - // Invalid ID returned! - throw new InvalidArrayCountException(array($this, "pathFile", count($pathFile), 2), self::EXCEPTION_ARRAY_HAS_INVALID_COUNT); - } + private function writeDataArrayToFqfn ($fqfn, array $dataArray) { + // Get a file pointer instance + $fileInstance = FrameworkFileOutputPointer::createFrameworkFileOutputPointer($fqfn, 'w'); - // Create full path name - $pathName = $this->getSavePath() . $pathFile[0]; + // Serialize and compress it + $compressedData = $this->getCompressorChannel()->getCompressor()->compressStream(serialize($dataArray)); - // Nothing cached, so let's create a FQFN first - $fqfn = sprintf("%s/%s.%s", $pathName, $pathFile[1], $this->getFileExtension()); - $this->setLastFile($fqfn); - } + // Write this data BASE64 encoded to the file + $fileInstance->writeToFile(base64_encode($compressedData)); - // Return repaired FQFN - return $fqfn; + // Close the file pointer + $fileInstance->closeFile(); } /** - * Private method for re-gathering the contents of a given file + * Getter for table information file contents or an empty if the info file was not created * - * @param $contents The (maybe) already cached contents as an array - * @param $fqfn The current FQFN we shall validate - * @return $contents The repaired contents from the given file + * @param $dataSetInstance An instance of a database set class + * @return $infoArray An array with all table informations */ - private function repairContents ($contents, $fqfn) { - // Is there some content and header (2 indexes) in? - if ((!is_array($contents)) || (count($contents) != 2) || (!isset($contents['header'])) || (!isset($contents['data']))) { - // No content found so load the file again - $contents = $inputHandler->loadFileContents($fqfn); - - // And remember all data for later usage - $this->setLastContents($contents); + 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 } - // Return the repaired contents - return $contents; + // ... and return it + return $infoArray; } /** - * Makes sure that the database connection is alive + * Creates the table info file from given dataset instance * + * @param $dataSetInstance An instance of a database set class * @return void */ - public function connectToDatabase () { - // @TODO Do some checks on the database directory and files here + 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()]); } /** - * Loads data saved with saveObject from the database and re-creates a - * full object from it. - * If limitObject() was called before a new object ObjectContainer with - * all requested attributes will be returned instead. + * Updates the primary key information or creates the table info file if not found * - * @return Object The fully re-created object or instance to - * ObjectContainer - * @throws SavePathIsEmptyException If the given save path is an - * empty string - * @throws SavePathIsNoDirectoryException If the save path is no - * path (e.g. a file) - * @throws SavePathReadProtectedException If the save path is read- - * protected - * @throws SavePathWriteProtectedException If the save path is write- - * protected + * @param $dataSetInstance An instance of a database set class + * @return void */ - public function loadObject () { - // Already connected? Then abort here - if ($this->alreadyConnected === true) return true; - - // Get the save path - $savePath = $this->getSavePath(); - - if (empty($savePath)) { - // Empty string - throw new SavePathIsEmptyException($dbInstance, self::EXCEPTION_UNEXPECTED_EMPTY_STRING); - } elseif (!is_dir($savePath)) { - // Is not a dir - throw new SavePathIsNoDirectoryException($savePath, self::EXCEPTION_INVALID_PATH_NAME); - } elseif (!is_readable($savePath)) { - // Path not readable - throw new SavePathReadProtectedException($savePath, self::EXCEPTION_READ_PROTECED_PATH); - } elseif (!is_writeable($savePath)) { - // Path not writeable - throw new SavePathWriteProtectedException($savePath, self::EXCEPTION_WRITE_PROTECED_PATH); + 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); } + } - // "Connection" established... ;-) - $this->alreadyConnected = true; + /** + * Makes sure that the database connection is alive + * + * @return void + * @todo Do some checks on the database directory and files here + */ + public function connectToDatabase () { } /** @@ -555,25 +458,19 @@ class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontend ); // Initialize limit/skip - $limitFound = 0; $skipFound = 0; + $limitFound = 0; + $skipFound = 0; // Read the directory with some exceptions - while (($dataFile = $directoryInstance->readDirectoryExcept(array(".", "..", ".htaccess", ".svn"))) && ($limitFound < $criteriaInstance->getLimit())) { - // Open this file for reading - $filePointer = FrameworkFileInputPointer::createFrameworkFileInputPointer($pathName . $dataFile); - - // Get the raw data and BASE64-decode it - $compressedData = base64_decode($filePointer->readLinesFromFile()); + 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; + } - // Close the file and throw the instance away - $filePointer->closeFile(); - unset($filePointer); - - // Decompress it - $serializedData = $this->getCompressorChannel()->getCompressor()->decompressStream($compressedData); - - // Unserialize it - $dataArray = unserialize($serializedData); + // Read the file + $dataArray = $this->getDataArrayFromFile($pathName . $dataFile); // Is this an array? if (is_array($dataArray)) { @@ -596,12 +493,15 @@ class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontend } // END - if // Entry found! - $resultData['rows'][] = $dataArray; + $resultData['rows'][] = $dataArray; $limitFound++; break; } // END - if } // END - foreach - } // END - if + } 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); + } } // END - while // Close directory and throw the instance away @@ -644,21 +544,103 @@ class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontend ); // 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 - $filePointer = FrameworkFileOutputPointer::createFrameworkFileOutputPointer($fqfn, 'w'); + $directoryInstance = FrameworkDirectoryPointer::createFrameworkDirectoryPointer($pathName); + + // Initialize limit/skip + $limitFound = 0; + $skipFound = 0; // Get the criteria array from the dataset $criteriaArray = $dataSetInstance->getCriteriaArray(); - // Serialize and compress it - $compressedData = $this->getCompressorChannel()->getCompressor()->compressStream(serialize($criteriaArray)); + // 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); - // Write this data BASE64 encoded to the file - $filePointer->writeToFile(base64_encode($compressedData)); + // Count it + $limitFound++; + break; + } // END - if + } // END - foreach + } // END - if + } // END - while // Close the file pointer - $filePointer->closeFile(); + $directoryInstance->closeDirectory(); + + // Update the primary key + $this->updatePrimaryKey($dataSetInstance); // Reset last error message and exception $this->resetLastError(); @@ -668,9 +650,30 @@ class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontend $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); + 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/class_NewsDatabaseWrapper.php b/inc/classes/main/database/wrapper/class_NewsDatabaseWrapper.php new file mode 100644 index 000000000..9a87e6a70 --- /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_UserDatabaseWrapper.php b/inc/classes/main/database/wrapper/class_UserDatabaseWrapper.php index 5fc62e2a8..1bbbf0315 100644 --- a/inc/classes/main/database/wrapper/class_UserDatabaseWrapper.php +++ b/inc/classes/main/database/wrapper/class_UserDatabaseWrapper.php @@ -2,10 +2,9 @@ /** * A database wrapper for the User class * - * @see DatabaseFrontendInterface - An interface for database frontends (front-end to the application) * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -23,17 +22,14 @@ * along with this program. If not, see . */ class UserDatabaseWrapper extends BaseDatabaseWrapper { - /** - * Cache instance - */ - private $cacheInstance = null; - // Constants for exceptions - const EXCEPTION_CLIENT_USERNAME_NOT_FOUND = 0x070; + const EXCEPTION_CLIENT_USERNAME_NOT_FOUND = 0x180; // Constants for database columns - const DB_COLUMN_USERNAME = "username"; - const DB_COLUMN_EMAIL = "email"; + 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"; @@ -46,12 +42,6 @@ class UserDatabaseWrapper extends BaseDatabaseWrapper { protected function __construct() { // Call parent constructor parent::__construct(__CLASS__); - - // Set part description - $this->setObjectDescription("Database wrapper for user objects"); - - // Create unique ID number - $this->generateUniqueId(); } /** @@ -65,65 +55,13 @@ class UserDatabaseWrapper extends BaseDatabaseWrapper { // Get a new instance $wrapperInstance = new UserDatabaseWrapper(); - // Initialize the cache instance - $wrapperInstance->initCacheInstance(); + // Set (primary!) table name + $wrapperInstance->setTableName(self::DB_TABLE_USER); // Return the instance return $wrapperInstance; } - /** - * Initializes the cache instance with a new object - * - * @return void - */ - protected function initCacheInstance () { - // Set the new instance - $this->cacheInstance = CacheFactory::getFactory()->createConfiguredCache(); - } - - /** - * Do a "select" query on the user 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(self::DB_TABLE_USER, $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; - } - /** * Handles inserting the registration data from a registration instance into the database * @@ -132,8 +70,10 @@ class UserDatabaseWrapper extends BaseDatabaseWrapper { */ public function insertRegistrationObject (UserRegister $registrationInstance) { // Generate a data set for the request - $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class'); - $dataSetInstance->setTableName(self::DB_TABLE_USER); + $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); @@ -141,6 +81,29 @@ class UserDatabaseWrapper extends BaseDatabaseWrapper { // "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 000000000..0a8af18ed --- /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/class_DebugConsoleOutput.php b/inc/classes/main/debug/class_DebugConsoleOutput.php index be17ae39a..b9db25680 100644 --- a/inc/classes/main/debug/class_DebugConsoleOutput.php +++ b/inc/classes/main/debug/class_DebugConsoleOutput.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -30,12 +30,6 @@ class DebugConsoleOutput extends BaseFrameworkSystem implements Debugger, Output protected function __construct () { // Call parent constructor parent::__construct(__CLASS__); - - // Set description - $this->setObjectDescription("Debug output for the console"); - - // Create an unique ID - $this->generateUniqueId(); } /** @@ -58,7 +52,7 @@ class DebugConsoleOutput extends BaseFrameworkSystem implements Debugger, Output * @return void */ public final function outputStream ($output) { - print html_entity_decode(strip_tags($output)); + print(html_entity_decode(strip_tags($output))); } /** diff --git a/inc/classes/main/debug/class_DebugErrorLogOutput.php b/inc/classes/main/debug/class_DebugErrorLogOutput.php index 34db47c5f..0d30d4f5b 100644 --- a/inc/classes/main/debug/class_DebugErrorLogOutput.php +++ b/inc/classes/main/debug/class_DebugErrorLogOutput.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -30,12 +30,6 @@ class DebugErrorLogOutput extends BaseFrameworkSystem implements Debugger, Outpu protected function __construct () { // Call parent constructor parent::__construct(__CLASS__); - - // Set description - $this->setObjectDescription("Debug output to error_log()"); - - // Create an unique ID - $this->generateUniqueId(); } /** diff --git a/inc/classes/main/debug/class_DebugWebOutput.php b/inc/classes/main/debug/class_DebugWebOutput.php index 81dd64dc9..268738a7a 100644 --- a/inc/classes/main/debug/class_DebugWebOutput.php +++ b/inc/classes/main/debug/class_DebugWebOutput.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -30,12 +30,6 @@ class DebugWebOutput extends BaseFrameworkSystem implements Debugger, OutputStre protected function __construct () { // Call parent constructor parent::__construct(__CLASS__); - - // Set description - $this->setObjectDescription("Debug output for webpages"); - - // Create an unique ID - $this->generateUniqueId(); } /** @@ -58,7 +52,9 @@ class DebugWebOutput extends BaseFrameworkSystem implements Debugger, OutputStre * @return void */ public final function outputStream ($output) { - trigger_error($output); + // Strip out
+ $output = str_replace("
", "", $output); + print($output."
\n"); } /** diff --git a/inc/classes/main/extended/class_ObjectLimits.php b/inc/classes/main/extended/class_ObjectLimits.php index 926e8fc69..113be61ac 100644 --- a/inc/classes/main/extended/class_ObjectLimits.php +++ b/inc/classes/main/extended/class_ObjectLimits.php @@ -38,12 +38,6 @@ class ObjectLimits extends BaseFrameworkSystem { // Call parent constructor parent::__construct(__CLASS__); - // Set part description - $this->setObjectDescription("Class for "limiting" other classes. See description for details."); - - // Create unique ID number - $this->generateUniqueId(); - // Clean up a little $this->removeNumberFormaters(); } diff --git a/inc/classes/main/factories/cache/class_CacheFactory.php b/inc/classes/main/factories/cache/class_CacheFactory.php index e2cb7bce3..2938b8742 100644 --- a/inc/classes/main/factories/cache/class_CacheFactory.php +++ b/inc/classes/main/factories/cache/class_CacheFactory.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -35,12 +35,6 @@ class CacheFactory extends BaseFactory { protected function __construct () { // Call parent constructor parent::__construct(__CLASS__); - - // Set object description - $this->setObjectDescription("Factory for cache objects"); - - // Create unique ID number - $this->generateUniqueId(); } /** @@ -66,7 +60,7 @@ class CacheFactory extends BaseFactory { */ public function createConfiguredCache () { // Read the config entry - $cacheType = $this->getConfigInstance()->readConfig("cache_class"); + $cacheType = $this->getConfigInstance()->readConfig('cache_class'); // And get a new instance $cacheInstance = ObjectFactory::createObjectByName($cacheType); diff --git a/inc/classes/main/factories/class_BaseFactory.php b/inc/classes/main/factories/class_BaseFactory.php index 68a856d39..3fd5510c6 100644 --- a/inc/classes/main/factories/class_BaseFactory.php +++ b/inc/classes/main/factories/class_BaseFactory.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -30,12 +30,12 @@ class BaseFactory extends BaseFrameworkSystem { /** * Protected constructor * - * @param $class Name of the real class (not BaseFactory) + * @param $className Name of the real class (not BaseFactory) * @return void */ - protected function __construct ($class) { + protected function __construct ($className) { // Call parent constructor - parent::__construct($class); + parent::__construct($className); // Clean up a little $this->removeNumberFormaters(); diff --git a/inc/classes/main/factories/objects/class_ObjectFactory.php b/inc/classes/main/factories/objects/class_ObjectFactory.php index 9a2ec9c2d..06c73d89c 100644 --- a/inc/classes/main/factories/objects/class_ObjectFactory.php +++ b/inc/classes/main/factories/objects/class_ObjectFactory.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -35,12 +35,6 @@ class ObjectFactory extends BaseFactory { protected function __construct () { // Call parent constructor parent::__construct(__CLASS__); - - // Set object description - $this->setObjectDescription("Simple generic object factory"); - - // Create unique ID number - $this->generateUniqueId(); } /** diff --git a/inc/classes/main/factories/web/class_WebNewsFactory.php b/inc/classes/main/factories/web/class_WebNewsFactory.php index dfbb6db85..d7307ec37 100644 --- a/inc/classes/main/factories/web/class_WebNewsFactory.php +++ b/inc/classes/main/factories/web/class_WebNewsFactory.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -35,12 +35,6 @@ class WebNewsFactory extends BaseFactory { protected function __construct () { // Call parent constructor parent::__construct(__CLASS__); - - // Set part description - $this->setObjectDescription("Factory for webpages with news"); - - // Create unique ID number - $this->generateUniqueId(); } /** diff --git a/inc/classes/main/filter/auth/class_UserAuthFilter.php b/inc/classes/main/filter/auth/class_UserAuthFilter.php index 5754bf1d6..b08d0c2b8 100644 --- a/inc/classes/main/filter/auth/class_UserAuthFilter.php +++ b/inc/classes/main/filter/auth/class_UserAuthFilter.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -23,7 +23,7 @@ */ class UserAuthFilter extends BaseFilter implements Filterable { // Exception constants - const EXCEPTION_AUTH_DATA_INVALID = 0x0a0; + const EXCEPTION_AUTH_DATA_INVALID = 0x1b0; /** * The login method we shall choose @@ -38,12 +38,6 @@ class UserAuthFilter extends BaseFilter implements Filterable { protected function __construct () { // Call parent constructor parent::__construct(__CLASS__); - - // Set part description - $this->setObjectDescription("A user authorization filter"); - - // Create unique ID number - $this->generateUniqueId(); } /** @@ -78,6 +72,8 @@ class UserAuthFilter extends BaseFilter implements Filterable { * @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 @@ -103,10 +99,37 @@ class UserAuthFilter extends BaseFilter implements Filterable { // Stop here throw new UserAuthorizationException($this, self::EXCEPTION_AUTH_DATA_INVALID); - } - - // Destroy safely the auth instance - unset($authInstance); + } // 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); } } diff --git a/inc/classes/main/filter/change/.htaccess b/inc/classes/main/filter/change/.htaccess new file mode 100644 index 000000000..3a4288278 --- /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 000000000..4e75421e1 --- /dev/null +++ b/inc/classes/main/filter/change/class_EmailChangeFilter.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 EmailChangeFilter extends BaseFrameworkSystem implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public final static function createEmailChangeFilter () { + // Get a new instance + $filterInstance = new EmailChangeFilter(); + + // 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 + + // 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) { + // Update the "new_email" field + $this->partialStub("Unfinished part."); + } // END - if + } +} + +// [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 000000000..078d2944f --- /dev/null +++ b/inc/classes/main/filter/change/class_PasswordChangeFilter.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 PasswordChangeFilter extends BaseFrameworkSystem implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public final static function createPasswordChangeFilter () { + // Get a new instance + $filterInstance = new PasswordChangeFilter(); + + // 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 + + // 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/class_RulesAcceptedFilter.php b/inc/classes/main/filter/checkboxes/class_RulesAcceptedFilter.php index d52c6aa6a..85e945e8b 100644 --- a/inc/classes/main/filter/checkboxes/class_RulesAcceptedFilter.php +++ b/inc/classes/main/filter/checkboxes/class_RulesAcceptedFilter.php @@ -6,7 +6,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -32,12 +32,6 @@ class RulesAcceptedFilter extends BaseFilter implements Filterable { protected function __construct () { // Call parent constructor parent::__construct(__CLASS__); - - // Set part description - $this->setObjectDescription("A filter for checking if rules where accepted"); - - // Create unique ID number - $this->generateUniqueId(); } /** diff --git a/inc/classes/main/filter/class_ b/inc/classes/main/filter/class_ index 674159909..9027c5d18 100644 --- a/inc/classes/main/filter/class_ +++ b/inc/classes/main/filter/class_ @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -31,12 +31,6 @@ class ???Filter extends BaseFrameworkSystem implements Filterable { // Call parent constructor parent::__construct(__CLASS__); - // Set part description - $this->setObjectDescription("A concrete filter"); - - // Create unique ID number - $this->generateUniqueId(); - // Clean up a little $this->removeNumberFormaters(); $this->removeSystemArray(); diff --git a/inc/classes/main/filter/class_AbstractFilterDecorator.php b/inc/classes/main/filter/class_AbstractFilterDecorator.php index 025c3dee4..e11b970dd 100644 --- a/inc/classes/main/filter/class_AbstractFilterDecorator.php +++ b/inc/classes/main/filter/class_AbstractFilterDecorator.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * diff --git a/inc/classes/main/filter/class_BaseFilter.php b/inc/classes/main/filter/class_BaseFilter.php index 3800c4925..0f3a47818 100644 --- a/inc/classes/main/filter/class_BaseFilter.php +++ b/inc/classes/main/filter/class_BaseFilter.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -23,7 +23,7 @@ */ class BaseFilter extends BaseFrameworkSystem { // Exception constants - const EXCEPTION_FILTER_CHAIN_ABORTED = 0x090; + const EXCEPTION_FILTER_CHAIN_ABORTED = 0x1a0; /** * Protected constructor diff --git a/inc/classes/main/filter/class_FilterChain.php b/inc/classes/main/filter/class_FilterChain.php index 7004eb50f..b3825dabd 100644 --- a/inc/classes/main/filter/class_FilterChain.php +++ b/inc/classes/main/filter/class_FilterChain.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -36,12 +36,6 @@ class FilterChain extends BaseFrameworkSystem { // Call parent constructor parent::__construct(__CLASS__); - // Set part description - $this->setObjectDescription("A filter chain class"); - - // Create unique ID number - $this->generateUniqueId(); - // Clean up a little $this->removeNumberFormaters(); $this->removeSystemArray(); diff --git a/inc/classes/main/filter/crypto/.htaccess b/inc/classes/main/filter/crypto/.htaccess new file mode 100644 index 000000000..3a4288278 --- /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 000000000..b399a8917 --- /dev/null +++ b/inc/classes/main/filter/crypto/class_CaptchaEncryptFilter.php @@ -0,0 +1,90 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General 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 BaseFrameworkSystem implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public final static function createCaptchaEncryptFilter () { + // Get a new instance + $filterInstance = new CaptchaEncryptFilter(); + + // 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/guest/.htaccess b/inc/classes/main/filter/guest/.htaccess new file mode 100644 index 000000000..3a4288278 --- /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 000000000..fc11b737f --- /dev/null +++ b/inc/classes/main/filter/guest/class_UserNameIsGuestFilter.php @@ -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 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 + * + * @return $filterInstance An instance of this filter class + */ + public final static function createUserNameIsGuestFilter () { + // Get a new instance + $filterInstance = new UserNameIsGuestFilter(); + + // 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/class_NewsDownloadFilter.php b/inc/classes/main/filter/news/class_NewsDownloadFilter.php index e3a1881c2..1b57940f2 100644 --- a/inc/classes/main/filter/news/class_NewsDownloadFilter.php +++ b/inc/classes/main/filter/news/class_NewsDownloadFilter.php @@ -6,7 +6,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -32,12 +32,6 @@ class NewsDownloadFilter extends BaseFilter implements Filterable { protected function __construct () { // Call parent constructor parent::__construct(__CLASS__); - - // Set part description - $this->setObjectDescription("A filter for downloading news"); - - // Create unique ID number - $this->generateUniqueId(); } /** @@ -64,8 +58,8 @@ class NewsDownloadFilter extends BaseFilter implements Filterable { // Get a news instance $newsInstance = WebNewsFactory::createFactoryByRequest($requestInstance); - // TODO Need to extend/rewrite this - $this->partialStub("Unfinished work."); + // Store the news instance in registry + Registry::getRegistry()->addInstance('news', $newsInstance); } } diff --git a/inc/classes/main/filter/news/class_NewsProcessFilter.php b/inc/classes/main/filter/news/class_NewsProcessFilter.php index 8df6a0f01..76ebf3df5 100644 --- a/inc/classes/main/filter/news/class_NewsProcessFilter.php +++ b/inc/classes/main/filter/news/class_NewsProcessFilter.php @@ -5,7 +5,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -31,12 +31,6 @@ class NewsProcessFilter extends BaseFilter implements Filterable { protected function __construct () { // Call parent constructor parent::__construct(__CLASS__); - - // Set part description - $this->setObjectDescription("A filter for processing news"); - - // Create unique ID number - $this->generateUniqueId(); } /** @@ -58,9 +52,9 @@ class NewsProcessFilter extends BaseFilter implements Filterable { * @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) { - $this->partialStub("Unfinished work."); } } diff --git a/inc/classes/main/filter/null/class_NullFilter.php b/inc/classes/main/filter/null/class_NullFilter.php index ef9c70c3f..9b145bab8 100644 --- a/inc/classes/main/filter/null/class_NullFilter.php +++ b/inc/classes/main/filter/null/class_NullFilter.php @@ -5,7 +5,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -31,12 +31,6 @@ class NullFilter extends BaseFilter implements Filterable { protected function __construct () { // Call parent constructor parent::__construct(__CLASS__); - - // Set part description - $this->setObjectDescription("A null filter"); - - // Create unique ID number - $this->generateUniqueId(); } /** diff --git a/inc/classes/main/filter/update/.htaccess b/inc/classes/main/filter/update/.htaccess new file mode 100644 index 000000000..3a4288278 --- /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 000000000..7e301484c --- /dev/null +++ b/inc/classes/main/filter/update/class_UserStatusConfimedUpdateFilter.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 UserStatusConfimedUpdateFilter extends BaseFrameworkSystem implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public final static function createUserStatusConfimedUpdateFilter () { + // Get a new instance + $filterInstance = new UserStatusConfimedUpdateFilter(); + + // 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 000000000..be0c9a8bf --- /dev/null +++ b/inc/classes/main/filter/update/class_UserUpdateFilter.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 UserUpdateFilter extends BaseFrameworkSystem implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public final static function createUserUpdateFilter () { + // Get a new instance + $filterInstance = new UserUpdateFilter(); + + // 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/class_EmailValidatorFilter.php b/inc/classes/main/filter/validator/class_EmailValidatorFilter.php index 4785a9653..feb819e99 100644 --- a/inc/classes/main/filter/validator/class_EmailValidatorFilter.php +++ b/inc/classes/main/filter/validator/class_EmailValidatorFilter.php @@ -7,7 +7,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -33,12 +33,6 @@ class EmailValidatorFilter extends BaseFilter implements Filterable { protected function __construct () { // Call parent constructor parent::__construct(__CLASS__); - - // Set part description - $this->setObjectDescription("A filter for Email validation"); - - // Create unique ID number - $this->generateUniqueId(); } /** @@ -66,7 +60,7 @@ class EmailValidatorFilter extends BaseFilter implements Filterable { $email = $requestInstance->getRequestElement('email'); // Is the Email set? - if ((is_null($email)) || ($this->getConfigInstance()->readConfig('register_email_unique') == "Y")) { + if ((is_null($email)) || ($this->getConfigInstance()->readConfig('register_email_unique') === "Y")) { // Try it again $email1 = $requestInstance->getRequestElement('email1'); $email2 = $requestInstance->getRequestElement('email2'); @@ -153,7 +147,7 @@ class EmailValidatorFilter extends BaseFilter implements Filterable { $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'), "createUserByEmail"), array($email)); + $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); diff --git a/inc/classes/main/filter/validator/class_PasswordValidatorFilter.php b/inc/classes/main/filter/validator/class_PasswordValidatorFilter.php index 1d371b1e8..8944f3588 100644 --- a/inc/classes/main/filter/validator/class_PasswordValidatorFilter.php +++ b/inc/classes/main/filter/validator/class_PasswordValidatorFilter.php @@ -5,7 +5,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -31,12 +31,6 @@ class PasswordValidatorFilter extends BaseFilter implements Filterable { protected function __construct () { // Call parent constructor parent::__construct(__CLASS__); - - // Set part description - $this->setObjectDescription("A filter for Password validation"); - - // Create unique ID number - $this->generateUniqueId(); } /** @@ -81,13 +75,13 @@ class PasswordValidatorFilter extends BaseFilter implements Filterable { // Is the password empty? if (empty($password1)) { // Add a message to the response - $responseInstance->addFatalMessage('password1_empty'); + $responseInstance->addFatalMessage('pass1_empty'); } // END - if // Is the confirmation empty? if (empty($password2)) { // Add a message to the response - $responseInstance->addFatalMessage('password2_empty'); + $responseInstance->addFatalMessage('pass2_empty'); } // END - if // Abort here @@ -97,7 +91,7 @@ class PasswordValidatorFilter extends BaseFilter implements Filterable { $requestInstance->requestIsValid(false); // Add a message to the response - $responseInstance->addFatalMessage('passwords_mismatching'); + $responseInstance->addFatalMessage('pass_mismatch'); // Abort here return false; diff --git a/inc/classes/main/filter/validator/class_UserNameValidatorFilter.php b/inc/classes/main/filter/validator/class_UserNameValidatorFilter.php index 456f16a40..522e77a82 100644 --- a/inc/classes/main/filter/validator/class_UserNameValidatorFilter.php +++ b/inc/classes/main/filter/validator/class_UserNameValidatorFilter.php @@ -7,7 +7,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -33,12 +33,6 @@ class UserNameValidatorFilter extends BaseFilter implements Filterable { protected function __construct () { // Call parent constructor parent::__construct(__CLASS__); - - // Set part description - $this->setObjectDescription("A filter for username validation"); - - // Create unique ID number - $this->generateUniqueId(); } /** @@ -121,7 +115,7 @@ class UserNameValidatorFilter extends BaseFilter implements Filterable { // 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'), "createUserByUsername"), array($userName)); + $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); @@ -134,7 +128,7 @@ class UserNameValidatorFilter extends BaseFilter implements Filterable { if ((is_null($userInstance)) || (!$userInstance->ifUsernameExists())) { // This username is still available $alreadyTaken = false; - } + } // END - if // Return the result return $alreadyTaken; diff --git a/inc/classes/main/filter/verifier/.htaccess b/inc/classes/main/filter/verifier/.htaccess new file mode 100644 index 000000000..3a4288278 --- /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 000000000..eab77bdea --- /dev/null +++ b/inc/classes/main/filter/verifier/class_AccountPasswordVerifierFilter.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 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 + * + * @return $filterInstance An instance of this filter class + */ + public final static function createAccountPasswordVerifierFilter () { + // Get a new instance + $filterInstance = new AccountPasswordVerifierFilter(); + + // 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 + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get password + $password = $requestInstance->getRequestElement('pass_old'); + + // 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('pass_old_unset'); + + // Abort here + return false; + } elseif (empty($password)) { + // Password is empty + $requestInstance->requestIsValid(false); + + // Add a message to the response + $responseInstance->addFatalMessage('pass_old_empty'); + + // Abort here + return false; + } + + // Get a user instance + $userInstance = Registry::getRegistry()->getInstance('user'); + + // Get old hash + $oldHash = $userInstance->getField('pass_hash'); + + // Get an encryption helper and encrypt the password + $passHash = ObjectFactory::createObjectByConfiguredName('crypto_class')->hashString($password, $oldHash); + + // Does it match? + if ($oldHash != $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 000000000..98fc1e67c --- /dev/null +++ b/inc/classes/main/filter/verifier/class_ConfirmCodeVerifierFilter.php @@ -0,0 +1,108 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General 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 + * + * @return $filterInstance An instance of this filter class + */ + public final static function createConfirmCodeVerifierFilter () { + // Get a new instance + $filterInstance = new ConfirmCodeVerifierFilter(); + + // 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 000000000..8bb65a44d --- /dev/null +++ b/inc/classes/main/filter/verifier/class_GraphicalCodeCaptchaVerifierFilter.php @@ -0,0 +1,122 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General 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 + * + * @return $filterInstance An instance of this filter class + */ + public final static function createGraphicalCodeCaptchaVerifierFilter () { + // Get a new instance + $filterInstance = new GraphicalCodeCaptchaVerifierFilter(); + + // 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 000000000..f2a15202e --- /dev/null +++ b/inc/classes/main/filter/verifier/class_PasswordGuestVerifierFilter.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 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 + * + * @return $filterInstance An instance of this filter class + */ + public final static function createPasswordGuestVerifierFilter () { + // Get a new instance + $filterInstance = new PasswordGuestVerifierFilter(); + + // 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 000000000..0bd5cceba --- /dev/null +++ b/inc/classes/main/filter/verifier/class_PasswordVerifierFilter.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 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 + * + * @return $filterInstance An instance of this filter class + */ + public final static function createPasswordVerifierFilter () { + // Get a new instance + $filterInstance = new PasswordVerifierFilter(); + + // 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 000000000..839b1eb96 --- /dev/null +++ b/inc/classes/main/filter/verifier/class_UserGuestVerifierFilter.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 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 + * + * @return $filterInstance An instance of this filter class + */ + public final static function createUserGuestVerifierFilter () { + // Get a new instance + $filterInstance = new UserGuestVerifierFilter(); + + // 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_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->ifUserGuestIsTaken($userName)) { + // Username is already taken + $requestInstance->requestIsValid(false); + + // Add a message to the response + $responseInstance->addFatalMessage('username_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())) { + // 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 000000000..7d0bde9e0 --- /dev/null +++ b/inc/classes/main/filter/verifier/class_UserNameVerifierFilter.php @@ -0,0 +1,139 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General 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 + * + * @return $filterInstance An instance of this filter class + */ + public final static function createUserNameVerifierFilter () { + // Get a new instance + $filterInstance = new UserNameVerifierFilter(); + + // 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_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())) { + // 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 000000000..79e0aceb2 --- /dev/null +++ b/inc/classes/main/filter/verifier/class_UserStatusVerifierFilter.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 UserStatusVerifierFilter extends BaseFrameworkSystem implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public final static function createUserStatusVerifierFilter () { + // Get a new instance + $filterInstance = new UserStatusVerifierFilter(); + + // 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 000000000..e36fa3898 --- /dev/null +++ b/inc/classes/main/filter/verifier/class_UserUnconfirmedVerifierFilter.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 UserUnconfirmedVerifierFilter extends BaseFrameworkSystem implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public final static function createUserUnconfirmedVerifierFilter () { + // Get a new instance + $filterInstance = new UserUnconfirmedVerifierFilter(); + + // 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()) { + // 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/captcha/.htaccess b/inc/classes/main/helper/captcha/.htaccess new file mode 100644 index 000000000..3a4288278 --- /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 000000000..758b20565 --- /dev/null +++ b/inc/classes/main/helper/captcha/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 ???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 + */ + public function initiateCaptcha () { + $this->partialStub("Please implement this method."); + } + + /** + * Render the CAPTCHA code + * + * @return void + */ + 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 000000000..8cb138ef9 --- /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 000000000..3a4288278 --- /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 000000000..0b5a76f03 --- /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 the 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 the 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 000000000..3a4288278 --- /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 000000000..37a206ca4 --- /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_ index 98d4a81bd..ba6cb0ee1 100644 --- a/inc/classes/main/helper/class_ +++ b/inc/classes/main/helper/class_ @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -21,7 +21,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -class extends BaseHelper { +class ???Helper extends BaseHelper { /** * Protected constructor * @@ -38,15 +38,24 @@ class extends BaseHelper { /** * Creates the helper class * - * @return $helperInstance A preparedf instance of this class + * @return $helperInstance A prepared instance of this helper */ - public final static function createHelper () { + public final static function create???Helper () { // Get new instance - $helperInstance = new Helper(); + $helperInstance = new ???Helper(); // Return the prepared instance return $helperInstance; } + + /** + * Flush the content out,e g. to a template variable + * + * @return void + */ + 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 index 1a4819441..94f4ed5f1 100644 --- a/inc/classes/main/helper/class_BaseHelper.php +++ b/inc/classes/main/helper/class_BaseHelper.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -23,15 +23,50 @@ */ class BaseHelper extends BaseFrameworkSystem { /** - * Template engine instance + * Instance to the class which provides field values */ - private $templateInstance = null; + 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 * @@ -48,32 +83,63 @@ class BaseHelper extends BaseFrameworkSystem { } /** - * Setter for template engine instances + * 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 $templateInstance An instance of a template engine class + * @param $content Content to to the base * @return void */ - protected final function setTemplateInstance (CompileableTemplate $templateInstance) { - $this->templateInstance = $templateInstance; + protected function addHeaderContent ($content) { + // Add the header content + $this->groups['header']['content'] = (string) trim($content); } /** - * Getter for template engine instances + * Add footer content to the helper * - * @return $templateInstance An instance of a template engine class + * @param $content Content to to the base + * @return void */ - protected final function getTemplateInstance () { - return $this->templateInstance; + protected function addFooterContent ($content) { + // Add the footer content + $this->groups['footer']['content'] = (string) trim($content); } /** - * Add 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 addContent ($newContent) { - $this->content .= (string) trim($newContent)."\r\n"; + 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); + } } /** @@ -84,6 +150,332 @@ class BaseHelper extends BaseFrameworkSystem { 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 + * @return void + * @throws HelperGroupAlreadyCreatedException If the group was already created before + */ + protected function openGroupByIdContent ($groupId, $content) { + //* DEBUG: */ echo "OPEN:groupId={$groupId}
\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'] = $content."\n"; + + // 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 grouop + * @return void + * @throws HelperNoPreviousOpenedGroupException If no previously opened group was found + */ + public function closePreviousGroupByContent ($content) { + // Check if any group was opened before + if (!$this->ifGroupOpenedPreviously()) { + // 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(); + + // Add content to it and mark it as closed + $this->groups[$groupId]['content'] .= $content."\n"; + $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 + * @return void + * @throws HelperSubGroupAlreadyCreatedException If the sub group was already created before + */ + protected function openSubGroupByIdContent ($subGroupId, $content) { + //* 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'] = $content."\n"; + + // 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 grouop + * @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()) { + // 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(); + + // Add content to it and mark it as closed + $this->subGroups[$subGroupId]['content'] .= $content."\n"; + $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 = $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 .= $subGroupContent; + } else { + // Something went wrong + $this->debugInstance(); + } + + } // 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/class_BaseLoginHelper.php b/inc/classes/main/helper/login/class_BaseLoginHelper.php index 25be6a929..8fdd13d79 100644 --- a/inc/classes/main/helper/login/class_BaseLoginHelper.php +++ b/inc/classes/main/helper/login/class_BaseLoginHelper.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * diff --git a/inc/classes/main/helper/web/blocks/.htaccess b/inc/classes/main/helper/web/blocks/.htaccess new file mode 100644 index 000000000..3a4288278 --- /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 000000000..48b32d838 --- /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 000000000..7c61ec832 --- /dev/null +++ b/inc/classes/main/helper/web/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 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 + */ + 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 000000000..19b5be3d8 --- /dev/null +++ b/inc/classes/main/helper/web/class_BaseWebHelper.php @@ -0,0 +1,200 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General 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 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/class_WebFormHelper.php b/inc/classes/main/helper/web/class_WebFormHelper.php index 61a624347..eccd2ca7a 100644 --- a/inc/classes/main/helper/web/class_WebFormHelper.php +++ b/inc/classes/main/helper/web/class_WebFormHelper.php @@ -62,12 +62,6 @@ class WebFormHelper extends BaseHelper { protected function __construct () { // Call parent constructor parent::__construct(__CLASS__); - - // Set part description - $this->setObjectDescription("Helper class for HTML forms"); - - // Create unique ID number - $this->generateUniqueId(); } /** diff --git a/inc/classes/main/helper/web/forms/.htaccess b/inc/classes/main/helper/web/forms/.htaccess new file mode 100644 index 000000000..3a4288278 --- /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 000000000..2f3502c9e --- /dev/null +++ b/inc/classes/main/helper/web/forms/class_WebFormHelper.php @@ -0,0 +1,786 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General 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())) { + // 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()) && ($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()) { + // Begin the div/span blocks + $content = sprintf(" +
+ + %s + +
", + $groupId, + $groupId, + $groupId, + $groupText, + $groupId + ); + + // Switch the state + $this->openGroupByIdContent($groupId, $content); + } 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 the 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 the 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()) { + // 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())) { + // 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()) && ($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()) { + // Begin the span block + $content = sprintf(" +
+ + %s + +
", + $subGroupId, + $subGroupId, + $subGroupId, + $subGroupText, + $subGroupId + ); + + // Switch the state and remeber the name + $this->openSubGroupByIdContent($subGroupId, $content); + } 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 + + // Is a group open? + if ($this->ifGroupOpenedPreviously()) { + // Then automatically close it here + $this->addFormGroup(); + } // 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()) && ($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()) { + // 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, + $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()) { + // 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 000000000..3a4288278 --- /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 000000000..24fb844b2 --- /dev/null +++ b/inc/classes/main/helper/web/links/class_WebLinkHelper.php @@ -0,0 +1,225 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General 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); + + // Return the prepared instance + return $helperInstance; + } + + /** + * 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 + * @return void + */ + public function addLinkGroup ($groupId, $groupText) { + // Is a group with that name open? + if ($this->ifGroupIsOpened($groupId)) { + // Then close it here + $this->closePreviousGroupByContent("
"); + } else { + // Is a previous opened group still open? + if ($this->ifGroupOpenedPreviously()) { + // Then close it + $this->closePreviousGroupByContent(""); + } // END - if + + // Generate the group content + $content = sprintf("
%s", + $this->getLinkName(), + $groupId, + $groupText + ); + + // Open the new group + $this->openGroupByIdContent($groupId, $content); + } + } + + /** + * Adds text (note) to the previously opened group or throws an exception + * if no previous group was opened. + * + * @param $groupNote Note to be added to a group + * @return void + * @throws NoGroupOpenedException If no previous group was opened + */ + public function addLinkNote ($groupNote) { + // Check if a previous group was opened + if (!$this->ifGroupOpenedPreviously()) { + // No group was opened before! + throw new NoGroupOpenedException(array($this, $groupNote), self::EXCEPTION_GROUP_NOT_OPENED); + } // END - if + + // Add the content to the previous group + $this->addContentToPreviousGroup($groupNote); + } + + /** + * 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()) { + // No group was opened before! + throw new NoGroupOpenedException(array($this, $groupNote), self::EXCEPTION_GROUP_NOT_OPENED); + } // END - if + + // Default parameter seperator is & + $seperator = "&"; + + // Get link base + $linkBase = $this->getLinkBase(); + + // Is there a question mark in? + $linkArray = explode("?", $linkBase); + if (count($linkArray) == 0) { + // No question mark + $seperator = "?"; + } + + // Renders the link content + $linkContent = sprintf("%s", + $linkBase, + $seperator, + $linkAction, + $linkText, + $linkText + ); + + // 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 000000000..3a4288278 --- /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 000000000..69b410054 --- /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 000000000..7c1e0891c --- /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->imageResource, $red, $green, $blue); + + // Fill the image + imagefill($this->imageResource, 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->imageResource, $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->imageResource, $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->imageResource, $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 000000000..3a4288278 --- /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 000000000..f8ee28b8f --- /dev/null +++ b/inc/classes/main/images/extended/class_PngImage.php @@ -0,0 +1,73 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General 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(); + + // 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/class_FileIoStream.php b/inc/classes/main/io/class_FileIoStream.php index f3cf60ef1..7e257be47 100644 --- a/inc/classes/main/io/class_FileIoStream.php +++ b/inc/classes/main/io/class_FileIoStream.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -29,12 +29,6 @@ class FileIoStream extends BaseFrameworkSystem implements FileInputStreamer, Fil // Call parent constructor parent::__construct(__CLASS__); - // Set part description - $this->setObjectDescription("Universal file I/O stream system"); - - // Create unique ID - $this->generateUniqueId(); - // Clean-up a little $this->removeNumberFormaters(); $this->removeSystemArray(); @@ -164,7 +158,7 @@ class FileIoStream extends BaseFrameworkSystem implements FileInputStreamer, Fil // 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); + 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! @@ -202,7 +196,7 @@ class FileIoStream extends BaseFrameworkSystem implements FileInputStreamer, Fil // 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); + throw new InvalidArrayCountException(array($this, 'header', count($header), 4), self::EXCEPTION_ARRAY_HAS_INVALID_COUNT); } // Decode all from Base64 diff --git a/inc/classes/main/io/class_FrameworkDirectoryPointer.php b/inc/classes/main/io/class_FrameworkDirectoryPointer.php index f9eacc71f..e19b0675b 100644 --- a/inc/classes/main/io/class_FrameworkDirectoryPointer.php +++ b/inc/classes/main/io/class_FrameworkDirectoryPointer.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -39,14 +39,9 @@ class FrameworkDirectoryPointer extends BaseFrameworkSystem { // Call parent constructor parent::__construct(__CLASS__); - // Set part description - $this->setObjectDescription("Helper for handling directories"); - - // Create unique ID - $this->generateUniqueId(); - // Clean-up a little $this->removeNumberFormaters(); + $this->removeSystemArray(); } /** diff --git a/inc/classes/main/io/class_FrameworkFileInputPointer.php b/inc/classes/main/io/class_FrameworkFileInputPointer.php index 25c77cb83..172c02f70 100644 --- a/inc/classes/main/io/class_FrameworkFileInputPointer.php +++ b/inc/classes/main/io/class_FrameworkFileInputPointer.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -34,23 +34,22 @@ class FrameworkFileInputPointer extends BaseFrameworkSystem { /** * Protected constructor + * + * @return void */ protected function __construct () { // Call parent constructor parent::__construct(__CLASS__); - // Set part description - $this->setObjectDescription("Handler for reading from files"); - - // Create unique ID - $this->generateUniqueId(); - // 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! @@ -67,26 +66,31 @@ class FrameworkFileInputPointer extends BaseFrameworkSystem { * 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 $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 + * @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)) { + 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 (($filePointer === null) || ($filePointer === false)) { + 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(); @@ -104,7 +108,7 @@ class FrameworkFileInputPointer extends BaseFrameworkSystem { * * @return mixed The result of fread() * @throws NullPointerException If the file pointer instance - * is not set by setPointer() + * is not set by setPointer() * @throws InvalidFileResourceException If there is being set * an invalid file resource */ @@ -126,7 +130,7 @@ class FrameworkFileInputPointer extends BaseFrameworkSystem { * * @return mixed The result of fread() * @throws NullPointerException If the file pointer instance - * is not set by setPointer() + * is not set by setPointer() * @throws InvalidFileResourceException If there is being set * an invalid file resource */ @@ -149,7 +153,7 @@ class FrameworkFileInputPointer extends BaseFrameworkSystem { * * @return void * @throws NullPointerException If the file pointer instance - * is not set by setPointer() + * is not set by setPointer() * @throws InvalidFileResourceException If there is being set */ public function closeFile () { @@ -170,7 +174,7 @@ class FrameworkFileInputPointer extends BaseFrameworkSystem { /** * Setter for the file pointer * - * @param $filePointer File resource + * @param $filePointer File resource * @return void */ public final function setPointer ($filePointer) { @@ -188,7 +192,7 @@ class FrameworkFileInputPointer extends BaseFrameworkSystem { * Getter for the file pointer * * @return $filePointer The file pointer which shall be a valid - * file resource + * file resource */ public final function getPointer () { return $this->filePointer; @@ -197,7 +201,7 @@ class FrameworkFileInputPointer extends BaseFrameworkSystem { /** * Setter for file name * - * @param $fileName The new file name + * @param $fileName The new file name * @return void */ public final function setFileName ($fileName) { @@ -208,7 +212,7 @@ class FrameworkFileInputPointer extends BaseFrameworkSystem { /** * Getter for file name * - * @return $fileName The current file name + * @return $fileName The current file name */ public final function getFileName () { return $this->fileName; diff --git a/inc/classes/main/io/class_FrameworkFileOutputPointer.php b/inc/classes/main/io/class_FrameworkFileOutputPointer.php index 5a7acddd6..37c2285ea 100644 --- a/inc/classes/main/io/class_FrameworkFileOutputPointer.php +++ b/inc/classes/main/io/class_FrameworkFileOutputPointer.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -39,14 +39,9 @@ class FrameworkFileOutputPointer extends BaseFrameworkSystem { // Call parent constructor parent::__construct(__CLASS__); - // Set part description - $this->setObjectDescription("Handler for writing to files"); - - // Create unique ID - $this->generateUniqueId(); - // Clean-up a little $this->removeNumberFormaters(); + $this->removeSystemArray(); } /** diff --git a/inc/classes/main/language/class_LanguageSystem.php b/inc/classes/main/language/class_LanguageSystem.php index eb99cf1e8..befccdb14 100644 --- a/inc/classes/main/language/class_LanguageSystem.php +++ b/inc/classes/main/language/class_LanguageSystem.php @@ -5,7 +5,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -52,12 +52,6 @@ class LanguageSystem extends BaseFrameworkSystem implements ManageableLanguage { // Call parent constructor parent::__construct(__CLASS__); - // Set part description - $this->setObjectDescription("Language sub-system"); - - // Create unique ID number - $this->generateUniqueId(); - // Clean up a little $this->removeNumberFormaters(); $this->removeSystemArray(); diff --git a/inc/classes/main/mailer/.htaccess b/inc/classes/main/mailer/.htaccess new file mode 100644 index 000000000..3a4288278 --- /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 000000000..b3181c54a --- /dev/null +++ b/inc/classes/main/mailer/class_ @@ -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 . + */ +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 + */ + public function deliverEmail() { + $this->partialStub("You have to implement this method."); + } + + /** + * Send notification to the admin + * + * @return void + */ + 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 000000000..4230fbc48 --- /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 000000000..3a4288278 --- /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 000000000..ffc3fc6ea --- /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 the 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/class_ConsoleOutput.php b/inc/classes/main/output/class_ConsoleOutput.php index dfba40dce..b1cae5c40 100644 --- a/inc/classes/main/output/class_ConsoleOutput.php +++ b/inc/classes/main/output/class_ConsoleOutput.php @@ -5,7 +5,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -41,19 +41,13 @@ class ConsoleOutput extends BaseFrameworkSystem implements OutputStreamer { protected function __construct () { // Call parent constructor parent::__construct(__CLASS__); - - // Set description - $this->setObjectDescription("Console output class"); - - // Create an unique ID - $this->generateUniqueId(); } /** * 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 + * @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 @@ -77,7 +71,7 @@ class ConsoleOutput extends BaseFrameworkSystem implements OutputStreamer { /** * Getter for an instance of this class * - * @return $consoleInstance An instance of this class + * @return $consoleInstance An instance of this class */ public final static function getInstance() { if (is_null(self::$consoleInstance)) { @@ -90,7 +84,7 @@ class ConsoleOutput extends BaseFrameworkSystem implements OutputStreamer { /** * Output the code * - * @param $outStream Something we shall sent to the console + * @param $outStream Something we shall sent to the console * @return void */ public final function output ($outStream=false) { @@ -108,8 +102,8 @@ class ConsoleOutput extends BaseFrameworkSystem implements OutputStreamer { /** * Assigns a variable for output * - * @param $var The variable we shall assign - * @param $value The value to store in the variable + * @param $var The variable we shall assign + * @param $value The value to store in the variable * @return void */ public function assignVariable ($var, $value) { diff --git a/inc/classes/main/output/class_WebOutput.php b/inc/classes/main/output/class_WebOutput.php index 5b4f58838..7a508058d 100644 --- a/inc/classes/main/output/class_WebOutput.php +++ b/inc/classes/main/output/class_WebOutput.php @@ -5,7 +5,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -36,12 +36,6 @@ class WebOutput extends BaseFrameworkSystem implements OutputStreamer, Registera protected function __construct () { // Call parent constructor parent::__construct(__CLASS__); - - // Set description - $this->setObjectDescription("Class for web output e.g. XHTML code"); - - // Create an unique ID - $this->generateUniqueId(); } /** @@ -90,7 +84,7 @@ class WebOutput extends BaseFrameworkSystem implements OutputStreamer, Registera * @return void */ public final function output ($outStream=false) { - print $outStream; + print($outStream); } } diff --git a/inc/classes/main/points/.htaccess b/inc/classes/main/points/.htaccess new file mode 100644 index 000000000..3a4288278 --- /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 000000000..6a9d88f17 --- /dev/null +++ b/inc/classes/main/points/class_UserPoints.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 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 + */ + 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()) { + // Load points here - TODO! + $this->partialStub("Load points here for comparison."); + } // END - if + + // Return the result + return $hasRequired; + } +} + +// [EOF] +?> diff --git a/inc/classes/main/reader/class_DefaultNewsReader.php b/inc/classes/main/reader/class_DefaultNewsReader.php index 7fa8ff2e6..4e5dbb105 100644 --- a/inc/classes/main/reader/class_DefaultNewsReader.php +++ b/inc/classes/main/reader/class_DefaultNewsReader.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -19,9 +19,9 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program. If not, see . */ -class DefaultNewsReader extends BaseFrameworkSystem implements ReadableNews { +class DefaultNewsReader extends BaseFrameworkSystem implements ReadableNews, Registerable { /** * Protected constructor * @@ -31,12 +31,6 @@ class DefaultNewsReader extends BaseFrameworkSystem implements ReadableNews { // Call parent constructor parent::__construct(__CLASS__); - // Set part description - $this->setObjectDescription("Default news reader"); - - // Create unique ID number - $this->generateUniqueId(); - // Clean up a little $this->removeNumberFormaters(); $this->removeSystemArray(); @@ -66,7 +60,26 @@ class DefaultNewsReader extends BaseFrameworkSystem implements ReadableNews { * @return void */ public function initializeReader () { - // TODO Need to implement this method + // 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); } } diff --git a/inc/classes/main/registration/class_BaseRegistration.php b/inc/classes/main/registration/class_BaseRegistration.php index 79225300e..0cc004045 100644 --- a/inc/classes/main/registration/class_BaseRegistration.php +++ b/inc/classes/main/registration/class_BaseRegistration.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -19,7 +19,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program. If not, see . */ abstract class BaseRegistration extends BaseFrameworkSystem implements UserRegister { /** @@ -97,7 +97,7 @@ abstract class BaseRegistration extends BaseFrameworkSystem implements UserRegis */ protected function executePostFilters () { // Execute all post filters - $this->postRegistrationFilter->processFilters($this->requestInstance, $this->responseInstance); + $this->postRegistrationFilter->processFilters($this->getRequestInstance(), $this->getResponseInstance()); } } diff --git a/inc/classes/main/registry/class_Registry.php b/inc/classes/main/registry/class_Registry.php index 308e89c72..2ca0382d3 100644 --- a/inc/classes/main/registry/class_Registry.php +++ b/inc/classes/main/registry/class_Registry.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -19,7 +19,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program. If not, see . */ class Registry extends BaseFrameworkSystem implements Register { /** @@ -46,12 +46,6 @@ class Registry extends BaseFrameworkSystem implements Register { // Call parent constructor parent::__construct(__CLASS__); - // Set part description - $this->setObjectDescription("Registry class"); - - // Create unique ID number - $this->generateUniqueId(); - // Clean up a little $this->removeNumberFormaters(); $this->removeSystemArray(); diff --git a/inc/classes/main/request/class_HttpRequest.php b/inc/classes/main/request/class_HttpRequest.php index b6f9b95f4..a046f185c 100644 --- a/inc/classes/main/request/class_HttpRequest.php +++ b/inc/classes/main/request/class_HttpRequest.php @@ -1,10 +1,10 @@ * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -43,12 +43,6 @@ class HttpRequest extends BaseFrameworkSystem implements Requestable { // Call parent constructor parent::__construct(__CLASS__); - // Set part description - $this->setObjectDescription("HTTP request"); - - // Create unique ID number - $this->generateUniqueId(); - // Clean up a little $this->removeNumberFormaters(); $this->removeSystemArray(); @@ -86,13 +80,12 @@ class HttpRequest extends BaseFrameworkSystem implements Requestable { * 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 */ public function isRequestElementSet ($element) { // Is this element found? if (!isset($this->requestData[$element])) { - // Then throw an exception - throw new MissingArrayElementsException(array($this, 'requestData', $element), self::EXCEPTION_MISSING_ELEMENT); + // Then return false + return false; } // END - if // All clear @@ -110,13 +103,14 @@ class HttpRequest extends BaseFrameworkSystem implements Requestable { // Initialize value $value = null; - try { - if ($this->isRequestElementSet($element)) { - $value = $this->requestData[$element]; - } // END - if - } catch (MissingArrayElementsException $e) { - // Do nothing here - } + // 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; diff --git a/inc/classes/main/resolver/action/.htaccess b/inc/classes/main/resolver/action/.htaccess new file mode 100644 index 000000000..3a4288278 --- /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 000000000..0f41a35df --- /dev/null +++ b/inc/classes/main/resolver/action/class_BaseActionResolver.php @@ -0,0 +1,139 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General 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 = $actionName; + } + + /** + * Getter for action name + * + * @return $actionName Last validated action name + */ + protected 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 the 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 + + // Debug output + //* DEBUG: */ $this->debugBackTrace(); + + // 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 + * @throws InvalidActionException Thrown if even the default + * action class is missing (bad!) + */ + 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 000000000..3a4288278 --- /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 000000000..83f5ddd77 --- /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 the default action is not set + * @throws InvalidActionException Thrown if the 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)) { + // 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 the action is valid + if (!$this->isActionValid($actionName)) { + // 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 the action is valid + if (!$this->isActionValid($actionName)) { + // 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 index 9345109a8..07e19662f 100644 --- a/inc/classes/main/resolver/class_BaseResolver.php +++ b/inc/classes/main/resolver/class_BaseResolver.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -23,28 +23,24 @@ */ class BaseResolver extends BaseFrameworkSystem { /** - * Validated command name + * Class name */ - private $commandName = ""; + private $className = ""; - /** - * Prefix for local, remote or other resolver - */ - private $commandPrefix = ""; - - /** - * A controller instance - */ - private $controllerInstance = null; + // 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 ($class) { + protected function __construct ($className) { // Call parent constructor - parent::__construct($class); + parent::__construct($className); // Clean up a little $this->removeNumberFormaters(); @@ -52,94 +48,22 @@ class BaseResolver extends BaseFrameworkSystem { } /** - * Setter for controller instance (this surely breaks a bit the MVC patterm) + * Setter for class name * - * @param $controllerInstance An instance of the controller + * @param $className Name of the class * @return void */ - public final function setControllerInstance (Controller $controllerInstance) { - $this->controllerInstance = $controllerInstance; + protected final function setClassName ($className) { + $this->className = $className; } /** - * Getter for controller instance (this surely breaks a bit the MVC patterm) + * Getter for class name * - * @return $controllerInstance An instance of the controller + * @return $className Name of the class */ - public final function getControllerInstance () { - return $this->controllerInstance; - } - - /** - * 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; - } - - /** - * Setter for command prefix - * - * @param $commandPrefix Last validated commandPrefix - * @return void - */ - protected final function setCommandPrefix ($commandPrefix) { - $this->commandPrefix = $commandPrefix; - } - - /** - * 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 the 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 - $class = sprintf("%s%sCommand", - $this->commandPrefix, - $this->convertToClassName($commandName) - ); - - // Is this class already loaded? - if (class_exists($class)) { - // This class does exist. :-) - $isValid = true; - } - - // Debug output - //echo "----- ".__METHOD__." -----
\n"; - //print($class."
");
-		//debug_print_backtrace();
-		//var_dump($isValid);
-		//print("
"); - - // Set command name - $this->setCommandName($commandName); - - // Return the result - return $isValid; + public final function getClassName () { + return $this->className; } } diff --git a/inc/classes/main/resolver/command/.htaccess b/inc/classes/main/resolver/command/.htaccess new file mode 100644 index 000000000..3a4288278 --- /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 000000000..f26d351fa --- /dev/null +++ b/inc/classes/main/resolver/command/class_BaseCommandResolver.php @@ -0,0 +1,140 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General 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 = ""; + + /** + * A controller instance + */ + private $controllerInstance = null; + + /** + * 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; + } + + /** + * 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; + } + + /** + * 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 the 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 + + // Debug output + //* DEBUG: */ $this->debugBackTrace(); + + // 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 000000000..3a4288278 --- /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 000000000..ed8492c75 --- /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 the default command is not set + * @throws InvalidCommandException Thrown if the 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)) { + // 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 the command is valid + if (!$this->isCommandValid($commandName)) { + // 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 the command is valid + if (!$this->isCommandValid($commandName)) { + // 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 000000000..3a4288278 --- /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_WebCommandResolver.php b/inc/classes/main/resolver/command/web/class_WebCommandResolver.php new file mode 100644 index 000000000..165d2f788 --- /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 the default command is not set + * @throws InvalidCommandException Thrown if the 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)) { + // 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)) { + // 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)) { + // 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 000000000..3a4288278 --- /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 000000000..2548b4f70 --- /dev/null +++ b/inc/classes/main/resolver/controller/class_BaseControllerResolver.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 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 the given controller is not set + * @throws DefaultControllerException If the 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) { + // 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 + + // Debug output + //* DEBUG: */ $this->debugBackTrace(); + + // 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 000000000..3a4288278 --- /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 000000000..157a98c60 --- /dev/null +++ b/inc/classes/main/resolver/controller/image/class_ImageControllerResolver.php @@ -0,0 +1,164 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General 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 the default command is not set + * @throws InvalidControllerException Thrown if the 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)) { + // 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) { + // Debug message + //* DEBUG: */ $this->debugBackTrace(); + + // 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 000000000..3a4288278 --- /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 000000000..2446e6dc7 --- /dev/null +++ b/inc/classes/main/resolver/controller/web/class_WebControllerResolver.php @@ -0,0 +1,170 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General 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 the default command is not set + * @throws InvalidControllerException Thrown if the 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)) { + // 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) { + // Debug message + //* DEBUG: */ $this->debugBackTrace(); + + // 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 + + // Initiate the resolver and controller + $resolverInstance = ObjectFactory::createObjectByConfiguredName('web_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/web/class_WebCommandResolver.php b/inc/classes/main/resolver/web/class_WebCommandResolver.php index f4b87a2b3..4b8a3bacf 100644 --- a/inc/classes/main/resolver/web/class_WebCommandResolver.php +++ b/inc/classes/main/resolver/web/class_WebCommandResolver.php @@ -36,12 +36,6 @@ class WebCommandResolver extends BaseResolver implements CommandResolver { // Call parent constructor parent::__construct(__CLASS__); - // Set part description - $this->setObjectDescription("Resolver for local web commands"); - - // Create unique ID number - $this->generateUniqueId(); - // Set prefix to "Web" $this->setCommandPrefix("Web"); } diff --git a/inc/classes/main/resolver/web/class_WebControllerResolver.php b/inc/classes/main/resolver/web/class_WebControllerResolver.php index 0585196bc..60dfcfe0f 100644 --- a/inc/classes/main/resolver/web/class_WebControllerResolver.php +++ b/inc/classes/main/resolver/web/class_WebControllerResolver.php @@ -41,12 +41,6 @@ class WebControllerResolver extends BaseResolver implements ControllerResolver { // Call parent constructor parent::__construct(__CLASS__); - // Set part description - $this->setObjectDescription("Resolver for local web controllers"); - - // Create unique ID number - $this->generateUniqueId(); - // Set prefix to "Web" $this->setCommandPrefix("Web"); } diff --git a/inc/classes/main/response/class_HttpResponse.php b/inc/classes/main/response/class_HttpResponse.php index 3fc5d2db1..869d358a4 100644 --- a/inc/classes/main/response/class_HttpResponse.php +++ b/inc/classes/main/response/class_HttpResponse.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -48,7 +48,7 @@ class HttpResponse extends BaseFrameworkSystem implements Responseable { /** * Instance of the template engine */ - private $templateEngine = null; + private $templateInstance = null; /** * Fatal resolved messages from filters and so on @@ -64,12 +64,6 @@ class HttpResponse extends BaseFrameworkSystem implements Responseable { // Call parent constructor parent::__construct(__CLASS__); - // Set part description - $this->setObjectDescription("HTTP response"); - - // Create unique ID number - $this->generateUniqueId(); - // Clean up a little $this->removeNumberFormaters(); $this->removeSystemArray(); @@ -148,7 +142,7 @@ class HttpResponse extends BaseFrameworkSystem implements Responseable { /** * Flushs the cached HTTP response to the outer world * - * @param $foce Wether we shall force the output or abort if headers are + * @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 @@ -213,16 +207,7 @@ class HttpResponse extends BaseFrameworkSystem implements Responseable { * @return void */ public final function initTemplateEngine (ManageableApplication $appInstance) { - $this->templateEngine = $this->prepareTemplateEngine($appInstance); - } - - /** - * Getter for the template engine instance - * - * @return $templateEngine An instance of the used template engine - */ - public final function getTemplateEngine () { - return $this->templateEngine; + $this->setTemplateInstance($this->prepareTemplateInstance($appInstance)); } /** @@ -246,17 +231,22 @@ class HttpResponse extends BaseFrameworkSystem implements Responseable { * @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) { - // @TODO Encryption of cookie data not yet supported } // END - if // For slow browsers set the cookie array element first @@ -271,15 +261,12 @@ class HttpResponse extends BaseFrameworkSystem implements Responseable { $domain = $this->getConfigInstance()->readConfig('cookie_domain'); setcookie($cookieName, $cookieValue, $expires); - // TODO Why are these parameters conflicting? //, $path, $domain, (isset($_SERVER['HTTPS'])) return; - // TODO This will send only one cookie out, the first one. // Now construct the full header $cookieString = $cookieName . "=" . $cookieValue . "; "; $cookieString .= "expires=" . date("D, d-F-Y H:i:s", $expires) . " GMT"; - // TODO Why are these parameters conflicting? // $cookieString .= "; path=".$path."; domain=".$domain; // Set the cookie as a header @@ -345,6 +332,30 @@ class HttpResponse extends BaseFrameworkSystem implements Responseable { 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/class_ImageResponse.php b/inc/classes/main/response/class_ImageResponse.php new file mode 100644 index 000000000..2329af7f3 --- /dev/null +++ b/inc/classes/main/response/class_ImageResponse.php @@ -0,0 +1,380 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General 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 BaseFrameworkSystem implements Responseable { + /** + * 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 = ""; + + /** + * Fatal resolved messages from filters and so on + */ + private $fatalMessages = array(); + + /** + * Instance of the image + */ + private $imageInstance = null; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Clean up a little + $this->removeNumberFormaters(); + $this->removeSystemArray(); + } + + /** + * 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; + } + + /** + * 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 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 function setResponseBody ($output) { + $this->responseBody = $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 + */ + public function flushBuffer ($force=false) { + if ((headers_sent()) && (!$force)) { + // 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 + $this->addHeader('Content-type', 'image/'.$this->imageInstance->getImageType()); + + // Define the charset to be used + //$this->addHeader('Content-Type:', sprintf("text/html; charset=%s", $this->getConfigInstance()->readConfig('header_charset'))); + + foreach ($this->responseHeaders as $name=>$value) { + header("{$name}: {$value}"); + } // 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) { + // Get image content from cache + $imageContent = $this->imageInstance->getContent(); + die($imageContent); + } else { + // Display all error messages + $this->partialStub("Fatal messages are currently unsupported in image response."); + } + + // Clear response header and body + $this->setResponseBody(""); + $this->resetResponseHeaders(); + } + + /** + * 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 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 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 + + // Get the url from config + $url = $this->getConfigInstance()->readConfig($configEntry); + + // 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 + } + + /** + * Setter for image instanxe + * + * @param $imageInstance An instance of an image + * @return void + */ + public final function setImageInstance (BaseImage $imageInstance) { + $this->imageInstance = $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/class_DatabaseResult.php b/inc/classes/main/result/class_DatabaseResult.php index c6a0b1149..f7b1648ff 100644 --- a/inc/classes/main/result/class_DatabaseResult.php +++ b/inc/classes/main/result/class_DatabaseResult.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -19,9 +19,13 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program. If not, see . */ -class DatabaseResult extends BaseFrameworkSystem implements SearchableResult, SeekableIterator { +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 */ @@ -37,6 +41,16 @@ class DatabaseResult extends BaseFrameworkSystem implements SearchableResult, Se */ private $resultArray = array(); + /** + * Array of out-dated entries + */ + private $outDated = array(); + + /** + * Affected rows + */ + private $affectedRows = 0; + /** * Protected constructor * @@ -46,12 +60,6 @@ class DatabaseResult extends BaseFrameworkSystem implements SearchableResult, Se // Call parent constructor parent::__construct(__CLASS__); - // Set part description - $this->setObjectDescription("Database result"); - - // Create unique ID number - $this->generateUniqueId(); - // Clean up a little $this->removeNumberFormaters(); $this->removeSystemArray(); @@ -84,6 +92,26 @@ class DatabaseResult extends BaseFrameworkSystem implements SearchableResult, Se $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 the result is invalid @@ -95,14 +123,11 @@ class DatabaseResult extends BaseFrameworkSystem implements SearchableResult, Se $nextValid = false; // Is the result valid? - if ($this->resultArray['status'] === "ok") { - // The status is fine so let's have a look for the next entry - 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 + 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 @@ -155,7 +180,7 @@ class DatabaseResult extends BaseFrameworkSystem implements SearchableResult, Se $isValid = false; // Check if - if ((isset($this->resultArray['rows'][($this->currentPos + 1)])) && (isset($this->resultArray['rows'][0]))) { + if (($this->ifStatusIsOkay()) && (isset($this->resultArray['rows'][($this->currentPos + 1)])) && (isset($this->resultArray['rows'][0]))) { // All fine! $isValid = true; } // END - if @@ -164,6 +189,15 @@ class DatabaseResult extends BaseFrameworkSystem implements SearchableResult, Se 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 * @@ -179,7 +213,7 @@ class DatabaseResult extends BaseFrameworkSystem implements SearchableResult, Se * @return void */ public function rewind () { - $this->currentPos = 0; + $this->currentPos = -1; } /** @@ -187,9 +221,112 @@ class DatabaseResult extends BaseFrameworkSystem implements SearchableResult, Se * * @param $criteriaInstance The criteria to look inside the data set * @return $result Found result entry + * @todo 0% done */ public function searchEntry (LocalSearchCriteria $criteriaInstance) { - die("OK"); + 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; + } + + /** + * 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) { + // Rewind the pointer + $this->rewind(); + + // Walk through all entries + while ($this->valid()) { + // Get next entry + $this->next(); + $currentEntry = $this->current(); + + // Walk only through out-dated columns + foreach ($this->outDated as $key=>$dummy) { + // Does this key exist? + //* DEBUG: */ echo "outDated: {$key}
\n"; + if (isset($currentEntry[$key])) { + // Then update it + $criteriaInstance->addCriteria($key, $currentEntry[$key]); + } // END - foreach + } // END - foreach + } // END - while } } diff --git a/inc/classes/main/rng/class_RandomNumberGenerator.php b/inc/classes/main/rng/class_RandomNumberGenerator.php index 8875a4ca0..93ba3988e 100644 --- a/inc/classes/main/rng/class_RandomNumberGenerator.php +++ b/inc/classes/main/rng/class_RandomNumberGenerator.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -19,7 +19,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program. If not, see . */ class RandomNumberGenerator extends BaseFrameworkSystem { /** @@ -37,6 +37,11 @@ class RandomNumberGenerator extends BaseFrameworkSystem { */ private $extraSalt = ""; + /** + * Fixed salt for secured hashing + */ + private $fixedSalt = ""; + /** * Maximum length for random string */ @@ -52,12 +57,6 @@ class RandomNumberGenerator extends BaseFrameworkSystem { // Call parent constructor parent::__construct($className); - // Set part description - $this->setObjectDescription("Standard random number generator"); - - // Create unique ID number - $this->generateUniqueId(); - // Clean up a little $this->removeNumberFormaters(); $this->removeSystemArray(); @@ -66,14 +65,15 @@ class RandomNumberGenerator extends BaseFrameworkSystem { /** * 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 () { + public final static function createRandomNumberGenerator (FrameworkInterface $extraInstance = null) { // Get a new instance $rngInstance = new RandomNumberGenerator(); // Initialize the RNG now - $rngInstance->initRng(); + $rngInstance->initRng($extraInstance); // Return the instance return $rngInstance; @@ -82,12 +82,11 @@ class RandomNumberGenerator extends BaseFrameworkSystem { /** * 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 () { - // Seed mt_rand() - mt_srand((double) microtime() * 1000000); - + protected function initRng ($extraInstance) { // Get the prime number from config $this->prime = $this->getConfigInstance()->readConfig('math_prime'); @@ -95,17 +94,29 @@ class RandomNumberGenerator extends BaseFrameworkSystem { // 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") { + 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 - // @TODO Add site for stronger salt! - $this->extraSalt = sha1($serverIp . ":" . getenv('SERVER_SOFTWARE') . ":" . $this->getConfigInstance()->readConfig('date_key') . ":" . serialize($this->getDatabaseInstance()->getConnectionData())); + $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'); @@ -117,7 +128,7 @@ class RandomNumberGenerator extends BaseFrameworkSystem { * @param $length Length of the string, default: 128 * @return $randomString The pseudo-random string */ - public function makeRandomString ($length = -1) { + public function randomString ($length = -1) { // Is the number <1, then fix it to default length if ($length < 1) $length = $this->rndStrLen; @@ -127,10 +138,10 @@ class RandomNumberGenerator extends BaseFrameworkSystem { // And generate it for ($idx = 0; $idx < $length; $idx++) { // Add a random character and add it to our string - $randomString .= chr($this->randomNumnber(0, 255)); + $randomString .= chr($this->randomNumber(0, 255)); } - // Return the random string mixed up + // Return the random string a little mixed up return str_shuffle($randomString); } @@ -140,9 +151,9 @@ class RandomNumberGenerator extends BaseFrameworkSystem { * @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 randomNumnber ($min, $max) { - // @TODO I had a better random number generator here + public function randomNumber ($min, $max) { return mt_rand($min, $max); } @@ -154,6 +165,15 @@ class RandomNumberGenerator extends BaseFrameworkSystem { 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/class_BaseTemplateEngine.php b/inc/classes/main/template/class_BaseTemplateEngine.php new file mode 100644 index 000000000..4db73b617 --- /dev/null +++ b/inc/classes/main/template/class_BaseTemplateEngine.php @@ -0,0 +1,1289 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General 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(); + + /** + * Configuration variables in a simple array + */ + private $configVariables = 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) { + // Is the entry found? + if ($currEntry['name'] == $var) { + // Found! + $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? + if ($this->isVariableAlreadySet($template) !== false) { + // Use that content here + $this->loadedRawData[$template] = $this->readVariable($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; + } + + // 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... + $this->configVariables[$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 = $this->configVariables; + + // 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 the 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()); + } + + /** + * "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/class_TemplateEngine.php b/inc/classes/main/template/class_TemplateEngine.php index fad4cf4a3..afa0cbb06 100644 --- a/inc/classes/main/template/class_TemplateEngine.php +++ b/inc/classes/main/template/class_TemplateEngine.php @@ -122,12 +122,6 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate // Call parent constructor parent::__construct(__CLASS__); - // Set part description - $this->setObjectDescription("Web template engine"); - - // Create unique ID number - $this->generateUniqueId(); - // Clean up a little $this->removeNumberFormaters(); $this->removeSystemArray(); diff --git a/inc/classes/main/template/image/.htaccess b/inc/classes/main/template/image/.htaccess new file mode 100644 index 000000000..3a4288278 --- /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 000000000..210002ffe --- /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(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 000000000..3a4288278 --- /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 000000000..fbe229d7c --- /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(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 000000000..3a4288278 --- /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 000000000..d166f9f01 --- /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(PATH . $cfgInstance->readConfig('compile_output_path')); + + // Return the prepared instance + return $tplInstance; + } +} + +// [EOF] +?> diff --git a/inc/classes/main/user/class_BaseUser.php b/inc/classes/main/user/class_BaseUser.php new file mode 100644 index 000000000..0a3432de3 --- /dev/null +++ b/inc/classes/main/user/class_BaseUser.php @@ -0,0 +1,294 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General 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 = ""; + + /** + * 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 = $userName; + } + + /** + * Setter for email + * + * @param $email The email to set + * @return void + */ + protected final function setEmail ($email) { + $this->email = $email; + } + + /** + * Getter for username + * + * @return $userName The username to get + */ + public final function getUsername () { + return $this->userName; + } + + /** + * 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 + $this->setResultInstance($wrapperInstance->doSelectByCriteria($criteriaInstance)); + } else { + // 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 resultInstance + $this->setResultInstance($wrapperInstance->doSelectByCriteria($criteriaInstance)); + } else { + // 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 the 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; + + // 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 resultInstance + $this->setResultInstance($wrapperInstance->doSelectByCriteria($criteriaInstance)); + + // Search for it + if ($this->getResultInstance()->next()) { + // Get the current entry (can only be one!) + $entry = $this->getResultInstance()->current(); + + // So does the hashes match? + //* DEBUG: */ echo $requestInstance->getRequestElement('pass_hash')."/".$entry['pass_hash']; + $matches = ($requestInstance->getRequestElement('pass_hash') === $entry['pass_hash']); + } // 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/class_User.php b/inc/classes/main/user/class_User.php index cc9c44348..f2ee7df52 100644 --- a/inc/classes/main/user/class_User.php +++ b/inc/classes/main/user/class_User.php @@ -49,12 +49,6 @@ class User extends BaseFrameworkSystem implements ManageableUser, Registerable { // Call parent constructor parent::__construct($class); - // Set part description - $this->setObjectDescription("Generic user class"); - - // Create unique ID number - $this->generateUniqueId(); - // Clean up a little $this->removeNumberFormaters(); $this->removeSystemArray(); diff --git a/inc/classes/main/user/guest/.htaccess b/inc/classes/main/user/guest/.htaccess new file mode 100644 index 000000000..3a4288278 --- /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 000000000..84405dc47 --- /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 the 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 the username exists + if (!$userInstance->ifUsernameExists()) { + // Throw an exception here + throw new UsernameMissingException(array($userInstance, $userName), self::EXCEPTION_USERNAME_NOT_FOUND); + } + + // Return the instance + return $userInstance; + } + + /** + * Creates an instance of this user class by a provided email address. This + * factory method will not check if the 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 000000000..3a4288278 --- /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 000000000..cdb98c1b9 --- /dev/null +++ b/inc/classes/main/user/member/class_Member.php @@ -0,0 +1,174 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General 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 the 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 the username exists + if (!$userInstance->ifUsernameExists()) { + // Throw an exception here + throw new UsernameMissingException(array($userInstance, $userName), self::EXCEPTION_USERNAME_NOT_FOUND); + } + + // Return the instance + return $userInstance; + } + + /** + * Creates an instance of this user class by a provided email address. This + * factory method will not check if the 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 + */ + 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/class_BaseMiddleware.php b/inc/classes/middleware/class_BaseMiddleware.php index 472aa8ba7..48e7b1c24 100644 --- a/inc/classes/middleware/class_BaseMiddleware.php +++ b/inc/classes/middleware/class_BaseMiddleware.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -19,17 +19,18 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program. If not, see . */ class BaseMiddleware extends BaseFrameworkSystem { /** * Protected constructor * + * @param $className Name of the class * @return void */ - protected function __construct ($class) { + protected function __construct ($className) { // Call parent constructor - parent::__construct($class); + parent::__construct($className); // Clean up a little $this->removeNumberFormaters(); diff --git a/inc/classes/middleware/compressor/class_CompressorChannel.php b/inc/classes/middleware/compressor/class_CompressorChannel.php index 346538024..266cf6fac 100644 --- a/inc/classes/middleware/compressor/class_CompressorChannel.php +++ b/inc/classes/middleware/compressor/class_CompressorChannel.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -35,12 +35,6 @@ class CompressorChannel extends BaseMiddleware implements Registerable { protected function __construct () { // Call parent constructor! parent::__construct(__CLASS__); - - // Set description - $this->setObjectDescription("Komprimierungshandler"); - - // Create an unique ID - $this->generateUniqueId(); } /** @@ -71,10 +65,10 @@ class CompressorChannel extends BaseMiddleware implements Registerable { // 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. - $class = substr($dir, 6, -4); + $className = substr($dir, 6, -4); // Get an instance from our object factory - $tempInstance = ObjectFactory::createObjectByName($class); + $tempInstance = ObjectFactory::createObjectByName($className); // Set the compressor $cInstance->setCompressor($tempInstance); diff --git a/inc/classes/middleware/database/class_DatabaseConnection.php b/inc/classes/middleware/database/class_DatabaseConnection.php index fc8ea9135..1d9fe9b43 100644 --- a/inc/classes/middleware/database/class_DatabaseConnection.php +++ b/inc/classes/middleware/database/class_DatabaseConnection.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -19,7 +19,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program. If not, see . */ class DatabaseConnection extends BaseMiddleware implements DatabaseConnector, Registerable { /** @@ -46,12 +46,6 @@ class DatabaseConnection extends BaseMiddleware implements DatabaseConnector, Re protected function __construct() { // Call parent constructor parent::__construct(__CLASS__); - - // Set description - $this->setObjectDescription("Datenbank-Mittelschicht"); - - // Create an unique ID - $this->generateUniqueId(); } // Create new database connection layer @@ -165,6 +159,37 @@ class DatabaseConnection extends BaseMiddleware implements DatabaseConnector, Re // 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/class_DebugMiddleware.php b/inc/classes/middleware/debug/class_DebugMiddleware.php index 1f5e6e0e6..8ee7e0837 100644 --- a/inc/classes/middleware/debug/class_DebugMiddleware.php +++ b/inc/classes/middleware/debug/class_DebugMiddleware.php @@ -6,7 +6,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -21,7 +21,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program. If not, see . */ class DebugMiddleware extends BaseMiddleware implements Registerable { /** @@ -43,12 +43,6 @@ class DebugMiddleware extends BaseMiddleware implements Registerable { // Call parent constructor parent::__construct(__CLASS__); - // Set description - $this->setObjectDescription("Debug-Ausgabe-Instance"); - - // Create an unique ID - $this->generateUniqueId(); - // Set own instance self::$thisInstance = $this; } @@ -110,23 +104,11 @@ class DebugMiddleware extends BaseMiddleware implements Registerable { * @return void */ public final function output ($outStream) { - // Check if the output instance is valid - if (is_null($this->outputInstance)) { - // Debug output instance was not set - throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER); - } elseif (!is_object($this->outputInstance)) { - // The debug output instance is not an object - throw new NoObjectException($this->ouputInstance, self::EXCEPTION_IS_NO_OBJECT); - } elseif (!method_exists($this->outputInstance, 'outputStream')) { - // The required method outputStream() is missing - throw new MissingMethodException(array($this->outputInstance, 'outputStream'), self::EXCEPTION_MISSING_METHOD); - } - // Is the output stream set if (empty($outStream)) { // Initialization phase return; - } + } // END - if // Use the output instance $this->outputInstance->outputStream($outStream); diff --git a/inc/classes/middleware/io/class_FileIoHandler.php b/inc/classes/middleware/io/class_FileIoHandler.php index 99cb434e1..db5797907 100644 --- a/inc/classes/middleware/io/class_FileIoHandler.php +++ b/inc/classes/middleware/io/class_FileIoHandler.php @@ -5,7 +5,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -47,12 +47,6 @@ class FileIoHandler extends BaseMiddleware { // Call parent constructor parent::__construct(__CLASS__); - // Set description - $this->setObjectDescription("Datei-Ein-/Ausgabe-Handler"); - - // Create an unique ID - $this->generateUniqueId(); - // Set own instance self::$thisInstance = $this; } @@ -61,7 +55,7 @@ class FileIoHandler extends BaseMiddleware { * 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 + * @return $ioInstance A prepared instance of FilIOHandler */ public final static function createFileIoHandler () { // Get instance @@ -87,7 +81,8 @@ class FileIoHandler extends BaseMiddleware { /** * Setter for the *real* file input instance * - * @param $inputStream The *real* file-input class + * @param $inputStream The *real* file-input class + * @return void */ public final function setInputStream (FileInputStreamer $inputStream) { $this->inputStream = $inputStream; @@ -105,7 +100,8 @@ class FileIoHandler extends BaseMiddleware { /** * Setter for the *real* file output instance * - * @param $outputStream The *real* file-output class + * @param $outputStream The *real* file-output class + * @return void */ public final function setOutputStream (FileOutputStreamer $outputStream) { $this->outputStream = $outputStream; @@ -123,51 +119,28 @@ class FileIoHandler extends BaseMiddleware { /** * Saves a file with data by using the current output stream * - * @see FileOutputStreamer + * @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(); - // Is it a valid stream? - if (is_null($outInstance)) { - // No class returned - throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER); - } elseif (!is_object($outInstance)) { - // Not an object! ;-( - throw new NoObjectException($outInstance, self::EXCEPTION_IS_NO_OBJECT); - } elseif (!method_exists($outInstance, 'saveFile')) { - // Nope, so throw exception - throw new MissingMethodException(array($outInstance, 'saveFile'), self::EXCEPTION_MISSING_METHOD); - } - // Send the fileName and dataArray to the output handler $outInstance->saveFile($fileName, $dataArray); } /** Loads data from a file over the input handler * - * @see FileInputStreamer + * @return $array Array with the file contents + * @see FileInputStreamer */ public function loadFileContents ($fqfn) { - // Initialize the array - $array = array(); - // Get output stream $inInstance = $this->getInputStream(); - // Is it a valid stream? - if (is_null($inInstance)) { - // No class returned - throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER); - } elseif (!is_object($inInstance)) { - // Not an object! ;-( - throw new NoObjectException($inInstance, self::EXCEPTION_IS_NO_OBJECT); - } elseif (!method_exists($inInstance, 'loadFileContents')) { - // Nope, so throw exception - throw new MissingMethodException(array($inInstance, 'loadFileContents'), self::EXCEPTION_MISSING_METHOD); - } - // Read from the input handler return $inInstance->loadFileContents($fqfn); } diff --git a/inc/classes/third_party/.htaccess b/inc/classes/third_party/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/inc/classes/third_party/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/third_party/api/.htaccess b/inc/classes/third_party/api/.htaccess new file mode 100644 index 000000000..3a4288278 --- /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 000000000..3a4288278 --- /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 000000000..fba746349 --- /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 000000000..3a4288278 --- /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 000000000..4c306dd1a --- /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 000000000..3a4288278 --- /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 000000000..377ac5b34 --- /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 000000000..03851a338 --- /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 000000000..3670fb62b --- /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 000000000..856faafde --- /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 000000000..cac5dfef3 --- /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 000000000..b2f0f3c3e --- /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 000000000..f7c3200af --- /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 000000000..54ac18370 --- /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 000000000..379c44e89 --- /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 000000000..3669f5d23 --- /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 000000000..70c7e3070 --- /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 000000000..794b2a267 --- /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 000000000..4592efc19 --- /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 000000000..e87056e91 --- /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 000000000..38eb78d59 --- /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 000000000..bc46c6727 --- /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 000000000..3a4288278 --- /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 000000000..601d3b810 --- /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 000000000..dbb22985a --- /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 000000000..ae82d2d04 --- /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 000000000..53c20e13c --- /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 000000000..fe60f314b --- /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 000000000..f7d4286d0 --- /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 000000000..bebf632f0 --- /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 000000000..3fd55953b --- /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 000000000..e2bb497a2 --- /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 000000000..13b136fc7 --- /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 000000000..8ef292a52 --- /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 000000000..8eafba767 --- /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 000000000..2fb6a5d25 --- /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 000000000..262b543a4 --- /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 000000000..9a2534151 --- /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 000000000..e2f86ff19 --- /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 000000000..335021719 --- /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 000000000..2e1b14839 --- /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 000000000..e61bbb127 --- /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 000000000..c8f388eec --- /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 000000000..87be4024b --- /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 000000000..4fdecb1bd --- /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 000000000..f7bde2c72 --- /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 000000000..1b7d1b529 --- /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 000000000..4382bc95a --- /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 000000000..f8a48da65 --- /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 000000000..7f65a7670 --- /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 000000000..e62d5ed61 --- /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 000000000..d5781a06b --- /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 000000000..f2b2c7aab --- /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 000000000..ec8456a04 --- /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 000000000..f2149ebb4 --- /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 000000000..7a8113967 --- /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 000000000..fdf40b0b8 --- /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 000000000..22d6f42b8 --- /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 000000000..1d508680c --- /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 index 50571624a..4c7395074 100644 --- a/inc/config.php +++ b/inc/config.php @@ -6,7 +6,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -90,7 +90,7 @@ $cfg->setConfigEntry('application_path', "application"); $cfg->setConfigEntry('compile_output_path', "templates/_compiled/"); // DON'T MISS THE TRAILING SLASH! // CFG: TEMPLATE-ENGINE -$cfg->setConfigEntry('template_class', "TemplateEngine"); +$cfg->setConfigEntry('template_class', "WebTemplateEngine"); // CFG: DEBUG-ENGINE $cfg->setConfigEntry('debug_class', "DebugWebOutput"); @@ -158,6 +158,9 @@ $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"); @@ -176,24 +179,66 @@ $cfg->setConfigEntry('email_validator_class', "EmailValidatorFilter"); // CFG: USERNAME-VALIDATOR $cfg->setConfigEntry('username_validator_class', "UserNameValidatorFilter"); +// CFG: USERNAME-IS-GUEST +$cfg->setConfigEntry('username_is_guest_class', "UserNameIsGuestFilter"); + // CFG: PASSWORD-VALIDATOR $cfg->setConfigEntry('password_validator_class', "PasswordValidatorFilter"); -// CFG: RULES-ACCEPTED-FILTER +// CFG: RULES-ACCEPTED-CLASS $cfg->setConfigEntry('rules_accepted_class', "RulesAcceptedFilter"); -// CFG: CRYPTO-HELPER +// CFG: USERNAME-VERIFIER-CLASS +$cfg->setConfigEntry('username_verifier_class', "UserNameVerifierFilter"); + +// CFG: USER-GUEST-VERIFIER-CLASS +$cfg->setConfigEntry('user_guest_verifier_class', "UserGuestVerifierFilter"); + +// CFG: EMAIL-VERIFIER +$cfg->setConfigEntry('email_verifier_class', "EmailVerifierFilter"); + +// CFG: PASSWORD-VERIFIER-CLASS +$cfg->setConfigEntry('password_verifier_class', "PasswordVerifierFilter"); + +// CFG: PASSWD-GUEST-VERIFIER-CLASS +$cfg->setConfigEntry('passwd_guest_verifier_class', "PasswordGuestVerifierFilter"); + +// CFG: EMAIL-CHANGE-CLASS +$cfg->setConfigEntry('email_change_class', "EmailChangeFilter"); + +// CFG: PASSWORD-CHANGE-CLASS +$cfg->setConfigEntry('password_change_class', "PasswordChangeFilter"); + +// CFG: ACCOUNT-PASSWORD-CLASS +$cfg->setConfigEntry('account_password_class', "AccountPasswordVerifierFilter"); + +// CFG: USER-STATUS-CLASS +$cfg->setConfigEntry('user_status_class', "UserStatusVerifierFilter"); + +// CFG: USER-UNCONFIRMED-CLASS +$cfg->setConfigEntry('user_unconfirmed_class', "UserUnconfirmedVerifierFilter"); + +// CFG: CRYPTO-CLASS $cfg->setConfigEntry('crypto_class', "CryptoHelper"); // CFG: RNG-CLASS $cfg->setConfigEntry('rng_class', "RandomNumberGenerator"); -// CFG: USER-DB-WRAPPER +// CFG: USER-DB-WRAPPER-CLASS $cfg->setConfigEntry('user_db_wrapper_class', "UserDatabaseWrapper"); -// CFG: WEB-CMD-RESOLVER +// 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); @@ -216,7 +261,10 @@ $cfg->setConfigEntry('is_single_server', "Y"); $cfg->setConfigEntry('post_registration_class', "LoginAfterRegistrationAction"); // CFG: USER-CLASS -$cfg->setConfigEntry('user_class', "User"); +$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! @@ -230,5 +278,14 @@ $cfg->setConfigEntry('cookie_domain', $cfg->detectDomain()); // Is mostly the sa // 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"); + // [EOF] ?> diff --git a/inc/config/class_FrameworkConfiguration.php b/inc/config/class_FrameworkConfiguration.php index 50a4ac18a..6bfdfbf7c 100644 --- a/inc/config/class_FrameworkConfiguration.php +++ b/inc/config/class_FrameworkConfiguration.php @@ -8,7 +8,7 @@ * @see ClassLoader * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -39,11 +39,13 @@ class FrameworkConfiguration implements Registerable { private static $cfgInstance = null; // Some constants for the configuration system - const EXCEPTION_CONFIG_ENTRY_IS_EMPTY = 0x040; - const EXCEPTION_CONFIG_ENTRY_WAS_NOT_FOUND = 0x041; + 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 @@ -51,6 +53,9 @@ class FrameworkConfiguration implements Registerable { /** * "Create" a configuration instance + * + * @param $enableDebug Wether enable debug mode (default: off) + * @return $cfgInstance An instance of this configuration class */ public final static function createFrameworkConfiguration ($enableDebug = false) { /** @@ -58,7 +63,7 @@ class FrameworkConfiguration implements Registerable { * through the initial configuration. */ if (is_null(self::$cfgInstance)) { - // CFG: DEBUG-LEVEL + // CFG: ERROR-REPORTING @error_reporting(E_ALL | E_STRICT); /** @@ -99,7 +104,7 @@ class FrameworkConfiguration implements Registerable { // At least 5.1.0 is required for this! if (version_compare(phpversion(), "5.1.0")) { @date_default_timezone_set($zone); - } + } // END - if } /** @@ -128,20 +133,20 @@ class FrameworkConfiguration implements Registerable { // 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", PATH, $inc); - } else { - // Base path is already added - $fqfn = $inc; - } - } + } // END - if + } // END - if // Include them all here require($fqfn); } - } + } // END - if } /** @@ -152,18 +157,15 @@ class FrameworkConfiguration implements Registerable { */ public function defineDatabaseType ($type) { // Is it defined or not? - if (!defined('_DB_TYPE')) { - // Cast to string - $type = (string) $type; - - // Set the constant - define('_DB_TYPE', $type); - } else { + if (defined('_DB_TYPE')) { // Already defined! But we cannot throw an exception here... :( ApplicationEntryPoint::app_die(sprintf("[%s:] Please define the database type only once in your application!", __CLASS__ )); } + + // Set the constant + define('_DB_TYPE', (string) $type); } /** @@ -185,15 +187,15 @@ class FrameworkConfiguration implements Registerable { ApplicationEntryPoint::app_die(sprintf("[%s:] Invalid path (not found) specified. Please make sure it is created.", __CLASS__ )); - } elseif (!defined('PATH')) { - // Set the constant - define('PATH', $path); - } else { + } elseif (defined('PATH')) { // Already defined! But we cannot throw an exception here... :( ApplicationEntryPoint::app_die(sprintf("[%s:] Please define the local file path only once in your application.", __CLASS__ )); } + + // Define path here + define('PATH', $path); } /** @@ -221,7 +223,7 @@ class FrameworkConfiguration implements Registerable { // 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]; @@ -244,7 +246,7 @@ class FrameworkConfiguration implements Registerable { 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; @@ -290,13 +292,40 @@ class FrameworkConfiguration implements Registerable { * @return $fullDomain The detected full domain */ public function detectDomain () { - // Detect the full domain - $fullDomain = htmlentities(strip_tags($_SERVER['SERVER_NAME']), ENT_QUOTES); + // 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; } -} // END - class + + /** + * 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 index 087dced80..0e792b787 100644 --- a/inc/config/config-hubmaster.php +++ b/inc/config/config-hubmaster.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @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 diff --git a/inc/config/config-override.php b/inc/config/config-override.php index b177c57e7..bdc7d9bd0 100644 --- a/inc/config/config-override.php +++ b/inc/config/config-override.php @@ -23,8 +23,8 @@ */ // CFG: DEFAULT-APPLICATION -FrameworkConfiguration::getInstance()->setConfigEntry("default_application", "mxchange"); -FrameworkConfiguration::getInstance()->setConfigEntry("app_name", "mxchange"); +FrameworkConfiguration::getInstance()->setConfigEntry("default_application", "hub"); +FrameworkConfiguration::getInstance()->setConfigEntry("app_name", "hub"); // [EOF] ?> diff --git a/inc/database.php b/inc/database.php index 8dd90e46d..1d381d2e2 100644 --- a/inc/database.php +++ b/inc/database.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -29,8 +29,8 @@ $layer = null; if (!defined('_DB_TYPE')) { // Abort here ApplicationEntryPoint::app_die("[Main:] Please define a database type first!
    -E.g.:
    $GLOBALS['cfg']->defineDatabaseType("local");
    -This will choose the local-file-based database type (layer)"); +E.g.:
    $cfg->defineDatabaseType("local");
    +This will choose the local file-based database layer."); } // Generate FQFN for the database layer diff --git a/inc/database/lib-local.php b/inc/database/lib-local.php index 613d6d2df..7216bedd6 100644 --- a/inc/database/lib-local.php +++ b/inc/database/lib-local.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -26,23 +26,23 @@ try { $layer = LocalFileDatabase::createLocalFileDatabase(PATH . FrameworkConfiguration::getInstance()->readConfig('local_db_path'), FileIoHandler::getInstance()); } catch (SavePathIsEmptyException $e) { - ApplicationEntryPoint::app_die(sprintf("[Main:] Database layer could not be initialized. Reason: %s
    \n", + 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
    \n", + 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
    \n", + 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
    \n", + 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
    \n", + ApplicationEntryPoint::app_die(sprintf("[Main:] Database layer could not be initialized. Reason: %s", $e->getMessage() )); } diff --git a/inc/file_io.php b/inc/file_io.php index afb41612b..0a5ec9b4c 100644 --- a/inc/file_io.php +++ b/inc/file_io.php @@ -6,7 +6,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * diff --git a/inc/includes.php b/inc/includes.php index a9af02b50..41933d954 100644 --- a/inc/includes.php +++ b/inc/includes.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -52,7 +52,7 @@ if (!empty($_GET['app'])) { $application = htmlentities(strip_tags($application), ENT_QUOTES); // Secure it a little more with a reg.exp. -$application = preg_replace('/([^a-z_-])+/i', "", $application); +$application = preg_replace('/([^a-z0-9_-])+/i', "", $application); // Set the application name for later usage $cfg->setConfigEntry('app_name', $application); diff --git a/inc/language.php b/inc/language.php index dc7bd078f..3f7c3859c 100644 --- a/inc/language.php +++ b/inc/language.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @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 diff --git a/inc/loader/class_ClassLoader.php b/inc/loader/class_ClassLoader.php index fa9c771d9..7297c7d19 100644 --- a/inc/loader/class_ClassLoader.php +++ b/inc/loader/class_ClassLoader.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -240,7 +240,7 @@ class ClassLoader { // If the basePath is false it is invalid if ($basePath2 === false) { - // TODO: Do not die here. + /* @todo: Do not die here. */ die("Cannot read {$basePath} !"); } else { // Set base path @@ -309,16 +309,18 @@ class ClassLoader { // 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')) { - // Mark this class as loaded - $this->loadedClasses[] = $this->classes[$fileName]; - // Reset cache $this->classesCached = false; } // END - if @@ -352,6 +354,22 @@ class ClassLoader { 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 index 35b9359f7..83c1372ca 100644 --- a/inc/output.php +++ b/inc/output.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * diff --git a/inc/selector.php b/inc/selector.php index c7375687d..a1ae86881 100644 --- a/inc/selector.php +++ b/inc/selector.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * diff --git a/index.php b/index.php index 947baf3c9..9d6174804 100644 --- a/index.php +++ b/index.php @@ -1,7 +1,6 @@ + * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org + * @link http://www.ship-simu.org * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -50,15 +49,17 @@ class ApplicationEntryPoint { /** * The application's emergency exit * - * @param $message The optional message we shall output on exit + * @param $message The optional message we shall output on exit + * @param $code Error code from exception + * @param $extraData Extra information from exceptions * @return void */ - public static function app_die ($message = "") { + public static function app_die ($message = "", $code = false, $extraData = "") { // Is this method already called? if (defined('EMERGENCY_EXIT_CALLED')) { // Then output the text directly die($message); - } + } // END - if // This method shall not be called twice define('EMERGENCY_EXIT_CALLED', true); @@ -70,60 +71,58 @@ class ApplicationEntryPoint { } // Get some instances - $tpl = FrameworkConfiguration::getInstance()->readConfig('tpl_engine'); + $tpl = FrameworkConfiguration::getInstance()->readConfig('template_class'); $lang = LanguageSystem::getInstance(); $io = FileIoHandler::getInstance(); + // Get response instance + $responseInstance = ApplicationHelper::getInstance()->getResponseInstance(); + // Is the template engine loaded? if ((class_exists($tpl)) && (is_object($lang)) && (is_object($io))) { // Use the template engine for putting out (nicer look) the message try { // Get the template instance from our object factory - $tplEngine = ObjectFactory::createObjectByConfiguredName('tpl_engine', array(FrameworkConfiguration::getInstance()->readConfig('tpl_base_path'), $lang, $io)); - } catch (BasePathIsEmptyException $e) { - die(sprintf("[Main:] Could not initialize template engine for this reason: %s", - $e->getMessage() - )); - } catch (InvalidBasePathStringException $e) { - die(sprintf("[Main:] Could not initialize template engine for this reason: %s", - $e->getMessage() - )); - } catch (BasePathIsNoDirectoryException $e) { - die(sprintf("[Main:] Could not initialize template engine for this reason: %s", - $e->getMessage() - )); - } catch (BasePathReadProtectedException $e) { - die(sprintf("[Main:] Could not initialize template engine for this reason: %s", + $templateInstance = ObjectFactory::createObjectByName($tpl, array(FrameworkConfiguration::getInstance()->readConfig('tpl_base_path'), $lang, $io)); + } catch (FrameworkException $e) { + die(sprintf("[Main:] Could not initialize template engine for reason: %s", $e->getMessage() )); } - // Backtrace holen und aufbereiten + // Get and prepare backtrace for output $backtraceArray = debug_backtrace(); $backtrace = ""; foreach ($backtraceArray as $key=>$trace) { if (!isset($trace['file'])) $trace['file'] = __FILE__; - if (!isset($trace['line'])) $trace['line'] = 5; + if (!isset($trace['line'])) $trace['line'] = __LINE__; if (!isset($trace['args'])) $trace['args'] = array(); $backtrace .= "".basename($trace['file']).":".$trace['line'].", ".$trace['function']."(".count($trace['args']).")
    "; - } + } // END - foreach // Assign variables - $tplEngine->assignVariable('message', $message); - $tplEngine->assignVariable('backtrace', $backtrace); - $tplEngine->assignVariable('total_objects', ObjectFactory::getTotal()); + $templateInstance->assignVariable('message', $message); + $templateInstance->assignVariable('code', $code); + $templateInstance->assignVariable('extra', $extraData); + $templateInstance->assignVariable('backtrace', $backtrace); + $templateInstance->assignVariable('total_includes', ClassLoader::getInstance()->getTotal()); + $templateInstance->assignVariable('total_objects', ObjectFactory::getTotal()); + $templateInstance->assignVariable('title', $lang->getMessage('emergency_exit_title')); // Load the template - $tplEngine->loadCodeTemplate('emergency_exit'); + $templateInstance->loadCodeTemplate('emergency_exit'); // Compile the template - $tplEngine->compileTemplate(); + $templateInstance->compileTemplate(); // Compile all variables - $tplEngine->compileVariables(); + $templateInstance->compileVariables(); + + // Transfer data to response + $templateInstance->transferToResponse($responseInstance); - // Output all - $tplEngine->output(); + // Flush the response + $responseInstance->flushBuffer(); // Good bye... exit(); @@ -158,7 +157,6 @@ class ApplicationEntryPoint { // Include the application selector require(PATH . 'inc/selector.php'); - } // END - main() } // END - class diff --git a/package.sh b/package.sh new file mode 100755 index 000000000..25bf0b4d6 --- /dev/null +++ b/package.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +sh ./clear-cache.sh + +echo -n "$0: Packaging... " +zip -9 shipsimu-hub_dev.zip docs/* Doxyfile *.php *.sh > /dev/null 2>&1 +echo -n "." +zip -9r shipsimu-hub_dev.zip application/ db/ devel/ Doxyfile inc/ templates/ tests/ > /dev/null 2>&1 +echo -n "." +zip -d shipsimu-hub_dev.zip docs/warn.log db/*/*.serialized > /dev/null 2>&1 +echo ". done" + +echo "$0: Renaming..." +mv shipsimu-hub_dev.zip shipsimu-hub_dev_`date +%Y%m%d_%H%M%S`.zip + +echo "$0: All done." diff --git a/pdepend.sh b/pdepend.sh new file mode 100755 index 000000000..91852371d --- /dev/null +++ b/pdepend.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +if ! test -e `which pdepend`; then + echo "$0: This script needs PHP_Depend. See URL" + echo "$0: http://www.manuel-pichler.de/pages/pdepend.html for details." +fi + +pdepend --bad-documentation --ignore=db,docs,ship-simu.org \ + --jdepend-chart=test.png --overview-pyramid=pyramid.png \ + --summary-xml=summary.xml --jdepend-xml=jdepend.xml . -- 2.39.5