@@ -105,7 +105,8 @@ discard block |
||
105 | 105 | } |
106 | 106 | } |
107 | 107 | |
108 | - private function getUserIP() { |
|
108 | + private function getUserIP() |
|
109 | + { |
|
109 | 110 | if( array_key_exists('HTTP_X_FORWARDED_FOR', $_SERVER) && !empty($_SERVER['HTTP_X_FORWARDED_FOR']) ) { |
110 | 111 | if (strpos($_SERVER['HTTP_X_FORWARDED_FOR'], ',')>0) { |
111 | 112 | $addr = explode(",",$_SERVER['HTTP_X_FORWARDED_FOR']); |
@@ -113,8 +114,7 @@ discard block |
||
113 | 114 | } else { |
114 | 115 | return $_SERVER['HTTP_X_FORWARDED_FOR']; |
115 | 116 | } |
116 | - } |
|
117 | - else { |
|
117 | + } else { |
|
118 | 118 | return $_SERVER['REMOTE_ADDR']; |
119 | 119 | } |
120 | 120 | } |
@@ -1,6 +1,7 @@ discard block |
||
1 | 1 | <?php namespace EvolutionCMS\Legacy; |
2 | 2 | |
3 | -class mgrResources { |
|
3 | +class mgrResources |
|
4 | +{ |
|
4 | 5 | /** |
5 | 6 | * @var array |
6 | 7 | */ |
@@ -21,7 +22,8 @@ discard block |
||
21 | 22 | /** |
22 | 23 | * mgrResources constructor. |
23 | 24 | */ |
24 | - public function __construct() { |
|
25 | + public function __construct() |
|
26 | + { |
|
25 | 27 | $this->setTypes(); |
26 | 28 | $this->queryItemsFromDB(); |
27 | 29 | $this->prepareCategoryArrays(); |
@@ -30,7 +32,8 @@ discard block |
||
30 | 32 | /** |
31 | 33 | * @return void |
32 | 34 | */ |
33 | - public function setTypes() { |
|
35 | + public function setTypes() |
|
36 | + { |
|
34 | 37 | global $_lang; |
35 | 38 | $this->types['site_templates'] = array( |
36 | 39 | 'title'=>$_lang["manage_templates"], |
@@ -68,7 +71,8 @@ discard block |
||
68 | 71 | /** |
69 | 72 | * @return void |
70 | 73 | */ |
71 | - public function queryItemsFromDB() { |
|
74 | + public function queryItemsFromDB() |
|
75 | + { |
|
72 | 76 | foreach($this->types as $resourceTable=>$type) { |
73 | 77 | if($this->hasAnyPermissions($type['permissions'])) { |
74 | 78 | $nameField = isset($type['name']) ? $type['name'] : 'name'; |
@@ -81,11 +85,13 @@ discard block |
||
81 | 85 | * @param array $permissions |
82 | 86 | * @return bool |
83 | 87 | */ |
84 | - public function hasAnyPermissions($permissions) { |
|
88 | + public function hasAnyPermissions($permissions) |
|
89 | + { |
|
85 | 90 | $modx = evolutionCMS(); |
86 | 91 | |
87 | - foreach($permissions as $p) |
|
88 | - if($modx->hasPermission($p)) return true; |
|
92 | + foreach($permissions as $p) { |
|
93 | + if($modx->hasPermission($p)) return true; |
|
94 | + } |
|
89 | 95 | |
90 | 96 | return false; |
91 | 97 | } |
@@ -95,7 +101,8 @@ discard block |
||
95 | 101 | * @param string $nameField |
96 | 102 | * @return array|bool |
97 | 103 | */ |
98 | - public function queryResources($resourceTable, $nameField = 'name') { |
|
104 | + public function queryResources($resourceTable, $nameField = 'name') |
|
105 | + { |
|
99 | 106 | $modx = evolutionCMS(); global $_lang; |
100 | 107 | |
101 | 108 | $allowed = array( |
@@ -112,8 +119,9 @@ discard block |
||
112 | 119 | $tvsql = 'site_tmplvars.caption, '; |
113 | 120 | $tvjoin = sprintf('LEFT JOIN %s AS stt ON site_tmplvars.id=stt.tmplvarid GROUP BY site_tmplvars.id,reltpl', $modx->getFullTableName('site_tmplvar_templates')); |
114 | 121 | $sttfield = 'IF(stt.templateid,1,0) AS reltpl,'; |
122 | + } else { |
|
123 | + $sttfield = ''; |
|
115 | 124 | } |
116 | - else $sttfield = ''; |
|
117 | 125 | |
118 | 126 | $selectableTemplates = $resourceTable === 'site_templates' ? "{$resourceTable}.selectable, " : ""; |
119 | 127 | |
@@ -126,7 +134,9 @@ discard block |
||
126 | 134 | ); |
127 | 135 | $limit = $modx->db->getRecordCount($rs); |
128 | 136 | |
129 | - if($limit < 1) return false; |
|
137 | + if($limit < 1) { |
|
138 | + return false; |
|
139 | + } |
|
130 | 140 | |
131 | 141 | $result = array(); |
132 | 142 | while ($row = $modx->db->getRow($rs)) { |
@@ -138,7 +148,8 @@ discard block |
||
138 | 148 | /** |
139 | 149 | * @return void |
140 | 150 | */ |
141 | - public function prepareCategoryArrays() { |
|
151 | + public function prepareCategoryArrays() |
|
152 | + { |
|
142 | 153 | foreach($this->items as $type=>$items) { |
143 | 154 | foreach((array)$items as $item) { |
144 | 155 | $catid = $item['catid'] ? $item['catid'] : 0; |
@@ -154,7 +165,7 @@ discard block |
||
154 | 165 | |
155 | 166 | // Now sort by name |
156 | 167 | foreach($this->itemsPerCategory as $catid=>$items) { |
157 | - usort($this->itemsPerCategory[$catid], function ($a, $b) { |
|
168 | + usort($this->itemsPerCategory[$catid], function ($a, $b){ |
|
158 | 169 | return strcasecmp($a['name'], $b['name']); |
159 | 170 | }); |
160 | 171 | } |
@@ -8,7 +8,8 @@ discard block |
||
8 | 8 | * @param array $data |
9 | 9 | * @return string |
10 | 10 | */ |
11 | - public function output($config = array(), $data = array()) { |
|
11 | + public function output($config = array(), $data = array()) |
|
12 | + { |
|
12 | 13 | $modx = evolutionCMS(); |
13 | 14 | |
14 | 15 | $output = ''; |
@@ -64,7 +65,8 @@ discard block |
||
64 | 65 | * @param array $data |
65 | 66 | * @return string |
66 | 67 | */ |
67 | - private function render($data) { |
|
68 | + private function render($data) |
|
69 | + { |
|
68 | 70 | $modx = evolutionCMS(); global $_lang, $_country_lang; |
69 | 71 | |
70 | 72 | $data['lang.name'] = (isset($_lang[$data['alias']]) ? $_lang[$data['alias']] : $data['alias']); |
@@ -701,13 +701,15 @@ discard block |
||
701 | 701 | $this->virtualDir = ''; |
702 | 702 | } |
703 | 703 | |
704 | - if (preg_match('@^[1-9][0-9]*$@', $q) && !isset($this->documentListing[$q])) { /* we got an ID returned, check to make sure it's not an alias */ |
|
704 | + if (preg_match('@^[1-9][0-9]*$@', $q) && !isset($this->documentListing[$q])) { |
|
705 | +/* we got an ID returned, check to make sure it's not an alias */ |
|
705 | 706 | /* FS#476 and FS#308: check that id is valid in terms of virtualDir structure */ |
706 | 707 | if ($this->config['use_alias_path'] == 1) { |
707 | 708 | if (($this->virtualDir != '' && !isset($this->documentListing[$this->virtualDir . '/' . $q]) || ($this->virtualDir == '' && !isset($this->documentListing[$q]))) && (($this->virtualDir != '' && isset($this->documentListing[$this->virtualDir]) && in_array($q, $this->getChildIds($this->documentListing[$this->virtualDir], 1))) || ($this->virtualDir == '' && in_array($q, $this->getChildIds(0, 1))))) { |
708 | 709 | $this->documentMethod = 'id'; |
709 | 710 | return $q; |
710 | - } else { /* not a valid id in terms of virtualDir, treat as alias */ |
|
711 | + } else { |
|
712 | +/* not a valid id in terms of virtualDir, treat as alias */ |
|
711 | 713 | $this->documentMethod = 'alias'; |
712 | 714 | return $q; |
713 | 715 | } |
@@ -715,7 +717,8 @@ discard block |
||
715 | 717 | $this->documentMethod = 'id'; |
716 | 718 | return $q; |
717 | 719 | } |
718 | - } else { /* we didn't get an ID back, so instead we assume it's an alias */ |
|
720 | + } else { |
|
721 | +/* we didn't get an ID back, so instead we assume it's an alias */ |
|
719 | 722 | if ($this->config['friendly_alias_urls'] != 1) { |
720 | 723 | $q = $qOrig; |
721 | 724 | } |
@@ -745,13 +748,14 @@ discard block |
||
745 | 748 | * @param $id |
746 | 749 | * @return array|mixed|null|string |
747 | 750 | */ |
748 | - public function makePageCacheKey($id){ |
|
751 | + public function makePageCacheKey($id) |
|
752 | + { |
|
749 | 753 | $hash = $id; |
750 | 754 | $tmp = null; |
751 | 755 | $params = array(); |
752 | - if(!empty($this->systemCacheKey)){ |
|
756 | + if(!empty($this->systemCacheKey)) { |
|
753 | 757 | $hash = $this->systemCacheKey; |
754 | - }else { |
|
758 | + } else { |
|
755 | 759 | if (!empty($_GET)) { |
756 | 760 | // Sort GET parameters so that the order of parameters on the HTTP request don't affect the generated cache ID. |
757 | 761 | $params = $_GET; |
@@ -760,7 +764,7 @@ discard block |
||
760 | 764 | } |
761 | 765 | } |
762 | 766 | $evtOut = $this->invokeEvent("OnMakePageCacheKey", array ("hash" => $hash, "id" => $id, 'params' => $params)); |
763 | - if (is_array($evtOut) && count($evtOut) > 0){ |
|
767 | + if (is_array($evtOut) && count($evtOut) > 0) { |
|
764 | 768 | $tmp = array_pop($evtOut); |
765 | 769 | } |
766 | 770 | return empty($tmp) ? $hash : $tmp; |
@@ -1087,7 +1091,8 @@ discard block |
||
1087 | 1091 | $where = "pub_date <= {$timeNow} AND pub_date!=0 AND published=0"; |
1088 | 1092 | $result_pub = $this->db->select( 'id', '[+prefix+]site_content', $where); |
1089 | 1093 | $this->db->update($field, '[+prefix+]site_content', $where); |
1090 | - if ($this->db->getRecordCount($result_pub) >= 1) { //Event unPublished doc |
|
1094 | + if ($this->db->getRecordCount($result_pub) >= 1) { |
|
1095 | +//Event unPublished doc |
|
1091 | 1096 | while ($row_pub = $this->db->getRow($result_pub)) { |
1092 | 1097 | $this->invokeEvent("OnDocUnPublished", array( |
1093 | 1098 | "docid" => $row_pub['id'] |
@@ -1100,7 +1105,8 @@ discard block |
||
1100 | 1105 | $where = "unpub_date <= {$timeNow} AND unpub_date!=0 AND published=1"; |
1101 | 1106 | $result_unpub = $this->db->select( 'id', '[+prefix+]site_content', $where); |
1102 | 1107 | $this->db->update($field, '[+prefix+]site_content', $where); |
1103 | - if ($this->db->getRecordCount($result_unpub) >= 1) { //Event unPublished doc |
|
1108 | + if ($this->db->getRecordCount($result_unpub) >= 1) { |
|
1109 | +//Event unPublished doc |
|
1104 | 1110 | while ($row_unpub = $this->db->getRow($result_unpub)) { |
1105 | 1111 | $this->invokeEvent("OnDocUnPublished", array( |
1106 | 1112 | "docid" => $row_unpub['id'] |
@@ -1187,10 +1193,18 @@ discard block |
||
1187 | 1193 | return array(); |
1188 | 1194 | } |
1189 | 1195 | $spacer = md5('<<<EVO>>>'); |
1190 | - if($left==='{{' && strpos($content,';}}')!==false) $content = str_replace(';}}', sprintf(';}%s}', $spacer),$content); |
|
1191 | - if($left==='{{' && strpos($content,'{{}}')!==false) $content = str_replace('{{}}',sprintf('{%$1s{}%$1s}',$spacer),$content); |
|
1192 | - if($left==='[[' && strpos($content,']]]]')!==false) $content = str_replace(']]]]',sprintf(']]%s]]', $spacer),$content); |
|
1193 | - if($left==='[[' && strpos($content,']]]')!==false) $content = str_replace(']]]', sprintf(']%s]]', $spacer),$content); |
|
1196 | + if($left==='{{' && strpos($content,';}}')!==false) { |
|
1197 | + $content = str_replace(';}}', sprintf(';}%s}', $spacer),$content); |
|
1198 | + } |
|
1199 | + if($left==='{{' && strpos($content,'{{}}')!==false) { |
|
1200 | + $content = str_replace('{{}}',sprintf('{%$1s{}%$1s}',$spacer),$content); |
|
1201 | + } |
|
1202 | + if($left==='[[' && strpos($content,']]]]')!==false) { |
|
1203 | + $content = str_replace(']]]]',sprintf(']]%s]]', $spacer),$content); |
|
1204 | + } |
|
1205 | + if($left==='[[' && strpos($content,']]]')!==false) { |
|
1206 | + $content = str_replace(']]]', sprintf(']%s]]', $spacer),$content); |
|
1207 | + } |
|
1194 | 1208 | |
1195 | 1209 | $pos['<![CDATA['] = strpos($content, '<![CDATA['); |
1196 | 1210 | $pos[']]>'] = strpos($content, ']]>'); |
@@ -1243,7 +1257,8 @@ discard block |
||
1243 | 1257 | } |
1244 | 1258 | } |
1245 | 1259 | |
1246 | - if (!in_array($fetch, $tags)) { // Avoid double Matches |
|
1260 | + if (!in_array($fetch, $tags)) { |
|
1261 | +// Avoid double Matches |
|
1247 | 1262 | $tags[] = $fetch; // Fetch |
1248 | 1263 | }; |
1249 | 1264 | $fetch = ''; // and reset |
@@ -1261,7 +1276,9 @@ discard block |
||
1261 | 1276 | } |
1262 | 1277 | } |
1263 | 1278 | foreach($tags as $i=>$tag) { |
1264 | - if(strpos($tag,$spacer)!==false) $tags[$i] = str_replace($spacer, '', $tag); |
|
1279 | + if(strpos($tag,$spacer)!==false) { |
|
1280 | + $tags[$i] = str_replace($spacer, '', $tag); |
|
1281 | + } |
|
1265 | 1282 | } |
1266 | 1283 | return $tags; |
1267 | 1284 | } |
@@ -1301,7 +1318,10 @@ discard block |
||
1301 | 1318 | } |
1302 | 1319 | |
1303 | 1320 | foreach ($matches[1] as $i => $key) { |
1304 | - if(strpos($key,'[+')!==false) continue; // Allow chunk {{chunk?¶m=`xxx`}} with [*tv_name_[+param+]*] as content |
|
1321 | + if(strpos($key,'[+')!==false) { |
|
1322 | + continue; |
|
1323 | + } |
|
1324 | + // Allow chunk {{chunk?¶m=`xxx`}} with [*tv_name_[+param+]*] as content |
|
1305 | 1325 | if (substr($key, 0, 1) == '#') { |
1306 | 1326 | $key = substr($key, 1); |
1307 | 1327 | } // remove # for QuickEdit format |
@@ -2026,7 +2046,8 @@ discard block |
||
2026 | 2046 | * @return mixed|string |
2027 | 2047 | */ |
2028 | 2048 | public function _getSGVar($value) |
2029 | - { // Get super globals |
|
2049 | + { |
|
2050 | +// Get super globals |
|
2030 | 2051 | $key = $value; |
2031 | 2052 | $_ = $this->config['enable_filter']; |
2032 | 2053 | $this->config['enable_filter'] = 1; |
@@ -2430,7 +2451,8 @@ discard block |
||
2430 | 2451 | if ($this->config['friendly_urls'] == 1) { |
2431 | 2452 | $aliases = array(); |
2432 | 2453 | if (is_array($this->documentListing)) { |
2433 | - foreach ($this->documentListing as $path => $docid) { // This is big Loop on large site! |
|
2454 | + foreach ($this->documentListing as $path => $docid) { |
|
2455 | +// This is big Loop on large site! |
|
2434 | 2456 | $aliases[$docid] = $path; |
2435 | 2457 | $isfolder[$docid] = $this->aliasListing[$docid]['isfolder']; |
2436 | 2458 | } |
@@ -2463,7 +2485,7 @@ discard block |
||
2463 | 2485 | $isfriendly = ($this->config['friendly_alias_urls'] == 1 ? 1 : 0); |
2464 | 2486 | $pref = $this->config['friendly_url_prefix']; |
2465 | 2487 | $suff = $this->config['friendly_url_suffix']; |
2466 | - $documentSource = preg_replace_callback($in, function ($m) use ($aliases, $isfolder, $isfriendly, $pref, $suff) { |
|
2488 | + $documentSource = preg_replace_callback($in, function ($m) use ($aliases, $isfolder, $isfriendly, $pref, $suff){ |
|
2467 | 2489 | global $modx; |
2468 | 2490 | $thealias = $aliases[$m[1]]; |
2469 | 2491 | $thefolder = $isfolder[$m[1]]; |
@@ -4239,7 +4261,8 @@ discard block |
||
4239 | 4261 | if (isset ($this->snippetCache[$snippetName])) { |
4240 | 4262 | $snippet = $this->snippetCache[$snippetName]; |
4241 | 4263 | $properties = !empty($this->snippetCache[$snippetName . "Props"]) ? $this->snippetCache[$snippetName . "Props"] : ''; |
4242 | - } else { // not in cache so let's check the db |
|
4264 | + } else { |
|
4265 | +// not in cache so let's check the db |
|
4243 | 4266 | $sql = "SELECT ss.`name`, ss.`snippet`, ss.`properties`, sm.properties as `sharedproperties` FROM " . $this->getFullTableName("site_snippets") . " as ss LEFT JOIN " . $this->getFullTableName('site_modules') . " as sm on sm.guid=ss.moduleguid WHERE ss.`name`='" . $this->db->escape($snippetName) . "' AND ss.disabled=0;"; |
4244 | 4267 | $result = $this->db->query($sql); |
4245 | 4268 | if ($this->db->getRecordCount($result) == 1) { |
@@ -4740,7 +4763,7 @@ discard block |
||
4740 | 4763 | $result = $this->db->makeArray($rs); |
4741 | 4764 | |
4742 | 4765 | // get default/built-in template variables |
4743 | - if(is_array($docRow)){ |
|
4766 | + if(is_array($docRow)) { |
|
4744 | 4767 | ksort($docRow); |
4745 | 4768 | |
4746 | 4769 | foreach ($docRow as $key => $value) { |
@@ -5219,12 +5242,16 @@ discard block |
||
5219 | 5242 | return ''; |
5220 | 5243 | } // nothing to register |
5221 | 5244 | if (!is_array($options)) { |
5222 | - if (is_bool($options)) // backward compatibility with old plaintext parameter |
|
5245 | + if (is_bool($options)) { |
|
5246 | + // backward compatibility with old plaintext parameter |
|
5223 | 5247 | { |
5224 | 5248 | $options = array('plaintext' => $options); |
5225 | - } elseif (is_string($options)) // Also allow script name as 2nd param |
|
5249 | + } |
|
5250 | + } elseif (is_string($options)) { |
|
5251 | + // Also allow script name as 2nd param |
|
5226 | 5252 | { |
5227 | 5253 | $options = array('name' => $options); |
5254 | + } |
|
5228 | 5255 | } else { |
5229 | 5256 | $options = array(); |
5230 | 5257 | } |
@@ -5236,7 +5263,8 @@ discard block |
||
5236 | 5263 | unset($overwritepos); // probably unnecessary--just making sure |
5237 | 5264 | |
5238 | 5265 | $useThisVer = true; |
5239 | - if (isset($this->loadedjscripts[$key])) { // a matching script was found |
|
5266 | + if (isset($this->loadedjscripts[$key])) { |
|
5267 | +// a matching script was found |
|
5240 | 5268 | // if existing script is a startup script, make sure the candidate is also a startup script |
5241 | 5269 | if ($this->loadedjscripts[$key]['startup']) { |
5242 | 5270 | $startup = true; |
@@ -5256,7 +5284,8 @@ discard block |
||
5256 | 5284 | // overwrite the old script (the position may be important for dependent scripts) |
5257 | 5285 | $overwritepos = $this->loadedjscripts[$key]['pos']; |
5258 | 5286 | } |
5259 | - } else { // Use the original version |
|
5287 | + } else { |
|
5288 | +// Use the original version |
|
5260 | 5289 | if ($startup == true && $this->loadedjscripts[$key]['startup'] == false) { |
5261 | 5290 | // need to move the exisiting script to the head |
5262 | 5291 | $version = $this->loadedjscripts[$key][$version]; |
@@ -5381,7 +5410,8 @@ discard block |
||
5381 | 5410 | } |
5382 | 5411 | |
5383 | 5412 | $results = null; |
5384 | - foreach ($this->pluginEvent[$evtName] as $pluginName) { // start for loop |
|
5413 | + foreach ($this->pluginEvent[$evtName] as $pluginName) { |
|
5414 | +// start for loop |
|
5385 | 5415 | if ($this->dumpPlugins) { |
5386 | 5416 | $eventtime = $this->getMicroTime(); |
5387 | 5417 | } |
@@ -5929,7 +5959,8 @@ discard block |
||
5929 | 5959 | * @return bool |
5930 | 5960 | */ |
5931 | 5961 | public function isSafeCode($phpcode = '', $safe_functions = '') |
5932 | - { // return true or false |
|
5962 | + { |
|
5963 | +// return true or false |
|
5933 | 5964 | if ($safe_functions == '') { |
5934 | 5965 | return false; |
5935 | 5966 | } |
@@ -6345,7 +6376,7 @@ discard block |
||
6345 | 6376 | $args = array_pad(array(), $_, '$var'); |
6346 | 6377 | $args = implode(", ", $args); |
6347 | 6378 | $modx = &$this; |
6348 | - $args = preg_replace_callback('/\$var/', function () use ($modx, &$tmp, $val) { |
|
6379 | + $args = preg_replace_callback('/\$var/', function () use ($modx, &$tmp, $val){ |
|
6349 | 6380 | $arg = $val['args'][$tmp - 1]; |
6350 | 6381 | switch (true) { |
6351 | 6382 | case is_null($arg): { |
@@ -79,7 +79,8 @@ discard block |
||
79 | 79 | * @return string |
80 | 80 | */ |
81 | 81 | public function getParents($id, $path = '') |
82 | - { // modx:returns child's parent |
|
82 | + { |
|
83 | +// modx:returns child's parent |
|
83 | 84 | $modx = evolutionCMS(); |
84 | 85 | if (empty($this->aliases)) { |
85 | 86 | $f = "id, IF(alias='', id, alias) AS alias, parent, alias_visible"; |
@@ -456,7 +457,8 @@ discard block |
||
456 | 457 | $_ = trim($_); |
457 | 458 | } |
458 | 459 | $lastChar = substr($_, -1); |
459 | - if (!in_array($lastChar, $chars)) {// ,320,327,288,284,289 |
|
460 | + if (!in_array($lastChar, $chars)) { |
|
461 | +// ,320,327,288,284,289 |
|
460 | 462 | if (!in_array($prev_token, |
461 | 463 | array(T_FOREACH, T_WHILE, T_FOR, T_BOOLEAN_AND, T_BOOLEAN_OR, T_DOUBLE_ARROW))) { |
462 | 464 | $_ .= ' '; |
@@ -457,7 +457,8 @@ |
||
457 | 457 | if ($this->formElementType) { |
458 | 458 | $table = "\n" . '<form id="' . $this->formName . '" name="' . $this->formName . '" action="' . $this->formAction . '" method="POST">' . $table; |
459 | 459 | } |
460 | - if (strlen($this->pageNav) > 1) {//changed to display the pagination if exists. |
|
460 | + if (strlen($this->pageNav) > 1) { |
|
461 | +//changed to display the pagination if exists. |
|
461 | 462 | /* commented this part because of cookie |
462 | 463 | $table .= '<div id="max-display-records" ><select style="display:inline" onchange="javascript:updatePageSize(this[this.selectedIndex].value);">'; |
463 | 464 | $pageSizes= array (10, 25, 50, 100, 250); |
@@ -43,7 +43,8 @@ discard block |
||
43 | 43 | public $im_height = 0; |
44 | 44 | public $im; |
45 | 45 | |
46 | - public function __construct($w=200, $h=80) { |
|
46 | + public function __construct($w=200, $h=80) |
|
47 | + { |
|
47 | 48 | /* create session to set word for verification */ |
48 | 49 | $this->setVeriword(); |
49 | 50 | $this->dir_font = MODX_BASE_PATH . 'assets/' . $this->dir_font; |
@@ -51,21 +52,24 @@ discard block |
||
51 | 52 | $this->im_height = $h; |
52 | 53 | } |
53 | 54 | |
54 | - public function setVeriword() { |
|
55 | + public function setVeriword() |
|
56 | + { |
|
55 | 57 | /* create session variable for verification, |
56 | 58 | you may change the session variable name */ |
57 | 59 | $this->word = $this->makeText(); |
58 | 60 | $_SESSION['veriword'] = $this->word; |
59 | 61 | } |
60 | 62 | |
61 | - public function output() { |
|
63 | + public function output() |
|
64 | + { |
|
62 | 65 | /* output the image as jpeg */ |
63 | 66 | $this->drawImage(); |
64 | 67 | header("Content-type: image/jpeg"); |
65 | 68 | imagejpeg($this->im); |
66 | 69 | } |
67 | 70 | |
68 | - public function makeText() { |
|
71 | + public function makeText() |
|
72 | + { |
|
69 | 73 | $modx = evolutionCMS(); |
70 | 74 | // set default words |
71 | 75 | $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"; |
@@ -76,7 +80,8 @@ discard block |
||
76 | 80 | return (string) $arr_words[array_rand($arr_words)].rand(10,999); |
77 | 81 | } |
78 | 82 | |
79 | - public function drawText() { |
|
83 | + public function drawText() |
|
84 | + { |
|
80 | 85 | $dir = dir($this->dir_font); |
81 | 86 | $fontstmp = array(); |
82 | 87 | while (false !== ($file = $dir->read())) { |
@@ -131,7 +136,8 @@ discard block |
||
131 | 136 | } |
132 | 137 | |
133 | 138 | |
134 | - public function drawImage() { |
|
139 | + public function drawImage() |
|
140 | + { |
|
135 | 141 | |
136 | 142 | /* pick one background image randomly from image directory */ |
137 | 143 | $img_file = MODX_BASE_PATH . 'assets/' . $this->dir_noise."noise".rand(1,4).".jpg"; |
@@ -162,7 +168,8 @@ discard block |
||
162 | 168 | return $this->im; |
163 | 169 | } |
164 | 170 | |
165 | - public function destroy() { |
|
171 | + public function destroy() |
|
172 | + { |
|
166 | 173 | imagedestroy($this->im); |
167 | 174 | } |
168 | 175 | } |
@@ -8,8 +8,8 @@ |
||
8 | 8 | * @todo could be unnecessary |
9 | 9 | * |
10 | 10 | */ |
11 | -Class TemplateParser extends EvolutionCMS\Legacy\TemplateParser |
|
12 | -{ |
|
11 | +Class TemplateParser extends EvolutionCMS\Legacy\TemplateParser |
|
12 | +{ |
|
13 | 13 | } |
14 | 14 | |
15 | 15 | ?> |
@@ -573,7 +573,8 @@ |
||
573 | 573 | * @return array|string |
574 | 574 | */ |
575 | 575 | function parseInput($src, $delim = "||", $type = "string", $columns = true) |
576 | - { // type can be: string, array |
|
576 | + { |
|
577 | +// type can be: string, array |
|
577 | 578 | $modx = evolutionCMS(); |
578 | 579 | if ($modx->db->isResult($src)) { |
579 | 580 | // must be a recordset |