@@ -5,133 +5,133 @@ discard block |
||
| 5 | 5 | |
| 6 | 6 | // action list |
| 7 | 7 | $GLOBALS['action_list'] = array( |
| 8 | - '1' => 'Loading a frame(set)', |
|
| 9 | - '2' => 'Viewing home page/ online users', |
|
| 10 | - '3' => 'Viewing data for resource', |
|
| 11 | - '4' => 'Creating a resource', |
|
| 12 | - '5' => 'Saving resource', |
|
| 13 | - '6' => 'Deleting resource', |
|
| 14 | - '7' => 'Waiting while MODX cleans up', |
|
| 15 | - '8' => 'Logged out', |
|
| 16 | - '9' => 'Viewing help', |
|
| 17 | - '10' => 'Viewing/ composing messages', |
|
| 18 | - '11' => 'Creating a user', |
|
| 19 | - '12' => 'Editing user', |
|
| 20 | - '13' => 'Viewing logging', |
|
| 21 | - '14' => 'Editing a parser', |
|
| 22 | - '15' => 'Saving a parser', |
|
| 23 | - '16' => 'Editing template', |
|
| 24 | - '17' => 'Editing settings', |
|
| 25 | - '18' => 'Viewing Credits :)', |
|
| 26 | - '19' => 'Creating a new template', |
|
| 27 | - '20' => 'Saving template', |
|
| 28 | - '21' => 'Deleting template', |
|
| 29 | - '22' => 'Editing Snippet', |
|
| 30 | - '23' => 'Creating a new Snippet', |
|
| 31 | - '24' => 'Saving Snippet', |
|
| 32 | - '25' => 'Deleting Snippet', |
|
| 33 | - '26' => 'Refreshing site', |
|
| 34 | - '27' => 'Editing resource', |
|
| 35 | - '28' => 'Changing password', |
|
| 36 | - '29' => 'Error', |
|
| 37 | - '30' => 'Saving settings', |
|
| 38 | - '31' => 'Using file manager', |
|
| 39 | - '32' => 'Saving user', |
|
| 40 | - '33' => 'Deleting user', |
|
| 41 | - '34' => 'Saving new password', |
|
| 42 | - '35' => 'Editing role', |
|
| 43 | - '36' => 'Saving role', |
|
| 44 | - '37' => 'Deleting role', |
|
| 45 | - '38' => 'Creating new role', |
|
| 46 | - '40' => 'Editing Access Permissions', |
|
| 47 | - '41' => 'Editing Access Permissions', |
|
| 48 | - '42' => 'Editing Access Permissions', |
|
| 49 | - '43' => 'Editing Access Permissions', |
|
| 50 | - '44' => 'Editing Access Permissions', |
|
| 51 | - '45' => 'Idle', |
|
| 52 | - '46' => 'Editing Access Permissions', |
|
| 53 | - '47' => 'Editing Access Permissions', |
|
| 54 | - '48' => 'Editing Access Permissions', |
|
| 55 | - '49' => 'Editing Access Permissions', |
|
| 56 | - '50' => 'Editing Access Permissions', |
|
| 57 | - '51' => 'Moving resource', |
|
| 58 | - '52' => 'Moved resource', |
|
| 59 | - '53' => 'Viewing system info', |
|
| 60 | - '54' => 'Optimizing a table', |
|
| 61 | - '55' => 'Empty logs', |
|
| 62 | - '56' => 'Refresh resource tree', |
|
| 63 | - '57' => 'Refresh menu', |
|
| 64 | - '58' => 'Logged in', |
|
| 65 | - '59' => 'About MODX', |
|
| 66 | - '60' => 'Emptying Recycle Bin', |
|
| 67 | - '61' => 'Publishing a resource', |
|
| 68 | - '62' => 'Un-publishing a resource', |
|
| 69 | - '63' => 'Un-deleting a resource', |
|
| 70 | - '64' => 'Removing deleted content', |
|
| 71 | - '65' => 'Deleting a message', |
|
| 72 | - '66' => 'Sending a message', |
|
| 73 | - '67' => 'Removing locks', |
|
| 74 | - '68' => 'Viewing site logging', |
|
| 75 | - '69' => 'Viewing online visitors', |
|
| 76 | - '70' => 'Viewing site schedule', |
|
| 77 | - '71' => 'Searching', |
|
| 78 | - '72' => 'Adding a weblink', |
|
| 79 | - '73' => 'Editing a weblink', |
|
| 80 | - //case "74" : return "Changing personal preferences"; break; |
|
| 81 | - '75' => 'User/ role management', |
|
| 82 | - '76' => 'Element management', |
|
| 83 | - '77' => 'Creating a new Chunk (HTML Snippet)', |
|
| 84 | - '78' => 'Editing Chunk (HTML Snippet)', |
|
| 85 | - '79' => 'Saving Chunk (HTML Snippet)', |
|
| 86 | - '80' => 'Deleting Chunk (HTML Snippet)', |
|
| 87 | - '83' => 'Exporting a resource to HTML', |
|
| 88 | - '84' => 'Load Element Selector', |
|
| 89 | - '85' => 'Create Folder', |
|
| 90 | - '86' => 'Role management', |
|
| 91 | - '87' => 'Create new web user', |
|
| 92 | - '88' => 'Editing web user', |
|
| 93 | - '89' => 'Saving web user', |
|
| 94 | - '90' => 'Deleting web user', |
|
| 95 | - '91' => 'Editing Web Access Permissions', |
|
| 96 | - '92' => 'Editing Access Permissions', |
|
| 97 | - '93' => 'Backup Manager', |
|
| 98 | - '94' => 'Duplicate resource', |
|
| 99 | - '95' => 'Importing resources from HTML', |
|
| 100 | - '96' => 'Duplicate Template', |
|
| 101 | - '97' => 'Duplicate Chunk (HTML Snippet)', |
|
| 102 | - '98' => 'Duplicate Snippet', |
|
| 103 | - '99' => 'Manage Web Users', |
|
| 104 | - '100' => 'Previewing resource', |
|
| 105 | - '101' => 'Create new plugin', |
|
| 106 | - '102' => 'Edit plugin', |
|
| 107 | - '103' => 'Saving plugin', |
|
| 108 | - '104' => 'Delete plugin', |
|
| 109 | - '105' => 'Duplicate plugin', |
|
| 110 | - '106' => 'Viewing Modules', |
|
| 111 | - '107' => 'Create new module', |
|
| 112 | - '108' => 'Edit module', |
|
| 113 | - '109' => 'Saving module', |
|
| 114 | - '110' => 'Delete module', |
|
| 115 | - '111' => 'Duplicate module', |
|
| 116 | - '112' => 'Execute module', |
|
| 117 | - '113' => 'Manage module dependencies', |
|
| 118 | - '114' => 'View event log', |
|
| 119 | - '115' => 'View event log details', |
|
| 120 | - '116' => 'Delete event log', |
|
| 121 | - '117' => 'Editing tv rank', |
|
| 122 | - '118' => 'Call settings ajax include', |
|
| 123 | - '119' => 'Login Fail (Temporary Block)', |
|
| 8 | + '1' => 'Loading a frame(set)', |
|
| 9 | + '2' => 'Viewing home page/ online users', |
|
| 10 | + '3' => 'Viewing data for resource', |
|
| 11 | + '4' => 'Creating a resource', |
|
| 12 | + '5' => 'Saving resource', |
|
| 13 | + '6' => 'Deleting resource', |
|
| 14 | + '7' => 'Waiting while MODX cleans up', |
|
| 15 | + '8' => 'Logged out', |
|
| 16 | + '9' => 'Viewing help', |
|
| 17 | + '10' => 'Viewing/ composing messages', |
|
| 18 | + '11' => 'Creating a user', |
|
| 19 | + '12' => 'Editing user', |
|
| 20 | + '13' => 'Viewing logging', |
|
| 21 | + '14' => 'Editing a parser', |
|
| 22 | + '15' => 'Saving a parser', |
|
| 23 | + '16' => 'Editing template', |
|
| 24 | + '17' => 'Editing settings', |
|
| 25 | + '18' => 'Viewing Credits :)', |
|
| 26 | + '19' => 'Creating a new template', |
|
| 27 | + '20' => 'Saving template', |
|
| 28 | + '21' => 'Deleting template', |
|
| 29 | + '22' => 'Editing Snippet', |
|
| 30 | + '23' => 'Creating a new Snippet', |
|
| 31 | + '24' => 'Saving Snippet', |
|
| 32 | + '25' => 'Deleting Snippet', |
|
| 33 | + '26' => 'Refreshing site', |
|
| 34 | + '27' => 'Editing resource', |
|
| 35 | + '28' => 'Changing password', |
|
| 36 | + '29' => 'Error', |
|
| 37 | + '30' => 'Saving settings', |
|
| 38 | + '31' => 'Using file manager', |
|
| 39 | + '32' => 'Saving user', |
|
| 40 | + '33' => 'Deleting user', |
|
| 41 | + '34' => 'Saving new password', |
|
| 42 | + '35' => 'Editing role', |
|
| 43 | + '36' => 'Saving role', |
|
| 44 | + '37' => 'Deleting role', |
|
| 45 | + '38' => 'Creating new role', |
|
| 46 | + '40' => 'Editing Access Permissions', |
|
| 47 | + '41' => 'Editing Access Permissions', |
|
| 48 | + '42' => 'Editing Access Permissions', |
|
| 49 | + '43' => 'Editing Access Permissions', |
|
| 50 | + '44' => 'Editing Access Permissions', |
|
| 51 | + '45' => 'Idle', |
|
| 52 | + '46' => 'Editing Access Permissions', |
|
| 53 | + '47' => 'Editing Access Permissions', |
|
| 54 | + '48' => 'Editing Access Permissions', |
|
| 55 | + '49' => 'Editing Access Permissions', |
|
| 56 | + '50' => 'Editing Access Permissions', |
|
| 57 | + '51' => 'Moving resource', |
|
| 58 | + '52' => 'Moved resource', |
|
| 59 | + '53' => 'Viewing system info', |
|
| 60 | + '54' => 'Optimizing a table', |
|
| 61 | + '55' => 'Empty logs', |
|
| 62 | + '56' => 'Refresh resource tree', |
|
| 63 | + '57' => 'Refresh menu', |
|
| 64 | + '58' => 'Logged in', |
|
| 65 | + '59' => 'About MODX', |
|
| 66 | + '60' => 'Emptying Recycle Bin', |
|
| 67 | + '61' => 'Publishing a resource', |
|
| 68 | + '62' => 'Un-publishing a resource', |
|
| 69 | + '63' => 'Un-deleting a resource', |
|
| 70 | + '64' => 'Removing deleted content', |
|
| 71 | + '65' => 'Deleting a message', |
|
| 72 | + '66' => 'Sending a message', |
|
| 73 | + '67' => 'Removing locks', |
|
| 74 | + '68' => 'Viewing site logging', |
|
| 75 | + '69' => 'Viewing online visitors', |
|
| 76 | + '70' => 'Viewing site schedule', |
|
| 77 | + '71' => 'Searching', |
|
| 78 | + '72' => 'Adding a weblink', |
|
| 79 | + '73' => 'Editing a weblink', |
|
| 80 | + //case "74" : return "Changing personal preferences"; break; |
|
| 81 | + '75' => 'User/ role management', |
|
| 82 | + '76' => 'Element management', |
|
| 83 | + '77' => 'Creating a new Chunk (HTML Snippet)', |
|
| 84 | + '78' => 'Editing Chunk (HTML Snippet)', |
|
| 85 | + '79' => 'Saving Chunk (HTML Snippet)', |
|
| 86 | + '80' => 'Deleting Chunk (HTML Snippet)', |
|
| 87 | + '83' => 'Exporting a resource to HTML', |
|
| 88 | + '84' => 'Load Element Selector', |
|
| 89 | + '85' => 'Create Folder', |
|
| 90 | + '86' => 'Role management', |
|
| 91 | + '87' => 'Create new web user', |
|
| 92 | + '88' => 'Editing web user', |
|
| 93 | + '89' => 'Saving web user', |
|
| 94 | + '90' => 'Deleting web user', |
|
| 95 | + '91' => 'Editing Web Access Permissions', |
|
| 96 | + '92' => 'Editing Access Permissions', |
|
| 97 | + '93' => 'Backup Manager', |
|
| 98 | + '94' => 'Duplicate resource', |
|
| 99 | + '95' => 'Importing resources from HTML', |
|
| 100 | + '96' => 'Duplicate Template', |
|
| 101 | + '97' => 'Duplicate Chunk (HTML Snippet)', |
|
| 102 | + '98' => 'Duplicate Snippet', |
|
| 103 | + '99' => 'Manage Web Users', |
|
| 104 | + '100' => 'Previewing resource', |
|
| 105 | + '101' => 'Create new plugin', |
|
| 106 | + '102' => 'Edit plugin', |
|
| 107 | + '103' => 'Saving plugin', |
|
| 108 | + '104' => 'Delete plugin', |
|
| 109 | + '105' => 'Duplicate plugin', |
|
| 110 | + '106' => 'Viewing Modules', |
|
| 111 | + '107' => 'Create new module', |
|
| 112 | + '108' => 'Edit module', |
|
| 113 | + '109' => 'Saving module', |
|
| 114 | + '110' => 'Delete module', |
|
| 115 | + '111' => 'Duplicate module', |
|
| 116 | + '112' => 'Execute module', |
|
| 117 | + '113' => 'Manage module dependencies', |
|
| 118 | + '114' => 'View event log', |
|
| 119 | + '115' => 'View event log details', |
|
| 120 | + '116' => 'Delete event log', |
|
| 121 | + '117' => 'Editing tv rank', |
|
| 122 | + '118' => 'Call settings ajax include', |
|
| 123 | + '119' => 'Login Fail (Temporary Block)', |
|
| 124 | 124 | |
| 125 | - '300' => 'Create Template Variable', |
|
| 126 | - '301' => 'Edit Template Variable', |
|
| 127 | - '302' => 'Save Template Variable', |
|
| 128 | - '303' => 'Delete Template Variable', |
|
| 129 | - '304' => 'Duplicate Template Variable', |
|
| 125 | + '300' => 'Create Template Variable', |
|
| 126 | + '301' => 'Edit Template Variable', |
|
| 127 | + '302' => 'Save Template Variable', |
|
| 128 | + '303' => 'Delete Template Variable', |
|
| 129 | + '304' => 'Duplicate Template Variable', |
|
| 130 | 130 | |
| 131 | - '200' => 'Viewing phpInfo()', |
|
| 132 | - '501' => 'Delete category', |
|
| 133 | - '998' => 'Viewing web page', |
|
| 134 | - '999' => 'Viewing test page', |
|
| 131 | + '200' => 'Viewing phpInfo()', |
|
| 132 | + '501' => 'Delete category', |
|
| 133 | + '998' => 'Viewing web page', |
|
| 134 | + '999' => 'Viewing test page', |
|
| 135 | 135 | ); |
| 136 | 136 | |
| 137 | 137 | /** |
@@ -140,10 +140,10 @@ discard block |
||
| 140 | 140 | * @return string |
| 141 | 141 | */ |
| 142 | 142 | function getAction($actionId, $itemid='') { |
| 143 | - global $action_list; |
|
| 143 | + global $action_list; |
|
| 144 | 144 | |
| 145 | - $ret = sprintf($action_list[$actionId], $itemid); |
|
| 146 | - if (!$ret) $ret = "Idle (unknown)"; |
|
| 145 | + $ret = sprintf($action_list[$actionId], $itemid); |
|
| 146 | + if (!$ret) $ret = "Idle (unknown)"; |
|
| 147 | 147 | |
| 148 | - return $ret; |
|
| 148 | + return $ret; |
|
| 149 | 149 | } |
@@ -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 | |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | * @param string $itemid |
| 140 | 140 | * @return string |
| 141 | 141 | */ |
| 142 | -function getAction($actionId, $itemid='') { |
|
| 142 | +function getAction($actionId, $itemid = ''){ |
|
| 143 | 143 | global $action_list; |
| 144 | 144 | |
| 145 | 145 | $ret = sprintf($action_list[$actionId], $itemid); |
@@ -139,11 +139,14 @@ |
||
| 139 | 139 | * @param string $itemid |
| 140 | 140 | * @return string |
| 141 | 141 | */ |
| 142 | -function getAction($actionId, $itemid='') { |
|
| 142 | +function getAction($actionId, $itemid='') |
|
| 143 | +{ |
|
| 143 | 144 | global $action_list; |
| 144 | 145 | |
| 145 | 146 | $ret = sprintf($action_list[$actionId], $itemid); |
| 146 | - if (!$ret) $ret = "Idle (unknown)"; |
|
| 147 | + if (!$ret) { |
|
| 148 | + $ret = "Idle (unknown)"; |
|
| 149 | + } |
|
| 147 | 150 | |
| 148 | 151 | return $ret; |
| 149 | 152 | } |
@@ -11,12 +11,12 @@ |
||
| 11 | 11 | |
| 12 | 12 | $out = false; |
| 13 | 13 | $class = 'DBAPI'; |
| 14 | -if( ! class_exists($class)){ |
|
| 15 | - include_once MODX_MANAGER_PATH . 'includes/extenders/dbapi.' . $database_type . '.class.inc.php'; |
|
| 14 | +if (!class_exists($class)) { |
|
| 15 | + include_once MODX_MANAGER_PATH.'includes/extenders/dbapi.'.$database_type.'.class.inc.php'; |
|
| 16 | 16 | } |
| 17 | 17 | |
| 18 | -if(class_exists($class)){ |
|
| 19 | - $this->db= new $class; |
|
| 18 | +if (class_exists($class)) { |
|
| 19 | + $this->db = new $class; |
|
| 20 | 20 | $out = true; |
| 21 | 21 | } |
| 22 | 22 | |
@@ -7,15 +7,17 @@ |
||
| 7 | 7 | |
| 8 | 8 | global $database_type; |
| 9 | 9 | |
| 10 | -if (empty($database_type)) $database_type = 'mysql'; |
|
| 10 | +if (empty($database_type)) { |
|
| 11 | + $database_type = 'mysql'; |
|
| 12 | +} |
|
| 11 | 13 | |
| 12 | 14 | $out = false; |
| 13 | 15 | $class = 'DBAPI'; |
| 14 | -if( ! class_exists($class)){ |
|
| 16 | +if( ! class_exists($class)) { |
|
| 15 | 17 | include_once MODX_MANAGER_PATH . 'includes/extenders/dbapi.' . $database_type . '.class.inc.php'; |
| 16 | 18 | } |
| 17 | 19 | |
| 18 | -if(class_exists($class)){ |
|
| 20 | +if(class_exists($class)) { |
|
| 19 | 21 | $this->db= new $class; |
| 20 | 22 | $out = true; |
| 21 | 23 | } |
@@ -373,7 +373,8 @@ discard block |
||
| 373 | 373 | * @return bool|mixed|mysqli_result |
| 374 | 374 | */ |
| 375 | 375 | public function save($fields, $table, $where = '') |
| 376 | - { // This is similar to "replace into table". |
|
| 376 | + { |
|
| 377 | +// This is similar to "replace into table". |
|
| 377 | 378 | |
| 378 | 379 | if ($where === '') { |
| 379 | 380 | $mode = 'insert'; |
@@ -490,7 +491,7 @@ discard block |
||
| 490 | 491 | { |
| 491 | 492 | $out = false; |
| 492 | 493 | if ($ds instanceof mysqli_result) { |
| 493 | - switch($mode){ |
|
| 494 | + switch($mode) { |
|
| 494 | 495 | case 'assoc': |
| 495 | 496 | $out = $ds->fetch_assoc(); |
| 496 | 497 | break; |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | $pre = null, |
| 31 | 31 | $charset = '', |
| 32 | 32 | $connection_method = 'SET CHARACTER SET' |
| 33 | - ) { |
|
| 33 | + ){ |
|
| 34 | 34 | $this->config['host'] = $host ? $host : $GLOBALS['database_server']; |
| 35 | 35 | $this->config['dbase'] = $dbase ? $dbase : $GLOBALS['dbase']; |
| 36 | 36 | $this->config['user'] = $uid ? $uid : $GLOBALS['database_user']; |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | $ua = $modx->htmlspecialchars($_SERVER['HTTP_USER_AGENT']); |
| 71 | 71 | $referer = $modx->htmlspecialchars($_SERVER['HTTP_REFERER']); |
| 72 | 72 | $modx->sendmail(array( |
| 73 | - 'subject' => 'Missing to create the database connection! from ' . $modx->config['site_name'], |
|
| 73 | + 'subject' => 'Missing to create the database connection! from '.$modx->config['site_name'], |
|
| 74 | 74 | 'body' => "{$logtitle}\n{$request_uri}\n{$ua}\n{$referer}", |
| 75 | 75 | 'type' => 'text' |
| 76 | 76 | )); |
@@ -85,8 +85,8 @@ discard block |
||
| 85 | 85 | $tend = $modx->getMicroTime(); |
| 86 | 86 | $totaltime = $tend - $tstart; |
| 87 | 87 | if ($modx->dumpSQL) { |
| 88 | - $modx->queryCode .= "<fieldset style='text-align:left'><legend>Database connection</legend>" . sprintf("Database connection was created in %2.4f s", |
|
| 89 | - $totaltime) . "</fieldset><br />"; |
|
| 88 | + $modx->queryCode .= "<fieldset style='text-align:left'><legend>Database connection</legend>".sprintf("Database connection was created in %2.4f s", |
|
| 89 | + $totaltime)."</fieldset><br />"; |
|
| 90 | 90 | } |
| 91 | 91 | $this->conn->set_charset($this->config['charset']); |
| 92 | 92 | $this->isConnected = true; |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | if (1000 < $safeCount) { |
| 120 | 120 | exit("Too many loops '{$safeCount}'"); |
| 121 | 121 | } |
| 122 | - if ( ! ($this->conn instanceof mysqli)) { |
|
| 122 | + if (!($this->conn instanceof mysqli)) { |
|
| 123 | 123 | $this->connect(); |
| 124 | 124 | } |
| 125 | 125 | if (is_array($s)) { |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | public function query($sql, $watchError = true) |
| 146 | 146 | { |
| 147 | 147 | $modx = evolutionCMS(); |
| 148 | - if ( ! ($this->conn instanceof mysqli)) { |
|
| 148 | + if (!($this->conn instanceof mysqli)) { |
|
| 149 | 149 | $this->connect(); |
| 150 | 150 | } |
| 151 | 151 | $tStart = $modx->getMicroTime(); |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | case 1091: |
| 166 | 166 | break; |
| 167 | 167 | default: |
| 168 | - $modx->messageQuit('Execution of a query to the database failed - ' . $this->getLastError(), $sql); |
|
| 168 | + $modx->messageQuit('Execution of a query to the database failed - '.$this->getLastError(), $sql); |
|
| 169 | 169 | } |
| 170 | 170 | } else { |
| 171 | 171 | $tend = $modx->getMicroTime(); |
@@ -179,24 +179,24 @@ discard block |
||
| 179 | 179 | $debug_path[] = $line['function']; |
| 180 | 180 | } |
| 181 | 181 | $debug_path = implode(' > ', array_reverse($debug_path)); |
| 182 | - $modx->queryCode .= "<fieldset style='text-align:left'><legend>Query " . ($modx->executedQueries + 1) . " - " . sprintf("%2.2f ms", |
|
| 183 | - $totalTime * 1000) . "</legend>"; |
|
| 184 | - $modx->queryCode .= $sql . '<br><br>'; |
|
| 182 | + $modx->queryCode .= "<fieldset style='text-align:left'><legend>Query ".($modx->executedQueries + 1)." - ".sprintf("%2.2f ms", |
|
| 183 | + $totalTime * 1000)."</legend>"; |
|
| 184 | + $modx->queryCode .= $sql.'<br><br>'; |
|
| 185 | 185 | if ($modx->event->name) { |
| 186 | - $modx->queryCode .= 'Current Event => ' . $modx->event->name . '<br>'; |
|
| 186 | + $modx->queryCode .= 'Current Event => '.$modx->event->name.'<br>'; |
|
| 187 | 187 | } |
| 188 | 188 | if ($modx->event->activePlugin) { |
| 189 | - $modx->queryCode .= 'Current Plugin => ' . $modx->event->activePlugin . '<br>'; |
|
| 189 | + $modx->queryCode .= 'Current Plugin => '.$modx->event->activePlugin.'<br>'; |
|
| 190 | 190 | } |
| 191 | 191 | if ($modx->currentSnippet) { |
| 192 | - $modx->queryCode .= 'Current Snippet => ' . $modx->currentSnippet . '<br>'; |
|
| 192 | + $modx->queryCode .= 'Current Snippet => '.$modx->currentSnippet.'<br>'; |
|
| 193 | 193 | } |
| 194 | 194 | if (stripos($sql, 'select') === 0) { |
| 195 | - $modx->queryCode .= 'Record Count => ' . $this->getRecordCount($result) . '<br>'; |
|
| 195 | + $modx->queryCode .= 'Record Count => '.$this->getRecordCount($result).'<br>'; |
|
| 196 | 196 | } else { |
| 197 | - $modx->queryCode .= 'Affected Rows => ' . $this->getAffectedRows() . '<br>'; |
|
| 197 | + $modx->queryCode .= 'Affected Rows => '.$this->getAffectedRows().'<br>'; |
|
| 198 | 198 | } |
| 199 | - $modx->queryCode .= 'Functions Path => ' . $debug_path . '<br>'; |
|
| 199 | + $modx->queryCode .= 'Functions Path => '.$debug_path.'<br>'; |
|
| 200 | 200 | $modx->queryCode .= "</fieldset><br />"; |
| 201 | 201 | } |
| 202 | 202 | $modx->executedQueries++; |
@@ -303,9 +303,9 @@ discard block |
||
| 303 | 303 | if ($value === null || strtolower($value) === 'null') { |
| 304 | 304 | $f = 'NULL'; |
| 305 | 305 | } else { |
| 306 | - $f = "'" . $value . "'"; |
|
| 306 | + $f = "'".$value."'"; |
|
| 307 | 307 | } |
| 308 | - $fields[$key] = "`{$key}` = " . $f; |
|
| 308 | + $fields[$key] = "`{$key}` = ".$f; |
|
| 309 | 309 | } |
| 310 | 310 | $fields = implode(',', $fields); |
| 311 | 311 | } |
@@ -340,12 +340,12 @@ discard block |
||
| 340 | 340 | $this->query("INSERT INTO {$intotable} {$fields}"); |
| 341 | 341 | } else { |
| 342 | 342 | if (empty($fromtable)) { |
| 343 | - $fields = "(`" . implode("`, `", array_keys($fields)) . "`) VALUES('" . implode("', '", |
|
| 344 | - array_values($fields)) . "')"; |
|
| 343 | + $fields = "(`".implode("`, `", array_keys($fields))."`) VALUES('".implode("', '", |
|
| 344 | + array_values($fields))."')"; |
|
| 345 | 345 | $this->query("INSERT INTO {$intotable} {$fields}"); |
| 346 | 346 | } else { |
| 347 | 347 | $fromtable = $this->replaceFullTableName($fromtable); |
| 348 | - $fields = "(" . implode(",", array_keys($fields)) . ")"; |
|
| 348 | + $fields = "(".implode(",", array_keys($fields)).")"; |
|
| 349 | 349 | $where = trim($where); |
| 350 | 350 | $limit = trim($limit); |
| 351 | 351 | if ($where !== '' && stripos($where, 'WHERE') !== 0) { |
@@ -439,8 +439,8 @@ discard block |
||
| 439 | 439 | */ |
| 440 | 440 | public function getInsertId($conn = null) |
| 441 | 441 | { |
| 442 | - if (! ($conn instanceof mysqli)) { |
|
| 443 | - $conn =& $this->conn; |
|
| 442 | + if (!($conn instanceof mysqli)) { |
|
| 443 | + $conn = & $this->conn; |
|
| 444 | 444 | } |
| 445 | 445 | |
| 446 | 446 | return $conn->insert_id; |
@@ -452,8 +452,8 @@ discard block |
||
| 452 | 452 | */ |
| 453 | 453 | public function getAffectedRows($conn = null) |
| 454 | 454 | { |
| 455 | - if (! ($conn instanceof mysqli)) { |
|
| 456 | - $conn =& $this->conn; |
|
| 455 | + if (!($conn instanceof mysqli)) { |
|
| 456 | + $conn = & $this->conn; |
|
| 457 | 457 | } |
| 458 | 458 | |
| 459 | 459 | return $conn->affected_rows; |
@@ -465,8 +465,8 @@ discard block |
||
| 465 | 465 | */ |
| 466 | 466 | public function getLastError($conn = null) |
| 467 | 467 | { |
| 468 | - if (! ($conn instanceof mysqli)) { |
|
| 469 | - $conn =& $this->conn; |
|
| 468 | + if (!($conn instanceof mysqli)) { |
|
| 469 | + $conn = & $this->conn; |
|
| 470 | 470 | } |
| 471 | 471 | |
| 472 | 472 | return $conn->error; |
@@ -490,7 +490,7 @@ discard block |
||
| 490 | 490 | { |
| 491 | 491 | $out = false; |
| 492 | 492 | if ($ds instanceof mysqli_result) { |
| 493 | - switch($mode){ |
|
| 493 | + switch ($mode) { |
|
| 494 | 494 | case 'assoc': |
| 495 | 495 | $out = $ds->fetch_assoc(); |
| 496 | 496 | break; |
@@ -520,7 +520,7 @@ discard block |
||
| 520 | 520 | public function getColumn($name, $dsq) |
| 521 | 521 | { |
| 522 | 522 | $col = array(); |
| 523 | - if ( ! ($dsq instanceof mysqli_result)) { |
|
| 523 | + if (!($dsq instanceof mysqli_result)) { |
|
| 524 | 524 | $dsq = $this->query($dsq); |
| 525 | 525 | } |
| 526 | 526 | if ($dsq) { |
@@ -539,7 +539,7 @@ discard block |
||
| 539 | 539 | public function getColumnNames($dsq) |
| 540 | 540 | { |
| 541 | 541 | $names = array(); |
| 542 | - if ( ! ($dsq instanceof mysqli_result)) { |
|
| 542 | + if (!($dsq instanceof mysqli_result)) { |
|
| 543 | 543 | $dsq = $this->query($dsq); |
| 544 | 544 | } |
| 545 | 545 | if ($dsq) { |
@@ -559,7 +559,7 @@ discard block |
||
| 559 | 559 | public function getValue($dsq) |
| 560 | 560 | { |
| 561 | 561 | $out = false; |
| 562 | - if ( ! ($dsq instanceof mysqli_result)) { |
|
| 562 | + if (!($dsq instanceof mysqli_result)) { |
|
| 563 | 563 | $dsq = $this->query($dsq); |
| 564 | 564 | } |
| 565 | 565 | if ($dsq) { |
@@ -657,7 +657,7 @@ discard block |
||
| 657 | 657 | $tableName = trim($tableName); |
| 658 | 658 | $dbase = trim($this->config['dbase'], '`'); |
| 659 | 659 | $prefix = $this->config['table_prefix']; |
| 660 | - if ((bool)$force === true) { |
|
| 660 | + if ((bool) $force === true) { |
|
| 661 | 661 | $result = "`{$dbase}`.`{$prefix}{$tableName}`"; |
| 662 | 662 | } elseif (strpos($tableName, '[+prefix+]') !== false) { |
| 663 | 663 | $result = preg_replace('@\[\+prefix\+\]([0-9a-zA-Z_]+)@', "`{$dbase}`.`{$prefix}$1`", $tableName); |
@@ -69,110 +69,110 @@ discard block |
||
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | switch($input['mode']) { |
| 72 | - case '11' : // new user |
|
| 73 | - // check if this user name already exist |
|
| 74 | - $rs = $modx->db->select('count(id)', $tbl_manager_users, sprintf("username='%s'", $modx->db->escape($newusername))); |
|
| 75 | - $limit = $modx->db->getValue($rs); |
|
| 76 | - if($limit > 0) { |
|
| 77 | - webAlertAndQuit("User name is already in use!"); |
|
| 78 | - } |
|
| 79 | - |
|
| 80 | - // check if the email address already exist |
|
| 81 | - $rs = $modx->db->select('count(internalKey)', $tbl_user_attributes, sprintf("email='%s' AND id!='%s'", $modx->db->escape($email), $id)); |
|
| 82 | - $limit = $modx->db->getValue($rs); |
|
| 83 | - if($limit > 0) { |
|
| 84 | - webAlertAndQuit("Email is already in use!"); |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - // generate a new password for this user |
|
| 88 | - if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
| 89 | - if(strlen($specifiedpassword) < 6) { |
|
| 90 | - webAlertAndQuit("Password is too short!"); |
|
| 91 | - } else { |
|
| 92 | - $newpassword = $specifiedpassword; |
|
| 93 | - } |
|
| 94 | - } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
| 95 | - webAlertAndQuit("You didn't specify a password for this user!"); |
|
| 96 | - } elseif($passwordgenmethod == 'g') { |
|
| 97 | - $newpassword = generate_password(8); |
|
| 98 | - } else { |
|
| 99 | - webAlertAndQuit("No password generation method specified!"); |
|
| 100 | - } |
|
| 101 | - |
|
| 102 | - // invoke OnBeforeUserFormSave event |
|
| 103 | - $modx->invokeEvent("OnBeforeUserFormSave", array( |
|
| 104 | - "mode" => "new", |
|
| 105 | - )); |
|
| 106 | - |
|
| 107 | - // create the user account |
|
| 108 | - $internalKey = $modx->db->insert(array('username' => $modx->db->escape($newusername)), $tbl_manager_users); |
|
| 109 | - |
|
| 110 | - $field = array(); |
|
| 111 | - $field['password'] = $modx->phpass->HashPassword($newpassword); |
|
| 112 | - $modx->db->update($field, $tbl_manager_users, "id='{$internalKey}'"); |
|
| 113 | - |
|
| 114 | - $field = compact('internalKey', 'fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'blocked', 'blockeduntil', 'blockedafter'); |
|
| 115 | - $field = $modx->db->escape($field); |
|
| 116 | - $modx->db->insert($field, $tbl_user_attributes); |
|
| 117 | - |
|
| 118 | - // Save user settings |
|
| 119 | - saveUserSettings($internalKey); |
|
| 120 | - |
|
| 121 | - // invoke OnManagerSaveUser event |
|
| 122 | - $modx->invokeEvent("OnManagerSaveUser", array( |
|
| 123 | - "mode" => "new", |
|
| 124 | - "userid" => $internalKey, |
|
| 125 | - "username" => $newusername, |
|
| 126 | - "userpassword" => $newpassword, |
|
| 127 | - "useremail" => $email, |
|
| 128 | - "userfullname" => $fullname, |
|
| 129 | - "userroleid" => $role |
|
| 130 | - )); |
|
| 131 | - |
|
| 132 | - // invoke OnUserFormSave event |
|
| 133 | - $modx->invokeEvent("OnUserFormSave", array( |
|
| 134 | - "mode" => "new", |
|
| 135 | - "id" => $internalKey |
|
| 136 | - )); |
|
| 137 | - |
|
| 138 | - // Set the item name for logger |
|
| 139 | - $_SESSION['itemname'] = $newusername; |
|
| 140 | - |
|
| 141 | - /*******************************************************************************/ |
|
| 142 | - // put the user in the user_groups he/ she should be in |
|
| 143 | - // first, check that up_perms are switched on! |
|
| 144 | - if($use_udperms == 1) { |
|
| 145 | - if(!empty($user_groups)) { |
|
| 146 | - for($i = 0; $i < count($user_groups); $i++) { |
|
| 147 | - $f = array(); |
|
| 148 | - $f['user_group'] = (int)$user_groups[$i]; |
|
| 149 | - $f['member'] = $internalKey; |
|
| 150 | - $modx->db->insert($f, $tbl_member_groups); |
|
| 151 | - } |
|
| 152 | - } |
|
| 153 | - } |
|
| 154 | - // end of user_groups stuff! |
|
| 155 | - |
|
| 156 | - if($passwordnotifymethod == 'e') { |
|
| 157 | - sendMailMessage($email, $newusername, $newpassword, $fullname); |
|
| 158 | - if($input['stay'] != '') { |
|
| 159 | - $a = ($input['stay'] == '2') ? "12&id={$internalKey}" : "11"; |
|
| 160 | - $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 161 | - header($header); |
|
| 162 | - } else { |
|
| 163 | - $header = "Location: index.php?a=75&r=2"; |
|
| 164 | - header($header); |
|
| 165 | - } |
|
| 166 | - } else { |
|
| 167 | - if($input['stay'] != '') { |
|
| 168 | - $a = ($input['stay'] == '2') ? "12&id={$internalKey}" : "11"; |
|
| 169 | - $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 170 | - } else { |
|
| 171 | - $stayUrl = "index.php?a=75&r=2"; |
|
| 172 | - } |
|
| 173 | - |
|
| 174 | - include_once "header.inc.php"; |
|
| 175 | - ?> |
|
| 72 | + case '11' : // new user |
|
| 73 | + // check if this user name already exist |
|
| 74 | + $rs = $modx->db->select('count(id)', $tbl_manager_users, sprintf("username='%s'", $modx->db->escape($newusername))); |
|
| 75 | + $limit = $modx->db->getValue($rs); |
|
| 76 | + if($limit > 0) { |
|
| 77 | + webAlertAndQuit("User name is already in use!"); |
|
| 78 | + } |
|
| 79 | + |
|
| 80 | + // check if the email address already exist |
|
| 81 | + $rs = $modx->db->select('count(internalKey)', $tbl_user_attributes, sprintf("email='%s' AND id!='%s'", $modx->db->escape($email), $id)); |
|
| 82 | + $limit = $modx->db->getValue($rs); |
|
| 83 | + if($limit > 0) { |
|
| 84 | + webAlertAndQuit("Email is already in use!"); |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + // generate a new password for this user |
|
| 88 | + if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
| 89 | + if(strlen($specifiedpassword) < 6) { |
|
| 90 | + webAlertAndQuit("Password is too short!"); |
|
| 91 | + } else { |
|
| 92 | + $newpassword = $specifiedpassword; |
|
| 93 | + } |
|
| 94 | + } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
| 95 | + webAlertAndQuit("You didn't specify a password for this user!"); |
|
| 96 | + } elseif($passwordgenmethod == 'g') { |
|
| 97 | + $newpassword = generate_password(8); |
|
| 98 | + } else { |
|
| 99 | + webAlertAndQuit("No password generation method specified!"); |
|
| 100 | + } |
|
| 101 | + |
|
| 102 | + // invoke OnBeforeUserFormSave event |
|
| 103 | + $modx->invokeEvent("OnBeforeUserFormSave", array( |
|
| 104 | + "mode" => "new", |
|
| 105 | + )); |
|
| 106 | + |
|
| 107 | + // create the user account |
|
| 108 | + $internalKey = $modx->db->insert(array('username' => $modx->db->escape($newusername)), $tbl_manager_users); |
|
| 109 | + |
|
| 110 | + $field = array(); |
|
| 111 | + $field['password'] = $modx->phpass->HashPassword($newpassword); |
|
| 112 | + $modx->db->update($field, $tbl_manager_users, "id='{$internalKey}'"); |
|
| 113 | + |
|
| 114 | + $field = compact('internalKey', 'fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'blocked', 'blockeduntil', 'blockedafter'); |
|
| 115 | + $field = $modx->db->escape($field); |
|
| 116 | + $modx->db->insert($field, $tbl_user_attributes); |
|
| 117 | + |
|
| 118 | + // Save user settings |
|
| 119 | + saveUserSettings($internalKey); |
|
| 120 | + |
|
| 121 | + // invoke OnManagerSaveUser event |
|
| 122 | + $modx->invokeEvent("OnManagerSaveUser", array( |
|
| 123 | + "mode" => "new", |
|
| 124 | + "userid" => $internalKey, |
|
| 125 | + "username" => $newusername, |
|
| 126 | + "userpassword" => $newpassword, |
|
| 127 | + "useremail" => $email, |
|
| 128 | + "userfullname" => $fullname, |
|
| 129 | + "userroleid" => $role |
|
| 130 | + )); |
|
| 131 | + |
|
| 132 | + // invoke OnUserFormSave event |
|
| 133 | + $modx->invokeEvent("OnUserFormSave", array( |
|
| 134 | + "mode" => "new", |
|
| 135 | + "id" => $internalKey |
|
| 136 | + )); |
|
| 137 | + |
|
| 138 | + // Set the item name for logger |
|
| 139 | + $_SESSION['itemname'] = $newusername; |
|
| 140 | + |
|
| 141 | + /*******************************************************************************/ |
|
| 142 | + // put the user in the user_groups he/ she should be in |
|
| 143 | + // first, check that up_perms are switched on! |
|
| 144 | + if($use_udperms == 1) { |
|
| 145 | + if(!empty($user_groups)) { |
|
| 146 | + for($i = 0; $i < count($user_groups); $i++) { |
|
| 147 | + $f = array(); |
|
| 148 | + $f['user_group'] = (int)$user_groups[$i]; |
|
| 149 | + $f['member'] = $internalKey; |
|
| 150 | + $modx->db->insert($f, $tbl_member_groups); |
|
| 151 | + } |
|
| 152 | + } |
|
| 153 | + } |
|
| 154 | + // end of user_groups stuff! |
|
| 155 | + |
|
| 156 | + if($passwordnotifymethod == 'e') { |
|
| 157 | + sendMailMessage($email, $newusername, $newpassword, $fullname); |
|
| 158 | + if($input['stay'] != '') { |
|
| 159 | + $a = ($input['stay'] == '2') ? "12&id={$internalKey}" : "11"; |
|
| 160 | + $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 161 | + header($header); |
|
| 162 | + } else { |
|
| 163 | + $header = "Location: index.php?a=75&r=2"; |
|
| 164 | + header($header); |
|
| 165 | + } |
|
| 166 | + } else { |
|
| 167 | + if($input['stay'] != '') { |
|
| 168 | + $a = ($input['stay'] == '2') ? "12&id={$internalKey}" : "11"; |
|
| 169 | + $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 170 | + } else { |
|
| 171 | + $stayUrl = "index.php?a=75&r=2"; |
|
| 172 | + } |
|
| 173 | + |
|
| 174 | + include_once "header.inc.php"; |
|
| 175 | + ?> |
|
| 176 | 176 | |
| 177 | 177 | <h1><?php echo $_lang['user_title']; ?></h1> |
| 178 | 178 | |
@@ -194,125 +194,125 @@ discard block |
||
| 194 | 194 | </div> |
| 195 | 195 | <?php |
| 196 | 196 | |
| 197 | - include_once "footer.inc.php"; |
|
| 198 | - } |
|
| 199 | - break; |
|
| 200 | - case '12' : // edit user |
|
| 201 | - // generate a new password for this user |
|
| 202 | - if($genpassword == 1) { |
|
| 203 | - if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
| 204 | - if(strlen($specifiedpassword) < 6) { |
|
| 205 | - webAlertAndQuit("Password is too short!"); |
|
| 206 | - } else { |
|
| 207 | - $newpassword = $specifiedpassword; |
|
| 208 | - } |
|
| 209 | - } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
| 210 | - webAlertAndQuit("You didn't specify a password for this user!"); |
|
| 211 | - } elseif($passwordgenmethod == 'g') { |
|
| 212 | - $newpassword = generate_password(8); |
|
| 213 | - } else { |
|
| 214 | - webAlertAndQuit("No password generation method specified!"); |
|
| 215 | - } |
|
| 216 | - } |
|
| 217 | - if($passwordnotifymethod == 'e') { |
|
| 218 | - sendMailMessage($email, $newusername, $newpassword, $fullname); |
|
| 219 | - } |
|
| 220 | - |
|
| 221 | - // check if the username already exist |
|
| 222 | - $rs = $modx->db->select('count(id)', $tbl_manager_users, sprintf("username='%s' AND id!='%s'", $modx->db->escape($newusername), $id)); |
|
| 223 | - $limit = $modx->db->getValue($rs); |
|
| 224 | - if($limit > 0) { |
|
| 225 | - webAlertAndQuit("User name is already in use!"); |
|
| 226 | - } |
|
| 227 | - |
|
| 228 | - // check if the email address already exists |
|
| 229 | - $rs = $modx->db->select('count(internalKey)', $tbl_user_attributes, sprintf("email='%s' AND internalKey!='%s'", $modx->db->escape($email), $id)); |
|
| 230 | - $limit = $modx->db->getValue($rs); |
|
| 231 | - if($limit > 0) { |
|
| 232 | - webAlertAndQuit("Email is already in use!"); |
|
| 233 | - } |
|
| 234 | - |
|
| 235 | - // invoke OnBeforeUserFormSave event |
|
| 236 | - $modx->invokeEvent("OnBeforeUserFormSave", array( |
|
| 237 | - "mode" => "upd", |
|
| 238 | - "id" => $id |
|
| 239 | - )); |
|
| 240 | - |
|
| 241 | - // update user name and password |
|
| 242 | - $field = array(); |
|
| 243 | - $field['username'] = $modx->db->escape($newusername); |
|
| 244 | - if($genpassword == 1) { |
|
| 245 | - $field['password'] = $modx->phpass->HashPassword($newpassword); |
|
| 246 | - } |
|
| 247 | - $modx->db->update($field, $tbl_manager_users, "id='{$id}'"); |
|
| 248 | - $field = compact('fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'failedlogincount', 'blocked', 'blockeduntil', 'blockedafter'); |
|
| 249 | - $field = $modx->db->escape($field); |
|
| 250 | - $modx->db->update($field, $tbl_user_attributes, "internalKey='{$id}'"); |
|
| 251 | - |
|
| 252 | - // Save user settings |
|
| 253 | - saveUserSettings($id); |
|
| 254 | - |
|
| 255 | - // Set the item name for logger |
|
| 256 | - $_SESSION['itemname'] = $newusername; |
|
| 257 | - |
|
| 258 | - // invoke OnManagerSaveUser event |
|
| 259 | - $modx->invokeEvent("OnManagerSaveUser", array( |
|
| 260 | - "mode" => "upd", |
|
| 261 | - "userid" => $id, |
|
| 262 | - "username" => $newusername, |
|
| 263 | - "userpassword" => $newpassword, |
|
| 264 | - "useremail" => $email, |
|
| 265 | - "userfullname" => $fullname, |
|
| 266 | - "userroleid" => $role, |
|
| 267 | - "oldusername" => (($oldusername != $newusername) ? $oldusername : ""), |
|
| 268 | - "olduseremail" => (($oldemail != $email) ? $oldemail : "") |
|
| 269 | - )); |
|
| 270 | - |
|
| 271 | - // invoke OnManagerChangePassword event |
|
| 272 | - if($genpassword == 1) { |
|
| 273 | - $modx->invokeEvent("OnManagerChangePassword", array( |
|
| 274 | - "userid" => $id, |
|
| 275 | - "username" => $newusername, |
|
| 276 | - "userpassword" => $newpassword |
|
| 277 | - )); |
|
| 278 | - } |
|
| 279 | - |
|
| 280 | - // invoke OnUserFormSave event |
|
| 281 | - $modx->invokeEvent("OnUserFormSave", array( |
|
| 282 | - "mode" => "upd", |
|
| 283 | - "id" => $id |
|
| 284 | - )); |
|
| 285 | - |
|
| 286 | - /*******************************************************************************/ |
|
| 287 | - // put the user in the user_groups he/ she should be in |
|
| 288 | - // first, check that up_perms are switched on! |
|
| 289 | - if($use_udperms == 1) { |
|
| 290 | - // as this is an existing user, delete his/ her entries in the groups before saving the new groups |
|
| 291 | - $modx->db->delete($tbl_member_groups, "member='{$id}'"); |
|
| 292 | - if(!empty($user_groups)) { |
|
| 293 | - for($i = 0; $i < count($user_groups); $i++) { |
|
| 294 | - $field = array(); |
|
| 295 | - $field['user_group'] = (int)$user_groups[$i]; |
|
| 296 | - $field['member'] = $id; |
|
| 297 | - $modx->db->insert($field, $tbl_member_groups); |
|
| 298 | - } |
|
| 299 | - } |
|
| 300 | - } |
|
| 301 | - // end of user_groups stuff! |
|
| 302 | - /*******************************************************************************/ |
|
| 303 | - if($id == $modx->getLoginUserID() && ($genpassword !== 1 && $passwordnotifymethod != 's')) { |
|
| 304 | - $modx->webAlertAndQuit($_lang["user_changeddata"], 'javascript:top.location.href="index.php?a=8";'); |
|
| 305 | - } |
|
| 306 | - if($genpassword == 1 && $passwordnotifymethod == 's') { |
|
| 307 | - if($input['stay'] != '') { |
|
| 308 | - $a = ($input['stay'] == '2') ? "12&id={$id}" : "11"; |
|
| 309 | - $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 310 | - } else { |
|
| 311 | - $stayUrl = "index.php?a=75&r=2"; |
|
| 312 | - } |
|
| 313 | - |
|
| 314 | - include_once "header.inc.php"; |
|
| 315 | - ?> |
|
| 197 | + include_once "footer.inc.php"; |
|
| 198 | + } |
|
| 199 | + break; |
|
| 200 | + case '12' : // edit user |
|
| 201 | + // generate a new password for this user |
|
| 202 | + if($genpassword == 1) { |
|
| 203 | + if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
| 204 | + if(strlen($specifiedpassword) < 6) { |
|
| 205 | + webAlertAndQuit("Password is too short!"); |
|
| 206 | + } else { |
|
| 207 | + $newpassword = $specifiedpassword; |
|
| 208 | + } |
|
| 209 | + } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
| 210 | + webAlertAndQuit("You didn't specify a password for this user!"); |
|
| 211 | + } elseif($passwordgenmethod == 'g') { |
|
| 212 | + $newpassword = generate_password(8); |
|
| 213 | + } else { |
|
| 214 | + webAlertAndQuit("No password generation method specified!"); |
|
| 215 | + } |
|
| 216 | + } |
|
| 217 | + if($passwordnotifymethod == 'e') { |
|
| 218 | + sendMailMessage($email, $newusername, $newpassword, $fullname); |
|
| 219 | + } |
|
| 220 | + |
|
| 221 | + // check if the username already exist |
|
| 222 | + $rs = $modx->db->select('count(id)', $tbl_manager_users, sprintf("username='%s' AND id!='%s'", $modx->db->escape($newusername), $id)); |
|
| 223 | + $limit = $modx->db->getValue($rs); |
|
| 224 | + if($limit > 0) { |
|
| 225 | + webAlertAndQuit("User name is already in use!"); |
|
| 226 | + } |
|
| 227 | + |
|
| 228 | + // check if the email address already exists |
|
| 229 | + $rs = $modx->db->select('count(internalKey)', $tbl_user_attributes, sprintf("email='%s' AND internalKey!='%s'", $modx->db->escape($email), $id)); |
|
| 230 | + $limit = $modx->db->getValue($rs); |
|
| 231 | + if($limit > 0) { |
|
| 232 | + webAlertAndQuit("Email is already in use!"); |
|
| 233 | + } |
|
| 234 | + |
|
| 235 | + // invoke OnBeforeUserFormSave event |
|
| 236 | + $modx->invokeEvent("OnBeforeUserFormSave", array( |
|
| 237 | + "mode" => "upd", |
|
| 238 | + "id" => $id |
|
| 239 | + )); |
|
| 240 | + |
|
| 241 | + // update user name and password |
|
| 242 | + $field = array(); |
|
| 243 | + $field['username'] = $modx->db->escape($newusername); |
|
| 244 | + if($genpassword == 1) { |
|
| 245 | + $field['password'] = $modx->phpass->HashPassword($newpassword); |
|
| 246 | + } |
|
| 247 | + $modx->db->update($field, $tbl_manager_users, "id='{$id}'"); |
|
| 248 | + $field = compact('fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'failedlogincount', 'blocked', 'blockeduntil', 'blockedafter'); |
|
| 249 | + $field = $modx->db->escape($field); |
|
| 250 | + $modx->db->update($field, $tbl_user_attributes, "internalKey='{$id}'"); |
|
| 251 | + |
|
| 252 | + // Save user settings |
|
| 253 | + saveUserSettings($id); |
|
| 254 | + |
|
| 255 | + // Set the item name for logger |
|
| 256 | + $_SESSION['itemname'] = $newusername; |
|
| 257 | + |
|
| 258 | + // invoke OnManagerSaveUser event |
|
| 259 | + $modx->invokeEvent("OnManagerSaveUser", array( |
|
| 260 | + "mode" => "upd", |
|
| 261 | + "userid" => $id, |
|
| 262 | + "username" => $newusername, |
|
| 263 | + "userpassword" => $newpassword, |
|
| 264 | + "useremail" => $email, |
|
| 265 | + "userfullname" => $fullname, |
|
| 266 | + "userroleid" => $role, |
|
| 267 | + "oldusername" => (($oldusername != $newusername) ? $oldusername : ""), |
|
| 268 | + "olduseremail" => (($oldemail != $email) ? $oldemail : "") |
|
| 269 | + )); |
|
| 270 | + |
|
| 271 | + // invoke OnManagerChangePassword event |
|
| 272 | + if($genpassword == 1) { |
|
| 273 | + $modx->invokeEvent("OnManagerChangePassword", array( |
|
| 274 | + "userid" => $id, |
|
| 275 | + "username" => $newusername, |
|
| 276 | + "userpassword" => $newpassword |
|
| 277 | + )); |
|
| 278 | + } |
|
| 279 | + |
|
| 280 | + // invoke OnUserFormSave event |
|
| 281 | + $modx->invokeEvent("OnUserFormSave", array( |
|
| 282 | + "mode" => "upd", |
|
| 283 | + "id" => $id |
|
| 284 | + )); |
|
| 285 | + |
|
| 286 | + /*******************************************************************************/ |
|
| 287 | + // put the user in the user_groups he/ she should be in |
|
| 288 | + // first, check that up_perms are switched on! |
|
| 289 | + if($use_udperms == 1) { |
|
| 290 | + // as this is an existing user, delete his/ her entries in the groups before saving the new groups |
|
| 291 | + $modx->db->delete($tbl_member_groups, "member='{$id}'"); |
|
| 292 | + if(!empty($user_groups)) { |
|
| 293 | + for($i = 0; $i < count($user_groups); $i++) { |
|
| 294 | + $field = array(); |
|
| 295 | + $field['user_group'] = (int)$user_groups[$i]; |
|
| 296 | + $field['member'] = $id; |
|
| 297 | + $modx->db->insert($field, $tbl_member_groups); |
|
| 298 | + } |
|
| 299 | + } |
|
| 300 | + } |
|
| 301 | + // end of user_groups stuff! |
|
| 302 | + /*******************************************************************************/ |
|
| 303 | + if($id == $modx->getLoginUserID() && ($genpassword !== 1 && $passwordnotifymethod != 's')) { |
|
| 304 | + $modx->webAlertAndQuit($_lang["user_changeddata"], 'javascript:top.location.href="index.php?a=8";'); |
|
| 305 | + } |
|
| 306 | + if($genpassword == 1 && $passwordnotifymethod == 's') { |
|
| 307 | + if($input['stay'] != '') { |
|
| 308 | + $a = ($input['stay'] == '2') ? "12&id={$id}" : "11"; |
|
| 309 | + $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 310 | + } else { |
|
| 311 | + $stayUrl = "index.php?a=75&r=2"; |
|
| 312 | + } |
|
| 313 | + |
|
| 314 | + include_once "header.inc.php"; |
|
| 315 | + ?> |
|
| 316 | 316 | |
| 317 | 317 | <h1><?php echo $_lang['user_title']; ?></h1> |
| 318 | 318 | |
@@ -332,20 +332,20 @@ discard block |
||
| 332 | 332 | </div> |
| 333 | 333 | <?php |
| 334 | 334 | |
| 335 | - include_once "footer.inc.php"; |
|
| 336 | - } else { |
|
| 337 | - if($input['stay'] != '') { |
|
| 338 | - $a = ($input['stay'] == '2') ? "12&id={$id}" : "11"; |
|
| 339 | - $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 340 | - header($header); |
|
| 341 | - } else { |
|
| 342 | - $header = "Location: index.php?a=75&r=2"; |
|
| 343 | - header($header); |
|
| 344 | - } |
|
| 345 | - } |
|
| 346 | - break; |
|
| 347 | - default: |
|
| 348 | - webAlertAndQuit("No operation set in request."); |
|
| 335 | + include_once "footer.inc.php"; |
|
| 336 | + } else { |
|
| 337 | + if($input['stay'] != '') { |
|
| 338 | + $a = ($input['stay'] == '2') ? "12&id={$id}" : "11"; |
|
| 339 | + $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 340 | + header($header); |
|
| 341 | + } else { |
|
| 342 | + $header = "Location: index.php?a=75&r=2"; |
|
| 343 | + header($header); |
|
| 344 | + } |
|
| 345 | + } |
|
| 346 | + break; |
|
| 347 | + default: |
|
| 348 | + webAlertAndQuit("No operation set in request."); |
|
| 349 | 349 | } |
| 350 | 350 | |
| 351 | 351 | /** |
@@ -1,9 +1,9 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
| 3 | - die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
|
| 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_user')) { |
| 6 | - $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 6 | + $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 7 | 7 | } |
| 8 | 8 | |
| 9 | 9 | $modx->loadExtension('phpass'); |
@@ -45,134 +45,134 @@ discard block |
||
| 45 | 45 | |
| 46 | 46 | // verify password |
| 47 | 47 | if($passwordgenmethod == "spec" && $input['specifiedpassword'] != $input['confirmpassword']) { |
| 48 | - webAlertAndQuit("Password typed is mismatched"); |
|
| 48 | + webAlertAndQuit("Password typed is mismatched"); |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | // verify email |
| 52 | 52 | if($email == '' || !preg_match("/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,24}$/i", $email)) { |
| 53 | - webAlertAndQuit("E-mail address doesn't seem to be valid!"); |
|
| 53 | + webAlertAndQuit("E-mail address doesn't seem to be valid!"); |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | // verify admin security |
| 57 | 57 | if($_SESSION['mgrRole'] != 1) { |
| 58 | - // Check to see if user tried to spoof a "1" (admin) role |
|
| 59 | - if(!$modx->hasPermission('save_role')) { |
|
| 60 | - webAlertAndQuit("Illegal attempt to create/modify administrator by non-administrator!"); |
|
| 61 | - } |
|
| 62 | - // Verify that the user being edited wasn't an admin and the user ID got spoofed |
|
| 63 | - $rs = $modx->db->select('count(internalKey)', $tbl_user_attributes, "internalKey='{$id}' AND role=1"); |
|
| 64 | - $limit = $modx->db->getValue($rs); |
|
| 65 | - if($limit > 0) { |
|
| 66 | - webAlertAndQuit("You cannot alter an administrative user."); |
|
| 67 | - } |
|
| 58 | + // Check to see if user tried to spoof a "1" (admin) role |
|
| 59 | + if(!$modx->hasPermission('save_role')) { |
|
| 60 | + webAlertAndQuit("Illegal attempt to create/modify administrator by non-administrator!"); |
|
| 61 | + } |
|
| 62 | + // Verify that the user being edited wasn't an admin and the user ID got spoofed |
|
| 63 | + $rs = $modx->db->select('count(internalKey)', $tbl_user_attributes, "internalKey='{$id}' AND role=1"); |
|
| 64 | + $limit = $modx->db->getValue($rs); |
|
| 65 | + if($limit > 0) { |
|
| 66 | + webAlertAndQuit("You cannot alter an administrative user."); |
|
| 67 | + } |
|
| 68 | 68 | |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | switch($input['mode']) { |
| 72 | - case '11' : // new user |
|
| 73 | - // check if this user name already exist |
|
| 74 | - $rs = $modx->db->select('count(id)', $tbl_manager_users, sprintf("username='%s'", $modx->db->escape($newusername))); |
|
| 75 | - $limit = $modx->db->getValue($rs); |
|
| 76 | - if($limit > 0) { |
|
| 77 | - webAlertAndQuit("User name is already in use!"); |
|
| 78 | - } |
|
| 79 | - |
|
| 80 | - // check if the email address already exist |
|
| 81 | - $rs = $modx->db->select('count(internalKey)', $tbl_user_attributes, sprintf("email='%s' AND id!='%s'", $modx->db->escape($email), $id)); |
|
| 82 | - $limit = $modx->db->getValue($rs); |
|
| 83 | - if($limit > 0) { |
|
| 84 | - webAlertAndQuit("Email is already in use!"); |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - // generate a new password for this user |
|
| 88 | - if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
| 89 | - if(strlen($specifiedpassword) < 6) { |
|
| 90 | - webAlertAndQuit("Password is too short!"); |
|
| 91 | - } else { |
|
| 92 | - $newpassword = $specifiedpassword; |
|
| 93 | - } |
|
| 94 | - } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
| 95 | - webAlertAndQuit("You didn't specify a password for this user!"); |
|
| 96 | - } elseif($passwordgenmethod == 'g') { |
|
| 97 | - $newpassword = generate_password(8); |
|
| 98 | - } else { |
|
| 99 | - webAlertAndQuit("No password generation method specified!"); |
|
| 100 | - } |
|
| 101 | - |
|
| 102 | - // invoke OnBeforeUserFormSave event |
|
| 103 | - $modx->invokeEvent("OnBeforeUserFormSave", array( |
|
| 104 | - "mode" => "new", |
|
| 105 | - )); |
|
| 106 | - |
|
| 107 | - // create the user account |
|
| 108 | - $internalKey = $modx->db->insert(array('username' => $modx->db->escape($newusername)), $tbl_manager_users); |
|
| 109 | - |
|
| 110 | - $field = array(); |
|
| 111 | - $field['password'] = $modx->phpass->HashPassword($newpassword); |
|
| 112 | - $modx->db->update($field, $tbl_manager_users, "id='{$internalKey}'"); |
|
| 113 | - |
|
| 114 | - $field = compact('internalKey', 'fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'blocked', 'blockeduntil', 'blockedafter'); |
|
| 115 | - $field = $modx->db->escape($field); |
|
| 116 | - $modx->db->insert($field, $tbl_user_attributes); |
|
| 117 | - |
|
| 118 | - // Save user settings |
|
| 119 | - saveUserSettings($internalKey); |
|
| 120 | - |
|
| 121 | - // invoke OnManagerSaveUser event |
|
| 122 | - $modx->invokeEvent("OnManagerSaveUser", array( |
|
| 123 | - "mode" => "new", |
|
| 124 | - "userid" => $internalKey, |
|
| 125 | - "username" => $newusername, |
|
| 126 | - "userpassword" => $newpassword, |
|
| 127 | - "useremail" => $email, |
|
| 128 | - "userfullname" => $fullname, |
|
| 129 | - "userroleid" => $role |
|
| 130 | - )); |
|
| 131 | - |
|
| 132 | - // invoke OnUserFormSave event |
|
| 133 | - $modx->invokeEvent("OnUserFormSave", array( |
|
| 134 | - "mode" => "new", |
|
| 135 | - "id" => $internalKey |
|
| 136 | - )); |
|
| 137 | - |
|
| 138 | - // Set the item name for logger |
|
| 139 | - $_SESSION['itemname'] = $newusername; |
|
| 140 | - |
|
| 141 | - /*******************************************************************************/ |
|
| 142 | - // put the user in the user_groups he/ she should be in |
|
| 143 | - // first, check that up_perms are switched on! |
|
| 144 | - if($use_udperms == 1) { |
|
| 145 | - if(!empty($user_groups)) { |
|
| 146 | - for($i = 0; $i < count($user_groups); $i++) { |
|
| 147 | - $f = array(); |
|
| 148 | - $f['user_group'] = (int)$user_groups[$i]; |
|
| 149 | - $f['member'] = $internalKey; |
|
| 150 | - $modx->db->insert($f, $tbl_member_groups); |
|
| 151 | - } |
|
| 152 | - } |
|
| 153 | - } |
|
| 154 | - // end of user_groups stuff! |
|
| 155 | - |
|
| 156 | - if($passwordnotifymethod == 'e') { |
|
| 157 | - sendMailMessage($email, $newusername, $newpassword, $fullname); |
|
| 158 | - if($input['stay'] != '') { |
|
| 159 | - $a = ($input['stay'] == '2') ? "12&id={$internalKey}" : "11"; |
|
| 160 | - $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 161 | - header($header); |
|
| 162 | - } else { |
|
| 163 | - $header = "Location: index.php?a=75&r=2"; |
|
| 164 | - header($header); |
|
| 165 | - } |
|
| 166 | - } else { |
|
| 167 | - if($input['stay'] != '') { |
|
| 168 | - $a = ($input['stay'] == '2') ? "12&id={$internalKey}" : "11"; |
|
| 169 | - $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 170 | - } else { |
|
| 171 | - $stayUrl = "index.php?a=75&r=2"; |
|
| 172 | - } |
|
| 173 | - |
|
| 174 | - include_once "header.inc.php"; |
|
| 175 | - ?> |
|
| 72 | + case '11' : // new user |
|
| 73 | + // check if this user name already exist |
|
| 74 | + $rs = $modx->db->select('count(id)', $tbl_manager_users, sprintf("username='%s'", $modx->db->escape($newusername))); |
|
| 75 | + $limit = $modx->db->getValue($rs); |
|
| 76 | + if($limit > 0) { |
|
| 77 | + webAlertAndQuit("User name is already in use!"); |
|
| 78 | + } |
|
| 79 | + |
|
| 80 | + // check if the email address already exist |
|
| 81 | + $rs = $modx->db->select('count(internalKey)', $tbl_user_attributes, sprintf("email='%s' AND id!='%s'", $modx->db->escape($email), $id)); |
|
| 82 | + $limit = $modx->db->getValue($rs); |
|
| 83 | + if($limit > 0) { |
|
| 84 | + webAlertAndQuit("Email is already in use!"); |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + // generate a new password for this user |
|
| 88 | + if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
| 89 | + if(strlen($specifiedpassword) < 6) { |
|
| 90 | + webAlertAndQuit("Password is too short!"); |
|
| 91 | + } else { |
|
| 92 | + $newpassword = $specifiedpassword; |
|
| 93 | + } |
|
| 94 | + } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
| 95 | + webAlertAndQuit("You didn't specify a password for this user!"); |
|
| 96 | + } elseif($passwordgenmethod == 'g') { |
|
| 97 | + $newpassword = generate_password(8); |
|
| 98 | + } else { |
|
| 99 | + webAlertAndQuit("No password generation method specified!"); |
|
| 100 | + } |
|
| 101 | + |
|
| 102 | + // invoke OnBeforeUserFormSave event |
|
| 103 | + $modx->invokeEvent("OnBeforeUserFormSave", array( |
|
| 104 | + "mode" => "new", |
|
| 105 | + )); |
|
| 106 | + |
|
| 107 | + // create the user account |
|
| 108 | + $internalKey = $modx->db->insert(array('username' => $modx->db->escape($newusername)), $tbl_manager_users); |
|
| 109 | + |
|
| 110 | + $field = array(); |
|
| 111 | + $field['password'] = $modx->phpass->HashPassword($newpassword); |
|
| 112 | + $modx->db->update($field, $tbl_manager_users, "id='{$internalKey}'"); |
|
| 113 | + |
|
| 114 | + $field = compact('internalKey', 'fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'blocked', 'blockeduntil', 'blockedafter'); |
|
| 115 | + $field = $modx->db->escape($field); |
|
| 116 | + $modx->db->insert($field, $tbl_user_attributes); |
|
| 117 | + |
|
| 118 | + // Save user settings |
|
| 119 | + saveUserSettings($internalKey); |
|
| 120 | + |
|
| 121 | + // invoke OnManagerSaveUser event |
|
| 122 | + $modx->invokeEvent("OnManagerSaveUser", array( |
|
| 123 | + "mode" => "new", |
|
| 124 | + "userid" => $internalKey, |
|
| 125 | + "username" => $newusername, |
|
| 126 | + "userpassword" => $newpassword, |
|
| 127 | + "useremail" => $email, |
|
| 128 | + "userfullname" => $fullname, |
|
| 129 | + "userroleid" => $role |
|
| 130 | + )); |
|
| 131 | + |
|
| 132 | + // invoke OnUserFormSave event |
|
| 133 | + $modx->invokeEvent("OnUserFormSave", array( |
|
| 134 | + "mode" => "new", |
|
| 135 | + "id" => $internalKey |
|
| 136 | + )); |
|
| 137 | + |
|
| 138 | + // Set the item name for logger |
|
| 139 | + $_SESSION['itemname'] = $newusername; |
|
| 140 | + |
|
| 141 | + /*******************************************************************************/ |
|
| 142 | + // put the user in the user_groups he/ she should be in |
|
| 143 | + // first, check that up_perms are switched on! |
|
| 144 | + if($use_udperms == 1) { |
|
| 145 | + if(!empty($user_groups)) { |
|
| 146 | + for($i = 0; $i < count($user_groups); $i++) { |
|
| 147 | + $f = array(); |
|
| 148 | + $f['user_group'] = (int)$user_groups[$i]; |
|
| 149 | + $f['member'] = $internalKey; |
|
| 150 | + $modx->db->insert($f, $tbl_member_groups); |
|
| 151 | + } |
|
| 152 | + } |
|
| 153 | + } |
|
| 154 | + // end of user_groups stuff! |
|
| 155 | + |
|
| 156 | + if($passwordnotifymethod == 'e') { |
|
| 157 | + sendMailMessage($email, $newusername, $newpassword, $fullname); |
|
| 158 | + if($input['stay'] != '') { |
|
| 159 | + $a = ($input['stay'] == '2') ? "12&id={$internalKey}" : "11"; |
|
| 160 | + $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 161 | + header($header); |
|
| 162 | + } else { |
|
| 163 | + $header = "Location: index.php?a=75&r=2"; |
|
| 164 | + header($header); |
|
| 165 | + } |
|
| 166 | + } else { |
|
| 167 | + if($input['stay'] != '') { |
|
| 168 | + $a = ($input['stay'] == '2') ? "12&id={$internalKey}" : "11"; |
|
| 169 | + $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 170 | + } else { |
|
| 171 | + $stayUrl = "index.php?a=75&r=2"; |
|
| 172 | + } |
|
| 173 | + |
|
| 174 | + include_once "header.inc.php"; |
|
| 175 | + ?> |
|
| 176 | 176 | |
| 177 | 177 | <h1><?php echo $_lang['user_title']; ?></h1> |
| 178 | 178 | |
@@ -194,125 +194,125 @@ discard block |
||
| 194 | 194 | </div> |
| 195 | 195 | <?php |
| 196 | 196 | |
| 197 | - include_once "footer.inc.php"; |
|
| 198 | - } |
|
| 199 | - break; |
|
| 200 | - case '12' : // edit user |
|
| 201 | - // generate a new password for this user |
|
| 202 | - if($genpassword == 1) { |
|
| 203 | - if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
| 204 | - if(strlen($specifiedpassword) < 6) { |
|
| 205 | - webAlertAndQuit("Password is too short!"); |
|
| 206 | - } else { |
|
| 207 | - $newpassword = $specifiedpassword; |
|
| 208 | - } |
|
| 209 | - } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
| 210 | - webAlertAndQuit("You didn't specify a password for this user!"); |
|
| 211 | - } elseif($passwordgenmethod == 'g') { |
|
| 212 | - $newpassword = generate_password(8); |
|
| 213 | - } else { |
|
| 214 | - webAlertAndQuit("No password generation method specified!"); |
|
| 215 | - } |
|
| 216 | - } |
|
| 217 | - if($passwordnotifymethod == 'e') { |
|
| 218 | - sendMailMessage($email, $newusername, $newpassword, $fullname); |
|
| 219 | - } |
|
| 220 | - |
|
| 221 | - // check if the username already exist |
|
| 222 | - $rs = $modx->db->select('count(id)', $tbl_manager_users, sprintf("username='%s' AND id!='%s'", $modx->db->escape($newusername), $id)); |
|
| 223 | - $limit = $modx->db->getValue($rs); |
|
| 224 | - if($limit > 0) { |
|
| 225 | - webAlertAndQuit("User name is already in use!"); |
|
| 226 | - } |
|
| 227 | - |
|
| 228 | - // check if the email address already exists |
|
| 229 | - $rs = $modx->db->select('count(internalKey)', $tbl_user_attributes, sprintf("email='%s' AND internalKey!='%s'", $modx->db->escape($email), $id)); |
|
| 230 | - $limit = $modx->db->getValue($rs); |
|
| 231 | - if($limit > 0) { |
|
| 232 | - webAlertAndQuit("Email is already in use!"); |
|
| 233 | - } |
|
| 234 | - |
|
| 235 | - // invoke OnBeforeUserFormSave event |
|
| 236 | - $modx->invokeEvent("OnBeforeUserFormSave", array( |
|
| 237 | - "mode" => "upd", |
|
| 238 | - "id" => $id |
|
| 239 | - )); |
|
| 240 | - |
|
| 241 | - // update user name and password |
|
| 242 | - $field = array(); |
|
| 243 | - $field['username'] = $modx->db->escape($newusername); |
|
| 244 | - if($genpassword == 1) { |
|
| 245 | - $field['password'] = $modx->phpass->HashPassword($newpassword); |
|
| 246 | - } |
|
| 247 | - $modx->db->update($field, $tbl_manager_users, "id='{$id}'"); |
|
| 248 | - $field = compact('fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'failedlogincount', 'blocked', 'blockeduntil', 'blockedafter'); |
|
| 249 | - $field = $modx->db->escape($field); |
|
| 250 | - $modx->db->update($field, $tbl_user_attributes, "internalKey='{$id}'"); |
|
| 251 | - |
|
| 252 | - // Save user settings |
|
| 253 | - saveUserSettings($id); |
|
| 254 | - |
|
| 255 | - // Set the item name for logger |
|
| 256 | - $_SESSION['itemname'] = $newusername; |
|
| 257 | - |
|
| 258 | - // invoke OnManagerSaveUser event |
|
| 259 | - $modx->invokeEvent("OnManagerSaveUser", array( |
|
| 260 | - "mode" => "upd", |
|
| 261 | - "userid" => $id, |
|
| 262 | - "username" => $newusername, |
|
| 263 | - "userpassword" => $newpassword, |
|
| 264 | - "useremail" => $email, |
|
| 265 | - "userfullname" => $fullname, |
|
| 266 | - "userroleid" => $role, |
|
| 267 | - "oldusername" => (($oldusername != $newusername) ? $oldusername : ""), |
|
| 268 | - "olduseremail" => (($oldemail != $email) ? $oldemail : "") |
|
| 269 | - )); |
|
| 270 | - |
|
| 271 | - // invoke OnManagerChangePassword event |
|
| 272 | - if($genpassword == 1) { |
|
| 273 | - $modx->invokeEvent("OnManagerChangePassword", array( |
|
| 274 | - "userid" => $id, |
|
| 275 | - "username" => $newusername, |
|
| 276 | - "userpassword" => $newpassword |
|
| 277 | - )); |
|
| 278 | - } |
|
| 279 | - |
|
| 280 | - // invoke OnUserFormSave event |
|
| 281 | - $modx->invokeEvent("OnUserFormSave", array( |
|
| 282 | - "mode" => "upd", |
|
| 283 | - "id" => $id |
|
| 284 | - )); |
|
| 285 | - |
|
| 286 | - /*******************************************************************************/ |
|
| 287 | - // put the user in the user_groups he/ she should be in |
|
| 288 | - // first, check that up_perms are switched on! |
|
| 289 | - if($use_udperms == 1) { |
|
| 290 | - // as this is an existing user, delete his/ her entries in the groups before saving the new groups |
|
| 291 | - $modx->db->delete($tbl_member_groups, "member='{$id}'"); |
|
| 292 | - if(!empty($user_groups)) { |
|
| 293 | - for($i = 0; $i < count($user_groups); $i++) { |
|
| 294 | - $field = array(); |
|
| 295 | - $field['user_group'] = (int)$user_groups[$i]; |
|
| 296 | - $field['member'] = $id; |
|
| 297 | - $modx->db->insert($field, $tbl_member_groups); |
|
| 298 | - } |
|
| 299 | - } |
|
| 300 | - } |
|
| 301 | - // end of user_groups stuff! |
|
| 302 | - /*******************************************************************************/ |
|
| 303 | - if($id == $modx->getLoginUserID() && ($genpassword !== 1 && $passwordnotifymethod != 's')) { |
|
| 304 | - $modx->webAlertAndQuit($_lang["user_changeddata"], 'javascript:top.location.href="index.php?a=8";'); |
|
| 305 | - } |
|
| 306 | - if($genpassword == 1 && $passwordnotifymethod == 's') { |
|
| 307 | - if($input['stay'] != '') { |
|
| 308 | - $a = ($input['stay'] == '2') ? "12&id={$id}" : "11"; |
|
| 309 | - $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 310 | - } else { |
|
| 311 | - $stayUrl = "index.php?a=75&r=2"; |
|
| 312 | - } |
|
| 313 | - |
|
| 314 | - include_once "header.inc.php"; |
|
| 315 | - ?> |
|
| 197 | + include_once "footer.inc.php"; |
|
| 198 | + } |
|
| 199 | + break; |
|
| 200 | + case '12' : // edit user |
|
| 201 | + // generate a new password for this user |
|
| 202 | + if($genpassword == 1) { |
|
| 203 | + if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
| 204 | + if(strlen($specifiedpassword) < 6) { |
|
| 205 | + webAlertAndQuit("Password is too short!"); |
|
| 206 | + } else { |
|
| 207 | + $newpassword = $specifiedpassword; |
|
| 208 | + } |
|
| 209 | + } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
| 210 | + webAlertAndQuit("You didn't specify a password for this user!"); |
|
| 211 | + } elseif($passwordgenmethod == 'g') { |
|
| 212 | + $newpassword = generate_password(8); |
|
| 213 | + } else { |
|
| 214 | + webAlertAndQuit("No password generation method specified!"); |
|
| 215 | + } |
|
| 216 | + } |
|
| 217 | + if($passwordnotifymethod == 'e') { |
|
| 218 | + sendMailMessage($email, $newusername, $newpassword, $fullname); |
|
| 219 | + } |
|
| 220 | + |
|
| 221 | + // check if the username already exist |
|
| 222 | + $rs = $modx->db->select('count(id)', $tbl_manager_users, sprintf("username='%s' AND id!='%s'", $modx->db->escape($newusername), $id)); |
|
| 223 | + $limit = $modx->db->getValue($rs); |
|
| 224 | + if($limit > 0) { |
|
| 225 | + webAlertAndQuit("User name is already in use!"); |
|
| 226 | + } |
|
| 227 | + |
|
| 228 | + // check if the email address already exists |
|
| 229 | + $rs = $modx->db->select('count(internalKey)', $tbl_user_attributes, sprintf("email='%s' AND internalKey!='%s'", $modx->db->escape($email), $id)); |
|
| 230 | + $limit = $modx->db->getValue($rs); |
|
| 231 | + if($limit > 0) { |
|
| 232 | + webAlertAndQuit("Email is already in use!"); |
|
| 233 | + } |
|
| 234 | + |
|
| 235 | + // invoke OnBeforeUserFormSave event |
|
| 236 | + $modx->invokeEvent("OnBeforeUserFormSave", array( |
|
| 237 | + "mode" => "upd", |
|
| 238 | + "id" => $id |
|
| 239 | + )); |
|
| 240 | + |
|
| 241 | + // update user name and password |
|
| 242 | + $field = array(); |
|
| 243 | + $field['username'] = $modx->db->escape($newusername); |
|
| 244 | + if($genpassword == 1) { |
|
| 245 | + $field['password'] = $modx->phpass->HashPassword($newpassword); |
|
| 246 | + } |
|
| 247 | + $modx->db->update($field, $tbl_manager_users, "id='{$id}'"); |
|
| 248 | + $field = compact('fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'failedlogincount', 'blocked', 'blockeduntil', 'blockedafter'); |
|
| 249 | + $field = $modx->db->escape($field); |
|
| 250 | + $modx->db->update($field, $tbl_user_attributes, "internalKey='{$id}'"); |
|
| 251 | + |
|
| 252 | + // Save user settings |
|
| 253 | + saveUserSettings($id); |
|
| 254 | + |
|
| 255 | + // Set the item name for logger |
|
| 256 | + $_SESSION['itemname'] = $newusername; |
|
| 257 | + |
|
| 258 | + // invoke OnManagerSaveUser event |
|
| 259 | + $modx->invokeEvent("OnManagerSaveUser", array( |
|
| 260 | + "mode" => "upd", |
|
| 261 | + "userid" => $id, |
|
| 262 | + "username" => $newusername, |
|
| 263 | + "userpassword" => $newpassword, |
|
| 264 | + "useremail" => $email, |
|
| 265 | + "userfullname" => $fullname, |
|
| 266 | + "userroleid" => $role, |
|
| 267 | + "oldusername" => (($oldusername != $newusername) ? $oldusername : ""), |
|
| 268 | + "olduseremail" => (($oldemail != $email) ? $oldemail : "") |
|
| 269 | + )); |
|
| 270 | + |
|
| 271 | + // invoke OnManagerChangePassword event |
|
| 272 | + if($genpassword == 1) { |
|
| 273 | + $modx->invokeEvent("OnManagerChangePassword", array( |
|
| 274 | + "userid" => $id, |
|
| 275 | + "username" => $newusername, |
|
| 276 | + "userpassword" => $newpassword |
|
| 277 | + )); |
|
| 278 | + } |
|
| 279 | + |
|
| 280 | + // invoke OnUserFormSave event |
|
| 281 | + $modx->invokeEvent("OnUserFormSave", array( |
|
| 282 | + "mode" => "upd", |
|
| 283 | + "id" => $id |
|
| 284 | + )); |
|
| 285 | + |
|
| 286 | + /*******************************************************************************/ |
|
| 287 | + // put the user in the user_groups he/ she should be in |
|
| 288 | + // first, check that up_perms are switched on! |
|
| 289 | + if($use_udperms == 1) { |
|
| 290 | + // as this is an existing user, delete his/ her entries in the groups before saving the new groups |
|
| 291 | + $modx->db->delete($tbl_member_groups, "member='{$id}'"); |
|
| 292 | + if(!empty($user_groups)) { |
|
| 293 | + for($i = 0; $i < count($user_groups); $i++) { |
|
| 294 | + $field = array(); |
|
| 295 | + $field['user_group'] = (int)$user_groups[$i]; |
|
| 296 | + $field['member'] = $id; |
|
| 297 | + $modx->db->insert($field, $tbl_member_groups); |
|
| 298 | + } |
|
| 299 | + } |
|
| 300 | + } |
|
| 301 | + // end of user_groups stuff! |
|
| 302 | + /*******************************************************************************/ |
|
| 303 | + if($id == $modx->getLoginUserID() && ($genpassword !== 1 && $passwordnotifymethod != 's')) { |
|
| 304 | + $modx->webAlertAndQuit($_lang["user_changeddata"], 'javascript:top.location.href="index.php?a=8";'); |
|
| 305 | + } |
|
| 306 | + if($genpassword == 1 && $passwordnotifymethod == 's') { |
|
| 307 | + if($input['stay'] != '') { |
|
| 308 | + $a = ($input['stay'] == '2') ? "12&id={$id}" : "11"; |
|
| 309 | + $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 310 | + } else { |
|
| 311 | + $stayUrl = "index.php?a=75&r=2"; |
|
| 312 | + } |
|
| 313 | + |
|
| 314 | + include_once "header.inc.php"; |
|
| 315 | + ?> |
|
| 316 | 316 | |
| 317 | 317 | <h1><?php echo $_lang['user_title']; ?></h1> |
| 318 | 318 | |
@@ -332,20 +332,20 @@ discard block |
||
| 332 | 332 | </div> |
| 333 | 333 | <?php |
| 334 | 334 | |
| 335 | - include_once "footer.inc.php"; |
|
| 336 | - } else { |
|
| 337 | - if($input['stay'] != '') { |
|
| 338 | - $a = ($input['stay'] == '2') ? "12&id={$id}" : "11"; |
|
| 339 | - $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 340 | - header($header); |
|
| 341 | - } else { |
|
| 342 | - $header = "Location: index.php?a=75&r=2"; |
|
| 343 | - header($header); |
|
| 344 | - } |
|
| 345 | - } |
|
| 346 | - break; |
|
| 347 | - default: |
|
| 348 | - webAlertAndQuit("No operation set in request."); |
|
| 335 | + include_once "footer.inc.php"; |
|
| 336 | + } else { |
|
| 337 | + if($input['stay'] != '') { |
|
| 338 | + $a = ($input['stay'] == '2') ? "12&id={$id}" : "11"; |
|
| 339 | + $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 340 | + header($header); |
|
| 341 | + } else { |
|
| 342 | + $header = "Location: index.php?a=75&r=2"; |
|
| 343 | + header($header); |
|
| 344 | + } |
|
| 345 | + } |
|
| 346 | + break; |
|
| 347 | + default: |
|
| 348 | + webAlertAndQuit("No operation set in request."); |
|
| 349 | 349 | } |
| 350 | 350 | |
| 351 | 351 | /** |
@@ -357,31 +357,31 @@ discard block |
||
| 357 | 357 | * @param string $ufn |
| 358 | 358 | */ |
| 359 | 359 | function sendMailMessage($email, $uid, $pwd, $ufn) { |
| 360 | - $modx = evolutionCMS(); global $_lang, $signupemail_message; |
|
| 361 | - global $emailsubject, $emailsender; |
|
| 362 | - global $site_name; |
|
| 363 | - $manager_url = MODX_MANAGER_URL; |
|
| 364 | - $message = sprintf($signupemail_message, $uid, $pwd); // use old method |
|
| 365 | - // replace placeholders |
|
| 366 | - $message = str_replace("[+uid+]", $uid, $message); |
|
| 367 | - $message = str_replace("[+pwd+]", $pwd, $message); |
|
| 368 | - $message = str_replace("[+ufn+]", $ufn, $message); |
|
| 369 | - $message = str_replace("[+sname+]", $site_name, $message); |
|
| 370 | - $message = str_replace("[+saddr+]", $emailsender, $message); |
|
| 371 | - $message = str_replace("[+semail+]", $emailsender, $message); |
|
| 372 | - $message = str_replace("[+surl+]", $manager_url, $message); |
|
| 373 | - |
|
| 374 | - $param = array(); |
|
| 375 | - $param['from'] = "{$site_name}<{$emailsender}>"; |
|
| 376 | - $param['subject'] = $emailsubject; |
|
| 377 | - $param['body'] = $message; |
|
| 378 | - $param['to'] = $email; |
|
| 379 | - $param['type'] = 'text'; |
|
| 380 | - $rs = $modx->sendmail($param); |
|
| 381 | - if(!$rs) { |
|
| 382 | - $modx->manager->saveFormValues(); |
|
| 383 | - $modx->messageQuit("{$email} - {$_lang['error_sending_email']}"); |
|
| 384 | - } |
|
| 360 | + $modx = evolutionCMS(); global $_lang, $signupemail_message; |
|
| 361 | + global $emailsubject, $emailsender; |
|
| 362 | + global $site_name; |
|
| 363 | + $manager_url = MODX_MANAGER_URL; |
|
| 364 | + $message = sprintf($signupemail_message, $uid, $pwd); // use old method |
|
| 365 | + // replace placeholders |
|
| 366 | + $message = str_replace("[+uid+]", $uid, $message); |
|
| 367 | + $message = str_replace("[+pwd+]", $pwd, $message); |
|
| 368 | + $message = str_replace("[+ufn+]", $ufn, $message); |
|
| 369 | + $message = str_replace("[+sname+]", $site_name, $message); |
|
| 370 | + $message = str_replace("[+saddr+]", $emailsender, $message); |
|
| 371 | + $message = str_replace("[+semail+]", $emailsender, $message); |
|
| 372 | + $message = str_replace("[+surl+]", $manager_url, $message); |
|
| 373 | + |
|
| 374 | + $param = array(); |
|
| 375 | + $param['from'] = "{$site_name}<{$emailsender}>"; |
|
| 376 | + $param['subject'] = $emailsubject; |
|
| 377 | + $param['body'] = $message; |
|
| 378 | + $param['to'] = $email; |
|
| 379 | + $param['type'] = 'text'; |
|
| 380 | + $rs = $modx->sendmail($param); |
|
| 381 | + if(!$rs) { |
|
| 382 | + $modx->manager->saveFormValues(); |
|
| 383 | + $modx->messageQuit("{$email} - {$_lang['error_sending_email']}"); |
|
| 384 | + } |
|
| 385 | 385 | } |
| 386 | 386 | |
| 387 | 387 | /** |
@@ -390,86 +390,86 @@ discard block |
||
| 390 | 390 | * @param int $id |
| 391 | 391 | */ |
| 392 | 392 | function saveUserSettings($id) { |
| 393 | - $modx = evolutionCMS(); |
|
| 394 | - $tbl_user_settings = $modx->getFullTableName('user_settings'); |
|
| 395 | - |
|
| 396 | - $ignore = array( |
|
| 397 | - 'id', |
|
| 398 | - 'oldusername', |
|
| 399 | - 'oldemail', |
|
| 400 | - 'newusername', |
|
| 401 | - 'fullname', |
|
| 402 | - 'newpassword', |
|
| 403 | - 'newpasswordcheck', |
|
| 404 | - 'passwordgenmethod', |
|
| 405 | - 'passwordnotifymethod', |
|
| 406 | - 'specifiedpassword', |
|
| 407 | - 'confirmpassword', |
|
| 408 | - 'email', |
|
| 409 | - 'phone', |
|
| 410 | - 'mobilephone', |
|
| 411 | - 'fax', |
|
| 412 | - 'dob', |
|
| 413 | - 'country', |
|
| 414 | - 'street', |
|
| 415 | - 'city', |
|
| 416 | - 'state', |
|
| 417 | - 'zip', |
|
| 418 | - 'gender', |
|
| 419 | - 'photo', |
|
| 420 | - 'comment', |
|
| 421 | - 'role', |
|
| 422 | - 'failedlogincount', |
|
| 423 | - 'blocked', |
|
| 424 | - 'blockeduntil', |
|
| 425 | - 'blockedafter', |
|
| 426 | - 'user_groups', |
|
| 427 | - 'mode', |
|
| 428 | - 'blockedmode', |
|
| 429 | - 'stay', |
|
| 430 | - 'save', |
|
| 431 | - 'theme_refresher' |
|
| 432 | - ); |
|
| 433 | - |
|
| 434 | - // determine which settings can be saved blank (based on 'default_{settingname}' POST checkbox values) |
|
| 435 | - $defaults = array( |
|
| 436 | - 'upload_images', |
|
| 437 | - 'upload_media', |
|
| 438 | - 'upload_flash', |
|
| 439 | - 'upload_files' |
|
| 440 | - ); |
|
| 441 | - |
|
| 442 | - // get user setting field names |
|
| 443 | - $settings = array(); |
|
| 444 | - foreach($_POST as $n => $v) { |
|
| 445 | - if(in_array($n, $ignore) || (!in_array($n, $defaults) && is_scalar($v) && trim($v) == '') || (!in_array($n, $defaults) && is_array($v) && empty($v))) { |
|
| 446 | - continue; |
|
| 447 | - } // ignore blacklist and empties |
|
| 448 | - $settings[$n] = $v; // this value should be saved |
|
| 449 | - } |
|
| 450 | - |
|
| 451 | - foreach($defaults as $k) { |
|
| 452 | - if(isset($settings['default_' . $k]) && $settings['default_' . $k] == '1') { |
|
| 453 | - unset($settings[$k]); |
|
| 454 | - } |
|
| 455 | - unset($settings['default_' . $k]); |
|
| 456 | - } |
|
| 457 | - |
|
| 458 | - $modx->db->delete($tbl_user_settings, "user='{$id}'"); |
|
| 459 | - |
|
| 460 | - foreach($settings as $n => $vl) { |
|
| 461 | - if(is_array($vl)) { |
|
| 462 | - $vl = implode(",", $vl); |
|
| 463 | - } |
|
| 464 | - if($vl != '') { |
|
| 465 | - $f = array(); |
|
| 466 | - $f['user'] = $id; |
|
| 467 | - $f['setting_name'] = $n; |
|
| 468 | - $f['setting_value'] = $vl; |
|
| 469 | - $f = $modx->db->escape($f); |
|
| 470 | - $modx->db->insert($f, $tbl_user_settings); |
|
| 471 | - } |
|
| 472 | - } |
|
| 393 | + $modx = evolutionCMS(); |
|
| 394 | + $tbl_user_settings = $modx->getFullTableName('user_settings'); |
|
| 395 | + |
|
| 396 | + $ignore = array( |
|
| 397 | + 'id', |
|
| 398 | + 'oldusername', |
|
| 399 | + 'oldemail', |
|
| 400 | + 'newusername', |
|
| 401 | + 'fullname', |
|
| 402 | + 'newpassword', |
|
| 403 | + 'newpasswordcheck', |
|
| 404 | + 'passwordgenmethod', |
|
| 405 | + 'passwordnotifymethod', |
|
| 406 | + 'specifiedpassword', |
|
| 407 | + 'confirmpassword', |
|
| 408 | + 'email', |
|
| 409 | + 'phone', |
|
| 410 | + 'mobilephone', |
|
| 411 | + 'fax', |
|
| 412 | + 'dob', |
|
| 413 | + 'country', |
|
| 414 | + 'street', |
|
| 415 | + 'city', |
|
| 416 | + 'state', |
|
| 417 | + 'zip', |
|
| 418 | + 'gender', |
|
| 419 | + 'photo', |
|
| 420 | + 'comment', |
|
| 421 | + 'role', |
|
| 422 | + 'failedlogincount', |
|
| 423 | + 'blocked', |
|
| 424 | + 'blockeduntil', |
|
| 425 | + 'blockedafter', |
|
| 426 | + 'user_groups', |
|
| 427 | + 'mode', |
|
| 428 | + 'blockedmode', |
|
| 429 | + 'stay', |
|
| 430 | + 'save', |
|
| 431 | + 'theme_refresher' |
|
| 432 | + ); |
|
| 433 | + |
|
| 434 | + // determine which settings can be saved blank (based on 'default_{settingname}' POST checkbox values) |
|
| 435 | + $defaults = array( |
|
| 436 | + 'upload_images', |
|
| 437 | + 'upload_media', |
|
| 438 | + 'upload_flash', |
|
| 439 | + 'upload_files' |
|
| 440 | + ); |
|
| 441 | + |
|
| 442 | + // get user setting field names |
|
| 443 | + $settings = array(); |
|
| 444 | + foreach($_POST as $n => $v) { |
|
| 445 | + if(in_array($n, $ignore) || (!in_array($n, $defaults) && is_scalar($v) && trim($v) == '') || (!in_array($n, $defaults) && is_array($v) && empty($v))) { |
|
| 446 | + continue; |
|
| 447 | + } // ignore blacklist and empties |
|
| 448 | + $settings[$n] = $v; // this value should be saved |
|
| 449 | + } |
|
| 450 | + |
|
| 451 | + foreach($defaults as $k) { |
|
| 452 | + if(isset($settings['default_' . $k]) && $settings['default_' . $k] == '1') { |
|
| 453 | + unset($settings[$k]); |
|
| 454 | + } |
|
| 455 | + unset($settings['default_' . $k]); |
|
| 456 | + } |
|
| 457 | + |
|
| 458 | + $modx->db->delete($tbl_user_settings, "user='{$id}'"); |
|
| 459 | + |
|
| 460 | + foreach($settings as $n => $vl) { |
|
| 461 | + if(is_array($vl)) { |
|
| 462 | + $vl = implode(",", $vl); |
|
| 463 | + } |
|
| 464 | + if($vl != '') { |
|
| 465 | + $f = array(); |
|
| 466 | + $f['user'] = $id; |
|
| 467 | + $f['setting_name'] = $n; |
|
| 468 | + $f['setting_value'] = $vl; |
|
| 469 | + $f = $modx->db->escape($f); |
|
| 470 | + $modx->db->insert($f, $tbl_user_settings); |
|
| 471 | + } |
|
| 472 | + } |
|
| 473 | 473 | } |
| 474 | 474 | |
| 475 | 475 | /** |
@@ -478,10 +478,10 @@ discard block |
||
| 478 | 478 | * @param $msg |
| 479 | 479 | */ |
| 480 | 480 | function webAlertAndQuit($msg) { |
| 481 | - global $id, $modx; |
|
| 482 | - $mode = $_POST['mode']; |
|
| 483 | - $modx->manager->saveFormValues($mode); |
|
| 484 | - $modx->webAlertAndQuit($msg, "index.php?a={$mode}" . ($mode == '12' ? "&id={$id}" : '')); |
|
| 481 | + global $id, $modx; |
|
| 482 | + $mode = $_POST['mode']; |
|
| 483 | + $modx->manager->saveFormValues($mode); |
|
| 484 | + $modx->webAlertAndQuit($msg, "index.php?a={$mode}" . ($mode == '12' ? "&id={$id}" : '')); |
|
| 485 | 485 | } |
| 486 | 486 | |
| 487 | 487 | /** |
@@ -491,12 +491,12 @@ discard block |
||
| 491 | 491 | * @return string |
| 492 | 492 | */ |
| 493 | 493 | function generate_password($length = 10) { |
| 494 | - $allowable_characters = "abcdefghjkmnpqrstuvxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789"; |
|
| 495 | - $ps_len = strlen($allowable_characters); |
|
| 496 | - mt_srand((double) microtime() * 1000000); |
|
| 497 | - $pass = ""; |
|
| 498 | - for($i = 0; $i < $length; $i++) { |
|
| 499 | - $pass .= $allowable_characters[mt_rand(0, $ps_len - 1)]; |
|
| 500 | - } |
|
| 501 | - return $pass; |
|
| 494 | + $allowable_characters = "abcdefghjkmnpqrstuvxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789"; |
|
| 495 | + $ps_len = strlen($allowable_characters); |
|
| 496 | + mt_srand((double) microtime() * 1000000); |
|
| 497 | + $pass = ""; |
|
| 498 | + for($i = 0; $i < $length; $i++) { |
|
| 499 | + $pass .= $allowable_characters[mt_rand(0, $ps_len - 1)]; |
|
| 500 | + } |
|
| 501 | + return $pass; |
|
| 502 | 502 | } |
@@ -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('save_user')) { |
|
| 5 | +if (!$modx->hasPermission('save_user')) { |
|
| 6 | 6 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
| 7 | 7 | } |
| 8 | 8 | |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | |
| 15 | 15 | $input = $_POST; |
| 16 | 16 | |
| 17 | -$id = (int)$input['id']; |
|
| 17 | +$id = (int) $input['id']; |
|
| 18 | 18 | $oldusername = $input['oldusername']; |
| 19 | 19 | $newusername = !empty ($input['newusername']) ? trim($input['newusername']) : "New User"; |
| 20 | 20 | $fullname = $input['fullname']; |
@@ -44,56 +44,56 @@ discard block |
||
| 44 | 44 | $user_groups = $input['user_groups']; |
| 45 | 45 | |
| 46 | 46 | // verify password |
| 47 | -if($passwordgenmethod == "spec" && $input['specifiedpassword'] != $input['confirmpassword']) { |
|
| 47 | +if ($passwordgenmethod == "spec" && $input['specifiedpassword'] != $input['confirmpassword']) { |
|
| 48 | 48 | webAlertAndQuit("Password typed is mismatched"); |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | // verify email |
| 52 | -if($email == '' || !preg_match("/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,24}$/i", $email)) { |
|
| 52 | +if ($email == '' || !preg_match("/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,24}$/i", $email)) { |
|
| 53 | 53 | webAlertAndQuit("E-mail address doesn't seem to be valid!"); |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | // verify admin security |
| 57 | -if($_SESSION['mgrRole'] != 1) { |
|
| 57 | +if ($_SESSION['mgrRole'] != 1) { |
|
| 58 | 58 | // Check to see if user tried to spoof a "1" (admin) role |
| 59 | - if(!$modx->hasPermission('save_role')) { |
|
| 59 | + if (!$modx->hasPermission('save_role')) { |
|
| 60 | 60 | webAlertAndQuit("Illegal attempt to create/modify administrator by non-administrator!"); |
| 61 | 61 | } |
| 62 | 62 | // Verify that the user being edited wasn't an admin and the user ID got spoofed |
| 63 | 63 | $rs = $modx->db->select('count(internalKey)', $tbl_user_attributes, "internalKey='{$id}' AND role=1"); |
| 64 | 64 | $limit = $modx->db->getValue($rs); |
| 65 | - if($limit > 0) { |
|
| 65 | + if ($limit > 0) { |
|
| 66 | 66 | webAlertAndQuit("You cannot alter an administrative user."); |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | -switch($input['mode']) { |
|
| 71 | +switch ($input['mode']) { |
|
| 72 | 72 | case '11' : // new user |
| 73 | 73 | // check if this user name already exist |
| 74 | 74 | $rs = $modx->db->select('count(id)', $tbl_manager_users, sprintf("username='%s'", $modx->db->escape($newusername))); |
| 75 | 75 | $limit = $modx->db->getValue($rs); |
| 76 | - if($limit > 0) { |
|
| 76 | + if ($limit > 0) { |
|
| 77 | 77 | webAlertAndQuit("User name is already in use!"); |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | // check if the email address already exist |
| 81 | 81 | $rs = $modx->db->select('count(internalKey)', $tbl_user_attributes, sprintf("email='%s' AND id!='%s'", $modx->db->escape($email), $id)); |
| 82 | 82 | $limit = $modx->db->getValue($rs); |
| 83 | - if($limit > 0) { |
|
| 83 | + if ($limit > 0) { |
|
| 84 | 84 | webAlertAndQuit("Email is already in use!"); |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | // generate a new password for this user |
| 88 | - if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
| 89 | - if(strlen($specifiedpassword) < 6) { |
|
| 88 | + if ($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
| 89 | + if (strlen($specifiedpassword) < 6) { |
|
| 90 | 90 | webAlertAndQuit("Password is too short!"); |
| 91 | 91 | } else { |
| 92 | 92 | $newpassword = $specifiedpassword; |
| 93 | 93 | } |
| 94 | - } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
| 94 | + } elseif ($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
| 95 | 95 | webAlertAndQuit("You didn't specify a password for this user!"); |
| 96 | - } elseif($passwordgenmethod == 'g') { |
|
| 96 | + } elseif ($passwordgenmethod == 'g') { |
|
| 97 | 97 | $newpassword = generate_password(8); |
| 98 | 98 | } else { |
| 99 | 99 | webAlertAndQuit("No password generation method specified!"); |
@@ -141,11 +141,11 @@ discard block |
||
| 141 | 141 | /*******************************************************************************/ |
| 142 | 142 | // put the user in the user_groups he/ she should be in |
| 143 | 143 | // first, check that up_perms are switched on! |
| 144 | - if($use_udperms == 1) { |
|
| 145 | - if(!empty($user_groups)) { |
|
| 146 | - for($i = 0; $i < count($user_groups); $i++) { |
|
| 144 | + if ($use_udperms == 1) { |
|
| 145 | + if (!empty($user_groups)) { |
|
| 146 | + for ($i = 0; $i < count($user_groups); $i++) { |
|
| 147 | 147 | $f = array(); |
| 148 | - $f['user_group'] = (int)$user_groups[$i]; |
|
| 148 | + $f['user_group'] = (int) $user_groups[$i]; |
|
| 149 | 149 | $f['member'] = $internalKey; |
| 150 | 150 | $modx->db->insert($f, $tbl_member_groups); |
| 151 | 151 | } |
@@ -153,20 +153,20 @@ discard block |
||
| 153 | 153 | } |
| 154 | 154 | // end of user_groups stuff! |
| 155 | 155 | |
| 156 | - if($passwordnotifymethod == 'e') { |
|
| 156 | + if ($passwordnotifymethod == 'e') { |
|
| 157 | 157 | sendMailMessage($email, $newusername, $newpassword, $fullname); |
| 158 | - if($input['stay'] != '') { |
|
| 158 | + if ($input['stay'] != '') { |
|
| 159 | 159 | $a = ($input['stay'] == '2') ? "12&id={$internalKey}" : "11"; |
| 160 | - $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 160 | + $header = "Location: index.php?a={$a}&r=2&stay=".$input['stay']; |
|
| 161 | 161 | header($header); |
| 162 | 162 | } else { |
| 163 | 163 | $header = "Location: index.php?a=75&r=2"; |
| 164 | 164 | header($header); |
| 165 | 165 | } |
| 166 | 166 | } else { |
| 167 | - if($input['stay'] != '') { |
|
| 167 | + if ($input['stay'] != '') { |
|
| 168 | 168 | $a = ($input['stay'] == '2') ? "12&id={$internalKey}" : "11"; |
| 169 | - $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 169 | + $stayUrl = "index.php?a={$a}&r=2&stay=".$input['stay']; |
|
| 170 | 170 | } else { |
| 171 | 171 | $stayUrl = "index.php?a=75&r=2"; |
| 172 | 172 | } |
@@ -199,36 +199,36 @@ discard block |
||
| 199 | 199 | break; |
| 200 | 200 | case '12' : // edit user |
| 201 | 201 | // generate a new password for this user |
| 202 | - if($genpassword == 1) { |
|
| 203 | - if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
| 204 | - if(strlen($specifiedpassword) < 6) { |
|
| 202 | + if ($genpassword == 1) { |
|
| 203 | + if ($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
| 204 | + if (strlen($specifiedpassword) < 6) { |
|
| 205 | 205 | webAlertAndQuit("Password is too short!"); |
| 206 | 206 | } else { |
| 207 | 207 | $newpassword = $specifiedpassword; |
| 208 | 208 | } |
| 209 | - } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
| 209 | + } elseif ($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
| 210 | 210 | webAlertAndQuit("You didn't specify a password for this user!"); |
| 211 | - } elseif($passwordgenmethod == 'g') { |
|
| 211 | + } elseif ($passwordgenmethod == 'g') { |
|
| 212 | 212 | $newpassword = generate_password(8); |
| 213 | 213 | } else { |
| 214 | 214 | webAlertAndQuit("No password generation method specified!"); |
| 215 | 215 | } |
| 216 | 216 | } |
| 217 | - if($passwordnotifymethod == 'e') { |
|
| 217 | + if ($passwordnotifymethod == 'e') { |
|
| 218 | 218 | sendMailMessage($email, $newusername, $newpassword, $fullname); |
| 219 | 219 | } |
| 220 | 220 | |
| 221 | 221 | // check if the username already exist |
| 222 | 222 | $rs = $modx->db->select('count(id)', $tbl_manager_users, sprintf("username='%s' AND id!='%s'", $modx->db->escape($newusername), $id)); |
| 223 | 223 | $limit = $modx->db->getValue($rs); |
| 224 | - if($limit > 0) { |
|
| 224 | + if ($limit > 0) { |
|
| 225 | 225 | webAlertAndQuit("User name is already in use!"); |
| 226 | 226 | } |
| 227 | 227 | |
| 228 | 228 | // check if the email address already exists |
| 229 | 229 | $rs = $modx->db->select('count(internalKey)', $tbl_user_attributes, sprintf("email='%s' AND internalKey!='%s'", $modx->db->escape($email), $id)); |
| 230 | 230 | $limit = $modx->db->getValue($rs); |
| 231 | - if($limit > 0) { |
|
| 231 | + if ($limit > 0) { |
|
| 232 | 232 | webAlertAndQuit("Email is already in use!"); |
| 233 | 233 | } |
| 234 | 234 | |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | // update user name and password |
| 242 | 242 | $field = array(); |
| 243 | 243 | $field['username'] = $modx->db->escape($newusername); |
| 244 | - if($genpassword == 1) { |
|
| 244 | + if ($genpassword == 1) { |
|
| 245 | 245 | $field['password'] = $modx->phpass->HashPassword($newpassword); |
| 246 | 246 | } |
| 247 | 247 | $modx->db->update($field, $tbl_manager_users, "id='{$id}'"); |
@@ -269,7 +269,7 @@ discard block |
||
| 269 | 269 | )); |
| 270 | 270 | |
| 271 | 271 | // invoke OnManagerChangePassword event |
| 272 | - if($genpassword == 1) { |
|
| 272 | + if ($genpassword == 1) { |
|
| 273 | 273 | $modx->invokeEvent("OnManagerChangePassword", array( |
| 274 | 274 | "userid" => $id, |
| 275 | 275 | "username" => $newusername, |
@@ -286,13 +286,13 @@ discard block |
||
| 286 | 286 | /*******************************************************************************/ |
| 287 | 287 | // put the user in the user_groups he/ she should be in |
| 288 | 288 | // first, check that up_perms are switched on! |
| 289 | - if($use_udperms == 1) { |
|
| 289 | + if ($use_udperms == 1) { |
|
| 290 | 290 | // as this is an existing user, delete his/ her entries in the groups before saving the new groups |
| 291 | 291 | $modx->db->delete($tbl_member_groups, "member='{$id}'"); |
| 292 | - if(!empty($user_groups)) { |
|
| 293 | - for($i = 0; $i < count($user_groups); $i++) { |
|
| 292 | + if (!empty($user_groups)) { |
|
| 293 | + for ($i = 0; $i < count($user_groups); $i++) { |
|
| 294 | 294 | $field = array(); |
| 295 | - $field['user_group'] = (int)$user_groups[$i]; |
|
| 295 | + $field['user_group'] = (int) $user_groups[$i]; |
|
| 296 | 296 | $field['member'] = $id; |
| 297 | 297 | $modx->db->insert($field, $tbl_member_groups); |
| 298 | 298 | } |
@@ -300,13 +300,13 @@ discard block |
||
| 300 | 300 | } |
| 301 | 301 | // end of user_groups stuff! |
| 302 | 302 | /*******************************************************************************/ |
| 303 | - if($id == $modx->getLoginUserID() && ($genpassword !== 1 && $passwordnotifymethod != 's')) { |
|
| 303 | + if ($id == $modx->getLoginUserID() && ($genpassword !== 1 && $passwordnotifymethod != 's')) { |
|
| 304 | 304 | $modx->webAlertAndQuit($_lang["user_changeddata"], 'javascript:top.location.href="index.php?a=8";'); |
| 305 | 305 | } |
| 306 | - if($genpassword == 1 && $passwordnotifymethod == 's') { |
|
| 307 | - if($input['stay'] != '') { |
|
| 306 | + if ($genpassword == 1 && $passwordnotifymethod == 's') { |
|
| 307 | + if ($input['stay'] != '') { |
|
| 308 | 308 | $a = ($input['stay'] == '2') ? "12&id={$id}" : "11"; |
| 309 | - $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 309 | + $stayUrl = "index.php?a={$a}&r=2&stay=".$input['stay']; |
|
| 310 | 310 | } else { |
| 311 | 311 | $stayUrl = "index.php?a=75&r=2"; |
| 312 | 312 | } |
@@ -326,7 +326,7 @@ discard block |
||
| 326 | 326 | <div class="sectionHeader"><?php echo $_lang['user_title']; ?></div> |
| 327 | 327 | <div class="sectionBody"> |
| 328 | 328 | <div id="disp"> |
| 329 | - <p><?php echo sprintf($_lang["password_msg"], $modx->htmlspecialchars($newusername), $modx->htmlspecialchars($newpassword)) . (($id == $modx->getLoginUserID()) ? ' ' . $_lang['user_changeddata'] : ''); ?></p> |
|
| 329 | + <p><?php echo sprintf($_lang["password_msg"], $modx->htmlspecialchars($newusername), $modx->htmlspecialchars($newpassword)).(($id == $modx->getLoginUserID()) ? ' '.$_lang['user_changeddata'] : ''); ?></p> |
|
| 330 | 330 | </div> |
| 331 | 331 | </div> |
| 332 | 332 | </div> |
@@ -334,9 +334,9 @@ discard block |
||
| 334 | 334 | |
| 335 | 335 | include_once "footer.inc.php"; |
| 336 | 336 | } else { |
| 337 | - if($input['stay'] != '') { |
|
| 337 | + if ($input['stay'] != '') { |
|
| 338 | 338 | $a = ($input['stay'] == '2') ? "12&id={$id}" : "11"; |
| 339 | - $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 339 | + $header = "Location: index.php?a={$a}&r=2&stay=".$input['stay']; |
|
| 340 | 340 | header($header); |
| 341 | 341 | } else { |
| 342 | 342 | $header = "Location: index.php?a=75&r=2"; |
@@ -356,7 +356,7 @@ discard block |
||
| 356 | 356 | * @param string $pwd |
| 357 | 357 | * @param string $ufn |
| 358 | 358 | */ |
| 359 | -function sendMailMessage($email, $uid, $pwd, $ufn) { |
|
| 359 | +function sendMailMessage($email, $uid, $pwd, $ufn){ |
|
| 360 | 360 | $modx = evolutionCMS(); global $_lang, $signupemail_message; |
| 361 | 361 | global $emailsubject, $emailsender; |
| 362 | 362 | global $site_name; |
@@ -378,7 +378,7 @@ discard block |
||
| 378 | 378 | $param['to'] = $email; |
| 379 | 379 | $param['type'] = 'text'; |
| 380 | 380 | $rs = $modx->sendmail($param); |
| 381 | - if(!$rs) { |
|
| 381 | + if (!$rs) { |
|
| 382 | 382 | $modx->manager->saveFormValues(); |
| 383 | 383 | $modx->messageQuit("{$email} - {$_lang['error_sending_email']}"); |
| 384 | 384 | } |
@@ -389,7 +389,7 @@ discard block |
||
| 389 | 389 | * |
| 390 | 390 | * @param int $id |
| 391 | 391 | */ |
| 392 | -function saveUserSettings($id) { |
|
| 392 | +function saveUserSettings($id){ |
|
| 393 | 393 | $modx = evolutionCMS(); |
| 394 | 394 | $tbl_user_settings = $modx->getFullTableName('user_settings'); |
| 395 | 395 | |
@@ -441,27 +441,27 @@ discard block |
||
| 441 | 441 | |
| 442 | 442 | // get user setting field names |
| 443 | 443 | $settings = array(); |
| 444 | - foreach($_POST as $n => $v) { |
|
| 445 | - if(in_array($n, $ignore) || (!in_array($n, $defaults) && is_scalar($v) && trim($v) == '') || (!in_array($n, $defaults) && is_array($v) && empty($v))) { |
|
| 444 | + foreach ($_POST as $n => $v) { |
|
| 445 | + if (in_array($n, $ignore) || (!in_array($n, $defaults) && is_scalar($v) && trim($v) == '') || (!in_array($n, $defaults) && is_array($v) && empty($v))) { |
|
| 446 | 446 | continue; |
| 447 | 447 | } // ignore blacklist and empties |
| 448 | 448 | $settings[$n] = $v; // this value should be saved |
| 449 | 449 | } |
| 450 | 450 | |
| 451 | - foreach($defaults as $k) { |
|
| 452 | - if(isset($settings['default_' . $k]) && $settings['default_' . $k] == '1') { |
|
| 451 | + foreach ($defaults as $k) { |
|
| 452 | + if (isset($settings['default_'.$k]) && $settings['default_'.$k] == '1') { |
|
| 453 | 453 | unset($settings[$k]); |
| 454 | 454 | } |
| 455 | - unset($settings['default_' . $k]); |
|
| 455 | + unset($settings['default_'.$k]); |
|
| 456 | 456 | } |
| 457 | 457 | |
| 458 | 458 | $modx->db->delete($tbl_user_settings, "user='{$id}'"); |
| 459 | 459 | |
| 460 | - foreach($settings as $n => $vl) { |
|
| 461 | - if(is_array($vl)) { |
|
| 460 | + foreach ($settings as $n => $vl) { |
|
| 461 | + if (is_array($vl)) { |
|
| 462 | 462 | $vl = implode(",", $vl); |
| 463 | 463 | } |
| 464 | - if($vl != '') { |
|
| 464 | + if ($vl != '') { |
|
| 465 | 465 | $f = array(); |
| 466 | 466 | $f['user'] = $id; |
| 467 | 467 | $f['setting_name'] = $n; |
@@ -477,11 +477,11 @@ discard block |
||
| 477 | 477 | * |
| 478 | 478 | * @param $msg |
| 479 | 479 | */ |
| 480 | -function webAlertAndQuit($msg) { |
|
| 480 | +function webAlertAndQuit($msg){ |
|
| 481 | 481 | global $id, $modx; |
| 482 | 482 | $mode = $_POST['mode']; |
| 483 | 483 | $modx->manager->saveFormValues($mode); |
| 484 | - $modx->webAlertAndQuit($msg, "index.php?a={$mode}" . ($mode == '12' ? "&id={$id}" : '')); |
|
| 484 | + $modx->webAlertAndQuit($msg, "index.php?a={$mode}".($mode == '12' ? "&id={$id}" : '')); |
|
| 485 | 485 | } |
| 486 | 486 | |
| 487 | 487 | /** |
@@ -490,12 +490,12 @@ discard block |
||
| 490 | 490 | * @param int $length |
| 491 | 491 | * @return string |
| 492 | 492 | */ |
| 493 | -function generate_password($length = 10) { |
|
| 493 | +function generate_password($length = 10){ |
|
| 494 | 494 | $allowable_characters = "abcdefghjkmnpqrstuvxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789"; |
| 495 | 495 | $ps_len = strlen($allowable_characters); |
| 496 | 496 | mt_srand((double) microtime() * 1000000); |
| 497 | 497 | $pass = ""; |
| 498 | - for($i = 0; $i < $length; $i++) { |
|
| 498 | + for ($i = 0; $i < $length; $i++) { |
|
| 499 | 499 | $pass .= $allowable_characters[mt_rand(0, $ps_len - 1)]; |
| 500 | 500 | } |
| 501 | 501 | return $pass; |
@@ -356,7 +356,8 @@ discard block |
||
| 356 | 356 | * @param string $pwd |
| 357 | 357 | * @param string $ufn |
| 358 | 358 | */ |
| 359 | -function sendMailMessage($email, $uid, $pwd, $ufn) { |
|
| 359 | +function sendMailMessage($email, $uid, $pwd, $ufn) |
|
| 360 | +{ |
|
| 360 | 361 | $modx = evolutionCMS(); global $_lang, $signupemail_message; |
| 361 | 362 | global $emailsubject, $emailsender; |
| 362 | 363 | global $site_name; |
@@ -389,7 +390,8 @@ discard block |
||
| 389 | 390 | * |
| 390 | 391 | * @param int $id |
| 391 | 392 | */ |
| 392 | -function saveUserSettings($id) { |
|
| 393 | +function saveUserSettings($id) |
|
| 394 | +{ |
|
| 393 | 395 | $modx = evolutionCMS(); |
| 394 | 396 | $tbl_user_settings = $modx->getFullTableName('user_settings'); |
| 395 | 397 | |
@@ -477,7 +479,8 @@ discard block |
||
| 477 | 479 | * |
| 478 | 480 | * @param $msg |
| 479 | 481 | */ |
| 480 | -function webAlertAndQuit($msg) { |
|
| 482 | +function webAlertAndQuit($msg) |
|
| 483 | +{ |
|
| 481 | 484 | global $id, $modx; |
| 482 | 485 | $mode = $_POST['mode']; |
| 483 | 486 | $modx->manager->saveFormValues($mode); |
@@ -490,7 +493,8 @@ discard block |
||
| 490 | 493 | * @param int $length |
| 491 | 494 | * @return string |
| 492 | 495 | */ |
| 493 | -function generate_password($length = 10) { |
|
| 496 | +function generate_password($length = 10) |
|
| 497 | +{ |
|
| 494 | 498 | $allowable_characters = "abcdefghjkmnpqrstuvxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789"; |
| 495 | 499 | $ps_len = strlen($allowable_characters); |
| 496 | 500 | mt_srand((double) microtime() * 1000000); |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | if (isset($this->aliases[$id])) { |
| 95 | 95 | if ($this->aliasVisible[$id] == 1) { |
| 96 | 96 | if ($path != '') { |
| 97 | - $path = $this->aliases[$id] . '/' . $path; |
|
| 97 | + $path = $this->aliases[$id].'/'.$path; |
|
| 98 | 98 | } else { |
| 99 | 99 | $path = $this->aliases[$id]; |
| 100 | 100 | } |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | $modx->messageQuit("Cache path not set."); |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | - $files = glob(realpath($this->cachePath) . '/*.pageCache.php'); |
|
| 121 | + $files = glob(realpath($this->cachePath).'/*.pageCache.php'); |
|
| 122 | 122 | $filesincache = count($files); |
| 123 | 123 | $deletedfiles = array(); |
| 124 | 124 | while ($file = array_shift($files)) { |
@@ -151,9 +151,9 @@ discard block |
||
| 151 | 151 | if (isset($opcache)) { |
| 152 | 152 | echo '<p>Opcache empty.</p>'; |
| 153 | 153 | } |
| 154 | - echo '<p>' . $_lang['cache_files_deleted'] . '</p><ul>'; |
|
| 154 | + echo '<p>'.$_lang['cache_files_deleted'].'</p><ul>'; |
|
| 155 | 155 | foreach ($deletedfiles as $deletedfile) { |
| 156 | - echo '<li>' . $deletedfile . '</li>'; |
|
| 156 | + echo '<li>'.$deletedfile.'</li>'; |
|
| 157 | 157 | } |
| 158 | 158 | echo '</ul>'; |
| 159 | 159 | } |
@@ -172,11 +172,11 @@ discard block |
||
| 172 | 172 | |
| 173 | 173 | |
| 174 | 174 | // write the file |
| 175 | - $content = '<?php' . "\n"; |
|
| 176 | - $content .= '$recent_update=\'' . $this->request_time . '\';' . "\n"; |
|
| 177 | - $content .= '$cacheRefreshTime=\'' . $cacheRefreshTime . '\';' . "\n"; |
|
| 175 | + $content = '<?php'."\n"; |
|
| 176 | + $content .= '$recent_update=\''.$this->request_time.'\';'."\n"; |
|
| 177 | + $content .= '$cacheRefreshTime=\''.$cacheRefreshTime.'\';'."\n"; |
|
| 178 | 178 | |
| 179 | - $filename = $this->cachePath . '/sitePublishing.idx.php'; |
|
| 179 | + $filename = $this->cachePath.'/sitePublishing.idx.php'; |
|
| 180 | 180 | if (!$handle = fopen($filename, 'w')) { |
| 181 | 181 | exit("Cannot open file ({$filename}"); |
| 182 | 182 | } |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | $timesArr = array(); |
| 201 | 201 | |
| 202 | 202 | $result = $modx->db->select('MIN(pub_date) AS minpub', '[+prefix+]site_content', |
| 203 | - 'pub_date>' . $this->request_time); |
|
| 203 | + 'pub_date>'.$this->request_time); |
|
| 204 | 204 | if (!$result) { |
| 205 | 205 | echo "Couldn't determine next publish event!"; |
| 206 | 206 | } |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | $result = $modx->db->select('MIN(unpub_date) AS minunpub', '[+prefix+]site_content', |
| 214 | - 'unpub_date>' . $this->request_time); |
|
| 214 | + 'unpub_date>'.$this->request_time); |
|
| 215 | 215 | if (!$result) { |
| 216 | 216 | echo "Couldn't determine next unpublish event!"; |
| 217 | 217 | } |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | $config = array(); |
| 251 | 251 | $content .= '$c=&$this->config;'; |
| 252 | 252 | while (list($key, $value) = $modx->db->getRow($rs, 'num')) { |
| 253 | - $content .= '$c[\'' . $key . '\']="' . $this->escapeDoubleQuotes($value) . '";'; |
|
| 253 | + $content .= '$c[\''.$key.'\']="'.$this->escapeDoubleQuotes($value).'";'; |
|
| 254 | 254 | $config[$key] = $value; |
| 255 | 255 | } |
| 256 | 256 | |
@@ -288,23 +288,23 @@ discard block |
||
| 288 | 288 | $docid = $doc['id']; |
| 289 | 289 | if ($use_alias_path) { |
| 290 | 290 | $tmpPath = $this->getParents($doc['parent']); |
| 291 | - $alias = (strlen($tmpPath) > 0 ? "$tmpPath/" : '') . $doc['alias']; |
|
| 291 | + $alias = (strlen($tmpPath) > 0 ? "$tmpPath/" : '').$doc['alias']; |
|
| 292 | 292 | $key = $alias; |
| 293 | 293 | } else { |
| 294 | 294 | $key = $doc['alias']; |
| 295 | 295 | } |
| 296 | 296 | |
| 297 | 297 | $doc['path'] = $tmpPath; |
| 298 | - $content .= '$a[' . $docid . ']=array(\'id\'=>' . $docid . ',\'alias\'=>\'' . $doc['alias'] . '\',\'path\'=>\'' . $doc['path'] . '\',\'parent\'=>' . $doc['parent'] . ',\'isfolder\'=>' . $doc['isfolder'] . ',\'alias_visible\'=>' . $doc['alias_visible'] . ');'; |
|
| 299 | - $content .= '$d[\'' . $key . '\']=' . $docid . ';'; |
|
| 300 | - $content .= '$m[]=array(' . $doc['parent'] . '=>' . $docid . ');'; |
|
| 298 | + $content .= '$a['.$docid.']=array(\'id\'=>'.$docid.',\'alias\'=>\''.$doc['alias'].'\',\'path\'=>\''.$doc['path'].'\',\'parent\'=>'.$doc['parent'].',\'isfolder\'=>'.$doc['isfolder'].',\'alias_visible\'=>'.$doc['alias_visible'].');'; |
|
| 299 | + $content .= '$d[\''.$key.'\']='.$docid.';'; |
|
| 300 | + $content .= '$m[]=array('.$doc['parent'].'=>'.$docid.');'; |
|
| 301 | 301 | } |
| 302 | 302 | |
| 303 | 303 | // get content types |
| 304 | 304 | $rs = $modx->db->select('id, contentType', '[+prefix+]site_content', "contentType!='text/html'"); |
| 305 | 305 | $content .= '$c=&$this->contentTypes;'; |
| 306 | 306 | while ($doc = $modx->db->getRow($rs)) { |
| 307 | - $content .= '$c[\'' . $doc['id'] . '\']=\'' . $doc['contentType'] . '\';'; |
|
| 307 | + $content .= '$c[\''.$doc['id'].'\']=\''.$doc['contentType'].'\';'; |
|
| 308 | 308 | } |
| 309 | 309 | |
| 310 | 310 | // WRITE Chunks to cache file |
@@ -314,7 +314,7 @@ discard block |
||
| 314 | 314 | if ($modx->config['minifyphp_incache']) { |
| 315 | 315 | $doc['snippet'] = $this->php_strip_whitespace($doc['snippet']); |
| 316 | 316 | } |
| 317 | - $content .= '$c[\'' . $doc['name'] . '\']=\'' . ($doc['disabled'] ? '' : $this->escapeSingleQuotes($doc['snippet'])) . '\';'; |
|
| 317 | + $content .= '$c[\''.$doc['name'].'\']=\''.($doc['disabled'] ? '' : $this->escapeSingleQuotes($doc['snippet'])).'\';'; |
|
| 318 | 318 | } |
| 319 | 319 | |
| 320 | 320 | // WRITE snippets to cache file |
@@ -325,18 +325,18 @@ discard block |
||
| 325 | 325 | while ($row = $modx->db->getRow($rs)) { |
| 326 | 326 | $key = $row['name']; |
| 327 | 327 | if ($row['disabled']) { |
| 328 | - $content .= '$s[\'' . $key . '\']=\'return false;\';'; |
|
| 328 | + $content .= '$s[\''.$key.'\']=\'return false;\';'; |
|
| 329 | 329 | } else { |
| 330 | 330 | $value = trim($row['snippet']); |
| 331 | 331 | if ($modx->config['minifyphp_incache']) { |
| 332 | 332 | $value = $this->php_strip_whitespace($value); |
| 333 | 333 | } |
| 334 | - $content .= '$s[\'' . $key . '\']=\'' . $this->escapeSingleQuotes($value) . '\';'; |
|
| 334 | + $content .= '$s[\''.$key.'\']=\''.$this->escapeSingleQuotes($value).'\';'; |
|
| 335 | 335 | $properties = $modx->parseProperties($row['properties']); |
| 336 | 336 | $sharedproperties = $modx->parseProperties($row['sharedproperties']); |
| 337 | 337 | $properties = array_merge($sharedproperties, $properties); |
| 338 | 338 | if (0 < count($properties)) { |
| 339 | - $content .= '$s[\'' . $key . 'Props\']=\'' . $this->escapeSingleQuotes(json_encode($properties)) . '\';'; |
|
| 339 | + $content .= '$s[\''.$key.'Props\']=\''.$this->escapeSingleQuotes(json_encode($properties)).'\';'; |
|
| 340 | 340 | } |
| 341 | 341 | } |
| 342 | 342 | } |
@@ -354,13 +354,13 @@ discard block |
||
| 354 | 354 | if ($modx->config['minifyphp_incache']) { |
| 355 | 355 | $value = $this->php_strip_whitespace($value); |
| 356 | 356 | } |
| 357 | - $content .= '$p[\'' . $key . '\']=\'' . $this->escapeSingleQuotes($value) . '\';'; |
|
| 357 | + $content .= '$p[\''.$key.'\']=\''.$this->escapeSingleQuotes($value).'\';'; |
|
| 358 | 358 | if ($row['properties'] != '' || $row['sharedproperties'] != '') { |
| 359 | 359 | $properties = $modx->parseProperties($row['properties']); |
| 360 | 360 | $sharedproperties = $modx->parseProperties($row['sharedproperties']); |
| 361 | 361 | $properties = array_merge($sharedproperties, $properties); |
| 362 | 362 | if (0 < count($properties)) { |
| 363 | - $content .= '$p[\'' . $key . 'Props\']=\'' . $this->escapeSingleQuotes(json_encode($properties)) . '\';'; |
|
| 363 | + $content .= '$p[\''.$key.'Props\']=\''.$this->escapeSingleQuotes(json_encode($properties)).'\';'; |
|
| 364 | 364 | } |
| 365 | 365 | } |
| 366 | 366 | } |
@@ -383,14 +383,14 @@ discard block |
||
| 383 | 383 | } |
| 384 | 384 | foreach ($events as $evtname => $pluginnames) { |
| 385 | 385 | $events[$evtname] = $pluginnames; |
| 386 | - $content .= '$e[\'' . $evtname . '\']=array(\'' . implode('\',\'', |
|
| 387 | - $this->escapeSingleQuotes($pluginnames)) . '\');'; |
|
| 386 | + $content .= '$e[\''.$evtname.'\']=array(\''.implode('\',\'', |
|
| 387 | + $this->escapeSingleQuotes($pluginnames)).'\');'; |
|
| 388 | 388 | } |
| 389 | 389 | |
| 390 | 390 | $content .= "\n"; |
| 391 | 391 | |
| 392 | 392 | // close and write the file |
| 393 | - $filename = $this->cachePath . 'siteCache.idx.php'; |
|
| 393 | + $filename = $this->cachePath.'siteCache.idx.php'; |
|
| 394 | 394 | |
| 395 | 395 | // invoke OnBeforeCacheUpdate event |
| 396 | 396 | if ($modx) { |
@@ -401,8 +401,8 @@ discard block |
||
| 401 | 401 | exit("Cannot write main MODX cache file! Make sure the assets/cache directory is writable!"); |
| 402 | 402 | } |
| 403 | 403 | |
| 404 | - if (!is_file($this->cachePath . '/.htaccess')) { |
|
| 405 | - file_put_contents($this->cachePath . '/.htaccess', "order deny,allow\ndeny from all\n"); |
|
| 404 | + if (!is_file($this->cachePath.'/.htaccess')) { |
|
| 405 | + file_put_contents($this->cachePath.'/.htaccess', "order deny,allow\ndeny from all\n"); |
|
| 406 | 406 | } |
| 407 | 407 | |
| 408 | 408 | // invoke OnCacheUpdate event |
@@ -424,7 +424,7 @@ discard block |
||
| 424 | 424 | |
| 425 | 425 | $source = trim($source); |
| 426 | 426 | if (substr($source, 0, 5) !== '<?php') { |
| 427 | - $source = '<?php ' . $source; |
|
| 427 | + $source = '<?php '.$source; |
|
| 428 | 428 | } |
| 429 | 429 | |
| 430 | 430 | $tokens = token_get_all($source); |
@@ -482,7 +482,7 @@ discard block |
||
| 482 | 482 | } |
| 483 | 483 | } |
| 484 | 484 | $source = preg_replace(array('@^<\?php@i', '|\s+|', '|<!--|', '|-->|', '|-->\s+<!--|'), |
| 485 | - array('', ' ', "\n" . '<!--', '-->' . "\n", '-->' . "\n" . '<!--'), $_); |
|
| 485 | + array('', ' ', "\n".'<!--', '-->'."\n", '-->'."\n".'<!--'), $_); |
|
| 486 | 486 | $source = trim($source); |
| 487 | 487 | |
| 488 | 488 | return $source; |
@@ -3,12 +3,12 @@ discard block |
||
| 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('new_module')) { |
| 6 | - $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 6 | + $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 7 | 7 | } |
| 8 | 8 | |
| 9 | 9 | $id = isset($_GET['id'])? (int)$_GET['id'] : 0; |
| 10 | 10 | if($id==0) { |
| 11 | - $modx->webAlertAndQuit($_lang["error_no_id"]); |
|
| 11 | + $modx->webAlertAndQuit($_lang["error_no_id"]); |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | /** |
@@ -17,11 +17,11 @@ discard block |
||
| 17 | 17 | * @return string |
| 18 | 18 | */ |
| 19 | 19 | function createGUID(){ |
| 20 | - srand((double)microtime()*1000000); |
|
| 21 | - $r = rand() ; |
|
| 22 | - $u = uniqid(getmypid() . $r . (double)microtime()*1000000,1); |
|
| 23 | - $m = md5 ($u); |
|
| 24 | - return $m; |
|
| 20 | + srand((double)microtime()*1000000); |
|
| 21 | + $r = rand() ; |
|
| 22 | + $u = uniqid(getmypid() . $r . (double)microtime()*1000000,1); |
|
| 23 | + $m = md5 ($u); |
|
| 24 | + return $m; |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | // count duplicates |
@@ -32,40 +32,40 @@ discard block |
||
| 32 | 32 | |
| 33 | 33 | // duplicate module |
| 34 | 34 | $newid = $modx->db->insert( |
| 35 | - array( |
|
| 36 | - 'name'=>'', |
|
| 37 | - 'description'=>'', |
|
| 38 | - 'disabled'=>'', |
|
| 39 | - 'category'=>'', |
|
| 40 | - 'wrap'=>'', |
|
| 41 | - 'icon'=>'', |
|
| 42 | - 'enable_resource'=>'', |
|
| 43 | - 'resourcefile'=>'', |
|
| 44 | - 'createdon'=>'', |
|
| 45 | - 'editedon'=>'', |
|
| 46 | - 'guid'=>'', |
|
| 47 | - 'enable_sharedparams'=>'', |
|
| 48 | - 'properties'=>'', |
|
| 49 | - 'modulecode'=>'', |
|
| 50 | - ), $modx->getFullTableName('site_modules'), // Insert into |
|
| 51 | - "CONCAT(name, ' {$_lang['duplicated_el_suffix']}{$count}') AS name, description, '1' AS disabled, category, wrap, icon, enable_resource, resourcefile, createdon, editedon, '".createGUID()."' AS guid, enable_sharedparams, properties, modulecode", $modx->getFullTableName('site_modules'), "id='{$id}'"); // Copy from |
|
| 35 | + array( |
|
| 36 | + 'name'=>'', |
|
| 37 | + 'description'=>'', |
|
| 38 | + 'disabled'=>'', |
|
| 39 | + 'category'=>'', |
|
| 40 | + 'wrap'=>'', |
|
| 41 | + 'icon'=>'', |
|
| 42 | + 'enable_resource'=>'', |
|
| 43 | + 'resourcefile'=>'', |
|
| 44 | + 'createdon'=>'', |
|
| 45 | + 'editedon'=>'', |
|
| 46 | + 'guid'=>'', |
|
| 47 | + 'enable_sharedparams'=>'', |
|
| 48 | + 'properties'=>'', |
|
| 49 | + 'modulecode'=>'', |
|
| 50 | + ), $modx->getFullTableName('site_modules'), // Insert into |
|
| 51 | + "CONCAT(name, ' {$_lang['duplicated_el_suffix']}{$count}') AS name, description, '1' AS disabled, category, wrap, icon, enable_resource, resourcefile, createdon, editedon, '".createGUID()."' AS guid, enable_sharedparams, properties, modulecode", $modx->getFullTableName('site_modules'), "id='{$id}'"); // Copy from |
|
| 52 | 52 | |
| 53 | 53 | // duplicate module dependencies |
| 54 | 54 | $modx->db->insert( |
| 55 | - array( |
|
| 56 | - 'module'=>'', |
|
| 57 | - 'resource'=>'', |
|
| 58 | - 'type'=>'', |
|
| 59 | - ), $modx->getFullTableName('site_module_depobj'), // Insert into |
|
| 60 | - "'{$newid}', resource, type", $modx->getFullTableName('site_module_depobj'), "module='{$id}'"); // Copy from |
|
| 55 | + array( |
|
| 56 | + 'module'=>'', |
|
| 57 | + 'resource'=>'', |
|
| 58 | + 'type'=>'', |
|
| 59 | + ), $modx->getFullTableName('site_module_depobj'), // Insert into |
|
| 60 | + "'{$newid}', resource, type", $modx->getFullTableName('site_module_depobj'), "module='{$id}'"); // Copy from |
|
| 61 | 61 | |
| 62 | 62 | // duplicate module user group access |
| 63 | 63 | $modx->db->insert( |
| 64 | - array( |
|
| 65 | - 'module'=>'', |
|
| 66 | - 'usergroup'=>'', |
|
| 67 | - ), $modx->getFullTableName('site_module_access'), // Insert into |
|
| 68 | - "'{$newid}', usergroup", $modx->getFullTableName('site_module_access'), "module='{$id}'"); // Copy from |
|
| 64 | + array( |
|
| 65 | + 'module'=>'', |
|
| 66 | + 'usergroup'=>'', |
|
| 67 | + ), $modx->getFullTableName('site_module_access'), // Insert into |
|
| 68 | + "'{$newid}', usergroup", $modx->getFullTableName('site_module_access'), "module='{$id}'"); // Copy from |
|
| 69 | 69 | |
| 70 | 70 | // Set the item name for logger |
| 71 | 71 | $name = $modx->db->getValue($modx->db->select('name', $modx->getFullTableName('site_modules'), "id='{$newid}'")); |
@@ -1,13 +1,13 @@ 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('new_module')) { |
|
| 5 | +if (!$modx->hasPermission('new_module')) { |
|
| 6 | 6 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
| 7 | 7 | } |
| 8 | 8 | |
| 9 | -$id = isset($_GET['id'])? (int)$_GET['id'] : 0; |
|
| 10 | -if($id==0) { |
|
| 9 | +$id = isset($_GET['id']) ? (int) $_GET['id'] : 0; |
|
| 10 | +if ($id == 0) { |
|
| 11 | 11 | $modx->webAlertAndQuit($_lang["error_no_id"]); |
| 12 | 12 | } |
| 13 | 13 | |
@@ -17,17 +17,17 @@ discard block |
||
| 17 | 17 | * @return string |
| 18 | 18 | */ |
| 19 | 19 | function createGUID(){ |
| 20 | - srand((double)microtime()*1000000); |
|
| 21 | - $r = rand() ; |
|
| 22 | - $u = uniqid(getmypid() . $r . (double)microtime()*1000000,1); |
|
| 23 | - $m = md5 ($u); |
|
| 20 | + srand((double) microtime() * 1000000); |
|
| 21 | + $r = rand(); |
|
| 22 | + $u = uniqid(getmypid().$r.(double) microtime() * 1000000, 1); |
|
| 23 | + $m = md5($u); |
|
| 24 | 24 | return $m; |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | // count duplicates |
| 28 | 28 | $name = $modx->db->getValue($modx->db->select('name', $modx->getFullTableName('site_modules'), "id='{$id}'")); |
| 29 | 29 | $count = $modx->db->getRecordCount($modx->db->select('name', $modx->getFullTableName('site_modules'), "name LIKE '{$name} {$_lang['duplicated_el_suffix']}%'")); |
| 30 | -if($count>=1) $count = ' '.($count+1); |
|
| 30 | +if ($count >= 1) $count = ' '.($count + 1); |
|
| 31 | 31 | else $count = ''; |
| 32 | 32 | |
| 33 | 33 | // duplicate module |
@@ -72,5 +72,5 @@ discard block |
||
| 72 | 72 | $_SESSION['itemname'] = $name; |
| 73 | 73 | |
| 74 | 74 | // finish duplicating - redirect to new module |
| 75 | -$header="Location: index.php?r=2&a=108&id=$newid"; |
|
| 75 | +$header = "Location: index.php?r=2&a=108&id=$newid"; |
|
| 76 | 76 | header($header); |
@@ -16,7 +16,8 @@ discard block |
||
| 16 | 16 | * |
| 17 | 17 | * @return string |
| 18 | 18 | */ |
| 19 | -function createGUID(){ |
|
| 19 | +function createGUID() |
|
| 20 | +{ |
|
| 20 | 21 | srand((double)microtime()*1000000); |
| 21 | 22 | $r = rand() ; |
| 22 | 23 | $u = uniqid(getmypid() . $r . (double)microtime()*1000000,1); |
@@ -27,8 +28,11 @@ discard block |
||
| 27 | 28 | // count duplicates |
| 28 | 29 | $name = $modx->db->getValue($modx->db->select('name', $modx->getFullTableName('site_modules'), "id='{$id}'")); |
| 29 | 30 | $count = $modx->db->getRecordCount($modx->db->select('name', $modx->getFullTableName('site_modules'), "name LIKE '{$name} {$_lang['duplicated_el_suffix']}%'")); |
| 30 | -if($count>=1) $count = ' '.($count+1); |
|
| 31 | -else $count = ''; |
|
| 31 | +if($count>=1) { |
|
| 32 | + $count = ' '.($count+1); |
|
| 33 | +} else { |
|
| 34 | + $count = ''; |
|
| 35 | +} |
|
| 32 | 36 | |
| 33 | 37 | // duplicate module |
| 34 | 38 | $newid = $modx->db->insert( |
@@ -1,25 +1,25 @@ 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('delete_document')) { |
| 6 | 6 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
| 7 | 7 | } |
| 8 | 8 | |
| 9 | -$id = isset($_GET['id'])? (int)$_GET['id'] : 0; |
|
| 10 | -if ($id==0) { |
|
| 9 | +$id = isset($_GET['id']) ? (int) $_GET['id'] : 0; |
|
| 10 | +if ($id == 0) { |
|
| 11 | 11 | $modx->webAlertAndQuit($_lang["error_no_id"]); |
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | /*******ищем родителя чтобы к нему вернуться********/ |
| 15 | -$content=$modx->db->getRow($modx->db->select('parent, pagetitle', $modx->getFullTableName('site_content'), "id='{$id}'")); |
|
| 16 | -$pid=($content['parent']==0?$id:$content['parent']); |
|
| 15 | +$content = $modx->db->getRow($modx->db->select('parent, pagetitle', $modx->getFullTableName('site_content'), "id='{$id}'")); |
|
| 16 | +$pid = ($content['parent'] == 0 ? $id : $content['parent']); |
|
| 17 | 17 | |
| 18 | 18 | /************ а заодно и путь возврата (сам путь внизу файла) **********/ |
| 19 | -$sd=isset($_REQUEST['dir'])?'&dir='.$_REQUEST['dir']:'&dir=DESC'; |
|
| 20 | -$sb=isset($_REQUEST['sort'])?'&sort='.$_REQUEST['sort']:'&sort=createdon'; |
|
| 21 | -$pg=isset($_REQUEST['page'])?'&page='.(int)$_REQUEST['page']:''; |
|
| 22 | -$add_path=$sd.$sb.$pg; |
|
| 19 | +$sd = isset($_REQUEST['dir']) ? '&dir='.$_REQUEST['dir'] : '&dir=DESC'; |
|
| 20 | +$sb = isset($_REQUEST['sort']) ? '&sort='.$_REQUEST['sort'] : '&sort=createdon'; |
|
| 21 | +$pg = isset($_REQUEST['page']) ? '&page='.(int) $_REQUEST['page'] : ''; |
|
| 22 | +$add_path = $sd.$sb.$pg; |
|
| 23 | 23 | |
| 24 | 24 | /*****************************/ |
| 25 | 25 | |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | $children = array(); |
| 28 | 28 | |
| 29 | 29 | // check permissions on the document |
| 30 | -include_once MODX_MANAGER_PATH . "processors/user_documents_permissions.class.php"; |
|
| 30 | +include_once MODX_MANAGER_PATH."processors/user_documents_permissions.class.php"; |
|
| 31 | 31 | $udperms = new udperms(); |
| 32 | 32 | $udperms->user = $modx->getLoginUserID(); |
| 33 | 33 | $udperms->document = $id; |
@@ -52,17 +52,17 @@ discard block |
||
| 52 | 52 | $parent = $modx->db->escape($parent); |
| 53 | 53 | $rs = $modx->db->select('id', $modx->getFullTableName('site_content'), "parent={$parent} AND deleted=0"); |
| 54 | 54 | // the document has children documents, we'll need to delete those too |
| 55 | - while ($childid=$modx->db->getValue($rs)) { |
|
| 56 | - if ($childid==$site_start) { |
|
| 55 | + while ($childid = $modx->db->getValue($rs)) { |
|
| 56 | + if ($childid == $site_start) { |
|
| 57 | 57 | $modx->webAlertAndQuit("The document you are trying to delete is a folder containing document {$childid}. This document is registered as the 'Site start' document, and cannot be deleted. Please assign another document as your 'Site start' document and try again."); |
| 58 | 58 | } |
| 59 | - if ($childid==$site_unavailable_page) { |
|
| 59 | + if ($childid == $site_unavailable_page) { |
|
| 60 | 60 | $modx->webAlertAndQuit("The document you are trying to delete is a folder containing document {$childid}. This document is registered as the 'Site unavailable page' document, and cannot be deleted. Please assign another document as your 'Site unavailable page' document and try again."); |
| 61 | 61 | } |
| 62 | - if ($childid==$error_page) { |
|
| 62 | + if ($childid == $error_page) { |
|
| 63 | 63 | $modx->webAlertAndQuit("The document you are trying to delete is a folder containing document {$childid}. This document is registered as the 'Site error page' document, and cannot be deleted. Please assign another document as your 'Site error page' document and try again."); |
| 64 | 64 | } |
| 65 | - if ($childid==$unauthorized_page) { |
|
| 65 | + if ($childid == $unauthorized_page) { |
|
| 66 | 66 | $modx->webAlertAndQuit("The document you are trying to delete is a folder containing document {$childid}. This document is registered as the 'Site unauthorized page' document, and cannot be deleted. Please assign another document as your 'Site unauthorized page' document and try again."); |
| 67 | 67 | } |
| 68 | 68 | $children[] = $childid; |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | "children"=>$children |
| 81 | 81 | )); |
| 82 | 82 | |
| 83 | -if (count($children)>0) { |
|
| 83 | +if (count($children) > 0) { |
|
| 84 | 84 | $modx->db->update( |
| 85 | 85 | array( |
| 86 | 86 | 'deleted' => 1, |
@@ -89,19 +89,19 @@ discard block |
||
| 89 | 89 | ), $modx->getFullTableName('site_content'), "id IN (".implode(", ", $children).")"); |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | -if ($site_start==$id) { |
|
| 92 | +if ($site_start == $id) { |
|
| 93 | 93 | $modx->webAlertAndQuit("Document is 'Site start' and cannot be deleted!"); |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | -if ($site_unavailable_page==$id) { |
|
| 96 | +if ($site_unavailable_page == $id) { |
|
| 97 | 97 | $modx->webAlertAndQuit("Document is used as the 'Site unavailable page' and cannot be deleted!"); |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | -if ($error_page==$id) { |
|
| 100 | +if ($error_page == $id) { |
|
| 101 | 101 | $modx->webAlertAndQuit("Document is used as the 'Site error page' and cannot be deleted!"); |
| 102 | 102 | } |
| 103 | 103 | |
| 104 | -if ($unauthorized_page==$id) { |
|
| 104 | +if ($unauthorized_page == $id) { |
|
| 105 | 105 | $modx->webAlertAndQuit("Document is used as the 'Site unauthorized page' and cannot be deleted!"); |
| 106 | 106 | } |
| 107 | 107 | |
@@ -127,5 +127,5 @@ discard block |
||
| 127 | 127 | $modx->clearCache('full'); |
| 128 | 128 | |
| 129 | 129 | // finished emptying cache - redirect |
| 130 | -$header="Location: index.php?a=3&id=$pid&r=1".$add_path; |
|
| 130 | +$header = "Location: index.php?a=3&id=$pid&r=1".$add_path; |
|
| 131 | 131 | header($header); |
@@ -16,9 +16,9 @@ discard block |
||
| 16 | 16 | $pth = dirname(dirname(dirname(__FILE__)))."/install/"; |
| 17 | 17 | $pth = str_replace("\\","/",$pth); |
| 18 | 18 | if(isset($_GET["rminstall"])) { |
| 19 | - if(is_dir($pth)) { |
|
| 20 | - if(!rmdirRecursive($pth)) $msg="An error occured while attempting to remove the install folder"; |
|
| 21 | - } |
|
| 19 | + if(is_dir($pth)) { |
|
| 20 | + if(!rmdirRecursive($pth)) $msg="An error occured while attempting to remove the install folder"; |
|
| 21 | + } |
|
| 22 | 22 | } |
| 23 | 23 | if($msg) echo "<script>alert('".addslashes($msg)."');</script>"; |
| 24 | 24 | echo "<script>window.location='../index.php?a=2';</script>"; |
@@ -31,15 +31,15 @@ discard block |
||
| 31 | 31 | * @return bool |
| 32 | 32 | */ |
| 33 | 33 | function rmdirRecursive($path, $followLinks=false) { |
| 34 | - $dir = opendir($path) ; |
|
| 35 | - while ($entry = readdir($dir)) { |
|
| 36 | - if (is_file("$path/$entry") || ((!$followLinks) && is_link("$path/$entry"))) { |
|
| 37 | - @unlink( "$path/$entry" ); |
|
| 38 | - } |
|
| 39 | - elseif (is_dir("$path/$entry") && $entry!='.' && $entry!='..') { |
|
| 40 | - rmdirRecursive("$path/$entry"); // recursive |
|
| 41 | - } |
|
| 42 | - } |
|
| 43 | - closedir($dir); |
|
| 44 | - return @rmdir($path); |
|
| 34 | + $dir = opendir($path) ; |
|
| 35 | + while ($entry = readdir($dir)) { |
|
| 36 | + if (is_file("$path/$entry") || ((!$followLinks) && is_link("$path/$entry"))) { |
|
| 37 | + @unlink( "$path/$entry" ); |
|
| 38 | + } |
|
| 39 | + elseif (is_dir("$path/$entry") && $entry!='.' && $entry!='..') { |
|
| 40 | + rmdirRecursive("$path/$entry"); // recursive |
|
| 41 | + } |
|
| 42 | + } |
|
| 43 | + closedir($dir); |
|
| 44 | + return @rmdir($path); |
|
| 45 | 45 | } |
@@ -12,15 +12,15 @@ discard block |
||
| 12 | 12 | * |
| 13 | 13 | */ |
| 14 | 14 | |
| 15 | -$msg =''; |
|
| 15 | +$msg = ''; |
|
| 16 | 16 | $pth = dirname(dirname(dirname(__FILE__)))."/install/"; |
| 17 | -$pth = str_replace("\\","/",$pth); |
|
| 18 | -if(isset($_GET["rminstall"])) { |
|
| 19 | - if(is_dir($pth)) { |
|
| 20 | - if(!rmdirRecursive($pth)) $msg="An error occured while attempting to remove the install folder"; |
|
| 17 | +$pth = str_replace("\\", "/", $pth); |
|
| 18 | +if (isset($_GET["rminstall"])) { |
|
| 19 | + if (is_dir($pth)) { |
|
| 20 | + if (!rmdirRecursive($pth)) $msg = "An error occured while attempting to remove the install folder"; |
|
| 21 | 21 | } |
| 22 | 22 | } |
| 23 | -if($msg) echo "<script>alert('".addslashes($msg)."');</script>"; |
|
| 23 | +if ($msg) echo "<script>alert('".addslashes($msg)."');</script>"; |
|
| 24 | 24 | echo "<script>window.location='../index.php?a=2';</script>"; |
| 25 | 25 | |
| 26 | 26 | /** |
@@ -30,13 +30,13 @@ discard block |
||
| 30 | 30 | * @param bool $followLinks |
| 31 | 31 | * @return bool |
| 32 | 32 | */ |
| 33 | -function rmdirRecursive($path, $followLinks=false) { |
|
| 34 | - $dir = opendir($path) ; |
|
| 33 | +function rmdirRecursive($path, $followLinks = false){ |
|
| 34 | + $dir = opendir($path); |
|
| 35 | 35 | while ($entry = readdir($dir)) { |
| 36 | 36 | if (is_file("$path/$entry") || ((!$followLinks) && is_link("$path/$entry"))) { |
| 37 | - @unlink( "$path/$entry" ); |
|
| 37 | + @unlink("$path/$entry"); |
|
| 38 | 38 | } |
| 39 | - elseif (is_dir("$path/$entry") && $entry!='.' && $entry!='..') { |
|
| 39 | + elseif (is_dir("$path/$entry") && $entry != '.' && $entry != '..') { |
|
| 40 | 40 | rmdirRecursive("$path/$entry"); // recursive |
| 41 | 41 | } |
| 42 | 42 | } |
@@ -17,10 +17,14 @@ discard block |
||
| 17 | 17 | $pth = str_replace("\\","/",$pth); |
| 18 | 18 | if(isset($_GET["rminstall"])) { |
| 19 | 19 | if(is_dir($pth)) { |
| 20 | - if(!rmdirRecursive($pth)) $msg="An error occured while attempting to remove the install folder"; |
|
| 20 | + if(!rmdirRecursive($pth)) { |
|
| 21 | + $msg="An error occured while attempting to remove the install folder"; |
|
| 22 | + } |
|
| 21 | 23 | } |
| 22 | 24 | } |
| 23 | -if($msg) echo "<script>alert('".addslashes($msg)."');</script>"; |
|
| 25 | +if($msg) { |
|
| 26 | + echo "<script>alert('".addslashes($msg)."');</script>"; |
|
| 27 | +} |
|
| 24 | 28 | echo "<script>window.location='../index.php?a=2';</script>"; |
| 25 | 29 | |
| 26 | 30 | /** |
@@ -30,13 +34,13 @@ discard block |
||
| 30 | 34 | * @param bool $followLinks |
| 31 | 35 | * @return bool |
| 32 | 36 | */ |
| 33 | -function rmdirRecursive($path, $followLinks=false) { |
|
| 37 | +function rmdirRecursive($path, $followLinks=false) |
|
| 38 | +{ |
|
| 34 | 39 | $dir = opendir($path) ; |
| 35 | 40 | while ($entry = readdir($dir)) { |
| 36 | 41 | if (is_file("$path/$entry") || ((!$followLinks) && is_link("$path/$entry"))) { |
| 37 | 42 | @unlink( "$path/$entry" ); |
| 38 | - } |
|
| 39 | - elseif (is_dir("$path/$entry") && $entry!='.' && $entry!='..') { |
|
| 43 | + } elseif (is_dir("$path/$entry") && $entry!='.' && $entry!='..') { |
|
| 40 | 44 | rmdirRecursive("$path/$entry"); // recursive |
| 41 | 45 | } |
| 42 | 46 | } |
@@ -8,7 +8,7 @@ |
||
| 8 | 8 | |
| 9 | 9 | $load_script = file_get_contents(dirname(__FILE__).'/datepicker.tpl'); |
| 10 | 10 | if(!isset($modx->config['lang_code'])) $modx->config['lang_code'] = $this->getLangCode(); |
| 11 | - $modx->config['datetime_format_lc'] = isset($modx->config['datetime_format']) ? strtolower($modx->config['datetime_format']) : 'dd-mm-yyyy'; |
|
| 11 | + $modx->config['datetime_format_lc'] = isset($modx->config['datetime_format']) ? strtolower($modx->config['datetime_format']) : 'dd-mm-yyyy'; |
|
| 12 | 12 | return $modx->mergeSettingsContent($load_script); |
| 13 | 13 | } |
| 14 | 14 | |
@@ -1,13 +1,13 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -class DATEPICKER { |
|
| 2 | +class DATEPICKER{ |
|
| 3 | 3 | /** |
| 4 | 4 | * @return string |
| 5 | 5 | */ |
| 6 | - public function getDP() { |
|
| 6 | + public function getDP(){ |
|
| 7 | 7 | $modx = evolutionCMS(); |
| 8 | 8 | |
| 9 | 9 | $load_script = file_get_contents(dirname(__FILE__).'/datepicker.tpl'); |
| 10 | - if(!isset($modx->config['lang_code'])) $modx->config['lang_code'] = $this->getLangCode(); |
|
| 10 | + if (!isset($modx->config['lang_code'])) $modx->config['lang_code'] = $this->getLangCode(); |
|
| 11 | 11 | $modx->config['datetime_format_lc'] = isset($modx->config['datetime_format']) ? strtolower($modx->config['datetime_format']) : 'dd-mm-yyyy'; |
| 12 | 12 | return $modx->mergeSettingsContent($load_script); |
| 13 | 13 | } |
@@ -15,14 +15,14 @@ discard block |
||
| 15 | 15 | /** |
| 16 | 16 | * @return string |
| 17 | 17 | */ |
| 18 | - public function getLangCode() { |
|
| 18 | + public function getLangCode(){ |
|
| 19 | 19 | $modx = evolutionCMS(); global $modx_lang_attribute; |
| 20 | 20 | |
| 21 | - if(!$modx_lang_attribute) return 'en'; |
|
| 21 | + if (!$modx_lang_attribute) return 'en'; |
|
| 22 | 22 | |
| 23 | 23 | $lc = $modx_lang_attribute; |
| 24 | - if($lc === 'uk') return 'ru'; |
|
| 25 | - $dp_path = str_replace('\\','/',dirname(__FILE__)); |
|
| 24 | + if ($lc === 'uk') return 'ru'; |
|
| 25 | + $dp_path = str_replace('\\', '/', dirname(__FILE__)); |
|
| 26 | 26 | |
| 27 | 27 | return (is_file("{$dp_path}/i18n/datepicker.{$lc}.js")) ? $modx_lang_attribute : 'en'; |
| 28 | 28 | } |
@@ -1,13 +1,17 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -class DATEPICKER { |
|
| 2 | +class DATEPICKER |
|
| 3 | +{ |
|
| 3 | 4 | /** |
| 4 | 5 | * @return string |
| 5 | 6 | */ |
| 6 | - public function getDP() { |
|
| 7 | + public function getDP() |
|
| 8 | + { |
|
| 7 | 9 | $modx = evolutionCMS(); |
| 8 | 10 | |
| 9 | 11 | $load_script = file_get_contents(dirname(__FILE__).'/datepicker.tpl'); |
| 10 | - if(!isset($modx->config['lang_code'])) $modx->config['lang_code'] = $this->getLangCode(); |
|
| 12 | + if(!isset($modx->config['lang_code'])) { |
|
| 13 | + $modx->config['lang_code'] = $this->getLangCode(); |
|
| 14 | + } |
|
| 11 | 15 | $modx->config['datetime_format_lc'] = isset($modx->config['datetime_format']) ? strtolower($modx->config['datetime_format']) : 'dd-mm-yyyy'; |
| 12 | 16 | return $modx->mergeSettingsContent($load_script); |
| 13 | 17 | } |
@@ -15,13 +19,18 @@ discard block |
||
| 15 | 19 | /** |
| 16 | 20 | * @return string |
| 17 | 21 | */ |
| 18 | - public function getLangCode() { |
|
| 22 | + public function getLangCode() |
|
| 23 | + { |
|
| 19 | 24 | $modx = evolutionCMS(); global $modx_lang_attribute; |
| 20 | 25 | |
| 21 | - if(!$modx_lang_attribute) return 'en'; |
|
| 26 | + if(!$modx_lang_attribute) { |
|
| 27 | + return 'en'; |
|
| 28 | + } |
|
| 22 | 29 | |
| 23 | 30 | $lc = $modx_lang_attribute; |
| 24 | - if($lc === 'uk') return 'ru'; |
|
| 31 | + if($lc === 'uk') { |
|
| 32 | + return 'ru'; |
|
| 33 | + } |
|
| 25 | 34 | $dp_path = str_replace('\\','/',dirname(__FILE__)); |
| 26 | 35 | |
| 27 | 36 | return (is_file("{$dp_path}/i18n/datepicker.{$lc}.js")) ? $modx_lang_attribute : 'en'; |