@@ -65,26 +65,26 @@ |
||
65 | 65 | $_['macintosh'] = 'Western European (Mac) - macintosh'; |
66 | 66 | $_['Windows-1252'] = 'Western European (Windows) - Windows-1252'; |
67 | 67 | |
68 | -if($modx_charset == 'euc-jp') $_['euc-jp'] = 'Japanese (EUC) - euc-jp'; |
|
69 | -elseif($modx_charset == 'shift_jis') $_['shift_jis'] = 'Japanese (Shift-JIS) - shift_jis'; |
|
70 | -elseif($modx_charset == 'iso-2022-jp') $_['iso-2022-jp'] = 'Japanese (JIS-Allow 1 byte Kana - SO/SI) - iso-2022-jp'; |
|
71 | -elseif($modx_charset == 'csISO2022JP') $_['csISO2022JP'] = 'Japanese (JIS-Allow 1 byte Kana) - csISO2022JP'; |
|
72 | -elseif($modx_charset == 'EUC-CN') $_['EUC-CN'] = 'Chinese Simplified (EUC) - EUC-CN'; |
|
73 | -elseif($modx_charset == 'hz-gb-2312') $_['hz-gb-2312'] = 'Chinese Simplified (HZ) - hz-gb-2312'; |
|
74 | -elseif($modx_charset == 'x-mac-chinesesimp') $_['x-mac-chinesesimp'] = 'Chinese Simplified (Mac) - x-mac-chinesesimp'; |
|
75 | -elseif($modx_charset == 'x-Chinese-CNS') $_['x-Chinese-CNS'] = 'Chinese Traditional (CNS) - x-Chinese-CNS'; |
|
76 | -elseif($modx_charset == 'x-Chinese-Eten') $_['x-Chinese-Eten'] = 'Chinese Traditional (Eten) - x-Chinese-Eten'; |
|
77 | -elseif($modx_charset == 'x-mac-chinesetrad') $_['x-mac-chinesetrad'] = 'Chinese Traditional (Mac) - x-mac-chinesetrad'; |
|
78 | -elseif($modx_charset == 'ks_c_5601-1987') $_['ks_c_5601-1987'] = 'Korean - ks_c_5601-1987'; |
|
79 | -elseif($modx_charset == 'euc-kr') $_['euc-kr'] = 'Korean (EUC) - euc-kr'; |
|
80 | -elseif($modx_charset == 'iso-2022-kr') $_['iso-2022-kr'] = 'Korean (ISO) - iso-2022-kr'; |
|
81 | -elseif($modx_charset == 'Johab') $_['Johab'] = 'Korean (Johab) - Johab'; |
|
82 | -elseif($modx_charset == 'x-mac-korean') $_['x-mac-korean'] = 'Korean (Mac) - x-mac-korean'; |
|
68 | +if ($modx_charset == 'euc-jp') $_['euc-jp'] = 'Japanese (EUC) - euc-jp'; |
|
69 | +elseif ($modx_charset == 'shift_jis') $_['shift_jis'] = 'Japanese (Shift-JIS) - shift_jis'; |
|
70 | +elseif ($modx_charset == 'iso-2022-jp') $_['iso-2022-jp'] = 'Japanese (JIS-Allow 1 byte Kana - SO/SI) - iso-2022-jp'; |
|
71 | +elseif ($modx_charset == 'csISO2022JP') $_['csISO2022JP'] = 'Japanese (JIS-Allow 1 byte Kana) - csISO2022JP'; |
|
72 | +elseif ($modx_charset == 'EUC-CN') $_['EUC-CN'] = 'Chinese Simplified (EUC) - EUC-CN'; |
|
73 | +elseif ($modx_charset == 'hz-gb-2312') $_['hz-gb-2312'] = 'Chinese Simplified (HZ) - hz-gb-2312'; |
|
74 | +elseif ($modx_charset == 'x-mac-chinesesimp') $_['x-mac-chinesesimp'] = 'Chinese Simplified (Mac) - x-mac-chinesesimp'; |
|
75 | +elseif ($modx_charset == 'x-Chinese-CNS') $_['x-Chinese-CNS'] = 'Chinese Traditional (CNS) - x-Chinese-CNS'; |
|
76 | +elseif ($modx_charset == 'x-Chinese-Eten') $_['x-Chinese-Eten'] = 'Chinese Traditional (Eten) - x-Chinese-Eten'; |
|
77 | +elseif ($modx_charset == 'x-mac-chinesetrad') $_['x-mac-chinesetrad'] = 'Chinese Traditional (Mac) - x-mac-chinesetrad'; |
|
78 | +elseif ($modx_charset == 'ks_c_5601-1987') $_['ks_c_5601-1987'] = 'Korean - ks_c_5601-1987'; |
|
79 | +elseif ($modx_charset == 'euc-kr') $_['euc-kr'] = 'Korean (EUC) - euc-kr'; |
|
80 | +elseif ($modx_charset == 'iso-2022-kr') $_['iso-2022-kr'] = 'Korean (ISO) - iso-2022-kr'; |
|
81 | +elseif ($modx_charset == 'Johab') $_['Johab'] = 'Korean (Johab) - Johab'; |
|
82 | +elseif ($modx_charset == 'x-mac-korean') $_['x-mac-korean'] = 'Korean (Mac) - x-mac-korean'; |
|
83 | 83 | |
84 | 84 | $tpl = '<option value="%s" %s>%s</option>'; |
85 | 85 | $options = array(); |
86 | -foreach($_ as $value=>$label) { |
|
87 | - $selected = $value===$modx_charset ? 'selected' : ''; |
|
86 | +foreach ($_ as $value=>$label) { |
|
87 | + $selected = $value === $modx_charset ? 'selected' : ''; |
|
88 | 88 | $options[] = sprintf($tpl, $value, $selected, $label); |
89 | 89 | } |
90 | 90 | echo implode("\n", $options); |
@@ -5,14 +5,14 @@ discard block |
||
5 | 5 | |
6 | 6 | // PROCESSOR FIRST |
7 | 7 | if($_SESSION['mgrRole'] == 1) { |
8 | - if($_REQUEST['b'] == 'resetSysfilesChecksum' && $modx->hasPermission('settings')) { |
|
9 | - $current = $modx->manager->getSystemChecksum($modx->config['check_files_onlogin']); |
|
10 | - if(!empty($current)) { |
|
11 | - $modx->manager->setSystemChecksum($current); |
|
12 | - $modx->clearCache('full'); |
|
13 | - $modx->config['sys_files_checksum'] = $current; |
|
14 | - }; |
|
15 | - } |
|
8 | + if($_REQUEST['b'] == 'resetSysfilesChecksum' && $modx->hasPermission('settings')) { |
|
9 | + $current = $modx->manager->getSystemChecksum($modx->config['check_files_onlogin']); |
|
10 | + if(!empty($current)) { |
|
11 | + $modx->manager->setSystemChecksum($current); |
|
12 | + $modx->clearCache('full'); |
|
13 | + $modx->config['sys_files_checksum'] = $current; |
|
14 | + }; |
|
15 | + } |
|
16 | 16 | } |
17 | 17 | |
18 | 18 | // NOW CHECK CONFIG |
@@ -20,15 +20,15 @@ discard block |
||
20 | 20 | |
21 | 21 | $sysfiles_check = $modx->manager->checkSystemChecksum(); |
22 | 22 | if ($sysfiles_check!=='0'){ |
23 | - $warningspresent = 1; |
|
24 | - $warnings[] = array($_lang['configcheck_sysfiles_mod']); |
|
23 | + $warningspresent = 1; |
|
24 | + $warnings[] = array($_lang['configcheck_sysfiles_mod']); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | if (is_writable("includes/config.inc.php")){ |
28 | 28 | // Warn if world writable |
29 | 29 | if(@fileperms('includes/config.inc.php') & 0x0002) { |
30 | - $warningspresent = 1; |
|
31 | - $warnings[] = array($_lang['configcheck_configinc']); |
|
30 | + $warningspresent = 1; |
|
31 | + $warnings[] = array($_lang['configcheck_configinc']); |
|
32 | 32 | } |
33 | 33 | } |
34 | 34 | |
@@ -179,10 +179,10 @@ discard block |
||
179 | 179 | break; |
180 | 180 | case $_lang['configcheck_sysfiles_mod']: |
181 | 181 | $warnings[$i][1] = $_lang["configcheck_sysfiles_mod_msg"]; |
182 | - $warnings[$i][2] = '<ul><li>'. implode('</li><li>', $sysfiles_check) .'</li></ul>'; |
|
183 | - if($modx->hasPermission('settings')) { |
|
184 | - $warnings[$i][2] .= '<ul class="actionButtons" style="float:right"><li><a href="index.php?a=2&b=resetSysfilesChecksum" onclick="return confirm(\'' . $_lang["reset_sysfiles_checksum_alert"] . '\')">' . $_lang["reset_sysfiles_checksum_button"] . '</a></li></ul>'; |
|
185 | - } |
|
182 | + $warnings[$i][2] = '<ul><li>'. implode('</li><li>', $sysfiles_check) .'</li></ul>'; |
|
183 | + if($modx->hasPermission('settings')) { |
|
184 | + $warnings[$i][2] .= '<ul class="actionButtons" style="float:right"><li><a href="index.php?a=2&b=resetSysfilesChecksum" onclick="return confirm(\'' . $_lang["reset_sysfiles_checksum_alert"] . '\')">' . $_lang["reset_sysfiles_checksum_button"] . '</a></li></ul>'; |
|
185 | + } |
|
186 | 186 | if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,3,$warnings[$i][1]." ".implode(', ',$sysfiles_check),$_lang['configcheck_sysfiles_mod']); |
187 | 187 | break; |
188 | 188 | case $_lang['configcheck_lang_difference'] : |
@@ -1,13 +1,13 @@ discard block |
||
1 | 1 | <?php |
2 | -if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
2 | +if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
3 | 3 | die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
4 | 4 | } |
5 | 5 | |
6 | 6 | // PROCESSOR FIRST |
7 | -if($_SESSION['mgrRole'] == 1) { |
|
8 | - if($_REQUEST['b'] == 'resetSysfilesChecksum' && $modx->hasPermission('settings')) { |
|
7 | +if ($_SESSION['mgrRole'] == 1) { |
|
8 | + if ($_REQUEST['b'] == 'resetSysfilesChecksum' && $modx->hasPermission('settings')) { |
|
9 | 9 | $current = $modx->manager->getSystemChecksum($modx->config['check_files_onlogin']); |
10 | - if(!empty($current)) { |
|
10 | + if (!empty($current)) { |
|
11 | 11 | $modx->manager->setSystemChecksum($current); |
12 | 12 | $modx->clearCache('full'); |
13 | 13 | $modx->config['sys_files_checksum'] = $current; |
@@ -19,14 +19,14 @@ discard block |
||
19 | 19 | $warningspresent = 0; |
20 | 20 | |
21 | 21 | $sysfiles_check = $modx->manager->checkSystemChecksum(); |
22 | -if ($sysfiles_check!=='0'){ |
|
22 | +if ($sysfiles_check !== '0') { |
|
23 | 23 | $warningspresent = 1; |
24 | 24 | $warnings[] = array($_lang['configcheck_sysfiles_mod']); |
25 | 25 | } |
26 | 26 | |
27 | -if (is_writable("includes/config.inc.php")){ |
|
27 | +if (is_writable("includes/config.inc.php")) { |
|
28 | 28 | // Warn if world writable |
29 | - if(@fileperms('includes/config.inc.php') & 0x0002) { |
|
29 | + if (@fileperms('includes/config.inc.php') & 0x0002) { |
|
30 | 30 | $warningspresent = 1; |
31 | 31 | $warnings[] = array($_lang['configcheck_configinc']); |
32 | 32 | } |
@@ -42,8 +42,8 @@ discard block |
||
42 | 42 | $warnings[] = array($_lang['configcheck_php_gdzip']); |
43 | 43 | } |
44 | 44 | |
45 | -if(!isset($modx->config['_hide_configcheck_validate_referer']) || $modx->config['_hide_configcheck_validate_referer'] !== '1') { |
|
46 | - if(isset($_SESSION['mgrPermissions']['settings']) && $_SESSION['mgrPermissions']['settings'] == '1') { |
|
45 | +if (!isset($modx->config['_hide_configcheck_validate_referer']) || $modx->config['_hide_configcheck_validate_referer'] !== '1') { |
|
46 | + if (isset($_SESSION['mgrPermissions']['settings']) && $_SESSION['mgrPermissions']['settings'] == '1') { |
|
47 | 47 | if ($modx->db->getValue($modx->db->select('COUNT(setting_value)', $modx->getFullTableName('system_settings'), "setting_name='validate_referer' AND setting_value='0'"))) { |
48 | 48 | $warningspresent = 1; |
49 | 49 | $warnings[] = array($_lang['configcheck_validate_referer']); |
@@ -52,11 +52,11 @@ discard block |
||
52 | 52 | } |
53 | 53 | |
54 | 54 | // check for Template Switcher plugin |
55 | -if(!isset($modx->config['_hide_configcheck_templateswitcher_present']) || $modx->config['_hide_configcheck_templateswitcher_present'] !== '1') { |
|
56 | - if(isset($_SESSION['mgrPermissions']['edit_plugin']) && $_SESSION['mgrPermissions']['edit_plugin'] == '1') { |
|
55 | +if (!isset($modx->config['_hide_configcheck_templateswitcher_present']) || $modx->config['_hide_configcheck_templateswitcher_present'] !== '1') { |
|
56 | + if (isset($_SESSION['mgrPermissions']['edit_plugin']) && $_SESSION['mgrPermissions']['edit_plugin'] == '1') { |
|
57 | 57 | $rs = $modx->db->select('name, disabled', $modx->getFullTableName('site_plugins'), "name IN ('TemplateSwitcher', 'Template Switcher', 'templateswitcher', 'template_switcher', 'template switcher') OR plugincode LIKE '%TemplateSwitcher%'"); |
58 | 58 | $row = $modx->db->getRow($rs); |
59 | - if($row && $row['disabled'] == 0) { |
|
59 | + if ($row && $row['disabled'] == 0) { |
|
60 | 60 | $warningspresent = 1; |
61 | 61 | $warnings[] = array($_lang['configcheck_templateswitcher_present']); |
62 | 62 | $tplName = $row['name']; |
@@ -117,36 +117,36 @@ discard block |
||
117 | 117 | } |
118 | 118 | |
119 | 119 | if (!function_exists('checkSiteCache')) { |
120 | - function checkSiteCache() { |
|
120 | + function checkSiteCache(){ |
|
121 | 121 | global $modx; |
122 | - $checked= true; |
|
123 | - if (file_exists($modx->config['base_path'] . 'assets/cache/siteCache.idx.php')) { |
|
124 | - $checked= @include_once ($modx->config['base_path'] . 'assets/cache/siteCache.idx.php'); |
|
122 | + $checked = true; |
|
123 | + if (file_exists($modx->config['base_path'].'assets/cache/siteCache.idx.php')) { |
|
124 | + $checked = @include_once ($modx->config['base_path'].'assets/cache/siteCache.idx.php'); |
|
125 | 125 | } |
126 | 126 | return $checked; |
127 | 127 | } |
128 | 128 | } |
129 | 129 | |
130 | -if (!is_writable(MODX_BASE_PATH . "assets/cache/")) { |
|
130 | +if (!is_writable(MODX_BASE_PATH."assets/cache/")) { |
|
131 | 131 | $warningspresent = 1; |
132 | 132 | $warnings[] = array($_lang['configcheck_cache']); |
133 | 133 | } |
134 | 134 | |
135 | 135 | if (!checkSiteCache()) { |
136 | 136 | $warningspresent = 1; |
137 | - $warnings[]= array($lang['configcheck_sitecache_integrity']); |
|
137 | + $warnings[] = array($lang['configcheck_sitecache_integrity']); |
|
138 | 138 | } |
139 | 139 | |
140 | -if (!is_writable(MODX_BASE_PATH . "assets/images/")) { |
|
140 | +if (!is_writable(MODX_BASE_PATH."assets/images/")) { |
|
141 | 141 | $warningspresent = 1; |
142 | 142 | $warnings[] = array($_lang['configcheck_images']); |
143 | 143 | } |
144 | 144 | |
145 | -if(strpos($modx->config['rb_base_dir'],MODX_BASE_PATH)!==0) { |
|
145 | +if (strpos($modx->config['rb_base_dir'], MODX_BASE_PATH) !== 0) { |
|
146 | 146 | $warningspresent = 1; |
147 | 147 | $warnings[] = array($_lang['configcheck_rb_base_dir']); |
148 | 148 | } |
149 | -if(strpos($modx->config['filemanager_path'],MODX_BASE_PATH)!==0) { |
|
149 | +if (strpos($modx->config['filemanager_path'], MODX_BASE_PATH) !== 0) { |
|
150 | 150 | $warningspresent = 1; |
151 | 151 | $warnings[] = array($_lang['configcheck_filemanager_path']); |
152 | 152 | } |
@@ -154,36 +154,36 @@ discard block |
||
154 | 154 | // clear file info cache |
155 | 155 | clearstatcache(); |
156 | 156 | |
157 | -if ($warningspresent==1) { |
|
157 | +if ($warningspresent == 1) { |
|
158 | 158 | |
159 | -if(!isset($modx->config['send_errormail'])) $modx->config['send_errormail']='3'; |
|
159 | +if (!isset($modx->config['send_errormail'])) $modx->config['send_errormail'] = '3'; |
|
160 | 160 | $config_check_results = "<h3>".$_lang['configcheck_notok']."</h3>"; |
161 | 161 | |
162 | -for ($i=0;$i<count($warnings);$i++) { |
|
162 | +for ($i = 0; $i < count($warnings); $i++) { |
|
163 | 163 | switch ($warnings[$i][0]) { |
164 | 164 | case $_lang['configcheck_configinc']; |
165 | 165 | $warnings[$i][1] = $_lang['configcheck_configinc_msg']; |
166 | - if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,3,$warnings[$i][1],$_lang['configcheck_configinc']); |
|
166 | + if (!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0, 3, $warnings[$i][1], $_lang['configcheck_configinc']); |
|
167 | 167 | break; |
168 | 168 | case $_lang['configcheck_installer'] : |
169 | 169 | $warnings[$i][1] = $_lang['configcheck_installer_msg']; |
170 | - if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,3,$warnings[$i][1],$_lang['configcheck_installer']); |
|
170 | + if (!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0, 3, $warnings[$i][1], $_lang['configcheck_installer']); |
|
171 | 171 | break; |
172 | 172 | case $_lang['configcheck_cache'] : |
173 | 173 | $warnings[$i][1] = $_lang['configcheck_cache_msg']; |
174 | - if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,2,$warnings[$i][1],$_lang['configcheck_cache']); |
|
174 | + if (!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0, 2, $warnings[$i][1], $_lang['configcheck_cache']); |
|
175 | 175 | break; |
176 | 176 | case $_lang['configcheck_images'] : |
177 | 177 | $warnings[$i][1] = $_lang['configcheck_images_msg']; |
178 | - if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,2,$warnings[$i][1],$_lang['configcheck_images']); |
|
178 | + if (!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0, 2, $warnings[$i][1], $_lang['configcheck_images']); |
|
179 | 179 | break; |
180 | 180 | case $_lang['configcheck_sysfiles_mod']: |
181 | 181 | $warnings[$i][1] = $_lang["configcheck_sysfiles_mod_msg"]; |
182 | - $warnings[$i][2] = '<ul><li>'. implode('</li><li>', $sysfiles_check) .'</li></ul>'; |
|
183 | - if($modx->hasPermission('settings')) { |
|
184 | - $warnings[$i][2] .= '<ul class="actionButtons" style="float:right"><li><a href="index.php?a=2&b=resetSysfilesChecksum" onclick="return confirm(\'' . $_lang["reset_sysfiles_checksum_alert"] . '\')">' . $_lang["reset_sysfiles_checksum_button"] . '</a></li></ul>'; |
|
182 | + $warnings[$i][2] = '<ul><li>'.implode('</li><li>', $sysfiles_check).'</li></ul>'; |
|
183 | + if ($modx->hasPermission('settings')) { |
|
184 | + $warnings[$i][2] .= '<ul class="actionButtons" style="float:right"><li><a href="index.php?a=2&b=resetSysfilesChecksum" onclick="return confirm(\''.$_lang["reset_sysfiles_checksum_alert"].'\')">'.$_lang["reset_sysfiles_checksum_button"].'</a></li></ul>'; |
|
185 | 185 | } |
186 | - if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,3,$warnings[$i][1]." ".implode(', ',$sysfiles_check),$_lang['configcheck_sysfiles_mod']); |
|
186 | + if (!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0, 3, $warnings[$i][1]." ".implode(', ', $sysfiles_check), $_lang['configcheck_sysfiles_mod']); |
|
187 | 187 | break; |
188 | 188 | case $_lang['configcheck_lang_difference'] : |
189 | 189 | $warnings[$i][1] = $_lang['configcheck_lang_difference_msg']; |
@@ -205,18 +205,18 @@ discard block |
||
205 | 205 | break; |
206 | 206 | case $_lang['configcheck_validate_referer'] : |
207 | 207 | $msg = $_lang['configcheck_validate_referer_msg']; |
208 | - $msg .= '<br />' . sprintf($_lang["configcheck_hide_warning"], 'validate_referer'); |
|
208 | + $msg .= '<br />'.sprintf($_lang["configcheck_hide_warning"], 'validate_referer'); |
|
209 | 209 | $warnings[$i][1] = "<span id=\"validate_referer_warning_wrapper\">{$msg}</span>\n"; |
210 | 210 | break; |
211 | 211 | case $_lang['configcheck_templateswitcher_present'] : |
212 | 212 | $msg = $_lang["configcheck_templateswitcher_present_msg"]; |
213 | - if(isset($_SESSION['mgrPermissions']['save_plugin']) && $_SESSION['mgrPermissions']['save_plugin'] == '1') { |
|
214 | - $msg .= '<br />' . $_lang["configcheck_templateswitcher_present_disable"]; |
|
213 | + if (isset($_SESSION['mgrPermissions']['save_plugin']) && $_SESSION['mgrPermissions']['save_plugin'] == '1') { |
|
214 | + $msg .= '<br />'.$_lang["configcheck_templateswitcher_present_disable"]; |
|
215 | 215 | } |
216 | - if(isset($_SESSION['mgrPermissions']['delete_plugin']) && $_SESSION['mgrPermissions']['delete_plugin'] == '1') { |
|
217 | - $msg .= '<br />' . $_lang["configcheck_templateswitcher_present_delete"]; |
|
216 | + if (isset($_SESSION['mgrPermissions']['delete_plugin']) && $_SESSION['mgrPermissions']['delete_plugin'] == '1') { |
|
217 | + $msg .= '<br />'.$_lang["configcheck_templateswitcher_present_delete"]; |
|
218 | 218 | } |
219 | - $msg .= '<br />' . sprintf($_lang["configcheck_hide_warning"], 'templateswitcher_present'); |
|
219 | + $msg .= '<br />'.sprintf($_lang["configcheck_hide_warning"], 'templateswitcher_present'); |
|
220 | 220 | $warnings[$i][1] = "<span id=\"templateswitcher_present_warning_wrapper\">{$msg}</span>\n"; |
221 | 221 | break; |
222 | 222 | case $_lang['configcheck_rb_base_dir'] : |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | $warnings[$i][1] = $_lang['configcheck_default_msg']; |
230 | 230 | } |
231 | 231 | |
232 | - $admin_warning = $_SESSION['mgrRole']!=1 ? $_lang['configcheck_admin'] : "" ; |
|
232 | + $admin_warning = $_SESSION['mgrRole'] != 1 ? $_lang['configcheck_admin'] : ""; |
|
233 | 233 | $config_check_results .= " |
234 | 234 | <fieldset> |
235 | 235 | <p><strong>".$_lang['configcheck_warning']."</strong> '".$warnings[$i][0]."'</p> |
@@ -238,11 +238,11 @@ discard block |
||
238 | 238 | ".(isset($warnings[$i][2]) ? '<div style="padding-left:1em">'.$warnings[$i][2].'</div>' : '')." |
239 | 239 | </fieldset> |
240 | 240 | "; |
241 | - if ($i!=count($warnings)-1) { |
|
241 | + if ($i != count($warnings) - 1) { |
|
242 | 242 | $config_check_results .= "<br />"; |
243 | 243 | } |
244 | 244 | } |
245 | - $_SESSION["mgrConfigCheck"]=true; |
|
245 | + $_SESSION["mgrConfigCheck"] = true; |
|
246 | 246 | } else { |
247 | 247 | $config_check_results = $_lang['configcheck_ok']; |
248 | 248 | } |
@@ -19,12 +19,12 @@ discard block |
||
19 | 19 | $warningspresent = 0; |
20 | 20 | |
21 | 21 | $sysfiles_check = $modx->manager->checkSystemChecksum(); |
22 | -if ($sysfiles_check!=='0'){ |
|
22 | +if ($sysfiles_check!=='0') { |
|
23 | 23 | $warningspresent = 1; |
24 | 24 | $warnings[] = array($_lang['configcheck_sysfiles_mod']); |
25 | 25 | } |
26 | 26 | |
27 | -if (is_writable("includes/config.inc.php")){ |
|
27 | +if (is_writable("includes/config.inc.php")) { |
|
28 | 28 | // Warn if world writable |
29 | 29 | if(@fileperms('includes/config.inc.php') & 0x0002) { |
30 | 30 | $warningspresent = 1; |
@@ -117,7 +117,8 @@ discard block |
||
117 | 117 | } |
118 | 118 | |
119 | 119 | if (!function_exists('checkSiteCache')) { |
120 | - function checkSiteCache() { |
|
120 | + function checkSiteCache() |
|
121 | + { |
|
121 | 122 | global $modx; |
122 | 123 | $checked= true; |
123 | 124 | if (file_exists($modx->config['base_path'] . 'assets/cache/siteCache.idx.php')) { |
@@ -156,26 +157,36 @@ discard block |
||
156 | 157 | |
157 | 158 | if ($warningspresent==1) { |
158 | 159 | |
159 | -if(!isset($modx->config['send_errormail'])) $modx->config['send_errormail']='3'; |
|
160 | +if(!isset($modx->config['send_errormail'])) { |
|
161 | + $modx->config['send_errormail']='3'; |
|
162 | +} |
|
160 | 163 | $config_check_results = "<h3>".$_lang['configcheck_notok']."</h3>"; |
161 | 164 | |
162 | 165 | for ($i=0;$i<count($warnings);$i++) { |
163 | 166 | switch ($warnings[$i][0]) { |
164 | 167 | case $_lang['configcheck_configinc']; |
165 | 168 | $warnings[$i][1] = $_lang['configcheck_configinc_msg']; |
166 | - if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,3,$warnings[$i][1],$_lang['configcheck_configinc']); |
|
169 | + if(!$_SESSION["mgrConfigCheck"]) { |
|
170 | + $modx->logEvent(0,3,$warnings[$i][1],$_lang['configcheck_configinc']); |
|
171 | + } |
|
167 | 172 | break; |
168 | 173 | case $_lang['configcheck_installer'] : |
169 | 174 | $warnings[$i][1] = $_lang['configcheck_installer_msg']; |
170 | - if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,3,$warnings[$i][1],$_lang['configcheck_installer']); |
|
175 | + if(!$_SESSION["mgrConfigCheck"]) { |
|
176 | + $modx->logEvent(0,3,$warnings[$i][1],$_lang['configcheck_installer']); |
|
177 | + } |
|
171 | 178 | break; |
172 | 179 | case $_lang['configcheck_cache'] : |
173 | 180 | $warnings[$i][1] = $_lang['configcheck_cache_msg']; |
174 | - if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,2,$warnings[$i][1],$_lang['configcheck_cache']); |
|
181 | + if(!$_SESSION["mgrConfigCheck"]) { |
|
182 | + $modx->logEvent(0,2,$warnings[$i][1],$_lang['configcheck_cache']); |
|
183 | + } |
|
175 | 184 | break; |
176 | 185 | case $_lang['configcheck_images'] : |
177 | 186 | $warnings[$i][1] = $_lang['configcheck_images_msg']; |
178 | - if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,2,$warnings[$i][1],$_lang['configcheck_images']); |
|
187 | + if(!$_SESSION["mgrConfigCheck"]) { |
|
188 | + $modx->logEvent(0,2,$warnings[$i][1],$_lang['configcheck_images']); |
|
189 | + } |
|
179 | 190 | break; |
180 | 191 | case $_lang['configcheck_sysfiles_mod']: |
181 | 192 | $warnings[$i][1] = $_lang["configcheck_sysfiles_mod_msg"]; |
@@ -183,7 +194,9 @@ discard block |
||
183 | 194 | if($modx->hasPermission('settings')) { |
184 | 195 | $warnings[$i][2] .= '<ul class="actionButtons" style="float:right"><li><a href="index.php?a=2&b=resetSysfilesChecksum" onclick="return confirm(\'' . $_lang["reset_sysfiles_checksum_alert"] . '\')">' . $_lang["reset_sysfiles_checksum_button"] . '</a></li></ul>'; |
185 | 196 | } |
186 | - if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,3,$warnings[$i][1]." ".implode(', ',$sysfiles_check),$_lang['configcheck_sysfiles_mod']); |
|
197 | + if(!$_SESSION["mgrConfigCheck"]) { |
|
198 | + $modx->logEvent(0,3,$warnings[$i][1]." ".implode(', ',$sysfiles_check),$_lang['configcheck_sysfiles_mod']); |
|
199 | + } |
|
187 | 200 | break; |
188 | 201 | case $_lang['configcheck_lang_difference'] : |
189 | 202 | $warnings[$i][1] = $_lang['configcheck_lang_difference_msg']; |
@@ -1,159 +1,159 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | // DISPLAY FORM ELEMENTS |
3 | 3 | function renderFormElement($field_type, $field_id, $default_text = '', $field_elements = '', $field_value = '', $field_style = '', $row = array(), $tvsArray = array()) { |
4 | - global $modx; |
|
5 | - global $_style; |
|
6 | - global $_lang; |
|
7 | - global $content; |
|
8 | - global $which_browser; |
|
4 | + global $modx; |
|
5 | + global $_style; |
|
6 | + global $_lang; |
|
7 | + global $content; |
|
8 | + global $which_browser; |
|
9 | 9 | |
10 | - if(substr($default_text, 0, 6) === '@@EVAL' && $field_value === $default_text) { |
|
11 | - $eval_str = trim(substr($default_text, 7)); |
|
12 | - $default_text = eval($eval_str); |
|
13 | - $field_value = $default_text; |
|
14 | - } |
|
10 | + if(substr($default_text, 0, 6) === '@@EVAL' && $field_value === $default_text) { |
|
11 | + $eval_str = trim(substr($default_text, 7)); |
|
12 | + $default_text = eval($eval_str); |
|
13 | + $field_value = $default_text; |
|
14 | + } |
|
15 | 15 | |
16 | - $field_html = ''; |
|
17 | - $cimode = strpos($field_type, ':'); |
|
18 | - if($cimode === false) { |
|
19 | - switch($field_type) { |
|
16 | + $field_html = ''; |
|
17 | + $cimode = strpos($field_type, ':'); |
|
18 | + if($cimode === false) { |
|
19 | + switch($field_type) { |
|
20 | 20 | |
21 | - case "text": // handler for regular text boxes |
|
22 | - case "rawtext"; // non-htmlentity converted text boxes |
|
23 | - $field_html .= '<input type="text" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $modx->htmlspecialchars($field_value) . '" ' . $field_style . ' tvtype="' . $field_type . '" onchange="documentDirty=true;" style="width:100%" />'; |
|
24 | - break; |
|
25 | - case "email": // handles email input fields |
|
26 | - $field_html .= '<input type="email" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $modx->htmlspecialchars($field_value) . '" ' . $field_style . ' tvtype="' . $field_type . '" onchange="documentDirty=true;" style="width:100%"/>'; |
|
27 | - break; |
|
28 | - case "number": // handles the input of numbers |
|
29 | - $field_html .= '<input type="number" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $modx->htmlspecialchars($field_value) . '" ' . $field_style . ' tvtype="' . $field_type . '" onchange="documentDirty=true;" style="width:100%" onkeyup="this.value=this.value.replace(/[^\d-,.+]/,\'\')"/>'; |
|
30 | - break; |
|
31 | - case "textareamini": // handler for textarea mini boxes |
|
32 | - $field_html .= '<textarea id="tv' . $field_id . '" name="tv' . $field_id . '" cols="40" rows="5" onchange="documentDirty=true;" style="width:100%">' . $modx->htmlspecialchars($field_value) . '</textarea>'; |
|
33 | - break; |
|
34 | - case "textarea": // handler for textarea boxes |
|
35 | - case "rawtextarea": // non-htmlentity convertex textarea boxes |
|
36 | - case "htmlarea": // handler for textarea boxes (deprecated) |
|
37 | - case "richtext": // handler for textarea boxes |
|
38 | - $field_html .= '<textarea id="tv' . $field_id . '" name="tv' . $field_id . '" cols="40" rows="15" onchange="documentDirty=true;" style="width:100%">' . $modx->htmlspecialchars($field_value) . '</textarea>'; |
|
39 | - break; |
|
40 | - case "date": |
|
41 | - $field_id = str_replace(array( |
|
42 | - '-', |
|
43 | - '.' |
|
44 | - ), '_', urldecode($field_id)); |
|
45 | - if($field_value == '') { |
|
46 | - $field_value = 0; |
|
47 | - } |
|
48 | - $field_html .= '<input id="tv' . $field_id . '" name="tv' . $field_id . '" class="DatePicker" type="text" value="' . ($field_value == 0 || !isset($field_value) ? "" : $field_value) . '" onblur="documentDirty=true;" />'; |
|
49 | - $field_html .= ' <a onclick="document.forms[\'mutate\'].elements[\'tv' . $field_id . '\'].value=\'\';document.forms[\'mutate\'].elements[\'tv' . $field_id . '\'].onblur(); return true;" onmouseover="window.status=\'clear the date\'; return true;" onmouseout="window.status=\'\'; return true;" style="cursor:pointer; cursor:hand"><i class="' . $_style["actions_calendar_delete"] . '"></i></a>'; |
|
21 | + case "text": // handler for regular text boxes |
|
22 | + case "rawtext"; // non-htmlentity converted text boxes |
|
23 | + $field_html .= '<input type="text" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $modx->htmlspecialchars($field_value) . '" ' . $field_style . ' tvtype="' . $field_type . '" onchange="documentDirty=true;" style="width:100%" />'; |
|
24 | + break; |
|
25 | + case "email": // handles email input fields |
|
26 | + $field_html .= '<input type="email" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $modx->htmlspecialchars($field_value) . '" ' . $field_style . ' tvtype="' . $field_type . '" onchange="documentDirty=true;" style="width:100%"/>'; |
|
27 | + break; |
|
28 | + case "number": // handles the input of numbers |
|
29 | + $field_html .= '<input type="number" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $modx->htmlspecialchars($field_value) . '" ' . $field_style . ' tvtype="' . $field_type . '" onchange="documentDirty=true;" style="width:100%" onkeyup="this.value=this.value.replace(/[^\d-,.+]/,\'\')"/>'; |
|
30 | + break; |
|
31 | + case "textareamini": // handler for textarea mini boxes |
|
32 | + $field_html .= '<textarea id="tv' . $field_id . '" name="tv' . $field_id . '" cols="40" rows="5" onchange="documentDirty=true;" style="width:100%">' . $modx->htmlspecialchars($field_value) . '</textarea>'; |
|
33 | + break; |
|
34 | + case "textarea": // handler for textarea boxes |
|
35 | + case "rawtextarea": // non-htmlentity convertex textarea boxes |
|
36 | + case "htmlarea": // handler for textarea boxes (deprecated) |
|
37 | + case "richtext": // handler for textarea boxes |
|
38 | + $field_html .= '<textarea id="tv' . $field_id . '" name="tv' . $field_id . '" cols="40" rows="15" onchange="documentDirty=true;" style="width:100%">' . $modx->htmlspecialchars($field_value) . '</textarea>'; |
|
39 | + break; |
|
40 | + case "date": |
|
41 | + $field_id = str_replace(array( |
|
42 | + '-', |
|
43 | + '.' |
|
44 | + ), '_', urldecode($field_id)); |
|
45 | + if($field_value == '') { |
|
46 | + $field_value = 0; |
|
47 | + } |
|
48 | + $field_html .= '<input id="tv' . $field_id . '" name="tv' . $field_id . '" class="DatePicker" type="text" value="' . ($field_value == 0 || !isset($field_value) ? "" : $field_value) . '" onblur="documentDirty=true;" />'; |
|
49 | + $field_html .= ' <a onclick="document.forms[\'mutate\'].elements[\'tv' . $field_id . '\'].value=\'\';document.forms[\'mutate\'].elements[\'tv' . $field_id . '\'].onblur(); return true;" onmouseover="window.status=\'clear the date\'; return true;" onmouseout="window.status=\'\'; return true;" style="cursor:pointer; cursor:hand"><i class="' . $_style["actions_calendar_delete"] . '"></i></a>'; |
|
50 | 50 | |
51 | - break; |
|
52 | - case "dropdown": // handler for select boxes |
|
53 | - $field_html .= '<select id="tv' . $field_id . '" name="tv' . $field_id . '" size="1" onchange="documentDirty=true;">'; |
|
54 | - $index_list = ParseIntputOptions(ProcessTVCommand($field_elements, $field_id, '', 'tvform', $tvsArray)); |
|
55 | - while(list($item, $itemvalue) = each($index_list)) { |
|
56 | - list($item, $itemvalue) = (is_array($itemvalue)) ? $itemvalue : explode("==", $itemvalue); |
|
57 | - if(strlen($itemvalue) == 0) { |
|
58 | - $itemvalue = $item; |
|
59 | - } |
|
60 | - $field_html .= '<option value="' . $modx->htmlspecialchars($itemvalue) . '"' . ($itemvalue == $field_value ? ' selected="selected"' : '') . '>' . $modx->htmlspecialchars($item) . '</option>'; |
|
61 | - } |
|
62 | - $field_html .= "</select>"; |
|
63 | - break; |
|
64 | - case "listbox": // handler for select boxes |
|
65 | - $field_html .= '<select id="tv' . $field_id . '" name="tv' . $field_id . '" onchange="documentDirty=true;" size="8">'; |
|
66 | - $index_list = ParseIntputOptions(ProcessTVCommand($field_elements, $field_id, '', 'tvform', $tvsArray)); |
|
67 | - while(list($item, $itemvalue) = each($index_list)) { |
|
68 | - list($item, $itemvalue) = (is_array($itemvalue)) ? $itemvalue : explode("==", $itemvalue); |
|
69 | - if(strlen($itemvalue) == 0) { |
|
70 | - $itemvalue = $item; |
|
71 | - } |
|
72 | - $field_html .= '<option value="' . $modx->htmlspecialchars($itemvalue) . '"' . ($itemvalue == $field_value ? ' selected="selected"' : '') . '>' . $modx->htmlspecialchars($item) . '</option>'; |
|
73 | - } |
|
74 | - $field_html .= "</select>"; |
|
75 | - break; |
|
76 | - case "listbox-multiple": // handler for select boxes where you can choose multiple items |
|
77 | - $field_value = explode("||", $field_value); |
|
78 | - $field_html .= '<select id="tv' . $field_id . '" name="tv' . $field_id . '[]" multiple="multiple" onchange="documentDirty=true;" size="8">'; |
|
79 | - $index_list = ParseIntputOptions(ProcessTVCommand($field_elements, $field_id, '', 'tvform', $tvsArray)); |
|
80 | - while(list($item, $itemvalue) = each($index_list)) { |
|
81 | - list($item, $itemvalue) = (is_array($itemvalue)) ? $itemvalue : explode("==", $itemvalue); |
|
82 | - if(strlen($itemvalue) == 0) { |
|
83 | - $itemvalue = $item; |
|
84 | - } |
|
85 | - $field_html .= '<option value="' . $modx->htmlspecialchars($itemvalue) . '"' . (in_array($itemvalue, $field_value) ? ' selected="selected"' : '') . '>' . $modx->htmlspecialchars($item) . '</option>'; |
|
86 | - } |
|
87 | - $field_html .= "</select>"; |
|
88 | - break; |
|
89 | - case "url": // handles url input fields |
|
90 | - $urls = array( |
|
91 | - '' => '--', |
|
92 | - 'http://' => 'http://', |
|
93 | - 'https://' => 'https://', |
|
94 | - 'ftp://' => 'ftp://', |
|
95 | - 'mailto:' => 'mailto:' |
|
96 | - ); |
|
97 | - $field_html = '<table border="0" cellspacing="0" cellpadding="0"><tr><td><select id="tv' . $field_id . '_prefix" name="tv' . $field_id . '_prefix" onchange="documentDirty=true;">'; |
|
98 | - foreach($urls as $k => $v) { |
|
99 | - if(strpos($field_value, $v) === false) { |
|
100 | - $field_html .= '<option value="' . $v . '">' . $k . '</option>'; |
|
101 | - } else { |
|
102 | - $field_value = str_replace($v, '', $field_value); |
|
103 | - $field_html .= '<option value="' . $v . '" selected="selected">' . $k . '</option>'; |
|
104 | - } |
|
105 | - } |
|
106 | - $field_html .= '</select></td><td>'; |
|
107 | - $field_html .= '<input type="text" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $modx->htmlspecialchars($field_value) . '" width="100" ' . $field_style . ' onchange="documentDirty=true;" /></td></tr></table>'; |
|
108 | - break; |
|
109 | - case 'checkbox': // handles check boxes |
|
110 | - $values = !is_array($field_value) ? explode('||', $field_value) : $field_value; |
|
111 | - $index_list = ParseIntputOptions(ProcessTVCommand($field_elements, $field_id, '', 'tvform', $tvsArray)); |
|
112 | - $tpl = '<label class="checkbox"><input type="checkbox" value="%s" id="tv_%s" name="tv%s[]" %s onchange="documentDirty=true;" />%s</label><br />'; |
|
113 | - static $i = 0; |
|
114 | - $_ = array(); |
|
115 | - foreach($index_list as $c => $item) { |
|
116 | - if(is_array($item)) { |
|
117 | - $name = trim($item[0]); |
|
118 | - $value = isset($item[1]) ? $item[1] : $name; |
|
119 | - } else { |
|
120 | - $item = trim($item); |
|
121 | - list($name, $value) = (strpos($item, '==') !== false) ? explode('==', $item, 2) : array( |
|
122 | - $item, |
|
123 | - $item |
|
124 | - ); |
|
125 | - } |
|
126 | - $checked = in_array($value, $values) ? ' checked="checked"' : ''; |
|
127 | - $param = array( |
|
128 | - $modx->htmlspecialchars($value), |
|
129 | - $i, |
|
130 | - $field_id, |
|
131 | - $checked, |
|
132 | - $modx->htmlspecialchars($name) |
|
133 | - ); |
|
134 | - $_[] = vsprintf($tpl, $param); |
|
135 | - $i++; |
|
136 | - } |
|
137 | - $field_html = implode("\n", $_); |
|
138 | - break; |
|
139 | - case "option": // handles radio buttons |
|
140 | - $index_list = ParseIntputOptions(ProcessTVCommand($field_elements, $field_id, '', 'tvform', $tvsArray)); |
|
141 | - static $i = 0; |
|
142 | - while(list($item, $itemvalue) = each($index_list)) { |
|
143 | - list($item, $itemvalue) = (is_array($itemvalue)) ? $itemvalue : explode("==", $itemvalue); |
|
144 | - if(strlen($itemvalue) == 0) { |
|
145 | - $itemvalue = $item; |
|
146 | - } |
|
147 | - $field_html .= '<input type="radio" value="' . $modx->htmlspecialchars($itemvalue) . '" id="tv_' . $i . '" name="tv' . $field_id . '" ' . ($itemvalue == $field_value ? 'checked="checked"' : '') . ' onchange="documentDirty=true;" /><label for="tv_' . $i . '" class="radio">' . $item . '</label><br />'; |
|
148 | - $i++; |
|
149 | - } |
|
150 | - break; |
|
151 | - case "image": // handles image fields using htmlarea image manager |
|
152 | - global $_lang; |
|
153 | - global $ResourceManagerLoaded; |
|
154 | - global $content, $use_editor, $which_editor; |
|
155 | - if(!$ResourceManagerLoaded && !(($content['richtext'] == 1 || $modx->manager->action == 4) && $use_editor == 1 && $which_editor == 3)) { |
|
156 | - $field_html .= " |
|
51 | + break; |
|
52 | + case "dropdown": // handler for select boxes |
|
53 | + $field_html .= '<select id="tv' . $field_id . '" name="tv' . $field_id . '" size="1" onchange="documentDirty=true;">'; |
|
54 | + $index_list = ParseIntputOptions(ProcessTVCommand($field_elements, $field_id, '', 'tvform', $tvsArray)); |
|
55 | + while(list($item, $itemvalue) = each($index_list)) { |
|
56 | + list($item, $itemvalue) = (is_array($itemvalue)) ? $itemvalue : explode("==", $itemvalue); |
|
57 | + if(strlen($itemvalue) == 0) { |
|
58 | + $itemvalue = $item; |
|
59 | + } |
|
60 | + $field_html .= '<option value="' . $modx->htmlspecialchars($itemvalue) . '"' . ($itemvalue == $field_value ? ' selected="selected"' : '') . '>' . $modx->htmlspecialchars($item) . '</option>'; |
|
61 | + } |
|
62 | + $field_html .= "</select>"; |
|
63 | + break; |
|
64 | + case "listbox": // handler for select boxes |
|
65 | + $field_html .= '<select id="tv' . $field_id . '" name="tv' . $field_id . '" onchange="documentDirty=true;" size="8">'; |
|
66 | + $index_list = ParseIntputOptions(ProcessTVCommand($field_elements, $field_id, '', 'tvform', $tvsArray)); |
|
67 | + while(list($item, $itemvalue) = each($index_list)) { |
|
68 | + list($item, $itemvalue) = (is_array($itemvalue)) ? $itemvalue : explode("==", $itemvalue); |
|
69 | + if(strlen($itemvalue) == 0) { |
|
70 | + $itemvalue = $item; |
|
71 | + } |
|
72 | + $field_html .= '<option value="' . $modx->htmlspecialchars($itemvalue) . '"' . ($itemvalue == $field_value ? ' selected="selected"' : '') . '>' . $modx->htmlspecialchars($item) . '</option>'; |
|
73 | + } |
|
74 | + $field_html .= "</select>"; |
|
75 | + break; |
|
76 | + case "listbox-multiple": // handler for select boxes where you can choose multiple items |
|
77 | + $field_value = explode("||", $field_value); |
|
78 | + $field_html .= '<select id="tv' . $field_id . '" name="tv' . $field_id . '[]" multiple="multiple" onchange="documentDirty=true;" size="8">'; |
|
79 | + $index_list = ParseIntputOptions(ProcessTVCommand($field_elements, $field_id, '', 'tvform', $tvsArray)); |
|
80 | + while(list($item, $itemvalue) = each($index_list)) { |
|
81 | + list($item, $itemvalue) = (is_array($itemvalue)) ? $itemvalue : explode("==", $itemvalue); |
|
82 | + if(strlen($itemvalue) == 0) { |
|
83 | + $itemvalue = $item; |
|
84 | + } |
|
85 | + $field_html .= '<option value="' . $modx->htmlspecialchars($itemvalue) . '"' . (in_array($itemvalue, $field_value) ? ' selected="selected"' : '') . '>' . $modx->htmlspecialchars($item) . '</option>'; |
|
86 | + } |
|
87 | + $field_html .= "</select>"; |
|
88 | + break; |
|
89 | + case "url": // handles url input fields |
|
90 | + $urls = array( |
|
91 | + '' => '--', |
|
92 | + 'http://' => 'http://', |
|
93 | + 'https://' => 'https://', |
|
94 | + 'ftp://' => 'ftp://', |
|
95 | + 'mailto:' => 'mailto:' |
|
96 | + ); |
|
97 | + $field_html = '<table border="0" cellspacing="0" cellpadding="0"><tr><td><select id="tv' . $field_id . '_prefix" name="tv' . $field_id . '_prefix" onchange="documentDirty=true;">'; |
|
98 | + foreach($urls as $k => $v) { |
|
99 | + if(strpos($field_value, $v) === false) { |
|
100 | + $field_html .= '<option value="' . $v . '">' . $k . '</option>'; |
|
101 | + } else { |
|
102 | + $field_value = str_replace($v, '', $field_value); |
|
103 | + $field_html .= '<option value="' . $v . '" selected="selected">' . $k . '</option>'; |
|
104 | + } |
|
105 | + } |
|
106 | + $field_html .= '</select></td><td>'; |
|
107 | + $field_html .= '<input type="text" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $modx->htmlspecialchars($field_value) . '" width="100" ' . $field_style . ' onchange="documentDirty=true;" /></td></tr></table>'; |
|
108 | + break; |
|
109 | + case 'checkbox': // handles check boxes |
|
110 | + $values = !is_array($field_value) ? explode('||', $field_value) : $field_value; |
|
111 | + $index_list = ParseIntputOptions(ProcessTVCommand($field_elements, $field_id, '', 'tvform', $tvsArray)); |
|
112 | + $tpl = '<label class="checkbox"><input type="checkbox" value="%s" id="tv_%s" name="tv%s[]" %s onchange="documentDirty=true;" />%s</label><br />'; |
|
113 | + static $i = 0; |
|
114 | + $_ = array(); |
|
115 | + foreach($index_list as $c => $item) { |
|
116 | + if(is_array($item)) { |
|
117 | + $name = trim($item[0]); |
|
118 | + $value = isset($item[1]) ? $item[1] : $name; |
|
119 | + } else { |
|
120 | + $item = trim($item); |
|
121 | + list($name, $value) = (strpos($item, '==') !== false) ? explode('==', $item, 2) : array( |
|
122 | + $item, |
|
123 | + $item |
|
124 | + ); |
|
125 | + } |
|
126 | + $checked = in_array($value, $values) ? ' checked="checked"' : ''; |
|
127 | + $param = array( |
|
128 | + $modx->htmlspecialchars($value), |
|
129 | + $i, |
|
130 | + $field_id, |
|
131 | + $checked, |
|
132 | + $modx->htmlspecialchars($name) |
|
133 | + ); |
|
134 | + $_[] = vsprintf($tpl, $param); |
|
135 | + $i++; |
|
136 | + } |
|
137 | + $field_html = implode("\n", $_); |
|
138 | + break; |
|
139 | + case "option": // handles radio buttons |
|
140 | + $index_list = ParseIntputOptions(ProcessTVCommand($field_elements, $field_id, '', 'tvform', $tvsArray)); |
|
141 | + static $i = 0; |
|
142 | + while(list($item, $itemvalue) = each($index_list)) { |
|
143 | + list($item, $itemvalue) = (is_array($itemvalue)) ? $itemvalue : explode("==", $itemvalue); |
|
144 | + if(strlen($itemvalue) == 0) { |
|
145 | + $itemvalue = $item; |
|
146 | + } |
|
147 | + $field_html .= '<input type="radio" value="' . $modx->htmlspecialchars($itemvalue) . '" id="tv_' . $i . '" name="tv' . $field_id . '" ' . ($itemvalue == $field_value ? 'checked="checked"' : '') . ' onchange="documentDirty=true;" /><label for="tv_' . $i . '" class="radio">' . $item . '</label><br />'; |
|
148 | + $i++; |
|
149 | + } |
|
150 | + break; |
|
151 | + case "image": // handles image fields using htmlarea image manager |
|
152 | + global $_lang; |
|
153 | + global $ResourceManagerLoaded; |
|
154 | + global $content, $use_editor, $which_editor; |
|
155 | + if(!$ResourceManagerLoaded && !(($content['richtext'] == 1 || $modx->manager->action == 4) && $use_editor == 1 && $which_editor == 3)) { |
|
156 | + $field_html .= " |
|
157 | 157 | <script type=\"text/javascript\"> |
158 | 158 | /* <![CDATA[ */ |
159 | 159 | var lastImageCtrl; |
@@ -212,18 +212,18 @@ discard block |
||
212 | 212 | } |
213 | 213 | /* ]]> */ |
214 | 214 | </script>"; |
215 | - $ResourceManagerLoaded = true; |
|
216 | - } |
|
217 | - $field_html .= '<input type="text" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $field_value . '" ' . $field_style . ' onchange="documentDirty=true;" /><input type="button" value="' . $_lang['insert'] . '" onclick="BrowseServer(\'tv' . $field_id . '\')" />'; |
|
218 | - break; |
|
219 | - case "file": // handles the input of file uploads |
|
220 | - /* Modified by Timon for use with resource browser */ |
|
221 | - global $_lang; |
|
222 | - global $ResourceManagerLoaded; |
|
223 | - global $content, $use_editor, $which_editor; |
|
224 | - if(!$ResourceManagerLoaded && !(($content['richtext'] == 1 || $modx->manager->action == 4) && $use_editor == 1 && $which_editor == 3)) { |
|
225 | - /* I didn't understand the meaning of the condition above, so I left it untouched ;-) */ |
|
226 | - $field_html .= " |
|
215 | + $ResourceManagerLoaded = true; |
|
216 | + } |
|
217 | + $field_html .= '<input type="text" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $field_value . '" ' . $field_style . ' onchange="documentDirty=true;" /><input type="button" value="' . $_lang['insert'] . '" onclick="BrowseServer(\'tv' . $field_id . '\')" />'; |
|
218 | + break; |
|
219 | + case "file": // handles the input of file uploads |
|
220 | + /* Modified by Timon for use with resource browser */ |
|
221 | + global $_lang; |
|
222 | + global $ResourceManagerLoaded; |
|
223 | + global $content, $use_editor, $which_editor; |
|
224 | + if(!$ResourceManagerLoaded && !(($content['richtext'] == 1 || $modx->manager->action == 4) && $use_editor == 1 && $which_editor == 3)) { |
|
225 | + /* I didn't understand the meaning of the condition above, so I left it untouched ;-) */ |
|
226 | + $field_html .= " |
|
227 | 227 | <script type=\"text/javascript\"> |
228 | 228 | /* <![CDATA[ */ |
229 | 229 | var lastImageCtrl; |
@@ -282,101 +282,101 @@ discard block |
||
282 | 282 | } |
283 | 283 | /* ]]> */ |
284 | 284 | </script>"; |
285 | - $ResourceManagerLoaded = true; |
|
286 | - } |
|
287 | - $field_html .= '<input type="text" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $field_value . '" ' . $field_style . ' onchange="documentDirty=true;" /><input type="button" value="' . $_lang['insert'] . '" onclick="BrowseFileServer(\'tv' . $field_id . '\')" />'; |
|
285 | + $ResourceManagerLoaded = true; |
|
286 | + } |
|
287 | + $field_html .= '<input type="text" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $field_value . '" ' . $field_style . ' onchange="documentDirty=true;" /><input type="button" value="' . $_lang['insert'] . '" onclick="BrowseFileServer(\'tv' . $field_id . '\')" />'; |
|
288 | 288 | |
289 | - break; |
|
289 | + break; |
|
290 | 290 | |
291 | - case 'custom_tv': |
|
292 | - $custom_output = ''; |
|
293 | - /* If we are loading a file */ |
|
294 | - if(substr($field_elements, 0, 5) == "@FILE") { |
|
295 | - $file_name = MODX_BASE_PATH . trim(substr($field_elements, 6)); |
|
296 | - if(!file_exists($file_name)) { |
|
297 | - $custom_output = $file_name . ' does not exist'; |
|
298 | - } else { |
|
299 | - $custom_output = file_get_contents($file_name); |
|
300 | - } |
|
301 | - } elseif(substr($field_elements, 0, 8) == '@INCLUDE') { |
|
302 | - $file_name = MODX_BASE_PATH . trim(substr($field_elements, 9)); |
|
303 | - if(!file_exists($file_name)) { |
|
304 | - $custom_output = $file_name . ' does not exist'; |
|
305 | - } else { |
|
306 | - ob_start(); |
|
307 | - include $file_name; |
|
308 | - $custom_output = ob_get_contents(); |
|
309 | - ob_end_clean(); |
|
310 | - } |
|
311 | - } elseif(substr($field_elements, 0, 6) == "@CHUNK") { |
|
312 | - $chunk_name = trim(substr($field_elements, 7)); |
|
313 | - $chunk_body = $modx->getChunk($chunk_name); |
|
314 | - if($chunk_body == false) { |
|
315 | - $custom_output = $_lang['chunk_no_exist'] . '(' . $_lang['htmlsnippet_name'] . ':' . $chunk_name . ')'; |
|
316 | - } else { |
|
317 | - $custom_output = $chunk_body; |
|
318 | - } |
|
319 | - } elseif(substr($field_elements, 0, 5) == "@EVAL") { |
|
320 | - $eval_str = trim(substr($field_elements, 6)); |
|
321 | - $custom_output = eval($eval_str); |
|
322 | - } else { |
|
323 | - $custom_output = $field_elements; |
|
324 | - } |
|
325 | - $replacements = array( |
|
326 | - '[+field_type+]' => $field_type, |
|
327 | - '[+field_id+]' => $field_id, |
|
328 | - '[+default_text+]' => $default_text, |
|
329 | - '[+field_value+]' => $modx->htmlspecialchars($field_value), |
|
330 | - '[+field_style+]' => $field_style, |
|
331 | - ); |
|
332 | - $custom_output = str_replace(array_keys($replacements), $replacements, $custom_output); |
|
333 | - $modx->documentObject = $content; |
|
334 | - $modx->documentIdentifier = $content['id']; |
|
335 | - $custom_output = $modx->parseDocumentSource($custom_output); |
|
336 | - $field_html .= $custom_output; |
|
337 | - break; |
|
291 | + case 'custom_tv': |
|
292 | + $custom_output = ''; |
|
293 | + /* If we are loading a file */ |
|
294 | + if(substr($field_elements, 0, 5) == "@FILE") { |
|
295 | + $file_name = MODX_BASE_PATH . trim(substr($field_elements, 6)); |
|
296 | + if(!file_exists($file_name)) { |
|
297 | + $custom_output = $file_name . ' does not exist'; |
|
298 | + } else { |
|
299 | + $custom_output = file_get_contents($file_name); |
|
300 | + } |
|
301 | + } elseif(substr($field_elements, 0, 8) == '@INCLUDE') { |
|
302 | + $file_name = MODX_BASE_PATH . trim(substr($field_elements, 9)); |
|
303 | + if(!file_exists($file_name)) { |
|
304 | + $custom_output = $file_name . ' does not exist'; |
|
305 | + } else { |
|
306 | + ob_start(); |
|
307 | + include $file_name; |
|
308 | + $custom_output = ob_get_contents(); |
|
309 | + ob_end_clean(); |
|
310 | + } |
|
311 | + } elseif(substr($field_elements, 0, 6) == "@CHUNK") { |
|
312 | + $chunk_name = trim(substr($field_elements, 7)); |
|
313 | + $chunk_body = $modx->getChunk($chunk_name); |
|
314 | + if($chunk_body == false) { |
|
315 | + $custom_output = $_lang['chunk_no_exist'] . '(' . $_lang['htmlsnippet_name'] . ':' . $chunk_name . ')'; |
|
316 | + } else { |
|
317 | + $custom_output = $chunk_body; |
|
318 | + } |
|
319 | + } elseif(substr($field_elements, 0, 5) == "@EVAL") { |
|
320 | + $eval_str = trim(substr($field_elements, 6)); |
|
321 | + $custom_output = eval($eval_str); |
|
322 | + } else { |
|
323 | + $custom_output = $field_elements; |
|
324 | + } |
|
325 | + $replacements = array( |
|
326 | + '[+field_type+]' => $field_type, |
|
327 | + '[+field_id+]' => $field_id, |
|
328 | + '[+default_text+]' => $default_text, |
|
329 | + '[+field_value+]' => $modx->htmlspecialchars($field_value), |
|
330 | + '[+field_style+]' => $field_style, |
|
331 | + ); |
|
332 | + $custom_output = str_replace(array_keys($replacements), $replacements, $custom_output); |
|
333 | + $modx->documentObject = $content; |
|
334 | + $modx->documentIdentifier = $content['id']; |
|
335 | + $custom_output = $modx->parseDocumentSource($custom_output); |
|
336 | + $field_html .= $custom_output; |
|
337 | + break; |
|
338 | 338 | |
339 | - default: // the default handler -- for errors, mostly |
|
340 | - $field_html .= '<input type="text" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $modx->htmlspecialchars($field_value) . '" ' . $field_style . ' onchange="documentDirty=true;" />'; |
|
339 | + default: // the default handler -- for errors, mostly |
|
340 | + $field_html .= '<input type="text" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $modx->htmlspecialchars($field_value) . '" ' . $field_style . ' onchange="documentDirty=true;" />'; |
|
341 | 341 | |
342 | - } // end switch statement |
|
343 | - } else { |
|
344 | - $custom = explode(":", $field_type); |
|
345 | - $custom_output = ''; |
|
346 | - $file_name = MODX_BASE_PATH . 'assets/tvs/' . $custom['1'] . '/' . $custom['1'] . '.customtv.php'; |
|
347 | - if(!file_exists($file_name)) { |
|
348 | - $custom_output = $file_name . ' does not exist'; |
|
349 | - } else { |
|
350 | - ob_start(); |
|
351 | - include $file_name; |
|
352 | - $custom_output = ob_get_contents(); |
|
353 | - ob_end_clean(); |
|
354 | - } |
|
355 | - $replacements = array( |
|
356 | - '[+field_type+]' => $field_type, |
|
357 | - '[+field_id+]' => $field_id, |
|
358 | - '[+default_text+]' => $default_text, |
|
359 | - '[+field_value+]' => $modx->htmlspecialchars($field_value), |
|
360 | - '[+field_style+]' => $field_style, |
|
361 | - ); |
|
362 | - $custom_output = str_replace(array_keys($replacements), $replacements, $custom_output); |
|
363 | - $modx->documentObject = $content; |
|
364 | - $custom_output = $modx->parseDocumentSource($custom_output); |
|
365 | - $field_html .= $custom_output; |
|
366 | - } |
|
342 | + } // end switch statement |
|
343 | + } else { |
|
344 | + $custom = explode(":", $field_type); |
|
345 | + $custom_output = ''; |
|
346 | + $file_name = MODX_BASE_PATH . 'assets/tvs/' . $custom['1'] . '/' . $custom['1'] . '.customtv.php'; |
|
347 | + if(!file_exists($file_name)) { |
|
348 | + $custom_output = $file_name . ' does not exist'; |
|
349 | + } else { |
|
350 | + ob_start(); |
|
351 | + include $file_name; |
|
352 | + $custom_output = ob_get_contents(); |
|
353 | + ob_end_clean(); |
|
354 | + } |
|
355 | + $replacements = array( |
|
356 | + '[+field_type+]' => $field_type, |
|
357 | + '[+field_id+]' => $field_id, |
|
358 | + '[+default_text+]' => $default_text, |
|
359 | + '[+field_value+]' => $modx->htmlspecialchars($field_value), |
|
360 | + '[+field_style+]' => $field_style, |
|
361 | + ); |
|
362 | + $custom_output = str_replace(array_keys($replacements), $replacements, $custom_output); |
|
363 | + $modx->documentObject = $content; |
|
364 | + $custom_output = $modx->parseDocumentSource($custom_output); |
|
365 | + $field_html .= $custom_output; |
|
366 | + } |
|
367 | 367 | |
368 | - return $field_html; |
|
368 | + return $field_html; |
|
369 | 369 | } // end renderFormElement function |
370 | 370 | |
371 | 371 | function ParseIntputOptions($v) { |
372 | - global $modx; |
|
373 | - $a = array(); |
|
374 | - if(is_array($v)) { |
|
375 | - return $v; |
|
376 | - } else if($modx->db->isResult($v)) { |
|
377 | - while($cols = $modx->db->getRow($v, 'num')) $a[] = $cols; |
|
378 | - } else { |
|
379 | - $a = explode("||", $v); |
|
380 | - } |
|
381 | - return $a; |
|
372 | + global $modx; |
|
373 | + $a = array(); |
|
374 | + if(is_array($v)) { |
|
375 | + return $v; |
|
376 | + } else if($modx->db->isResult($v)) { |
|
377 | + while($cols = $modx->db->getRow($v, 'num')) $a[] = $cols; |
|
378 | + } else { |
|
379 | + $a = explode("||", $v); |
|
380 | + } |
|
381 | + return $a; |
|
382 | 382 | } |
@@ -16,27 +16,27 @@ discard block |
||
16 | 16 | * |
17 | 17 | */ |
18 | 18 | |
19 | -class RSSCache { |
|
20 | - var $BASE_CACHE = './cache'; // where the cache files are stored |
|
21 | - var $MAX_AGE = 3600; // when are files stale, default one hour |
|
22 | - var $ERROR = ""; // accumulate error messages |
|
19 | +class RSSCache{ |
|
20 | + var $BASE_CACHE = './cache'; // where the cache files are stored |
|
21 | + var $MAX_AGE = 3600; // when are files stale, default one hour |
|
22 | + var $ERROR = ""; // accumulate error messages |
|
23 | 23 | |
24 | - function __construct($base='', $age='') { |
|
25 | - if ( $base ) { |
|
24 | + function __construct($base = '', $age = ''){ |
|
25 | + if ($base) { |
|
26 | 26 | $this->BASE_CACHE = $base; |
27 | 27 | } |
28 | - if ( $age ) { |
|
28 | + if ($age) { |
|
29 | 29 | $this->MAX_AGE = $age; |
30 | 30 | } |
31 | 31 | |
32 | 32 | // attempt to make the cache directory |
33 | - if ( ! file_exists( $this->BASE_CACHE ) ) { |
|
34 | - $status = @mkdir( $this->BASE_CACHE, 0755 ); |
|
33 | + if (!file_exists($this->BASE_CACHE)) { |
|
34 | + $status = @mkdir($this->BASE_CACHE, 0755); |
|
35 | 35 | |
36 | 36 | // if make failed |
37 | - if ( ! $status ) { |
|
37 | + if (!$status) { |
|
38 | 38 | $this->error( |
39 | - "Cache couldn't make dir '" . $this->BASE_CACHE . "'." |
|
39 | + "Cache couldn't make dir '".$this->BASE_CACHE."'." |
|
40 | 40 | ); |
41 | 41 | } |
42 | 42 | } |
@@ -48,12 +48,12 @@ discard block |
||
48 | 48 | Input: url from wich the rss file was fetched |
49 | 49 | Output: true on sucess |
50 | 50 | \*=======================================================================*/ |
51 | - function set ($url, $rss) { |
|
51 | + function set($url, $rss){ |
|
52 | 52 | $this->ERROR = ""; |
53 | - $cache_file = $this->file_name( $url ); |
|
54 | - $fp = @fopen( $cache_file, 'w' ); |
|
53 | + $cache_file = $this->file_name($url); |
|
54 | + $fp = @fopen($cache_file, 'w'); |
|
55 | 55 | |
56 | - if ( ! $fp ) { |
|
56 | + if (!$fp) { |
|
57 | 57 | $this->error( |
58 | 58 | "Cache unable to open file for writing: $cache_file" |
59 | 59 | ); |
@@ -61,9 +61,9 @@ discard block |
||
61 | 61 | } |
62 | 62 | |
63 | 63 | |
64 | - $data = $this->serialize( $rss ); |
|
65 | - fwrite( $fp, $data ); |
|
66 | - fclose( $fp ); |
|
64 | + $data = $this->serialize($rss); |
|
65 | + fwrite($fp, $data); |
|
66 | + fclose($fp); |
|
67 | 67 | |
68 | 68 | return $cache_file; |
69 | 69 | } |
@@ -74,11 +74,11 @@ discard block |
||
74 | 74 | Input: url from wich the rss file was fetched |
75 | 75 | Output: cached object on HIT, false on MISS |
76 | 76 | \*=======================================================================*/ |
77 | - function get ($url) { |
|
77 | + function get($url){ |
|
78 | 78 | $this->ERROR = ""; |
79 | - $cache_file = $this->file_name( $url ); |
|
79 | + $cache_file = $this->file_name($url); |
|
80 | 80 | |
81 | - if ( ! file_exists( $cache_file ) ) { |
|
81 | + if (!file_exists($cache_file)) { |
|
82 | 82 | $this->debug( |
83 | 83 | "Cache doesn't contain: $url (cache file: $cache_file)" |
84 | 84 | ); |
@@ -86,16 +86,16 @@ discard block |
||
86 | 86 | } |
87 | 87 | |
88 | 88 | $fp = @fopen($cache_file, 'r'); |
89 | - if ( ! $fp ) { |
|
89 | + if (!$fp) { |
|
90 | 90 | $this->error( |
91 | 91 | "Failed to open cache file for reading: $cache_file" |
92 | 92 | ); |
93 | 93 | return 0; |
94 | 94 | } |
95 | 95 | |
96 | - if ($filesize = filesize($cache_file) ) { |
|
97 | - $data = fread( $fp, filesize($cache_file) ); |
|
98 | - $rss = $this->unserialize( $data ); |
|
96 | + if ($filesize = filesize($cache_file)) { |
|
97 | + $data = fread($fp, filesize($cache_file)); |
|
98 | + $rss = $this->unserialize($data); |
|
99 | 99 | |
100 | 100 | return $rss; |
101 | 101 | } |
@@ -110,16 +110,16 @@ discard block |
||
110 | 110 | Input: url from wich the rss file was fetched |
111 | 111 | Output: cached object on HIT, false on MISS |
112 | 112 | \*=======================================================================*/ |
113 | - function check_cache ( $url ) { |
|
113 | + function check_cache($url){ |
|
114 | 114 | $this->ERROR = ""; |
115 | - $filename = $this->file_name( $url ); |
|
115 | + $filename = $this->file_name($url); |
|
116 | 116 | |
117 | - if ( file_exists( $filename ) ) { |
|
117 | + if (file_exists($filename)) { |
|
118 | 118 | // find how long ago the file was added to the cache |
119 | 119 | // and whether that is longer then MAX_AGE |
120 | - $mtime = filemtime( $filename ); |
|
120 | + $mtime = filemtime($filename); |
|
121 | 121 | $age = time() - $mtime; |
122 | - if ( $this->MAX_AGE > $age ) { |
|
122 | + if ($this->MAX_AGE > $age) { |
|
123 | 123 | // object exists and is current |
124 | 124 | return 'HIT'; |
125 | 125 | } |
@@ -134,10 +134,10 @@ discard block |
||
134 | 134 | } |
135 | 135 | } |
136 | 136 | |
137 | - function cache_age( $cache_key ) { |
|
138 | - $filename = $this->file_name( $url ); |
|
139 | - if ( file_exists( $filename ) ) { |
|
140 | - $mtime = filemtime( $filename ); |
|
137 | + function cache_age($cache_key){ |
|
138 | + $filename = $this->file_name($url); |
|
139 | + if (file_exists($filename)) { |
|
140 | + $mtime = filemtime($filename); |
|
141 | 141 | $age = time() - $mtime; |
142 | 142 | return $age; |
143 | 143 | } |
@@ -149,15 +149,15 @@ discard block |
||
149 | 149 | /*=======================================================================*\ |
150 | 150 | Function: serialize |
151 | 151 | \*=======================================================================*/ |
152 | - function serialize ( $rss ) { |
|
153 | - return serialize( $rss ); |
|
152 | + function serialize($rss){ |
|
153 | + return serialize($rss); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | /*=======================================================================*\ |
157 | 157 | Function: unserialize |
158 | 158 | \*=======================================================================*/ |
159 | - function unserialize ( $data ) { |
|
160 | - return unserialize( $data ); |
|
159 | + function unserialize($data){ |
|
160 | + return unserialize($data); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | /*=======================================================================*\ |
@@ -166,31 +166,31 @@ discard block |
||
166 | 166 | Input: url from wich the rss file was fetched |
167 | 167 | Output: a file name |
168 | 168 | \*=======================================================================*/ |
169 | - function file_name ($url) { |
|
170 | - $filename = md5( $url ); |
|
171 | - return implode( DIRECTORY_SEPARATOR, array( $this->BASE_CACHE, $filename ) ); |
|
169 | + function file_name($url){ |
|
170 | + $filename = md5($url); |
|
171 | + return implode(DIRECTORY_SEPARATOR, array($this->BASE_CACHE, $filename)); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | /*=======================================================================*\ |
175 | 175 | Function: error |
176 | 176 | Purpose: register error |
177 | 177 | \*=======================================================================*/ |
178 | - function error ($errormsg, $lvl=E_USER_WARNING) { |
|
178 | + function error($errormsg, $lvl = E_USER_WARNING){ |
|
179 | 179 | // append PHP's error message if track_errors enabled |
180 | - if ( isset($php_errormsg) ) { |
|
180 | + if (isset($php_errormsg)) { |
|
181 | 181 | $errormsg .= " ($php_errormsg)"; |
182 | 182 | } |
183 | 183 | $this->ERROR = $errormsg; |
184 | - if ( MAGPIE_DEBUG ) { |
|
185 | - trigger_error( $errormsg, $lvl); |
|
184 | + if (MAGPIE_DEBUG) { |
|
185 | + trigger_error($errormsg, $lvl); |
|
186 | 186 | } |
187 | 187 | else { |
188 | - error_log( $errormsg, 0); |
|
188 | + error_log($errormsg, 0); |
|
189 | 189 | } |
190 | 190 | } |
191 | 191 | |
192 | - function debug ($debugmsg, $lvl=E_USER_NOTICE) { |
|
193 | - if ( MAGPIE_DEBUG ) { |
|
192 | + function debug($debugmsg, $lvl = E_USER_NOTICE){ |
|
193 | + if (MAGPIE_DEBUG) { |
|
194 | 194 | $this->error("MagpieRSS [debug] $debugmsg", $lvl); |
195 | 195 | } |
196 | 196 | } |
@@ -16,12 +16,14 @@ discard block |
||
16 | 16 | * |
17 | 17 | */ |
18 | 18 | |
19 | -class RSSCache { |
|
19 | +class RSSCache |
|
20 | +{ |
|
20 | 21 | var $BASE_CACHE = './cache'; // where the cache files are stored |
21 | 22 | var $MAX_AGE = 3600; // when are files stale, default one hour |
22 | 23 | var $ERROR = ""; // accumulate error messages |
23 | 24 | |
24 | - function __construct($base='', $age='') { |
|
25 | + function __construct($base='', $age='') |
|
26 | + { |
|
25 | 27 | if ( $base ) { |
26 | 28 | $this->BASE_CACHE = $base; |
27 | 29 | } |
@@ -48,7 +50,8 @@ discard block |
||
48 | 50 | Input: url from wich the rss file was fetched |
49 | 51 | Output: true on sucess |
50 | 52 | \*=======================================================================*/ |
51 | - function set ($url, $rss) { |
|
53 | + function set ($url, $rss) |
|
54 | + { |
|
52 | 55 | $this->ERROR = ""; |
53 | 56 | $cache_file = $this->file_name( $url ); |
54 | 57 | $fp = @fopen( $cache_file, 'w' ); |
@@ -74,7 +77,8 @@ discard block |
||
74 | 77 | Input: url from wich the rss file was fetched |
75 | 78 | Output: cached object on HIT, false on MISS |
76 | 79 | \*=======================================================================*/ |
77 | - function get ($url) { |
|
80 | + function get ($url) |
|
81 | + { |
|
78 | 82 | $this->ERROR = ""; |
79 | 83 | $cache_file = $this->file_name( $url ); |
80 | 84 | |
@@ -110,7 +114,8 @@ discard block |
||
110 | 114 | Input: url from wich the rss file was fetched |
111 | 115 | Output: cached object on HIT, false on MISS |
112 | 116 | \*=======================================================================*/ |
113 | - function check_cache ( $url ) { |
|
117 | + function check_cache ( $url ) |
|
118 | + { |
|
114 | 119 | $this->ERROR = ""; |
115 | 120 | $filename = $this->file_name( $url ); |
116 | 121 | |
@@ -122,26 +127,24 @@ discard block |
||
122 | 127 | if ( $this->MAX_AGE > $age ) { |
123 | 128 | // object exists and is current |
124 | 129 | return 'HIT'; |
125 | - } |
|
126 | - else { |
|
130 | + } else { |
|
127 | 131 | // object exists but is old |
128 | 132 | return 'STALE'; |
129 | 133 | } |
130 | - } |
|
131 | - else { |
|
134 | + } else { |
|
132 | 135 | // object does not exist |
133 | 136 | return 'MISS'; |
134 | 137 | } |
135 | 138 | } |
136 | 139 | |
137 | - function cache_age( $cache_key ) { |
|
140 | + function cache_age( $cache_key ) |
|
141 | + { |
|
138 | 142 | $filename = $this->file_name( $url ); |
139 | 143 | if ( file_exists( $filename ) ) { |
140 | 144 | $mtime = filemtime( $filename ); |
141 | 145 | $age = time() - $mtime; |
142 | 146 | return $age; |
143 | - } |
|
144 | - else { |
|
147 | + } else { |
|
145 | 148 | return -1; |
146 | 149 | } |
147 | 150 | } |
@@ -149,14 +152,16 @@ discard block |
||
149 | 152 | /*=======================================================================*\ |
150 | 153 | Function: serialize |
151 | 154 | \*=======================================================================*/ |
152 | - function serialize ( $rss ) { |
|
155 | + function serialize ( $rss ) |
|
156 | + { |
|
153 | 157 | return serialize( $rss ); |
154 | 158 | } |
155 | 159 | |
156 | 160 | /*=======================================================================*\ |
157 | 161 | Function: unserialize |
158 | 162 | \*=======================================================================*/ |
159 | - function unserialize ( $data ) { |
|
163 | + function unserialize ( $data ) |
|
164 | + { |
|
160 | 165 | return unserialize( $data ); |
161 | 166 | } |
162 | 167 | |
@@ -166,7 +171,8 @@ discard block |
||
166 | 171 | Input: url from wich the rss file was fetched |
167 | 172 | Output: a file name |
168 | 173 | \*=======================================================================*/ |
169 | - function file_name ($url) { |
|
174 | + function file_name ($url) |
|
175 | + { |
|
170 | 176 | $filename = md5( $url ); |
171 | 177 | return implode( DIRECTORY_SEPARATOR, array( $this->BASE_CACHE, $filename ) ); |
172 | 178 | } |
@@ -175,7 +181,8 @@ discard block |
||
175 | 181 | Function: error |
176 | 182 | Purpose: register error |
177 | 183 | \*=======================================================================*/ |
178 | - function error ($errormsg, $lvl=E_USER_WARNING) { |
|
184 | + function error ($errormsg, $lvl=E_USER_WARNING) |
|
185 | + { |
|
179 | 186 | // append PHP's error message if track_errors enabled |
180 | 187 | if ( isset($php_errormsg) ) { |
181 | 188 | $errormsg .= " ($php_errormsg)"; |
@@ -183,13 +190,13 @@ discard block |
||
183 | 190 | $this->ERROR = $errormsg; |
184 | 191 | if ( MAGPIE_DEBUG ) { |
185 | 192 | trigger_error( $errormsg, $lvl); |
186 | - } |
|
187 | - else { |
|
193 | + } else { |
|
188 | 194 | error_log( $errormsg, 0); |
189 | 195 | } |
190 | 196 | } |
191 | 197 | |
192 | - function debug ($debugmsg, $lvl=E_USER_NOTICE) { |
|
198 | + function debug ($debugmsg, $lvl=E_USER_NOTICE) |
|
199 | + { |
|
193 | 200 | if ( MAGPIE_DEBUG ) { |
194 | 201 | $this->error("MagpieRSS [debug] $debugmsg", $lvl); |
195 | 202 | } |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | $modx->getSettings(); |
6 | 6 | $modx->invokeEvent('OnWebPageInit'); |
7 | 7 | |
8 | -$vword = new VeriWord(148,60); |
|
8 | +$vword = new VeriWord(148, 60); |
|
9 | 9 | $vword->output_image(); |
10 | 10 | $vword->destroy_image(); |
11 | 11 | |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | ## see sample.php for test and usage |
42 | 42 | ## sample URL: http://www.program-ruti.org/veriword/ |
43 | 43 | #### |
44 | -class VeriWord { |
|
44 | +class VeriWord{ |
|
45 | 45 | |
46 | 46 | /* path to font directory*/ |
47 | 47 | public $dir_font = "ttf/"; |
@@ -52,44 +52,44 @@ discard block |
||
52 | 52 | public $im_height = 0; |
53 | 53 | public $im; |
54 | 54 | |
55 | - public function __construct($w=200, $h=80) { |
|
55 | + public function __construct($w = 200, $h = 80){ |
|
56 | 56 | /* create session to set word for verification */ |
57 | 57 | $this->set_veriword(); |
58 | - $this->dir_font = dirname(__FILE__) . '/' . $this->dir_font; |
|
58 | + $this->dir_font = dirname(__FILE__).'/'.$this->dir_font; |
|
59 | 59 | $this->im_width = $w; |
60 | 60 | $this->im_height = $h; |
61 | 61 | } |
62 | 62 | |
63 | - public function set_veriword() { |
|
63 | + public function set_veriword(){ |
|
64 | 64 | /* create session variable for verification, |
65 | 65 | you may change the session variable name */ |
66 | 66 | $this->word = $this->pick_word(); |
67 | 67 | $_SESSION['veriword'] = $this->word; |
68 | 68 | } |
69 | 69 | |
70 | - public function output_image() { |
|
70 | + public function output_image(){ |
|
71 | 71 | /* output the image as jpeg */ |
72 | 72 | $this->draw_image(); |
73 | 73 | header("Content-type: image/jpeg"); |
74 | 74 | imagejpeg($this->im); |
75 | 75 | } |
76 | 76 | |
77 | - public function pick_word() { |
|
77 | + public function pick_word(){ |
|
78 | 78 | global $modx; |
79 | 79 | // set default words |
80 | - $words="MODX,Access,Better,BitCode,Chunk,Cache,Desc,Design,Excell,Enjoy,URLs,TechView,Gerald,Griff,Humphrey,Holiday,Intel,Integration,Joystick,Join(),Oscope,Genetic,Light,Likeness,Marit,Maaike,Niche,Netherlands,Ordinance,Oscillo,Parser,Phusion,Query,Question,Regalia,Righteous,Snippet,Sentinel,Template,Thespian,Unity,Enterprise,Verily,Veri,Website,WideWeb,Yap,Yellow,Zebra,Zygote"; |
|
80 | + $words = "MODX,Access,Better,BitCode,Chunk,Cache,Desc,Design,Excell,Enjoy,URLs,TechView,Gerald,Griff,Humphrey,Holiday,Intel,Integration,Joystick,Join(),Oscope,Genetic,Light,Likeness,Marit,Maaike,Niche,Netherlands,Ordinance,Oscillo,Parser,Phusion,Query,Question,Regalia,Righteous,Snippet,Sentinel,Template,Thespian,Unity,Enterprise,Verily,Veri,Website,WideWeb,Yap,Yellow,Zebra,Zygote"; |
|
81 | 81 | $words = $modx->config['captcha_words'] ? $modx->config['captcha_words'] : $words; |
82 | 82 | $arr_words = array_filter(array_map('trim', explode(',', $words))); |
83 | 83 | |
84 | 84 | /* pick one randomly for text verification */ |
85 | - return (string) $arr_words[array_rand($arr_words)].rand(10,999); |
|
85 | + return (string) $arr_words[array_rand($arr_words)].rand(10, 999); |
|
86 | 86 | } |
87 | 87 | |
88 | - public function draw_text() { |
|
88 | + public function draw_text(){ |
|
89 | 89 | $dir = dir($this->dir_font); |
90 | 90 | $fontstmp = array(); |
91 | 91 | while (false !== ($file = $dir->read())) { |
92 | - if(substr($file, -4) == '.ttf') { |
|
92 | + if (substr($file, -4) == '.ttf') { |
|
93 | 93 | $fontstmp[] = $this->dir_font.$file; |
94 | 94 | } |
95 | 95 | } |
@@ -97,35 +97,35 @@ discard block |
||
97 | 97 | $text_font = (string) $fontstmp[array_rand($fontstmp)]; |
98 | 98 | |
99 | 99 | /* angle for text inclination */ |
100 | - $text_angle = rand(-9,9); |
|
100 | + $text_angle = rand(-9, 9); |
|
101 | 101 | /* initial text size */ |
102 | 102 | $text_size = 30; |
103 | 103 | /* calculate text width and height */ |
104 | - $box = imagettfbbox ( $text_size, $text_angle, $text_font, $this->word); |
|
105 | - $text_width = $box[2]-$box[0]; //text width |
|
106 | - $text_height= $box[5]-$box[3]; //text height |
|
104 | + $box = imagettfbbox($text_size, $text_angle, $text_font, $this->word); |
|
105 | + $text_width = $box[2] - $box[0]; //text width |
|
106 | + $text_height = $box[5] - $box[3]; //text height |
|
107 | 107 | |
108 | 108 | /* adjust text size */ |
109 | - $text_size = round((20 * $this->im_width)/$text_width); |
|
109 | + $text_size = round((20 * $this->im_width) / $text_width); |
|
110 | 110 | |
111 | 111 | /* recalculate text width and height */ |
112 | - $box = imagettfbbox ( $text_size, $text_angle, $text_font, $this->word); |
|
113 | - $text_width = $box[2]-$box[0]; //text width |
|
114 | - $text_height= $box[5]-$box[3]; //text height |
|
112 | + $box = imagettfbbox($text_size, $text_angle, $text_font, $this->word); |
|
113 | + $text_width = $box[2] - $box[0]; //text width |
|
114 | + $text_height = $box[5] - $box[3]; //text height |
|
115 | 115 | |
116 | 116 | /* calculate center position of text */ |
117 | - $text_x = ($this->im_width - $text_width)/2; |
|
118 | - $text_y = ($this->im_height - $text_height)/2; |
|
117 | + $text_x = ($this->im_width - $text_width) / 2; |
|
118 | + $text_y = ($this->im_height - $text_height) / 2; |
|
119 | 119 | |
120 | 120 | /* create canvas for text drawing */ |
121 | - $im_text = imagecreate ($this->im_width, $this->im_height); |
|
122 | - $bg_color = imagecolorallocate ($im_text, 255, 255, 255); |
|
121 | + $im_text = imagecreate($this->im_width, $this->im_height); |
|
122 | + $bg_color = imagecolorallocate($im_text, 255, 255, 255); |
|
123 | 123 | |
124 | 124 | /* pick color for text */ |
125 | - $text_color = imagecolorallocate ($im_text, 0, 51, 153); |
|
125 | + $text_color = imagecolorallocate($im_text, 0, 51, 153); |
|
126 | 126 | |
127 | 127 | /* draw text into canvas */ |
128 | - imagettftext ( $im_text, |
|
128 | + imagettftext($im_text, |
|
129 | 129 | $text_size, |
130 | 130 | $text_angle, |
131 | 131 | $text_x, |
@@ -140,19 +140,19 @@ discard block |
||
140 | 140 | } |
141 | 141 | |
142 | 142 | |
143 | - public function draw_image() { |
|
143 | + public function draw_image(){ |
|
144 | 144 | |
145 | 145 | /* pick one background image randomly from image directory */ |
146 | - $img_file = $this->dir_noise."noise".rand(1,4).".jpg"; |
|
146 | + $img_file = $this->dir_noise."noise".rand(1, 4).".jpg"; |
|
147 | 147 | |
148 | 148 | /* create "noise" background image from your image stock*/ |
149 | - $noise_img = @imagecreatefromjpeg ($img_file); |
|
149 | + $noise_img = @imagecreatefromjpeg($img_file); |
|
150 | 150 | $noise_width = imagesx($noise_img); |
151 | 151 | $noise_height = imagesy($noise_img); |
152 | 152 | |
153 | 153 | /* resize the background image to fit the size of image output */ |
154 | - $this->im = imagecreatetruecolor($this->im_width,$this->im_height); |
|
155 | - imagecopyresampled ($this->im, |
|
154 | + $this->im = imagecreatetruecolor($this->im_width, $this->im_height); |
|
155 | + imagecopyresampled($this->im, |
|
156 | 156 | $noise_img, |
157 | 157 | 0, 0, 0, 0, |
158 | 158 | $this->im_width, |
@@ -161,17 +161,17 @@ discard block |
||
161 | 161 | $noise_height); |
162 | 162 | |
163 | 163 | /* put text image into background image */ |
164 | - imagecopymerge ( $this->im, |
|
164 | + imagecopymerge($this->im, |
|
165 | 165 | $this->draw_text(), |
166 | 166 | 0, 0, 0, 0, |
167 | 167 | $this->im_width, |
168 | 168 | $this->im_height, |
169 | - 70 ); |
|
169 | + 70); |
|
170 | 170 | |
171 | 171 | return $this->im; |
172 | 172 | } |
173 | 173 | |
174 | - public function destroy_image() { |
|
174 | + public function destroy_image(){ |
|
175 | 175 | |
176 | 176 | imagedestroy($this->im); |
177 | 177 |
@@ -41,7 +41,8 @@ discard block |
||
41 | 41 | ## see sample.php for test and usage |
42 | 42 | ## sample URL: http://www.program-ruti.org/veriword/ |
43 | 43 | #### |
44 | -class VeriWord { |
|
44 | +class VeriWord |
|
45 | +{ |
|
45 | 46 | |
46 | 47 | /* path to font directory*/ |
47 | 48 | public $dir_font = "ttf/"; |
@@ -52,7 +53,8 @@ discard block |
||
52 | 53 | public $im_height = 0; |
53 | 54 | public $im; |
54 | 55 | |
55 | - public function __construct($w=200, $h=80) { |
|
56 | + public function __construct($w=200, $h=80) |
|
57 | + { |
|
56 | 58 | /* create session to set word for verification */ |
57 | 59 | $this->set_veriword(); |
58 | 60 | $this->dir_font = dirname(__FILE__) . '/' . $this->dir_font; |
@@ -60,21 +62,24 @@ discard block |
||
60 | 62 | $this->im_height = $h; |
61 | 63 | } |
62 | 64 | |
63 | - public function set_veriword() { |
|
65 | + public function set_veriword() |
|
66 | + { |
|
64 | 67 | /* create session variable for verification, |
65 | 68 | you may change the session variable name */ |
66 | 69 | $this->word = $this->pick_word(); |
67 | 70 | $_SESSION['veriword'] = $this->word; |
68 | 71 | } |
69 | 72 | |
70 | - public function output_image() { |
|
73 | + public function output_image() |
|
74 | + { |
|
71 | 75 | /* output the image as jpeg */ |
72 | 76 | $this->draw_image(); |
73 | 77 | header("Content-type: image/jpeg"); |
74 | 78 | imagejpeg($this->im); |
75 | 79 | } |
76 | 80 | |
77 | - public function pick_word() { |
|
81 | + public function pick_word() |
|
82 | + { |
|
78 | 83 | global $modx; |
79 | 84 | // set default words |
80 | 85 | $words="MODX,Access,Better,BitCode,Chunk,Cache,Desc,Design,Excell,Enjoy,URLs,TechView,Gerald,Griff,Humphrey,Holiday,Intel,Integration,Joystick,Join(),Oscope,Genetic,Light,Likeness,Marit,Maaike,Niche,Netherlands,Ordinance,Oscillo,Parser,Phusion,Query,Question,Regalia,Righteous,Snippet,Sentinel,Template,Thespian,Unity,Enterprise,Verily,Veri,Website,WideWeb,Yap,Yellow,Zebra,Zygote"; |
@@ -85,7 +90,8 @@ discard block |
||
85 | 90 | return (string) $arr_words[array_rand($arr_words)].rand(10,999); |
86 | 91 | } |
87 | 92 | |
88 | - public function draw_text() { |
|
93 | + public function draw_text() |
|
94 | + { |
|
89 | 95 | $dir = dir($this->dir_font); |
90 | 96 | $fontstmp = array(); |
91 | 97 | while (false !== ($file = $dir->read())) { |
@@ -140,7 +146,8 @@ discard block |
||
140 | 146 | } |
141 | 147 | |
142 | 148 | |
143 | - public function draw_image() { |
|
149 | + public function draw_image() |
|
150 | + { |
|
144 | 151 | |
145 | 152 | /* pick one background image randomly from image directory */ |
146 | 153 | $img_file = $this->dir_noise."noise".rand(1,4).".jpg"; |
@@ -171,7 +178,8 @@ discard block |
||
171 | 178 | return $this->im; |
172 | 179 | } |
173 | 180 | |
174 | - public function destroy_image() { |
|
181 | + public function destroy_image() |
|
182 | + { |
|
175 | 183 | |
176 | 184 | imagedestroy($this->im); |
177 | 185 |
@@ -3,10 +3,10 @@ discard block |
||
3 | 3 | global $site_sessionname; |
4 | 4 | $site_sessionname = genEvoSessionName(); // For legacy extras not using startCMSSession |
5 | 5 | |
6 | -function genEvoSessionName() { |
|
6 | +function genEvoSessionName(){ |
|
7 | 7 | $_ = crc32(__FILE__); |
8 | 8 | $_ = sprintf('%u', $_); |
9 | - return 'evo' . base_convert($_,10,36); |
|
9 | + return 'evo'.base_convert($_, 10, 36); |
|
10 | 10 | } |
11 | 11 | |
12 | 12 | function startCMSSession(){ |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | |
16 | 16 | session_name($site_sessionname); |
17 | 17 | removeInvalidCmsSessionIds($site_sessionname); |
18 | - $cookieExpiration= 0; |
|
18 | + $cookieExpiration = 0; |
|
19 | 19 | $secure = ((isset ($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on') || $_SERVER['SERVER_PORT'] == $https_port); |
20 | 20 | $cookiePath = !empty($session_cookie_path) ? $session_cookie_path : MODX_BASE_URL; |
21 | 21 | $cookieDomain = !empty($session_cookie_domain) ? $session_cookie_domain : ''; |
@@ -23,8 +23,8 @@ discard block |
||
23 | 23 | session_start(); |
24 | 24 | $key = "modx.mgr.session.cookie.lifetime"; |
25 | 25 | if (isset($_SESSION[$key]) && is_numeric($_SESSION[$key])) { |
26 | - $cookieLifetime= (int)$_SESSION[$key]; |
|
27 | - if($cookieLifetime) $cookieExpiration = $_SERVER['REQUEST_TIME']+$cookieLifetime; |
|
26 | + $cookieLifetime = (int) $_SESSION[$key]; |
|
27 | + if ($cookieLifetime) $cookieExpiration = $_SERVER['REQUEST_TIME'] + $cookieLifetime; |
|
28 | 28 | setcookie(session_name(), session_id(), $cookieExpiration, $cookiePath, $cookieDomain, $secure, true); |
29 | 29 | } |
30 | 30 | if (!isset($_SESSION['modx.session.created.time'])) { |
@@ -32,14 +32,14 @@ discard block |
||
32 | 32 | } |
33 | 33 | } |
34 | 34 | |
35 | -function removeInvalidCmsSessionFromStorage(&$storage, $session_name) { |
|
35 | +function removeInvalidCmsSessionFromStorage(&$storage, $session_name){ |
|
36 | 36 | if (isset($storage[$session_name]) && ($storage[$session_name] === '' || $storage[$session_name] === 'deleted')) |
37 | 37 | { |
38 | 38 | unset($storage[$session_name]); |
39 | 39 | } |
40 | 40 | } |
41 | 41 | |
42 | -function removeInvalidCmsSessionIds($session_name) { |
|
42 | +function removeInvalidCmsSessionIds($session_name){ |
|
43 | 43 | // session ids is invalid iff it is empty string |
44 | 44 | // storage priorioty can see in PHP source ext/session/session.c |
45 | 45 | removeInvalidCmsSessionFromStorage($_COOKIE, $session_name); |
@@ -3,13 +3,15 @@ discard block |
||
3 | 3 | global $site_sessionname; |
4 | 4 | $site_sessionname = genEvoSessionName(); // For legacy extras not using startCMSSession |
5 | 5 | |
6 | -function genEvoSessionName() { |
|
6 | +function genEvoSessionName() |
|
7 | +{ |
|
7 | 8 | $_ = crc32(__FILE__); |
8 | 9 | $_ = sprintf('%u', $_); |
9 | 10 | return 'evo' . base_convert($_,10,36); |
10 | 11 | } |
11 | 12 | |
12 | -function startCMSSession(){ |
|
13 | +function startCMSSession() |
|
14 | +{ |
|
13 | 15 | |
14 | 16 | global $site_sessionname, $https_port, $session_cookie_path, $session_cookie_domain; |
15 | 17 | |
@@ -22,24 +24,27 @@ discard block |
||
22 | 24 | session_set_cookie_params($cookieExpiration, $cookiePath, $cookieDomain, $secure, true); |
23 | 25 | session_start(); |
24 | 26 | $key = "modx.mgr.session.cookie.lifetime"; |
25 | - if (isset($_SESSION[$key]) && is_numeric($_SESSION[$key])) { |
|
27 | + if (isset($_SESSION[$key]) && is_numeric($_SESSION[$key])) { |
|
26 | 28 | $cookieLifetime= (int)$_SESSION[$key]; |
27 | - if($cookieLifetime) $cookieExpiration = $_SERVER['REQUEST_TIME']+$cookieLifetime; |
|
29 | + if($cookieLifetime) { |
|
30 | + $cookieExpiration = $_SERVER['REQUEST_TIME']+$cookieLifetime; |
|
31 | + } |
|
28 | 32 | setcookie(session_name(), session_id(), $cookieExpiration, $cookiePath, $cookieDomain, $secure, true); |
29 | 33 | } |
30 | - if (!isset($_SESSION['modx.session.created.time'])) { |
|
34 | + if (!isset($_SESSION['modx.session.created.time'])) { |
|
31 | 35 | $_SESSION['modx.session.created.time'] = $_SERVER['REQUEST_TIME']; |
32 | 36 | } |
33 | 37 | } |
34 | 38 | |
35 | -function removeInvalidCmsSessionFromStorage(&$storage, $session_name) { |
|
36 | - if (isset($storage[$session_name]) && ($storage[$session_name] === '' || $storage[$session_name] === 'deleted')) |
|
37 | - { |
|
39 | +function removeInvalidCmsSessionFromStorage(&$storage, $session_name) |
|
40 | +{ |
|
41 | + if (isset($storage[$session_name]) && ($storage[$session_name] === '' || $storage[$session_name] === 'deleted')) { |
|
38 | 42 | unset($storage[$session_name]); |
39 | 43 | } |
40 | 44 | } |
41 | 45 | |
42 | -function removeInvalidCmsSessionIds($session_name) { |
|
46 | +function removeInvalidCmsSessionIds($session_name) |
|
47 | +{ |
|
43 | 48 | // session ids is invalid iff it is empty string |
44 | 49 | // storage priorioty can see in PHP source ext/session/session.c |
45 | 50 | removeInvalidCmsSessionFromStorage($_COOKIE, $session_name); |