@@ -1,5 +1,5 @@ |
||
| 1 | 1 | <?php |
| 2 | -if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
| 2 | +if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
| 3 | 3 | die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
| 4 | 4 | } |
| 5 | 5 | ?> |
@@ -4,141 +4,141 @@ |
||
| 4 | 4 | // SNUFFKIN/ Alex 2004 |
| 5 | 5 | |
| 6 | 6 | class SqlParser { |
| 7 | - public $host; |
|
| 8 | - public $dbname; |
|
| 9 | - public $prefix; |
|
| 10 | - public $user; |
|
| 11 | - public $password; |
|
| 12 | - public $mysqlErrors; |
|
| 13 | - public $conn; |
|
| 14 | - public $installFailed; |
|
| 15 | - public $sitename; |
|
| 16 | - public $adminname; |
|
| 17 | - public $adminemail; |
|
| 18 | - public $adminpass; |
|
| 19 | - public $managerlanguage; |
|
| 20 | - public $mode; |
|
| 21 | - public $fileManagerPath; |
|
| 22 | - public $imgPath; |
|
| 23 | - public $imgUrl; |
|
| 24 | - public $dbMODx; |
|
| 25 | - public $dbVersion; |
|
| 7 | + public $host; |
|
| 8 | + public $dbname; |
|
| 9 | + public $prefix; |
|
| 10 | + public $user; |
|
| 11 | + public $password; |
|
| 12 | + public $mysqlErrors; |
|
| 13 | + public $conn; |
|
| 14 | + public $installFailed; |
|
| 15 | + public $sitename; |
|
| 16 | + public $adminname; |
|
| 17 | + public $adminemail; |
|
| 18 | + public $adminpass; |
|
| 19 | + public $managerlanguage; |
|
| 20 | + public $mode; |
|
| 21 | + public $fileManagerPath; |
|
| 22 | + public $imgPath; |
|
| 23 | + public $imgUrl; |
|
| 24 | + public $dbMODx; |
|
| 25 | + public $dbVersion; |
|
| 26 | 26 | public $connection_charset; |
| 27 | 27 | public $connection_method; |
| 28 | 28 | public $ignoreDuplicateErrors; |
| 29 | 29 | public $autoTemplateLogic; |
| 30 | 30 | |
| 31 | - public function __construct($host, $user, $password, $db, $prefix='modx_', $adminname, $adminemail, $adminpass, $connection_charset= 'utf8', $managerlanguage='english', $connection_method = 'SET CHARACTER SET', $auto_template_logic = 'parent') { |
|
| 32 | - $this->host = $host; |
|
| 33 | - $this->dbname = $db; |
|
| 34 | - $this->prefix = $prefix; |
|
| 35 | - $this->user = $user; |
|
| 36 | - $this->password = $password; |
|
| 37 | - $this->adminpass = $adminpass; |
|
| 38 | - $this->adminname = $adminname; |
|
| 39 | - $this->adminemail = $adminemail; |
|
| 40 | - $this->connection_charset = $connection_charset; |
|
| 41 | - $this->connection_method = $connection_method; |
|
| 42 | - $this->ignoreDuplicateErrors = false; |
|
| 43 | - $this->managerlanguage = $managerlanguage; |
|
| 31 | + public function __construct($host, $user, $password, $db, $prefix='modx_', $adminname, $adminemail, $adminpass, $connection_charset= 'utf8', $managerlanguage='english', $connection_method = 'SET CHARACTER SET', $auto_template_logic = 'parent') { |
|
| 32 | + $this->host = $host; |
|
| 33 | + $this->dbname = $db; |
|
| 34 | + $this->prefix = $prefix; |
|
| 35 | + $this->user = $user; |
|
| 36 | + $this->password = $password; |
|
| 37 | + $this->adminpass = $adminpass; |
|
| 38 | + $this->adminname = $adminname; |
|
| 39 | + $this->adminemail = $adminemail; |
|
| 40 | + $this->connection_charset = $connection_charset; |
|
| 41 | + $this->connection_method = $connection_method; |
|
| 42 | + $this->ignoreDuplicateErrors = false; |
|
| 43 | + $this->managerlanguage = $managerlanguage; |
|
| 44 | 44 | $this->autoTemplateLogic = $auto_template_logic; |
| 45 | - } |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - public function connect() { |
|
| 48 | - $this->conn = mysqli_connect($this->host, $this->user, $this->password); |
|
| 49 | - mysqli_select_db($this->conn, $this->dbname); |
|
| 50 | - if (function_exists('mysqli_set_charset')) mysqli_set_charset($this->conn, $this->connection_charset); |
|
| 47 | + public function connect() { |
|
| 48 | + $this->conn = mysqli_connect($this->host, $this->user, $this->password); |
|
| 49 | + mysqli_select_db($this->conn, $this->dbname); |
|
| 50 | + if (function_exists('mysqli_set_charset')) mysqli_set_charset($this->conn, $this->connection_charset); |
|
| 51 | 51 | |
| 52 | - $this->dbVersion = 3.23; // assume version 3.23 |
|
| 53 | - if(function_exists("mysqli_get_server_info")) { |
|
| 54 | - $ver = mysqli_get_server_info($this->conn); |
|
| 55 | - $this->dbMODx = version_compare($ver,"4.0.2"); |
|
| 56 | - $this->dbVersion = (float) $ver; // Typecasting (float) instead of floatval() [PHP < 4.2] |
|
| 57 | - } |
|
| 52 | + $this->dbVersion = 3.23; // assume version 3.23 |
|
| 53 | + if(function_exists("mysqli_get_server_info")) { |
|
| 54 | + $ver = mysqli_get_server_info($this->conn); |
|
| 55 | + $this->dbMODx = version_compare($ver,"4.0.2"); |
|
| 56 | + $this->dbVersion = (float) $ver; // Typecasting (float) instead of floatval() [PHP < 4.2] |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | 59 | mysqli_query($this->conn,"{$this->connection_method} {$this->connection_charset}"); |
| 60 | - } |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | 62 | public function process($filename) { |
| 63 | - global $custom_placeholders; |
|
| 64 | - |
|
| 65 | - // check to make sure file exists |
|
| 66 | - if (!file_exists($filename)) { |
|
| 67 | - $this->mysqlErrors[] = array("error" => "File '$filename' not found"); |
|
| 68 | - $this->installFailed = true ; |
|
| 69 | - return false; |
|
| 70 | - } |
|
| 71 | - |
|
| 72 | - $fh = fopen($filename, 'r'); |
|
| 73 | - $idata = ''; |
|
| 74 | - |
|
| 75 | - while (!feof($fh)) { |
|
| 76 | - $idata .= fread($fh, 1024); |
|
| 77 | - } |
|
| 78 | - |
|
| 79 | - fclose($fh); |
|
| 80 | - $idata = str_replace("\r", '', $idata); |
|
| 81 | - |
|
| 82 | - // check if in upgrade mode |
|
| 83 | - if ($this->mode === 'upd') { |
|
| 84 | - // remove non-upgradeable parts |
|
| 85 | - $s = strpos($idata,'non-upgrade-able[['); |
|
| 86 | - $e = strpos($idata,']]non-upgrade-able') + 17; |
|
| 87 | - if($s && $e) { |
|
| 88 | - $idata = str_replace(substr($idata, $s,$e-$s),' Removed non upgradeable items', $idata); |
|
| 63 | + global $custom_placeholders; |
|
| 64 | + |
|
| 65 | + // check to make sure file exists |
|
| 66 | + if (!file_exists($filename)) { |
|
| 67 | + $this->mysqlErrors[] = array("error" => "File '$filename' not found"); |
|
| 68 | + $this->installFailed = true ; |
|
| 69 | + return false; |
|
| 70 | + } |
|
| 71 | + |
|
| 72 | + $fh = fopen($filename, 'r'); |
|
| 73 | + $idata = ''; |
|
| 74 | + |
|
| 75 | + while (!feof($fh)) { |
|
| 76 | + $idata .= fread($fh, 1024); |
|
| 77 | + } |
|
| 78 | + |
|
| 79 | + fclose($fh); |
|
| 80 | + $idata = str_replace("\r", '', $idata); |
|
| 81 | + |
|
| 82 | + // check if in upgrade mode |
|
| 83 | + if ($this->mode === 'upd') { |
|
| 84 | + // remove non-upgradeable parts |
|
| 85 | + $s = strpos($idata,'non-upgrade-able[['); |
|
| 86 | + $e = strpos($idata,']]non-upgrade-able') + 17; |
|
| 87 | + if($s && $e) { |
|
| 88 | + $idata = str_replace(substr($idata, $s,$e-$s),' Removed non upgradeable items', $idata); |
|
| 89 | 89 | } |
| 90 | - } |
|
| 91 | - |
|
| 92 | - // replace {} tags |
|
| 93 | - $idata = str_replace('{PREFIX}', $this->prefix, $idata); |
|
| 94 | - $idata = str_replace('{ADMIN}', $this->adminname, $idata); |
|
| 95 | - $idata = str_replace('{ADMINEMAIL}', $this->adminemail, $idata); |
|
| 96 | - $idata = str_replace('{ADMINPASS}', $this->adminpass, $idata); |
|
| 97 | - $idata = str_replace('{IMAGEPATH}', $this->imgPath, $idata); |
|
| 98 | - $idata = str_replace('{IMAGEURL}', $this->imgUrl, $idata); |
|
| 99 | - $idata = str_replace('{FILEMANAGERPATH}', $this->fileManagerPath, $idata); |
|
| 100 | - $idata = str_replace('{MANAGERLANGUAGE}', $this->managerlanguage, $idata); |
|
| 101 | - $idata = str_replace('{AUTOTEMPLATELOGIC}', $this->autoTemplateLogic, $idata); |
|
| 102 | - /*$idata = str_replace('{VERSION}', $modx_version, $idata);*/ |
|
| 103 | - |
|
| 104 | - // Replace custom placeholders |
|
| 105 | - foreach($custom_placeholders as $key=>$val) { |
|
| 106 | - if (strpos($idata, '{'.$key.'}') !== false) { |
|
| 107 | - $idata = str_replace('{'.$key.'}', $val, $idata); |
|
| 108 | - } |
|
| 109 | - } |
|
| 110 | - |
|
| 111 | - $sql_array = explode("\n\n", $idata); |
|
| 112 | - |
|
| 113 | - $num = 0; |
|
| 114 | - foreach($sql_array as $sql_entry) { |
|
| 115 | - $sql_do = trim($sql_entry, "\r\n; "); |
|
| 116 | - |
|
| 117 | - if (preg_match('/^\#/', $sql_do)) continue; |
|
| 118 | - |
|
| 119 | - // strip out comments and \n for mysql 3.x |
|
| 120 | - if ($this->dbVersion <4.0) { |
|
| 121 | - $sql_do = preg_replace("~COMMENT.*[^']?'.*[^']?'~","",$sql_do); |
|
| 122 | - $sql_do = str_replace('\r', "", $sql_do); |
|
| 123 | - $sql_do = str_replace('\n', "", $sql_do); |
|
| 124 | - } |
|
| 125 | - |
|
| 126 | - |
|
| 127 | - $num = $num + 1; |
|
| 128 | - if ($sql_do) mysqli_query($this->conn, $sql_do); |
|
| 129 | - if(mysqli_error($this->conn)) { |
|
| 130 | - // Ignore duplicate and drop errors - Raymond |
|
| 131 | - if ($this->ignoreDuplicateErrors){ |
|
| 132 | - if (mysqli_errno($this->conn) == 1060 || mysqli_errno($this->conn) == 1061 || mysqli_errno($this->conn) == 1062 ||mysqli_errno($this->conn) == 1091) continue; |
|
| 133 | - } |
|
| 134 | - // End Ignore duplicate |
|
| 135 | - $this->mysqlErrors[] = array("error" => mysqli_error($this->conn), "sql" => $sql_do); |
|
| 136 | - $this->installFailed = true; |
|
| 137 | - } |
|
| 138 | - } |
|
| 139 | - } |
|
| 90 | + } |
|
| 91 | + |
|
| 92 | + // replace {} tags |
|
| 93 | + $idata = str_replace('{PREFIX}', $this->prefix, $idata); |
|
| 94 | + $idata = str_replace('{ADMIN}', $this->adminname, $idata); |
|
| 95 | + $idata = str_replace('{ADMINEMAIL}', $this->adminemail, $idata); |
|
| 96 | + $idata = str_replace('{ADMINPASS}', $this->adminpass, $idata); |
|
| 97 | + $idata = str_replace('{IMAGEPATH}', $this->imgPath, $idata); |
|
| 98 | + $idata = str_replace('{IMAGEURL}', $this->imgUrl, $idata); |
|
| 99 | + $idata = str_replace('{FILEMANAGERPATH}', $this->fileManagerPath, $idata); |
|
| 100 | + $idata = str_replace('{MANAGERLANGUAGE}', $this->managerlanguage, $idata); |
|
| 101 | + $idata = str_replace('{AUTOTEMPLATELOGIC}', $this->autoTemplateLogic, $idata); |
|
| 102 | + /*$idata = str_replace('{VERSION}', $modx_version, $idata);*/ |
|
| 103 | + |
|
| 104 | + // Replace custom placeholders |
|
| 105 | + foreach($custom_placeholders as $key=>$val) { |
|
| 106 | + if (strpos($idata, '{'.$key.'}') !== false) { |
|
| 107 | + $idata = str_replace('{'.$key.'}', $val, $idata); |
|
| 108 | + } |
|
| 109 | + } |
|
| 110 | + |
|
| 111 | + $sql_array = explode("\n\n", $idata); |
|
| 112 | + |
|
| 113 | + $num = 0; |
|
| 114 | + foreach($sql_array as $sql_entry) { |
|
| 115 | + $sql_do = trim($sql_entry, "\r\n; "); |
|
| 116 | + |
|
| 117 | + if (preg_match('/^\#/', $sql_do)) continue; |
|
| 118 | + |
|
| 119 | + // strip out comments and \n for mysql 3.x |
|
| 120 | + if ($this->dbVersion <4.0) { |
|
| 121 | + $sql_do = preg_replace("~COMMENT.*[^']?'.*[^']?'~","",$sql_do); |
|
| 122 | + $sql_do = str_replace('\r', "", $sql_do); |
|
| 123 | + $sql_do = str_replace('\n', "", $sql_do); |
|
| 124 | + } |
|
| 125 | + |
|
| 126 | + |
|
| 127 | + $num = $num + 1; |
|
| 128 | + if ($sql_do) mysqli_query($this->conn, $sql_do); |
|
| 129 | + if(mysqli_error($this->conn)) { |
|
| 130 | + // Ignore duplicate and drop errors - Raymond |
|
| 131 | + if ($this->ignoreDuplicateErrors){ |
|
| 132 | + if (mysqli_errno($this->conn) == 1060 || mysqli_errno($this->conn) == 1061 || mysqli_errno($this->conn) == 1062 ||mysqli_errno($this->conn) == 1091) continue; |
|
| 133 | + } |
|
| 134 | + // End Ignore duplicate |
|
| 135 | + $this->mysqlErrors[] = array("error" => mysqli_error($this->conn), "sql" => $sql_do); |
|
| 136 | + $this->installFailed = true; |
|
| 137 | + } |
|
| 138 | + } |
|
| 139 | + } |
|
| 140 | 140 | |
| 141 | 141 | public function close() { |
| 142 | - mysqli_close($this->conn); |
|
| 143 | - } |
|
| 142 | + mysqli_close($this->conn); |
|
| 143 | + } |
|
| 144 | 144 | } |
@@ -3,7 +3,7 @@ discard block |
||
| 3 | 3 | // MySQL Dump Parser |
| 4 | 4 | // SNUFFKIN/ Alex 2004 |
| 5 | 5 | |
| 6 | -class SqlParser { |
|
| 6 | +class SqlParser{ |
|
| 7 | 7 | public $host; |
| 8 | 8 | public $dbname; |
| 9 | 9 | public $prefix; |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | public $ignoreDuplicateErrors; |
| 29 | 29 | public $autoTemplateLogic; |
| 30 | 30 | |
| 31 | - public function __construct($host, $user, $password, $db, $prefix='modx_', $adminname, $adminemail, $adminpass, $connection_charset= 'utf8', $managerlanguage='english', $connection_method = 'SET CHARACTER SET', $auto_template_logic = 'parent') { |
|
| 31 | + public function __construct($host, $user, $password, $db, $prefix = 'modx_', $adminname, $adminemail, $adminpass, $connection_charset = 'utf8', $managerlanguage = 'english', $connection_method = 'SET CHARACTER SET', $auto_template_logic = 'parent'){ |
|
| 32 | 32 | $this->host = $host; |
| 33 | 33 | $this->dbname = $db; |
| 34 | 34 | $this->prefix = $prefix; |
@@ -44,28 +44,28 @@ discard block |
||
| 44 | 44 | $this->autoTemplateLogic = $auto_template_logic; |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - public function connect() { |
|
| 47 | + public function connect(){ |
|
| 48 | 48 | $this->conn = mysqli_connect($this->host, $this->user, $this->password); |
| 49 | 49 | mysqli_select_db($this->conn, $this->dbname); |
| 50 | 50 | if (function_exists('mysqli_set_charset')) mysqli_set_charset($this->conn, $this->connection_charset); |
| 51 | 51 | |
| 52 | 52 | $this->dbVersion = 3.23; // assume version 3.23 |
| 53 | - if(function_exists("mysqli_get_server_info")) { |
|
| 53 | + if (function_exists("mysqli_get_server_info")) { |
|
| 54 | 54 | $ver = mysqli_get_server_info($this->conn); |
| 55 | - $this->dbMODx = version_compare($ver,"4.0.2"); |
|
| 55 | + $this->dbMODx = version_compare($ver, "4.0.2"); |
|
| 56 | 56 | $this->dbVersion = (float) $ver; // Typecasting (float) instead of floatval() [PHP < 4.2] |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | - mysqli_query($this->conn,"{$this->connection_method} {$this->connection_charset}"); |
|
| 59 | + mysqli_query($this->conn, "{$this->connection_method} {$this->connection_charset}"); |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | - public function process($filename) { |
|
| 62 | + public function process($filename){ |
|
| 63 | 63 | global $custom_placeholders; |
| 64 | 64 | |
| 65 | 65 | // check to make sure file exists |
| 66 | 66 | if (!file_exists($filename)) { |
| 67 | 67 | $this->mysqlErrors[] = array("error" => "File '$filename' not found"); |
| 68 | - $this->installFailed = true ; |
|
| 68 | + $this->installFailed = true; |
|
| 69 | 69 | return false; |
| 70 | 70 | } |
| 71 | 71 | |
@@ -82,10 +82,10 @@ discard block |
||
| 82 | 82 | // check if in upgrade mode |
| 83 | 83 | if ($this->mode === 'upd') { |
| 84 | 84 | // remove non-upgradeable parts |
| 85 | - $s = strpos($idata,'non-upgrade-able[['); |
|
| 86 | - $e = strpos($idata,']]non-upgrade-able') + 17; |
|
| 87 | - if($s && $e) { |
|
| 88 | - $idata = str_replace(substr($idata, $s,$e-$s),' Removed non upgradeable items', $idata); |
|
| 85 | + $s = strpos($idata, 'non-upgrade-able[['); |
|
| 86 | + $e = strpos($idata, ']]non-upgrade-able') + 17; |
|
| 87 | + if ($s && $e) { |
|
| 88 | + $idata = str_replace(substr($idata, $s, $e - $s), ' Removed non upgradeable items', $idata); |
|
| 89 | 89 | } |
| 90 | 90 | } |
| 91 | 91 | |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | /*$idata = str_replace('{VERSION}', $modx_version, $idata);*/ |
| 103 | 103 | |
| 104 | 104 | // Replace custom placeholders |
| 105 | - foreach($custom_placeholders as $key=>$val) { |
|
| 105 | + foreach ($custom_placeholders as $key=>$val) { |
|
| 106 | 106 | if (strpos($idata, '{'.$key.'}') !== false) { |
| 107 | 107 | $idata = str_replace('{'.$key.'}', $val, $idata); |
| 108 | 108 | } |
@@ -111,14 +111,14 @@ discard block |
||
| 111 | 111 | $sql_array = explode("\n\n", $idata); |
| 112 | 112 | |
| 113 | 113 | $num = 0; |
| 114 | - foreach($sql_array as $sql_entry) { |
|
| 114 | + foreach ($sql_array as $sql_entry) { |
|
| 115 | 115 | $sql_do = trim($sql_entry, "\r\n; "); |
| 116 | 116 | |
| 117 | 117 | if (preg_match('/^\#/', $sql_do)) continue; |
| 118 | 118 | |
| 119 | 119 | // strip out comments and \n for mysql 3.x |
| 120 | - if ($this->dbVersion <4.0) { |
|
| 121 | - $sql_do = preg_replace("~COMMENT.*[^']?'.*[^']?'~","",$sql_do); |
|
| 120 | + if ($this->dbVersion < 4.0) { |
|
| 121 | + $sql_do = preg_replace("~COMMENT.*[^']?'.*[^']?'~", "", $sql_do); |
|
| 122 | 122 | $sql_do = str_replace('\r', "", $sql_do); |
| 123 | 123 | $sql_do = str_replace('\n', "", $sql_do); |
| 124 | 124 | } |
@@ -126,10 +126,10 @@ discard block |
||
| 126 | 126 | |
| 127 | 127 | $num = $num + 1; |
| 128 | 128 | if ($sql_do) mysqli_query($this->conn, $sql_do); |
| 129 | - if(mysqli_error($this->conn)) { |
|
| 129 | + if (mysqli_error($this->conn)) { |
|
| 130 | 130 | // Ignore duplicate and drop errors - Raymond |
| 131 | - if ($this->ignoreDuplicateErrors){ |
|
| 132 | - if (mysqli_errno($this->conn) == 1060 || mysqli_errno($this->conn) == 1061 || mysqli_errno($this->conn) == 1062 ||mysqli_errno($this->conn) == 1091) continue; |
|
| 131 | + if ($this->ignoreDuplicateErrors) { |
|
| 132 | + if (mysqli_errno($this->conn) == 1060 || mysqli_errno($this->conn) == 1061 || mysqli_errno($this->conn) == 1062 || mysqli_errno($this->conn) == 1091) continue; |
|
| 133 | 133 | } |
| 134 | 134 | // End Ignore duplicate |
| 135 | 135 | $this->mysqlErrors[] = array("error" => mysqli_error($this->conn), "sql" => $sql_do); |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | } |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | - public function close() { |
|
| 141 | + public function close(){ |
|
| 142 | 142 | mysqli_close($this->conn); |
| 143 | 143 | } |
| 144 | 144 | } |
@@ -3,7 +3,8 @@ discard block |
||
| 3 | 3 | // MySQL Dump Parser |
| 4 | 4 | // SNUFFKIN/ Alex 2004 |
| 5 | 5 | |
| 6 | -class SqlParser { |
|
| 6 | +class SqlParser |
|
| 7 | +{ |
|
| 7 | 8 | public $host; |
| 8 | 9 | public $dbname; |
| 9 | 10 | public $prefix; |
@@ -28,7 +29,8 @@ discard block |
||
| 28 | 29 | public $ignoreDuplicateErrors; |
| 29 | 30 | public $autoTemplateLogic; |
| 30 | 31 | |
| 31 | - public function __construct($host, $user, $password, $db, $prefix='modx_', $adminname, $adminemail, $adminpass, $connection_charset= 'utf8', $managerlanguage='english', $connection_method = 'SET CHARACTER SET', $auto_template_logic = 'parent') { |
|
| 32 | + public function __construct($host, $user, $password, $db, $prefix='modx_', $adminname, $adminemail, $adminpass, $connection_charset= 'utf8', $managerlanguage='english', $connection_method = 'SET CHARACTER SET', $auto_template_logic = 'parent') |
|
| 33 | + { |
|
| 32 | 34 | $this->host = $host; |
| 33 | 35 | $this->dbname = $db; |
| 34 | 36 | $this->prefix = $prefix; |
@@ -44,10 +46,13 @@ discard block |
||
| 44 | 46 | $this->autoTemplateLogic = $auto_template_logic; |
| 45 | 47 | } |
| 46 | 48 | |
| 47 | - public function connect() { |
|
| 49 | + public function connect() |
|
| 50 | + { |
|
| 48 | 51 | $this->conn = mysqli_connect($this->host, $this->user, $this->password); |
| 49 | 52 | mysqli_select_db($this->conn, $this->dbname); |
| 50 | - if (function_exists('mysqli_set_charset')) mysqli_set_charset($this->conn, $this->connection_charset); |
|
| 53 | + if (function_exists('mysqli_set_charset')) { |
|
| 54 | + mysqli_set_charset($this->conn, $this->connection_charset); |
|
| 55 | + } |
|
| 51 | 56 | |
| 52 | 57 | $this->dbVersion = 3.23; // assume version 3.23 |
| 53 | 58 | if(function_exists("mysqli_get_server_info")) { |
@@ -59,7 +64,8 @@ discard block |
||
| 59 | 64 | mysqli_query($this->conn,"{$this->connection_method} {$this->connection_charset}"); |
| 60 | 65 | } |
| 61 | 66 | |
| 62 | - public function process($filename) { |
|
| 67 | + public function process($filename) |
|
| 68 | + { |
|
| 63 | 69 | global $custom_placeholders; |
| 64 | 70 | |
| 65 | 71 | // check to make sure file exists |
@@ -114,7 +120,9 @@ discard block |
||
| 114 | 120 | foreach($sql_array as $sql_entry) { |
| 115 | 121 | $sql_do = trim($sql_entry, "\r\n; "); |
| 116 | 122 | |
| 117 | - if (preg_match('/^\#/', $sql_do)) continue; |
|
| 123 | + if (preg_match('/^\#/', $sql_do)) { |
|
| 124 | + continue; |
|
| 125 | + } |
|
| 118 | 126 | |
| 119 | 127 | // strip out comments and \n for mysql 3.x |
| 120 | 128 | if ($this->dbVersion <4.0) { |
@@ -125,11 +133,15 @@ discard block |
||
| 125 | 133 | |
| 126 | 134 | |
| 127 | 135 | $num = $num + 1; |
| 128 | - if ($sql_do) mysqli_query($this->conn, $sql_do); |
|
| 136 | + if ($sql_do) { |
|
| 137 | + mysqli_query($this->conn, $sql_do); |
|
| 138 | + } |
|
| 129 | 139 | if(mysqli_error($this->conn)) { |
| 130 | 140 | // Ignore duplicate and drop errors - Raymond |
| 131 | - if ($this->ignoreDuplicateErrors){ |
|
| 132 | - if (mysqli_errno($this->conn) == 1060 || mysqli_errno($this->conn) == 1061 || mysqli_errno($this->conn) == 1062 ||mysqli_errno($this->conn) == 1091) continue; |
|
| 141 | + if ($this->ignoreDuplicateErrors) { |
|
| 142 | + if (mysqli_errno($this->conn) == 1060 || mysqli_errno($this->conn) == 1061 || mysqli_errno($this->conn) == 1062 ||mysqli_errno($this->conn) == 1091) { |
|
| 143 | + continue; |
|
| 144 | + } |
|
| 133 | 145 | } |
| 134 | 146 | // End Ignore duplicate |
| 135 | 147 | $this->mysqlErrors[] = array("error" => mysqli_error($this->conn), "sql" => $sql_do); |
@@ -138,7 +150,8 @@ discard block |
||
| 138 | 150 | } |
| 139 | 151 | } |
| 140 | 152 | |
| 141 | - public function close() { |
|
| 153 | + public function close() |
|
| 154 | + { |
|
| 142 | 155 | mysqli_close($this->conn); |
| 143 | 156 | } |
| 144 | 157 | } |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
| 2 | +if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
| 3 | 3 | die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
| 4 | 4 | } |
| 5 | 5 | if (!$modx->hasPermission('bk_manager')) { |
@@ -9,10 +9,10 @@ discard block |
||
| 9 | 9 | $dbase = trim($dbase, '`'); |
| 10 | 10 | |
| 11 | 11 | if (!isset($modx->config['snapshot_path'])) { |
| 12 | - if (is_dir(MODX_BASE_PATH . 'temp/backup/')) { |
|
| 13 | - $modx->config['snapshot_path'] = MODX_BASE_PATH . 'temp/backup/'; |
|
| 12 | + if (is_dir(MODX_BASE_PATH.'temp/backup/')) { |
|
| 13 | + $modx->config['snapshot_path'] = MODX_BASE_PATH.'temp/backup/'; |
|
| 14 | 14 | } else { |
| 15 | - $modx->config['snapshot_path'] = MODX_BASE_PATH . 'assets/backup/'; |
|
| 15 | + $modx->config['snapshot_path'] = MODX_BASE_PATH.'assets/backup/'; |
|
| 16 | 16 | } |
| 17 | 17 | } |
| 18 | 18 | |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | if ($mode == 'restore1') { |
| 24 | 24 | if (isset($_POST['textarea']) && !empty($_POST['textarea'])) { |
| 25 | 25 | $source = trim($_POST['textarea']); |
| 26 | - $_SESSION['textarea'] = $source . "\n"; |
|
| 26 | + $_SESSION['textarea'] = $source."\n"; |
|
| 27 | 27 | } else { |
| 28 | 28 | $source = file_get_contents($_FILES['sqlfile']['tmp_name']); |
| 29 | 29 | } |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | header('Location: index.php?r=9&a=93'); |
| 32 | 32 | exit; |
| 33 | 33 | } elseif ($mode == 'restore2') { |
| 34 | - $path = $modx->config['snapshot_path'] . $_POST['filename']; |
|
| 34 | + $path = $modx->config['snapshot_path'].$_POST['filename']; |
|
| 35 | 35 | if (file_exists($path)) { |
| 36 | 36 | $source = file_get_contents($path); |
| 37 | 37 | import_sql($source); |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | if (!is_writable(rtrim($modx->config['snapshot_path'], '/'))) { |
| 78 | 78 | $modx->webAlertAndQuit(parsePlaceholder($_lang["bkmgr_alert_mkdir"], array('snapshot_path' => $modx->config['snapshot_path']))); |
| 79 | 79 | } |
| 80 | - $sql = "SHOW TABLE STATUS FROM `{$dbase}` LIKE '" . $modx->db->escape($modx->db->config['table_prefix']) . "%'"; |
|
| 80 | + $sql = "SHOW TABLE STATUS FROM `{$dbase}` LIKE '".$modx->db->escape($modx->db->config['table_prefix'])."%'"; |
|
| 81 | 81 | $rs = $modx->db->query($sql); |
| 82 | 82 | $tables = $modx->db->getColumn('Name', $rs); |
| 83 | 83 | $today = date('Y-m-d_H-i-s'); |
@@ -109,18 +109,18 @@ discard block |
||
| 109 | 109 | $modx->webAlertAndQuit('Unable to Backup Database'); |
| 110 | 110 | } |
| 111 | 111 | } else { |
| 112 | - include_once MODX_MANAGER_PATH . "includes/header.inc.php"; // start normal header |
|
| 112 | + include_once MODX_MANAGER_PATH."includes/header.inc.php"; // start normal header |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | if (isset($_SESSION['result_msg']) && $_SESSION['result_msg'] != '') { |
| 116 | 116 | switch ($_SESSION['result_msg']) { |
| 117 | 117 | case 'import_ok': |
| 118 | - $ph['result_msg_import'] = '<div class="alert alert-success">' . $_lang["bkmgr_import_ok"] . '</div>'; |
|
| 119 | - $ph['result_msg_snapshot'] = '<div class="alert alert-success">' . $_lang["bkmgr_import_ok"] . '</div>'; |
|
| 118 | + $ph['result_msg_import'] = '<div class="alert alert-success">'.$_lang["bkmgr_import_ok"].'</div>'; |
|
| 119 | + $ph['result_msg_snapshot'] = '<div class="alert alert-success">'.$_lang["bkmgr_import_ok"].'</div>'; |
|
| 120 | 120 | break; |
| 121 | 121 | case 'snapshot_ok': |
| 122 | 122 | $ph['result_msg_import'] = ''; |
| 123 | - $ph['result_msg_snapshot'] = '<div class="alert alert-success">' . $_lang["bkmgr_snapshot_ok"] . '</div>'; |
|
| 123 | + $ph['result_msg_snapshot'] = '<div class="alert alert-success">'.$_lang["bkmgr_snapshot_ok"].'</div>'; |
|
| 124 | 124 | break; |
| 125 | 125 | } |
| 126 | 126 | $_SESSION['result_msg'] = ''; |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | f.style.display = 'none'; |
| 180 | 180 | } |
| 181 | 181 | } |
| 182 | - <?= (isset($_REQUEST['r']) ? " doRefresh(" . $_REQUEST['r'] . ");" : "") ?> |
|
| 182 | + <?= (isset($_REQUEST['r']) ? " doRefresh(".$_REQUEST['r'].");" : "") ?> |
|
| 183 | 183 | |
| 184 | 184 | </script> |
| 185 | 185 | |
@@ -223,7 +223,7 @@ discard block |
||
| 223 | 223 | </thead> |
| 224 | 224 | <tbody> |
| 225 | 225 | <?php |
| 226 | - $sql = "SHOW TABLE STATUS FROM `{$dbase}` LIKE '" . $modx->db->escape($modx->db->config['table_prefix']) . "%'"; |
|
| 226 | + $sql = "SHOW TABLE STATUS FROM `{$dbase}` LIKE '".$modx->db->escape($modx->db->config['table_prefix'])."%'"; |
|
| 227 | 227 | $rs = $modx->db->query($sql); |
| 228 | 228 | $i = 0; |
| 229 | 229 | while ($db_status = $modx->db->getRow($rs)) { |
@@ -233,29 +233,29 @@ discard block |
||
| 233 | 233 | $table_string = ''; |
| 234 | 234 | } |
| 235 | 235 | |
| 236 | - echo '<tr>' . "\n" . '<td><label class="form-check form-check-label"><input type="checkbox" name="chk[]" class="form-check-input" value="' . $db_status['Name'] . '"' . (strstr($table_string, $db_status['Name']) === false ? '' : ' checked="checked"') . ' /><b class="text-primary">' . $db_status['Name'] . '</b></label></td>' . "\n"; |
|
| 237 | - echo '<td class="text-xs-center">' . (!empty($db_status['Comment']) ? '<i class="' . $_style['actions_help'] . '" data-tooltip="' . $db_status['Comment'] . '"></i>' : '') . '</td>' . "\n"; |
|
| 238 | - echo '<td class="text-xs-right">' . $db_status['Rows'] . '</td>' . "\n"; |
|
| 239 | - echo '<td class="text-xs-right">' . $db_status['Collation'] . '</td>' . "\n"; |
|
| 236 | + echo '<tr>'."\n".'<td><label class="form-check form-check-label"><input type="checkbox" name="chk[]" class="form-check-input" value="'.$db_status['Name'].'"'.(strstr($table_string, $db_status['Name']) === false ? '' : ' checked="checked"').' /><b class="text-primary">'.$db_status['Name'].'</b></label></td>'."\n"; |
|
| 237 | + echo '<td class="text-xs-center">'.(!empty($db_status['Comment']) ? '<i class="'.$_style['actions_help'].'" data-tooltip="'.$db_status['Comment'].'"></i>' : '').'</td>'."\n"; |
|
| 238 | + echo '<td class="text-xs-right">'.$db_status['Rows'].'</td>'."\n"; |
|
| 239 | + echo '<td class="text-xs-right">'.$db_status['Collation'].'</td>'."\n"; |
|
| 240 | 240 | |
| 241 | 241 | // Enable record deletion for certain tables (TRUNCATE TABLE) if they're not already empty |
| 242 | 242 | $truncateable = array( |
| 243 | - $modx->db->config['table_prefix'] . 'event_log', |
|
| 244 | - $modx->db->config['table_prefix'] . 'manager_log', |
|
| 243 | + $modx->db->config['table_prefix'].'event_log', |
|
| 244 | + $modx->db->config['table_prefix'].'manager_log', |
|
| 245 | 245 | ); |
| 246 | 246 | if ($modx->hasPermission('settings') && in_array($db_status['Name'], $truncateable) && $db_status['Rows'] > 0) { |
| 247 | - echo '<td class="text-xs-right"><a class="text-danger" href="index.php?a=54&mode=' . $action . '&u=' . $db_status['Name'] . '" title="' . $_lang['truncate_table'] . '">' . $modx->nicesize($db_status['Data_length'] + $db_status['Data_free']) . '</a>' . '</td>' . "\n"; |
|
| 247 | + echo '<td class="text-xs-right"><a class="text-danger" href="index.php?a=54&mode='.$action.'&u='.$db_status['Name'].'" title="'.$_lang['truncate_table'].'">'.$modx->nicesize($db_status['Data_length'] + $db_status['Data_free']).'</a>'.'</td>'."\n"; |
|
| 248 | 248 | } else { |
| 249 | - echo '<td class="text-xs-right">' . $modx->nicesize($db_status['Data_length'] + $db_status['Data_free']) . '</td>' . "\n"; |
|
| 249 | + echo '<td class="text-xs-right">'.$modx->nicesize($db_status['Data_length'] + $db_status['Data_free']).'</td>'."\n"; |
|
| 250 | 250 | } |
| 251 | 251 | |
| 252 | 252 | if ($modx->hasPermission('settings')) { |
| 253 | - echo '<td class="text-xs-right">' . ($db_status['Data_free'] > 0 ? '<a class="text-danger" href="index.php?a=54&mode=' . $action . '&t=' . $db_status['Name'] . '" title="' . $_lang['optimize_table'] . '">' . $modx->nicesize($db_status['Data_free']) . '</a>' : '-') . '</td>' . "\n"; |
|
| 253 | + echo '<td class="text-xs-right">'.($db_status['Data_free'] > 0 ? '<a class="text-danger" href="index.php?a=54&mode='.$action.'&t='.$db_status['Name'].'" title="'.$_lang['optimize_table'].'">'.$modx->nicesize($db_status['Data_free']).'</a>' : '-').'</td>'."\n"; |
|
| 254 | 254 | } else { |
| 255 | - echo '<td class="text-xs-right">' . ($db_status['Data_free'] > 0 ? $modx->nicesize($db_status['Data_free']) : '-') . '</td>' . "\n"; |
|
| 255 | + echo '<td class="text-xs-right">'.($db_status['Data_free'] > 0 ? $modx->nicesize($db_status['Data_free']) : '-').'</td>'."\n"; |
|
| 256 | 256 | } |
| 257 | 257 | |
| 258 | - echo '<td class="text-xs-right">' . $modx->nicesize($db_status['Data_length'] - $db_status['Data_free']) . '</td>' . "\n" . '<td class="text-xs-right">' . $modx->nicesize($db_status['Index_length']) . '</td>' . "\n" . '<td class="text-xs-right">' . $modx->nicesize($db_status['Index_length'] + $db_status['Data_length'] + $db_status['Data_free']) . '</td>' . "\n" . "</tr>"; |
|
| 258 | + echo '<td class="text-xs-right">'.$modx->nicesize($db_status['Data_length'] - $db_status['Data_free']).'</td>'."\n".'<td class="text-xs-right">'.$modx->nicesize($db_status['Index_length']).'</td>'."\n".'<td class="text-xs-right">'.$modx->nicesize($db_status['Index_length'] + $db_status['Data_length'] + $db_status['Data_free']).'</td>'."\n"."</tr>"; |
|
| 259 | 259 | |
| 260 | 260 | $total = $total + $db_status['Index_length'] + $db_status['Data_length']; |
| 261 | 261 | $totaloverhead = $totaloverhead + $db_status['Data_free']; |
@@ -266,9 +266,9 @@ discard block |
||
| 266 | 266 | <tr> |
| 267 | 267 | <td class="text-xs-right"><?= $_lang['database_table_totals'] ?></td> |
| 268 | 268 | <td colspan="4"> </td> |
| 269 | - <td class="text-xs-right"><?= $totaloverhead > 0 ? '<b class="text-danger">' . $modx->nicesize($totaloverhead) . '</b><br />(' . number_format($totaloverhead) . ' B)' : '-' ?></td> |
|
| 269 | + <td class="text-xs-right"><?= $totaloverhead > 0 ? '<b class="text-danger">'.$modx->nicesize($totaloverhead).'</b><br />('.number_format($totaloverhead).' B)' : '-' ?></td> |
|
| 270 | 270 | <td colspan="2"> </td> |
| 271 | - <td class="text-xs-right"><?= "<b>" . $modx->nicesize($total) . "</b><br />(" . number_format($total) . " B)" ?></td> |
|
| 271 | + <td class="text-xs-right"><?= "<b>".$modx->nicesize($total)."</b><br />(".number_format($total)." B)" ?></td> |
|
| 272 | 272 | </tr> |
| 273 | 273 | </tfoot> |
| 274 | 274 | </table> |
@@ -319,7 +319,7 @@ discard block |
||
| 319 | 319 | foreach ($last_result['0'] as $k => $v) { |
| 320 | 320 | $title[] = $k; |
| 321 | 321 | } |
| 322 | - $result = '<thead><tr><th>' . implode('</th><th>', $title) . '</th></tr></thead>'; |
|
| 322 | + $result = '<thead><tr><th>'.implode('</th><th>', $title).'</th></tr></thead>'; |
|
| 323 | 323 | $result .= '<tbody>'; |
| 324 | 324 | foreach ($last_result as $row) { |
| 325 | 325 | $result_value = array(); |
@@ -327,11 +327,11 @@ discard block |
||
| 327 | 327 | foreach ($row as $k => $v) { |
| 328 | 328 | $result_value[] = $v; |
| 329 | 329 | } |
| 330 | - $result .= '<tr><td>' . implode('</td><td>', $result_value) . '</td></tr>'; |
|
| 330 | + $result .= '<tr><td>'.implode('</td><td>', $result_value).'</td></tr>'; |
|
| 331 | 331 | } |
| 332 | 332 | } |
| 333 | 333 | $result .= '</tbody>'; |
| 334 | - $result = '<table class="table data">' . $result . '</table>'; |
|
| 334 | + $result = '<table class="table data">'.$result.'</table>'; |
|
| 335 | 335 | } |
| 336 | 336 | } |
| 337 | 337 | |
@@ -433,7 +433,7 @@ discard block |
||
| 433 | 433 | while ($count < 11) { |
| 434 | 434 | $line = fgets($file); |
| 435 | 435 | foreach ($detailFields as $label) { |
| 436 | - $fileLabel = '# ' . $label; |
|
| 436 | + $fileLabel = '# '.$label; |
|
| 437 | 437 | if (strpos($line, $fileLabel) !== false) { |
| 438 | 438 | $details[$label] = htmlentities(trim(str_replace(array( |
| 439 | 439 | $fileLabel, |
@@ -446,10 +446,10 @@ discard block |
||
| 446 | 446 | }; |
| 447 | 447 | fclose($file); |
| 448 | 448 | |
| 449 | - $tooltip = "Generation Time: " . $details["Generation Time"] . "\n"; |
|
| 450 | - $tooltip .= "Server version: " . $details["Server version"] . "\n"; |
|
| 451 | - $tooltip .= "PHP Version: " . $details["PHP Version"] . "\n"; |
|
| 452 | - $tooltip .= "Host: " . $details["Host"] . "\n"; |
|
| 449 | + $tooltip = "Generation Time: ".$details["Generation Time"]."\n"; |
|
| 450 | + $tooltip .= "Server version: ".$details["Server version"]."\n"; |
|
| 451 | + $tooltip .= "PHP Version: ".$details["PHP Version"]."\n"; |
|
| 452 | + $tooltip .= "Host: ".$details["Host"]."\n"; |
|
| 453 | 453 | ?> |
| 454 | 454 | <tr> |
| 455 | 455 | <td><?= $filename ?></td> |
@@ -481,7 +481,7 @@ discard block |
||
| 481 | 481 | <?php |
| 482 | 482 | |
| 483 | 483 | if (is_numeric($_GET['tab'])) { |
| 484 | - echo '<script type="text/javascript">tpDBM.setSelectedIndex( ' . $_GET['tab'] . ' );</script>'; |
|
| 484 | + echo '<script type="text/javascript">tpDBM.setSelectedIndex( '.$_GET['tab'].' );</script>'; |
|
| 485 | 485 | } |
| 486 | 486 | |
| 487 | 487 | include_once "footer.inc.php"; // send footer |
@@ -535,7 +535,7 @@ discard block |
||
| 535 | 535 | |
| 536 | 536 | // Set line feed |
| 537 | 537 | $lf = "\n"; |
| 538 | - $tempfile_path = $modx->config['base_path'] . 'assets/backup/temp.php'; |
|
| 538 | + $tempfile_path = $modx->config['base_path'].'assets/backup/temp.php'; |
|
| 539 | 539 | |
| 540 | 540 | $result = $modx->db->query('SHOW TABLES'); |
| 541 | 541 | $tables = $this->result2Array(0, $result); |
@@ -548,15 +548,15 @@ discard block |
||
| 548 | 548 | |
| 549 | 549 | // Set header |
| 550 | 550 | $output = "#{$lf}"; |
| 551 | - $output .= "# " . addslashes($modx->config['site_name']) . " Database Dump{$lf}"; |
|
| 551 | + $output .= "# ".addslashes($modx->config['site_name'])." Database Dump{$lf}"; |
|
| 552 | 552 | $output .= "# MODX Version:{$version['version']}{$lf}"; |
| 553 | 553 | $output .= "# {$lf}"; |
| 554 | 554 | $output .= "# Host: {$this->database_server}{$lf}"; |
| 555 | - $output .= "# Generation Time: " . $modx->toDateFormat(time()) . $lf; |
|
| 556 | - $output .= "# Server version: " . $modx->db->getVersion() . $lf; |
|
| 557 | - $output .= "# PHP Version: " . phpversion() . $lf; |
|
| 555 | + $output .= "# Generation Time: ".$modx->toDateFormat(time()).$lf; |
|
| 556 | + $output .= "# Server version: ".$modx->db->getVersion().$lf; |
|
| 557 | + $output .= "# PHP Version: ".phpversion().$lf; |
|
| 558 | 558 | $output .= "# Database: `{$this->dbname}`{$lf}"; |
| 559 | - $output .= "# Description: " . trim($_REQUEST['backup_title']) . "{$lf}"; |
|
| 559 | + $output .= "# Description: ".trim($_REQUEST['backup_title'])."{$lf}"; |
|
| 560 | 560 | $output .= "#"; |
| 561 | 561 | file_put_contents($tempfile_path, $output, FILE_APPEND | LOCK_EX); |
| 562 | 562 | $output = ''; |
@@ -575,7 +575,7 @@ discard block |
||
| 575 | 575 | } |
| 576 | 576 | } |
| 577 | 577 | if ($callBack === 'snapshot') { |
| 578 | - if (!preg_match('@^' . $modx->db->config['table_prefix'] . '@', $tblval)) { |
|
| 578 | + if (!preg_match('@^'.$modx->db->config['table_prefix'].'@', $tblval)) { |
|
| 579 | 579 | continue; |
| 580 | 580 | } |
| 581 | 581 | } |
@@ -597,7 +597,7 @@ discard block |
||
| 597 | 597 | $insertdump = $lf; |
| 598 | 598 | $insertdump .= "INSERT INTO `{$tblval}` VALUES ("; |
| 599 | 599 | $arr = $this->object2Array($row); |
| 600 | - if( ! is_array($arr)) $arr = array(); |
|
| 600 | + if (!is_array($arr)) $arr = array(); |
|
| 601 | 601 | foreach ($arr as $key => $value) { |
| 602 | 602 | if (is_null($value)) { |
| 603 | 603 | $value = 'NULL'; |
@@ -610,9 +610,9 @@ discard block |
||
| 610 | 610 | ), '\\n', $value); |
| 611 | 611 | $value = "'{$value}'"; |
| 612 | 612 | } |
| 613 | - $insertdump .= $value . ','; |
|
| 613 | + $insertdump .= $value.','; |
|
| 614 | 614 | } |
| 615 | - $output .= rtrim($insertdump, ',') . ");\n"; |
|
| 615 | + $output .= rtrim($insertdump, ',').");\n"; |
|
| 616 | 616 | if (1048576 < strlen($output)) { |
| 617 | 617 | file_put_contents($tempfile_path, $output, FILE_APPEND | LOCK_EX); |
| 618 | 618 | $output = ''; |
@@ -597,7 +597,9 @@ |
||
| 597 | 597 | $insertdump = $lf; |
| 598 | 598 | $insertdump .= "INSERT INTO `{$tblval}` VALUES ("; |
| 599 | 599 | $arr = $this->object2Array($row); |
| 600 | - if( ! is_array($arr)) $arr = array(); |
|
| 600 | + if( ! is_array($arr)) { |
|
| 601 | + $arr = array(); |
|
| 602 | + } |
|
| 601 | 603 | foreach ($arr as $key => $value) { |
| 602 | 604 | if (is_null($value)) { |
| 603 | 605 | $value = 'NULL'; |
@@ -1,11 +1,11 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -$installMode = isset($_POST['installmode']) ? (int)$_POST['installmode'] : 0; |
|
| 2 | +$installMode = isset($_POST['installmode']) ? (int) $_POST['installmode'] : 0; |
|
| 3 | 3 | |
| 4 | 4 | // Determine upgradeability |
| 5 | -$upgradeable= 0; |
|
| 5 | +$upgradeable = 0; |
|
| 6 | 6 | if ($installMode === 0) { |
| 7 | - $database_name= ''; |
|
| 8 | - $database_server= 'localhost'; |
|
| 7 | + $database_name = ''; |
|
| 8 | + $database_server = 'localhost'; |
|
| 9 | 9 | $table_prefix = base_convert(rand(10, 20), 10, 36).substr(str_shuffle('0123456789abcdefghijklmnopqrstuvwxyz'), rand(0, 33), 3).'_'; |
| 10 | 10 | } else { |
| 11 | 11 | $database_name = ''; |
@@ -17,13 +17,13 @@ discard block |
||
| 17 | 17 | if ($dbase) { |
| 18 | 18 | $database_name = trim($dbase, '`'); |
| 19 | 19 | if (!$conn = mysqli_connect($database_server, $database_user, $database_password)) |
| 20 | - $upgradeable = (isset($_POST['installmode']) && $_POST['installmode']=='new') ? 0 : 2; |
|
| 21 | - elseif (! mysqli_select_db($conn, trim($dbase, '`'))) |
|
| 22 | - $upgradeable = (isset($_POST['installmode']) && $_POST['installmode']=='new') ? 0 : 2; |
|
| 20 | + $upgradeable = (isset($_POST['installmode']) && $_POST['installmode'] == 'new') ? 0 : 2; |
|
| 21 | + elseif (!mysqli_select_db($conn, trim($dbase, '`'))) |
|
| 22 | + $upgradeable = (isset($_POST['installmode']) && $_POST['installmode'] == 'new') ? 0 : 2; |
|
| 23 | 23 | else |
| 24 | 24 | $upgradeable = 1; |
| 25 | 25 | } |
| 26 | - else $upgradable= 2; |
|
| 26 | + else $upgradable = 2; |
|
| 27 | 27 | } |
| 28 | 28 | } |
| 29 | 29 | |
@@ -49,28 +49,28 @@ discard block |
||
| 49 | 49 | $database_connection_method = 'SET CHARACTER SET'; |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | -$ph['database_name'] = isset($_POST['database_name']) ? $_POST['database_name']: $database_name; |
|
| 53 | -$ph['tableprefix'] = isset($_POST['tableprefix']) ? $_POST['tableprefix']: $table_prefix; |
|
| 52 | +$ph['database_name'] = isset($_POST['database_name']) ? $_POST['database_name'] : $database_name; |
|
| 53 | +$ph['tableprefix'] = isset($_POST['tableprefix']) ? $_POST['tableprefix'] : $table_prefix; |
|
| 54 | 54 | $ph['selected_set_character_set'] = isset($database_connection_method) && $database_connection_method == 'SET CHARACTER SET' ? 'selected' : ''; |
| 55 | 55 | $ph['selected_set_names'] = isset($database_connection_method) && $database_connection_method == 'SET NAMES' ? 'selected' : ''; |
| 56 | 56 | $ph['show#connection_method'] = (($installMode == 0) || ($installMode == 2)) ? 'block' : 'none'; |
| 57 | -$ph['database_collation'] = isset($_POST['database_collation']) ? $_POST['database_collation']: $database_collation; |
|
| 58 | -$ph['show#AUH'] = ($installMode == 0) ? 'block':'none'; |
|
| 59 | -$ph['cmsadmin'] = isset($_POST['cmsadmin']) ? $_POST['cmsadmin']:'admin'; |
|
| 60 | -$ph['cmsadminemail'] = isset($_POST['cmsadminemail']) ? $_POST['cmsadminemail']:""; |
|
| 61 | -$ph['cmspassword'] = isset($_POST['cmspassword']) ? $_POST['cmspassword']:""; |
|
| 62 | -$ph['cmspasswordconfirm'] = isset($_POST['cmspasswordconfirm']) ? $_POST['cmspasswordconfirm']:""; |
|
| 57 | +$ph['database_collation'] = isset($_POST['database_collation']) ? $_POST['database_collation'] : $database_collation; |
|
| 58 | +$ph['show#AUH'] = ($installMode == 0) ? 'block' : 'none'; |
|
| 59 | +$ph['cmsadmin'] = isset($_POST['cmsadmin']) ? $_POST['cmsadmin'] : 'admin'; |
|
| 60 | +$ph['cmsadminemail'] = isset($_POST['cmsadminemail']) ? $_POST['cmsadminemail'] : ""; |
|
| 61 | +$ph['cmspassword'] = isset($_POST['cmspassword']) ? $_POST['cmspassword'] : ""; |
|
| 62 | +$ph['cmspasswordconfirm'] = isset($_POST['cmspasswordconfirm']) ? $_POST['cmspasswordconfirm'] : ""; |
|
| 63 | 63 | $ph['managerLangs'] = getLangs($install_language); |
| 64 | 64 | $ph['install_language'] = $install_language; |
| 65 | 65 | $ph['installMode'] = $installMode; |
| 66 | -$ph['checkedChkagree'] = isset($_POST['chkagree']) ? 'checked':""; |
|
| 66 | +$ph['checkedChkagree'] = isset($_POST['chkagree']) ? 'checked' : ""; |
|
| 67 | 67 | $ph['database_connection_method'] = isset($database_connection_method) ? $database_connection_method : ''; |
| 68 | -$ph['databasehost'] = isset($_POST['databasehost']) ? $_POST['databasehost']: $database_server; |
|
| 69 | -$ph['databaseloginname'] = isset($_SESSION['databaseloginname']) ? $_SESSION['databaseloginname']: ''; |
|
| 70 | -$ph['databaseloginpassword'] = isset($_SESSION['databaseloginpassword']) ? $_SESSION['databaseloginpassword']: ""; |
|
| 68 | +$ph['databasehost'] = isset($_POST['databasehost']) ? $_POST['databasehost'] : $database_server; |
|
| 69 | +$ph['databaseloginname'] = isset($_SESSION['databaseloginname']) ? $_SESSION['databaseloginname'] : ''; |
|
| 70 | +$ph['databaseloginpassword'] = isset($_SESSION['databaseloginpassword']) ? $_SESSION['databaseloginpassword'] : ""; |
|
| 71 | 71 | $ph['MGR_DIR'] = MGR_DIR; |
| 72 | 72 | |
| 73 | 73 | $content = file_get_contents('./actions/tpl_connection.html'); |
| 74 | -$content = parse($content, $_lang, '[%','%]'); |
|
| 74 | +$content = parse($content, $_lang, '[%', '%]'); |
|
| 75 | 75 | $content = parse($content, $ph); |
| 76 | 76 | echo $content; |
@@ -9,21 +9,24 @@ |
||
| 9 | 9 | $table_prefix = base_convert(rand(10, 20), 10, 36).substr(str_shuffle('0123456789abcdefghijklmnopqrstuvwxyz'), rand(0, 33), 3).'_'; |
| 10 | 10 | } else { |
| 11 | 11 | $database_name = ''; |
| 12 | - if (!is_file($base_path.MGR_DIR.'/includes/config.inc.php')) $upgradeable = 0; |
|
| 13 | - else { |
|
| 12 | + if (!is_file($base_path.MGR_DIR.'/includes/config.inc.php')) { |
|
| 13 | + $upgradeable = 0; |
|
| 14 | + } else { |
|
| 14 | 15 | // Include the file so we can test its validity |
| 15 | 16 | include($base_path.MGR_DIR.'/includes/config.inc.php'); |
| 16 | 17 | // We need to have all connection settings - but prefix may be empty so we have to ignore it |
| 17 | 18 | if ($dbase) { |
| 18 | 19 | $database_name = trim($dbase, '`'); |
| 19 | - if (!$conn = mysqli_connect($database_server, $database_user, $database_password)) |
|
| 20 | - $upgradeable = (isset($_POST['installmode']) && $_POST['installmode']=='new') ? 0 : 2; |
|
| 21 | - elseif (! mysqli_select_db($conn, trim($dbase, '`'))) |
|
| 22 | - $upgradeable = (isset($_POST['installmode']) && $_POST['installmode']=='new') ? 0 : 2; |
|
| 23 | - else |
|
| 24 | - $upgradeable = 1; |
|
| 20 | + if (!$conn = mysqli_connect($database_server, $database_user, $database_password)) { |
|
| 21 | + $upgradeable = (isset($_POST['installmode']) && $_POST['installmode']=='new') ? 0 : 2; |
|
| 22 | + } elseif (! mysqli_select_db($conn, trim($dbase, '`'))) { |
|
| 23 | + $upgradeable = (isset($_POST['installmode']) && $_POST['installmode']=='new') ? 0 : 2; |
|
| 24 | + } else { |
|
| 25 | + $upgradeable = 1; |
|
| 26 | + } |
|
| 27 | + } else { |
|
| 28 | + $upgradable= 2; |
|
| 25 | 29 | } |
| 26 | - else $upgradable= 2; |
|
| 27 | 30 | } |
| 28 | 31 | } |
| 29 | 32 | |
@@ -31,6 +31,9 @@ discard block |
||
| 31 | 31 | public $renderPagerFnc; |
| 32 | 32 | public $renderPagerFncArgs; |
| 33 | 33 | |
| 34 | + /** |
|
| 35 | + * @param boolean|string $id |
|
| 36 | + */ |
|
| 34 | 37 | public function __construct($id, $ds, $pageSize = 10, $pageNumber = -1) { |
| 35 | 38 | global $_PAGE; // use view state object |
| 36 | 39 | |
@@ -77,6 +80,9 @@ discard block |
||
| 77 | 80 | $this->pageSize = $ps; |
| 78 | 81 | } |
| 79 | 82 | |
| 83 | + /** |
|
| 84 | + * @param DataGrid $fncName |
|
| 85 | + */ |
|
| 80 | 86 | public function setRenderRowFnc($fncName, $args = "") { |
| 81 | 87 | $this->renderRowFnc = &$fncName; |
| 82 | 88 | $this->renderRowFncArgs = $args; // extra agruments |
@@ -12,18 +12,18 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | class DataSetPager { |
| 14 | 14 | |
| 15 | - public $ds; // datasource |
|
| 15 | + public $ds; // datasource |
|
| 16 | 16 | public $pageSize; |
| 17 | 17 | public $pageNumber; |
| 18 | 18 | public $rows; |
| 19 | 19 | public $pager; |
| 20 | 20 | public $id; |
| 21 | 21 | |
| 22 | - // normal page |
|
| 22 | + // normal page |
|
| 23 | 23 | public $pageStyle; |
| 24 | 24 | public $pageClass; |
| 25 | 25 | |
| 26 | - // selected page |
|
| 26 | + // selected page |
|
| 27 | 27 | public $selPageStyle; |
| 28 | 28 | public $selPageClass; |
| 29 | 29 | public $renderRowFnc; |
@@ -32,166 +32,166 @@ discard block |
||
| 32 | 32 | public $renderPagerFncArgs; |
| 33 | 33 | |
| 34 | 34 | public function __construct($id, $ds, $pageSize = 10, $pageNumber = -1) { |
| 35 | - global $_PAGE; // use view state object |
|
| 36 | - |
|
| 37 | - global $__DataSetPagerCnt; |
|
| 38 | - |
|
| 39 | - // set id |
|
| 40 | - $__DataSetPagerCnt++; |
|
| 41 | - $this->id = !empty($id) ? $id : "dsp" . $__DataSetPagerCnt; |
|
| 42 | - |
|
| 43 | - // get pagenumber |
|
| 44 | - // by setting pager to -1 cause pager to load it's last page number |
|
| 45 | - if($pageNumber == -1) { |
|
| 46 | - $pageNumber = 1; |
|
| 47 | - if(isset($_GET["dpgn" . $this->id])) { |
|
| 48 | - $pageNumber = $_GET["dpgn" . $this->id]; |
|
| 49 | - } elseif(isset($_PAGE['vs'][$id . '_dpgn'])) { |
|
| 50 | - $pageNumber = $_PAGE['vs'][$id . '_dpgn']; |
|
| 51 | - } |
|
| 52 | - } |
|
| 53 | - if(!is_numeric($pageNumber)) { |
|
| 54 | - $pageNumber = 1; |
|
| 55 | - } |
|
| 56 | - |
|
| 57 | - $this->ds = $ds; // datasource |
|
| 58 | - $this->pageSize = $pageSize; |
|
| 59 | - $this->pageNumber = $pageNumber; |
|
| 60 | - $this->rows = ''; |
|
| 61 | - $this->pager = ''; |
|
| 62 | - } |
|
| 35 | + global $_PAGE; // use view state object |
|
| 36 | + |
|
| 37 | + global $__DataSetPagerCnt; |
|
| 38 | + |
|
| 39 | + // set id |
|
| 40 | + $__DataSetPagerCnt++; |
|
| 41 | + $this->id = !empty($id) ? $id : "dsp" . $__DataSetPagerCnt; |
|
| 42 | + |
|
| 43 | + // get pagenumber |
|
| 44 | + // by setting pager to -1 cause pager to load it's last page number |
|
| 45 | + if($pageNumber == -1) { |
|
| 46 | + $pageNumber = 1; |
|
| 47 | + if(isset($_GET["dpgn" . $this->id])) { |
|
| 48 | + $pageNumber = $_GET["dpgn" . $this->id]; |
|
| 49 | + } elseif(isset($_PAGE['vs'][$id . '_dpgn'])) { |
|
| 50 | + $pageNumber = $_PAGE['vs'][$id . '_dpgn']; |
|
| 51 | + } |
|
| 52 | + } |
|
| 53 | + if(!is_numeric($pageNumber)) { |
|
| 54 | + $pageNumber = 1; |
|
| 55 | + } |
|
| 56 | + |
|
| 57 | + $this->ds = $ds; // datasource |
|
| 58 | + $this->pageSize = $pageSize; |
|
| 59 | + $this->pageNumber = $pageNumber; |
|
| 60 | + $this->rows = ''; |
|
| 61 | + $this->pager = ''; |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | 64 | public function getRenderedPager() { |
| 65 | - return $this->pager; |
|
| 66 | - } |
|
| 65 | + return $this->pager; |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | 68 | public function getRenderedRows() { |
| 69 | - return $this->rows; |
|
| 70 | - } |
|
| 69 | + return $this->rows; |
|
| 70 | + } |
|
| 71 | 71 | |
| 72 | 72 | public function setDataSource($ds) { |
| 73 | - $this->ds = $ds; |
|
| 74 | - } |
|
| 73 | + $this->ds = $ds; |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | 76 | public function setPageSize($ps) { |
| 77 | - $this->pageSize = $ps; |
|
| 78 | - } |
|
| 77 | + $this->pageSize = $ps; |
|
| 78 | + } |
|
| 79 | 79 | |
| 80 | 80 | public function setRenderRowFnc($fncName, $args = "") { |
| 81 | - $this->renderRowFnc = &$fncName; |
|
| 82 | - $this->renderRowFncArgs = $args; // extra agruments |
|
| 81 | + $this->renderRowFnc = &$fncName; |
|
| 82 | + $this->renderRowFncArgs = $args; // extra agruments |
|
| 83 | 83 | |
| 84 | 84 | |
| 85 | - } |
|
| 85 | + } |
|
| 86 | 86 | |
| 87 | 87 | public function setRenderPagerFnc($fncName, $args = "") { |
| 88 | - $this->renderPagerFnc = $fncName; |
|
| 89 | - $this->renderPagerFncArgs = $args; // extra agruments |
|
| 90 | - } |
|
| 88 | + $this->renderPagerFnc = $fncName; |
|
| 89 | + $this->renderPagerFncArgs = $args; // extra agruments |
|
| 90 | + } |
|
| 91 | 91 | |
| 92 | 92 | public function render() { |
| 93 | - global $modx, $_PAGE; |
|
| 94 | - |
|
| 95 | - $isDataset = $modx->db->isResult($this->ds); |
|
| 96 | - |
|
| 97 | - if(!$this->selPageStyle) { |
|
| 98 | - $this->selPageStyle = "font-weight:bold"; |
|
| 99 | - } |
|
| 100 | - |
|
| 101 | - // get total number of rows |
|
| 102 | - $tnr = ($isDataset) ? $modx->db->getRecordCount($this->ds) : count($this->ds); |
|
| 103 | - |
|
| 104 | - // render: no records found |
|
| 105 | - if($tnr <= 0) { |
|
| 106 | - $fnc = $this->renderRowFnc; |
|
| 107 | - $args = $this->renderRowFncArgs; |
|
| 108 | - if(isset($fnc)) { |
|
| 109 | - if($args != "") { |
|
| 110 | - $this->rows .= $fnc(0, null, $args); |
|
| 111 | - } // if agrs was specified then we will pass three params |
|
| 112 | - else { |
|
| 113 | - $this->rows .= $fnc(0, null); |
|
| 114 | - } // otherwise two will be passed |
|
| 115 | - } |
|
| 116 | - return; |
|
| 117 | - } |
|
| 118 | - |
|
| 119 | - // get total pages |
|
| 120 | - $tp = ceil($tnr / $this->pageSize); |
|
| 121 | - if($this->pageNumber > $tp) { |
|
| 122 | - $this->pageNumber = 1; |
|
| 123 | - } |
|
| 124 | - |
|
| 125 | - // get page number |
|
| 126 | - $p = $this->pageNumber; |
|
| 127 | - |
|
| 128 | - // save page number to view state if available |
|
| 129 | - if(isset($_PAGE['vs'])) { |
|
| 130 | - $_PAGE['vs'][$this->id . '_dpgn'] = $p; |
|
| 131 | - } |
|
| 132 | - |
|
| 133 | - // render pager : renderPagerFnc($cuurentPage,$pagerNumber,$arguments=""); |
|
| 134 | - if($tp > 1) { |
|
| 135 | - $url = ''; |
|
| 136 | - $fnc = $this->renderPagerFnc; |
|
| 137 | - $args = $this->renderPagerFncArgs; |
|
| 138 | - if(!isset($fnc)) { |
|
| 139 | - if($modx->isFrontend()) { |
|
| 140 | - $url = $modx->makeUrl($modx->documentIdentifier, '', '', 'full') . '?'; |
|
| 141 | - } else { |
|
| 142 | - $url = $_SERVER['PHP_SELF'] . '?'; |
|
| 143 | - } |
|
| 144 | - $i = 0; |
|
| 145 | - foreach($_GET as $n => $v) if($n != 'dpgn' . $this->id) { |
|
| 146 | - $i++; |
|
| 147 | - $url .= (($i > 1) ? "&" : "") . "$n=$v"; |
|
| 148 | - } |
|
| 149 | - if($i >= 1) { |
|
| 150 | - $url .= "&"; |
|
| 151 | - } |
|
| 152 | - } |
|
| 153 | - for($i = 1; $i <= $tp; $i++) { |
|
| 154 | - if(isset($fnc)) { |
|
| 155 | - if($args != "") { |
|
| 156 | - $this->pager .= $fnc($p, $i, $args); |
|
| 157 | - } else { |
|
| 158 | - $this->pager .= $fnc($p, $i); |
|
| 159 | - } |
|
| 160 | - } else { |
|
| 161 | - $this->pager .= ($p == $i) ? " <span class='" . $this->selPageClass . "' style='" . $this->selPageStyle . "'>$i</span> " : " <a href='" . $url . "dpgn" . $this->id . "=$i' class='" . $this->pageClass . "' style='" . $this->pageStyle . "'>$i</a> "; |
|
| 162 | - } |
|
| 163 | - } |
|
| 164 | - } |
|
| 165 | - |
|
| 166 | - // render row : renderRowFnc($rowNumber,$row,$arguments="") |
|
| 167 | - $fnc = $this->renderRowFnc; |
|
| 168 | - $args = $this->renderRowFncArgs; |
|
| 169 | - |
|
| 170 | - if(isset($fnc)) { |
|
| 171 | - $i = 1; |
|
| 172 | - $fncObject = is_object($fnc); |
|
| 173 | - $minitems = (($p - 1) * $this->pageSize) + 1; |
|
| 174 | - $maxitems = (($p - 1) * $this->pageSize) + $this->pageSize; |
|
| 175 | - while($i <= $maxitems && ($row = ($isDataset) ? $modx->db->getRow($this->ds) : $this->ds[$i - 1])) { |
|
| 176 | - if($i >= $minitems && $i <= $maxitems) { |
|
| 177 | - if($fncObject) { |
|
| 178 | - if($args != "") { |
|
| 179 | - $this->rows .= $fnc->RenderRowFnc($i, $row, $args); |
|
| 180 | - } else { |
|
| 181 | - $this->rows .= $fnc->RenderRowFnc($i, $row); |
|
| 182 | - } |
|
| 183 | - } else { |
|
| 184 | - if($args != "") { |
|
| 185 | - $this->rows .= $fnc($i, $row, $args); |
|
| 186 | - } // if agrs was specified then we wil pass three params |
|
| 187 | - else { |
|
| 188 | - $this->rows .= $fnc($i, $row); |
|
| 189 | - } // otherwise two will be passed |
|
| 190 | - } |
|
| 191 | - |
|
| 192 | - } |
|
| 193 | - $i++; |
|
| 194 | - } |
|
| 195 | - } |
|
| 196 | - } |
|
| 93 | + global $modx, $_PAGE; |
|
| 94 | + |
|
| 95 | + $isDataset = $modx->db->isResult($this->ds); |
|
| 96 | + |
|
| 97 | + if(!$this->selPageStyle) { |
|
| 98 | + $this->selPageStyle = "font-weight:bold"; |
|
| 99 | + } |
|
| 100 | + |
|
| 101 | + // get total number of rows |
|
| 102 | + $tnr = ($isDataset) ? $modx->db->getRecordCount($this->ds) : count($this->ds); |
|
| 103 | + |
|
| 104 | + // render: no records found |
|
| 105 | + if($tnr <= 0) { |
|
| 106 | + $fnc = $this->renderRowFnc; |
|
| 107 | + $args = $this->renderRowFncArgs; |
|
| 108 | + if(isset($fnc)) { |
|
| 109 | + if($args != "") { |
|
| 110 | + $this->rows .= $fnc(0, null, $args); |
|
| 111 | + } // if agrs was specified then we will pass three params |
|
| 112 | + else { |
|
| 113 | + $this->rows .= $fnc(0, null); |
|
| 114 | + } // otherwise two will be passed |
|
| 115 | + } |
|
| 116 | + return; |
|
| 117 | + } |
|
| 118 | + |
|
| 119 | + // get total pages |
|
| 120 | + $tp = ceil($tnr / $this->pageSize); |
|
| 121 | + if($this->pageNumber > $tp) { |
|
| 122 | + $this->pageNumber = 1; |
|
| 123 | + } |
|
| 124 | + |
|
| 125 | + // get page number |
|
| 126 | + $p = $this->pageNumber; |
|
| 127 | + |
|
| 128 | + // save page number to view state if available |
|
| 129 | + if(isset($_PAGE['vs'])) { |
|
| 130 | + $_PAGE['vs'][$this->id . '_dpgn'] = $p; |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + // render pager : renderPagerFnc($cuurentPage,$pagerNumber,$arguments=""); |
|
| 134 | + if($tp > 1) { |
|
| 135 | + $url = ''; |
|
| 136 | + $fnc = $this->renderPagerFnc; |
|
| 137 | + $args = $this->renderPagerFncArgs; |
|
| 138 | + if(!isset($fnc)) { |
|
| 139 | + if($modx->isFrontend()) { |
|
| 140 | + $url = $modx->makeUrl($modx->documentIdentifier, '', '', 'full') . '?'; |
|
| 141 | + } else { |
|
| 142 | + $url = $_SERVER['PHP_SELF'] . '?'; |
|
| 143 | + } |
|
| 144 | + $i = 0; |
|
| 145 | + foreach($_GET as $n => $v) if($n != 'dpgn' . $this->id) { |
|
| 146 | + $i++; |
|
| 147 | + $url .= (($i > 1) ? "&" : "") . "$n=$v"; |
|
| 148 | + } |
|
| 149 | + if($i >= 1) { |
|
| 150 | + $url .= "&"; |
|
| 151 | + } |
|
| 152 | + } |
|
| 153 | + for($i = 1; $i <= $tp; $i++) { |
|
| 154 | + if(isset($fnc)) { |
|
| 155 | + if($args != "") { |
|
| 156 | + $this->pager .= $fnc($p, $i, $args); |
|
| 157 | + } else { |
|
| 158 | + $this->pager .= $fnc($p, $i); |
|
| 159 | + } |
|
| 160 | + } else { |
|
| 161 | + $this->pager .= ($p == $i) ? " <span class='" . $this->selPageClass . "' style='" . $this->selPageStyle . "'>$i</span> " : " <a href='" . $url . "dpgn" . $this->id . "=$i' class='" . $this->pageClass . "' style='" . $this->pageStyle . "'>$i</a> "; |
|
| 162 | + } |
|
| 163 | + } |
|
| 164 | + } |
|
| 165 | + |
|
| 166 | + // render row : renderRowFnc($rowNumber,$row,$arguments="") |
|
| 167 | + $fnc = $this->renderRowFnc; |
|
| 168 | + $args = $this->renderRowFncArgs; |
|
| 169 | + |
|
| 170 | + if(isset($fnc)) { |
|
| 171 | + $i = 1; |
|
| 172 | + $fncObject = is_object($fnc); |
|
| 173 | + $minitems = (($p - 1) * $this->pageSize) + 1; |
|
| 174 | + $maxitems = (($p - 1) * $this->pageSize) + $this->pageSize; |
|
| 175 | + while($i <= $maxitems && ($row = ($isDataset) ? $modx->db->getRow($this->ds) : $this->ds[$i - 1])) { |
|
| 176 | + if($i >= $minitems && $i <= $maxitems) { |
|
| 177 | + if($fncObject) { |
|
| 178 | + if($args != "") { |
|
| 179 | + $this->rows .= $fnc->RenderRowFnc($i, $row, $args); |
|
| 180 | + } else { |
|
| 181 | + $this->rows .= $fnc->RenderRowFnc($i, $row); |
|
| 182 | + } |
|
| 183 | + } else { |
|
| 184 | + if($args != "") { |
|
| 185 | + $this->rows .= $fnc($i, $row, $args); |
|
| 186 | + } // if agrs was specified then we wil pass three params |
|
| 187 | + else { |
|
| 188 | + $this->rows .= $fnc($i, $row); |
|
| 189 | + } // otherwise two will be passed |
|
| 190 | + } |
|
| 191 | + |
|
| 192 | + } |
|
| 193 | + $i++; |
|
| 194 | + } |
|
| 195 | + } |
|
| 196 | + } |
|
| 197 | 197 | } |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | |
| 11 | 11 | $__DataSetPagerCnt = 0; |
| 12 | 12 | |
| 13 | -class DataSetPager { |
|
| 13 | +class DataSetPager{ |
|
| 14 | 14 | |
| 15 | 15 | public $ds; // datasource |
| 16 | 16 | public $pageSize; |
@@ -31,26 +31,26 @@ discard block |
||
| 31 | 31 | public $renderPagerFnc; |
| 32 | 32 | public $renderPagerFncArgs; |
| 33 | 33 | |
| 34 | - public function __construct($id, $ds, $pageSize = 10, $pageNumber = -1) { |
|
| 34 | + public function __construct($id, $ds, $pageSize = 10, $pageNumber = -1){ |
|
| 35 | 35 | global $_PAGE; // use view state object |
| 36 | 36 | |
| 37 | 37 | global $__DataSetPagerCnt; |
| 38 | 38 | |
| 39 | 39 | // set id |
| 40 | 40 | $__DataSetPagerCnt++; |
| 41 | - $this->id = !empty($id) ? $id : "dsp" . $__DataSetPagerCnt; |
|
| 41 | + $this->id = !empty($id) ? $id : "dsp".$__DataSetPagerCnt; |
|
| 42 | 42 | |
| 43 | 43 | // get pagenumber |
| 44 | 44 | // by setting pager to -1 cause pager to load it's last page number |
| 45 | - if($pageNumber == -1) { |
|
| 45 | + if ($pageNumber == -1) { |
|
| 46 | 46 | $pageNumber = 1; |
| 47 | - if(isset($_GET["dpgn" . $this->id])) { |
|
| 48 | - $pageNumber = $_GET["dpgn" . $this->id]; |
|
| 49 | - } elseif(isset($_PAGE['vs'][$id . '_dpgn'])) { |
|
| 50 | - $pageNumber = $_PAGE['vs'][$id . '_dpgn']; |
|
| 47 | + if (isset($_GET["dpgn".$this->id])) { |
|
| 48 | + $pageNumber = $_GET["dpgn".$this->id]; |
|
| 49 | + } elseif (isset($_PAGE['vs'][$id.'_dpgn'])) { |
|
| 50 | + $pageNumber = $_PAGE['vs'][$id.'_dpgn']; |
|
| 51 | 51 | } |
| 52 | 52 | } |
| 53 | - if(!is_numeric($pageNumber)) { |
|
| 53 | + if (!is_numeric($pageNumber)) { |
|
| 54 | 54 | $pageNumber = 1; |
| 55 | 55 | } |
| 56 | 56 | |
@@ -61,40 +61,40 @@ discard block |
||
| 61 | 61 | $this->pager = ''; |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - public function getRenderedPager() { |
|
| 64 | + public function getRenderedPager(){ |
|
| 65 | 65 | return $this->pager; |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | - public function getRenderedRows() { |
|
| 68 | + public function getRenderedRows(){ |
|
| 69 | 69 | return $this->rows; |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - public function setDataSource($ds) { |
|
| 72 | + public function setDataSource($ds){ |
|
| 73 | 73 | $this->ds = $ds; |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | - public function setPageSize($ps) { |
|
| 76 | + public function setPageSize($ps){ |
|
| 77 | 77 | $this->pageSize = $ps; |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | - public function setRenderRowFnc($fncName, $args = "") { |
|
| 80 | + public function setRenderRowFnc($fncName, $args = ""){ |
|
| 81 | 81 | $this->renderRowFnc = &$fncName; |
| 82 | - $this->renderRowFncArgs = $args; // extra agruments |
|
| 82 | + $this->renderRowFncArgs = $args; // extra agruments |
|
| 83 | 83 | |
| 84 | 84 | |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | - public function setRenderPagerFnc($fncName, $args = "") { |
|
| 87 | + public function setRenderPagerFnc($fncName, $args = ""){ |
|
| 88 | 88 | $this->renderPagerFnc = $fncName; |
| 89 | - $this->renderPagerFncArgs = $args; // extra agruments |
|
| 89 | + $this->renderPagerFncArgs = $args; // extra agruments |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | - public function render() { |
|
| 92 | + public function render(){ |
|
| 93 | 93 | global $modx, $_PAGE; |
| 94 | 94 | |
| 95 | 95 | $isDataset = $modx->db->isResult($this->ds); |
| 96 | 96 | |
| 97 | - if(!$this->selPageStyle) { |
|
| 97 | + if (!$this->selPageStyle) { |
|
| 98 | 98 | $this->selPageStyle = "font-weight:bold"; |
| 99 | 99 | } |
| 100 | 100 | |
@@ -102,11 +102,11 @@ discard block |
||
| 102 | 102 | $tnr = ($isDataset) ? $modx->db->getRecordCount($this->ds) : count($this->ds); |
| 103 | 103 | |
| 104 | 104 | // render: no records found |
| 105 | - if($tnr <= 0) { |
|
| 105 | + if ($tnr <= 0) { |
|
| 106 | 106 | $fnc = $this->renderRowFnc; |
| 107 | 107 | $args = $this->renderRowFncArgs; |
| 108 | - if(isset($fnc)) { |
|
| 109 | - if($args != "") { |
|
| 108 | + if (isset($fnc)) { |
|
| 109 | + if ($args != "") { |
|
| 110 | 110 | $this->rows .= $fnc(0, null, $args); |
| 111 | 111 | } // if agrs was specified then we will pass three params |
| 112 | 112 | else { |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | |
| 119 | 119 | // get total pages |
| 120 | 120 | $tp = ceil($tnr / $this->pageSize); |
| 121 | - if($this->pageNumber > $tp) { |
|
| 121 | + if ($this->pageNumber > $tp) { |
|
| 122 | 122 | $this->pageNumber = 1; |
| 123 | 123 | } |
| 124 | 124 | |
@@ -126,39 +126,39 @@ discard block |
||
| 126 | 126 | $p = $this->pageNumber; |
| 127 | 127 | |
| 128 | 128 | // save page number to view state if available |
| 129 | - if(isset($_PAGE['vs'])) { |
|
| 130 | - $_PAGE['vs'][$this->id . '_dpgn'] = $p; |
|
| 129 | + if (isset($_PAGE['vs'])) { |
|
| 130 | + $_PAGE['vs'][$this->id.'_dpgn'] = $p; |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | // render pager : renderPagerFnc($cuurentPage,$pagerNumber,$arguments=""); |
| 134 | - if($tp > 1) { |
|
| 134 | + if ($tp > 1) { |
|
| 135 | 135 | $url = ''; |
| 136 | 136 | $fnc = $this->renderPagerFnc; |
| 137 | 137 | $args = $this->renderPagerFncArgs; |
| 138 | - if(!isset($fnc)) { |
|
| 139 | - if($modx->isFrontend()) { |
|
| 140 | - $url = $modx->makeUrl($modx->documentIdentifier, '', '', 'full') . '?'; |
|
| 138 | + if (!isset($fnc)) { |
|
| 139 | + if ($modx->isFrontend()) { |
|
| 140 | + $url = $modx->makeUrl($modx->documentIdentifier, '', '', 'full').'?'; |
|
| 141 | 141 | } else { |
| 142 | - $url = $_SERVER['PHP_SELF'] . '?'; |
|
| 142 | + $url = $_SERVER['PHP_SELF'].'?'; |
|
| 143 | 143 | } |
| 144 | 144 | $i = 0; |
| 145 | - foreach($_GET as $n => $v) if($n != 'dpgn' . $this->id) { |
|
| 145 | + foreach ($_GET as $n => $v) if ($n != 'dpgn'.$this->id) { |
|
| 146 | 146 | $i++; |
| 147 | - $url .= (($i > 1) ? "&" : "") . "$n=$v"; |
|
| 147 | + $url .= (($i > 1) ? "&" : "")."$n=$v"; |
|
| 148 | 148 | } |
| 149 | - if($i >= 1) { |
|
| 149 | + if ($i >= 1) { |
|
| 150 | 150 | $url .= "&"; |
| 151 | 151 | } |
| 152 | 152 | } |
| 153 | - for($i = 1; $i <= $tp; $i++) { |
|
| 154 | - if(isset($fnc)) { |
|
| 155 | - if($args != "") { |
|
| 153 | + for ($i = 1; $i <= $tp; $i++) { |
|
| 154 | + if (isset($fnc)) { |
|
| 155 | + if ($args != "") { |
|
| 156 | 156 | $this->pager .= $fnc($p, $i, $args); |
| 157 | 157 | } else { |
| 158 | 158 | $this->pager .= $fnc($p, $i); |
| 159 | 159 | } |
| 160 | 160 | } else { |
| 161 | - $this->pager .= ($p == $i) ? " <span class='" . $this->selPageClass . "' style='" . $this->selPageStyle . "'>$i</span> " : " <a href='" . $url . "dpgn" . $this->id . "=$i' class='" . $this->pageClass . "' style='" . $this->pageStyle . "'>$i</a> "; |
|
| 161 | + $this->pager .= ($p == $i) ? " <span class='".$this->selPageClass."' style='".$this->selPageStyle."'>$i</span> " : " <a href='".$url."dpgn".$this->id."=$i' class='".$this->pageClass."' style='".$this->pageStyle."'>$i</a> "; |
|
| 162 | 162 | } |
| 163 | 163 | } |
| 164 | 164 | } |
@@ -167,21 +167,21 @@ discard block |
||
| 167 | 167 | $fnc = $this->renderRowFnc; |
| 168 | 168 | $args = $this->renderRowFncArgs; |
| 169 | 169 | |
| 170 | - if(isset($fnc)) { |
|
| 170 | + if (isset($fnc)) { |
|
| 171 | 171 | $i = 1; |
| 172 | 172 | $fncObject = is_object($fnc); |
| 173 | 173 | $minitems = (($p - 1) * $this->pageSize) + 1; |
| 174 | 174 | $maxitems = (($p - 1) * $this->pageSize) + $this->pageSize; |
| 175 | - while($i <= $maxitems && ($row = ($isDataset) ? $modx->db->getRow($this->ds) : $this->ds[$i - 1])) { |
|
| 176 | - if($i >= $minitems && $i <= $maxitems) { |
|
| 177 | - if($fncObject) { |
|
| 178 | - if($args != "") { |
|
| 175 | + while ($i <= $maxitems && ($row = ($isDataset) ? $modx->db->getRow($this->ds) : $this->ds[$i - 1])) { |
|
| 176 | + if ($i >= $minitems && $i <= $maxitems) { |
|
| 177 | + if ($fncObject) { |
|
| 178 | + if ($args != "") { |
|
| 179 | 179 | $this->rows .= $fnc->RenderRowFnc($i, $row, $args); |
| 180 | 180 | } else { |
| 181 | 181 | $this->rows .= $fnc->RenderRowFnc($i, $row); |
| 182 | 182 | } |
| 183 | 183 | } else { |
| 184 | - if($args != "") { |
|
| 184 | + if ($args != "") { |
|
| 185 | 185 | $this->rows .= $fnc($i, $row, $args); |
| 186 | 186 | } // if agrs was specified then we wil pass three params |
| 187 | 187 | else { |
@@ -10,7 +10,8 @@ discard block |
||
| 10 | 10 | |
| 11 | 11 | $__DataSetPagerCnt = 0; |
| 12 | 12 | |
| 13 | -class DataSetPager { |
|
| 13 | +class DataSetPager |
|
| 14 | +{ |
|
| 14 | 15 | |
| 15 | 16 | public $ds; // datasource |
| 16 | 17 | public $pageSize; |
@@ -31,7 +32,8 @@ discard block |
||
| 31 | 32 | public $renderPagerFnc; |
| 32 | 33 | public $renderPagerFncArgs; |
| 33 | 34 | |
| 34 | - public function __construct($id, $ds, $pageSize = 10, $pageNumber = -1) { |
|
| 35 | + public function __construct($id, $ds, $pageSize = 10, $pageNumber = -1) |
|
| 36 | + { |
|
| 35 | 37 | global $_PAGE; // use view state object |
| 36 | 38 | |
| 37 | 39 | global $__DataSetPagerCnt; |
@@ -61,35 +63,42 @@ discard block |
||
| 61 | 63 | $this->pager = ''; |
| 62 | 64 | } |
| 63 | 65 | |
| 64 | - public function getRenderedPager() { |
|
| 66 | + public function getRenderedPager() |
|
| 67 | + { |
|
| 65 | 68 | return $this->pager; |
| 66 | 69 | } |
| 67 | 70 | |
| 68 | - public function getRenderedRows() { |
|
| 71 | + public function getRenderedRows() |
|
| 72 | + { |
|
| 69 | 73 | return $this->rows; |
| 70 | 74 | } |
| 71 | 75 | |
| 72 | - public function setDataSource($ds) { |
|
| 76 | + public function setDataSource($ds) |
|
| 77 | + { |
|
| 73 | 78 | $this->ds = $ds; |
| 74 | 79 | } |
| 75 | 80 | |
| 76 | - public function setPageSize($ps) { |
|
| 81 | + public function setPageSize($ps) |
|
| 82 | + { |
|
| 77 | 83 | $this->pageSize = $ps; |
| 78 | 84 | } |
| 79 | 85 | |
| 80 | - public function setRenderRowFnc($fncName, $args = "") { |
|
| 86 | + public function setRenderRowFnc($fncName, $args = "") |
|
| 87 | + { |
|
| 81 | 88 | $this->renderRowFnc = &$fncName; |
| 82 | 89 | $this->renderRowFncArgs = $args; // extra agruments |
| 83 | 90 | |
| 84 | 91 | |
| 85 | 92 | } |
| 86 | 93 | |
| 87 | - public function setRenderPagerFnc($fncName, $args = "") { |
|
| 94 | + public function setRenderPagerFnc($fncName, $args = "") |
|
| 95 | + { |
|
| 88 | 96 | $this->renderPagerFnc = $fncName; |
| 89 | 97 | $this->renderPagerFncArgs = $args; // extra agruments |
| 90 | 98 | } |
| 91 | 99 | |
| 92 | - public function render() { |
|
| 100 | + public function render() |
|
| 101 | + { |
|
| 93 | 102 | global $modx, $_PAGE; |
| 94 | 103 | |
| 95 | 104 | $isDataset = $modx->db->isResult($this->ds); |
@@ -142,8 +151,10 @@ discard block |
||
| 142 | 151 | $url = $_SERVER['PHP_SELF'] . '?'; |
| 143 | 152 | } |
| 144 | 153 | $i = 0; |
| 145 | - foreach($_GET as $n => $v) if($n != 'dpgn' . $this->id) { |
|
| 154 | + foreach($_GET as $n => $v) { |
|
| 155 | + if($n != 'dpgn' . $this->id) { |
|
| 146 | 156 | $i++; |
| 157 | + } |
|
| 147 | 158 | $url .= (($i > 1) ? "&" : "") . "$n=$v"; |
| 148 | 159 | } |
| 149 | 160 | if($i >= 1) { |
@@ -8,8 +8,8 @@ |
||
| 8 | 8 | ******************************************************* |
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | -use PHPMailer\PHPMailer\PHPMailer; |
|
| 12 | 11 | use PHPMailer\PHPMailer\Exception as PHPMailerException; |
| 12 | +use PHPMailer\PHPMailer\PHPMailer; |
|
| 13 | 13 | |
| 14 | 14 | require MODX_MANAGER_PATH . 'includes/controls/phpmailer/Exception.php'; |
| 15 | 15 | require MODX_MANAGER_PATH . 'includes/controls/phpmailer/PHPMailer.php'; |
@@ -11,9 +11,9 @@ discard block |
||
| 11 | 11 | use PHPMailer\PHPMailer\PHPMailer; |
| 12 | 12 | use PHPMailer\PHPMailer\Exception as PHPMailerException; |
| 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 |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | public function init(DocumentParser $modx) |
| 47 | 47 | { |
| 48 | 48 | $this->modx = $modx; |
| 49 | - $this->PluginDir = MODX_MANAGER_PATH . 'includes/controls/phpmailer/'; |
|
| 49 | + $this->PluginDir = MODX_MANAGER_PATH.'includes/controls/phpmailer/'; |
|
| 50 | 50 | |
| 51 | 51 | switch ($modx->config['email_method']) { |
| 52 | 52 | case 'smtp': |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | mb_language($this->mb_language); |
| 111 | 111 | mb_internal_encoding($modx->config['modx_charset']); |
| 112 | 112 | } |
| 113 | - $exconf = MODX_MANAGER_PATH . 'includes/controls/phpmailer/config.inc.php'; |
|
| 113 | + $exconf = MODX_MANAGER_PATH.'includes/controls/phpmailer/config.inc.php'; |
|
| 114 | 114 | if (is_file($exconf)) { |
| 115 | 115 | include($exconf); |
| 116 | 116 | } |
@@ -178,12 +178,12 @@ discard block |
||
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | if ($this->modx->debug) { |
| 181 | - $debug_info = 'CharSet = ' . $this->CharSet . "\n"; |
|
| 182 | - $debug_info .= 'Encoding = ' . $this->Encoding . "\n"; |
|
| 183 | - $debug_info .= 'mb_language = ' . $this->mb_language . "\n"; |
|
| 184 | - $debug_info .= 'encode_header_method = ' . $this->encode_header_method . "\n"; |
|
| 181 | + $debug_info = 'CharSet = '.$this->CharSet."\n"; |
|
| 182 | + $debug_info .= 'Encoding = '.$this->Encoding."\n"; |
|
| 183 | + $debug_info .= 'mb_language = '.$this->mb_language."\n"; |
|
| 184 | + $debug_info .= 'encode_header_method = '.$this->encode_header_method."\n"; |
|
| 185 | 185 | $debug_info .= "send_mode = {$mode}\n"; |
| 186 | - $debug_info .= 'Subject = ' . $this->Subject . "\n"; |
|
| 186 | + $debug_info .= 'Subject = '.$this->Subject."\n"; |
|
| 187 | 187 | $log = "<pre>{$debug_info}\n{$header}\n{$org_body}</pre>"; |
| 188 | 188 | $this->modx->logEvent(1, 1, $log, 'MODxMailer debug information'); |
| 189 | 189 | |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | ini_set('sendmail_from', $old_from); |
| 250 | 250 | } |
| 251 | 251 | if (!$rt) { |
| 252 | - $msg = $this->Lang('instantiate') . "<br />\n"; |
|
| 252 | + $msg = $this->Lang('instantiate')."<br />\n"; |
|
| 253 | 253 | $msg .= "{$this->Subject}<br />\n"; |
| 254 | 254 | $msg .= "{$this->FromName}<{$this->From}><br />\n"; |
| 255 | 255 | $msg .= mb_convert_encoding($body, $this->modx->config['modx_charset'], $this->CharSet); |
@@ -268,7 +268,7 @@ discard block |
||
| 268 | 268 | */ |
| 269 | 269 | public function SetError($msg) |
| 270 | 270 | { |
| 271 | - $msg .= '<pre>' . print_r(call_user_func('get_object_vars', $this), true) . '</pre>'; |
|
| 271 | + $msg .= '<pre>'.print_r(call_user_func('get_object_vars', $this), true).'</pre>'; |
|
| 272 | 272 | $this->modx->config['send_errormail'] = '0'; |
| 273 | 273 | $this->modx->logEvent(0, 3, $msg, 'phpmailer'); |
| 274 | 274 | |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
|
|
| 2 | +if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
|
|
| 3 | 3 | die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
|
| 4 | 4 | } |
| 5 | 5 | if (!$modx->hasPermission('logs')) {
|
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | $logs_user = record_sort(array_unique_multi($logs, 'internalKey'), 'username'); |
| 66 | 66 | foreach ($logs_user as $row) {
|
| 67 | 67 | $selectedtext = $row['internalKey'] == $_REQUEST['searchuser'] ? ' selected="selected"' : ''; |
| 68 | - echo "\t\t" . '<option value="' . $row['internalKey'] . '"' . $selectedtext . '>' . $row['username'] . "</option>\n"; |
|
| 68 | + echo "\t\t".'<option value="'.$row['internalKey'].'"'.$selectedtext.'>'.$row['username']."</option>\n"; |
|
| 69 | 69 | } |
| 70 | 70 | ?> |
| 71 | 71 | </select> |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | continue; |
| 87 | 87 | } |
| 88 | 88 | $selectedtext = $row['action'] == $_REQUEST['action'] ? ' selected="selected"' : ''; |
| 89 | - echo "\t\t" . '<option value="' . $row['action'] . '"' . $selectedtext . '>' . $row['action'] . ' - ' . $action . "</option>\n"; |
|
| 89 | + echo "\t\t".'<option value="'.$row['action'].'"'.$selectedtext.'>'.$row['action'].' - '.$action."</option>\n"; |
|
| 90 | 90 | } |
| 91 | 91 | ?> |
| 92 | 92 | </select> |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | $logs_items = record_sort(array_unique_multi($logs, 'itemid'), 'itemid'); |
| 103 | 103 | foreach ($logs_items as $row) {
|
| 104 | 104 | $selectedtext = $row['itemid'] == $_REQUEST['itemid'] ? ' selected="selected"' : ''; |
| 105 | - echo "\t\t" . '<option value="' . $row['itemid'] . '"' . $selectedtext . '>' . $row['itemid'] . "</option>\n"; |
|
| 105 | + echo "\t\t".'<option value="'.$row['itemid'].'"'.$selectedtext.'>'.$row['itemid']."</option>\n"; |
|
| 106 | 106 | } |
| 107 | 107 | ?> |
| 108 | 108 | </select> |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | $logs_names = record_sort(array_unique_multi($logs, 'itemname'), 'itemname'); |
| 119 | 119 | foreach ($logs_names as $row) {
|
| 120 | 120 | $selectedtext = $row['itemname'] == $_REQUEST['itemname'] ? ' selected="selected"' : ''; |
| 121 | - echo "\t\t" . '<option value="' . $row['itemname'] . '"' . $selectedtext . '>' . $row['itemname'] . "</option>\n"; |
|
| 121 | + echo "\t\t".'<option value="'.$row['itemname'].'"'.$selectedtext.'>'.$row['itemname']."</option>\n"; |
|
| 122 | 122 | } |
| 123 | 123 | ?> |
| 124 | 124 | </select> |
@@ -176,26 +176,26 @@ discard block |
||
| 176 | 176 | // get the selections the user made. |
| 177 | 177 | $sqladd = array(); |
| 178 | 178 | if ($_REQUEST['searchuser'] != 0) {
|
| 179 | - $sqladd[] = "internalKey='" . (int)$_REQUEST['searchuser'] . "'"; |
|
| 179 | + $sqladd[] = "internalKey='".(int) $_REQUEST['searchuser']."'"; |
|
| 180 | 180 | } |
| 181 | 181 | if ($_REQUEST['action'] != 0) {
|
| 182 | - $sqladd[] = "action=" . (int)$_REQUEST['action']; |
|
| 182 | + $sqladd[] = "action=".(int) $_REQUEST['action']; |
|
| 183 | 183 | } |
| 184 | 184 | if ($_REQUEST['itemid'] != 0 || $_REQUEST['itemid'] == "-") {
|
| 185 | - $sqladd[] = "itemid='" . $_REQUEST['itemid'] . "'"; |
|
| 185 | + $sqladd[] = "itemid='".$_REQUEST['itemid']."'"; |
|
| 186 | 186 | } |
| 187 | 187 | if ($_REQUEST['itemname'] != '0') {
|
| 188 | - $sqladd[] = "itemname='" . $modx->db->escape($_REQUEST['itemname']) . "'"; |
|
| 188 | + $sqladd[] = "itemname='".$modx->db->escape($_REQUEST['itemname'])."'"; |
|
| 189 | 189 | } |
| 190 | 190 | if ($_REQUEST['message'] != "") {
|
| 191 | - $sqladd[] = "message LIKE '%" . $modx->db->escape($_REQUEST['message']) . "%'"; |
|
| 191 | + $sqladd[] = "message LIKE '%".$modx->db->escape($_REQUEST['message'])."%'"; |
|
| 192 | 192 | } |
| 193 | 193 | // date stuff |
| 194 | 194 | if ($_REQUEST['datefrom'] != "") {
|
| 195 | - $sqladd[] = "timestamp>" . $modx->toTimeStamp($_REQUEST['datefrom']); |
|
| 195 | + $sqladd[] = "timestamp>".$modx->toTimeStamp($_REQUEST['datefrom']); |
|
| 196 | 196 | } |
| 197 | 197 | if ($_REQUEST['dateto'] != "") {
|
| 198 | - $sqladd[] = "timestamp<" . $modx->toTimeStamp($_REQUEST['dateto']); |
|
| 198 | + $sqladd[] = "timestamp<".$modx->toTimeStamp($_REQUEST['dateto']); |
|
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | // If current position is not set, set it to zero |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | // Number of result to display on the page, will be in the LIMIT of the sql query also |
| 209 | 209 | $int_num_result = is_numeric($_REQUEST['nrresults']) ? $_REQUEST['nrresults'] : $number_of_logs; |
| 210 | 210 | |
| 211 | - $extargv = "&a=13&searchuser=" . $_REQUEST['searchuser'] . "&action=" . $_REQUEST['action'] . "&itemid=" . $_REQUEST['itemid'] . "&itemname=" . $_REQUEST['itemname'] . "&message=" . $_REQUEST['message'] . "&dateto=" . $_REQUEST['dateto'] . "&datefrom=" . $_REQUEST['datefrom'] . "&nrresults=" . $int_num_result . "&log_submit=" . $_REQUEST['log_submit']; // extra argv here (could be anything depending on your page) |
|
| 211 | + $extargv = "&a=13&searchuser=".$_REQUEST['searchuser']."&action=".$_REQUEST['action']."&itemid=".$_REQUEST['itemid']."&itemname=".$_REQUEST['itemname']."&message=".$_REQUEST['message']."&dateto=".$_REQUEST['dateto']."&datefrom=".$_REQUEST['datefrom']."&nrresults=".$int_num_result."&log_submit=".$_REQUEST['log_submit']; // extra argv here (could be anything depending on your page) |
|
| 212 | 212 | |
| 213 | 213 | // build the sql |
| 214 | 214 | $limit = $num_rows = $modx->db->getValue($modx->db->select('COUNT(*)', $modx->getFullTableName('manager_log'), (!empty($sqladd) ? implode(' AND ', $sqladd) : '')));
|
@@ -216,9 +216,9 @@ discard block |
||
| 216 | 216 | $rs = $modx->db->select('*', $modx->getFullTableName('manager_log'), (!empty($sqladd) ? implode(' AND ', $sqladd) : ''), 'timestamp DESC, id DESC', "{$int_cur_position}, {$int_num_result}");
|
| 217 | 217 | |
| 218 | 218 | if ($limit < 1) {
|
| 219 | - echo '<p>' . $_lang["mgrlog_emptysrch"] . '</p>'; |
|
| 219 | + echo '<p>'.$_lang["mgrlog_emptysrch"].'</p>'; |
|
| 220 | 220 | } else {
|
| 221 | - echo '<p>' . $_lang["mgrlog_sortinst"] . '</p>'; |
|
| 221 | + echo '<p>'.$_lang["mgrlog_sortinst"].'</p>'; |
|
| 222 | 222 | |
| 223 | 223 | include_once "paginate.inc.php"; |
| 224 | 224 | // New instance of the Paging class, you can modify the color and the width of the html table |
@@ -230,11 +230,11 @@ discard block |
||
| 230 | 230 | $current_row = $int_cur_position / $int_num_result; |
| 231 | 231 | |
| 232 | 232 | // Display the result as you like... |
| 233 | - print "<p>" . $_lang["paging_showing"] . " " . $array_paging['lower']; |
|
| 234 | - print " " . $_lang["paging_to"] . " " . $array_paging['upper']; |
|
| 235 | - print " (" . $array_paging['total'] . " " . $_lang["paging_total"] . ")<br />";
|
|
| 236 | - $paging = $array_paging['first_link'] . $_lang["paging_first"] . (isset($array_paging['first_link']) ? "</a> " : " "); |
|
| 237 | - $paging .= $array_paging['previous_link'] . $_lang["paging_prev"] . (isset($array_paging['previous_link']) ? "</a> " : " "); |
|
| 233 | + print "<p>".$_lang["paging_showing"]." ".$array_paging['lower']; |
|
| 234 | + print " ".$_lang["paging_to"]." ".$array_paging['upper']; |
|
| 235 | + print " (".$array_paging['total']." ".$_lang["paging_total"].")<br />";
|
|
| 236 | + $paging = $array_paging['first_link'].$_lang["paging_first"].(isset($array_paging['first_link']) ? "</a> " : " "); |
|
| 237 | + $paging .= $array_paging['previous_link'].$_lang["paging_prev"].(isset($array_paging['previous_link']) ? "</a> " : " "); |
|
| 238 | 238 | $pagesfound = sizeof($array_row_paging); |
| 239 | 239 | if ($pagesfound > 6) {
|
| 240 | 240 | $paging .= $array_row_paging[$current_row - 2]; // ." "; |
@@ -244,11 +244,11 @@ discard block |
||
| 244 | 244 | $paging .= $array_row_paging[$current_row + 2]; // ." "; |
| 245 | 245 | } else {
|
| 246 | 246 | for ($i = 0; $i < $pagesfound; $i++) {
|
| 247 | - $paging .= $array_row_paging[$i] . " "; |
|
| 247 | + $paging .= $array_row_paging[$i]." "; |
|
| 248 | 248 | } |
| 249 | 249 | } |
| 250 | - $paging .= $array_paging['next_link'] . $_lang["paging_next"] . (isset($array_paging['next_link']) ? "</a> " : " ") . " "; |
|
| 251 | - $paging .= $array_paging['last_link'] . $_lang["paging_last"] . (isset($array_paging['last_link']) ? "</a> " : " ") . " "; |
|
| 250 | + $paging .= $array_paging['next_link'].$_lang["paging_next"].(isset($array_paging['next_link']) ? "</a> " : " ")." "; |
|
| 251 | + $paging .= $array_paging['last_link'].$_lang["paging_last"].(isset($array_paging['last_link']) ? "</a> " : " ")." "; |
|
| 252 | 252 | // The above exemple print somethings like: |
| 253 | 253 | // Results 1 to 20 of 597 <<< 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 >>> |
| 254 | 254 | // Of course you can now play with array_row_paging in order to print |
@@ -282,16 +282,16 @@ discard block |
||
| 282 | 282 | if (!preg_match("/^[0-9]+$/", $logentry['itemid'])) {
|
| 283 | 283 | $item = '<div style="text-align:center;">-</div>'; |
| 284 | 284 | } elseif ($logentry['action'] == 3 || $logentry['action'] == 27 || $logentry['action'] == 5) {
|
| 285 | - $item = '<a href="index.php?a=3&id=' . $logentry['itemid'] . '">' . $logentry['itemname'] . '</a>'; |
|
| 285 | + $item = '<a href="index.php?a=3&id='.$logentry['itemid'].'">'.$logentry['itemname'].'</a>'; |
|
| 286 | 286 | } else {
|
| 287 | 287 | $item = $logentry['itemname']; |
| 288 | 288 | } |
| 289 | 289 | //index.php?a=13&searchuser=' . $logentry['internalKey'] . '&action=' . $logentry['action'] . '&itemname=' . $logentry['itemname'] . '&log_submit=true' |
| 290 | - $user_drill = 'index.php?a=13&searchuser=' . $logentry['internalKey'] . '&itemname=0&log_submit=true'; |
|
| 290 | + $user_drill = 'index.php?a=13&searchuser='.$logentry['internalKey'].'&itemname=0&log_submit=true'; |
|
| 291 | 291 | ?> |
| 292 | 292 | <tr> |
| 293 | - <td><?= '<a href="' . $user_drill . '">' . $logentry['username'] . '</a>' ?></td> |
|
| 294 | - <td class="text-nowrap"><?= '[' . $logentry['action'] . '] ' . $logentry['message'] ?></td> |
|
| 293 | + <td><?= '<a href="'.$user_drill.'">'.$logentry['username'].'</a>' ?></td> |
|
| 294 | + <td class="text-nowrap"><?= '['.$logentry['action'].'] '.$logentry['message'] ?></td> |
|
| 295 | 295 | <td class="text-xs-right"><?= $logentry['itemid'] ?></td> |
| 296 | 296 | <td><?= $item ?></td> |
| 297 | 297 | <td class="text-nowrap"><?= $modx->toDateFormat($logentry['timestamp'] + $server_offset_time) ?></td> |
@@ -1,8 +1,8 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
|
|
| 2 | +if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
| 3 | 3 | die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
|
| 4 | 4 | } |
| 5 | -if (!$modx->hasPermission('logs')) {
|
|
| 5 | +if (!$modx->hasPermission('logs')) { |
|
| 6 | 6 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
| 7 | 7 | } |
| 8 | 8 | |
@@ -11,17 +11,17 @@ discard block |
||
| 11 | 11 | * @param string $checkKey |
| 12 | 12 | * @return array |
| 13 | 13 | */ |
| 14 | -function array_unique_multi($array, $checkKey) |
|
| 15 | -{
|
|
| 14 | +function array_unique_multi($array, $checkKey) |
|
| 15 | +{ |
|
| 16 | 16 | // Use the builtin if we're not a multi-dimensional array |
| 17 | - if (!is_array(current($array)) || empty($checkKey)) {
|
|
| 17 | + if (!is_array(current($array)) || empty($checkKey)) { |
|
| 18 | 18 | return array_unique($array); |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | $ret = array(); |
| 22 | 22 | $checkValues = array(); // contains the unique key Values |
| 23 | - foreach ($array as $key => $current) {
|
|
| 24 | - if (in_array($current[$checkKey], $checkValues)) {
|
|
| 23 | + foreach ($array as $key => $current) { |
|
| 24 | + if (in_array($current[$checkKey], $checkValues)) { |
|
| 25 | 25 | continue; |
| 26 | 26 | } // duplicate |
| 27 | 27 | |
@@ -36,17 +36,17 @@ discard block |
||
| 36 | 36 | * @param string $key |
| 37 | 37 | * @return array |
| 38 | 38 | */ |
| 39 | -function record_sort($array, $key) |
|
| 40 | -{
|
|
| 39 | +function record_sort($array, $key) |
|
| 40 | +{ |
|
| 41 | 41 | $hash = array(); |
| 42 | - foreach ($array as $k => $v) {
|
|
| 42 | + foreach ($array as $k => $v) { |
|
| 43 | 43 | $hash[$k] = $v[$key]; |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | natsort($hash); |
| 47 | 47 | |
| 48 | 48 | $records = array(); |
| 49 | - foreach ($hash as $k => $row) {
|
|
| 49 | + foreach ($hash as $k => $row) { |
|
| 50 | 50 | $records[$k] = $array[$k]; |
| 51 | 51 | } |
| 52 | 52 | |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | <?php |
| 74 | 74 | // get all users currently in the log |
| 75 | 75 | $logs_user = record_sort(array_unique_multi($logs, 'internalKey'), 'username'); |
| 76 | - foreach ($logs_user as $row) {
|
|
| 76 | + foreach ($logs_user as $row) { |
|
| 77 | 77 | $selectedtext = $row['internalKey'] == $_REQUEST['searchuser'] ? ' selected="selected"' : ''; |
| 78 | 78 | echo "\t\t" . '<option value="' . $row['internalKey'] . '"' . $selectedtext . '>' . $row['username'] . "</option>\n"; |
| 79 | 79 | } |
@@ -90,9 +90,9 @@ discard block |
||
| 90 | 90 | // get all available actions in the log |
| 91 | 91 | include_once "actionlist.inc.php"; |
| 92 | 92 | $logs_actions = record_sort(array_unique_multi($logs, 'action'), 'action'); |
| 93 | - foreach ($logs_actions as $row) {
|
|
| 93 | + foreach ($logs_actions as $row) { |
|
| 94 | 94 | $action = getAction($row['action']); |
| 95 | - if ($action == 'Idle') {
|
|
| 95 | + if ($action == 'Idle') { |
|
| 96 | 96 | continue; |
| 97 | 97 | } |
| 98 | 98 | $selectedtext = $row['action'] == $_REQUEST['action'] ? ' selected="selected"' : ''; |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | <?php |
| 111 | 111 | // get all itemid currently in logging |
| 112 | 112 | $logs_items = record_sort(array_unique_multi($logs, 'itemid'), 'itemid'); |
| 113 | - foreach ($logs_items as $row) {
|
|
| 113 | + foreach ($logs_items as $row) { |
|
| 114 | 114 | $selectedtext = $row['itemid'] == $_REQUEST['itemid'] ? ' selected="selected"' : ''; |
| 115 | 115 | echo "\t\t" . '<option value="' . $row['itemid'] . '"' . $selectedtext . '>' . $row['itemid'] . "</option>\n"; |
| 116 | 116 | } |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | <?php |
| 127 | 127 | // get all itemname currently in logging |
| 128 | 128 | $logs_names = record_sort(array_unique_multi($logs, 'itemname'), 'itemname'); |
| 129 | - foreach ($logs_names as $row) {
|
|
| 129 | + foreach ($logs_names as $row) { |
|
| 130 | 130 | $selectedtext = $row['itemname'] == $_REQUEST['itemname'] ? ' selected="selected"' : ''; |
| 131 | 131 | echo "\t\t" . '<option value="' . $row['itemname'] . '"' . $selectedtext . '>' . $row['itemname'] . "</option>\n"; |
| 132 | 132 | } |
@@ -182,36 +182,36 @@ discard block |
||
| 182 | 182 | <div class="container container-body"> |
| 183 | 183 | |
| 184 | 184 | <?php |
| 185 | -if (isset($_REQUEST['log_submit'])) {
|
|
| 185 | +if (isset($_REQUEST['log_submit'])) { |
|
| 186 | 186 | // get the selections the user made. |
| 187 | 187 | $sqladd = array(); |
| 188 | - if ($_REQUEST['searchuser'] != 0) {
|
|
| 188 | + if ($_REQUEST['searchuser'] != 0) { |
|
| 189 | 189 | $sqladd[] = "internalKey='" . (int)$_REQUEST['searchuser'] . "'"; |
| 190 | 190 | } |
| 191 | - if ($_REQUEST['action'] != 0) {
|
|
| 191 | + if ($_REQUEST['action'] != 0) { |
|
| 192 | 192 | $sqladd[] = "action=" . (int)$_REQUEST['action']; |
| 193 | 193 | } |
| 194 | - if ($_REQUEST['itemid'] != 0 || $_REQUEST['itemid'] == "-") {
|
|
| 194 | + if ($_REQUEST['itemid'] != 0 || $_REQUEST['itemid'] == "-") { |
|
| 195 | 195 | $sqladd[] = "itemid='" . $_REQUEST['itemid'] . "'"; |
| 196 | 196 | } |
| 197 | - if ($_REQUEST['itemname'] != '0') {
|
|
| 197 | + if ($_REQUEST['itemname'] != '0') { |
|
| 198 | 198 | $sqladd[] = "itemname='" . $modx->db->escape($_REQUEST['itemname']) . "'"; |
| 199 | 199 | } |
| 200 | - if ($_REQUEST['message'] != "") {
|
|
| 200 | + if ($_REQUEST['message'] != "") { |
|
| 201 | 201 | $sqladd[] = "message LIKE '%" . $modx->db->escape($_REQUEST['message']) . "%'"; |
| 202 | 202 | } |
| 203 | 203 | // date stuff |
| 204 | - if ($_REQUEST['datefrom'] != "") {
|
|
| 204 | + if ($_REQUEST['datefrom'] != "") { |
|
| 205 | 205 | $sqladd[] = "timestamp>" . $modx->toTimeStamp($_REQUEST['datefrom']); |
| 206 | 206 | } |
| 207 | - if ($_REQUEST['dateto'] != "") {
|
|
| 207 | + if ($_REQUEST['dateto'] != "") { |
|
| 208 | 208 | $sqladd[] = "timestamp<" . $modx->toTimeStamp($_REQUEST['dateto']); |
| 209 | 209 | } |
| 210 | 210 | |
| 211 | 211 | // If current position is not set, set it to zero |
| 212 | - if (!isset($_REQUEST['int_cur_position']) || $_REQUEST['int_cur_position'] == 0) {
|
|
| 212 | + if (!isset($_REQUEST['int_cur_position']) || $_REQUEST['int_cur_position'] == 0) { |
|
| 213 | 213 | $int_cur_position = 0; |
| 214 | - } else {
|
|
| 214 | + } else { |
|
| 215 | 215 | $int_cur_position = $_REQUEST['int_cur_position']; |
| 216 | 216 | } |
| 217 | 217 | |
@@ -225,9 +225,9 @@ discard block |
||
| 225 | 225 | |
| 226 | 226 | $rs = $modx->db->select('*', $modx->getFullTableName('manager_log'), (!empty($sqladd) ? implode(' AND ', $sqladd) : ''), 'timestamp DESC, id DESC', "{$int_cur_position}, {$int_num_result}");
|
| 227 | 227 | |
| 228 | -if ($limit < 1) {
|
|
| 228 | +if ($limit < 1) { |
|
| 229 | 229 | echo '<p>' . $_lang["mgrlog_emptysrch"] . '</p>'; |
| 230 | -} else {
|
|
| 230 | +} else { |
|
| 231 | 231 | echo '<p>' . $_lang["mgrlog_sortinst"] . '</p>'; |
| 232 | 232 | |
| 233 | 233 | include_once "paginate.inc.php"; |
@@ -246,14 +246,14 @@ discard block |
||
| 246 | 246 | $paging = $array_paging['first_link'] . $_lang["paging_first"] . (isset($array_paging['first_link']) ? "</a> " : " "); |
| 247 | 247 | $paging .= $array_paging['previous_link'] . $_lang["paging_prev"] . (isset($array_paging['previous_link']) ? "</a> " : " "); |
| 248 | 248 | $pagesfound = sizeof($array_row_paging); |
| 249 | - if ($pagesfound > 6) {
|
|
| 249 | + if ($pagesfound > 6) { |
|
| 250 | 250 | $paging .= $array_row_paging[$current_row - 2]; // ." "; |
| 251 | 251 | $paging .= $array_row_paging[$current_row - 1]; // ." "; |
| 252 | 252 | $paging .= $array_row_paging[$current_row]; // ." "; |
| 253 | 253 | $paging .= $array_row_paging[$current_row + 1]; // ." "; |
| 254 | 254 | $paging .= $array_row_paging[$current_row + 2]; // ." "; |
| 255 | - } else {
|
|
| 256 | - for ($i = 0; $i < $pagesfound; $i++) {
|
|
| 255 | + } else { |
|
| 256 | + for ($i = 0; $i < $pagesfound; $i++) { |
|
| 257 | 257 | $paging .= $array_row_paging[$i] . " "; |
| 258 | 258 | } |
| 259 | 259 | } |
@@ -288,12 +288,12 @@ discard block |
||
| 288 | 288 | // grab the entire log file... |
| 289 | 289 | $logentries = array(); |
| 290 | 290 | $i = 0; |
| 291 | - while ($logentry = $modx->db->getRow($rs)) {
|
|
| 292 | - if (!preg_match("/^[0-9]+$/", $logentry['itemid'])) {
|
|
| 291 | + while ($logentry = $modx->db->getRow($rs)) { |
|
| 292 | + if (!preg_match("/^[0-9]+$/", $logentry['itemid'])) { |
|
| 293 | 293 | $item = '<div style="text-align:center;">-</div>'; |
| 294 | - } elseif ($logentry['action'] == 3 || $logentry['action'] == 27 || $logentry['action'] == 5) {
|
|
| 294 | + } elseif ($logentry['action'] == 3 || $logentry['action'] == 27 || $logentry['action'] == 5) { |
|
| 295 | 295 | $item = '<a href="index.php?a=3&id=' . $logentry['itemid'] . '">' . $logentry['itemname'] . '</a>'; |
| 296 | - } else {
|
|
| 296 | + } else { |
|
| 297 | 297 | $item = $logentry['itemname']; |
| 298 | 298 | } |
| 299 | 299 | //index.php?a=13&searchuser=' . $logentry['internalKey'] . '&action=' . $logentry['action'] . '&itemname=' . $logentry['itemname'] . '&log_submit=true' |
@@ -328,6 +328,6 @@ discard block |
||
| 328 | 328 | // @see index.php @ 915 |
| 329 | 329 | global $action; |
| 330 | 330 | $action = 1; |
| 331 | -} else {
|
|
| 331 | +} else { |
|
| 332 | 332 | echo $_lang["mgrlog_noquery"]; |
| 333 | 333 | } |
@@ -4,18 +4,18 @@ |
||
| 4 | 4 | } |
| 5 | 5 | |
| 6 | 6 | switch ($modx->manager->action) { |
| 7 | - case 78: |
|
| 8 | - if (!$modx->hasPermission('edit_chunk')) { |
|
| 9 | - $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 10 | - } |
|
| 11 | - break; |
|
| 12 | - case 77: |
|
| 13 | - if (!$modx->hasPermission('new_chunk')) { |
|
| 7 | + case 78: |
|
| 8 | + if (!$modx->hasPermission('edit_chunk')) { |
|
| 9 | + $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 10 | + } |
|
| 11 | + break; |
|
| 12 | + case 77: |
|
| 13 | + if (!$modx->hasPermission('new_chunk')) { |
|
| 14 | + $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 15 | + } |
|
| 16 | + break; |
|
| 17 | + default: |
|
| 14 | 18 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
| 15 | - } |
|
| 16 | - break; |
|
| 17 | - default: |
|
| 18 | - $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | $id = isset($_REQUEST['id']) ? (int)$_REQUEST['id'] : 0; |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
| 2 | +if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
| 3 | 3 | die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
| 4 | 4 | } |
| 5 | 5 | |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | -$id = isset($_REQUEST['id']) ? (int)$_REQUEST['id'] : 0; |
|
| 21 | +$id = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : 0; |
|
| 22 | 22 | |
| 23 | 23 | // Get table names (alphabetical) |
| 24 | 24 | $tbl_site_htmlsnippets = $modx->getFullTableName('site_htmlsnippets'); |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | $content['name'] = $_REQUEST['itemname']; |
| 48 | 48 | } else { |
| 49 | 49 | $_SESSION['itemname'] = $_lang["new_htmlsnippet"]; |
| 50 | - $content['category'] = (int)$_REQUEST['catid']; |
|
| 50 | + $content['category'] = (int) $_REQUEST['catid']; |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | if ($modx->manager->hasFormValues()) { |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | // Add lock-element JS-Script |
| 66 | 66 | $lockElementId = $id; |
| 67 | 67 | $lockElementType = 3; |
| 68 | -require_once(MODX_MANAGER_PATH . 'includes/active_user_locks.inc.php'); |
|
| 68 | +require_once(MODX_MANAGER_PATH.'includes/active_user_locks.inc.php'); |
|
| 69 | 69 | |
| 70 | 70 | // Print RTE Javascript function |
| 71 | 71 | ?> |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | <input type="hidden" name="mode" value="<?= $modx->manager->action ?>" /> |
| 137 | 137 | |
| 138 | 138 | <h1> |
| 139 | - <i class="fa fa-th-large"></i><?= ($content['name'] ? $content['name'] . '<small>(' . $content['id'] . ')</small>' : $_lang['new_htmlsnippet']) ?><i class="fa fa-question-circle help"></i> |
|
| 139 | + <i class="fa fa-th-large"></i><?= ($content['name'] ? $content['name'].'<small>('.$content['id'].')</small>' : $_lang['new_htmlsnippet']) ?><i class="fa fa-question-circle help"></i> |
|
| 140 | 140 | </h1> |
| 141 | 141 | |
| 142 | 142 | <?= $_style['actionbuttons']['dynamic']['element'] ?> |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | <div class="form-control-name clearfix"> |
| 161 | 161 | <input name="name" type="text" maxlength="100" value="<?= $modx->htmlspecialchars($content['name']) ?>" class="form-control form-control-lg" onchange="documentDirty=true;" /> |
| 162 | 162 | <?php if ($modx->hasPermission('save_role')): ?> |
| 163 | - <label class="custom-control" title="<?= $_lang['lock_htmlsnippet'] . "\n" . $_lang['lock_htmlsnippet_msg'] ?>" tooltip> |
|
| 163 | + <label class="custom-control" title="<?= $_lang['lock_htmlsnippet']."\n".$_lang['lock_htmlsnippet_msg'] ?>" tooltip> |
|
| 164 | 164 | <input name="locked" type="checkbox" value="on"<?= ($content['locked'] == 1 || $content['locked'] == 'on' ? ' checked="checked"' : '') ?> /> |
| 165 | 165 | <i class="fa fa-lock"></i> |
| 166 | 166 | </label> |
@@ -184,9 +184,9 @@ discard block |
||
| 184 | 184 | <select name="categoryid" class="form-control" onchange="documentDirty=true;"> |
| 185 | 185 | <option> </option> |
| 186 | 186 | <?php |
| 187 | - include_once(MODX_MANAGER_PATH . 'includes/categories.inc.php'); |
|
| 187 | + include_once(MODX_MANAGER_PATH.'includes/categories.inc.php'); |
|
| 188 | 188 | foreach (getCategories() as $n => $v) { |
| 189 | - echo "\t\t\t\t" . '<option value="' . $v['id'] . '"' . ($content['category'] == $v['id'] || (empty($content['category']) && $_POST['categoryid'] == $v['id']) ? ' selected="selected"' : '') . '>' . $modx->htmlspecialchars($v['category']) . "</option>\n"; |
|
| 189 | + echo "\t\t\t\t".'<option value="'.$v['id'].'"'.($content['category'] == $v['id'] || (empty($content['category']) && $_POST['categoryid'] == $v['id']) ? ' selected="selected"' : '').'>'.$modx->htmlspecialchars($v['category'])."</option>\n"; |
|
| 190 | 190 | } |
| 191 | 191 | ?> |
| 192 | 192 | </select> |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | </div> |
| 201 | 201 | <?php if ($_SESSION['mgrRole'] == 1): ?> |
| 202 | 202 | <div class="form-row"> |
| 203 | - <label><input name="disabled" type="checkbox" value="on"<?= ($content['disabled'] == 1 ? ' checked="checked"' : '') ?> /> <?= ($content['disabled'] == 1 ? "<span class='text-danger'>" . $_lang['disabled'] . "</span>" : $_lang['disabled']) ?></label> |
|
| 203 | + <label><input name="disabled" type="checkbox" value="on"<?= ($content['disabled'] == 1 ? ' checked="checked"' : '') ?> /> <?= ($content['disabled'] == 1 ? "<span class='text-danger'>".$_lang['disabled']."</span>" : $_lang['disabled']) ?></label> |
|
| 204 | 204 | </div> |
| 205 | 205 | <?php endif; ?> |
| 206 | 206 | </div> |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | $evtOut = $modx->invokeEvent('OnRichTextEditorRegister'); |
| 217 | 217 | if (is_array($evtOut)) { |
| 218 | 218 | foreach ($evtOut as $i => $editor) { |
| 219 | - echo "\t" . '<option value="' . $editor . '"' . ($which_editor == $editor ? ' selected="selected"' : '') . '>' . $editor . "</option>\n"; |
|
| 219 | + echo "\t".'<option value="'.$editor.'"'.($which_editor == $editor ? ' selected="selected"' : '').'>'.$editor."</option>\n"; |
|
| 220 | 220 | } |
| 221 | 221 | } |
| 222 | 222 | ?> |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
| 2 | +if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
| 3 | 3 | die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
| 4 | 4 | } |
| 5 | 5 | if (!$modx->hasPermission('save_document')) { |
@@ -7,13 +7,13 @@ discard block |
||
| 7 | 7 | } |
| 8 | 8 | |
| 9 | 9 | if (isset($_REQUEST['id'])) { |
| 10 | - $id = (int)$_REQUEST['id']; |
|
| 10 | + $id = (int) $_REQUEST['id']; |
|
| 11 | 11 | } else { |
| 12 | 12 | $modx->webAlertAndQuit($_lang["error_no_id"]); |
| 13 | 13 | } |
| 14 | 14 | |
| 15 | 15 | // check permissions on the document |
| 16 | -include_once MODX_MANAGER_PATH . "processors/user_documents_permissions.class.php"; |
|
| 16 | +include_once MODX_MANAGER_PATH."processors/user_documents_permissions.class.php"; |
|
| 17 | 17 | $udperms = new udperms(); |
| 18 | 18 | $udperms->user = $modx->getLoginUserID(); |
| 19 | 19 | $udperms->document = $id; |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | }, |
| 40 | 40 | cancel: function() { |
| 41 | 41 | documentDirty = false; |
| 42 | - <?= ($id == 0 ? 'document.location.href="index.php?a=2";' : 'document.location.href="index.php?a=3&id=' . $id . '";') ?> |
|
| 42 | + <?= ($id == 0 ? 'document.location.href="index.php?a=2";' : 'document.location.href="index.php?a=3&id='.$id.'";') ?> |
|
| 43 | 43 | } |
| 44 | 44 | }; |
| 45 | 45 | |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | </script> |
| 81 | 81 | |
| 82 | 82 | <h1> |
| 83 | - <i class="fa fa-arrows"></i><?= ($pagetitle ? $pagetitle . '<small>(' . $id . ')</small>' : $_lang['move_resource_title']) ?> |
|
| 83 | + <i class="fa fa-arrows"></i><?= ($pagetitle ? $pagetitle.'<small>('.$id.')</small>' : $_lang['move_resource_title']) ?> |
|
| 84 | 84 | </h1> |
| 85 | 85 | |
| 86 | 86 | <?= $_style['actionbuttons']['dynamic']['save'] ?> |