@@ -4,12 +4,13 @@ discard block |
||
4 | 4 | * |
5 | 5 | * @return array of keys from a language file |
6 | 6 | */ |
7 | -function get_lang_keys($filename) { |
|
7 | +function get_lang_keys($filename) |
|
8 | +{ |
|
8 | 9 | $file = MODX_MANAGER_PATH.'includes/lang' . DIRECTORY_SEPARATOR . $filename; |
9 | - if(is_file($file) && is_readable($file)) { |
|
10 | + if(is_file($file) && is_readable($file)) { |
|
10 | 11 | include($file); |
11 | 12 | $out = isset($_lang) ? array_keys($_lang) : array(); |
12 | - } else { |
|
13 | + } else { |
|
13 | 14 | $out = array(); |
14 | 15 | } |
15 | 16 | |
@@ -20,11 +21,12 @@ discard block |
||
20 | 21 | * |
21 | 22 | * @return array of languages that define the key in their file |
22 | 23 | */ |
23 | -function get_langs_by_key($key) { |
|
24 | +function get_langs_by_key($key) |
|
25 | +{ |
|
24 | 26 | global $lang_keys; |
25 | 27 | $lang_return = array(); |
26 | - foreach($lang_keys as $lang=>$keys) { |
|
27 | - if(in_array($key, $keys)) { |
|
28 | + foreach($lang_keys as $lang=>$keys) { |
|
29 | + if(in_array($key, $keys)) { |
|
28 | 30 | $lang_return[] = $lang; |
29 | 31 | } |
30 | 32 | } |
@@ -40,23 +42,24 @@ discard block |
||
40 | 42 | * @param string $selected_lang specify language to select in option list, default none |
41 | 43 | * @return string html option list |
42 | 44 | */ |
43 | -function get_lang_options($key = '', $selected_lang=null) { |
|
45 | +function get_lang_options($key = '', $selected_lang=null) |
|
46 | +{ |
|
44 | 47 | global $lang_keys, $_lang; |
45 | 48 | $lang_options = ''; |
46 | - if( ! empty($key)) { |
|
49 | + if( ! empty($key)) { |
|
47 | 50 | $languages = get_langs_by_key($key); |
48 | 51 | sort($languages); |
49 | 52 | $lang_options .= '<option value="">'.$_lang['language_title'].'</option>'; |
50 | 53 | |
51 | - foreach($languages as $language_name) { |
|
54 | + foreach($languages as $language_name) { |
|
52 | 55 | $uclanguage_name = ucwords(str_replace("_", " ", $language_name)); |
53 | 56 | $lang_options .= '<option value="'.$language_name.'">'.$uclanguage_name.'</option>'; |
54 | 57 | } |
55 | 58 | return $lang_options; |
56 | - } else { |
|
59 | + } else { |
|
57 | 60 | $languages = array_keys($lang_keys); |
58 | 61 | sort($languages); |
59 | - foreach($languages as $language_name) { |
|
62 | + foreach($languages as $language_name) { |
|
60 | 63 | $uclanguage_name = ucwords(str_replace("_", " ", $language_name)); |
61 | 64 | $sel = $language_name == $selected_lang ? ' selected="selected"' : ''; |
62 | 65 | $lang_options .= '<option value="'.$language_name.'" '.$sel.'>'.$uclanguage_name.'</option>'; |
@@ -65,31 +68,42 @@ discard block |
||
65 | 68 | } |
66 | 69 | } |
67 | 70 | |
68 | -function form_radio($name,$value,$add='',$disabled=false) { |
|
71 | +function form_radio($name,$value,$add='',$disabled=false) |
|
72 | +{ |
|
69 | 73 | global ${$name}; |
70 | 74 | $var = ${$name}; |
71 | 75 | $checked = ($var==$value) ? ' checked="checked"' : ''; |
72 | - if($disabled) $disabled = ' disabled'; else $disabled = ''; |
|
73 | - if($add) $add = ' ' . $add; |
|
76 | + if($disabled) { |
|
77 | + $disabled = ' disabled'; |
|
78 | + } else { |
|
79 | + $disabled = ''; |
|
80 | + } |
|
81 | + if($add) { |
|
82 | + $add = ' ' . $add; |
|
83 | + } |
|
74 | 84 | return sprintf('<input onchange="documentDirty=true;" type="radio" name="%s" value="%s" %s %s %s />', $name, $value, $checked, $disabled, $add); |
75 | 85 | } |
76 | 86 | |
77 | -function wrap_label($str='',$object) { |
|
87 | +function wrap_label($str='',$object) |
|
88 | +{ |
|
78 | 89 | return "<label>{$object}\n{$str}</label>"; |
79 | 90 | } |
80 | 91 | |
81 | -function parseText($tpl='', $ph=array()) { |
|
82 | - if(empty($ph) || empty($tpl)) return $tpl; |
|
92 | +function parseText($tpl='', $ph=array()) |
|
93 | +{ |
|
94 | + if(empty($ph) || empty($tpl)) { |
|
95 | + return $tpl; |
|
96 | + } |
|
83 | 97 | |
84 | - foreach($ph as $k=>$v) |
|
85 | - { |
|
98 | + foreach($ph as $k=>$v) { |
|
86 | 99 | $k = "[+{$k}+]"; |
87 | 100 | $tpl = str_replace($k, $v, $tpl); |
88 | 101 | } |
89 | 102 | return $tpl; |
90 | 103 | } |
91 | 104 | |
92 | -function showHide($cond=true) { |
|
105 | +function showHide($cond=true) |
|
106 | +{ |
|
93 | 107 | global $displayStyle; |
94 | 108 | $showHide = $cond ? $displayStyle : 'none'; |
95 | 109 | return sprintf('style="display:%s"', $showHide); |
@@ -733,7 +733,8 @@ discard block |
||
733 | 733 | } |
734 | 734 | |
735 | 735 | function mkdirs($strPath, $mode) |
736 | -{ // recursive mkdir function |
|
736 | +{ |
|
737 | +// recursive mkdir function |
|
737 | 738 | if (is_dir($strPath)) { |
738 | 739 | return true; |
739 | 740 | } |
@@ -838,7 +839,9 @@ discard block |
||
838 | 839 | global $modx, $_lang, $startpath, $filemanager_path, $uploadablefiles, $new_file_permissions; |
839 | 840 | $msg = ''; |
840 | 841 | foreach ($_FILES['userfile']['name'] as $i => $name) { |
841 | - if (empty($_FILES['userfile']['tmp_name'][$i])) continue; |
|
842 | + if (empty($_FILES['userfile']['tmp_name'][$i])) { |
|
843 | + continue; |
|
844 | + } |
|
842 | 845 | $userfile= array(); |
843 | 846 | |
844 | 847 | $userfile['tmp_name'] = $_FILES['userfile']['tmp_name'][$i]; |
@@ -695,13 +695,15 @@ discard block |
||
695 | 695 | $this->virtualDir = ''; |
696 | 696 | } |
697 | 697 | |
698 | - 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 */ |
|
698 | + if (preg_match('@^[1-9][0-9]*$@', $q) && !isset($this->documentListing[$q])) { |
|
699 | +/* we got an ID returned, check to make sure it's not an alias */ |
|
699 | 700 | /* FS#476 and FS#308: check that id is valid in terms of virtualDir structure */ |
700 | 701 | if ($this->config['use_alias_path'] == 1) { |
701 | 702 | 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))))) { |
702 | 703 | $this->documentMethod = 'id'; |
703 | 704 | return $q; |
704 | - } else { /* not a valid id in terms of virtualDir, treat as alias */ |
|
705 | + } else { |
|
706 | +/* not a valid id in terms of virtualDir, treat as alias */ |
|
705 | 707 | $this->documentMethod = 'alias'; |
706 | 708 | return $q; |
707 | 709 | } |
@@ -709,7 +711,8 @@ discard block |
||
709 | 711 | $this->documentMethod = 'id'; |
710 | 712 | return $q; |
711 | 713 | } |
712 | - } else { /* we didn't get an ID back, so instead we assume it's an alias */ |
|
714 | + } else { |
|
715 | +/* we didn't get an ID back, so instead we assume it's an alias */ |
|
713 | 716 | if ($this->config['friendly_alias_urls'] != 1) { |
714 | 717 | $q = $qOrig; |
715 | 718 | } |
@@ -739,13 +742,14 @@ discard block |
||
739 | 742 | * @param $id |
740 | 743 | * @return array|mixed|null|string |
741 | 744 | */ |
742 | - public function makePageCacheKey($id){ |
|
745 | + public function makePageCacheKey($id) |
|
746 | + { |
|
743 | 747 | $hash = $id; |
744 | 748 | $tmp = null; |
745 | 749 | $params = array(); |
746 | - if(!empty($this->systemCacheKey)){ |
|
750 | + if(!empty($this->systemCacheKey)) { |
|
747 | 751 | $hash = $this->systemCacheKey; |
748 | - }else { |
|
752 | + } else { |
|
749 | 753 | if (!empty($_GET)) { |
750 | 754 | // Sort GET parameters so that the order of parameters on the HTTP request don't affect the generated cache ID. |
751 | 755 | $params = $_GET; |
@@ -754,7 +758,7 @@ discard block |
||
754 | 758 | } |
755 | 759 | } |
756 | 760 | $evtOut = $this->invokeEvent("OnMakePageCacheKey", array ("hash" => $hash, "id" => $id, 'params' => $params)); |
757 | - if (is_array($evtOut) && count($evtOut) > 0){ |
|
761 | + if (is_array($evtOut) && count($evtOut) > 0) { |
|
758 | 762 | $tmp = array_pop($evtOut); |
759 | 763 | } |
760 | 764 | return empty($tmp) ? $hash : $tmp; |
@@ -1165,10 +1169,18 @@ discard block |
||
1165 | 1169 | return array(); |
1166 | 1170 | } |
1167 | 1171 | $spacer = md5('<<<EVO>>>'); |
1168 | - if($left==='{{' && strpos($content,';}}')!==false) $content = str_replace(';}}', sprintf(';}%s}', $spacer),$content); |
|
1169 | - if($left==='{{' && strpos($content,'{{}}')!==false) $content = str_replace('{{}}',sprintf('{%$1s{}%$1s}',$spacer),$content); |
|
1170 | - if($left==='[[' && strpos($content,']]]]')!==false) $content = str_replace(']]]]',sprintf(']]%s]]', $spacer),$content); |
|
1171 | - if($left==='[[' && strpos($content,']]]')!==false) $content = str_replace(']]]', sprintf(']%s]]', $spacer),$content); |
|
1172 | + if($left==='{{' && strpos($content,';}}')!==false) { |
|
1173 | + $content = str_replace(';}}', sprintf(';}%s}', $spacer),$content); |
|
1174 | + } |
|
1175 | + if($left==='{{' && strpos($content,'{{}}')!==false) { |
|
1176 | + $content = str_replace('{{}}',sprintf('{%$1s{}%$1s}',$spacer),$content); |
|
1177 | + } |
|
1178 | + if($left==='[[' && strpos($content,']]]]')!==false) { |
|
1179 | + $content = str_replace(']]]]',sprintf(']]%s]]', $spacer),$content); |
|
1180 | + } |
|
1181 | + if($left==='[[' && strpos($content,']]]')!==false) { |
|
1182 | + $content = str_replace(']]]', sprintf(']%s]]', $spacer),$content); |
|
1183 | + } |
|
1172 | 1184 | |
1173 | 1185 | $pos['<![CDATA['] = strpos($content, '<![CDATA['); |
1174 | 1186 | $pos[']]>'] = strpos($content, ']]>'); |
@@ -1221,7 +1233,8 @@ discard block |
||
1221 | 1233 | } |
1222 | 1234 | } |
1223 | 1235 | |
1224 | - if (!in_array($fetch, $tags)) { // Avoid double Matches |
|
1236 | + if (!in_array($fetch, $tags)) { |
|
1237 | +// Avoid double Matches |
|
1225 | 1238 | $tags[] = $fetch; // Fetch |
1226 | 1239 | }; |
1227 | 1240 | $fetch = ''; // and reset |
@@ -1239,7 +1252,9 @@ discard block |
||
1239 | 1252 | } |
1240 | 1253 | } |
1241 | 1254 | foreach($tags as $i=>$tag) { |
1242 | - if(strpos($tag,$spacer)!==false) $tags[$i] = str_replace($spacer, '', $tag); |
|
1255 | + if(strpos($tag,$spacer)!==false) { |
|
1256 | + $tags[$i] = str_replace($spacer, '', $tag); |
|
1257 | + } |
|
1243 | 1258 | } |
1244 | 1259 | return $tags; |
1245 | 1260 | } |
@@ -1279,7 +1294,10 @@ discard block |
||
1279 | 1294 | } |
1280 | 1295 | |
1281 | 1296 | foreach ($matches[1] as $i => $key) { |
1282 | - if(strpos($key,'[+')!==false) continue; // Allow chunk {{chunk?¶m=`xxx`}} with [*tv_name_[+param+]*] as content |
|
1297 | + if(strpos($key,'[+')!==false) { |
|
1298 | + continue; |
|
1299 | + } |
|
1300 | + // Allow chunk {{chunk?¶m=`xxx`}} with [*tv_name_[+param+]*] as content |
|
1283 | 1301 | if (substr($key, 0, 1) == '#') { |
1284 | 1302 | $key = substr($key, 1); |
1285 | 1303 | } // remove # for QuickEdit format |
@@ -2004,7 +2022,8 @@ discard block |
||
2004 | 2022 | * @return mixed|string |
2005 | 2023 | */ |
2006 | 2024 | public function _getSGVar($value) |
2007 | - { // Get super globals |
|
2025 | + { |
|
2026 | +// Get super globals |
|
2008 | 2027 | $key = $value; |
2009 | 2028 | $_ = $this->config['enable_filter']; |
2010 | 2029 | $this->config['enable_filter'] = 1; |
@@ -2409,7 +2428,8 @@ discard block |
||
2409 | 2428 | if ($this->config['friendly_urls'] == 1) { |
2410 | 2429 | $aliases = array(); |
2411 | 2430 | if (is_array($this->documentListing)) { |
2412 | - foreach ($this->documentListing as $path => $docid) { // This is big Loop on large site! |
|
2431 | + foreach ($this->documentListing as $path => $docid) { |
|
2432 | +// This is big Loop on large site! |
|
2413 | 2433 | $aliases[$docid] = $path; |
2414 | 2434 | $isfolder[$docid] = $this->aliasListing[$docid]['isfolder']; |
2415 | 2435 | } |
@@ -2442,7 +2462,7 @@ discard block |
||
2442 | 2462 | $isfriendly = ($this->config['friendly_alias_urls'] == 1 ? 1 : 0); |
2443 | 2463 | $pref = $this->config['friendly_url_prefix']; |
2444 | 2464 | $suff = $this->config['friendly_url_suffix']; |
2445 | - $documentSource = preg_replace_callback($in, function ($m) use ($aliases, $isfolder, $isfriendly, $pref, $suff) { |
|
2465 | + $documentSource = preg_replace_callback($in, function ($m) use ($aliases, $isfolder, $isfriendly, $pref, $suff){ |
|
2446 | 2466 | global $modx; |
2447 | 2467 | $thealias = $aliases[$m[1]]; |
2448 | 2468 | $thefolder = $isfolder[$m[1]]; |
@@ -4214,7 +4234,8 @@ discard block |
||
4214 | 4234 | if (isset ($this->snippetCache[$snippetName])) { |
4215 | 4235 | $snippet = $this->snippetCache[$snippetName]; |
4216 | 4236 | $properties = !empty($this->snippetCache[$snippetName . "Props"]) ? $this->snippetCache[$snippetName . "Props"] : ''; |
4217 | - } else { // not in cache so let's check the db |
|
4237 | + } else { |
|
4238 | +// not in cache so let's check the db |
|
4218 | 4239 | $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;"; |
4219 | 4240 | $result = $this->db->query($sql); |
4220 | 4241 | if ($this->db->getRecordCount($result) == 1) { |
@@ -4718,7 +4739,7 @@ discard block |
||
4718 | 4739 | $result = $this->db->makeArray($rs); |
4719 | 4740 | |
4720 | 4741 | // get default/built-in template variables |
4721 | - if(is_array($docRow)){ |
|
4742 | + if(is_array($docRow)) { |
|
4722 | 4743 | ksort($docRow); |
4723 | 4744 | |
4724 | 4745 | foreach ($docRow as $key => $value) { |
@@ -5197,12 +5218,16 @@ discard block |
||
5197 | 5218 | return ''; |
5198 | 5219 | } // nothing to register |
5199 | 5220 | if (!is_array($options)) { |
5200 | - if (is_bool($options)) // backward compatibility with old plaintext parameter |
|
5221 | + if (is_bool($options)) { |
|
5222 | + // backward compatibility with old plaintext parameter |
|
5201 | 5223 | { |
5202 | 5224 | $options = array('plaintext' => $options); |
5203 | - } elseif (is_string($options)) // Also allow script name as 2nd param |
|
5225 | + } |
|
5226 | + } elseif (is_string($options)) { |
|
5227 | + // Also allow script name as 2nd param |
|
5204 | 5228 | { |
5205 | 5229 | $options = array('name' => $options); |
5230 | + } |
|
5206 | 5231 | } else { |
5207 | 5232 | $options = array(); |
5208 | 5233 | } |
@@ -5214,7 +5239,8 @@ discard block |
||
5214 | 5239 | unset($overwritepos); // probably unnecessary--just making sure |
5215 | 5240 | |
5216 | 5241 | $useThisVer = true; |
5217 | - if (isset($this->loadedjscripts[$key])) { // a matching script was found |
|
5242 | + if (isset($this->loadedjscripts[$key])) { |
|
5243 | +// a matching script was found |
|
5218 | 5244 | // if existing script is a startup script, make sure the candidate is also a startup script |
5219 | 5245 | if ($this->loadedjscripts[$key]['startup']) { |
5220 | 5246 | $startup = true; |
@@ -5234,7 +5260,8 @@ discard block |
||
5234 | 5260 | // overwrite the old script (the position may be important for dependent scripts) |
5235 | 5261 | $overwritepos = $this->loadedjscripts[$key]['pos']; |
5236 | 5262 | } |
5237 | - } else { // Use the original version |
|
5263 | + } else { |
|
5264 | +// Use the original version |
|
5238 | 5265 | if ($startup == true && $this->loadedjscripts[$key]['startup'] == false) { |
5239 | 5266 | // need to move the exisiting script to the head |
5240 | 5267 | $version = $this->loadedjscripts[$key][$version]; |
@@ -5358,7 +5385,8 @@ discard block |
||
5358 | 5385 | } |
5359 | 5386 | |
5360 | 5387 | $results = null; |
5361 | - foreach ($this->pluginEvent[$evtName] as $pluginName) { // start for loop |
|
5388 | + foreach ($this->pluginEvent[$evtName] as $pluginName) { |
|
5389 | +// start for loop |
|
5362 | 5390 | if ($this->dumpPlugins) { |
5363 | 5391 | $eventtime = $this->getMicroTime(); |
5364 | 5392 | } |
@@ -5906,7 +5934,8 @@ discard block |
||
5906 | 5934 | * @return bool |
5907 | 5935 | */ |
5908 | 5936 | public function isSafeCode($phpcode = '', $safe_functions = '') |
5909 | - { // return true or false |
|
5937 | + { |
|
5938 | +// return true or false |
|
5910 | 5939 | if ($safe_functions == '') { |
5911 | 5940 | return false; |
5912 | 5941 | } |
@@ -6322,7 +6351,7 @@ discard block |
||
6322 | 6351 | $args = array_pad(array(), $_, '$var'); |
6323 | 6352 | $args = implode(", ", $args); |
6324 | 6353 | $modx = &$this; |
6325 | - $args = preg_replace_callback('/\$var/', function () use ($modx, &$tmp, $val) { |
|
6354 | + $args = preg_replace_callback('/\$var/', function () use ($modx, &$tmp, $val){ |
|
6326 | 6355 | $arg = $val['args'][$tmp - 1]; |
6327 | 6356 | switch (true) { |
6328 | 6357 | case is_null($arg): { |
@@ -5,7 +5,9 @@ |
||
5 | 5 | * Time: 10:00 |
6 | 6 | */ |
7 | 7 | |
8 | -if (isset($this->filter) && is_object($this->filter)) return true; |
|
8 | +if (isset($this->filter) && is_object($this->filter)) { |
|
9 | + return true; |
|
10 | +} |
|
9 | 11 | |
10 | 12 | include_once(MODX_MANAGER_PATH.'includes/extenders/modifiers.class.inc.php'); |
11 | 13 | $this->filter = new MODIFIERS; |
@@ -9,21 +9,24 @@ |
||
9 | 9 | $table_prefix = base_convert(rand(10, 20), 10, 36).substr(str_shuffle('0123456789abcdefghijklmnopqrstuvwxyz'), rand(0, 33), 3).'_'; |
10 | 10 | } else { |
11 | 11 | $database_name = ''; |
12 | - if (!is_file($base_path.MGR_DIR.'/includes/config.inc.php')) $upgradeable = 0; |
|
13 | - else { |
|
12 | + if (!is_file($base_path.MGR_DIR.'/includes/config.inc.php')) { |
|
13 | + $upgradeable = 0; |
|
14 | + } else { |
|
14 | 15 | // Include the file so we can test its validity |
15 | 16 | include($base_path.MGR_DIR.'/includes/config.inc.php'); |
16 | 17 | // We need to have all connection settings - but prefix may be empty so we have to ignore it |
17 | 18 | if ($dbase) { |
18 | 19 | $database_name = trim($dbase, '`'); |
19 | - if (!$conn = mysqli_connect($database_server, $database_user, $database_password)) |
|
20 | - $upgradeable = (isset($_POST['installmode']) && $_POST['installmode']=='new') ? 0 : 2; |
|
21 | - elseif (! mysqli_select_db($conn, trim($dbase, '`'))) |
|
22 | - $upgradeable = (isset($_POST['installmode']) && $_POST['installmode']=='new') ? 0 : 2; |
|
23 | - else |
|
24 | - $upgradeable = 1; |
|
20 | + if (!$conn = mysqli_connect($database_server, $database_user, $database_password)) { |
|
21 | + $upgradeable = (isset($_POST['installmode']) && $_POST['installmode']=='new') ? 0 : 2; |
|
22 | + } elseif (! mysqli_select_db($conn, trim($dbase, '`'))) { |
|
23 | + $upgradeable = (isset($_POST['installmode']) && $_POST['installmode']=='new') ? 0 : 2; |
|
24 | + } else { |
|
25 | + $upgradeable = 1; |
|
26 | + } |
|
27 | + } else { |
|
28 | + $upgradable= 2; |
|
25 | 29 | } |
26 | - else $upgradable= 2; |
|
27 | 30 | } |
28 | 31 | } |
29 | 32 |
@@ -1,22 +1,22 @@ 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 | -if (!$modx->hasPermission('logs')) { |
|
5 | +if (!$modx->hasPermission('logs')) { |
|
6 | 6 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
7 | 7 | } |
8 | 8 | |
9 | -function array_unique_multi($array, $checkKey) |
|
10 | -{ |
|
9 | +function array_unique_multi($array, $checkKey) |
|
10 | +{ |
|
11 | 11 | // Use the builtin if we're not a multi-dimensional array |
12 | - if (!is_array(current($array)) || empty($checkKey)) { |
|
12 | + if (!is_array(current($array)) || empty($checkKey)) { |
|
13 | 13 | return array_unique($array); |
14 | 14 | } |
15 | 15 | |
16 | 16 | $ret = array(); |
17 | 17 | $checkValues = array(); // contains the unique key Values |
18 | - foreach ($array as $key => $current) { |
|
19 | - if (in_array($current[$checkKey], $checkValues)) { |
|
18 | + foreach ($array as $key => $current) { |
|
19 | + if (in_array($current[$checkKey], $checkValues)) { |
|
20 | 20 | continue; |
21 | 21 | } // duplicate |
22 | 22 | |
@@ -26,17 +26,17 @@ discard block |
||
26 | 26 | return $ret; |
27 | 27 | } |
28 | 28 | |
29 | -function record_sort($array, $key) |
|
30 | -{ |
|
29 | +function record_sort($array, $key) |
|
30 | +{ |
|
31 | 31 | $hash = array(); |
32 | - foreach ($array as $k => $v) { |
|
32 | + foreach ($array as $k => $v) { |
|
33 | 33 | $hash[$k] = $v[$key]; |
34 | 34 | } |
35 | 35 | |
36 | 36 | natsort($hash); |
37 | 37 | |
38 | 38 | $records = array(); |
39 | - foreach ($hash as $k => $row) { |
|
39 | + foreach ($hash as $k => $row) { |
|
40 | 40 | $records[$k] = $array[$k]; |
41 | 41 | } |
42 | 42 | |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | <?php |
64 | 64 | // get all users currently in the log |
65 | 65 | $logs_user = record_sort(array_unique_multi($logs, 'internalKey'), 'username'); |
66 | - foreach ($logs_user as $row) { |
|
66 | + foreach ($logs_user as $row) { |
|
67 | 67 | $selectedtext = $row['internalKey'] == $_REQUEST['searchuser'] ? ' selected="selected"' : ''; |
68 | 68 | echo "\t\t" . '<option value="' . $row['internalKey'] . '"' . $selectedtext . '>' . $row['username'] . "</option>\n"; |
69 | 69 | } |
@@ -80,9 +80,9 @@ discard block |
||
80 | 80 | // get all available actions in the log |
81 | 81 | include_once "actionlist.inc.php"; |
82 | 82 | $logs_actions = record_sort(array_unique_multi($logs, 'action'), 'action'); |
83 | - foreach ($logs_actions as $row) { |
|
83 | + foreach ($logs_actions as $row) { |
|
84 | 84 | $action = getAction($row['action']); |
85 | - if ($action == 'Idle') { |
|
85 | + if ($action == 'Idle') { |
|
86 | 86 | continue; |
87 | 87 | } |
88 | 88 | $selectedtext = $row['action'] == $_REQUEST['action'] ? ' selected="selected"' : ''; |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | <?php |
101 | 101 | // get all itemid currently in logging |
102 | 102 | $logs_items = record_sort(array_unique_multi($logs, 'itemid'), 'itemid'); |
103 | - foreach ($logs_items as $row) { |
|
103 | + foreach ($logs_items as $row) { |
|
104 | 104 | $selectedtext = $row['itemid'] == $_REQUEST['itemid'] ? ' selected="selected"' : ''; |
105 | 105 | echo "\t\t" . '<option value="' . $row['itemid'] . '"' . $selectedtext . '>' . $row['itemid'] . "</option>\n"; |
106 | 106 | } |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | <?php |
117 | 117 | // get all itemname currently in logging |
118 | 118 | $logs_names = record_sort(array_unique_multi($logs, 'itemname'), 'itemname'); |
119 | - foreach ($logs_names as $row) { |
|
119 | + foreach ($logs_names as $row) { |
|
120 | 120 | $selectedtext = $row['itemname'] == $_REQUEST['itemname'] ? ' selected="selected"' : ''; |
121 | 121 | echo "\t\t" . '<option value="' . $row['itemname'] . '"' . $selectedtext . '>' . $row['itemname'] . "</option>\n"; |
122 | 122 | } |
@@ -172,36 +172,36 @@ discard block |
||
172 | 172 | <div class="container container-body"> |
173 | 173 | |
174 | 174 | <?php |
175 | -if (isset($_REQUEST['log_submit'])) { |
|
175 | +if (isset($_REQUEST['log_submit'])) { |
|
176 | 176 | // get the selections the user made. |
177 | 177 | $sqladd = array(); |
178 | - if ($_REQUEST['searchuser'] != 0) { |
|
178 | + if ($_REQUEST['searchuser'] != 0) { |
|
179 | 179 | $sqladd[] = "internalKey='" . (int)$_REQUEST['searchuser'] . "'"; |
180 | 180 | } |
181 | - if ($_REQUEST['action'] != 0) { |
|
181 | + if ($_REQUEST['action'] != 0) { |
|
182 | 182 | $sqladd[] = "action=" . (int)$_REQUEST['action']; |
183 | 183 | } |
184 | - if ($_REQUEST['itemid'] != 0 || $_REQUEST['itemid'] == "-") { |
|
184 | + if ($_REQUEST['itemid'] != 0 || $_REQUEST['itemid'] == "-") { |
|
185 | 185 | $sqladd[] = "itemid='" . $_REQUEST['itemid'] . "'"; |
186 | 186 | } |
187 | - if ($_REQUEST['itemname'] != '0') { |
|
187 | + if ($_REQUEST['itemname'] != '0') { |
|
188 | 188 | $sqladd[] = "itemname='" . $modx->db->escape($_REQUEST['itemname']) . "'"; |
189 | 189 | } |
190 | - if ($_REQUEST['message'] != "") { |
|
190 | + if ($_REQUEST['message'] != "") { |
|
191 | 191 | $sqladd[] = "message LIKE '%" . $modx->db->escape($_REQUEST['message']) . "%'"; |
192 | 192 | } |
193 | 193 | // date stuff |
194 | - if ($_REQUEST['datefrom'] != "") { |
|
194 | + if ($_REQUEST['datefrom'] != "") { |
|
195 | 195 | $sqladd[] = "timestamp>" . $modx->toTimeStamp($_REQUEST['datefrom']); |
196 | 196 | } |
197 | - if ($_REQUEST['dateto'] != "") { |
|
197 | + if ($_REQUEST['dateto'] != "") { |
|
198 | 198 | $sqladd[] = "timestamp<" . $modx->toTimeStamp($_REQUEST['dateto']); |
199 | 199 | } |
200 | 200 | |
201 | 201 | // If current position is not set, set it to zero |
202 | - if (!isset($_REQUEST['int_cur_position']) || $_REQUEST['int_cur_position'] == 0) { |
|
202 | + if (!isset($_REQUEST['int_cur_position']) || $_REQUEST['int_cur_position'] == 0) { |
|
203 | 203 | $int_cur_position = 0; |
204 | - } else { |
|
204 | + } else { |
|
205 | 205 | $int_cur_position = $_REQUEST['int_cur_position']; |
206 | 206 | } |
207 | 207 | |
@@ -215,9 +215,9 @@ discard block |
||
215 | 215 | |
216 | 216 | $rs = $modx->db->select('*', $modx->getFullTableName('manager_log'), (!empty($sqladd) ? implode(' AND ', $sqladd) : ''), 'timestamp DESC, id DESC', "{$int_cur_position}, {$int_num_result}"); |
217 | 217 | |
218 | -if ($limit < 1) { |
|
218 | +if ($limit < 1) { |
|
219 | 219 | echo '<p>' . $_lang["mgrlog_emptysrch"] . '</p>'; |
220 | -} else { |
|
220 | +} else { |
|
221 | 221 | echo '<p>' . $_lang["mgrlog_sortinst"] . '</p>'; |
222 | 222 | |
223 | 223 | include_once "paginate.inc.php"; |
@@ -236,14 +236,14 @@ discard block |
||
236 | 236 | $paging = $array_paging['first_link'] . $_lang["paging_first"] . (isset($array_paging['first_link']) ? "</a> " : " "); |
237 | 237 | $paging .= $array_paging['previous_link'] . $_lang["paging_prev"] . (isset($array_paging['previous_link']) ? "</a> " : " "); |
238 | 238 | $pagesfound = sizeof($array_row_paging); |
239 | - if ($pagesfound > 6) { |
|
239 | + if ($pagesfound > 6) { |
|
240 | 240 | $paging .= $array_row_paging[$current_row - 2]; // ." "; |
241 | 241 | $paging .= $array_row_paging[$current_row - 1]; // ." "; |
242 | 242 | $paging .= $array_row_paging[$current_row]; // ." "; |
243 | 243 | $paging .= $array_row_paging[$current_row + 1]; // ." "; |
244 | 244 | $paging .= $array_row_paging[$current_row + 2]; // ." "; |
245 | - } else { |
|
246 | - for ($i = 0; $i < $pagesfound; $i++) { |
|
245 | + } else { |
|
246 | + for ($i = 0; $i < $pagesfound; $i++) { |
|
247 | 247 | $paging .= $array_row_paging[$i] . " "; |
248 | 248 | } |
249 | 249 | } |
@@ -278,12 +278,12 @@ discard block |
||
278 | 278 | // grab the entire log file... |
279 | 279 | $logentries = array(); |
280 | 280 | $i = 0; |
281 | - while ($logentry = $modx->db->getRow($rs)) { |
|
282 | - if (!preg_match("/^[0-9]+$/", $logentry['itemid'])) { |
|
281 | + while ($logentry = $modx->db->getRow($rs)) { |
|
282 | + if (!preg_match("/^[0-9]+$/", $logentry['itemid'])) { |
|
283 | 283 | $item = '<div style="text-align:center;">-</div>'; |
284 | - } elseif ($logentry['action'] == 3 || $logentry['action'] == 27 || $logentry['action'] == 5) { |
|
284 | + } elseif ($logentry['action'] == 3 || $logentry['action'] == 27 || $logentry['action'] == 5) { |
|
285 | 285 | $item = '<a href="index.php?a=3&id=' . $logentry['itemid'] . '">' . $logentry['itemname'] . '</a>'; |
286 | - } else { |
|
286 | + } else { |
|
287 | 287 | $item = $logentry['itemname']; |
288 | 288 | } |
289 | 289 | //index.php?a=13&searchuser=' . $logentry['internalKey'] . '&action=' . $logentry['action'] . '&itemname=' . $logentry['itemname'] . '&log_submit=true' |
@@ -318,6 +318,6 @@ discard block |
||
318 | 318 | // @see index.php @ 915 |
319 | 319 | global $action; |
320 | 320 | $action = 1; |
321 | -} else { |
|
321 | +} else { |
|
322 | 322 | echo $_lang["mgrlog_noquery"]; |
323 | 323 | } |
@@ -18,8 +18,7 @@ discard block |
||
18 | 18 | $this->db = & $modx->db; |
19 | 19 | $this->db_tbl['categories'] = $modx->getFullTableName('categories'); |
20 | 20 | |
21 | - foreach( $this->elements as $element ) |
|
22 | - { |
|
21 | + foreach( $this->elements as $element ) { |
|
23 | 22 | $this->db_tbl[$element] = $modx->getFullTableName('site_' . $element ); |
24 | 23 | } |
25 | 24 | } |
@@ -69,8 +68,7 @@ discard block |
||
69 | 68 | |
70 | 69 | public function getAssignedElements( $category_id, $element ) |
71 | 70 | { |
72 | - if( in_array( $element, $this->elements, true ) ) |
|
73 | - { |
|
71 | + if( in_array( $element, $this->elements, true ) ) { |
|
74 | 72 | $elements = $this->db->makeArray( |
75 | 73 | $this->db->select( |
76 | 74 | '*', |
@@ -80,11 +78,9 @@ discard block |
||
80 | 78 | ); |
81 | 79 | |
82 | 80 | // correct the name of templates |
83 | - if( $element === 'templates' ) |
|
84 | - { |
|
81 | + if( $element === 'templates' ) { |
|
85 | 82 | $_elements_count = count($elements); |
86 | - for( $i=0; $i < $_elements_count; $i++ ) |
|
87 | - { |
|
83 | + for( $i=0; $i < $_elements_count; $i++ ) { |
|
88 | 84 | $elements[$i]['name'] = $elements[$i]['templatename']; |
89 | 85 | } |
90 | 86 | } |
@@ -96,8 +92,7 @@ discard block |
||
96 | 92 | public function getAllAssignedElements( $category_id ) |
97 | 93 | { |
98 | 94 | $elements = array(); |
99 | - foreach( $this->elements as $element ) |
|
100 | - { |
|
95 | + foreach( $this->elements as $element ) { |
|
101 | 96 | $elements[$element] = $this->getAssignedElements( $category_id, $element ); |
102 | 97 | } |
103 | 98 | return $elements; |
@@ -106,8 +101,7 @@ discard block |
||
106 | 101 | public function deleteCategory( $category_id ) |
107 | 102 | { |
108 | 103 | $_update = array('category' => 0); |
109 | - foreach( $this->elements as $element ) |
|
110 | - { |
|
104 | + foreach( $this->elements as $element ) { |
|
111 | 105 | $this->db->update( |
112 | 106 | $_update, |
113 | 107 | $this->db_tbl[$element], |
@@ -126,8 +120,7 @@ discard block |
||
126 | 120 | public function updateCategory( $category_id, $data = array() ) |
127 | 121 | { |
128 | 122 | if( empty( $data ) |
129 | - || empty( $category_id ) ) |
|
130 | - { |
|
123 | + || empty( $category_id ) ) { |
|
131 | 124 | return false; |
132 | 125 | } |
133 | 126 | |
@@ -142,8 +135,7 @@ discard block |
||
142 | 135 | "`id` = '" . (int)$category_id . "'" |
143 | 136 | ); |
144 | 137 | |
145 | - if( $this->db->getAffectedRows() === 1 ) |
|
146 | - { |
|
138 | + if( $this->db->getAffectedRows() === 1 ) { |
|
147 | 139 | return true; |
148 | 140 | } |
149 | 141 | |
@@ -152,8 +144,7 @@ discard block |
||
152 | 144 | |
153 | 145 | public function addCategory( $category_name, $category_rank ) |
154 | 146 | { |
155 | - if( $this->isCategoryExists( $category_name ) ) |
|
156 | - { |
|
147 | + if( $this->isCategoryExists( $category_name ) ) { |
|
157 | 148 | return false; |
158 | 149 | } |
159 | 150 | |
@@ -167,8 +158,7 @@ discard block |
||
167 | 158 | $this->db_tbl['categories'] |
168 | 159 | ); |
169 | 160 | |
170 | - if( $this->db->getAffectedRows() === 1 ) |
|
171 | - { |
|
161 | + if( $this->db->getAffectedRows() === 1 ) { |
|
172 | 162 | return $this->db->getInsertId(); |
173 | 163 | } |
174 | 164 | |
@@ -187,8 +177,7 @@ discard block |
||
187 | 177 | ) |
188 | 178 | ); |
189 | 179 | |
190 | - if( $this->db->getAffectedRows() === 1 ) |
|
191 | - { |
|
180 | + if( $this->db->getAffectedRows() === 1 ) { |
|
192 | 181 | return $category_id; |
193 | 182 | } |
194 | 183 | return false; |
@@ -43,7 +43,8 @@ discard block |
||
43 | 43 | ## see sample.php for test and usage |
44 | 44 | ## sample URL: http://www.program-ruti.org/veriword/ |
45 | 45 | #### |
46 | -class VeriWord { |
|
46 | +class VeriWord |
|
47 | +{ |
|
47 | 48 | |
48 | 49 | /* path to font directory*/ |
49 | 50 | public $dir_font = "ttf/"; |
@@ -54,7 +55,8 @@ discard block |
||
54 | 55 | public $im_height = 0; |
55 | 56 | public $im; |
56 | 57 | |
57 | - public function __construct($w=200, $h=80) { |
|
58 | + public function __construct($w=200, $h=80) |
|
59 | + { |
|
58 | 60 | /* create session to set word for verification */ |
59 | 61 | startCMSSession(); |
60 | 62 | $this->set_veriword(); |
@@ -63,21 +65,24 @@ discard block |
||
63 | 65 | $this->im_height = $h; |
64 | 66 | } |
65 | 67 | |
66 | - public function set_veriword() { |
|
68 | + public function set_veriword() |
|
69 | + { |
|
67 | 70 | /* create session variable for verification, |
68 | 71 | you may change the session variable name */ |
69 | 72 | $this->word = $this->pick_word(); |
70 | 73 | $_SESSION['veriword'] = $this->word; |
71 | 74 | } |
72 | 75 | |
73 | - public function output_image() { |
|
76 | + public function output_image() |
|
77 | + { |
|
74 | 78 | /* output the image as jpeg */ |
75 | 79 | $this->draw_image(); |
76 | 80 | header("Content-type: image/jpeg"); |
77 | 81 | imagejpeg($this->im); |
78 | 82 | } |
79 | 83 | |
80 | - public function pick_word() { |
|
84 | + public function pick_word() |
|
85 | + { |
|
81 | 86 | global $modx; |
82 | 87 | // set default words |
83 | 88 | $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"; |
@@ -88,7 +93,8 @@ discard block |
||
88 | 93 | return (string) $arr_words[array_rand($arr_words)].rand(10,999); |
89 | 94 | } |
90 | 95 | |
91 | - public function draw_text() { |
|
96 | + public function draw_text() |
|
97 | + { |
|
92 | 98 | $dir = dir($this->dir_font); |
93 | 99 | $fontstmp = array(); |
94 | 100 | while (false !== ($file = $dir->read())) { |
@@ -143,7 +149,8 @@ discard block |
||
143 | 149 | } |
144 | 150 | |
145 | 151 | |
146 | - public function draw_image() { |
|
152 | + public function draw_image() |
|
153 | + { |
|
147 | 154 | |
148 | 155 | /* pick one background image randomly from image directory */ |
149 | 156 | $img_file = $this->dir_noise."noise".rand(1,4).".jpg"; |
@@ -174,7 +181,8 @@ discard block |
||
174 | 181 | return $this->im; |
175 | 182 | } |
176 | 183 | |
177 | - public function destroy_image() { |
|
184 | + public function destroy_image() |
|
185 | + { |
|
178 | 186 | |
179 | 187 | imagedestroy($this->im); |
180 | 188 |
@@ -304,7 +304,8 @@ discard block |
||
304 | 304 | } |
305 | 305 | |
306 | 306 | public function save($fields, $table, $where = '') |
307 | - { // This is similar to "replace into table". |
|
307 | + { |
|
308 | +// This is similar to "replace into table". |
|
308 | 309 | |
309 | 310 | if ($where === '') { |
310 | 311 | $mode = 'insert'; |
@@ -386,7 +387,7 @@ discard block |
||
386 | 387 | { |
387 | 388 | $out = false; |
388 | 389 | if (is_object($ds)) { |
389 | - switch($mode){ |
|
390 | + switch($mode) { |
|
390 | 391 | case 'assoc': |
391 | 392 | $out = $ds->fetch_assoc(); |
392 | 393 | break; |