@@ -5,9 +5,9 @@ |
||
5 | 5 | * Time: 14:16 |
6 | 6 | */ |
7 | 7 | |
8 | -if (!include_once MODX_MANAGER_PATH . 'includes/extenders/manager.api.class.inc.php'){ |
|
8 | +if (!include_once MODX_MANAGER_PATH . 'includes/extenders/manager.api.class.inc.php') { |
|
9 | 9 | return false; |
10 | -}else{ |
|
10 | +} else { |
|
11 | 11 | $this->manager= new ManagerAPI; |
12 | 12 | return true; |
13 | 13 | } |
14 | 14 | \ No newline at end of file |
@@ -1,8 +1,11 @@ |
||
1 | 1 | <?php |
2 | 2 | $userid = intval($value); |
3 | 3 | if (!isset($modx->filter->cache['ui'][$userid])) { |
4 | - if ($userid < 0) $user = $modx->getWebUserInfo(abs($userid)); |
|
5 | - else $user = $modx->getUserInfo($userid); |
|
4 | + if ($userid < 0) { |
|
5 | + $user = $modx->getWebUserInfo(abs($userid)); |
|
6 | + } else { |
|
7 | + $user = $modx->getUserInfo($userid); |
|
8 | + } |
|
6 | 9 | $modx->filter->cache['ui'][$userid] = $user; |
7 | 10 | } else { |
8 | 11 | $user = $modx->filter->cache['ui'][$userid]; |
@@ -1,16 +1,17 @@ |
||
1 | 1 | <?php |
2 | 2 | $pattern = '/<img[\s\n]+.*src=[\s\n]*"([^"]+\.(jpg|jpeg|png|gif))"[^>]+>/i'; |
3 | 3 | preg_match_all($pattern , $value , $images); |
4 | -if($opt==='') |
|
5 | -{ |
|
6 | - if($images[1][0]) return $images[1][0]; |
|
7 | - else return ''; |
|
8 | -} |
|
9 | -else |
|
10 | -{ |
|
11 | - foreach($images[0] as $i=>$image) |
|
12 | - { |
|
13 | - if(strpos($image,$opt)!==false) return $images[1][$i]; |
|
4 | +if($opt==='') { |
|
5 | + if($images[1][0]) { |
|
6 | + return $images[1][0]; |
|
7 | + } else { |
|
8 | + return ''; |
|
9 | + } |
|
10 | + } else { |
|
11 | + foreach($images[0] as $i=>$image) { |
|
12 | + if(strpos($image,$opt)!==false) { |
|
13 | + return $images[1][$i]; |
|
14 | + } |
|
14 | 15 | } |
15 | 16 | } |
16 | 17 |
@@ -9,14 +9,15 @@ |
||
9 | 9 | $blockElms = explode(',', $blockElms); |
10 | 10 | $lines = explode("\n",$text); |
11 | 11 | $c = count($lines); |
12 | -foreach($lines as $i=>$line) |
|
13 | -{ |
|
12 | +foreach($lines as $i=>$line) { |
|
14 | 13 | $line = rtrim($line); |
15 | - if($i===$c-1) break; |
|
16 | - foreach($blockElms as $block) |
|
17 | - { |
|
18 | - if(preg_match("@</?{$block}" . '[^>]*>$@',$line)) |
|
19 | - continue 2; |
|
14 | + if($i===$c-1) { |
|
15 | + break; |
|
16 | + } |
|
17 | + foreach($blockElms as $block) { |
|
18 | + if(preg_match("@</?{$block}" . '[^>]*>$@',$line)) { |
|
19 | + continue 2; |
|
20 | + } |
|
20 | 21 | } |
21 | 22 | $lines[$i] = "{$line}<br />"; |
22 | 23 | } |
@@ -1,9 +1,11 @@ discard block |
||
1 | 1 | <?php |
2 | -if(strpos($opt,',')) list($limit,$delim) = explode(',', $opt); |
|
3 | -elseif(preg_match('/^[1-9][0-9]*$/',$opt)) {$limit=$opt;$delim='';} |
|
4 | -else {$limit=124;$delim='';} |
|
2 | +if(strpos($opt,',')) { |
|
3 | + list($limit,$delim) = explode(',', $opt); |
|
4 | +} elseif(preg_match('/^[1-9][0-9]*$/',$opt)) {$limit=$opt;$delim='';} else {$limit=124;$delim='';} |
|
5 | 5 | |
6 | -if($delim==='') $delim = $modx->config['manager_language']==='japanese-utf8' ? '。' : '.'; |
|
6 | +if($delim==='') { |
|
7 | + $delim = $modx->config['manager_language']==='japanese-utf8' ? '。' : '.'; |
|
8 | +} |
|
7 | 9 | $limit = intval($limit); |
8 | 10 | |
9 | 11 | $content = $modx->filter->parseDocumentSource($value); |
@@ -11,8 +13,9 @@ discard block |
||
11 | 13 | $content = strip_tags($content); |
12 | 14 | |
13 | 15 | $content = str_replace(array("\r\n","\r","\n","\t",' '),' ',$content); |
14 | -if(preg_match('/\s+/',$content)) |
|
16 | +if(preg_match('/\s+/',$content)) { |
|
15 | 17 | $content = preg_replace('/\s+/',' ',$content); |
18 | +} |
|
16 | 19 | $content = trim($content); |
17 | 20 | |
18 | 21 | $pos = $modx->filter->strpos($content, $delim); |
@@ -21,23 +24,35 @@ discard block |
||
21 | 24 | $_ = explode($delim, $content); |
22 | 25 | $text = ''; |
23 | 26 | foreach($_ as $v) { |
24 | - if($limit <= $modx->filter->strlen($text.$v.$delim)) break; |
|
27 | + if($limit <= $modx->filter->strlen($text.$v.$delim)) { |
|
28 | + break; |
|
29 | + } |
|
25 | 30 | $text .= $v.$delim; |
26 | 31 | } |
27 | - if($text) $content = $text; |
|
28 | -} |
|
32 | + if($text) { |
|
33 | + $content = $text; |
|
34 | + } |
|
35 | + } |
|
29 | 36 | |
30 | 37 | if($limit<$modx->filter->strlen($content) && strpos($content,' ')!==false) { |
31 | 38 | $_ = explode(' ', $content); |
32 | 39 | $text = ''; |
33 | 40 | foreach($_ as $v) { |
34 | - if($limit <= $modx->filter->strlen($text.$v.' ')) break; |
|
41 | + if($limit <= $modx->filter->strlen($text.$v.' ')) { |
|
42 | + break; |
|
43 | + } |
|
35 | 44 | $text .= $v . ' '; |
36 | 45 | } |
37 | - if($text!=='') $content = $text; |
|
38 | -} |
|
46 | + if($text!=='') { |
|
47 | + $content = $text; |
|
48 | + } |
|
49 | + } |
|
39 | 50 | |
40 | -if($limit < $modx->filter->strlen($content)) $content = $modx->filter->substr($content, 0, $limit); |
|
41 | -if($modx->filter->substr($content,-1)==$delim) $content = rtrim($content,$delim) . $delim; |
|
51 | +if($limit < $modx->filter->strlen($content)) { |
|
52 | + $content = $modx->filter->substr($content, 0, $limit); |
|
53 | +} |
|
54 | +if($modx->filter->substr($content,-1)==$delim) { |
|
55 | + $content = rtrim($content,$delim) . $delim; |
|
56 | +} |
|
42 | 57 | |
43 | 58 | return $content; |
@@ -5,11 +5,14 @@ discard block |
||
5 | 5 | $groupNames = ($this->strlen($opt) > 0 ) ? explode(',',$opt) : array(); |
6 | 6 | |
7 | 7 | // if $groupNames is not an array return false |
8 | -if(!is_array($groupNames)) return 0; |
|
8 | +if(!is_array($groupNames)) { |
|
9 | + return 0; |
|
10 | +} |
|
9 | 11 | |
10 | 12 | // Creates an array with all webgroups the user id is in |
11 | -if (isset($modx->filter->cache['mo'][$userID])) $grpNames = $modx->filter->cache['mo'][$userID]; |
|
12 | -else { |
|
13 | +if (isset($modx->filter->cache['mo'][$userID])) { |
|
14 | + $grpNames = $modx->filter->cache['mo'][$userID]; |
|
15 | +} else { |
|
13 | 16 | $from = sprintf("[+prefix+]webgroup_names wgn INNER JOIN [+prefix+]web_groups wg ON wg.webgroup=wgn.id AND wg.webuser='%s'",$userID); |
14 | 17 | $rs = $modx->db->select('wgn.name',$from); |
15 | 18 | $modx->filter->cache['mo'][$userID] = $grpNames = $modx->db->getColumn('name',$rs); |
@@ -17,8 +20,10 @@ discard block |
||
17 | 20 | |
18 | 21 | // Check if a supplied group matches a webgroup from the array we just created |
19 | 22 | foreach($groupNames as $k=>$v) { |
20 | - if(in_array(trim($v),$grpNames)) return 1; |
|
21 | -} |
|
23 | + if(in_array(trim($v),$grpNames)) { |
|
24 | + return 1; |
|
25 | + } |
|
26 | + } |
|
22 | 27 | |
23 | 28 | // If we get here the above logic did not find a match, so return false |
24 | 29 | return 0; |
@@ -5,13 +5,13 @@ |
||
5 | 5 | * Time: 12:25 |
6 | 6 | */ |
7 | 7 | |
8 | -if (isset($this->phpcompat) && is_object($this->phpcompat)){ |
|
8 | +if (isset($this->phpcompat) && is_object($this->phpcompat)) { |
|
9 | 9 | return true; |
10 | 10 | } |
11 | 11 | |
12 | -if (!include_once(MODX_MANAGER_PATH . 'includes/extenders/phpcompat.class.inc.php')){ |
|
12 | +if (!include_once(MODX_MANAGER_PATH . 'includes/extenders/phpcompat.class.inc.php')) { |
|
13 | 13 | return false; |
14 | -}else{ |
|
14 | +} else { |
|
15 | 15 | $this->phpcompat = new PHPCOMPAT; |
16 | 16 | return true; |
17 | 17 | } |
@@ -5,13 +5,13 @@ |
||
5 | 5 | * Time: 19:14 |
6 | 6 | */ |
7 | 7 | |
8 | -if (isset($this->phpass) && is_object($this->phpass)){ |
|
8 | +if (isset($this->phpass) && is_object($this->phpass)) { |
|
9 | 9 | return true; |
10 | 10 | } |
11 | 11 | |
12 | -if (!include_once(MODX_MANAGER_PATH . 'includes/extenders/phpass.class.inc.php')){ |
|
12 | +if (!include_once(MODX_MANAGER_PATH . 'includes/extenders/phpass.class.inc.php')) { |
|
13 | 13 | return false; |
14 | -}else{ |
|
14 | +} else { |
|
15 | 15 | $this->phpass = new PasswordHash; |
16 | 16 | return true; |
17 | 17 | } |
18 | 18 | \ No newline at end of file |
@@ -1,16 +1,32 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | $this->old = new OldFunctions(); |
3 | -class OldFunctions { |
|
3 | +class OldFunctions |
|
4 | +{ |
|
4 | 5 | |
5 | - function dbConnect() {global $modx; $modx->db->connect();$modx->rs = $modx->db->conn;} |
|
6 | - function dbQuery($sql) {global $modx;return $modx->db->query($sql);} |
|
7 | - function recordCount($rs) {global $modx;return $modx->db->getRecordCount($rs);} |
|
8 | - function fetchRow($rs,$mode='assoc') {global $modx;return $modx->db->getRow($rs, $mode);} |
|
9 | - function affectedRows($rs) {global $modx;return $modx->db->getAffectedRows($rs);} |
|
10 | - function insertId($rs) {global $modx;return $modx->db->getInsertId($rs);} |
|
11 | - function dbClose() {global $modx; $modx->db->disconnect();} |
|
6 | + function dbConnect() |
|
7 | + { |
|
8 | +global $modx; $modx->db->connect();$modx->rs = $modx->db->conn;} |
|
9 | + function dbQuery($sql) |
|
10 | + { |
|
11 | +global $modx;return $modx->db->query($sql);} |
|
12 | + function recordCount($rs) |
|
13 | + { |
|
14 | +global $modx;return $modx->db->getRecordCount($rs);} |
|
15 | + function fetchRow($rs,$mode='assoc') |
|
16 | + { |
|
17 | +global $modx;return $modx->db->getRow($rs, $mode);} |
|
18 | + function affectedRows($rs) |
|
19 | + { |
|
20 | +global $modx;return $modx->db->getAffectedRows($rs);} |
|
21 | + function insertId($rs) |
|
22 | + { |
|
23 | +global $modx;return $modx->db->getInsertId($rs);} |
|
24 | + function dbClose() |
|
25 | + { |
|
26 | +global $modx; $modx->db->disconnect();} |
|
12 | 27 | |
13 | - function makeList($array, $ulroot= 'root', $ulprefix= 'sub_', $type= '', $ordered= false, $tablevel= 0) { |
|
28 | + function makeList($array, $ulroot= 'root', $ulprefix= 'sub_', $type= '', $ordered= false, $tablevel= 0) |
|
29 | + { |
|
14 | 30 | // first find out whether the value passed is an array |
15 | 31 | if (!is_array($array)) { |
16 | 32 | return "<ul><li>Bad list</li></ul>"; |
@@ -37,7 +53,8 @@ discard block |
||
37 | 53 | } |
38 | 54 | |
39 | 55 | |
40 | - function getUserData() { |
|
56 | + function getUserData() |
|
57 | + { |
|
41 | 58 | $client['ip'] = $_SERVER['REMOTE_ADDR']; |
42 | 59 | $client['ua'] = $_SERVER['HTTP_USER_AGENT']; |
43 | 60 | return $client; |
@@ -45,35 +62,42 @@ discard block |
||
45 | 62 | |
46 | 63 | # Returns true, install or interact when inside manager |
47 | 64 | // deprecated |
48 | - function insideManager() { |
|
65 | + function insideManager() |
|
66 | + { |
|
49 | 67 | $m= false; |
50 | 68 | if (defined('IN_MANAGER_MODE') && IN_MANAGER_MODE == 'true') { |
51 | 69 | $m= true; |
52 | - if (defined('SNIPPET_INTERACTIVE_MODE') && SNIPPET_INTERACTIVE_MODE == 'true') |
|
53 | - $m= "interact"; |
|
54 | - else |
|
55 | - if (defined('SNIPPET_INSTALL_MODE') && SNIPPET_INSTALL_MODE == 'true') |
|
56 | - $m= "install"; |
|
70 | + if (defined('SNIPPET_INTERACTIVE_MODE') && SNIPPET_INTERACTIVE_MODE == 'true') { |
|
71 | + $m= "interact"; |
|
72 | + } else |
|
73 | + if (defined('SNIPPET_INSTALL_MODE') && SNIPPET_INSTALL_MODE == 'true') { |
|
74 | + $m= "install"; |
|
75 | + } |
|
57 | 76 | } |
58 | 77 | return $m; |
59 | 78 | } |
60 | 79 | |
61 | 80 | // deprecated |
62 | - function putChunk($chunkName) { // alias name >.< |
|
81 | + function putChunk($chunkName) |
|
82 | + { |
|
83 | +// alias name >.< |
|
63 | 84 | global $modx; |
64 | 85 | return $modx->getChunk($chunkName); |
65 | 86 | } |
66 | 87 | |
67 | - function getDocGroups() { |
|
88 | + function getDocGroups() |
|
89 | + { |
|
68 | 90 | global $modx; |
69 | 91 | return $modx->getUserDocGroups(); |
70 | 92 | } // deprecated |
71 | 93 | |
72 | - function changePassword($o, $n) { |
|
94 | + function changePassword($o, $n) |
|
95 | + { |
|
73 | 96 | return changeWebUserPassword($o, $n); |
74 | 97 | } // deprecated |
75 | 98 | |
76 | - function userLoggedIn() { |
|
99 | + function userLoggedIn() |
|
100 | + { |
|
77 | 101 | global $modx; |
78 | 102 | $userdetails= array (); |
79 | 103 | if ($modx->isFrontend() && isset ($_SESSION['webValidated'])) { |
@@ -96,18 +120,22 @@ discard block |
||
96 | 120 | } |
97 | 121 | } |
98 | 122 | |
99 | - function getFormVars($method= "", $prefix= "", $trim= "", $REQUEST_METHOD) { |
|
123 | + function getFormVars($method= "", $prefix= "", $trim= "", $REQUEST_METHOD) |
|
124 | + { |
|
100 | 125 | // function to retrieve form results into an associative array |
101 | 126 | global $modx; |
102 | 127 | $results= array (); |
103 | 128 | $method= strtoupper($method); |
104 | - if ($method == "") |
|
105 | - $method= $REQUEST_METHOD; |
|
106 | - if ($method == "POST") |
|
107 | - $method= & $_POST; |
|
108 | - elseif ($method == "GET") $method= & $_GET; |
|
109 | - else |
|
110 | - return false; |
|
129 | + if ($method == "") { |
|
130 | + $method= $REQUEST_METHOD; |
|
131 | + } |
|
132 | + if ($method == "POST") { |
|
133 | + $method= & $_POST; |
|
134 | + } elseif ($method == "GET") { |
|
135 | + $method= & $_GET; |
|
136 | + } else { |
|
137 | + return false; |
|
138 | + } |
|
111 | 139 | reset($method); |
112 | 140 | foreach ($method as $key => $value) { |
113 | 141 | if (($prefix != "") && (substr($key, 0, strlen($prefix)) == $prefix)) { |
@@ -115,10 +143,12 @@ discard block |
||
115 | 143 | $pieces= explode($prefix, $key, 2); |
116 | 144 | $key= $pieces[1]; |
117 | 145 | $results[$key]= $value; |
118 | - } else |
|
119 | - $results[$key]= $value; |
|
146 | + } else { |
|
147 | + $results[$key]= $value; |
|
148 | + } |
|
149 | + } elseif ($prefix == "") { |
|
150 | + $results[$key]= $value; |
|
120 | 151 | } |
121 | - elseif ($prefix == "") $results[$key]= $value; |
|
122 | 152 | } |
123 | 153 | return $results; |
124 | 154 | } |
@@ -129,7 +159,8 @@ discard block |
||
129 | 159 | * @param string $msg Message to show |
130 | 160 | * @param string $url URL to redirect to |
131 | 161 | */ |
132 | - function webAlert($msg, $url= "") { |
|
162 | + function webAlert($msg, $url= "") |
|
163 | + { |
|
133 | 164 | global $modx; |
134 | 165 | $msg= addslashes($modx->db->escape($msg)); |
135 | 166 | if (substr(strtolower($url), 0, 11) == "javascript:") { |
@@ -139,9 +170,9 @@ discard block |
||
139 | 170 | $act= ($url ? "window.location.href='" . addslashes($url) . "';" : ""); |
140 | 171 | } |
141 | 172 | $html= "<script>$fnc window.setTimeout(\"alert('$msg');$act\",100);</script>"; |
142 | - if ($modx->isFrontend()) |
|
143 | - $modx->regClientScript($html); |
|
144 | - else { |
|
173 | + if ($modx->isFrontend()) { |
|
174 | + $modx->regClientScript($html); |
|
175 | + } else { |
|
145 | 176 | echo $html; |
146 | 177 | } |
147 | 178 | } |