Completed
Push — develop ( 923a1c...1e9876 )
by Maxim
47s queued 29s
created
manager/includes/extenders/ex_phpcompat.inc.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -5,13 +5,13 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
manager/includes/extenders/ex_phpass.inc.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -5,13 +5,13 @@
 block discarded – undo
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
Please login to merge, or discard this patch.
manager/includes/extenders/deprecated.functions.inc.php 1 patch
Spacing   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -1,43 +1,43 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 $this->old = new OldFunctions();
3
-class OldFunctions {
3
+class OldFunctions{
4 4
     
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();}
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(); }
12 12
     
13
-    function makeList($array, $ulroot= 'root', $ulprefix= 'sub_', $type= '', $ordered= false, $tablevel= 0) {
13
+    function makeList($array, $ulroot = 'root', $ulprefix = 'sub_', $type = '', $ordered = false, $tablevel = 0){
14 14
         // first find out whether the value passed is an array
15 15
         if (!is_array($array)) {
16 16
             return "<ul><li>Bad list</li></ul>";
17 17
         }
18 18
         if (!empty ($type)) {
19
-            $typestr= " style='list-style-type: $type'";
19
+            $typestr = " style='list-style-type: $type'";
20 20
         } else {
21
-            $typestr= "";
21
+            $typestr = "";
22 22
         }
23
-        $tabs= "";
24
-        for ($i= 0; $i < $tablevel; $i++) {
23
+        $tabs = "";
24
+        for ($i = 0; $i < $tablevel; $i++) {
25 25
             $tabs .= "\t";
26 26
         }
27
-        $listhtml= $ordered == true ? $tabs . "<ol class='$ulroot'$typestr>\n" : $tabs . "<ul class='$ulroot'$typestr>\n";
27
+        $listhtml = $ordered == true ? $tabs."<ol class='$ulroot'$typestr>\n" : $tabs."<ul class='$ulroot'$typestr>\n";
28 28
         foreach ($array as $key => $value) {
29 29
             if (is_array($value)) {
30
-                $listhtml .= $tabs . "\t<li>" . $key . "\n" . $this->makeList($value, $ulprefix . $ulroot, $ulprefix, $type, $ordered, $tablevel +2) . $tabs . "\t</li>\n";
30
+                $listhtml .= $tabs."\t<li>".$key."\n".$this->makeList($value, $ulprefix.$ulroot, $ulprefix, $type, $ordered, $tablevel + 2).$tabs."\t</li>\n";
31 31
             } else {
32
-                $listhtml .= $tabs . "\t<li>" . $value . "</li>\n";
32
+                $listhtml .= $tabs."\t<li>".$value."</li>\n";
33 33
             }
34 34
         }
35
-        $listhtml .= $ordered == true ? $tabs . "</ol>\n" : $tabs . "</ul>\n";
35
+        $listhtml .= $ordered == true ? $tabs."</ol>\n" : $tabs."</ul>\n";
36 36
         return $listhtml;
37 37
     }
38 38
 
39 39
     
40
-    function getUserData() {
40
+    function getUserData(){
41 41
         $client['ip'] = $_SERVER['REMOTE_ADDR'];
42 42
         $client['ua'] = $_SERVER['HTTP_USER_AGENT'];
43 43
     	return $client;
@@ -45,80 +45,80 @@  discard block
 block discarded – undo
45 45
     
46 46
     # Returns true, install or interact when inside manager
47 47
     // deprecated
48
-    function insideManager() {
49
-        $m= false;
48
+    function insideManager(){
49
+        $m = false;
50 50
         if (defined('IN_MANAGER_MODE') && IN_MANAGER_MODE == 'true') {
51
-            $m= true;
51
+            $m = true;
52 52
             if (defined('SNIPPET_INTERACTIVE_MODE') && SNIPPET_INTERACTIVE_MODE == 'true')
53
-                $m= "interact";
53
+                $m = "interact";
54 54
             else
55 55
                 if (defined('SNIPPET_INSTALL_MODE') && SNIPPET_INSTALL_MODE == 'true')
56
-                    $m= "install";
56
+                    $m = "install";
57 57
         }
58 58
         return $m;
59 59
     }
60 60
 
61 61
     // deprecated
62
-    function putChunk($chunkName) { // alias name >.<
62
+    function putChunk($chunkName){ // alias name >.<
63 63
     	global $modx;
64 64
         return $modx->getChunk($chunkName);
65 65
     }
66 66
 
67
-    function getDocGroups() {
67
+    function getDocGroups(){
68 68
     	global $modx;
69 69
         return $modx->getUserDocGroups();
70 70
     } // deprecated
71 71
 
72
-    function changePassword($o, $n) {
72
+    function changePassword($o, $n){
73 73
         return changeWebUserPassword($o, $n);
74 74
     } // deprecated
75 75
     
76
-    function userLoggedIn() {
76
+    function userLoggedIn(){
77 77
     	global $modx;
78
-        $userdetails= array ();
78
+        $userdetails = array();
79 79
         if ($modx->isFrontend() && isset ($_SESSION['webValidated'])) {
80 80
             // web user
81
-            $userdetails['loggedIn']= true;
82
-            $userdetails['id']= $_SESSION['webInternalKey'];
83
-            $userdetails['username']= $_SESSION['webShortname'];
84
-            $userdetails['usertype']= 'web'; // added by Raymond
81
+            $userdetails['loggedIn'] = true;
82
+            $userdetails['id'] = $_SESSION['webInternalKey'];
83
+            $userdetails['username'] = $_SESSION['webShortname'];
84
+            $userdetails['usertype'] = 'web'; // added by Raymond
85 85
             return $userdetails;
86 86
         } else
87 87
             if ($modx->isBackend() && isset ($_SESSION['mgrValidated'])) {
88 88
                 // manager user
89
-                $userdetails['loggedIn']= true;
90
-                $userdetails['id']= $_SESSION['mgrInternalKey'];
91
-                $userdetails['username']= $_SESSION['mgrShortname'];
92
-                $userdetails['usertype']= 'manager'; // added by Raymond
89
+                $userdetails['loggedIn'] = true;
90
+                $userdetails['id'] = $_SESSION['mgrInternalKey'];
91
+                $userdetails['username'] = $_SESSION['mgrShortname'];
92
+                $userdetails['usertype'] = 'manager'; // added by Raymond
93 93
                 return $userdetails;
94 94
             } else {
95 95
                 return false;
96 96
             }
97 97
     }
98 98
     
99
-    function getFormVars($method= "", $prefix= "", $trim= "", $REQUEST_METHOD) {
99
+    function getFormVars($method = "", $prefix = "", $trim = "", $REQUEST_METHOD){
100 100
         //  function to retrieve form results into an associative array
101 101
     	global $modx;
102
-        $results= array ();
103
-        $method= strtoupper($method);
102
+        $results = array();
103
+        $method = strtoupper($method);
104 104
         if ($method == "")
105
-            $method= $REQUEST_METHOD;
105
+            $method = $REQUEST_METHOD;
106 106
         if ($method == "POST")
107
-            $method= & $_POST;
108
-        elseif ($method == "GET") $method= & $_GET;
107
+            $method = & $_POST;
108
+        elseif ($method == "GET") $method = & $_GET;
109 109
         else
110 110
             return false;
111 111
         reset($method);
112 112
         foreach ($method as $key => $value) {
113 113
             if (($prefix != "") && (substr($key, 0, strlen($prefix)) == $prefix)) {
114 114
                 if ($trim) {
115
-                    $pieces= explode($prefix, $key, 2);
116
-                    $key= $pieces[1];
117
-                    $results[$key]= $value;
115
+                    $pieces = explode($prefix, $key, 2);
116
+                    $key = $pieces[1];
117
+                    $results[$key] = $value;
118 118
                 } else
119
-                    $results[$key]= $value;
119
+                    $results[$key] = $value;
120 120
             }
121
-            elseif ($prefix == "") $results[$key]= $value;
121
+            elseif ($prefix == "") $results[$key] = $value;
122 122
         }
123 123
         return $results;
124 124
     }
@@ -129,16 +129,16 @@  discard block
 block discarded – undo
129 129
      * @param string $msg Message to show
130 130
      * @param string $url URL to redirect to
131 131
      */
132
-    function webAlert($msg, $url= "") {
132
+    function webAlert($msg, $url = ""){
133 133
     	global $modx;
134
-        $msg= addslashes($modx->db->escape($msg));
134
+        $msg = addslashes($modx->db->escape($msg));
135 135
         if (substr(strtolower($url), 0, 11) == "javascript:") {
136
-            $act= "__WebAlert();";
137
-            $fnc= "function __WebAlert(){" . substr($url, 11) . "};";
136
+            $act = "__WebAlert();";
137
+            $fnc = "function __WebAlert(){".substr($url, 11)."};";
138 138
         } else {
139
-            $act= ($url ? "window.location.href='" . addslashes($url) . "';" : "");
139
+            $act = ($url ? "window.location.href='".addslashes($url)."';" : "");
140 140
         }
141
-        $html= "<script>$fnc window.setTimeout(\"alert('$msg');$act\",100);</script>";
141
+        $html = "<script>$fnc window.setTimeout(\"alert('$msg');$act\",100);</script>";
142 142
         if ($modx->isFrontend())
143 143
             $modx->regClientScript($html);
144 144
         else {
Please login to merge, or discard this patch.
manager/includes/extenders/modxmailer.class.inc.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -11,9 +11,9 @@  discard block
 block discarded – undo
11 11
 use PHPMailer\PHPMailer\PHPMailer;
12 12
 use PHPMailer\PHPMailer\Exception;
13 13
 
14
-require MODX_MANAGER_PATH . 'includes/controls/phpmailer/Exception.php';
15
-require MODX_MANAGER_PATH . 'includes/controls/phpmailer/PHPMailer.php';
16
-require MODX_MANAGER_PATH . 'includes/controls/phpmailer/SMTP.php';
14
+require MODX_MANAGER_PATH.'includes/controls/phpmailer/Exception.php';
15
+require MODX_MANAGER_PATH.'includes/controls/phpmailer/PHPMailer.php';
16
+require MODX_MANAGER_PATH.'includes/controls/phpmailer/SMTP.php';
17 17
 
18 18
 /**
19 19
  * Class MODxMailer
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
     public function init(\DocumentParser $modx)
32 32
     {
33 33
         $this->modx = $modx;
34
-        $this->PluginDir = MODX_MANAGER_PATH . 'includes/controls/phpmailer/';
34
+        $this->PluginDir = MODX_MANAGER_PATH.'includes/controls/phpmailer/';
35 35
 
36 36
         switch ($modx->config['email_method']) {
37 37
             case 'smtp':
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
             mb_language($this->mb_language);
96 96
             mb_internal_encoding($modx->config['modx_charset']);
97 97
         }
98
-        $exconf = MODX_MANAGER_PATH . 'includes/controls/phpmailer/config.inc.php';
98
+        $exconf = MODX_MANAGER_PATH.'includes/controls/phpmailer/config.inc.php';
99 99
         if (is_file($exconf)) {
100 100
             include($exconf);
101 101
         }
@@ -163,12 +163,12 @@  discard block
 block discarded – undo
163 163
         }
164 164
 
165 165
         if ($this->modx->debug) {
166
-            $debug_info = 'CharSet = ' . $this->CharSet . "\n";
167
-            $debug_info .= 'Encoding = ' . $this->Encoding . "\n";
168
-            $debug_info .= 'mb_language = ' . $this->mb_language . "\n";
169
-            $debug_info .= 'encode_header_method = ' . $this->encode_header_method . "\n";
166
+            $debug_info = 'CharSet = '.$this->CharSet."\n";
167
+            $debug_info .= 'Encoding = '.$this->Encoding."\n";
168
+            $debug_info .= 'mb_language = '.$this->mb_language."\n";
169
+            $debug_info .= 'encode_header_method = '.$this->encode_header_method."\n";
170 170
             $debug_info .= "send_mode = {$mode}\n";
171
-            $debug_info .= 'Subject = ' . $this->Subject . "\n";
171
+            $debug_info .= 'Subject = '.$this->Subject."\n";
172 172
             $log = "<pre>{$debug_info}\n{$header}\n{$org_body}</pre>";
173 173
             $this->modx->logEvent(1, 1, $log, 'MODxMailer debug information');
174 174
 
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
             ini_set('sendmail_from', $old_from);
229 229
         }
230 230
         if (!$rt) {
231
-            $msg = $this->Lang('instantiate') . "<br />\n";
231
+            $msg = $this->Lang('instantiate')."<br />\n";
232 232
             $msg .= "{$this->Subject}<br />\n";
233 233
             $msg .= "{$this->FromName}&lt;{$this->From}&gt;<br />\n";
234 234
             $msg .= mb_convert_encoding($body, $this->modx->config['modx_charset'], $this->CharSet);
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
      */
248 248
     public function SetError($msg)
249 249
     {
250
-        $msg .= '<pre>' . print_r(get_object_vars($this), true) . '</pre>';
250
+        $msg .= '<pre>'.print_r(get_object_vars($this), true).'</pre>';
251 251
         $this->modx->config['send_errormail'] = '0';
252 252
         $this->modx->logEvent(0, 3, $msg, 'phpmailer');
253 253
 
@@ -276,14 +276,14 @@  discard block
 block discarded – undo
276 276
     /**
277 277
      * @return string
278 278
      */
279
-    public function getMIMEHeader() {
279
+    public function getMIMEHeader(){
280 280
         return $this->MIMEHeader;
281 281
     }
282 282
 
283 283
     /**
284 284
      * @return string
285 285
      */
286
-    public function getMIMEBody() {
286
+    public function getMIMEBody(){
287 287
         return $this->MIMEBody;
288 288
     }
289 289
 
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
      * 
293 293
      * @return $this
294 294
      */
295
-    public function setMIMEHeader($header = '') {
295
+    public function setMIMEHeader($header = ''){
296 296
         $this->MIMEHeader = $header;
297 297
 
298 298
         return $this;
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
      * 
304 304
      * @return $this
305 305
      */
306
-    public function setMIMEBody($body = '') {
306
+    public function setMIMEBody($body = ''){
307 307
         $this->MIMEBody = $body;
308 308
 
309 309
         return $this;
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
      * 
315 315
      * @return $this
316 316
      */
317
-    public function setMailHeader($header = '') {
317
+    public function setMailHeader($header = ''){
318 318
         $this->mailHeader = $header;
319 319
 
320 320
         return $this;
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
     /**
324 324
      * @return string
325 325
      */
326
-    public function getMessageID() {
327
-        return trim($this->lastMessageID,'<>');
326
+    public function getMessageID(){
327
+        return trim($this->lastMessageID, '<>');
328 328
     }
329 329
 }
Please login to merge, or discard this patch.
manager/includes/extenders/ex_getUserData.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@
 block discarded – undo
1 1
 <?php
2
-if(IN_MANAGER_MODE!="true" && IN_PARSER_MODE!="true") die("<b>INCLUDE ACCESS ERROR</b><br /><br />Direct access to this file prohibited.");
2
+if (IN_MANAGER_MODE != "true" && IN_PARSER_MODE != "true") die("<b>INCLUDE ACCESS ERROR</b><br /><br />Direct access to this file prohibited.");
3 3
 $tmpArray = array();
4 4
 $tmpArray['ip'] = $_SERVER['REMOTE_ADDR'];
5 5
 $tmpArray['ua'] = $_SERVER['HTTP_USER_AGENT'];
Please login to merge, or discard this patch.
manager/includes/extenders/dbapi.mysqli.class.inc.php 1 patch
Spacing   +84 added lines, -84 removed lines patch added patch discarded remove patch
@@ -1,25 +1,25 @@  discard block
 block discarded – undo
1 1
 <?php
2
-class DBAPI {
2
+class DBAPI{
3 3
 	var $conn;
4 4
 	var $config;
5 5
 	var $lastQuery;
6 6
 	var $isConnected;
7 7
 
8
-	function __construct($host='', $dbase='', $uid='', $pwd='', $pre=NULL, $charset='', $connection_method='SET CHARACTER SET') {
8
+	function __construct($host = '', $dbase = '', $uid = '', $pwd = '', $pre = NULL, $charset = '', $connection_method = 'SET CHARACTER SET'){
9 9
 		$this->config['host'] = $host ? $host : $GLOBALS['database_server'];
10 10
 		$this->config['dbase'] = $dbase ? $dbase : $GLOBALS['dbase'];
11 11
 		$this->config['user'] = $uid ? $uid : $GLOBALS['database_user'];
12 12
 		$this->config['pass'] = $pwd ? $pwd : $GLOBALS['database_password'];
13 13
 		$this->config['charset'] = $charset ? $charset : $GLOBALS['database_connection_charset'];
14
-		$this->config['connection_method'] =  $this->_dbconnectionmethod = (isset($GLOBALS['database_connection_method']) ? $GLOBALS['database_connection_method'] : $connection_method);
14
+		$this->config['connection_method'] = $this->_dbconnectionmethod = (isset($GLOBALS['database_connection_method']) ? $GLOBALS['database_connection_method'] : $connection_method);
15 15
 		$this->config['table_prefix'] = ($pre !== NULL) ? $pre : $GLOBALS['table_prefix'];
16 16
 	}
17 17
 
18
-	function connect($host = '', $dbase = '', $uid = '', $pwd = '', $tmp = 0) {
18
+	function connect($host = '', $dbase = '', $uid = '', $pwd = '', $tmp = 0){
19 19
 		global $modx;
20
-		$uid     = $uid   ? $uid   : $this->config['user'];
21
-		$pwd     = $pwd   ? $pwd   : $this->config['pass'];
22
-		$host    = $host  ? $host  : $this->config['host'];
20
+		$uid     = $uid ? $uid : $this->config['user'];
21
+		$pwd     = $pwd ? $pwd : $this->config['pass'];
22
+		$host    = $host ? $host : $this->config['host'];
23 23
 		$dbase   = $dbase ? $dbase : $this->config['dbase'];
24 24
 		$dbase   = trim($dbase, '`'); // remove the `` chars
25 25
 		$charset = $this->config['charset'];
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 						$ua          = $modx->htmlspecialchars($_SERVER['HTTP_USER_AGENT']);
38 38
 						$referer     = $modx->htmlspecialchars($_SERVER['HTTP_REFERER']);
39 39
 						$modx->sendmail(array(
40
-							'subject' => 'Missing to create the database connection! from ' . $modx->config['site_name'],
40
+							'subject' => 'Missing to create the database connection! from '.$modx->config['site_name'],
41 41
 							'body' => "{$logtitle}\n{$request_uri}\n{$ua}\n{$referer}",
42 42
 							'type' => 'text'
43 43
 						));
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 				sleep(1);
47 47
 				$safe_count++;
48 48
 			}
49
-		} while (!$this->conn && $safe_count<3);
49
+		} while (!$this->conn && $safe_count < 3);
50 50
 		if (!$this->conn) {
51 51
 			$modx->messageQuit("Failed to create the database connection!");
52 52
 			exit;
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 			$tend = $modx->getMicroTime();
56 56
 			$totaltime = $tend - $tstart;
57 57
 			if ($modx->dumpSQL) {
58
-				$modx->queryCode .= "<fieldset style='text-align:left'><legend>Database connection</legend>" . sprintf("Database connection was created in %2.4f s", $totaltime) . "</fieldset><br />";
58
+				$modx->queryCode .= "<fieldset style='text-align:left'><legend>Database connection</legend>".sprintf("Database connection was created in %2.4f s", $totaltime)."</fieldset><br />";
59 59
 			}
60 60
 			$this->conn->set_charset($this->config['charset']);
61 61
 			$this->isConnected = true;
@@ -63,15 +63,15 @@  discard block
 block discarded – undo
63 63
 		}
64 64
 	}
65 65
 
66
-	function disconnect() {
66
+	function disconnect(){
67 67
 		$this->conn->close();
68 68
 		$this->conn = null;
69 69
 		$this->isConnected = false;
70 70
 	}
71 71
 
72
-	function escape($s, $safecount=0) {
72
+	function escape($s, $safecount = 0){
73 73
 		$safecount++;
74
-		if (1000<$safecount) exit("Too many loops '{$safecount}'");
74
+		if (1000 < $safecount) exit("Too many loops '{$safecount}'");
75 75
 		if (empty ($this->conn) || !is_object($this->conn)) {
76 76
 			$this->connect();
77 77
 		}
@@ -89,17 +89,17 @@  discard block
 block discarded – undo
89 89
 		return $s;
90 90
 	}
91 91
 
92
-	function query($sql,$watchError=true) {
92
+	function query($sql, $watchError = true){
93 93
 		global $modx;
94 94
 		if (empty ($this->conn) || !is_object($this->conn)) {
95 95
 			$this->connect();
96 96
 		}
97 97
 		$tstart = $modx->getMicroTime();
98
-		if(is_array($sql)) $sql = join("\n", $sql);
98
+		if (is_array($sql)) $sql = join("\n", $sql);
99 99
 		$this->lastQuery = $sql;
100 100
 		if (!($result = $this->conn->query($sql))) {
101
-			if(!$watchError) return;
102
-            switch(mysqli_errno($this->conn)) {
101
+			if (!$watchError) return;
102
+            switch (mysqli_errno($this->conn)) {
103 103
                 case 1054:
104 104
                 case 1060:
105 105
                 case 1061:
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
                 case 1091:
108 108
                     break;
109 109
                 default:
110
-                    $modx->messageQuit('Execution of a query to the database failed - ' . $this->getLastError(), $sql);
110
+                    $modx->messageQuit('Execution of a query to the database failed - '.$this->getLastError(), $sql);
111 111
             }
112 112
 		} else {
113 113
 			$tend = $modx->getMicroTime();
@@ -119,14 +119,14 @@  discard block
 block discarded – undo
119 119
 				$debug_path = array();
120 120
 				foreach ($debug as $line) $debug_path[] = $line['function'];
121 121
 				$debug_path = implode(' > ', array_reverse($debug_path));
122
-				$modx->queryCode .= "<fieldset style='text-align:left'><legend>Query " . ($modx->executedQueries + 1) . " - " . sprintf("%2.2f ms", $totaltime*1000) . "</legend>";
123
-				$modx->queryCode .= $sql . '<br><br>';
124
-				if ($modx->event->name) $modx->queryCode .= 'Current Event  => ' . $modx->event->name . '<br>';
125
-				if ($modx->event->activePlugin) $modx->queryCode .= 'Current Plugin => ' . $modx->event->activePlugin . '<br>';
126
-				if ($modx->currentSnippet) $modx->queryCode .= 'Current Snippet => ' . $modx->currentSnippet . '<br>';
127
-				if (stripos($sql, 'select')===0) $modx->queryCode .= 'Record Count => ' . $this->getRecordCount($result) . '<br>';
128
-				else $modx->queryCode .= 'Affected Rows => ' . $this->getAffectedRows() . '<br>';
129
-				$modx->queryCode .= 'Functions Path => ' . $debug_path . '<br>';
122
+				$modx->queryCode .= "<fieldset style='text-align:left'><legend>Query ".($modx->executedQueries + 1)." - ".sprintf("%2.2f ms", $totaltime * 1000)."</legend>";
123
+				$modx->queryCode .= $sql.'<br><br>';
124
+				if ($modx->event->name) $modx->queryCode .= 'Current Event  => '.$modx->event->name.'<br>';
125
+				if ($modx->event->activePlugin) $modx->queryCode .= 'Current Plugin => '.$modx->event->activePlugin.'<br>';
126
+				if ($modx->currentSnippet) $modx->queryCode .= 'Current Snippet => '.$modx->currentSnippet.'<br>';
127
+				if (stripos($sql, 'select') === 0) $modx->queryCode .= 'Record Count => '.$this->getRecordCount($result).'<br>';
128
+				else $modx->queryCode .= 'Affected Rows => '.$this->getAffectedRows().'<br>';
129
+				$modx->queryCode .= 'Functions Path => '.$debug_path.'<br>';
130 130
 				$modx->queryCode .= "</fieldset><br />";
131 131
 			}
132 132
 			$modx->executedQueries = $modx->executedQueries + 1;
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 		}
135 135
 	}
136 136
 
137
-	function delete($from, $where='', $orderby='', $limit = '') {
137
+	function delete($from, $where = '', $orderby = '', $limit = ''){
138 138
 		global $modx;
139 139
 		if (!$from) {
140 140
 			$modx->messageQuit("Empty \$from parameters in DBAPI::delete().");
@@ -143,19 +143,19 @@  discard block
 block discarded – undo
143 143
 			$where   = trim($where);
144 144
 			$orderby = trim($orderby);
145 145
 			$limit   = trim($limit);
146
-			if($where!==''    && stripos($where,  'WHERE')!==0)    $where   = "WHERE {$where}";
147
-			if($orderby!== '' && stripos($orderby,'ORDER BY')!==0) $orderby = "ORDER BY {$orderby}";
148
-			if($limit!== ''   && stripos($limit,  'LIMIT')!==0)    $limit   = "LIMIT {$limit}";
146
+			if ($where !== '' && stripos($where, 'WHERE') !== 0)    $where   = "WHERE {$where}";
147
+			if ($orderby !== '' && stripos($orderby, 'ORDER BY') !== 0) $orderby = "ORDER BY {$orderby}";
148
+			if ($limit !== '' && stripos($limit, 'LIMIT') !== 0)    $limit   = "LIMIT {$limit}";
149 149
 			return $this->query("DELETE FROM {$from} {$where} {$orderby} {$limit}");
150 150
 		}
151 151
 	}
152 152
 
153
-	function select($fields = "*", $from = "", $where = "", $orderby = "", $limit = "") {
153
+	function select($fields = "*", $from = "", $where = "", $orderby = "", $limit = ""){
154 154
 		global $modx;
155 155
 		
156
-		if(is_array($fields)) $fields = $this->_getFieldsStringFromArray($fields);
157
-		if(is_array($from))   $from   = $this->_getFromStringFromArray($from);
158
-		if(is_array($where))  $where  = join(' ', $where);
156
+		if (is_array($fields)) $fields = $this->_getFieldsStringFromArray($fields);
157
+		if (is_array($from))   $from   = $this->_getFromStringFromArray($from);
158
+		if (is_array($where))  $where  = join(' ', $where);
159 159
 		
160 160
 		if (!$from) {
161 161
 			$modx->messageQuit("Empty \$from parameters in DBAPI::select().");
@@ -167,13 +167,13 @@  discard block
 block discarded – undo
167 167
         $where   = trim($where);
168 168
         $orderby = trim($orderby);
169 169
         $limit   = trim($limit);
170
-        if($where!==''   && stripos($where,'WHERE')!==0)   $where   = "WHERE {$where}";
171
-        if($orderby!=='' && stripos($orderby,'ORDER')!==0) $orderby = "ORDER BY {$orderby}";
172
-        if($limit!==''   && stripos($limit,'LIMIT')!==0)   $limit   = "LIMIT {$limit}";
170
+        if ($where !== '' && stripos($where, 'WHERE') !== 0)   $where   = "WHERE {$where}";
171
+        if ($orderby !== '' && stripos($orderby, 'ORDER') !== 0) $orderby = "ORDER BY {$orderby}";
172
+        if ($limit !== '' && stripos($limit, 'LIMIT') !== 0)   $limit   = "LIMIT {$limit}";
173 173
 		return $this->query("SELECT {$fields} FROM {$from} {$where} {$orderby} {$limit}");
174 174
 	}
175 175
 
176
-	function update($fields, $table, $where = "") {
176
+	function update($fields, $table, $where = ""){
177 177
 		global $modx;
178 178
 		if (!$table) {
179 179
 			$modx->messageQuit("Empty \$table parameter in DBAPI::update().");
@@ -181,22 +181,22 @@  discard block
 block discarded – undo
181 181
 			$table = $this->replaceFullTableName($table);
182 182
 			if (is_array($fields)) {
183 183
 				foreach ($fields as $key => $value) {
184
-					if(is_null($value) || strtolower($value) === 'null'){
184
+					if (is_null($value) || strtolower($value) === 'null') {
185 185
 						$flds = 'NULL';
186
-					}else{
187
-						$flds = "'" . $value . "'";
186
+					} else {
187
+						$flds = "'".$value."'";
188 188
 					}
189 189
 					$fields[$key] = "`{$key}` = ".$flds;
190 190
 				}
191 191
 				$fields = implode(",", $fields);
192 192
 			}
193 193
 			$where = trim($where);
194
-			if($where!=='' && stripos($where, 'WHERE')!==0) $where = "WHERE {$where}";
194
+			if ($where !== '' && stripos($where, 'WHERE') !== 0) $where = "WHERE {$where}";
195 195
 			return $this->query("UPDATE {$table} SET {$fields} {$where}");
196 196
 		}
197 197
 	}
198 198
 
199
-	function insert($fields, $intotable, $fromfields = "*", $fromtable = "", $where = "", $limit = "") {
199
+	function insert($fields, $intotable, $fromfields = "*", $fromtable = "", $where = "", $limit = ""){
200 200
 		global $modx;
201 201
 		if (!$intotable) {
202 202
 			$modx->messageQuit("Empty \$intotable parameters in DBAPI::insert().");
@@ -213,68 +213,68 @@  discard block
 block discarded – undo
213 213
 					$fields = "(".implode(",", array_keys($fields)).")";
214 214
 					$where = trim($where);
215 215
 					$limit = trim($limit);
216
-					if($where!=='' && stripos($where, 'WHERE')!==0) $where = "WHERE {$where}";
217
-					if($limit!=='' && stripos($limit, 'LIMIT')!==0) $limit = "LIMIT {$limit}";
216
+					if ($where !== '' && stripos($where, 'WHERE') !== 0) $where = "WHERE {$where}";
217
+					if ($limit !== '' && stripos($limit, 'LIMIT') !== 0) $limit = "LIMIT {$limit}";
218 218
 					$rt = $this->query("INSERT INTO {$intotable} {$fields} SELECT {$fromfields} FROM {$fromtable} {$where} {$limit}");
219 219
 				}
220 220
 			}
221
-			if (($lid = $this->getInsertId())===false) $modx->messageQuit("Couldn't get last insert key!");
221
+			if (($lid = $this->getInsertId()) === false) $modx->messageQuit("Couldn't get last insert key!");
222 222
 			return $lid;
223 223
 		}
224 224
 	}
225 225
 
226
-    function save($fields, $table, $where='') { // This is similar to "replace into table".
226
+    function save($fields, $table, $where = ''){ // This is similar to "replace into table".
227 227
         
228
-        if($where === '')                                                  $mode = 'insert';
229
-        elseif($this->getRecordCount($this->select('*',$table,$where))==0) $mode = 'insert';
228
+        if ($where === '')                                                  $mode = 'insert';
229
+        elseif ($this->getRecordCount($this->select('*', $table, $where)) == 0) $mode = 'insert';
230 230
         else                                                               $mode = 'update';
231 231
         
232
-        if($mode==='insert') return $this->insert($fields, $table);
232
+        if ($mode === 'insert') return $this->insert($fields, $table);
233 233
         else                 return $this->update($fields, $table, $where);
234 234
     }
235 235
     
236
-	function isResult($rs) {
236
+	function isResult($rs){
237 237
 		return is_object($rs);
238 238
 	}
239 239
 
240
-	function freeResult($rs) {
240
+	function freeResult($rs){
241 241
 		$rs->free_result();
242 242
 	}
243 243
 
244
-	function numFields($rs) {
244
+	function numFields($rs){
245 245
 		return $rs->field_count;
246 246
 	}
247 247
 
248
-	function fieldName($rs,$col=0) {
248
+	function fieldName($rs, $col = 0){
249 249
 		$field = $rs->fetch_field_direct($col);
250 250
 		return $field->name;
251 251
 	}
252 252
 
253
-	function selectDb($name) {
253
+	function selectDb($name){
254 254
 		$this->conn->select_db($name);
255 255
 	}
256 256
 
257 257
 
258
-	function getInsertId($conn=NULL) {
259
-		if (!is_object($conn)) $conn =& $this->conn;
258
+	function getInsertId($conn = NULL){
259
+		if (!is_object($conn)) $conn = & $this->conn;
260 260
 		return $conn->insert_id;
261 261
 	}
262 262
 
263
-	function getAffectedRows($conn=NULL) {
264
-		if (!is_object($conn)) $conn =& $this->conn;
263
+	function getAffectedRows($conn = NULL){
264
+		if (!is_object($conn)) $conn = & $this->conn;
265 265
 		return $conn->affected_rows;
266 266
 	}
267 267
 
268
-	function getLastError($conn=NULL) {
269
-		if (!is_object($conn)) $conn =& $this->conn;
268
+	function getLastError($conn = NULL){
269
+		if (!is_object($conn)) $conn = & $this->conn;
270 270
 		return $conn->error;
271 271
 	}
272 272
 
273
-	function getRecordCount($ds) {
273
+	function getRecordCount($ds){
274 274
 		return (is_object($ds)) ? $ds->num_rows : 0;
275 275
 	}
276 276
 
277
-	function getRow($ds, $mode = 'assoc') {
277
+	function getRow($ds, $mode = 'assoc'){
278 278
 		if (is_object($ds)) {
279 279
 			if ($mode == 'assoc') {
280 280
 				return $ds->fetch_assoc();
@@ -291,12 +291,12 @@  discard block
 block discarded – undo
291 291
 		}
292 292
 	}
293 293
 
294
-	function getColumn($name, $dsq) {
294
+	function getColumn($name, $dsq){
295 295
 		if (!is_object($dsq)) {
296 296
 			$dsq = $this->query($dsq);
297 297
 		}
298 298
 		if ($dsq) {
299
-			$col = array ();
299
+			$col = array();
300 300
 			while ($row = $this->getRow($dsq)) {
301 301
 				$col[] = $row[$name];
302 302
 			}
@@ -304,12 +304,12 @@  discard block
 block discarded – undo
304 304
 		}
305 305
 	}
306 306
 
307
-	function getColumnNames($dsq) {
307
+	function getColumnNames($dsq){
308 308
 		if (!is_object($dsq)) {
309 309
 			$dsq = $this->query($dsq);
310 310
 		}
311 311
 		if ($dsq) {
312
-			$names = array ();
312
+			$names = array();
313 313
 			$limit = $this->numFields($dsq);
314 314
 			for ($i = 0; $i < $limit; $i++) {
315 315
 				$names[] = $this->fieldName($dsq, $i);
@@ -318,7 +318,7 @@  discard block
 block discarded – undo
318 318
 		}
319 319
 	}
320 320
 
321
-	function getValue($dsq) {
321
+	function getValue($dsq){
322 322
 		if (!is_object($dsq)) {
323 323
 			$dsq = $this->query($dsq);
324 324
 		}
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
 		}
329 329
 	}
330 330
 
331
-	function getTableMetaData($table) {
331
+	function getTableMetaData($table){
332 332
 		$metadata = false;
333 333
 		if (!empty ($table)) {
334 334
 			$sql = "SHOW FIELDS FROM $table";
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
 		return $metadata;
343 343
 	}
344 344
 
345
-	function prepareDate($timestamp, $fieldType = 'DATETIME') {
345
+	function prepareDate($timestamp, $fieldType = 'DATETIME'){
346 346
 		$date = '';
347 347
 		if (!$timestamp === false && $timestamp > 0) {
348 348
 			switch ($fieldType) {
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
 		return $date;
364 364
 	}
365 365
 
366
-	function makeArray($rs='',$index=false){
366
+	function makeArray($rs = '', $index = false){
367 367
 		if (!$rs) return false;
368 368
 		$rsArray = array();
369 369
 		$iterator = 0;
@@ -375,17 +375,17 @@  discard block
 block discarded – undo
375 375
 		return $rsArray;
376 376
 	}
377 377
 
378
-	function getVersion() {
378
+	function getVersion(){
379 379
 		return $this->conn->server_info;
380 380
 	}
381 381
 
382
-	function replaceFullTableName($str,$force=null) {
382
+	function replaceFullTableName($str, $force = null){
383 383
 		$str = trim($str);
384
-		$dbase  = trim($this->config['dbase'],'`');
384
+		$dbase  = trim($this->config['dbase'], '`');
385 385
 		$prefix = $this->config['table_prefix'];
386 386
 		if (!empty($force)) {
387 387
 			$result = "`{$dbase}`.`{$prefix}{$str}`";
388
-		} elseif (strpos($str,'[+prefix+]')!==false) {
388
+		} elseif (strpos($str, '[+prefix+]') !== false) {
389 389
 			$result = preg_replace('@\[\+prefix\+\]([0-9a-zA-Z_]+)@', "`{$dbase}`.`{$prefix}$1`", $str);
390 390
 		} else {
391 391
 			$result = $str;
@@ -393,7 +393,7 @@  discard block
 block discarded – undo
393 393
 		return $result;
394 394
 	}
395 395
 
396
-	function optimize($table_name) {
396
+	function optimize($table_name){
397 397
 		$rs = $this->query("OPTIMIZE TABLE {$table_name}");
398 398
 		if ($rs) {
399 399
 			$rs = $this->query("ALTER TABLE {$table_name}");
@@ -401,30 +401,30 @@  discard block
 block discarded – undo
401 401
 		return $rs;
402 402
 	}
403 403
 
404
-	function truncate($table_name) {
404
+	function truncate($table_name){
405 405
 		$rs = $this->query("TRUNCATE {$table_name}");
406 406
 		return $rs;
407 407
 	}
408 408
 
409
-	function dataSeek($result, $row_number) {
409
+	function dataSeek($result, $row_number){
410 410
 		return $result->data_seek($row_number);
411 411
 	}
412 412
 	
413
-    function _getFieldsStringFromArray($fields=array()) {
413
+    function _getFieldsStringFromArray($fields = array()){
414 414
         
415
-        if(empty($fields)) return '*';
415
+        if (empty($fields)) return '*';
416 416
         
417 417
         $_ = array();
418
-        foreach($fields as $k=>$v) {
419
-            if($k!==$v) $_[] = "{$v} as {$k}";
418
+        foreach ($fields as $k=>$v) {
419
+            if ($k !== $v) $_[] = "{$v} as {$k}";
420 420
             else        $_[] = $v;
421 421
         }
422 422
         return join(',', $_);
423 423
     }
424 424
     
425
-    function _getFromStringFromArray($tables=array()) {
425
+    function _getFromStringFromArray($tables = array()){
426 426
         $_ = array();
427
-        foreach($tables as $k=>$v) {
427
+        foreach ($tables as $k=>$v) {
428 428
             $_[] = $v;
429 429
         }
430 430
         return join(' ', $_);
Please login to merge, or discard this patch.
manager/includes/extenders/ex_export_site.inc.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@
 block discarded – undo
5 5
  * Time: 14:24
6 6
  */
7 7
 
8
-if(include_once(MODX_MANAGER_PATH . 'includes/extenders/export.class.inc.php'))
8
+if (include_once(MODX_MANAGER_PATH.'includes/extenders/export.class.inc.php'))
9 9
 {
10 10
     $this->export = new EXPORT_SITE;
11 11
     return true;
Please login to merge, or discard this patch.
manager/includes/extenders/dbapi.mysql.class.inc.php 1 patch
Spacing   +98 added lines, -98 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
  *
6 6
  */
7 7
 
8
-class DBAPI {
8
+class DBAPI{
9 9
 
10 10
    var $conn;
11 11
    var $config;
@@ -16,13 +16,13 @@  discard block
 block discarded – undo
16 16
     * @name:  DBAPI
17 17
     *
18 18
     */
19
-   function __construct($host='',$dbase='', $uid='',$pwd='',$pre=NULL,$charset='',$connection_method='SET CHARACTER SET') {
19
+   function __construct($host = '', $dbase = '', $uid = '', $pwd = '', $pre = NULL, $charset = '', $connection_method = 'SET CHARACTER SET'){
20 20
       $this->config['host'] = $host ? $host : $GLOBALS['database_server'];
21 21
       $this->config['dbase'] = $dbase ? $dbase : $GLOBALS['dbase'];
22 22
       $this->config['user'] = $uid ? $uid : $GLOBALS['database_user'];
23 23
       $this->config['pass'] = $pwd ? $pwd : $GLOBALS['database_password'];
24 24
       $this->config['charset'] = $charset ? $charset : $GLOBALS['database_connection_charset'];
25
-      $this->config['connection_method'] =  $this->_dbconnectionmethod = (isset($GLOBALS['database_connection_method']) ? $GLOBALS['database_connection_method'] : $connection_method);
25
+      $this->config['connection_method'] = $this->_dbconnectionmethod = (isset($GLOBALS['database_connection_method']) ? $GLOBALS['database_connection_method'] : $connection_method);
26 26
       $this->config['table_prefix'] = ($pre !== NULL) ? $pre : $GLOBALS['table_prefix'];
27 27
       $this->initDataTypes();
28 28
    }
@@ -32,8 +32,8 @@  discard block
 block discarded – undo
32 32
     * @desc:  called in the constructor to set up arrays containing the types
33 33
     *         of database fields that can be used with specific PHP types
34 34
     */
35
-   function initDataTypes() {
36
-      $this->dataTypes['numeric'] = array (
35
+   function initDataTypes(){
36
+      $this->dataTypes['numeric'] = array(
37 37
          'INT',
38 38
          'INTEGER',
39 39
          'TINYINT',
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
          'BIGINT',
50 50
          'BIT'
51 51
       );
52
-      $this->dataTypes['string'] = array (
52
+      $this->dataTypes['string'] = array(
53 53
          'CHAR',
54 54
          'VARCHAR',
55 55
          'BINARY',
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
          'ENUM',
66 66
          'SET'
67 67
       );
68
-      $this->dataTypes['date'] = array (
68
+      $this->dataTypes['date'] = array(
69 69
          'DATE',
70 70
          'DATETIME',
71 71
          'TIMESTAMP',
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
     * @name:  connect
79 79
     *
80 80
     */
81
-   function connect($host = '', $dbase = '', $uid = '', $pwd = '', $persist = 0) {
81
+   function connect($host = '', $dbase = '', $uid = '', $pwd = '', $persist = 0){
82 82
       global $modx;
83 83
       $uid = $uid ? $uid : $this->config['user'];
84 84
       $pwd = $pwd ? $pwd : $this->config['pass'];
@@ -88,16 +88,16 @@  discard block
 block discarded – undo
88 88
       $connection_method = $this->config['connection_method'];
89 89
       $tstart = $modx->getMicroTime();
90 90
       $safe_count = 0;
91
-      while(!$this->conn && $safe_count<3)
91
+      while (!$this->conn && $safe_count < 3)
92 92
       {
93
-          if($persist!=0) $this->conn = mysql_pconnect($host, $uid, $pwd);
93
+          if ($persist != 0) $this->conn = mysql_pconnect($host, $uid, $pwd);
94 94
           else            $this->conn = mysql_connect($host, $uid, $pwd, true);
95 95
           
96
-          if(!$this->conn)
96
+          if (!$this->conn)
97 97
           {
98
-            if(isset($modx->config['send_errormail']) && $modx->config['send_errormail'] !== '0')
98
+            if (isset($modx->config['send_errormail']) && $modx->config['send_errormail'] !== '0')
99 99
             {
100
-               if($modx->config['send_errormail'] <= 2)
100
+               if ($modx->config['send_errormail'] <= 2)
101 101
                {
102 102
                   $logtitle    = 'Failed to create the database connection!';
103 103
                   $request_uri = $modx->htmlspecialchars($_SERVER['REQUEST_URI']);
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
                   $referer     = $modx->htmlspecialchars($_SERVER['HTTP_REFERER']);
106 106
 
107 107
                   $modx->sendmail(array(
108
-					  'subject' => 'Missing to create the database connection! from ' . $modx->config['site_name'],
108
+					  'subject' => 'Missing to create the database connection! from '.$modx->config['site_name'],
109 109
 					  'body' => "{$logtitle}\n{$request_uri}\n{$ua}\n{$referer}",
110 110
 					  'type' => 'text')
111 111
 				  );
@@ -119,16 +119,16 @@  discard block
 block discarded – undo
119 119
          $modx->messageQuit("Failed to create the database connection!");
120 120
          exit;
121 121
       } else {
122
-         $dbase = trim($dbase,'`'); // remove the `` chars
122
+         $dbase = trim($dbase, '`'); // remove the `` chars
123 123
          if (!@ mysql_select_db($dbase, $this->conn)) {
124
-            $modx->messageQuit("Failed to select the database '" . $dbase . "'!");
124
+            $modx->messageQuit("Failed to select the database '".$dbase."'!");
125 125
             exit;
126 126
          }
127 127
          @mysql_query("{$connection_method} {$charset}", $this->conn);
128 128
          $tend = $modx->getMicroTime();
129 129
          $totaltime = $tend - $tstart;
130 130
          if ($modx->dumpSQL) {
131
-            $modx->queryCode .= "<fieldset style='text-align:left'><legend>Database connection</legend>" . sprintf("Database connection was created in %2.4f s", $totaltime) . "</fieldset><br />";
131
+            $modx->queryCode .= "<fieldset style='text-align:left'><legend>Database connection</legend>".sprintf("Database connection was created in %2.4f s", $totaltime)."</fieldset><br />";
132 132
          }
133 133
             if (function_exists('mysql_set_charset')) {
134 134
                 mysql_set_charset($this->config['charset']);
@@ -146,26 +146,26 @@  discard block
 block discarded – undo
146 146
     * @name:  disconnect
147 147
     *
148 148
     */
149
-   function disconnect() {
149
+   function disconnect(){
150 150
       @ mysql_close($this->conn);
151 151
       $this->conn = null;
152 152
       $this->isConnected = false;
153 153
    }
154 154
 
155
-   function escape($s, $safecount=0) {
155
+   function escape($s, $safecount = 0){
156 156
       
157 157
       $safecount++;
158
-      if(1000<$safecount) exit("Too many loops '{$safecount}'");
158
+      if (1000 < $safecount) exit("Too many loops '{$safecount}'");
159 159
       
160 160
       if (empty ($this->conn) || !is_resource($this->conn)) {
161 161
          $this->connect();
162 162
        }
163 163
        
164
-      if(is_array($s)) {
165
-          if(count($s) === 0) $s = '';
164
+      if (is_array($s)) {
165
+          if (count($s) === 0) $s = '';
166 166
           else {
167
-              foreach($s as $i=>$v) {
168
-                  $s[$i] = $this->escape($v,$safecount);
167
+              foreach ($s as $i=>$v) {
168
+                  $s[$i] = $this->escape($v, $safecount);
169 169
               }
170 170
           }
171 171
       }
@@ -178,17 +178,17 @@  discard block
 block discarded – undo
178 178
     * @desc:  Mainly for internal use.
179 179
     * Developers should use select, update, insert, delete where possible
180 180
     */
181
-   function query($sql,$watchError=true) {
181
+   function query($sql, $watchError = true){
182 182
       global $modx;
183 183
       if (empty ($this->conn) || !is_resource($this->conn)) {
184 184
          $this->connect();
185 185
       }
186 186
       $tstart = $modx->getMicroTime();
187
-      if(is_array($sql)) $sql = join("\n", $sql);
187
+      if (is_array($sql)) $sql = join("\n", $sql);
188 188
       $this->lastQuery = $sql;
189 189
       if (!$result = @ mysql_query($sql, $this->conn)) {
190
-         if(!$watchError) return;
191
-            switch(mysql_errno()) {
190
+         if (!$watchError) return;
191
+            switch (mysql_errno()) {
192 192
                 case 1054:
193 193
                 case 1060:
194 194
                 case 1061:
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
                 case 1091:
197 197
                     break;
198 198
                 default:
199
-                    $modx->messageQuit('Execution of a query to the database failed - ' . $this->getLastError(), $sql);
199
+                    $modx->messageQuit('Execution of a query to the database failed - '.$this->getLastError(), $sql);
200 200
             }
201 201
       } else {
202 202
          $tend = $modx->getMicroTime();
@@ -207,15 +207,15 @@  discard block
 block discarded – undo
207 207
             array_shift($debug);	
208 208
             $debug_path = array();
209 209
             foreach ($debug as $line) $debug_path[] = $line['function'];
210
-            $debug_path = implode(' > ',array_reverse($debug_path));
211
-            $modx->queryCode .= "<fieldset style='text-align:left'><legend>Query " . ($modx->executedQueries + 1) . " - " . sprintf("%2.2f ms", $totaltime*1000) . "</legend>";
212
-            $modx->queryCode .= $sql . '<br><br>';
213
-            if ($modx->event->name) $modx->queryCode .= 'Current Event  => ' . $modx->event->name . '<br>';
214
-            if ($modx->event->activePlugin) $modx->queryCode .= 'Current Plugin => ' . $modx->event->activePlugin . '<br>';
215
-            if ($modx->currentSnippet) $modx->queryCode .= 'Current Snippet => ' . $modx->currentSnippet . '<br>';
216
-            if (stripos($sql, 'select')===0) $modx->queryCode .= 'Record Count => ' . $this->getRecordCount($result) . '<br>';
217
-            else $modx->queryCode .= 'Affected Rows => ' . $this->getAffectedRows() . '<br>';
218
-            $modx->queryCode .= 'Functions Path => ' . $debug_path . '<br>';
210
+            $debug_path = implode(' > ', array_reverse($debug_path));
211
+            $modx->queryCode .= "<fieldset style='text-align:left'><legend>Query ".($modx->executedQueries + 1)." - ".sprintf("%2.2f ms", $totaltime * 1000)."</legend>";
212
+            $modx->queryCode .= $sql.'<br><br>';
213
+            if ($modx->event->name) $modx->queryCode .= 'Current Event  => '.$modx->event->name.'<br>';
214
+            if ($modx->event->activePlugin) $modx->queryCode .= 'Current Plugin => '.$modx->event->activePlugin.'<br>';
215
+            if ($modx->currentSnippet) $modx->queryCode .= 'Current Snippet => '.$modx->currentSnippet.'<br>';
216
+            if (stripos($sql, 'select') === 0) $modx->queryCode .= 'Record Count => '.$this->getRecordCount($result).'<br>';
217
+            else $modx->queryCode .= 'Affected Rows => '.$this->getAffectedRows().'<br>';
218
+            $modx->queryCode .= 'Functions Path => '.$debug_path.'<br>';
219 219
             $modx->queryCode .= "</fieldset><br />";
220 220
          }
221 221
          $modx->executedQueries = $modx->executedQueries + 1;
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
     * @name:  delete
228 228
     *
229 229
     */
230
-   function delete($from, $where='', $orderby='', $limit = '') {
230
+   function delete($from, $where = '', $orderby = '', $limit = ''){
231 231
       global $modx;
232 232
       if (!$from)
233 233
          $modx->messageQuit("Empty \$from parameters in DBAPI::delete().");
@@ -236,9 +236,9 @@  discard block
 block discarded – undo
236 236
          $where   = trim($where);
237 237
          $orderby = trim($orderby);
238 238
          $limit   = trim($limit);
239
-         if($where!==''   && stripos($where,   'WHERE')!==0)    $where   = "WHERE {$where}";
240
-         if($orderby!=='' && stripos($orderby, 'ORDER BY')!==0) $orderby = "ORDER BY {$orderby}";
241
-         if($limit!==''   && stripos($limit,   'LIMIT')!==0)    $limit   = "LIMIT {$limit}";
239
+         if ($where !== '' && stripos($where, 'WHERE') !== 0)    $where   = "WHERE {$where}";
240
+         if ($orderby !== '' && stripos($orderby, 'ORDER BY') !== 0) $orderby = "ORDER BY {$orderby}";
241
+         if ($limit !== '' && stripos($limit, 'LIMIT') !== 0)    $limit   = "LIMIT {$limit}";
242 242
          return $this->query("DELETE FROM {$from} {$where} {$orderby} {$limit}");
243 243
       }
244 244
    }
@@ -247,12 +247,12 @@  discard block
 block discarded – undo
247 247
     * @name:  select
248 248
     *
249 249
     */
250
-   function select($fields = "*", $from = "", $where = "", $orderby = "", $limit = "") {
250
+   function select($fields = "*", $from = "", $where = "", $orderby = "", $limit = ""){
251 251
       global $modx;
252 252
       
253
-      if(is_array($fields)) $fields = $this->_getFieldsStringFromArray($fields);
254
-      if(is_array($from))   $from   = $this->_getFromStringFromArray($from);
255
-      if(is_array($where))  $where  = join(' ', $where);
253
+      if (is_array($fields)) $fields = $this->_getFieldsStringFromArray($fields);
254
+      if (is_array($from))   $from   = $this->_getFromStringFromArray($from);
255
+      if (is_array($where))  $where  = join(' ', $where);
256 256
       
257 257
       if (!$from) {
258 258
          $modx->messageQuit("Empty \$from parameters in DBAPI::select().");
@@ -264,9 +264,9 @@  discard block
 block discarded – undo
264 264
       $where   = trim($where);
265 265
       $orderby = trim($orderby);
266 266
       $limit   = trim($limit);
267
-      if($where!==''   && stripos($where,'WHERE')!==0)   $where   = "WHERE {$where}";
268
-      if($orderby!=='' && stripos($orderby,'ORDER')!==0) $orderby = "ORDER BY {$orderby}";
269
-      if($limit!==''   && stripos($limit,'LIMIT')!==0)   $limit   = "LIMIT {$limit}";
267
+      if ($where !== '' && stripos($where, 'WHERE') !== 0)   $where   = "WHERE {$where}";
268
+      if ($orderby !== '' && stripos($orderby, 'ORDER') !== 0) $orderby = "ORDER BY {$orderby}";
269
+      if ($limit !== '' && stripos($limit, 'LIMIT') !== 0)   $limit   = "LIMIT {$limit}";
270 270
       return $this->query("SELECT {$fields} FROM {$from} {$where} {$orderby} {$limit}");
271 271
    }
272 272
 
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
     * @name:  update
275 275
     *
276 276
     */
277
-   function update($fields, $table, $where = "") {
277
+   function update($fields, $table, $where = ""){
278 278
       global $modx;
279 279
       if (!$table)
280 280
          $modx->messageQuit("Empty \$table parameter in DBAPI::update().");
@@ -282,17 +282,17 @@  discard block
 block discarded – undo
282 282
          $table = $this->replaceFullTableName($table);
283 283
          if (is_array($fields)) {
284 284
 			 foreach ($fields as $key => $value) {
285
-				 if(is_null($value) || strtolower($value) === 'null'){
285
+				 if (is_null($value) || strtolower($value) === 'null') {
286 286
 					 $flds = 'NULL';
287
-				 }else{
288
-					 $flds = "'" . $value . "'";
287
+				 } else {
288
+					 $flds = "'".$value."'";
289 289
 				 }
290 290
 				 $fields[$key] = "`{$key}` = ".$flds;
291 291
 			 }
292 292
             $fields = implode(",", $fields);
293 293
          }
294 294
          $where = trim($where);
295
-         if($where!=='' && stripos($where, 'WHERE')!==0) $where = "WHERE {$where}";
295
+         if ($where !== '' && stripos($where, 'WHERE') !== 0) $where = "WHERE {$where}";
296 296
          return $this->query("UPDATE {$table} SET {$fields} {$where}");
297 297
       }
298 298
    }
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
     * @name:  insert
302 302
     * @desc:  returns either last id inserted or the result from the query
303 303
     */
304
-   function insert($fields, $intotable, $fromfields = "*", $fromtable = "", $where = "", $limit = "") {
304
+   function insert($fields, $intotable, $fromfields = "*", $fromtable = "", $where = "", $limit = ""){
305 305
       global $modx;
306 306
       if (!$intotable)
307 307
          $modx->messageQuit("Empty \$intotable parameters in DBAPI::insert().");
@@ -314,13 +314,13 @@  discard block
 block discarded – undo
314 314
                $fields = "(`".implode("`, `", array_keys($fields))."`) VALUES('".implode("', '", array_values($fields))."')";
315 315
                $rt = $this->query("INSERT INTO {$intotable} {$fields}");
316 316
             } else {
317
-               if (version_compare($this->getVersion(),"4.0.14")>=0) {
317
+               if (version_compare($this->getVersion(), "4.0.14") >= 0) {
318 318
                   $fromtable = $this->replaceFullTableName($fromtable);
319 319
                   $fields = "(".implode(",", array_keys($fields)).")";
320 320
                   $where = trim($where);
321 321
                   $limit = trim($limit);
322
-                  if($where!=='' && stripos($where, 'WHERE')!==0) $where = "WHERE {$where}";
323
-                  if($limit!=='' && stripos($limit, 'LIMIT')!==0) $limit = "LIMIT {$limit}";
322
+                  if ($where !== '' && stripos($where, 'WHERE') !== 0) $where = "WHERE {$where}";
323
+                  if ($limit !== '' && stripos($limit, 'LIMIT') !== 0) $limit = "LIMIT {$limit}";
324 324
                   $rt = $this->query("INSERT INTO {$intotable} {$fields} SELECT {$fromfields} FROM {$fromtable} {$where} {$limit}");
325 325
                } else {
326 326
                   $ds = $this->select($fromfields, $fromtable, $where, '', $limit);
@@ -331,18 +331,18 @@  discard block
 block discarded – undo
331 331
                }
332 332
             }
333 333
          }
334
-         if (($lid = $this->getInsertId())===false) $modx->messageQuit("Couldn't get last insert key!");
334
+         if (($lid = $this->getInsertId()) === false) $modx->messageQuit("Couldn't get last insert key!");
335 335
          return $lid;
336 336
       }
337 337
    }
338 338
    
339
-    function save($fields, $table, $where='') {
339
+    function save($fields, $table, $where = ''){
340 340
         
341
-        if($where === '')                                                  $mode = 'insert';
342
-        elseif($this->getRecordCount($this->select('*',$table,$where))==0) $mode = 'insert';
341
+        if ($where === '')                                                  $mode = 'insert';
342
+        elseif ($this->getRecordCount($this->select('*', $table, $where)) == 0) $mode = 'insert';
343 343
         else                                                               $mode = 'update';
344 344
         
345
-        if($mode==='insert') return $this->insert($fields, $table);
345
+        if ($mode === 'insert') return $this->insert($fields, $table);
346 346
         else                 return $this->update($fields, $table, $where);
347 347
     }
348 348
     
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
     * @name:  isResult
351 351
     *
352 352
     */
353
-   function isResult($rs) {
353
+   function isResult($rs){
354 354
       return is_resource($rs);
355 355
    }
356 356
 
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
     * @name:  freeResult
359 359
     *
360 360
     */
361
-   function freeResult($rs) {
361
+   function freeResult($rs){
362 362
       mysql_free_result($rs);
363 363
    }
364 364
    
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
     * @name:  numFields
367 367
     *
368 368
     */
369
-   function numFields($rs) {
369
+   function numFields($rs){
370 370
       return mysql_num_fields($rs);
371 371
    }
372 372
    
@@ -374,15 +374,15 @@  discard block
 block discarded – undo
374 374
     * @name:  fieldName
375 375
     *
376 376
     */
377
-   function fieldName($rs,$col=0) {
378
-      return mysql_field_name($rs,$col);
377
+   function fieldName($rs, $col = 0){
378
+      return mysql_field_name($rs, $col);
379 379
    }
380 380
    
381 381
     /**
382 382
     * @name:  selectDb
383 383
     *
384 384
     */
385
-   function selectDb($name) {
385
+   function selectDb($name){
386 386
       mysql_select_db($name);
387 387
    }
388 388
    
@@ -391,8 +391,8 @@  discard block
 block discarded – undo
391 391
     * @name:  getInsertId
392 392
     *
393 393
     */
394
-   function getInsertId($conn=NULL) {
395
-      if( !is_resource($conn)) $conn =& $this->conn;
394
+   function getInsertId($conn = NULL){
395
+      if (!is_resource($conn)) $conn = & $this->conn;
396 396
       return mysql_insert_id($conn);
397 397
    }
398 398
 
@@ -400,8 +400,8 @@  discard block
 block discarded – undo
400 400
     * @name:  getAffectedRows
401 401
     *
402 402
     */
403
-   function getAffectedRows($conn=NULL) {
404
-      if (!is_resource($conn)) $conn =& $this->conn;
403
+   function getAffectedRows($conn = NULL){
404
+      if (!is_resource($conn)) $conn = & $this->conn;
405 405
       return mysql_affected_rows($conn);
406 406
    }
407 407
 
@@ -409,8 +409,8 @@  discard block
 block discarded – undo
409 409
     * @name:  getLastError
410 410
     *
411 411
     */
412
-   function getLastError($conn=NULL) {
413
-      if (!is_resource($conn)) $conn =& $this->conn;
412
+   function getLastError($conn = NULL){
413
+      if (!is_resource($conn)) $conn = & $this->conn;
414 414
       return mysql_error($conn);
415 415
    }
416 416
 
@@ -418,7 +418,7 @@  discard block
 block discarded – undo
418 418
     * @name:  getRecordCount
419 419
     *
420 420
     */
421
-   function getRecordCount($ds) {
421
+   function getRecordCount($ds){
422 422
       return (is_resource($ds)) ? mysql_num_rows($ds) : 0;
423 423
    }
424 424
 
@@ -428,7 +428,7 @@  discard block
 block discarded – undo
428 428
     * @param: $dsq - dataset
429 429
     *
430 430
     */
431
-   function getRow($ds, $mode = 'assoc') {
431
+   function getRow($ds, $mode = 'assoc'){
432 432
       if (is_resource($ds)) {
433 433
          if ($mode == 'assoc') {
434 434
             return mysql_fetch_assoc($ds);
@@ -453,11 +453,11 @@  discard block
 block discarded – undo
453 453
     * @desc:  returns an array of the values found on colun $name
454 454
     * @param: $dsq - dataset or query string
455 455
     */
456
-   function getColumn($name, $dsq) {
456
+   function getColumn($name, $dsq){
457 457
       if (!is_resource($dsq))
458 458
          $dsq = $this->query($dsq);
459 459
       if ($dsq) {
460
-         $col = array ();
460
+         $col = array();
461 461
          while ($row = $this->getRow($dsq)) {
462 462
             $col[] = $row[$name];
463 463
          }
@@ -470,11 +470,11 @@  discard block
 block discarded – undo
470 470
     * @desc:  returns an array containing the column $name
471 471
     * @param: $dsq - dataset or query string
472 472
     */
473
-   function getColumnNames($dsq) {
473
+   function getColumnNames($dsq){
474 474
       if (!is_resource($dsq))
475 475
          $dsq = $this->query($dsq);
476 476
       if ($dsq) {
477
-         $names = array ();
477
+         $names = array();
478 478
          $limit = mysql_num_fields($dsq);
479 479
          for ($i = 0; $i < $limit; $i++) {
480 480
             $names[] = mysql_field_name($dsq, $i);
@@ -488,7 +488,7 @@  discard block
 block discarded – undo
488 488
     * @desc:  returns the value from the first column in the set
489 489
     * @param: $dsq - dataset or query string
490 490
     */
491
-   function getValue($dsq) {
491
+   function getValue($dsq){
492 492
       if (!is_resource($dsq))
493 493
          $dsq = $this->query($dsq);
494 494
       if ($dsq) {
@@ -503,7 +503,7 @@  discard block
 block discarded – undo
503 503
     *         table
504 504
     * @param: $table: the full name of the database table
505 505
     */
506
-   function getTableMetaData($table) {
506
+   function getTableMetaData($table){
507 507
       $metadata = false;
508 508
       if (!empty ($table)) {
509 509
          $sql = "SHOW FIELDS FROM $table";
@@ -525,7 +525,7 @@  discard block
 block discarded – undo
525 525
     * @param: $fieldType: the type of field to format the date for
526 526
     *         (in MySQL, you have DATE, TIME, YEAR, and DATETIME)
527 527
     */
528
-   function prepareDate($timestamp, $fieldType = 'DATETIME') {
528
+   function prepareDate($timestamp, $fieldType = 'DATETIME'){
529 529
       $date = '';
530 530
       if (!$timestamp === false && $timestamp > 0) {
531 531
          switch ($fieldType) {
@@ -554,7 +554,7 @@  discard block
 block discarded – undo
554 554
    *          was passed
555 555
    * @param: $rs Recordset to be packaged into an array
556 556
    */
557
-	function makeArray($rs='',$index=false){
557
+	function makeArray($rs = '', $index = false){
558 558
 		if (!$rs) return false;
559 559
 		$rsArray = array();
560 560
 		$iterator = 0;
@@ -572,7 +572,7 @@  discard block
 block discarded – undo
572 572
     *
573 573
     * @return string
574 574
     */
575
-   function getVersion() {
575
+   function getVersion(){
576 576
        return mysql_get_server_info();
577 577
    }
578 578
    
@@ -583,16 +583,16 @@  discard block
 block discarded – undo
583 583
     * @param string $str
584 584
     * @return string 
585 585
     */
586
-   function replaceFullTableName($str,$force=null) {
586
+   function replaceFullTableName($str, $force = null){
587 587
        
588 588
        $str = trim($str);
589
-       $dbase  = trim($this->config['dbase'],'`');
589
+       $dbase  = trim($this->config['dbase'], '`');
590 590
        $prefix = $this->config['table_prefix'];
591
-       if(!empty($force))
591
+       if (!empty($force))
592 592
        {
593 593
            $result = "`{$dbase}`.`{$prefix}{$str}`";
594 594
        }
595
-       elseif(strpos($str,'[+prefix+]')!==false)
595
+       elseif (strpos($str, '[+prefix+]') !== false)
596 596
        {
597 597
            $result = preg_replace('@\[\+prefix\+\]([0-9a-zA-Z_]+)@', "`{$dbase}`.`{$prefix}$1`", $str);
598 598
        }
@@ -604,7 +604,7 @@  discard block
 block discarded – undo
604 604
    function optimize($table_name)
605 605
    {
606 606
        $rs = $this->query("OPTIMIZE TABLE {$table_name}");
607
-       if($rs) $rs = $this->query("ALTER TABLE {$table_name}");
607
+       if ($rs) $rs = $this->query("ALTER TABLE {$table_name}");
608 608
        return $rs;
609 609
    }
610 610
    
@@ -614,25 +614,25 @@  discard block
 block discarded – undo
614 614
        return $rs;
615 615
    }
616 616
 
617
-  function dataSeek($result, $row_number) {
617
+  function dataSeek($result, $row_number){
618 618
     return mysql_data_seek($result, $row_number);
619 619
   }
620 620
   
621
-    function _getFieldsStringFromArray($fields=array()) {
621
+    function _getFieldsStringFromArray($fields = array()){
622 622
         
623
-        if(empty($fields)) return '*';
623
+        if (empty($fields)) return '*';
624 624
         
625 625
         $_ = array();
626
-        foreach($fields as $k=>$v) {
627
-            if($k!==$v) $_[] = "{$v} as {$k}";
626
+        foreach ($fields as $k=>$v) {
627
+            if ($k !== $v) $_[] = "{$v} as {$k}";
628 628
             else        $_[] = $v;
629 629
         }
630 630
         return join(',', $_);
631 631
     }
632 632
     
633
-    function _getFromStringFromArray($tables=array()) {
633
+    function _getFromStringFromArray($tables = array()){
634 634
         $_ = array();
635
-        foreach($tables as $k=>$v) {
635
+        foreach ($tables as $k=>$v) {
636 636
             $_[] = $v;
637 637
         }
638 638
         return join(' ', $_);
Please login to merge, or discard this patch.
manager/includes/extenders/export.class.inc.php 1 patch
Spacing   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -15,19 +15,19 @@  discard block
 block discarded – undo
15 15
 	{
16 16
 		global $modx;
17 17
 		
18
-		if(!defined('MODX_BASE_PATH'))  return false;
18
+		if (!defined('MODX_BASE_PATH'))  return false;
19 19
 		$this->exportstart = $this->get_mtime();
20 20
 		$this->count = 0;
21 21
 		$this->setUrlMode();
22 22
 		$this->dirCheckCount = 0;
23 23
 		$this->generate_mode = 'crawl';
24
-		$this->targetDir = $modx->config['base_path'] . 'temp/export';
25
-		if(!isset($this->total)) $this->getTotal();
24
+		$this->targetDir = $modx->config['base_path'].'temp/export';
25
+		if (!isset($this->total)) $this->getTotal();
26 26
 	}
27 27
 	
28 28
 	function setExportDir($dir)
29 29
 	{
30
-		$dir = str_replace('\\','/',$dir);
30
+		$dir = str_replace('\\', '/', $dir);
31 31
 		$dir = rtrim($dir, '/');
32 32
 		$this->targetDir = $dir;
33 33
 	}
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 	{
45 45
 		global $modx;
46 46
 		
47
-		if($modx->config['friendly_urls']==0)
47
+		if ($modx->config['friendly_urls'] == 0)
48 48
 		{
49 49
 			$modx->config['friendly_urls']  = 1;
50 50
 			$modx->config['use_alias_path'] = 1;
@@ -53,13 +53,13 @@  discard block
 block discarded – undo
53 53
 		$modx->config['make_folders'] = '1';
54 54
 	}
55 55
 	
56
-	function getTotal($ignore_ids='', $noncache='0')
56
+	function getTotal($ignore_ids = '', $noncache = '0')
57 57
 	{
58 58
 		global $modx;
59 59
 		$tbl_site_content = $modx->getFullTableName('site_content');
60 60
 		
61 61
 		$ignore_ids = array_filter(array_map('intval', explode(',', $ignore_ids)));
62
-		if(count($ignore_ids)>0)
62
+		if (count($ignore_ids) > 0)
63 63
 		{
64 64
 			$ignore_ids = "AND NOT id IN ('".implode("','", $ignore_ids)."')";
65 65
 		} else {
@@ -70,72 +70,72 @@  discard block
 block discarded – undo
70 70
 		
71 71
 		$noncache = ($noncache == 1) ? '' : 'AND cacheable=1';
72 72
 		$where = "deleted=0 AND ((published=1 AND type='document') OR (isfolder=1)) {$noncache} {$ignore_ids}";
73
-		$rs  = $modx->db->select('count(id)',$tbl_site_content,$where);
73
+		$rs = $modx->db->select('count(id)', $tbl_site_content, $where);
74 74
 		$this->total = $modx->db->getValue($rs);
75 75
 		return $this->total;
76 76
 	}
77 77
 	
78
-	function removeDirectoryAll($directory='')
78
+	function removeDirectoryAll($directory = '')
79 79
 	{
80
-		if(empty($directory)) $directory = $this->targetDir;
81
-		$directory = rtrim($directory,'/');
80
+		if (empty($directory)) $directory = $this->targetDir;
81
+		$directory = rtrim($directory, '/');
82 82
 		// if the path is not valid or is not a directory ...
83
-		if(empty($directory)) return false;
84
-		if(strpos($directory,MODX_BASE_PATH)===false) return FALSE;
83
+		if (empty($directory)) return false;
84
+		if (strpos($directory, MODX_BASE_PATH) === false) return FALSE;
85 85
 		
86
-		if(!is_dir($directory))          return FALSE;
87
-		elseif(!is_readable($directory)) return FALSE;
86
+		if (!is_dir($directory))          return FALSE;
87
+		elseif (!is_readable($directory)) return FALSE;
88 88
 		else
89 89
 		{
90
-			$files = glob($directory . '/*');
91
-			if(!empty($files))
90
+			$files = glob($directory.'/*');
91
+			if (!empty($files))
92 92
 			{
93
-    			foreach($files as $path)
93
+    			foreach ($files as $path)
94 94
     			{
95
-    				if(is_dir($path)) $this->removeDirectoryAll($path);
95
+    				if (is_dir($path)) $this->removeDirectoryAll($path);
96 96
     				else              $rs = unlink($path);
97 97
     			}
98 98
 			}
99 99
 		}
100
-		if($directory !== $this->targetDir) $rs = rmdir($directory);
100
+		if ($directory !== $this->targetDir) $rs = rmdir($directory);
101 101
 		
102 102
 		return $rs;
103 103
 	}
104 104
 
105 105
 	function makeFile($docid, $filepath)
106 106
 	{
107
-		global  $modx,$_lang;
107
+		global  $modx, $_lang;
108 108
 		$file_permission = octdec($modx->config['new_file_permissions']);
109
-		if($this->generate_mode==='direct')
109
+		if ($this->generate_mode === 'direct')
110 110
 		{
111 111
 			$back_lang = $_lang;
112 112
 			$src = $modx->executeParser($docid);
113 113
 			
114 114
 			$_lang = $back_lang;
115 115
 		}
116
-		else $src = $this->curl_get_contents(MODX_SITE_URL . "index.php?id={$docid}");
116
+		else $src = $this->curl_get_contents(MODX_SITE_URL."index.php?id={$docid}");
117 117
 		
118 118
 		
119
-		if($src !== false)
119
+		if ($src !== false)
120 120
 		{
121
-			if($this->repl_before!==$this->repl_after) $src = str_replace($this->repl_before,$this->repl_after,$src);
122
-			$result = file_put_contents($filepath,$src);
123
-			if($result!==false) @chmod($filepath, $file_permission);
121
+			if ($this->repl_before !== $this->repl_after) $src = str_replace($this->repl_before, $this->repl_after, $src);
122
+			$result = file_put_contents($filepath, $src);
123
+			if ($result !== false) @chmod($filepath, $file_permission);
124 124
 			
125
-			if($result !== false) return 'success';
125
+			if ($result !== false) return 'success';
126 126
 			else                  return 'failed_no_write';
127 127
 		}
128 128
 		else                      return 'failed_no_retrieve';
129 129
 	}
130 130
 
131
-	function getFileName($docid, $alias='', $prefix, $suffix)
131
+	function getFileName($docid, $alias = '', $prefix, $suffix)
132 132
 	{
133 133
 		global $modx;
134 134
 		
135
-		if($alias==='') $filename = $prefix.$docid.$suffix;
135
+		if ($alias === '') $filename = $prefix.$docid.$suffix;
136 136
 		else
137 137
 		{
138
-			if($modx->config['suffix_mode']==='1' && strpos($alias, '.')!==false)
138
+			if ($modx->config['suffix_mode'] === '1' && strpos($alias, '.') !== false)
139 139
 			{
140 140
 				$suffix = '';
141 141
 			}
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 		return $filename;
145 145
 	}
146 146
 
147
-	function run($parent=0)
147
+	function run($parent = 0)
148 148
 	{
149 149
 		global $_lang;
150 150
 		global $modx;
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 		$tbl_site_content = $modx->getFullTableName('site_content');
153 153
 		
154 154
 		$ignore_ids = $this->ignore_ids;
155
-		$dirpath = $this->targetDir . '/';
155
+		$dirpath = $this->targetDir.'/';
156 156
 		
157 157
 		$prefix = $modx->config['friendly_url_prefix'];
158 158
 		$suffix = $modx->config['friendly_url_suffix'];
@@ -162,36 +162,36 @@  discard block
 block discarded – undo
162 162
 		
163 163
 		$ph['status'] = 'fail';
164 164
 		$ph['msg1']   = $_lang['export_site_failed'];
165
-		$ph['msg2']   = $_lang["export_site_failed_no_write"] . ' - ' . $dirpath;
166
-		$msg_failed_no_write    = $this->parsePlaceholder($tpl,$ph);
165
+		$ph['msg2']   = $_lang["export_site_failed_no_write"].' - '.$dirpath;
166
+		$msg_failed_no_write    = $this->parsePlaceholder($tpl, $ph);
167 167
 		
168 168
 		$ph['msg2']   = $_lang["export_site_failed_no_retrieve"];
169
-		$msg_failed_no_retrieve = $this->parsePlaceholder($tpl,$ph);
169
+		$msg_failed_no_retrieve = $this->parsePlaceholder($tpl, $ph);
170 170
 		
171 171
 		$ph['status'] = 'success';
172 172
 		$ph['msg1']   = $_lang['export_site_success'];
173 173
 		$ph['msg2']   = '';
174
-		$msg_success            = $this->parsePlaceholder($tpl,$ph);
174
+		$msg_success = $this->parsePlaceholder($tpl, $ph);
175 175
 		
176 176
 		$ph['msg2']   = $_lang['export_site_success_skip_doc'];
177
-		$msg_success_skip_doc = $this->parsePlaceholder($tpl,$ph);
177
+		$msg_success_skip_doc = $this->parsePlaceholder($tpl, $ph);
178 178
 		
179 179
 		$ph['msg2']   = $_lang['export_site_success_skip_dir'];
180
-		$msg_success_skip_dir = $this->parsePlaceholder($tpl,$ph);
180
+		$msg_success_skip_dir = $this->parsePlaceholder($tpl, $ph);
181 181
 		
182 182
 		$fields = "id, alias, pagetitle, isfolder, (content = '' AND template = 0) AS wasNull, published";
183
-		$noncache = $_POST['includenoncache']==1 ? '' : 'AND cacheable=1';
183
+		$noncache = $_POST['includenoncache'] == 1 ? '' : 'AND cacheable=1';
184 184
 		$where = "parent = '{$parent}' AND deleted=0 AND ((published=1 AND type='document') OR (isfolder=1)) {$noncache} {$ignore_ids}";
185
-		$rs = $modx->db->select($fields,$tbl_site_content,$where);
185
+		$rs = $modx->db->select($fields, $tbl_site_content, $where);
186 186
 		
187 187
 		$ph = array();
188
-		$ph['total']     = $this->total;
188
+		$ph['total'] = $this->total;
189 189
 		$folder_permission = octdec($modx->config['new_folder_permissions']);
190
-		while($row = $modx->db->getRow($rs))
190
+		while ($row = $modx->db->getRow($rs))
191 191
 		{
192 192
 			$this->count++;
193 193
 			
194
-			$row['count']     = $this->count;
194
+			$row['count'] = $this->count;
195 195
 			$row['url'] = $modx->makeUrl($row['id']);
196 196
 			
197 197
 			if (!$row['wasNull'])
@@ -200,10 +200,10 @@  discard block
 block discarded – undo
200 200
 				$filename = $dirpath.$docname;
201 201
 				if (!is_file($filename))
202 202
 				{
203
-					if($row['published']==='1')
203
+					if ($row['published'] === '1')
204 204
 					{
205 205
 						$status = $this->makeFile($row['id'], $filename);
206
-						switch($status)
206
+						switch ($status)
207 207
 						{
208 208
 							case 'failed_no_write'   :
209 209
                                                             $row['status'] = $msg_failed_no_write;
@@ -225,11 +225,11 @@  discard block
 block discarded – undo
225 225
 				$row['status'] = $msg_success_skip_dir;
226 226
 				$this->output[] = $this->parsePlaceholder($_lang['export_site_exporting_document'], $row);
227 227
 			}
228
-			if ($row['isfolder']==='1' && ($modx->config['suffix_mode']!=='1' || strpos($row['alias'],'.')===false))
228
+			if ($row['isfolder'] === '1' && ($modx->config['suffix_mode'] !== '1' || strpos($row['alias'], '.') === false))
229 229
 			{ // needs making a folder
230
-				$end_dir = ($row['alias']!=='') ? $row['alias'] : $row['id'];
231
-				$dir_path = $dirpath . $end_dir;
232
-				if(strpos($dir_path,MODX_BASE_PATH)===false) return FALSE;
230
+				$end_dir = ($row['alias'] !== '') ? $row['alias'] : $row['id'];
231
+				$dir_path = $dirpath.$end_dir;
232
+				if (strpos($dir_path, MODX_BASE_PATH) === false) return FALSE;
233 233
 				if (!is_dir($dir_path))
234 234
 				{
235 235
 					if (is_file($dir_path)) @unlink($dir_path);
@@ -239,9 +239,9 @@  discard block
 block discarded – undo
239 239
 				}
240 240
 				
241 241
 				
242
-				if($modx->config['make_folders']==='1' && $row['published']==='1')
242
+				if ($modx->config['make_folders'] === '1' && $row['published'] === '1')
243 243
 				{
244
-					if(is_file($filename)) rename($filename,$dir_path . '/index.html');
244
+					if (is_file($filename)) rename($filename, $dir_path.'/index.html');
245 245
 				}
246 246
 				$this->targetDir = $dir_path;
247 247
 				$this->run($row['id']);
@@ -250,16 +250,16 @@  discard block
 block discarded – undo
250 250
 		return implode("\n", $this->output);
251 251
 	}
252 252
 	
253
-    function curl_get_contents($url, $timeout = 30 )
253
+    function curl_get_contents($url, $timeout = 30)
254 254
     {
255
-    	if(!function_exists('curl_init')) return @file_get_contents($url);
255
+    	if (!function_exists('curl_init')) return @file_get_contents($url);
256 256
 
257 257
         $ch = curl_init();
258 258
         curl_setopt($ch, CURLOPT_URL, $url);
259
-        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);    // 0 = DO NOT VERIFY AUTHENTICITY OF SSL-CERT
260
-        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);    // 2 = CERT MUST INDICATE BEING CONNECTED TO RIGHT SERVER
259
+        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); // 0 = DO NOT VERIFY AUTHENTICITY OF SSL-CERT
260
+        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); // 2 = CERT MUST INDICATE BEING CONNECTED TO RIGHT SERVER
261 261
         curl_setopt($ch, CURLOPT_HEADER, false);
262
-        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true );
262
+        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
263 263
         curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
264 264
         curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
265 265
         $result = curl_exec($ch);
@@ -267,12 +267,12 @@  discard block
 block discarded – undo
267 267
         return $result;
268 268
     }
269 269
 
270
-    function parsePlaceholder($tpl,$ph=array())
270
+    function parsePlaceholder($tpl, $ph = array())
271 271
     {
272
-    	foreach($ph as $k=>$v)
272
+    	foreach ($ph as $k=>$v)
273 273
     	{
274 274
     		$k = "[+{$k}+]";
275
-    		$tpl = str_replace($k,$v,$tpl);
275
+    		$tpl = str_replace($k, $v, $tpl);
276 276
     	}
277 277
     	return $tpl;
278 278
     }
Please login to merge, or discard this patch.