@@ -3,7 +3,7 @@ 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('settings')) { |
| 6 | - $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 6 | + $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 7 | 7 | } |
| 8 | 8 | $data = $_POST; |
| 9 | 9 | // lose the POST now, gets rid of quirky issue with Safari 3 - see FS#972 |
@@ -11,41 +11,41 @@ discard block |
||
| 11 | 11 | |
| 12 | 12 | if($data['friendly_urls']==='1' && strpos($_SERVER['SERVER_SOFTWARE'],'IIS')===false) |
| 13 | 13 | { |
| 14 | - $htaccess = $modx->config['base_path'] . '.htaccess'; |
|
| 15 | - $sample_htaccess = $modx->config['base_path'] . 'ht.access'; |
|
| 16 | - $dir = '/' . trim($modx->config['base_url'],'/'); |
|
| 17 | - if(is_file($htaccess)) |
|
| 18 | - { |
|
| 19 | - $_ = file_get_contents($htaccess); |
|
| 20 | - if(strpos($_,'RewriteBase')===false) |
|
| 21 | - { |
|
| 22 | - $warnings[] = $_lang["settings_friendlyurls_alert2"]; |
|
| 23 | - } |
|
| 24 | - elseif(is_writable($htaccess)) |
|
| 25 | - { |
|
| 26 | - $_ = preg_replace('@RewriteBase.+@',"RewriteBase {$dir}", $_); |
|
| 27 | - if(!@file_put_contents($htaccess,$_)) |
|
| 28 | - { |
|
| 29 | - $warnings[] = $_lang["settings_friendlyurls_alert2"]; |
|
| 30 | - } |
|
| 31 | - } |
|
| 32 | - } |
|
| 33 | - elseif(is_file($sample_htaccess)) |
|
| 34 | - { |
|
| 35 | - if(!@rename($sample_htaccess,$htaccess)) |
|
| 14 | + $htaccess = $modx->config['base_path'] . '.htaccess'; |
|
| 15 | + $sample_htaccess = $modx->config['base_path'] . 'ht.access'; |
|
| 16 | + $dir = '/' . trim($modx->config['base_url'],'/'); |
|
| 17 | + if(is_file($htaccess)) |
|
| 18 | + { |
|
| 19 | + $_ = file_get_contents($htaccess); |
|
| 20 | + if(strpos($_,'RewriteBase')===false) |
|
| 36 | 21 | { |
| 37 | - $warnings[] = $_lang["settings_friendlyurls_alert"]; |
|
| 38 | - } |
|
| 39 | - elseif($modx->config['base_url']!=='/') |
|
| 40 | - { |
|
| 41 | - $_ = file_get_contents($htaccess); |
|
| 42 | - $_ = preg_replace('@RewriteBase.+@',"RewriteBase {$dir}", $_); |
|
| 43 | - if(!@file_put_contents($htaccess,$_)) |
|
| 44 | - { |
|
| 45 | - $warnings[] = $_lang["settings_friendlyurls_alert2"]; |
|
| 46 | - } |
|
| 47 | - } |
|
| 48 | - } |
|
| 22 | + $warnings[] = $_lang["settings_friendlyurls_alert2"]; |
|
| 23 | + } |
|
| 24 | + elseif(is_writable($htaccess)) |
|
| 25 | + { |
|
| 26 | + $_ = preg_replace('@RewriteBase.+@',"RewriteBase {$dir}", $_); |
|
| 27 | + if(!@file_put_contents($htaccess,$_)) |
|
| 28 | + { |
|
| 29 | + $warnings[] = $_lang["settings_friendlyurls_alert2"]; |
|
| 30 | + } |
|
| 31 | + } |
|
| 32 | + } |
|
| 33 | + elseif(is_file($sample_htaccess)) |
|
| 34 | + { |
|
| 35 | + if(!@rename($sample_htaccess,$htaccess)) |
|
| 36 | + { |
|
| 37 | + $warnings[] = $_lang["settings_friendlyurls_alert"]; |
|
| 38 | + } |
|
| 39 | + elseif($modx->config['base_url']!=='/') |
|
| 40 | + { |
|
| 41 | + $_ = file_get_contents($htaccess); |
|
| 42 | + $_ = preg_replace('@RewriteBase.+@',"RewriteBase {$dir}", $_); |
|
| 43 | + if(!@file_put_contents($htaccess,$_)) |
|
| 44 | + { |
|
| 45 | + $warnings[] = $_lang["settings_friendlyurls_alert2"]; |
|
| 46 | + } |
|
| 47 | + } |
|
| 48 | + } |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | if (file_exists(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/styles.min.css')) { |
@@ -56,19 +56,19 @@ discard block |
||
| 56 | 56 | $data['rb_base_dir'] = str_replace('[(base_path)]',MODX_BASE_PATH,$data['rb_base_dir']); |
| 57 | 57 | |
| 58 | 58 | if (isset($data) && count($data) > 0) { |
| 59 | - if(isset($data['manager_language'])) { |
|
| 60 | - $lang_path = MODX_MANAGER_PATH . 'includes/lang/' . $data['manager_language'] . '.inc.php'; |
|
| 61 | - if(is_file($lang_path)) { |
|
| 62 | - include($lang_path); |
|
| 59 | + if(isset($data['manager_language'])) { |
|
| 60 | + $lang_path = MODX_MANAGER_PATH . 'includes/lang/' . $data['manager_language'] . '.inc.php'; |
|
| 61 | + if(is_file($lang_path)) { |
|
| 62 | + include($lang_path); |
|
| 63 | 63 | global $modx_lang_attribute; |
| 64 | 64 | $data['lang_code'] = !$modx_lang_attribute ? 'en' : $modx_lang_attribute; |
| 65 | - } |
|
| 66 | - } |
|
| 67 | - $savethese = array(); |
|
| 68 | - $data['sys_files_checksum'] = $modx->manager->getSystemChecksum($data['check_files_onlogin']); |
|
| 69 | - $data['mail_check_timeperiod'] = (int)$data['mail_check_timeperiod'] < 60 ? 60 : $data['mail_check_timeperiod']; // updateMail() in mainMenu no faster than every minute |
|
| 70 | - foreach ($data as $k => $v) { |
|
| 71 | - switch ($k) { |
|
| 65 | + } |
|
| 66 | + } |
|
| 67 | + $savethese = array(); |
|
| 68 | + $data['sys_files_checksum'] = $modx->manager->getSystemChecksum($data['check_files_onlogin']); |
|
| 69 | + $data['mail_check_timeperiod'] = (int)$data['mail_check_timeperiod'] < 60 ? 60 : $data['mail_check_timeperiod']; // updateMail() in mainMenu no faster than every minute |
|
| 70 | + foreach ($data as $k => $v) { |
|
| 71 | + switch ($k) { |
|
| 72 | 72 | case 'settings_version':{ |
| 73 | 73 | if($modx->getVersionData('version')!=$data['settings_version']){ |
| 74 | 74 | $modx->logEvent(17,2,'<pre>'.var_export($data['settings_version'],true).'</pre>','fake settings_version'); |
@@ -76,24 +76,24 @@ discard block |
||
| 76 | 76 | } |
| 77 | 77 | break; |
| 78 | 78 | } |
| 79 | - case 'error_page': |
|
| 80 | - case 'unauthorized_page': |
|
| 81 | - if (trim($v) == '' || !is_numeric($v)) { |
|
| 82 | - $v = $data['site_start']; |
|
| 83 | - } |
|
| 84 | - break; |
|
| 79 | + case 'error_page': |
|
| 80 | + case 'unauthorized_page': |
|
| 81 | + if (trim($v) == '' || !is_numeric($v)) { |
|
| 82 | + $v = $data['site_start']; |
|
| 83 | + } |
|
| 84 | + break; |
|
| 85 | 85 | |
| 86 | - case 'lst_custom_contenttype': |
|
| 87 | - case 'txt_custom_contenttype': |
|
| 88 | - // Skip these |
|
| 89 | - $k = ''; |
|
| 90 | - break; |
|
| 91 | - case 'rb_base_dir': |
|
| 92 | - case 'rb_base_url': |
|
| 93 | - case 'filemanager_path': |
|
| 94 | - $v = trim($v); |
|
| 95 | - $v = rtrim($v,'/') . '/'; |
|
| 96 | - break; |
|
| 86 | + case 'lst_custom_contenttype': |
|
| 87 | + case 'txt_custom_contenttype': |
|
| 88 | + // Skip these |
|
| 89 | + $k = ''; |
|
| 90 | + break; |
|
| 91 | + case 'rb_base_dir': |
|
| 92 | + case 'rb_base_url': |
|
| 93 | + case 'filemanager_path': |
|
| 94 | + $v = trim($v); |
|
| 95 | + $v = rtrim($v,'/') . '/'; |
|
| 96 | + break; |
|
| 97 | 97 | case 'manager_language': |
| 98 | 98 | $langDir = realpath(MODX_MANAGER_PATH . 'includes/lang'); |
| 99 | 99 | $langFile = realpath(MODX_MANAGER_PATH . 'includes/lang/' . $v . '.inc.php'); |
@@ -101,56 +101,56 @@ discard block |
||
| 101 | 101 | if($langDir !== $langFileDir || !file_exists($langFile)) { |
| 102 | 102 | $v = 'english'; |
| 103 | 103 | } |
| 104 | - break; |
|
| 105 | - case 'smtppw': |
|
| 106 | - if ($v !== '********************' && $v !== '') { |
|
| 107 | - $v = trim($v); |
|
| 108 | - $v = base64_encode($v) . substr(str_shuffle('abcdefghjkmnpqrstuvxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789'), 0, 7); |
|
| 109 | - $v = str_replace('=','%',$v); |
|
| 110 | - } elseif ($v === '********************') { |
|
| 111 | - $k = ''; |
|
| 112 | - } |
|
| 113 | - break; |
|
| 104 | + break; |
|
| 105 | + case 'smtppw': |
|
| 106 | + if ($v !== '********************' && $v !== '') { |
|
| 107 | + $v = trim($v); |
|
| 108 | + $v = base64_encode($v) . substr(str_shuffle('abcdefghjkmnpqrstuvxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789'), 0, 7); |
|
| 109 | + $v = str_replace('=','%',$v); |
|
| 110 | + } elseif ($v === '********************') { |
|
| 111 | + $k = ''; |
|
| 112 | + } |
|
| 113 | + break; |
|
| 114 | 114 | case 'valid_hostnames': |
| 115 | - $v = str_replace(array(' ,', ', '), ',', $v); |
|
| 116 | - if ($v !== ',') { |
|
| 117 | - $v = ($v != 'MODX_SITE_HOSTNAMES') ? $v : ''; |
|
| 118 | - $configString = '<?php' . "\n" . 'define(\'MODX_SITE_HOSTNAMES\', \'' . $v . '\');' . "\n"; |
|
| 119 | - @file_put_contents(MODX_BASE_PATH . 'assets/cache/siteHostnames.php', $configString); |
|
| 120 | - } |
|
| 121 | - $k = ''; |
|
| 122 | - break; |
|
| 123 | - case 'session_timeout': |
|
| 124 | - $mail_check_timeperiod = $data['mail_check_timeperiod']; |
|
| 125 | - $v = (int)$v < ($data['mail_check_timeperiod']/60+1) ? ($data['mail_check_timeperiod']/60+1) : $v; // updateMail() in mainMenu pings as per mail_check_timeperiod, so +1min is minimum |
|
| 126 | - break; |
|
| 127 | - default: |
|
| 128 | - break; |
|
| 129 | - } |
|
| 130 | - $v = is_array($v) ? implode(",", $v) : $v; |
|
| 115 | + $v = str_replace(array(' ,', ', '), ',', $v); |
|
| 116 | + if ($v !== ',') { |
|
| 117 | + $v = ($v != 'MODX_SITE_HOSTNAMES') ? $v : ''; |
|
| 118 | + $configString = '<?php' . "\n" . 'define(\'MODX_SITE_HOSTNAMES\', \'' . $v . '\');' . "\n"; |
|
| 119 | + @file_put_contents(MODX_BASE_PATH . 'assets/cache/siteHostnames.php', $configString); |
|
| 120 | + } |
|
| 121 | + $k = ''; |
|
| 122 | + break; |
|
| 123 | + case 'session_timeout': |
|
| 124 | + $mail_check_timeperiod = $data['mail_check_timeperiod']; |
|
| 125 | + $v = (int)$v < ($data['mail_check_timeperiod']/60+1) ? ($data['mail_check_timeperiod']/60+1) : $v; // updateMail() in mainMenu pings as per mail_check_timeperiod, so +1min is minimum |
|
| 126 | + break; |
|
| 127 | + default: |
|
| 128 | + break; |
|
| 129 | + } |
|
| 130 | + $v = is_array($v) ? implode(",", $v) : $v; |
|
| 131 | 131 | |
| 132 | - $modx->config[$k] = $v; |
|
| 132 | + $modx->config[$k] = $v; |
|
| 133 | 133 | |
| 134 | - if(!empty($k)) $savethese[] = '(\''.$modx->db->escape($k).'\', \''.$modx->db->escape($v).'\')'; |
|
| 135 | - } |
|
| 134 | + if(!empty($k)) $savethese[] = '(\''.$modx->db->escape($k).'\', \''.$modx->db->escape($v).'\')'; |
|
| 135 | + } |
|
| 136 | 136 | |
| 137 | - // Run a single query to save all the values |
|
| 138 | - $sql = "REPLACE INTO ".$modx->getFullTableName("system_settings")." (setting_name, setting_value) |
|
| 137 | + // Run a single query to save all the values |
|
| 138 | + $sql = "REPLACE INTO ".$modx->getFullTableName("system_settings")." (setting_name, setting_value) |
|
| 139 | 139 | VALUES ".implode(', ', $savethese); |
| 140 | - $modx->db->query($sql); |
|
| 140 | + $modx->db->query($sql); |
|
| 141 | 141 | |
| 142 | - // Reset Template Pages |
|
| 143 | - if (isset($data['reset_template'])) { |
|
| 144 | - $newtemplate = (int)$data['default_template']; |
|
| 145 | - $oldtemplate = (int)$data['old_template']; |
|
| 146 | - $tbl = $modx->getFullTableName('site_content'); |
|
| 147 | - $reset = $data['reset_template']; |
|
| 148 | - if($reset==1) $modx->db->update(array('template' => $newtemplate), $tbl, "type='document'"); |
|
| 149 | - else if($reset==2) $modx->db->update(array('template' => $newtemplate), $tbl, "template='{$oldtemplate}'"); |
|
| 150 | - } |
|
| 142 | + // Reset Template Pages |
|
| 143 | + if (isset($data['reset_template'])) { |
|
| 144 | + $newtemplate = (int)$data['default_template']; |
|
| 145 | + $oldtemplate = (int)$data['old_template']; |
|
| 146 | + $tbl = $modx->getFullTableName('site_content'); |
|
| 147 | + $reset = $data['reset_template']; |
|
| 148 | + if($reset==1) $modx->db->update(array('template' => $newtemplate), $tbl, "type='document'"); |
|
| 149 | + else if($reset==2) $modx->db->update(array('template' => $newtemplate), $tbl, "template='{$oldtemplate}'"); |
|
| 150 | + } |
|
| 151 | 151 | |
| 152 | - // empty cache |
|
| 153 | - $modx->clearCache('full'); |
|
| 152 | + // empty cache |
|
| 153 | + $modx->clearCache('full'); |
|
| 154 | 154 | } |
| 155 | 155 | $header="Location: index.php?a=7&r=10"; |
| 156 | 156 | header($header); |
@@ -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_plugin')) { |
| 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 | // count duplicates |
@@ -19,25 +19,25 @@ discard block |
||
| 19 | 19 | |
| 20 | 20 | // duplicate Plugin |
| 21 | 21 | $newid = $modx->db->insert( |
| 22 | - array( |
|
| 23 | - 'name'=>'', |
|
| 24 | - 'description'=>'', |
|
| 25 | - 'disabled'=>'', |
|
| 26 | - 'moduleguid'=>'', |
|
| 27 | - 'plugincode'=>'', |
|
| 28 | - 'properties'=>'', |
|
| 29 | - 'category'=>'', |
|
| 30 | - ), $modx->getFullTableName('site_plugins'), // Insert into |
|
| 31 | - "CONCAT(name, ' {$_lang['duplicated_el_suffix']}{$count}') AS name, description, '1' AS disabled, moduleguid, plugincode, properties, category", $modx->getFullTableName('site_plugins'), "id='{$id}'"); // Copy from |
|
| 22 | + array( |
|
| 23 | + 'name'=>'', |
|
| 24 | + 'description'=>'', |
|
| 25 | + 'disabled'=>'', |
|
| 26 | + 'moduleguid'=>'', |
|
| 27 | + 'plugincode'=>'', |
|
| 28 | + 'properties'=>'', |
|
| 29 | + 'category'=>'', |
|
| 30 | + ), $modx->getFullTableName('site_plugins'), // Insert into |
|
| 31 | + "CONCAT(name, ' {$_lang['duplicated_el_suffix']}{$count}') AS name, description, '1' AS disabled, moduleguid, plugincode, properties, category", $modx->getFullTableName('site_plugins'), "id='{$id}'"); // Copy from |
|
| 32 | 32 | |
| 33 | 33 | // duplicate Plugin Event Listeners |
| 34 | 34 | $modx->db->insert( |
| 35 | - array( |
|
| 36 | - 'pluginid'=>'', |
|
| 37 | - 'evtid'=>'', |
|
| 38 | - 'priority'=>'', |
|
| 39 | - ), $modx->getFullTableName('site_plugin_events'), // Insert into |
|
| 40 | - "'{$newid}', evtid, priority", $modx->getFullTableName('site_plugin_events'), "pluginid='{$id}'"); // Copy from |
|
| 35 | + array( |
|
| 36 | + 'pluginid'=>'', |
|
| 37 | + 'evtid'=>'', |
|
| 38 | + 'priority'=>'', |
|
| 39 | + ), $modx->getFullTableName('site_plugin_events'), // Insert into |
|
| 40 | + "'{$newid}', evtid, priority", $modx->getFullTableName('site_plugin_events'), "pluginid='{$id}'"); // Copy from |
|
| 41 | 41 | |
| 42 | 42 | // Set the item name for logger |
| 43 | 43 | $name = $modx->db->getValue($modx->db->select('name', $modx->getFullTableName('site_plugins'), "id='{$newid}'")); |
@@ -3,17 +3,17 @@ 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('delete_user')) { |
| 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 | // delete the user, but first check if we are deleting our own record |
| 15 | 15 | if($id==$modx->getLoginUserID()) { |
| 16 | - $modx->webAlertAndQuit("You can't delete yourself!"); |
|
| 16 | + $modx->webAlertAndQuit("You can't delete yourself!"); |
|
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | // Set the item name for logger |
@@ -22,9 +22,9 @@ discard block |
||
| 22 | 22 | |
| 23 | 23 | // invoke OnBeforeUserFormDelete event |
| 24 | 24 | $modx->invokeEvent("OnBeforeUserFormDelete", |
| 25 | - array( |
|
| 26 | - "id" => $id |
|
| 27 | - )); |
|
| 25 | + array( |
|
| 26 | + "id" => $id |
|
| 27 | + )); |
|
| 28 | 28 | |
| 29 | 29 | // delete the user. |
| 30 | 30 | $modx->db->delete($modx->getFullTableName('manager_users'), "id='{$id}'"); |
@@ -39,16 +39,16 @@ discard block |
||
| 39 | 39 | |
| 40 | 40 | // invoke OnManagerDeleteUser event |
| 41 | 41 | $modx->invokeEvent("OnManagerDeleteUser", |
| 42 | - array( |
|
| 43 | - "userid" => $id, |
|
| 44 | - "username" => $username |
|
| 45 | - )); |
|
| 42 | + array( |
|
| 43 | + "userid" => $id, |
|
| 44 | + "username" => $username |
|
| 45 | + )); |
|
| 46 | 46 | |
| 47 | 47 | // invoke OnUserFormDelete event |
| 48 | 48 | $modx->invokeEvent("OnUserFormDelete", |
| 49 | - array( |
|
| 50 | - "id" => $id |
|
| 51 | - )); |
|
| 49 | + array( |
|
| 50 | + "id" => $id |
|
| 51 | + )); |
|
| 52 | 52 | |
| 53 | 53 | $header="Location: index.php?a=75"; |
| 54 | 54 | header($header); |
@@ -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_web_user')) { |
| 6 | - $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 6 | + $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 7 | 7 | } |
| 8 | 8 | |
| 9 | 9 | $tbl_web_users = $modx->getFullTableName('web_users'); |
@@ -12,10 +12,10 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | $input = $_POST; |
| 14 | 14 | foreach($input as $k => $v) { |
| 15 | - if($k !== 'comment') { |
|
| 16 | - $v = sanitize($v); |
|
| 17 | - } |
|
| 18 | - $input[$k] = $v; |
|
| 15 | + if($k !== 'comment') { |
|
| 16 | + $v = sanitize($v); |
|
| 17 | + } |
|
| 18 | + $input[$k] = $v; |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | $id = (int)$input['id']; |
@@ -51,80 +51,80 @@ discard block |
||
| 51 | 51 | |
| 52 | 52 | // verify password |
| 53 | 53 | if($passwordgenmethod == "spec" && $input['specifiedpassword'] != $input['confirmpassword']) { |
| 54 | - webAlertAndQuit("Password typed is mismatched"); |
|
| 54 | + webAlertAndQuit("Password typed is mismatched"); |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | // verify email |
| 58 | 58 | if($email == '' || !preg_match("/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,24}$/i", $email)) { |
| 59 | - webAlertAndQuit("E-mail address doesn't seem to be valid!"); |
|
| 59 | + webAlertAndQuit("E-mail address doesn't seem to be valid!"); |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | switch($input['mode']) { |
| 63 | - case '87' : // new user |
|
| 64 | - // check if this user name already exist |
|
| 65 | - $rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}'"); |
|
| 66 | - $limit = $modx->db->getValue($rs); |
|
| 67 | - if($limit > 0) { |
|
| 68 | - webAlertAndQuit("User name is already in use!"); |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - // check if the email address already exist |
|
| 72 | - $rs = $modx->db->select('count(id)', $tbl_web_user_attributes, "email='{$esc_email}' AND id!='{$id}'"); |
|
| 73 | - $limit = $modx->db->getValue($rs); |
|
| 74 | - if($limit > 0) { |
|
| 75 | - webAlertAndQuit("Email is already in use!"); |
|
| 76 | - } |
|
| 77 | - |
|
| 78 | - // generate a new password for this user |
|
| 79 | - if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
| 80 | - if(strlen($specifiedpassword) < 6) { |
|
| 81 | - webAlertAndQuit("Password is too short!"); |
|
| 82 | - } else { |
|
| 83 | - $newpassword = $specifiedpassword; |
|
| 84 | - } |
|
| 85 | - } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
| 86 | - webAlertAndQuit("You didn't specify a password for this user!"); |
|
| 87 | - } elseif($passwordgenmethod == 'g') { |
|
| 88 | - $newpassword = generate_password(8); |
|
| 89 | - } else { |
|
| 90 | - webAlertAndQuit("No password generation method specified!"); |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - // invoke OnBeforeWUsrFormSave event |
|
| 94 | - $modx->invokeEvent("OnBeforeWUsrFormSave", array( |
|
| 95 | - "mode" => "new", |
|
| 96 | - )); |
|
| 97 | - |
|
| 98 | - // create the user account |
|
| 99 | - $field = array(); |
|
| 100 | - $field['username'] = $esc_newusername; |
|
| 101 | - $field['password'] = md5($newpassword); |
|
| 102 | - $internalKey = $modx->db->insert($field, $tbl_web_users); |
|
| 103 | - |
|
| 104 | - $field = compact('internalKey', 'fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'blocked', 'blockeduntil', 'blockedafter'); |
|
| 105 | - $field = $modx->db->escape($field); |
|
| 106 | - $modx->db->insert($field, $tbl_web_user_attributes); |
|
| 107 | - |
|
| 108 | - // Save User Settings |
|
| 109 | - saveUserSettings($internalKey); |
|
| 110 | - |
|
| 111 | - // Set the item name for logger |
|
| 112 | - $_SESSION['itemname'] = $newusername; |
|
| 113 | - |
|
| 114 | - /*******************************************************************************/ |
|
| 115 | - // put the user in the user_groups he/ she should be in |
|
| 116 | - // first, check that up_perms are switched on! |
|
| 117 | - if($use_udperms == 1) { |
|
| 118 | - if(!empty($user_groups)) { |
|
| 119 | - for($i = 0; $i < count($user_groups); $i++) { |
|
| 120 | - $f = array(); |
|
| 121 | - $f['webgroup'] = (int)$user_groups[$i]; |
|
| 122 | - $f['webuser'] = $internalKey; |
|
| 123 | - $modx->db->insert($f, $tbl_web_groups); |
|
| 124 | - } |
|
| 125 | - } |
|
| 126 | - } |
|
| 127 | - // end of user_groups stuff! |
|
| 63 | + case '87' : // new user |
|
| 64 | + // check if this user name already exist |
|
| 65 | + $rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}'"); |
|
| 66 | + $limit = $modx->db->getValue($rs); |
|
| 67 | + if($limit > 0) { |
|
| 68 | + webAlertAndQuit("User name is already in use!"); |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + // check if the email address already exist |
|
| 72 | + $rs = $modx->db->select('count(id)', $tbl_web_user_attributes, "email='{$esc_email}' AND id!='{$id}'"); |
|
| 73 | + $limit = $modx->db->getValue($rs); |
|
| 74 | + if($limit > 0) { |
|
| 75 | + webAlertAndQuit("Email is already in use!"); |
|
| 76 | + } |
|
| 77 | + |
|
| 78 | + // generate a new password for this user |
|
| 79 | + if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
| 80 | + if(strlen($specifiedpassword) < 6) { |
|
| 81 | + webAlertAndQuit("Password is too short!"); |
|
| 82 | + } else { |
|
| 83 | + $newpassword = $specifiedpassword; |
|
| 84 | + } |
|
| 85 | + } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
| 86 | + webAlertAndQuit("You didn't specify a password for this user!"); |
|
| 87 | + } elseif($passwordgenmethod == 'g') { |
|
| 88 | + $newpassword = generate_password(8); |
|
| 89 | + } else { |
|
| 90 | + webAlertAndQuit("No password generation method specified!"); |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + // invoke OnBeforeWUsrFormSave event |
|
| 94 | + $modx->invokeEvent("OnBeforeWUsrFormSave", array( |
|
| 95 | + "mode" => "new", |
|
| 96 | + )); |
|
| 97 | + |
|
| 98 | + // create the user account |
|
| 99 | + $field = array(); |
|
| 100 | + $field['username'] = $esc_newusername; |
|
| 101 | + $field['password'] = md5($newpassword); |
|
| 102 | + $internalKey = $modx->db->insert($field, $tbl_web_users); |
|
| 103 | + |
|
| 104 | + $field = compact('internalKey', 'fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'blocked', 'blockeduntil', 'blockedafter'); |
|
| 105 | + $field = $modx->db->escape($field); |
|
| 106 | + $modx->db->insert($field, $tbl_web_user_attributes); |
|
| 107 | + |
|
| 108 | + // Save User Settings |
|
| 109 | + saveUserSettings($internalKey); |
|
| 110 | + |
|
| 111 | + // Set the item name for logger |
|
| 112 | + $_SESSION['itemname'] = $newusername; |
|
| 113 | + |
|
| 114 | + /*******************************************************************************/ |
|
| 115 | + // put the user in the user_groups he/ she should be in |
|
| 116 | + // first, check that up_perms are switched on! |
|
| 117 | + if($use_udperms == 1) { |
|
| 118 | + if(!empty($user_groups)) { |
|
| 119 | + for($i = 0; $i < count($user_groups); $i++) { |
|
| 120 | + $f = array(); |
|
| 121 | + $f['webgroup'] = (int)$user_groups[$i]; |
|
| 122 | + $f['webuser'] = $internalKey; |
|
| 123 | + $modx->db->insert($f, $tbl_web_groups); |
|
| 124 | + } |
|
| 125 | + } |
|
| 126 | + } |
|
| 127 | + // end of user_groups stuff! |
|
| 128 | 128 | |
| 129 | 129 | // invoke OnWebSaveUser event |
| 130 | 130 | $modx->invokeEvent("OnWebSaveUser", array( |
@@ -142,26 +142,26 @@ discard block |
||
| 142 | 142 | "id" => $internalKey |
| 143 | 143 | )); |
| 144 | 144 | |
| 145 | - if($passwordnotifymethod == 'e') { |
|
| 146 | - sendMailMessage($email, $newusername, $newpassword, $fullname); |
|
| 147 | - if($input['stay'] != '') { |
|
| 148 | - $a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87"; |
|
| 149 | - $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 150 | - header($header); |
|
| 151 | - } else { |
|
| 152 | - $header = "Location: index.php?a=99&r=2"; |
|
| 153 | - header($header); |
|
| 154 | - } |
|
| 155 | - } else { |
|
| 156 | - if($input['stay'] != '') { |
|
| 157 | - $a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87"; |
|
| 158 | - $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 159 | - } else { |
|
| 160 | - $stayUrl = "index.php?a=99&r=2"; |
|
| 161 | - } |
|
| 162 | - |
|
| 163 | - include_once "header.inc.php"; |
|
| 164 | - ?> |
|
| 145 | + if($passwordnotifymethod == 'e') { |
|
| 146 | + sendMailMessage($email, $newusername, $newpassword, $fullname); |
|
| 147 | + if($input['stay'] != '') { |
|
| 148 | + $a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87"; |
|
| 149 | + $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 150 | + header($header); |
|
| 151 | + } else { |
|
| 152 | + $header = "Location: index.php?a=99&r=2"; |
|
| 153 | + header($header); |
|
| 154 | + } |
|
| 155 | + } else { |
|
| 156 | + if($input['stay'] != '') { |
|
| 157 | + $a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87"; |
|
| 158 | + $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 159 | + } else { |
|
| 160 | + $stayUrl = "index.php?a=99&r=2"; |
|
| 161 | + } |
|
| 162 | + |
|
| 163 | + include_once "header.inc.php"; |
|
| 164 | + ?> |
|
| 165 | 165 | |
| 166 | 166 | <h1><?php echo $_lang['web_user_title']; ?></h1> |
| 167 | 167 | |
@@ -183,84 +183,84 @@ discard block |
||
| 183 | 183 | </div> |
| 184 | 184 | <?php |
| 185 | 185 | |
| 186 | - include_once "footer.inc.php"; |
|
| 187 | - } |
|
| 188 | - break; |
|
| 189 | - case '88' : // edit user |
|
| 190 | - // generate a new password for this user |
|
| 191 | - if($genpassword == 1) { |
|
| 192 | - if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
| 193 | - if(strlen($specifiedpassword) < 6) { |
|
| 194 | - webAlertAndQuit("Password is too short!"); |
|
| 195 | - } else { |
|
| 196 | - $newpassword = $specifiedpassword; |
|
| 197 | - } |
|
| 198 | - } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
| 199 | - webAlertAndQuit("You didn't specify a password for this user!"); |
|
| 200 | - } elseif($passwordgenmethod == 'g') { |
|
| 201 | - $newpassword = generate_password(8); |
|
| 202 | - } else { |
|
| 203 | - webAlertAndQuit("No password generation method specified!"); |
|
| 204 | - } |
|
| 205 | - } |
|
| 206 | - if($passwordnotifymethod == 'e') { |
|
| 207 | - sendMailMessage($email, $newusername, $newpassword, $fullname); |
|
| 208 | - } |
|
| 209 | - |
|
| 210 | - // check if the username already exist |
|
| 211 | - $rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}' AND id!='{$id}'"); |
|
| 212 | - $limit = $modx->db->getValue($rs); |
|
| 213 | - if($limit > 0) { |
|
| 214 | - webAlertAndQuit("User name is already in use!"); |
|
| 215 | - } |
|
| 216 | - |
|
| 217 | - // check if the email address already exists |
|
| 218 | - $rs = $modx->db->select('count(internalKey)', $tbl_web_user_attributes, "email='{$esc_email}' AND internalKey!='{$id}'"); |
|
| 219 | - $limit = $modx->db->getValue($rs); |
|
| 220 | - if($limit > 0) { |
|
| 221 | - webAlertAndQuit("Email is already in use!"); |
|
| 222 | - } |
|
| 223 | - |
|
| 224 | - // invoke OnBeforeWUsrFormSave event |
|
| 225 | - $modx->invokeEvent("OnBeforeWUsrFormSave", array( |
|
| 226 | - "mode" => "upd", |
|
| 227 | - "id" => $id |
|
| 228 | - )); |
|
| 229 | - |
|
| 230 | - // update user name and password |
|
| 231 | - $field = array(); |
|
| 232 | - $field['username'] = $esc_newusername; |
|
| 233 | - if($genpassword == 1) { |
|
| 234 | - $field['password'] = md5($newpassword); |
|
| 235 | - } |
|
| 236 | - $modx->db->update($field, $tbl_web_users, "id='{$id}'"); |
|
| 237 | - $field = compact('fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'failedlogincount', 'blocked', 'blockeduntil', 'blockedafter'); |
|
| 238 | - $field = $modx->db->escape($field); |
|
| 239 | - $modx->db->update($field, $tbl_web_user_attributes, "internalKey='{$id}'"); |
|
| 240 | - |
|
| 241 | - // Save User Settings |
|
| 242 | - saveUserSettings($id); |
|
| 243 | - |
|
| 244 | - // Set the item name for logger |
|
| 245 | - $_SESSION['itemname'] = $newusername; |
|
| 246 | - |
|
| 247 | - /*******************************************************************************/ |
|
| 248 | - // put the user in the user_groups he/ she should be in |
|
| 249 | - // first, check that up_perms are switched on! |
|
| 250 | - if($use_udperms == 1) { |
|
| 251 | - // as this is an existing user, delete his/ her entries in the groups before saving the new groups |
|
| 252 | - $modx->db->delete($tbl_web_groups, "webuser='{$id}'"); |
|
| 253 | - if(!empty($user_groups)) { |
|
| 254 | - for($i = 0; $i < count($user_groups); $i++) { |
|
| 255 | - $field = array(); |
|
| 256 | - $field['webgroup'] = (int)$user_groups[$i]; |
|
| 257 | - $field['webuser'] = $id; |
|
| 258 | - $modx->db->insert($field, $tbl_web_groups); |
|
| 259 | - } |
|
| 260 | - } |
|
| 261 | - } |
|
| 262 | - // end of user_groups stuff! |
|
| 263 | - /*******************************************************************************/ |
|
| 186 | + include_once "footer.inc.php"; |
|
| 187 | + } |
|
| 188 | + break; |
|
| 189 | + case '88' : // edit user |
|
| 190 | + // generate a new password for this user |
|
| 191 | + if($genpassword == 1) { |
|
| 192 | + if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
| 193 | + if(strlen($specifiedpassword) < 6) { |
|
| 194 | + webAlertAndQuit("Password is too short!"); |
|
| 195 | + } else { |
|
| 196 | + $newpassword = $specifiedpassword; |
|
| 197 | + } |
|
| 198 | + } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
| 199 | + webAlertAndQuit("You didn't specify a password for this user!"); |
|
| 200 | + } elseif($passwordgenmethod == 'g') { |
|
| 201 | + $newpassword = generate_password(8); |
|
| 202 | + } else { |
|
| 203 | + webAlertAndQuit("No password generation method specified!"); |
|
| 204 | + } |
|
| 205 | + } |
|
| 206 | + if($passwordnotifymethod == 'e') { |
|
| 207 | + sendMailMessage($email, $newusername, $newpassword, $fullname); |
|
| 208 | + } |
|
| 209 | + |
|
| 210 | + // check if the username already exist |
|
| 211 | + $rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}' AND id!='{$id}'"); |
|
| 212 | + $limit = $modx->db->getValue($rs); |
|
| 213 | + if($limit > 0) { |
|
| 214 | + webAlertAndQuit("User name is already in use!"); |
|
| 215 | + } |
|
| 216 | + |
|
| 217 | + // check if the email address already exists |
|
| 218 | + $rs = $modx->db->select('count(internalKey)', $tbl_web_user_attributes, "email='{$esc_email}' AND internalKey!='{$id}'"); |
|
| 219 | + $limit = $modx->db->getValue($rs); |
|
| 220 | + if($limit > 0) { |
|
| 221 | + webAlertAndQuit("Email is already in use!"); |
|
| 222 | + } |
|
| 223 | + |
|
| 224 | + // invoke OnBeforeWUsrFormSave event |
|
| 225 | + $modx->invokeEvent("OnBeforeWUsrFormSave", array( |
|
| 226 | + "mode" => "upd", |
|
| 227 | + "id" => $id |
|
| 228 | + )); |
|
| 229 | + |
|
| 230 | + // update user name and password |
|
| 231 | + $field = array(); |
|
| 232 | + $field['username'] = $esc_newusername; |
|
| 233 | + if($genpassword == 1) { |
|
| 234 | + $field['password'] = md5($newpassword); |
|
| 235 | + } |
|
| 236 | + $modx->db->update($field, $tbl_web_users, "id='{$id}'"); |
|
| 237 | + $field = compact('fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'failedlogincount', 'blocked', 'blockeduntil', 'blockedafter'); |
|
| 238 | + $field = $modx->db->escape($field); |
|
| 239 | + $modx->db->update($field, $tbl_web_user_attributes, "internalKey='{$id}'"); |
|
| 240 | + |
|
| 241 | + // Save User Settings |
|
| 242 | + saveUserSettings($id); |
|
| 243 | + |
|
| 244 | + // Set the item name for logger |
|
| 245 | + $_SESSION['itemname'] = $newusername; |
|
| 246 | + |
|
| 247 | + /*******************************************************************************/ |
|
| 248 | + // put the user in the user_groups he/ she should be in |
|
| 249 | + // first, check that up_perms are switched on! |
|
| 250 | + if($use_udperms == 1) { |
|
| 251 | + // as this is an existing user, delete his/ her entries in the groups before saving the new groups |
|
| 252 | + $modx->db->delete($tbl_web_groups, "webuser='{$id}'"); |
|
| 253 | + if(!empty($user_groups)) { |
|
| 254 | + for($i = 0; $i < count($user_groups); $i++) { |
|
| 255 | + $field = array(); |
|
| 256 | + $field['webgroup'] = (int)$user_groups[$i]; |
|
| 257 | + $field['webuser'] = $id; |
|
| 258 | + $modx->db->insert($field, $tbl_web_groups); |
|
| 259 | + } |
|
| 260 | + } |
|
| 261 | + } |
|
| 262 | + // end of user_groups stuff! |
|
| 263 | + /*******************************************************************************/ |
|
| 264 | 264 | |
| 265 | 265 | // invoke OnWebSaveUser event |
| 266 | 266 | $modx->invokeEvent("OnWebSaveUser", array( |
@@ -289,16 +289,16 @@ discard block |
||
| 289 | 289 | "id" => $id |
| 290 | 290 | )); |
| 291 | 291 | |
| 292 | - if($genpassword == 1 && $passwordnotifymethod == 's') { |
|
| 293 | - if($input['stay'] != '') { |
|
| 294 | - $a = ($input['stay'] == '2') ? "88&id={$id}" : "87"; |
|
| 295 | - $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 296 | - } else { |
|
| 297 | - $stayUrl = "index.php?a=99&r=2"; |
|
| 298 | - } |
|
| 292 | + if($genpassword == 1 && $passwordnotifymethod == 's') { |
|
| 293 | + if($input['stay'] != '') { |
|
| 294 | + $a = ($input['stay'] == '2') ? "88&id={$id}" : "87"; |
|
| 295 | + $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 296 | + } else { |
|
| 297 | + $stayUrl = "index.php?a=99&r=2"; |
|
| 298 | + } |
|
| 299 | 299 | |
| 300 | - include_once "header.inc.php"; |
|
| 301 | - ?> |
|
| 300 | + include_once "header.inc.php"; |
|
| 301 | + ?> |
|
| 302 | 302 | |
| 303 | 303 | <h1><?php echo $_lang['web_user_title']; ?></h1> |
| 304 | 304 | |
@@ -318,124 +318,124 @@ discard block |
||
| 318 | 318 | </div> |
| 319 | 319 | <?php |
| 320 | 320 | |
| 321 | - include_once "footer.inc.php"; |
|
| 322 | - } else { |
|
| 323 | - if($input['stay'] != '') { |
|
| 324 | - $a = ($input['stay'] == '2') ? "88&id={$id}" : "87"; |
|
| 325 | - $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 326 | - header($header); |
|
| 327 | - } else { |
|
| 328 | - $header = "Location: index.php?a=99&r=2"; |
|
| 329 | - header($header); |
|
| 330 | - } |
|
| 331 | - } |
|
| 332 | - break; |
|
| 333 | - default : |
|
| 334 | - webAlertAndQuit("No operation set in request."); |
|
| 321 | + include_once "footer.inc.php"; |
|
| 322 | + } else { |
|
| 323 | + if($input['stay'] != '') { |
|
| 324 | + $a = ($input['stay'] == '2') ? "88&id={$id}" : "87"; |
|
| 325 | + $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
| 326 | + header($header); |
|
| 327 | + } else { |
|
| 328 | + $header = "Location: index.php?a=99&r=2"; |
|
| 329 | + header($header); |
|
| 330 | + } |
|
| 331 | + } |
|
| 332 | + break; |
|
| 333 | + default : |
|
| 334 | + webAlertAndQuit("No operation set in request."); |
|
| 335 | 335 | } |
| 336 | 336 | |
| 337 | 337 | // in case any plugins include a quoted_printable function |
| 338 | 338 | function save_user_quoted_printable($string) { |
| 339 | - $crlf = "\n"; |
|
| 340 | - $string = preg_replace('!(\r\n|\r|\n)!', $crlf, $string) . $crlf; |
|
| 341 | - $f[] = '/([\000-\010\013\014\016-\037\075\177-\377])/e'; |
|
| 342 | - $r[] = "'=' . sprintf('%02X', ord('\\1'))"; |
|
| 343 | - $f[] = '/([\011\040])' . $crlf . '/e'; |
|
| 344 | - $r[] = "'=' . sprintf('%02X', ord('\\1')) . '" . $crlf . "'"; |
|
| 345 | - $string = preg_replace($f, $r, $string); |
|
| 346 | - return trim(wordwrap($string, 70, ' =' . $crlf)); |
|
| 339 | + $crlf = "\n"; |
|
| 340 | + $string = preg_replace('!(\r\n|\r|\n)!', $crlf, $string) . $crlf; |
|
| 341 | + $f[] = '/([\000-\010\013\014\016-\037\075\177-\377])/e'; |
|
| 342 | + $r[] = "'=' . sprintf('%02X', ord('\\1'))"; |
|
| 343 | + $f[] = '/([\011\040])' . $crlf . '/e'; |
|
| 344 | + $r[] = "'=' . sprintf('%02X', ord('\\1')) . '" . $crlf . "'"; |
|
| 345 | + $string = preg_replace($f, $r, $string); |
|
| 346 | + return trim(wordwrap($string, 70, ' =' . $crlf)); |
|
| 347 | 347 | } |
| 348 | 348 | |
| 349 | 349 | // Send an email to the user |
| 350 | 350 | function sendMailMessage($email, $uid, $pwd, $ufn) { |
| 351 | - global $modx, $_lang, $websignupemail_message; |
|
| 352 | - global $emailsubject, $emailsender; |
|
| 353 | - global $site_name, $site_url; |
|
| 354 | - $message = sprintf($websignupemail_message, $uid, $pwd); // use old method |
|
| 355 | - // replace placeholders |
|
| 356 | - $message = str_replace("[+uid+]", $uid, $message); |
|
| 357 | - $message = str_replace("[+pwd+]", $pwd, $message); |
|
| 358 | - $message = str_replace("[+ufn+]", $ufn, $message); |
|
| 359 | - $message = str_replace("[+sname+]", $site_name, $message); |
|
| 360 | - $message = str_replace("[+saddr+]", $emailsender, $message); |
|
| 361 | - $message = str_replace("[+semail+]", $emailsender, $message); |
|
| 362 | - $message = str_replace("[+surl+]", $site_url, $message); |
|
| 363 | - |
|
| 364 | - $param = array(); |
|
| 365 | - $param['from'] = "{$site_name}<{$emailsender}>"; |
|
| 366 | - $param['subject'] = $emailsubject; |
|
| 367 | - $param['body'] = $message; |
|
| 368 | - $param['to'] = $email; |
|
| 369 | - $param['type'] = 'text'; |
|
| 370 | - $rs = $modx->sendmail($param); |
|
| 371 | - if(!$rs) { |
|
| 372 | - $modx->manager->saveFormValues(); |
|
| 373 | - $modx->messageQuit("{$email} - {$_lang['error_sending_email']}"); |
|
| 374 | - } |
|
| 351 | + global $modx, $_lang, $websignupemail_message; |
|
| 352 | + global $emailsubject, $emailsender; |
|
| 353 | + global $site_name, $site_url; |
|
| 354 | + $message = sprintf($websignupemail_message, $uid, $pwd); // use old method |
|
| 355 | + // replace placeholders |
|
| 356 | + $message = str_replace("[+uid+]", $uid, $message); |
|
| 357 | + $message = str_replace("[+pwd+]", $pwd, $message); |
|
| 358 | + $message = str_replace("[+ufn+]", $ufn, $message); |
|
| 359 | + $message = str_replace("[+sname+]", $site_name, $message); |
|
| 360 | + $message = str_replace("[+saddr+]", $emailsender, $message); |
|
| 361 | + $message = str_replace("[+semail+]", $emailsender, $message); |
|
| 362 | + $message = str_replace("[+surl+]", $site_url, $message); |
|
| 363 | + |
|
| 364 | + $param = array(); |
|
| 365 | + $param['from'] = "{$site_name}<{$emailsender}>"; |
|
| 366 | + $param['subject'] = $emailsubject; |
|
| 367 | + $param['body'] = $message; |
|
| 368 | + $param['to'] = $email; |
|
| 369 | + $param['type'] = 'text'; |
|
| 370 | + $rs = $modx->sendmail($param); |
|
| 371 | + if(!$rs) { |
|
| 372 | + $modx->manager->saveFormValues(); |
|
| 373 | + $modx->messageQuit("{$email} - {$_lang['error_sending_email']}"); |
|
| 374 | + } |
|
| 375 | 375 | } |
| 376 | 376 | |
| 377 | 377 | // Save User Settings |
| 378 | 378 | function saveUserSettings($id) { |
| 379 | - global $modx; |
|
| 380 | - $tbl_web_user_settings = $modx->getFullTableName('web_user_settings'); |
|
| 381 | - |
|
| 382 | - $settings = array( |
|
| 383 | - "login_home", |
|
| 384 | - "allowed_ip", |
|
| 385 | - "allowed_days" |
|
| 386 | - ); |
|
| 387 | - |
|
| 388 | - $modx->db->delete($tbl_web_user_settings, "webuser='{$id}'"); |
|
| 389 | - |
|
| 390 | - foreach($settings as $n) { |
|
| 391 | - $vl = $_POST[$n]; |
|
| 392 | - if(is_array($vl)) { |
|
| 393 | - $vl = implode(",", $vl); |
|
| 394 | - } |
|
| 395 | - if($vl != '') { |
|
| 396 | - $f = array(); |
|
| 397 | - $f['webuser'] = $id; |
|
| 398 | - $f['setting_name'] = $n; |
|
| 399 | - $f['setting_value'] = $vl; |
|
| 400 | - $f = $modx->db->escape($f); |
|
| 401 | - $modx->db->insert($f, $tbl_web_user_settings); |
|
| 402 | - } |
|
| 403 | - } |
|
| 379 | + global $modx; |
|
| 380 | + $tbl_web_user_settings = $modx->getFullTableName('web_user_settings'); |
|
| 381 | + |
|
| 382 | + $settings = array( |
|
| 383 | + "login_home", |
|
| 384 | + "allowed_ip", |
|
| 385 | + "allowed_days" |
|
| 386 | + ); |
|
| 387 | + |
|
| 388 | + $modx->db->delete($tbl_web_user_settings, "webuser='{$id}'"); |
|
| 389 | + |
|
| 390 | + foreach($settings as $n) { |
|
| 391 | + $vl = $_POST[$n]; |
|
| 392 | + if(is_array($vl)) { |
|
| 393 | + $vl = implode(",", $vl); |
|
| 394 | + } |
|
| 395 | + if($vl != '') { |
|
| 396 | + $f = array(); |
|
| 397 | + $f['webuser'] = $id; |
|
| 398 | + $f['setting_name'] = $n; |
|
| 399 | + $f['setting_value'] = $vl; |
|
| 400 | + $f = $modx->db->escape($f); |
|
| 401 | + $modx->db->insert($f, $tbl_web_user_settings); |
|
| 402 | + } |
|
| 403 | + } |
|
| 404 | 404 | } |
| 405 | 405 | |
| 406 | 406 | // Web alert - sends an alert to web browser |
| 407 | 407 | function webAlertAndQuit($msg) { |
| 408 | - global $id, $modx; |
|
| 409 | - $mode = $_POST['mode']; |
|
| 410 | - $modx->manager->saveFormValues($mode); |
|
| 411 | - $modx->webAlertAndQuit($msg, "index.php?a={$mode}" . ($mode == '88' ? "&id={$id}" : '')); |
|
| 408 | + global $id, $modx; |
|
| 409 | + $mode = $_POST['mode']; |
|
| 410 | + $modx->manager->saveFormValues($mode); |
|
| 411 | + $modx->webAlertAndQuit($msg, "index.php?a={$mode}" . ($mode == '88' ? "&id={$id}" : '')); |
|
| 412 | 412 | } |
| 413 | 413 | |
| 414 | 414 | // Generate password |
| 415 | 415 | function generate_password($length = 10) { |
| 416 | - $allowable_characters = "abcdefghjkmnpqrstuvxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789"; |
|
| 417 | - $ps_len = strlen($allowable_characters); |
|
| 418 | - mt_srand((double) microtime() * 1000000); |
|
| 419 | - $pass = ""; |
|
| 420 | - for($i = 0; $i < $length; $i++) { |
|
| 421 | - $pass .= $allowable_characters[mt_rand(0, $ps_len - 1)]; |
|
| 422 | - } |
|
| 423 | - return $pass; |
|
| 416 | + $allowable_characters = "abcdefghjkmnpqrstuvxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789"; |
|
| 417 | + $ps_len = strlen($allowable_characters); |
|
| 418 | + mt_srand((double) microtime() * 1000000); |
|
| 419 | + $pass = ""; |
|
| 420 | + for($i = 0; $i < $length; $i++) { |
|
| 421 | + $pass .= $allowable_characters[mt_rand(0, $ps_len - 1)]; |
|
| 422 | + } |
|
| 423 | + return $pass; |
|
| 424 | 424 | } |
| 425 | 425 | |
| 426 | 426 | function sanitize($str = '', $safecount = 0) { |
| 427 | - global $modx; |
|
| 428 | - $safecount++; |
|
| 429 | - if(1000 < $safecount) { |
|
| 430 | - exit("error too many loops '{$safecount}'"); |
|
| 431 | - } |
|
| 432 | - if(is_array($str)) { |
|
| 433 | - foreach($str as $i => $v) { |
|
| 434 | - $str[$i] = sanitize($v, $safecount); |
|
| 435 | - } |
|
| 436 | - } else { |
|
| 437 | - // $str = strip_tags($str); // LEAVE < and > intact |
|
| 438 | - $str = htmlspecialchars($str, ENT_NOQUOTES, $modx->config['modx_charset']); |
|
| 439 | - } |
|
| 440 | - return $str; |
|
| 427 | + global $modx; |
|
| 428 | + $safecount++; |
|
| 429 | + if(1000 < $safecount) { |
|
| 430 | + exit("error too many loops '{$safecount}'"); |
|
| 431 | + } |
|
| 432 | + if(is_array($str)) { |
|
| 433 | + foreach($str as $i => $v) { |
|
| 434 | + $str[$i] = sanitize($v, $safecount); |
|
| 435 | + } |
|
| 436 | + } else { |
|
| 437 | + // $str = strip_tags($str); // LEAVE < and > intact |
|
| 438 | + $str = htmlspecialchars($str, ENT_NOQUOTES, $modx->config['modx_charset']); |
|
| 439 | + } |
|
| 440 | + return $str; |
|
| 441 | 441 | } |
@@ -9,34 +9,34 @@ discard block |
||
| 9 | 9 | |
| 10 | 10 | public function checkPermissions() { |
| 11 | 11 | |
| 12 | - global $udperms_allowroot; |
|
| 13 | - global $modx; |
|
| 12 | + global $udperms_allowroot; |
|
| 13 | + global $modx; |
|
| 14 | 14 | |
| 15 | - $tblsc = $modx->getFullTableName('site_content'); |
|
| 16 | - $tbldg = $modx->getFullTableName('document_groups'); |
|
| 17 | - $tbldgn = $modx->getFullTableName('documentgroup_names'); |
|
| 15 | + $tblsc = $modx->getFullTableName('site_content'); |
|
| 16 | + $tbldg = $modx->getFullTableName('document_groups'); |
|
| 17 | + $tbldgn = $modx->getFullTableName('documentgroup_names'); |
|
| 18 | 18 | |
| 19 | - $document = $this->document; |
|
| 20 | - $role = $this->role; |
|
| 19 | + $document = $this->document; |
|
| 20 | + $role = $this->role; |
|
| 21 | 21 | |
| 22 | - if($role==1) { |
|
| 23 | - return true; // administrator - grant all document permissions |
|
| 24 | - } |
|
| 22 | + if($role==1) { |
|
| 23 | + return true; // administrator - grant all document permissions |
|
| 24 | + } |
|
| 25 | 25 | |
| 26 | - if($modx->config['use_udperms']==0 || $modx->config['use_udperms']=="" || !isset($modx->config['use_udperms'])) { |
|
| 27 | - return true; // permissions aren't in use |
|
| 28 | - } |
|
| 26 | + if($modx->config['use_udperms']==0 || $modx->config['use_udperms']=="" || !isset($modx->config['use_udperms'])) { |
|
| 27 | + return true; // permissions aren't in use |
|
| 28 | + } |
|
| 29 | 29 | |
| 30 | - $parent = $modx->db->getValue($modx->db->select('parent', $tblsc, "id='{$this->document}'")); |
|
| 31 | - if($document == 0 && $parent == NULL && $udperms_allowroot == 1) return true; // User is allowed to create new document in root |
|
| 32 | - if (($this->duplicateDoc==true || $document==0) && $parent==0 && $udperms_allowroot==0) { |
|
| 33 | - return false; // deny duplicate || create new document at root if Allow Root is No |
|
| 34 | - } |
|
| 30 | + $parent = $modx->db->getValue($modx->db->select('parent', $tblsc, "id='{$this->document}'")); |
|
| 31 | + if($document == 0 && $parent == NULL && $udperms_allowroot == 1) return true; // User is allowed to create new document in root |
|
| 32 | + if (($this->duplicateDoc==true || $document==0) && $parent==0 && $udperms_allowroot==0) { |
|
| 33 | + return false; // deny duplicate || create new document at root if Allow Root is No |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | - // get document groups for current user |
|
| 36 | + // get document groups for current user |
|
| 37 | 37 | $docgrp = empty($_SESSION['mgrDocgroups']) ? '' : implode(' || dg.document_group = ', $_SESSION['mgrDocgroups']); |
| 38 | 38 | |
| 39 | - /* Note: |
|
| 39 | + /* Note: |
|
| 40 | 40 | A document is flagged as private whenever the document group that it |
| 41 | 41 | belongs to is assigned or links to a user group. In other words if |
| 42 | 42 | the document is assigned to a document group that is not yet linked |
@@ -44,18 +44,18 @@ discard block |
||
| 44 | 44 | are private to the manager users will not be private to web users if the |
| 45 | 45 | document group is not assigned to a web user group and visa versa. |
| 46 | 46 | */ |
| 47 | - $permissionsok = false; // set permissions to false |
|
| 47 | + $permissionsok = false; // set permissions to false |
|
| 48 | 48 | |
| 49 | - $rs = $modx->db->select( |
|
| 50 | - 'count(DISTINCT sc.id)', |
|
| 51 | - "{$tblsc} AS sc |
|
| 49 | + $rs = $modx->db->select( |
|
| 50 | + 'count(DISTINCT sc.id)', |
|
| 51 | + "{$tblsc} AS sc |
|
| 52 | 52 | LEFT JOIN {$tbldg} AS dg on dg.document = sc.id |
| 53 | 53 | LEFT JOIN {$tbldgn} dgn ON dgn.id = dg.document_group", |
| 54 | - "sc.id='{$this->document}' AND (". (empty($docgrp) ? '' : "dg.document_group = ".$docgrp." ||" ) . " sc.privatemgr = 0)" |
|
| 55 | - ); |
|
| 56 | - $limit = $modx->db->getValue($rs); |
|
| 57 | - if($limit==1) $permissionsok = true; |
|
| 54 | + "sc.id='{$this->document}' AND (". (empty($docgrp) ? '' : "dg.document_group = ".$docgrp." ||" ) . " sc.privatemgr = 0)" |
|
| 55 | + ); |
|
| 56 | + $limit = $modx->db->getValue($rs); |
|
| 57 | + if($limit==1) $permissionsok = true; |
|
| 58 | 58 | |
| 59 | - return $permissionsok; |
|
| 60 | - } |
|
| 59 | + return $permissionsok; |
|
| 60 | + } |
|
| 61 | 61 | } |
@@ -3,21 +3,21 @@ 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 | // create globally unique identifiers (guid) |
| 15 | 15 | function createGUID(){ |
| 16 | - srand((double)microtime()*1000000); |
|
| 17 | - $r = rand() ; |
|
| 18 | - $u = uniqid(getmypid() . $r . (double)microtime()*1000000,1); |
|
| 19 | - $m = md5 ($u); |
|
| 20 | - return $m; |
|
| 16 | + srand((double)microtime()*1000000); |
|
| 17 | + $r = rand() ; |
|
| 18 | + $u = uniqid(getmypid() . $r . (double)microtime()*1000000,1); |
|
| 19 | + $m = md5 ($u); |
|
| 20 | + return $m; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | // count duplicates |
@@ -28,40 +28,40 @@ discard block |
||
| 28 | 28 | |
| 29 | 29 | // duplicate module |
| 30 | 30 | $newid = $modx->db->insert( |
| 31 | - array( |
|
| 32 | - 'name'=>'', |
|
| 33 | - 'description'=>'', |
|
| 34 | - 'disabled'=>'', |
|
| 35 | - 'category'=>'', |
|
| 36 | - 'wrap'=>'', |
|
| 37 | - 'icon'=>'', |
|
| 38 | - 'enable_resource'=>'', |
|
| 39 | - 'resourcefile'=>'', |
|
| 40 | - 'createdon'=>'', |
|
| 41 | - 'editedon'=>'', |
|
| 42 | - 'guid'=>'', |
|
| 43 | - 'enable_sharedparams'=>'', |
|
| 44 | - 'properties'=>'', |
|
| 45 | - 'modulecode'=>'', |
|
| 46 | - ), $modx->getFullTableName('site_modules'), // Insert into |
|
| 47 | - "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 |
|
| 31 | + array( |
|
| 32 | + 'name'=>'', |
|
| 33 | + 'description'=>'', |
|
| 34 | + 'disabled'=>'', |
|
| 35 | + 'category'=>'', |
|
| 36 | + 'wrap'=>'', |
|
| 37 | + 'icon'=>'', |
|
| 38 | + 'enable_resource'=>'', |
|
| 39 | + 'resourcefile'=>'', |
|
| 40 | + 'createdon'=>'', |
|
| 41 | + 'editedon'=>'', |
|
| 42 | + 'guid'=>'', |
|
| 43 | + 'enable_sharedparams'=>'', |
|
| 44 | + 'properties'=>'', |
|
| 45 | + 'modulecode'=>'', |
|
| 46 | + ), $modx->getFullTableName('site_modules'), // Insert into |
|
| 47 | + "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 |
|
| 48 | 48 | |
| 49 | 49 | // duplicate module dependencies |
| 50 | 50 | $modx->db->insert( |
| 51 | - array( |
|
| 52 | - 'module'=>'', |
|
| 53 | - 'resource'=>'', |
|
| 54 | - 'type'=>'', |
|
| 55 | - ), $modx->getFullTableName('site_module_depobj'), // Insert into |
|
| 56 | - "'{$newid}', resource, type", $modx->getFullTableName('site_module_depobj'), "module='{$id}'"); // Copy from |
|
| 51 | + array( |
|
| 52 | + 'module'=>'', |
|
| 53 | + 'resource'=>'', |
|
| 54 | + 'type'=>'', |
|
| 55 | + ), $modx->getFullTableName('site_module_depobj'), // Insert into |
|
| 56 | + "'{$newid}', resource, type", $modx->getFullTableName('site_module_depobj'), "module='{$id}'"); // Copy from |
|
| 57 | 57 | |
| 58 | 58 | // duplicate module user group access |
| 59 | 59 | $modx->db->insert( |
| 60 | - array( |
|
| 61 | - 'module'=>'', |
|
| 62 | - 'usergroup'=>'', |
|
| 63 | - ), $modx->getFullTableName('site_module_access'), // Insert into |
|
| 64 | - "'{$newid}', usergroup", $modx->getFullTableName('site_module_access'), "module='{$id}'"); // Copy from |
|
| 60 | + array( |
|
| 61 | + 'module'=>'', |
|
| 62 | + 'usergroup'=>'', |
|
| 63 | + ), $modx->getFullTableName('site_module_access'), // Insert into |
|
| 64 | + "'{$newid}', usergroup", $modx->getFullTableName('site_module_access'), "module='{$id}'"); // Copy from |
|
| 65 | 65 | |
| 66 | 66 | // Set the item name for logger |
| 67 | 67 | $name = $modx->db->getValue($modx->db->select('name', $modx->getFullTableName('site_modules'), "id='{$newid}'")); |
@@ -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_document') || !$modx->hasPermission('save_document')) { |
| 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 | $children = array(); |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | $udperms->duplicateDoc = true; |
| 23 | 23 | |
| 24 | 24 | if(!$udperms->checkPermissions()) { |
| 25 | - $modx->webAlertAndQuit($_lang["access_permission_denied"]); |
|
| 25 | + $modx->webAlertAndQuit($_lang["access_permission_denied"]); |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | // Run the duplicator |
@@ -37,125 +37,125 @@ discard block |
||
| 37 | 37 | header($header); |
| 38 | 38 | |
| 39 | 39 | function duplicateDocument($docid, $parent=null, $_toplevel=0) { |
| 40 | - global $modx, $_lang; |
|
| 41 | - |
|
| 42 | - // invoke OnBeforeDocDuplicate event |
|
| 43 | - $evtOut = $modx->invokeEvent('OnBeforeDocDuplicate', array( |
|
| 44 | - 'id' => $docid |
|
| 45 | - )); |
|
| 46 | - |
|
| 47 | - // if( !in_array( 'false', array_values( $evtOut ) ) ){} |
|
| 48 | - // TODO: Determine necessary handling for duplicateDocument "return $newparent" if OnBeforeDocDuplicate were able to conditially control duplication |
|
| 49 | - // [DISABLED]: Proceed with duplicateDocument if OnBeforeDocDuplicate did not return false via: $event->output('false'); |
|
| 50 | - |
|
| 51 | - $userID = $modx->getLoginUserID(); |
|
| 52 | - |
|
| 53 | - $tblsc = $modx->getFullTableName('site_content'); |
|
| 54 | - |
|
| 55 | - // Grab the original document |
|
| 56 | - $rs = $modx->db->select('*', $tblsc, "id='{$docid}'"); |
|
| 57 | - $content = $modx->db->getRow($rs); |
|
| 58 | - |
|
| 59 | - // Handle incremental ID |
|
| 60 | - switch($modx->config['docid_incrmnt_method']) |
|
| 61 | - { |
|
| 62 | - case '1': |
|
| 63 | - $from = "{$tblsc} AS T0 LEFT JOIN {$tblsc} AS T1 ON T0.id + 1 = T1.id"; |
|
| 64 | - $rs = $modx->db->select('MIN(T0.id)+1', $from, "T1.id IS NULL"); |
|
| 65 | - $content['id'] = $modx->db->getValue($rs); |
|
| 66 | - break; |
|
| 67 | - case '2': |
|
| 68 | - $rs = $modx->db->select('MAX(id)+1',$tblsc); |
|
| 69 | - $content['id'] = $modx->db->getValue($rs); |
|
| 70 | - break; |
|
| 71 | - |
|
| 72 | - default: |
|
| 73 | - unset($content['id']); // remove the current id. |
|
| 74 | - } |
|
| 75 | - |
|
| 76 | - // Once we've grabbed the document object, start doing some modifications |
|
| 77 | - if ($_toplevel == 0) { |
|
| 78 | - // count duplicates |
|
| 79 | - $pagetitle = $modx->db->getValue($modx->db->select('pagetitle', $modx->getFullTableName('site_content'), "id='{$docid}'")); |
|
| 80 | - $pagetitle = $modx->db->escape($pagetitle); |
|
| 81 | - $count = $modx->db->getRecordCount($modx->db->select('pagetitle', $modx->getFullTableName('site_content'), "pagetitle LIKE '{$pagetitle} Duplicate%'")); |
|
| 82 | - if($count>=1) $count = ' '.($count+1); |
|
| 83 | - else $count = ''; |
|
| 84 | - |
|
| 85 | - $content['pagetitle'] = $_lang['duplicated_el_suffix'].$count.' '.$content['pagetitle']; |
|
| 86 | - $content['alias'] = null; |
|
| 87 | - } elseif($modx->config['friendly_urls'] == 0 || $modx->config['allow_duplicate_alias'] == 0) { |
|
| 88 | - $content['alias'] = null; |
|
| 89 | - } |
|
| 90 | - |
|
| 91 | - // change the parent accordingly |
|
| 92 | - if ($parent !== null) $content['parent'] = $parent; |
|
| 93 | - |
|
| 94 | - // Change the author |
|
| 95 | - $content['createdby'] = $userID; |
|
| 96 | - $content['createdon'] = time(); |
|
| 97 | - // Remove other modification times |
|
| 98 | - $content['editedby'] = $content['editedon'] = $content['deleted'] = $content['deletedby'] = $content['deletedon'] = 0; |
|
| 99 | - |
|
| 100 | - // [FS#922] Should the published status be honored? - sirlancelot |
|
| 40 | + global $modx, $_lang; |
|
| 41 | + |
|
| 42 | + // invoke OnBeforeDocDuplicate event |
|
| 43 | + $evtOut = $modx->invokeEvent('OnBeforeDocDuplicate', array( |
|
| 44 | + 'id' => $docid |
|
| 45 | + )); |
|
| 46 | + |
|
| 47 | + // if( !in_array( 'false', array_values( $evtOut ) ) ){} |
|
| 48 | + // TODO: Determine necessary handling for duplicateDocument "return $newparent" if OnBeforeDocDuplicate were able to conditially control duplication |
|
| 49 | + // [DISABLED]: Proceed with duplicateDocument if OnBeforeDocDuplicate did not return false via: $event->output('false'); |
|
| 50 | + |
|
| 51 | + $userID = $modx->getLoginUserID(); |
|
| 52 | + |
|
| 53 | + $tblsc = $modx->getFullTableName('site_content'); |
|
| 54 | + |
|
| 55 | + // Grab the original document |
|
| 56 | + $rs = $modx->db->select('*', $tblsc, "id='{$docid}'"); |
|
| 57 | + $content = $modx->db->getRow($rs); |
|
| 58 | + |
|
| 59 | + // Handle incremental ID |
|
| 60 | + switch($modx->config['docid_incrmnt_method']) |
|
| 61 | + { |
|
| 62 | + case '1': |
|
| 63 | + $from = "{$tblsc} AS T0 LEFT JOIN {$tblsc} AS T1 ON T0.id + 1 = T1.id"; |
|
| 64 | + $rs = $modx->db->select('MIN(T0.id)+1', $from, "T1.id IS NULL"); |
|
| 65 | + $content['id'] = $modx->db->getValue($rs); |
|
| 66 | + break; |
|
| 67 | + case '2': |
|
| 68 | + $rs = $modx->db->select('MAX(id)+1',$tblsc); |
|
| 69 | + $content['id'] = $modx->db->getValue($rs); |
|
| 70 | + break; |
|
| 71 | + |
|
| 72 | + default: |
|
| 73 | + unset($content['id']); // remove the current id. |
|
| 74 | + } |
|
| 75 | + |
|
| 76 | + // Once we've grabbed the document object, start doing some modifications |
|
| 77 | + if ($_toplevel == 0) { |
|
| 78 | + // count duplicates |
|
| 79 | + $pagetitle = $modx->db->getValue($modx->db->select('pagetitle', $modx->getFullTableName('site_content'), "id='{$docid}'")); |
|
| 80 | + $pagetitle = $modx->db->escape($pagetitle); |
|
| 81 | + $count = $modx->db->getRecordCount($modx->db->select('pagetitle', $modx->getFullTableName('site_content'), "pagetitle LIKE '{$pagetitle} Duplicate%'")); |
|
| 82 | + if($count>=1) $count = ' '.($count+1); |
|
| 83 | + else $count = ''; |
|
| 84 | + |
|
| 85 | + $content['pagetitle'] = $_lang['duplicated_el_suffix'].$count.' '.$content['pagetitle']; |
|
| 86 | + $content['alias'] = null; |
|
| 87 | + } elseif($modx->config['friendly_urls'] == 0 || $modx->config['allow_duplicate_alias'] == 0) { |
|
| 88 | + $content['alias'] = null; |
|
| 89 | + } |
|
| 90 | + |
|
| 91 | + // change the parent accordingly |
|
| 92 | + if ($parent !== null) $content['parent'] = $parent; |
|
| 93 | + |
|
| 94 | + // Change the author |
|
| 95 | + $content['createdby'] = $userID; |
|
| 96 | + $content['createdon'] = time(); |
|
| 97 | + // Remove other modification times |
|
| 98 | + $content['editedby'] = $content['editedon'] = $content['deleted'] = $content['deletedby'] = $content['deletedon'] = 0; |
|
| 99 | + |
|
| 100 | + // [FS#922] Should the published status be honored? - sirlancelot |
|
| 101 | 101 | // if ($modx->hasPermission('publish_document')) { |
| 102 | 102 | // if ($modx->config['publish_default']) |
| 103 | 103 | // $content['pub_date'] = $content['pub_date']; // should this be changed to 1? |
| 104 | 104 | // else $content['pub_date'] = 0; |
| 105 | 105 | // } else { |
| 106 | - // User can't publish documents |
|
| 106 | + // User can't publish documents |
|
| 107 | 107 | // $content['published'] = $content['pub_date'] = 0; |
| 108 | 108 | // } |
| 109 | 109 | |
| 110 | 110 | // Set the published status to unpublished by default (see above ... commit #3388) |
| 111 | 111 | $content['published'] = $content['pub_date'] = 0; |
| 112 | 112 | |
| 113 | - // Escape the proper strings |
|
| 114 | - $content = $modx->db->escape($content); |
|
| 113 | + // Escape the proper strings |
|
| 114 | + $content = $modx->db->escape($content); |
|
| 115 | 115 | |
| 116 | - // Duplicate the Document |
|
| 117 | - $newparent = $modx->db->insert($content, $tblsc); |
|
| 116 | + // Duplicate the Document |
|
| 117 | + $newparent = $modx->db->insert($content, $tblsc); |
|
| 118 | 118 | |
| 119 | - // duplicate document's TVs |
|
| 120 | - duplicateTVs($docid, $newparent); |
|
| 121 | - duplicateAccess($docid, $newparent); |
|
| 119 | + // duplicate document's TVs |
|
| 120 | + duplicateTVs($docid, $newparent); |
|
| 121 | + duplicateAccess($docid, $newparent); |
|
| 122 | 122 | |
| 123 | - // invoke OnDocDuplicate event |
|
| 124 | - $evtOut = $modx->invokeEvent('OnDocDuplicate', array( |
|
| 125 | - 'id' => $docid, |
|
| 126 | - 'new_id' => $newparent |
|
| 127 | - )); |
|
| 123 | + // invoke OnDocDuplicate event |
|
| 124 | + $evtOut = $modx->invokeEvent('OnDocDuplicate', array( |
|
| 125 | + 'id' => $docid, |
|
| 126 | + 'new_id' => $newparent |
|
| 127 | + )); |
|
| 128 | 128 | |
| 129 | - // Start duplicating all the child documents that aren't deleted. |
|
| 130 | - $_toplevel++; |
|
| 131 | - $rs = $modx->db->select('id', $tblsc, "parent='{$docid}' AND deleted=0", 'id ASC'); |
|
| 132 | - while ($row = $modx->db->getRow($rs)) |
|
| 133 | - duplicateDocument($row['id'], $newparent, $_toplevel); |
|
| 129 | + // Start duplicating all the child documents that aren't deleted. |
|
| 130 | + $_toplevel++; |
|
| 131 | + $rs = $modx->db->select('id', $tblsc, "parent='{$docid}' AND deleted=0", 'id ASC'); |
|
| 132 | + while ($row = $modx->db->getRow($rs)) |
|
| 133 | + duplicateDocument($row['id'], $newparent, $_toplevel); |
|
| 134 | 134 | |
| 135 | - // return the new doc id |
|
| 136 | - return $newparent; |
|
| 135 | + // return the new doc id |
|
| 136 | + return $newparent; |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | // Duplicate Document TVs |
| 140 | 140 | function duplicateTVs($oldid,$newid){ |
| 141 | - global $modx; |
|
| 141 | + global $modx; |
|
| 142 | 142 | |
| 143 | - $tbltvc = $modx->getFullTableName('site_tmplvar_contentvalues'); |
|
| 143 | + $tbltvc = $modx->getFullTableName('site_tmplvar_contentvalues'); |
|
| 144 | 144 | |
| 145 | - $modx->db->insert( |
|
| 146 | - array('contentid'=>'', 'tmplvarid'=>'', 'value'=>''), $tbltvc, // Insert into |
|
| 147 | - "{$newid}, tmplvarid, value", $tbltvc, "contentid='{$oldid}'" // Copy from |
|
| 148 | - ); |
|
| 145 | + $modx->db->insert( |
|
| 146 | + array('contentid'=>'', 'tmplvarid'=>'', 'value'=>''), $tbltvc, // Insert into |
|
| 147 | + "{$newid}, tmplvarid, value", $tbltvc, "contentid='{$oldid}'" // Copy from |
|
| 148 | + ); |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | // Duplicate Document Access Permissions |
| 152 | 152 | function duplicateAccess($oldid,$newid){ |
| 153 | - global $modx; |
|
| 153 | + global $modx; |
|
| 154 | 154 | |
| 155 | - $tbldg = $modx->getFullTableName('document_groups'); |
|
| 155 | + $tbldg = $modx->getFullTableName('document_groups'); |
|
| 156 | 156 | |
| 157 | - $modx->db->insert( |
|
| 158 | - array('document'=>'', 'document_group'=>''), $tbldg, // Insert into |
|
| 159 | - "{$newid}, document_group", $tbldg, "document='{$oldid}'" // Copy from |
|
| 160 | - ); |
|
| 157 | + $modx->db->insert( |
|
| 158 | + array('document'=>'', 'document_group'=>''), $tbldg, // Insert into |
|
| 159 | + "{$newid}, document_group", $tbldg, "document='{$oldid}'" // Copy from |
|
| 160 | + ); |
|
| 161 | 161 | } |
@@ -3,51 +3,51 @@ 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('exec_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 | // check if user has access permission, except admins |
| 15 | 15 | if($_SESSION['mgrRole']!=1){ |
| 16 | - $rs = $modx->db->select( |
|
| 17 | - 'sma.usergroup,mg.member', |
|
| 18 | - $modx->getFullTableName("site_module_access")." sma |
|
| 16 | + $rs = $modx->db->select( |
|
| 17 | + 'sma.usergroup,mg.member', |
|
| 18 | + $modx->getFullTableName("site_module_access")." sma |
|
| 19 | 19 | LEFT JOIN ".$modx->getFullTableName("member_groups")." mg ON mg.user_group = sma.usergroup AND member='".$modx->getLoginUserID()."'", |
| 20 | - "sma.module = '{$id}'" |
|
| 21 | - ); |
|
| 22 | - //initialize permission to -1, if it stays -1 no permissions |
|
| 23 | - //attached so permission granted |
|
| 24 | - $permissionAccessInt = -1; |
|
| 20 | + "sma.module = '{$id}'" |
|
| 21 | + ); |
|
| 22 | + //initialize permission to -1, if it stays -1 no permissions |
|
| 23 | + //attached so permission granted |
|
| 24 | + $permissionAccessInt = -1; |
|
| 25 | 25 | |
| 26 | - while ($row = $modx->db->getRow($rs)) { |
|
| 27 | - if($row["usergroup"] && $row["member"]) { |
|
| 28 | - //if there are permissions and this member has permission, ofcourse |
|
| 29 | - //this is granted |
|
| 30 | - $permissionAccessInt = 1; |
|
| 31 | - } elseif ($permissionAccessInt==-1) { |
|
| 32 | - //if there are permissions but this member has no permission and the |
|
| 33 | - //variable was still in init state we set permission to 0; no permissions |
|
| 34 | - $permissionAccessInt = 0; |
|
| 35 | - } |
|
| 36 | - } |
|
| 26 | + while ($row = $modx->db->getRow($rs)) { |
|
| 27 | + if($row["usergroup"] && $row["member"]) { |
|
| 28 | + //if there are permissions and this member has permission, ofcourse |
|
| 29 | + //this is granted |
|
| 30 | + $permissionAccessInt = 1; |
|
| 31 | + } elseif ($permissionAccessInt==-1) { |
|
| 32 | + //if there are permissions but this member has no permission and the |
|
| 33 | + //variable was still in init state we set permission to 0; no permissions |
|
| 34 | + $permissionAccessInt = 0; |
|
| 35 | + } |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | - if($permissionAccessInt==0) { |
|
| 39 | - $modx->webAlertAndQuit("You do not sufficient privileges to execute this module.", "index.php?a=106"); |
|
| 40 | - } |
|
| 38 | + if($permissionAccessInt==0) { |
|
| 39 | + $modx->webAlertAndQuit("You do not sufficient privileges to execute this module.", "index.php?a=106"); |
|
| 40 | + } |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | // get module data |
| 44 | 44 | $rs = $modx->db->select('*', $modx->getFullTableName("site_modules"), "id='{$id}'"); |
| 45 | 45 | $content = $modx->db->getRow($rs); |
| 46 | 46 | if(!$content) { |
| 47 | - $modx->webAlertAndQuit("No record found for id {$id}.", "index.php?a=106"); |
|
| 47 | + $modx->webAlertAndQuit("No record found for id {$id}.", "index.php?a=106"); |
|
| 48 | 48 | } |
| 49 | 49 | if($content['disabled']) { |
| 50 | - $modx->webAlertAndQuit("This module is disabled and cannot be executed.", "index.php?a=106"); |
|
| 50 | + $modx->webAlertAndQuit("This module is disabled and cannot be executed.", "index.php?a=106"); |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | // Set the item name for logger |
@@ -65,38 +65,38 @@ discard block |
||
| 65 | 65 | |
| 66 | 66 | // evalModule |
| 67 | 67 | function evalModule($moduleCode,$params){ |
| 68 | - global $modx; |
|
| 69 | - $modx->event->params = &$params; // store params inside event object |
|
| 70 | - if(is_array($params)) { |
|
| 71 | - extract($params, EXTR_SKIP); |
|
| 72 | - } |
|
| 73 | - ob_start(); |
|
| 74 | - $mod = eval($moduleCode); |
|
| 75 | - $msg = ob_get_contents(); |
|
| 76 | - ob_end_clean(); |
|
| 77 | - if (isset($php_errormsg)) |
|
| 78 | - { |
|
| 79 | - $error_info = error_get_last(); |
|
| 68 | + global $modx; |
|
| 69 | + $modx->event->params = &$params; // store params inside event object |
|
| 70 | + if(is_array($params)) { |
|
| 71 | + extract($params, EXTR_SKIP); |
|
| 72 | + } |
|
| 73 | + ob_start(); |
|
| 74 | + $mod = eval($moduleCode); |
|
| 75 | + $msg = ob_get_contents(); |
|
| 76 | + ob_end_clean(); |
|
| 77 | + if (isset($php_errormsg)) |
|
| 78 | + { |
|
| 79 | + $error_info = error_get_last(); |
|
| 80 | 80 | switch($error_info['type']) |
| 81 | 81 | { |
| 82 | - case E_NOTICE : |
|
| 83 | - $error_level = 1; |
|
| 84 | - case E_USER_NOTICE : |
|
| 85 | - break; |
|
| 86 | - case E_DEPRECATED : |
|
| 87 | - case E_USER_DEPRECATED : |
|
| 88 | - case E_STRICT : |
|
| 89 | - $error_level = 2; |
|
| 90 | - break; |
|
| 91 | - default: |
|
| 92 | - $error_level = 99; |
|
| 82 | + case E_NOTICE : |
|
| 83 | + $error_level = 1; |
|
| 84 | + case E_USER_NOTICE : |
|
| 85 | + break; |
|
| 86 | + case E_DEPRECATED : |
|
| 87 | + case E_USER_DEPRECATED : |
|
| 88 | + case E_STRICT : |
|
| 89 | + $error_level = 2; |
|
| 90 | + break; |
|
| 91 | + default: |
|
| 92 | + $error_level = 99; |
|
| 93 | + } |
|
| 94 | + if($modx->config['error_reporting']==='99' || 2<$error_level) |
|
| 95 | + { |
|
| 96 | + $modx->messageQuit('PHP Parse Error', '', true, $error_info['type'], $error_info['file'], $_SESSION['itemname'] . ' - Module', $error_info['message'], $error_info['line'], $msg); |
|
| 97 | + $modx->event->alert("An error occurred while loading. Please see the event log for more information<p>{$msg}</p>"); |
|
| 93 | 98 | } |
| 94 | - if($modx->config['error_reporting']==='99' || 2<$error_level) |
|
| 95 | - { |
|
| 96 | - $modx->messageQuit('PHP Parse Error', '', true, $error_info['type'], $error_info['file'], $_SESSION['itemname'] . ' - Module', $error_info['message'], $error_info['line'], $msg); |
|
| 97 | - $modx->event->alert("An error occurred while loading. Please see the event log for more information<p>{$msg}</p>"); |
|
| 98 | - } |
|
| 99 | - } |
|
| 100 | - unset($modx->event->params); |
|
| 101 | - return $mod.$msg; |
|
| 99 | + } |
|
| 100 | + unset($modx->event->params); |
|
| 101 | + return $mod.$msg; |
|
| 102 | 102 | } |
@@ -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_snippet')) { |
| 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 | // count duplicates |
@@ -19,14 +19,14 @@ discard block |
||
| 19 | 19 | |
| 20 | 20 | // duplicate Snippet |
| 21 | 21 | $newid = $modx->db->insert( |
| 22 | - array( |
|
| 23 | - 'name'=>'', |
|
| 24 | - 'description'=>'', |
|
| 25 | - 'snippet'=>'', |
|
| 26 | - 'properties'=>'', |
|
| 27 | - 'category'=>'', |
|
| 28 | - ), $modx->getFullTableName('site_snippets'), // Insert into |
|
| 29 | - "CONCAT(name, ' {$_lang['duplicated_el_suffix']}{$count}') AS name, description, snippet, properties, category", $modx->getFullTableName('site_snippets'), "id='{$id}'"); // Copy from |
|
| 22 | + array( |
|
| 23 | + 'name'=>'', |
|
| 24 | + 'description'=>'', |
|
| 25 | + 'snippet'=>'', |
|
| 26 | + 'properties'=>'', |
|
| 27 | + 'category'=>'', |
|
| 28 | + ), $modx->getFullTableName('site_snippets'), // Insert into |
|
| 29 | + "CONCAT(name, ' {$_lang['duplicated_el_suffix']}{$count}') AS name, description, snippet, properties, category", $modx->getFullTableName('site_snippets'), "id='{$id}'"); // Copy from |
|
| 30 | 30 | |
| 31 | 31 | // Set the item name for logger |
| 32 | 32 | $name = $modx->db->getValue($modx->db->select('name', $modx->getFullTableName('site_snippets'), "id='{$newid}'")); |