1 | <?php |
||
18 | class SettingFormProcess extends Form |
||
19 | { |
||
20 | const LOGO_FILENAME = 'logo.png'; |
||
21 | const MIN_CSRF_TOKEN_LIFETIME = 10; |
||
22 | const LOGO_WIDTH = 50; |
||
23 | const LOGO_HEIGHT = 45; |
||
24 | const MAX_WATERMARK_SIZE = 5; |
||
25 | const DEFAULT_BROWSER_HEX_CODE = '#000000'; |
||
26 | |||
27 | /** @var boolean */ |
||
28 | private $bIsErr = false; |
||
29 | |||
30 | /** @var array */ |
||
31 | private static $aSettingFields = [ |
||
32 | // General Settings |
||
33 | 'site_name' => 'siteName', |
||
34 | 'default_template' => 'defaultTemplate', |
||
35 | 'default_sys_module' => 'defaultSysModule', |
||
36 | 'default_language' => 'defaultLanguage', |
||
37 | 'map_type' => 'mapType', |
||
38 | 'profile_with_avatars' => 'profileWithAvatarSet', |
||
39 | 'splash_page' => 'splashPage', |
||
40 | 'bg_splash_vid' => 'bgSplashVideo', |
||
41 | 'users_block' => 'usersBlock', |
||
42 | 'number_profile_splash_page' => 'numberProfileSplashPage', |
||
43 | 'full_ajax_site' => 'fullAjaxSite', |
||
44 | 'site_status' => 'siteStatus', |
||
45 | 'social_media_widgets' => 'socialMediaWidgets', |
||
46 | 'disclaimer' => 'disclaimer', |
||
47 | 'cookie_consent_bar' => 'cookieConsentBar', |
||
48 | 'display_powered_by_link' => 'displayPoweredByLink', |
||
49 | 'is_software_news_feed' => 'isSoftwareNewsFeed', |
||
50 | |||
51 | |||
52 | 'email_name' => 'emailName', |
||
53 | 'admin_email' => 'adminEmail', |
||
54 | 'feedback_email' => 'feedbackEmail', |
||
55 | 'return_email' => 'returnEmail', |
||
56 | |||
57 | // Registration |
||
58 | 'user_activation_type' => 'userActivationType', |
||
59 | 'aff_activation_type' => 'affActivationType', |
||
60 | 'min_username_length' => 'minUsernameLength', |
||
61 | 'max_username_length' => 'maxUsernameLength', |
||
62 | 'min_age_registration' => 'minAgeRegistration', |
||
63 | 'max_age_registration' => 'maxAgeRegistration', |
||
64 | 'require_registration_avatar' => 'requireRegistrationAvatar', |
||
65 | 'default_membership_group_id' => 'defaultMembershipGroupId', |
||
66 | |||
67 | // Picture and Video |
||
68 | 'watermark_text_image' => 'watermarkTextImage', |
||
69 | 'size_watermark_text_image' => 'sizeWatermarkTextImage', |
||
70 | 'default_video' => 'defaultVideo', |
||
71 | 'autoplay_video' => 'autoplayVideo', |
||
72 | |||
73 | // Moderation |
||
74 | 'avatar_manual_approval' => 'avatarManualApproval', |
||
75 | 'bg_profile_manual_approval' => 'bgProfileManualApproval', |
||
76 | 'note_manual_approval' => 'noteManualApproval', |
||
77 | 'picture_manual_approval' => 'pictureManualApproval', |
||
78 | 'nudity_filter' => 'nudityFilter', |
||
79 | 'video_manual_approval' => 'videoManualApproval', |
||
80 | 'webcam_picture_manual_approval' => 'webcamPictureManualApproval', |
||
81 | |||
82 | // Security |
||
83 | 'min_password_length' => 'minPasswordLength', |
||
84 | 'max_password_length' => 'maxPasswordLength', |
||
85 | 'is_user_login_attempt' => 'isUserLoginAttempt', |
||
86 | 'is_affiliate_login_attempt' => 'isAffiliateLoginAttempt', |
||
87 | 'is_admin_login_attempt' => 'isAdminLoginAttempt', |
||
88 | 'max_user_login_attempts' => 'maxUserLoginAttempts', |
||
89 | 'max_affiliate_login_attempts' => 'maxAffiliateLoginAttempts', |
||
90 | 'max_admin_login_attempts' => 'maxAdminLoginAttempts', |
||
91 | 'login_user_attempt_time' => 'loginUserAttemptTime', |
||
92 | 'login_affiliate_attempt_time' => 'loginAffiliateAttemptTime', |
||
93 | 'login_admin_attempt_time' => 'loginAdminAttemptTime', |
||
94 | 'send_report_mail' => 'sendReportMail', |
||
95 | 'ip_login' => 'ipLogin', |
||
96 | 'ban_word_replace' => 'banWordReplace', |
||
97 | 'security_token_forms' => 'securityToken', |
||
98 | 'security_token_lifetime' => 'securityTokenLifetime', |
||
99 | 'stop_DDoS' => 'DDoS', |
||
100 | |||
101 | // Spam |
||
102 | 'time_delay_user_registration' => 'timeDelayUserRegistration', |
||
103 | 'time_delay_aff_registration' => 'timeDelayAffRegistration', |
||
104 | 'time_delay_send_note' => 'timeDelaySendNote', |
||
105 | 'time_delay_send_mail' => 'timeDelaySendMail', |
||
106 | 'time_delay_send_comment' => 'timeDelaySendComment', |
||
107 | 'time_delay_send_forum_topic' => 'timeDelaySendForumTopic', |
||
108 | 'time_delay_send_forum_msg' => 'timeDelaySendForumMsg', |
||
109 | |||
110 | // Captcha |
||
111 | 'captcha_complexity' => 'captchaComplexity', |
||
112 | 'captcha_case_sensitive' => 'captchaCaseSensitive', |
||
113 | 'is_captcha_user_signup' => 'isCaptchaUserSignup', |
||
114 | 'is_captcha_affiliate_signup' => 'isCaptchaAffiliateSignup', |
||
115 | 'is_captcha_mail' => 'isCaptchaMail', |
||
116 | 'is_captcha_comment' => 'isCaptchaComment', |
||
117 | 'is_captcha_forum' => 'isCaptchaForum', |
||
118 | 'is_captcha_note' => 'isCaptchaNote', |
||
119 | 'clean_msg' => 'cleanMsg', |
||
120 | 'clean_comment' => 'cleanComment', |
||
121 | 'clean_messenger' => 'cleanMessenger', |
||
122 | |||
123 | // Design |
||
124 | 'background_color' => 'backgroundColor', |
||
125 | 'text_color' => 'textColor', |
||
126 | 'link_color' => 'linkColor', |
||
127 | 'footer_link_color' => 'footerLinkColor', |
||
128 | 'link_hover_color' => 'linkHoverColor', |
||
129 | |||
130 | // API |
||
131 | 'google_api_key' => 'googleApiKey', |
||
132 | 'ip_api' => 'ipApi', |
||
133 | 'chat_api' => 'chatApi', |
||
134 | 'chatroulette_api' => 'chatrouletteApi', |
||
135 | |||
136 | // Automation |
||
137 | 'cron_security_hash' => 'cronSecurityHash', |
||
138 | 'user_timeout' => 'userTimeout' |
||
139 | ]; |
||
140 | |||
141 | public function __construct() |
||
154 | |||
155 | /** |
||
156 | * Update the other "generic" fields (if modified only). |
||
157 | */ |
||
158 | private function updateGenericFields() |
||
228 | |||
229 | /** |
||
230 | * Update Logo (if a new one if uploaded only). |
||
231 | */ |
||
232 | private function updateLogo() |
||
256 | |||
257 | /** |
||
258 | * @param string $sKey |
||
259 | * @param string $sVal |
||
260 | * |
||
261 | * @return bool |
||
262 | * |
||
263 | * @throws Framework\Mvc\Request\WrongRequestMethodException |
||
264 | */ |
||
265 | private function hasDataChanged($sKey, $sVal) |
||
269 | |||
270 | /** |
||
271 | * @return bool |
||
272 | */ |
||
273 | private function noErrors() |
||
277 | } |
||
278 |
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.