@@ -33,6 +33,10 @@ |
||
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | if( ! function_exists('parse')) { |
| 36 | + |
|
| 37 | + /** |
|
| 38 | + * @param string $src |
|
| 39 | + */ |
|
| 36 | 40 | function parse($src, $ph, $left = '[+', $right = '+]') |
| 37 | 41 | { |
| 38 | 42 | foreach ($ph as $k => $v) { |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if( ! function_exists('install_sessionCheck')) { |
|
| 2 | +if (!function_exists('install_sessionCheck')) { |
|
| 3 | 3 | function install_sessionCheck() |
| 4 | 4 | { |
| 5 | 5 | global $_lang; |
@@ -21,8 +21,8 @@ discard block |
||
| 21 | 21 | </head> |
| 22 | 22 | <body> |
| 23 | 23 | <div class="install"> |
| 24 | - <p>' . $_lang["session_problem"] . '</p> |
|
| 25 | - <p><a href="./">' . $_lang["session_problem_try_again"] . '</a></p> |
|
| 24 | + <p>' . $_lang["session_problem"].'</p> |
|
| 25 | + <p><a href="./">' . $_lang["session_problem_try_again"].'</a></p> |
|
| 26 | 26 | </div> |
| 27 | 27 | </body> |
| 28 | 28 | </html>'; |
@@ -32,11 +32,11 @@ discard block |
||
| 32 | 32 | } |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | -if( ! function_exists('parse')) { |
|
| 35 | +if (!function_exists('parse')) { |
|
| 36 | 36 | function parse($src, $ph, $left = '[+', $right = '+]') |
| 37 | 37 | { |
| 38 | 38 | foreach ($ph as $k => $v) { |
| 39 | - $k = $left . $k . $right; |
|
| 39 | + $k = $left.$k.$right; |
|
| 40 | 40 | $src = str_replace($k, $v, $src); |
| 41 | 41 | } |
| 42 | 42 | |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | } |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | -if( ! function_exists('ph')) { |
|
| 47 | +if (!function_exists('ph')) { |
|
| 48 | 48 | function ph() |
| 49 | 49 | { |
| 50 | 50 | global $_lang, $moduleName, $moduleVersion, $modx_textdir, $modx_release_date; |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | $ph['textdir'] = $modx_textdir ? ' id="rtl"' : ''; |
| 60 | 60 | $ph['help_link'] = $installmode == 0 ? $_lang['help_link_new'] : $_lang['help_link_upd']; |
| 61 | 61 | $ph['version'] = $moduleVersion; |
| 62 | - $ph['release_date'] = ($modx_textdir ? '‏' : '') . $modx_release_date; |
|
| 62 | + $ph['release_date'] = ($modx_textdir ? '‏' : '').$modx_release_date; |
|
| 63 | 63 | $ph['footer1'] = $_lang['modx_footer1']; |
| 64 | 64 | $ph['footer2'] = $_lang['modx_footer2']; |
| 65 | 65 | $ph['current_year'] = date('Y'); |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | } |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | -if( ! function_exists('get_installmode')) { |
|
| 71 | +if (!function_exists('get_installmode')) { |
|
| 72 | 72 | function get_installmode() |
| 73 | 73 | { |
| 74 | 74 | global $base_path, $database_server, $database_user, $database_password, $dbase, $table_prefix; |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | } |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | -if( ! function_exists('getLangs')) { |
|
| 130 | +if (!function_exists('getLangs')) { |
|
| 131 | 131 | /** |
| 132 | 132 | * @param $install_language |
| 133 | 133 | * @return string |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | $langs = array(); |
| 144 | - if ($handle = opendir("../" . MGR_DIR . "/includes/lang")) { |
|
| 144 | + if ($handle = opendir("../".MGR_DIR."/includes/lang")) { |
|
| 145 | 145 | while (false !== ($file = readdir($handle))) { |
| 146 | 146 | if (strpos($file, '.inc.') !== false) { |
| 147 | 147 | $langs[] = $file; |
@@ -18,6 +18,7 @@ |
||
| 18 | 18 | /** |
| 19 | 19 | * get_langs_by_key |
| 20 | 20 | * |
| 21 | + * @param string $key |
|
| 21 | 22 | * @return array of languages that define the key in their file |
| 22 | 23 | */ |
| 23 | 24 | function get_langs_by_key($key) {
|
@@ -4,9 +4,9 @@ discard block |
||
| 4 | 4 | * |
| 5 | 5 | * @return array of keys from a language file |
| 6 | 6 | */ |
| 7 | -function get_lang_keys($filename) {
|
|
| 8 | - $file = MODX_MANAGER_PATH.'includes/lang' . DIRECTORY_SEPARATOR . $filename; |
|
| 9 | - if(is_file($file) && is_readable($file)) {
|
|
| 7 | +function get_lang_keys($filename){
|
|
| 8 | + $file = MODX_MANAGER_PATH.'includes/lang'.DIRECTORY_SEPARATOR.$filename; |
|
| 9 | + if (is_file($file) && is_readable($file)) {
|
|
| 10 | 10 | include($file); |
| 11 | 11 | $out = isset($_lang) ? array_keys($_lang) : array(); |
| 12 | 12 | } else {
|
@@ -20,11 +20,11 @@ discard block |
||
| 20 | 20 | * |
| 21 | 21 | * @return array of languages that define the key in their file |
| 22 | 22 | */ |
| 23 | -function get_langs_by_key($key) {
|
|
| 23 | +function get_langs_by_key($key){
|
|
| 24 | 24 | global $lang_keys; |
| 25 | 25 | $lang_return = array(); |
| 26 | - foreach($lang_keys as $lang=>$keys) {
|
|
| 27 | - if(in_array($key, $keys)) {
|
|
| 26 | + foreach ($lang_keys as $lang=>$keys) {
|
|
| 27 | + if (in_array($key, $keys)) {
|
|
| 28 | 28 | $lang_return[] = $lang; |
| 29 | 29 | } |
| 30 | 30 | } |
@@ -40,15 +40,15 @@ discard block |
||
| 40 | 40 | * @param string $selected_lang specify language to select in option list, default none |
| 41 | 41 | * @return string html option list |
| 42 | 42 | */ |
| 43 | -function get_lang_options($key = '', $selected_lang=null) {
|
|
| 43 | +function get_lang_options($key = '', $selected_lang = null){
|
|
| 44 | 44 | global $lang_keys, $_lang; |
| 45 | 45 | $lang_options = ''; |
| 46 | - if( ! empty($key)) {
|
|
| 46 | + if (!empty($key)) {
|
|
| 47 | 47 | $languages = get_langs_by_key($key); |
| 48 | 48 | sort($languages); |
| 49 | 49 | $lang_options .= '<option value="">'.$_lang['language_title'].'</option>'; |
| 50 | 50 | |
| 51 | - foreach($languages as $language_name) {
|
|
| 51 | + foreach ($languages as $language_name) {
|
|
| 52 | 52 | $uclanguage_name = ucwords(str_replace("_", " ", $language_name));
|
| 53 | 53 | $lang_options .= '<option value="'.$language_name.'">'.$uclanguage_name.'</option>'; |
| 54 | 54 | } |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | } else {
|
| 57 | 57 | $languages = array_keys($lang_keys); |
| 58 | 58 | sort($languages); |
| 59 | - foreach($languages as $language_name) {
|
|
| 59 | + foreach ($languages as $language_name) {
|
|
| 60 | 60 | $uclanguage_name = ucwords(str_replace("_", " ", $language_name));
|
| 61 | 61 | $sel = $language_name == $selected_lang ? ' selected="selected"' : ''; |
| 62 | 62 | $lang_options .= '<option value="'.$language_name.'" '.$sel.'>'.$uclanguage_name.'</option>'; |
@@ -65,23 +65,23 @@ discard block |
||
| 65 | 65 | } |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | -function form_radio($name,$value,$add='',$disabled=false) {
|
|
| 68 | +function form_radio($name, $value, $add = '', $disabled = false){
|
|
| 69 | 69 | global ${$name};
|
| 70 | 70 | $var = ${$name};
|
| 71 | - $checked = ($var==$value) ? ' checked="checked"' : ''; |
|
| 72 | - if($disabled) $disabled = ' disabled'; else $disabled = ''; |
|
| 73 | - if($add) $add = ' ' . $add; |
|
| 71 | + $checked = ($var == $value) ? ' checked="checked"' : ''; |
|
| 72 | + if ($disabled) $disabled = ' disabled'; else $disabled = ''; |
|
| 73 | + if ($add) $add = ' '.$add; |
|
| 74 | 74 | return sprintf('<input onchange="documentDirty=true;" type="radio" name="%s" value="%s" %s %s %s />', $name, $value, $checked, $disabled, $add);
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | -function wrap_label($str='',$object) {
|
|
| 77 | +function wrap_label($str = '', $object){
|
|
| 78 | 78 | return "<label>{$object}\n{$str}</label>";
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | -function parseText($tpl='', $ph=array()) {
|
|
| 82 | - if(empty($ph) || empty($tpl)) return $tpl; |
|
| 81 | +function parseText($tpl = '', $ph = array()){
|
|
| 82 | + if (empty($ph) || empty($tpl)) return $tpl; |
|
| 83 | 83 | |
| 84 | - foreach($ph as $k=>$v) |
|
| 84 | + foreach ($ph as $k=>$v) |
|
| 85 | 85 | {
|
| 86 | 86 | $k = "[+{$k}+]";
|
| 87 | 87 | $tpl = str_replace($k, $v, $tpl); |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | return $tpl; |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | -function showHide($cond=true) {
|
|
| 92 | +function showHide($cond = true){
|
|
| 93 | 93 | global $displayStyle; |
| 94 | 94 | $showHide = $cond ? $displayStyle : 'none'; |
| 95 | 95 | return sprintf('style="display:%s"', $showHide);
|
@@ -4,12 +4,13 @@ discard block |
||
| 4 | 4 | * |
| 5 | 5 | * @return array of keys from a language file |
| 6 | 6 | */ |
| 7 | -function get_lang_keys($filename) {
|
|
| 7 | +function get_lang_keys($filename) |
|
| 8 | +{ |
|
| 8 | 9 | $file = MODX_MANAGER_PATH.'includes/lang' . DIRECTORY_SEPARATOR . $filename; |
| 9 | - if(is_file($file) && is_readable($file)) {
|
|
| 10 | + if(is_file($file) && is_readable($file)) { |
|
| 10 | 11 | include($file); |
| 11 | 12 | $out = isset($_lang) ? array_keys($_lang) : array(); |
| 12 | - } else {
|
|
| 13 | + } else { |
|
| 13 | 14 | $out = array(); |
| 14 | 15 | } |
| 15 | 16 | |
@@ -20,11 +21,12 @@ discard block |
||
| 20 | 21 | * |
| 21 | 22 | * @return array of languages that define the key in their file |
| 22 | 23 | */ |
| 23 | -function get_langs_by_key($key) {
|
|
| 24 | +function get_langs_by_key($key) |
|
| 25 | +{ |
|
| 24 | 26 | global $lang_keys; |
| 25 | 27 | $lang_return = array(); |
| 26 | - foreach($lang_keys as $lang=>$keys) {
|
|
| 27 | - if(in_array($key, $keys)) {
|
|
| 28 | + foreach($lang_keys as $lang=>$keys) { |
|
| 29 | + if(in_array($key, $keys)) { |
|
| 28 | 30 | $lang_return[] = $lang; |
| 29 | 31 | } |
| 30 | 32 | } |
@@ -40,23 +42,24 @@ discard block |
||
| 40 | 42 | * @param string $selected_lang specify language to select in option list, default none |
| 41 | 43 | * @return string html option list |
| 42 | 44 | */ |
| 43 | -function get_lang_options($key = '', $selected_lang=null) {
|
|
| 45 | +function get_lang_options($key = '', $selected_lang=null) |
|
| 46 | +{ |
|
| 44 | 47 | global $lang_keys, $_lang; |
| 45 | 48 | $lang_options = ''; |
| 46 | - if( ! empty($key)) {
|
|
| 49 | + if( ! empty($key)) { |
|
| 47 | 50 | $languages = get_langs_by_key($key); |
| 48 | 51 | sort($languages); |
| 49 | 52 | $lang_options .= '<option value="">'.$_lang['language_title'].'</option>'; |
| 50 | 53 | |
| 51 | - foreach($languages as $language_name) {
|
|
| 54 | + foreach($languages as $language_name) { |
|
| 52 | 55 | $uclanguage_name = ucwords(str_replace("_", " ", $language_name));
|
| 53 | 56 | $lang_options .= '<option value="'.$language_name.'">'.$uclanguage_name.'</option>'; |
| 54 | 57 | } |
| 55 | 58 | return $lang_options; |
| 56 | - } else {
|
|
| 59 | + } else { |
|
| 57 | 60 | $languages = array_keys($lang_keys); |
| 58 | 61 | sort($languages); |
| 59 | - foreach($languages as $language_name) {
|
|
| 62 | + foreach($languages as $language_name) { |
|
| 60 | 63 | $uclanguage_name = ucwords(str_replace("_", " ", $language_name));
|
| 61 | 64 | $sel = $language_name == $selected_lang ? ' selected="selected"' : ''; |
| 62 | 65 | $lang_options .= '<option value="'.$language_name.'" '.$sel.'>'.$uclanguage_name.'</option>'; |
@@ -65,31 +68,42 @@ discard block |
||
| 65 | 68 | } |
| 66 | 69 | } |
| 67 | 70 | |
| 68 | -function form_radio($name,$value,$add='',$disabled=false) {
|
|
| 71 | +function form_radio($name,$value,$add='',$disabled=false) |
|
| 72 | +{ |
|
| 69 | 73 | global ${$name};
|
| 70 | 74 | $var = ${$name};
|
| 71 | 75 | $checked = ($var==$value) ? ' checked="checked"' : ''; |
| 72 | - if($disabled) $disabled = ' disabled'; else $disabled = ''; |
|
| 73 | - if($add) $add = ' ' . $add; |
|
| 76 | + if($disabled) { |
|
| 77 | + $disabled = ' disabled'; |
|
| 78 | + } else { |
|
| 79 | + $disabled = ''; |
|
| 80 | + } |
|
| 81 | + if($add) { |
|
| 82 | + $add = ' ' . $add; |
|
| 83 | + } |
|
| 74 | 84 | return sprintf('<input onchange="documentDirty=true;" type="radio" name="%s" value="%s" %s %s %s />', $name, $value, $checked, $disabled, $add);
|
| 75 | 85 | } |
| 76 | 86 | |
| 77 | -function wrap_label($str='',$object) {
|
|
| 87 | +function wrap_label($str='',$object) |
|
| 88 | +{ |
|
| 78 | 89 | return "<label>{$object}\n{$str}</label>";
|
| 79 | 90 | } |
| 80 | 91 | |
| 81 | -function parseText($tpl='', $ph=array()) {
|
|
| 82 | - if(empty($ph) || empty($tpl)) return $tpl; |
|
| 92 | +function parseText($tpl='', $ph=array()) |
|
| 93 | +{ |
|
| 94 | + if(empty($ph) || empty($tpl)) { |
|
| 95 | + return $tpl; |
|
| 96 | + } |
|
| 83 | 97 | |
| 84 | - foreach($ph as $k=>$v) |
|
| 85 | - {
|
|
| 98 | + foreach($ph as $k=>$v) { |
|
| 86 | 99 | $k = "[+{$k}+]";
|
| 87 | 100 | $tpl = str_replace($k, $v, $tpl); |
| 88 | 101 | } |
| 89 | 102 | return $tpl; |
| 90 | 103 | } |
| 91 | 104 | |
| 92 | -function showHide($cond=true) {
|
|
| 105 | +function showHide($cond=true) |
|
| 106 | +{ |
|
| 93 | 107 | global $displayStyle; |
| 94 | 108 | $showHide = $cond ? $displayStyle : 'none'; |
| 95 | 109 | return sprintf('style="display:%s"', $showHide);
|
@@ -252,7 +252,7 @@ discard block |
||
| 252 | 252 | * MODX_MANAGER_PATH."includes/extenders/ex_{$extname}.inc.php" |
| 253 | 253 | * $extname - extension name in lowercase |
| 254 | 254 | * |
| 255 | - * @param $extname |
|
| 255 | + * @param string $extname |
|
| 256 | 256 | * @param bool $reload |
| 257 | 257 | * @return bool |
| 258 | 258 | */ |
@@ -295,7 +295,7 @@ discard block |
||
| 295 | 295 | * @param int $count_attempts |
| 296 | 296 | * @param string $type $type |
| 297 | 297 | * @param string $responseCode |
| 298 | - * @return bool |
|
| 298 | + * @return false|null |
|
| 299 | 299 | * @global string $base_url |
| 300 | 300 | * @global string $site_url |
| 301 | 301 | */ |
@@ -995,7 +995,7 @@ discard block |
||
| 995 | 995 | } |
| 996 | 996 | |
| 997 | 997 | /** |
| 998 | - * @param $contents |
|
| 998 | + * @param string $contents |
|
| 999 | 999 | * @return mixed |
| 1000 | 1000 | */ |
| 1001 | 1001 | public function RecoveryEscapedTags($contents) |
@@ -1019,7 +1019,7 @@ discard block |
||
| 1019 | 1019 | } |
| 1020 | 1020 | |
| 1021 | 1021 | /** |
| 1022 | - * @param $tstart |
|
| 1022 | + * @param double $tstart |
|
| 1023 | 1023 | * @return array |
| 1024 | 1024 | */ |
| 1025 | 1025 | public function getTimerStats($tstart) |
@@ -1771,7 +1771,7 @@ discard block |
||
| 1771 | 1771 | |
| 1772 | 1772 | /** |
| 1773 | 1773 | * Remove Comment-Tags from output like <!--@- Comment -@--> |
| 1774 | - * @param $content |
|
| 1774 | + * @param string $content |
|
| 1775 | 1775 | * @param string $left |
| 1776 | 1776 | * @param string $right |
| 1777 | 1777 | * @return mixed |
@@ -1944,7 +1944,7 @@ discard block |
||
| 1944 | 1944 | /** |
| 1945 | 1945 | * Run snippets as per the tags in $documentSource and replace the tags with the returned values. |
| 1946 | 1946 | * |
| 1947 | - * @param $content |
|
| 1947 | + * @param string $content |
|
| 1948 | 1948 | * @return string |
| 1949 | 1949 | * @internal param string $documentSource |
| 1950 | 1950 | */ |
@@ -2977,7 +2977,7 @@ discard block |
||
| 2977 | 2977 | |
| 2978 | 2978 | /** |
| 2979 | 2979 | * @param $templateID |
| 2980 | - * @return mixed |
|
| 2980 | + * @return string |
|
| 2981 | 2981 | */ |
| 2982 | 2982 | public function _getTemplateCodeFromDB($templateID) |
| 2983 | 2983 | { |
@@ -3018,9 +3018,9 @@ discard block |
||
| 3018 | 3018 | } |
| 3019 | 3019 | |
| 3020 | 3020 | /** |
| 3021 | - * @param $id |
|
| 3021 | + * @param integer $id |
|
| 3022 | 3022 | * @param int $top |
| 3023 | - * @return mixed |
|
| 3023 | + * @return string |
|
| 3024 | 3024 | */ |
| 3025 | 3025 | public function getUltimateParentId($id, $top = 0) |
| 3026 | 3026 | { |
@@ -3351,7 +3351,7 @@ discard block |
||
| 3351 | 3351 | * |
| 3352 | 3352 | * @param int $type Types: 1=template, 2=tv, 3=chunk, 4=snippet, 5=plugin, 6=module, 7=resource, 8=role |
| 3353 | 3353 | * @param int $id Element- / Resource-id |
| 3354 | - * @return bool |
|
| 3354 | + * @return false|null |
|
| 3355 | 3355 | */ |
| 3356 | 3356 | public function lockElement($type, $id) |
| 3357 | 3357 | { |
@@ -3373,7 +3373,7 @@ discard block |
||
| 3373 | 3373 | * @param int $type Types: 1=template, 2=tv, 3=chunk, 4=snippet, 5=plugin, 6=module, 7=resource, 8=role |
| 3374 | 3374 | * @param int $id Element- / Resource-id |
| 3375 | 3375 | * @param bool $includeAllUsers true = Deletes not only own user-locks |
| 3376 | - * @return bool |
|
| 3376 | + * @return false|null |
|
| 3377 | 3377 | */ |
| 3378 | 3378 | public function unlockElement($type, $id, $includeAllUsers = false) |
| 3379 | 3379 | { |
@@ -3481,7 +3481,7 @@ discard block |
||
| 3481 | 3481 | * @param array $params |
| 3482 | 3482 | * @param string $msg |
| 3483 | 3483 | * @param array $files |
| 3484 | - * @return mixed |
|
| 3484 | + * @return boolean |
|
| 3485 | 3485 | */ |
| 3486 | 3486 | public function sendmail($params = array(), $msg = '', $files = array()) |
| 3487 | 3487 | { |
@@ -3977,7 +3977,7 @@ discard block |
||
| 3977 | 3977 | * |
| 3978 | 3978 | * @param string $type |
| 3979 | 3979 | * @param bool $report |
| 3980 | - * @return bool |
|
| 3980 | + * @return boolean|null |
|
| 3981 | 3981 | */ |
| 3982 | 3982 | public function clearCache($type = '', $report = false) |
| 3983 | 3983 | { |
@@ -5322,7 +5322,7 @@ discard block |
||
| 5322 | 5322 | * Remove event listener - only for use within the current execution cycle |
| 5323 | 5323 | * |
| 5324 | 5324 | * @param string $evtName |
| 5325 | - * @return boolean |
|
| 5325 | + * @return false|null |
|
| 5326 | 5326 | */ |
| 5327 | 5327 | public function removeEventListener($evtName) |
| 5328 | 5328 | { |
@@ -5346,7 +5346,7 @@ discard block |
||
| 5346 | 5346 | * |
| 5347 | 5347 | * @param string $evtName |
| 5348 | 5348 | * @param array $extParams Parameters available to plugins. Each array key will be the PHP variable name, and the array value will be the variable value. |
| 5349 | - * @return boolean|array |
|
| 5349 | + * @return false|null |
|
| 5350 | 5350 | */ |
| 5351 | 5351 | public function invokeEvent($evtName, $extParams = array()) |
| 5352 | 5352 | { |
@@ -5767,7 +5767,7 @@ discard block |
||
| 5767 | 5767 | |
| 5768 | 5768 | /** |
| 5769 | 5769 | * @param string $string |
| 5770 | - * @return mixed|string |
|
| 5770 | + * @return string |
|
| 5771 | 5771 | */ |
| 5772 | 5772 | public function removeSanitizeSeed($string = '') |
| 5773 | 5773 | { |
@@ -5782,7 +5782,7 @@ discard block |
||
| 5782 | 5782 | |
| 5783 | 5783 | /** |
| 5784 | 5784 | * @param string $content |
| 5785 | - * @return mixed|string |
|
| 5785 | + * @return string |
|
| 5786 | 5786 | */ |
| 5787 | 5787 | public function cleanUpMODXTags($content = '') |
| 5788 | 5788 | { |
@@ -5945,7 +5945,7 @@ discard block |
||
| 5945 | 5945 | |
| 5946 | 5946 | /** |
| 5947 | 5947 | * @param string $str |
| 5948 | - * @return bool|mixed|string |
|
| 5948 | + * @return string |
|
| 5949 | 5949 | */ |
| 5950 | 5950 | public function atBindFileContent($str = '') |
| 5951 | 5951 | { |
@@ -5996,8 +5996,8 @@ discard block |
||
| 5996 | 5996 | } |
| 5997 | 5997 | |
| 5998 | 5998 | /** |
| 5999 | - * @param $str |
|
| 6000 | - * @return bool|string |
|
| 5999 | + * @param string $str |
|
| 6000 | + * @return false|string |
|
| 6001 | 6001 | */ |
| 6002 | 6002 | public function getExtFromFilename($str) |
| 6003 | 6003 | { |
@@ -6025,7 +6025,7 @@ discard block |
||
| 6025 | 6025 | * @param string $text Error message |
| 6026 | 6026 | * @param string $file File where the error was detected |
| 6027 | 6027 | * @param string $line Line number within $file |
| 6028 | - * @return boolean |
|
| 6028 | + * @return boolean|null |
|
| 6029 | 6029 | */ |
| 6030 | 6030 | public function phpError($nr, $text, $file, $line) |
| 6031 | 6031 | { |
@@ -6077,7 +6077,7 @@ discard block |
||
| 6077 | 6077 | * @param string $text |
| 6078 | 6078 | * @param string $line |
| 6079 | 6079 | * @param string $output |
| 6080 | - * @return bool |
|
| 6080 | + * @return null|boolean |
|
| 6081 | 6081 | */ |
| 6082 | 6082 | public function messageQuit($msg = 'unspecified error', $query = '', $is_error = true, $nr = '', $file = '', $source = '', $text = '', $line = '', $output = '') |
| 6083 | 6083 | { |
@@ -6499,7 +6499,7 @@ discard block |
||
| 6499 | 6499 | |
| 6500 | 6500 | /** |
| 6501 | 6501 | * @param string $str |
| 6502 | - * @return bool|mixed|string |
|
| 6502 | + * @return string |
|
| 6503 | 6503 | */ |
| 6504 | 6504 | public function atBindInclude($str = '') |
| 6505 | 6505 | { |
@@ -6550,7 +6550,7 @@ discard block |
||
| 6550 | 6550 | * @param $str |
| 6551 | 6551 | * @param int $flags |
| 6552 | 6552 | * @param string $encode |
| 6553 | - * @return mixed |
|
| 6553 | + * @return string |
|
| 6554 | 6554 | */ |
| 6555 | 6555 | public function htmlspecialchars($str, $flags = ENT_COMPAT, $encode = '') |
| 6556 | 6556 | { |
@@ -6559,7 +6559,7 @@ discard block |
||
| 6559 | 6559 | } |
| 6560 | 6560 | |
| 6561 | 6561 | /** |
| 6562 | - * @param $string |
|
| 6562 | + * @param string $string |
|
| 6563 | 6563 | * @param bool $returnData |
| 6564 | 6564 | * @return bool|mixed |
| 6565 | 6565 | */ |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | */ |
| 202 | 202 | function __call($method_name, $arguments) |
| 203 | 203 | { |
| 204 | - include_once(MODX_MANAGER_PATH . 'includes/extenders/deprecated.functions.inc.php'); |
|
| 204 | + include_once(MODX_MANAGER_PATH.'includes/extenders/deprecated.functions.inc.php'); |
|
| 205 | 205 | if (method_exists($this->old, $method_name)) { |
| 206 | 206 | $error_type = 1; |
| 207 | 207 | } else { |
@@ -219,12 +219,12 @@ discard block |
||
| 219 | 219 | $info = debug_backtrace(); |
| 220 | 220 | $m[] = $msg; |
| 221 | 221 | if (!empty($this->currentSnippet)) { |
| 222 | - $m[] = 'Snippet - ' . $this->currentSnippet; |
|
| 222 | + $m[] = 'Snippet - '.$this->currentSnippet; |
|
| 223 | 223 | } elseif (!empty($this->event->activePlugin)) { |
| 224 | - $m[] = 'Plugin - ' . $this->event->activePlugin; |
|
| 224 | + $m[] = 'Plugin - '.$this->event->activePlugin; |
|
| 225 | 225 | } |
| 226 | 226 | $m[] = $this->decoded_request_uri; |
| 227 | - $m[] = str_replace('\\', '/', $info[0]['file']) . '(line:' . $info[0]['line'] . ')'; |
|
| 227 | + $m[] = str_replace('\\', '/', $info[0]['file']).'(line:'.$info[0]['line'].')'; |
|
| 228 | 228 | $msg = implode('<br />', $m); |
| 229 | 229 | $this->logEvent(0, $error_type, $msg, $title); |
| 230 | 230 | } |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | { |
| 242 | 242 | $flag = false; |
| 243 | 243 | if (is_scalar($connector) && !empty($connector) && isset($this->{$connector}) && $this->{$connector} instanceof DBAPI) { |
| 244 | - $flag = (bool)$this->{$connector}->conn; |
|
| 244 | + $flag = (bool) $this->{$connector}->conn; |
|
| 245 | 245 | } |
| 246 | 246 | return $flag; |
| 247 | 247 | } |
@@ -268,7 +268,7 @@ discard block |
||
| 268 | 268 | } |
| 269 | 269 | if (!$out && $flag) { |
| 270 | 270 | $extname = trim(str_replace(array('..', '/', '\\'), '', strtolower($extname))); |
| 271 | - $filename = MODX_MANAGER_PATH . "includes/extenders/ex_{$extname}.inc.php"; |
|
| 271 | + $filename = MODX_MANAGER_PATH."includes/extenders/ex_{$extname}.inc.php"; |
|
| 272 | 272 | $out = is_file($filename) ? include $filename : false; |
| 273 | 273 | } |
| 274 | 274 | if ($out && !in_array($extname, $this->extensions)) { |
@@ -285,7 +285,7 @@ discard block |
||
| 285 | 285 | public function getMicroTime() |
| 286 | 286 | { |
| 287 | 287 | list ($usec, $sec) = explode(' ', microtime()); |
| 288 | - return ((float)$usec + (float)$sec); |
|
| 288 | + return ((float) $usec + (float) $sec); |
|
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | /** |
@@ -309,7 +309,7 @@ discard block |
||
| 309 | 309 | // append the redirect count string to the url |
| 310 | 310 | $currentNumberOfRedirects = isset ($_REQUEST['err']) ? $_REQUEST['err'] : 0; |
| 311 | 311 | if ($currentNumberOfRedirects > 3) { |
| 312 | - $this->messageQuit('Redirection attempt failed - please ensure the document you\'re trying to redirect to exists. <p>Redirection URL: <i>' . $url . '</i></p>'); |
|
| 312 | + $this->messageQuit('Redirection attempt failed - please ensure the document you\'re trying to redirect to exists. <p>Redirection URL: <i>'.$url.'</i></p>'); |
|
| 313 | 313 | } else { |
| 314 | 314 | $currentNumberOfRedirects += 1; |
| 315 | 315 | if (strpos($url, "?") > 0) { |
@@ -320,9 +320,9 @@ discard block |
||
| 320 | 320 | } |
| 321 | 321 | } |
| 322 | 322 | if ($type == 'REDIRECT_REFRESH') { |
| 323 | - $header = 'Refresh: 0;URL=' . $url; |
|
| 323 | + $header = 'Refresh: 0;URL='.$url; |
|
| 324 | 324 | } elseif ($type == 'REDIRECT_META') { |
| 325 | - $header = '<META HTTP-EQUIV="Refresh" CONTENT="0; URL=' . $url . '" />'; |
|
| 325 | + $header = '<META HTTP-EQUIV="Refresh" CONTENT="0; URL='.$url.'" />'; |
|
| 326 | 326 | echo $header; |
| 327 | 327 | exit; |
| 328 | 328 | } elseif ($type == 'REDIRECT_HEADER' || empty ($type)) { |
@@ -330,10 +330,10 @@ discard block |
||
| 330 | 330 | global $base_url, $site_url; |
| 331 | 331 | if (substr($url, 0, strlen($base_url)) == $base_url) { |
| 332 | 332 | // append $site_url to make it work with Location: |
| 333 | - $url = $site_url . substr($url, strlen($base_url)); |
|
| 333 | + $url = $site_url.substr($url, strlen($base_url)); |
|
| 334 | 334 | } |
| 335 | 335 | if (strpos($url, "\n") === false) { |
| 336 | - $header = 'Location: ' . $url; |
|
| 336 | + $header = 'Location: '.$url; |
|
| 337 | 337 | } else { |
| 338 | 338 | $this->messageQuit('No newline allowed in redirect url.'); |
| 339 | 339 | } |
@@ -342,7 +342,7 @@ discard block |
||
| 342 | 342 | header($responseCode); |
| 343 | 343 | } |
| 344 | 344 | |
| 345 | - if(!empty($header)) { |
|
| 345 | + if (!empty($header)) { |
|
| 346 | 346 | header($header); |
| 347 | 347 | } |
| 348 | 348 | |
@@ -446,8 +446,8 @@ discard block |
||
| 446 | 446 | |
| 447 | 447 | private function recoverySiteCache() |
| 448 | 448 | { |
| 449 | - $site_cache_dir = MODX_BASE_PATH . $this->getCacheFolder(); |
|
| 450 | - $site_cache_path = $site_cache_dir . 'siteCache.idx.php'; |
|
| 449 | + $site_cache_dir = MODX_BASE_PATH.$this->getCacheFolder(); |
|
| 450 | + $site_cache_path = $site_cache_dir.'siteCache.idx.php'; |
|
| 451 | 451 | |
| 452 | 452 | if (is_file($site_cache_path)) { |
| 453 | 453 | include($site_cache_path); |
@@ -456,7 +456,7 @@ discard block |
||
| 456 | 456 | return; |
| 457 | 457 | } |
| 458 | 458 | |
| 459 | - include_once(MODX_MANAGER_PATH . 'processors/cache_sync.class.processor.php'); |
|
| 459 | + include_once(MODX_MANAGER_PATH.'processors/cache_sync.class.processor.php'); |
|
| 460 | 460 | $cache = new synccache(); |
| 461 | 461 | $cache->setCachepath($site_cache_dir); |
| 462 | 462 | $cache->setReport(false); |
@@ -507,8 +507,8 @@ discard block |
||
| 507 | 507 | $this->invokeEvent("OnBeforeManagerPageInit"); |
| 508 | 508 | } |
| 509 | 509 | |
| 510 | - if (isset ($_SESSION[$usrType . 'UsrConfigSet'])) { |
|
| 511 | - $usrSettings = &$_SESSION[$usrType . 'UsrConfigSet']; |
|
| 510 | + if (isset ($_SESSION[$usrType.'UsrConfigSet'])) { |
|
| 511 | + $usrSettings = &$_SESSION[$usrType.'UsrConfigSet']; |
|
| 512 | 512 | } else { |
| 513 | 513 | if ($usrType == 'web') { |
| 514 | 514 | $from = $tbl_web_user_settings; |
@@ -528,7 +528,7 @@ discard block |
||
| 528 | 528 | $usrSettings[$row['setting_name']] = $row['setting_value']; |
| 529 | 529 | } |
| 530 | 530 | if (isset ($usrType)) { |
| 531 | - $_SESSION[$usrType . 'UsrConfigSet'] = $usrSettings; |
|
| 531 | + $_SESSION[$usrType.'UsrConfigSet'] = $usrSettings; |
|
| 532 | 532 | } // store user settings in session |
| 533 | 533 | } |
| 534 | 534 | } |
@@ -673,10 +673,10 @@ discard block |
||
| 673 | 673 | $suf = $this->config['friendly_url_suffix']; |
| 674 | 674 | $pre = preg_quote($pre, '/'); |
| 675 | 675 | $suf = preg_quote($suf, '/'); |
| 676 | - if ($pre && preg_match('@^' . $pre . '(.*)$@', $q, $_)) { |
|
| 676 | + if ($pre && preg_match('@^'.$pre.'(.*)$@', $q, $_)) { |
|
| 677 | 677 | $q = $_[1]; |
| 678 | 678 | } |
| 679 | - if ($suf && preg_match('@(.*)' . $suf . '$@', $q, $_)) { |
|
| 679 | + if ($suf && preg_match('@(.*)'.$suf.'$@', $q, $_)) { |
|
| 680 | 680 | $q = $_[1]; |
| 681 | 681 | } |
| 682 | 682 | |
@@ -698,7 +698,7 @@ discard block |
||
| 698 | 698 | if (preg_match('@^[1-9][0-9]*$@', $q) && !isset($this->documentListing[$q])) { /* we got an ID returned, check to make sure it's not an alias */ |
| 699 | 699 | /* FS#476 and FS#308: check that id is valid in terms of virtualDir structure */ |
| 700 | 700 | if ($this->config['use_alias_path'] == 1) { |
| 701 | - if (($this->virtualDir != '' && !isset($this->documentListing[$this->virtualDir . '/' . $q]) || ($this->virtualDir == '' && !isset($this->documentListing[$q]))) && (($this->virtualDir != '' && isset($this->documentListing[$this->virtualDir]) && in_array($q, $this->getChildIds($this->documentListing[$this->virtualDir], 1))) || ($this->virtualDir == '' && in_array($q, $this->getChildIds(0, 1))))) { |
|
| 701 | + if (($this->virtualDir != '' && !isset($this->documentListing[$this->virtualDir.'/'.$q]) || ($this->virtualDir == '' && !isset($this->documentListing[$q]))) && (($this->virtualDir != '' && isset($this->documentListing[$this->virtualDir]) && in_array($q, $this->getChildIds($this->documentListing[$this->virtualDir], 1))) || ($this->virtualDir == '' && in_array($q, $this->getChildIds(0, 1))))) { |
|
| 702 | 702 | $this->documentMethod = 'id'; |
| 703 | 703 | return $q; |
| 704 | 704 | } else { /* not a valid id in terms of virtualDir, treat as alias */ |
@@ -732,7 +732,7 @@ discard block |
||
| 732 | 732 | */ |
| 733 | 733 | public function getHashFile($key) |
| 734 | 734 | { |
| 735 | - return $this->getCacheFolder() . "docid_" . $key . ".pageCache.php"; |
|
| 735 | + return $this->getCacheFolder()."docid_".$key.".pageCache.php"; |
|
| 736 | 736 | } |
| 737 | 737 | |
| 738 | 738 | /** |
@@ -743,9 +743,9 @@ discard block |
||
| 743 | 743 | $hash = $id; |
| 744 | 744 | $tmp = null; |
| 745 | 745 | $params = array(); |
| 746 | - if(!empty($this->systemCacheKey)){ |
|
| 746 | + if (!empty($this->systemCacheKey)) { |
|
| 747 | 747 | $hash = $this->systemCacheKey; |
| 748 | - }else { |
|
| 748 | + } else { |
|
| 749 | 749 | if (!empty($_GET)) { |
| 750 | 750 | // Sort GET parameters so that the order of parameters on the HTTP request don't affect the generated cache ID. |
| 751 | 751 | $params = $_GET; |
@@ -753,8 +753,8 @@ discard block |
||
| 753 | 753 | $hash .= '_'.md5(http_build_query($params)); |
| 754 | 754 | } |
| 755 | 755 | } |
| 756 | - $evtOut = $this->invokeEvent("OnMakePageCacheKey", array ("hash" => $hash, "id" => $id, 'params' => $params)); |
|
| 757 | - if (is_array($evtOut) && count($evtOut) > 0){ |
|
| 756 | + $evtOut = $this->invokeEvent("OnMakePageCacheKey", array("hash" => $hash, "id" => $id, 'params' => $params)); |
|
| 757 | + if (is_array($evtOut) && count($evtOut) > 0) { |
|
| 758 | 758 | $tmp = array_pop($evtOut); |
| 759 | 759 | } |
| 760 | 760 | return empty($tmp) ? $hash : $tmp; |
@@ -896,12 +896,12 @@ discard block |
||
| 896 | 896 | if ($js = $this->getRegisteredClientStartupScripts()) { |
| 897 | 897 | // change to just before closing </head> |
| 898 | 898 | // $this->documentContent = preg_replace("/(<head[^>]*>)/i", "\\1\n".$js, $this->documentContent); |
| 899 | - $this->documentOutput = preg_replace("/(<\/head>)/i", $js . "\n\\1", $this->documentOutput); |
|
| 899 | + $this->documentOutput = preg_replace("/(<\/head>)/i", $js."\n\\1", $this->documentOutput); |
|
| 900 | 900 | } |
| 901 | 901 | |
| 902 | 902 | // Insert jscripts & html block into template - template must have a </body> tag |
| 903 | 903 | if ($js = $this->getRegisteredClientScripts()) { |
| 904 | - $this->documentOutput = preg_replace("/(<\/body>)/i", $js . "\n\\1", $this->documentOutput); |
|
| 904 | + $this->documentOutput = preg_replace("/(<\/body>)/i", $js."\n\\1", $this->documentOutput); |
|
| 905 | 905 | } |
| 906 | 906 | // End fix by sirlancelot |
| 907 | 907 | |
@@ -912,7 +912,7 @@ discard block |
||
| 912 | 912 | // send out content-type and content-disposition headers |
| 913 | 913 | if (IN_PARSER_MODE == "true") { |
| 914 | 914 | $type = !empty ($this->contentTypes[$this->documentIdentifier]) ? $this->contentTypes[$this->documentIdentifier] : "text/html"; |
| 915 | - header('Content-Type: ' . $type . '; charset=' . $this->config['modx_charset']); |
|
| 915 | + header('Content-Type: '.$type.'; charset='.$this->config['modx_charset']); |
|
| 916 | 916 | // if (($this->documentIdentifier == $this->config['error_page']) || $redirect_error) |
| 917 | 917 | // header('HTTP/1.0 404 Not Found'); |
| 918 | 918 | if (!$this->checkPreview() && $this->documentObject['content_dispo'] == 1) { |
@@ -930,7 +930,7 @@ discard block |
||
| 930 | 930 | $name = preg_replace('|-+|', '-', $name); |
| 931 | 931 | $name = trim($name, '-'); |
| 932 | 932 | } |
| 933 | - $header = 'Content-Disposition: attachment; filename=' . $name; |
|
| 933 | + $header = 'Content-Disposition: attachment; filename='.$name; |
|
| 934 | 934 | header($header); |
| 935 | 935 | } |
| 936 | 936 | } |
@@ -938,7 +938,7 @@ discard block |
||
| 938 | 938 | |
| 939 | 939 | $stats = $this->getTimerStats($this->tstart); |
| 940 | 940 | |
| 941 | - $out =& $this->documentOutput; |
|
| 941 | + $out = & $this->documentOutput; |
|
| 942 | 942 | $out = str_replace("[^q^]", $stats['queries'], $out); |
| 943 | 943 | $out = str_replace("[^qt^]", $stats['queryTime'], $out); |
| 944 | 944 | $out = str_replace("[^p^]", $stats['phpTime'], $out); |
@@ -977,17 +977,17 @@ discard block |
||
| 977 | 977 | $sc .= sprintf("%s. %s (%s)<br>", $s, $sname, sprintf("%2.2f ms", $t)); // currentSnippet |
| 978 | 978 | $tt += $t; |
| 979 | 979 | } |
| 980 | - echo "<fieldset><legend><b>Snippets</b> (" . count($this->snippetsTime) . " / " . sprintf("%2.2f ms", $tt) . ")</legend>{$sc}</fieldset><br />"; |
|
| 980 | + echo "<fieldset><legend><b>Snippets</b> (".count($this->snippetsTime)." / ".sprintf("%2.2f ms", $tt).")</legend>{$sc}</fieldset><br />"; |
|
| 981 | 981 | echo $this->snippetsCode; |
| 982 | 982 | } |
| 983 | 983 | if ($this->dumpPlugins) { |
| 984 | 984 | $ps = ""; |
| 985 | 985 | $tt = 0; |
| 986 | 986 | foreach ($this->pluginsTime as $s => $t) { |
| 987 | - $ps .= "$s (" . sprintf("%2.2f ms", $t * 1000) . ")<br>"; |
|
| 987 | + $ps .= "$s (".sprintf("%2.2f ms", $t * 1000).")<br>"; |
|
| 988 | 988 | $tt += $t; |
| 989 | 989 | } |
| 990 | - echo "<fieldset><legend><b>Plugins</b> (" . count($this->pluginsTime) . " / " . sprintf("%2.2f ms", $tt * 1000) . ")</legend>{$ps}</fieldset><br />"; |
|
| 990 | + echo "<fieldset><legend><b>Plugins</b> (".count($this->pluginsTime)." / ".sprintf("%2.2f ms", $tt * 1000).")</legend>{$ps}</fieldset><br />"; |
|
| 991 | 991 | echo $this->pluginsCode; |
| 992 | 992 | } |
| 993 | 993 | |
@@ -1013,7 +1013,7 @@ discard block |
||
| 1013 | 1013 | $srcTags = explode(',', $tags); |
| 1014 | 1014 | $repTags = array(); |
| 1015 | 1015 | foreach ($srcTags as $tag) { |
| 1016 | - $repTags[] = '\\' . $tag[0] . '\\' . $tag[1]; |
|
| 1016 | + $repTags[] = '\\'.$tag[0].'\\'.$tag[1]; |
|
| 1017 | 1017 | } |
| 1018 | 1018 | return array($srcTags, $repTags); |
| 1019 | 1019 | } |
@@ -1035,7 +1035,7 @@ discard block |
||
| 1035 | 1035 | $stats['phpTime'] = sprintf("%2.4f s", $stats['phpTime']); |
| 1036 | 1036 | $stats['source'] = $this->documentGenerated == 1 ? "database" : "cache"; |
| 1037 | 1037 | $stats['queries'] = isset ($this->executedQueries) ? $this->executedQueries : 0; |
| 1038 | - $stats['phpMemory'] = (memory_get_peak_usage(true) / 1024 / 1024) . " mb"; |
|
| 1038 | + $stats['phpMemory'] = (memory_get_peak_usage(true) / 1024 / 1024)." mb"; |
|
| 1039 | 1039 | |
| 1040 | 1040 | return $stats; |
| 1041 | 1041 | } |
@@ -1068,7 +1068,7 @@ discard block |
||
| 1068 | 1068 | { |
| 1069 | 1069 | $cacheRefreshTime = 0; |
| 1070 | 1070 | $recent_update = 0; |
| 1071 | - @include(MODX_BASE_PATH . $this->getCacheFolder() . 'sitePublishing.idx.php'); |
|
| 1071 | + @include(MODX_BASE_PATH.$this->getCacheFolder().'sitePublishing.idx.php'); |
|
| 1072 | 1072 | $this->recentUpdate = $recent_update; |
| 1073 | 1073 | |
| 1074 | 1074 | $timeNow = $_SERVER['REQUEST_TIME'] + $this->config['server_offset_time']; |
@@ -1122,8 +1122,8 @@ discard block |
||
| 1122 | 1122 | } |
| 1123 | 1123 | |
| 1124 | 1124 | $docObjSerial = serialize($this->documentObject); |
| 1125 | - $cacheContent = $docObjSerial . "<!--__MODxCacheSpliter__-->" . $this->documentContent; |
|
| 1126 | - $page_cache_path = MODX_BASE_PATH . $this->getHashFile($this->cacheKey); |
|
| 1125 | + $cacheContent = $docObjSerial."<!--__MODxCacheSpliter__-->".$this->documentContent; |
|
| 1126 | + $page_cache_path = MODX_BASE_PATH.$this->getHashFile($this->cacheKey); |
|
| 1127 | 1127 | file_put_contents($page_cache_path, "<?php die('Unauthorized access.'); ?>$cacheContent"); |
| 1128 | 1128 | } |
| 1129 | 1129 | } |
@@ -1165,16 +1165,16 @@ discard block |
||
| 1165 | 1165 | return array(); |
| 1166 | 1166 | } |
| 1167 | 1167 | $spacer = md5('<<<EVO>>>'); |
| 1168 | - if($left==='{{' && strpos($content,';}}')!==false) $content = str_replace(';}}', sprintf(';}%s}', $spacer),$content); |
|
| 1169 | - if($left==='{{' && strpos($content,'{{}}')!==false) $content = str_replace('{{}}',sprintf('{%$1s{}%$1s}',$spacer),$content); |
|
| 1170 | - if($left==='[[' && strpos($content,']]]]')!==false) $content = str_replace(']]]]',sprintf(']]%s]]', $spacer),$content); |
|
| 1171 | - if($left==='[[' && strpos($content,']]]')!==false) $content = str_replace(']]]', sprintf(']%s]]', $spacer),$content); |
|
| 1168 | + if ($left === '{{' && strpos($content, ';}}') !== false) $content = str_replace(';}}', sprintf(';}%s}', $spacer), $content); |
|
| 1169 | + if ($left === '{{' && strpos($content, '{{}}') !== false) $content = str_replace('{{}}', sprintf('{%$1s{}%$1s}', $spacer), $content); |
|
| 1170 | + if ($left === '[[' && strpos($content, ']]]]') !== false) $content = str_replace(']]]]', sprintf(']]%s]]', $spacer), $content); |
|
| 1171 | + if ($left === '[[' && strpos($content, ']]]') !== false) $content = str_replace(']]]', sprintf(']%s]]', $spacer), $content); |
|
| 1172 | 1172 | |
| 1173 | 1173 | $pos['<![CDATA['] = strpos($content, '<![CDATA['); |
| 1174 | 1174 | $pos[']]>'] = strpos($content, ']]>'); |
| 1175 | 1175 | |
| 1176 | 1176 | if ($pos['<![CDATA['] !== false && $pos[']]>'] !== false) { |
| 1177 | - $content = substr($content, 0, $pos['<![CDATA[']) . substr($content, $pos[']]>'] + 3); |
|
| 1177 | + $content = substr($content, 0, $pos['<![CDATA[']).substr($content, $pos[']]>'] + 3); |
|
| 1178 | 1178 | } |
| 1179 | 1179 | |
| 1180 | 1180 | $lp = explode($left, $content); |
@@ -1238,8 +1238,8 @@ discard block |
||
| 1238 | 1238 | } |
| 1239 | 1239 | } |
| 1240 | 1240 | } |
| 1241 | - foreach($tags as $i=>$tag) { |
|
| 1242 | - if(strpos($tag,$spacer)!==false) $tags[$i] = str_replace($spacer, '', $tag); |
|
| 1241 | + foreach ($tags as $i=>$tag) { |
|
| 1242 | + if (strpos($tag, $spacer) !== false) $tags[$i] = str_replace($spacer, '', $tag); |
|
| 1243 | 1243 | } |
| 1244 | 1244 | return $tags; |
| 1245 | 1245 | } |
@@ -1279,7 +1279,7 @@ discard block |
||
| 1279 | 1279 | } |
| 1280 | 1280 | |
| 1281 | 1281 | foreach ($matches[1] as $i => $key) { |
| 1282 | - if(strpos($key,'[+')!==false) continue; // Allow chunk {{chunk?¶m=`xxx`}} with [*tv_name_[+param+]*] as content |
|
| 1282 | + if (strpos($key, '[+') !== false) continue; // Allow chunk {{chunk?¶m=`xxx`}} with [*tv_name_[+param+]*] as content |
|
| 1283 | 1283 | if (substr($key, 0, 1) == '#') { |
| 1284 | 1284 | $key = substr($key, 1); |
| 1285 | 1285 | } // remove # for QuickEdit format |
@@ -1299,8 +1299,8 @@ discard block |
||
| 1299 | 1299 | } |
| 1300 | 1300 | |
| 1301 | 1301 | if (is_array($value)) { |
| 1302 | - include_once(MODX_MANAGER_PATH . 'includes/tmplvars.format.inc.php'); |
|
| 1303 | - include_once(MODX_MANAGER_PATH . 'includes/tmplvars.commands.inc.php'); |
|
| 1302 | + include_once(MODX_MANAGER_PATH.'includes/tmplvars.format.inc.php'); |
|
| 1303 | + include_once(MODX_MANAGER_PATH.'includes/tmplvars.commands.inc.php'); |
|
| 1304 | 1304 | $value = getTVDisplayFormat($value[0], $value[1], $value[2], $value[3], $value[4]); |
| 1305 | 1305 | } |
| 1306 | 1306 | |
@@ -1311,8 +1311,8 @@ discard block |
||
| 1311 | 1311 | |
| 1312 | 1312 | if (strpos($content, $s) !== false) { |
| 1313 | 1313 | $content = str_replace($s, $value, $content); |
| 1314 | - } elseif($this->debug) { |
|
| 1315 | - $this->addLog('mergeDocumentContent parse error', $_SERVER['REQUEST_URI'] . $s, 2); |
|
| 1314 | + } elseif ($this->debug) { |
|
| 1315 | + $this->addLog('mergeDocumentContent parse error', $_SERVER['REQUEST_URI'].$s, 2); |
|
| 1316 | 1316 | } |
| 1317 | 1317 | } |
| 1318 | 1318 | |
@@ -1479,8 +1479,8 @@ discard block |
||
| 1479 | 1479 | $s = &$matches[0][$i]; |
| 1480 | 1480 | if (strpos($content, $s) !== false) { |
| 1481 | 1481 | $content = str_replace($s, $value, $content); |
| 1482 | - } elseif($this->debug) { |
|
| 1483 | - $this->addLog('mergeSettingsContent parse error', $_SERVER['REQUEST_URI'] . $s, 2); |
|
| 1482 | + } elseif ($this->debug) { |
|
| 1483 | + $this->addLog('mergeSettingsContent parse error', $_SERVER['REQUEST_URI'].$s, 2); |
|
| 1484 | 1484 | } |
| 1485 | 1485 | } |
| 1486 | 1486 | return $content; |
@@ -1533,7 +1533,7 @@ discard block |
||
| 1533 | 1533 | } |
| 1534 | 1534 | |
| 1535 | 1535 | $value = $this->parseText($value, $params); // parse local scope placeholers for ConditionalTags |
| 1536 | - $value = $this->mergePlaceholderContent($value, $params); // parse page global placeholers |
|
| 1536 | + $value = $this->mergePlaceholderContent($value, $params); // parse page global placeholers |
|
| 1537 | 1537 | if ($this->config['enable_at_syntax']) { |
| 1538 | 1538 | $value = $this->mergeConditionalTagsContent($value); |
| 1539 | 1539 | } |
@@ -1548,8 +1548,8 @@ discard block |
||
| 1548 | 1548 | $s = &$matches[0][$i]; |
| 1549 | 1549 | if (strpos($content, $s) !== false) { |
| 1550 | 1550 | $content = str_replace($s, $value, $content); |
| 1551 | - } elseif($this->debug) { |
|
| 1552 | - $this->addLog('mergeChunkContent parse error', $_SERVER['REQUEST_URI'] . $s, 2); |
|
| 1551 | + } elseif ($this->debug) { |
|
| 1552 | + $this->addLog('mergeChunkContent parse error', $_SERVER['REQUEST_URI'].$s, 2); |
|
| 1553 | 1553 | } |
| 1554 | 1554 | } |
| 1555 | 1555 | return $content; |
@@ -1607,8 +1607,8 @@ discard block |
||
| 1607 | 1607 | $s = &$matches[0][$i]; |
| 1608 | 1608 | if (strpos($content, $s) !== false) { |
| 1609 | 1609 | $content = str_replace($s, $value, $content); |
| 1610 | - } elseif($this->debug) { |
|
| 1611 | - $this->addLog('mergePlaceholderContent parse error', $_SERVER['REQUEST_URI'] . $s, 2); |
|
| 1610 | + } elseif ($this->debug) { |
|
| 1611 | + $this->addLog('mergePlaceholderContent parse error', $_SERVER['REQUEST_URI'].$s, 2); |
|
| 1612 | 1612 | } |
| 1613 | 1613 | } |
| 1614 | 1614 | return $content; |
@@ -1632,7 +1632,7 @@ discard block |
||
| 1632 | 1632 | return $content; |
| 1633 | 1633 | } |
| 1634 | 1634 | |
| 1635 | - $sp = '#' . md5('ConditionalTags' . $_SERVER['REQUEST_TIME']) . '#'; |
|
| 1635 | + $sp = '#'.md5('ConditionalTags'.$_SERVER['REQUEST_TIME']).'#'; |
|
| 1636 | 1636 | $content = str_replace(array('<?php', '<?=', '<?', '?>'), array("{$sp}b", "{$sp}p", "{$sp}s", "{$sp}e"), $content); |
| 1637 | 1637 | |
| 1638 | 1638 | $pieces = explode('<@IF:', $content); |
@@ -1643,7 +1643,7 @@ discard block |
||
| 1643 | 1643 | } |
| 1644 | 1644 | list($cmd, $text) = explode('>', $split, 2); |
| 1645 | 1645 | $cmd = str_replace("'", "\'", $cmd); |
| 1646 | - $content .= "<?php if(\$this->_parseCTagCMD('" . $cmd . "')): ?>"; |
|
| 1646 | + $content .= "<?php if(\$this->_parseCTagCMD('".$cmd."')): ?>"; |
|
| 1647 | 1647 | $content .= $text; |
| 1648 | 1648 | } |
| 1649 | 1649 | $pieces = explode('<@ELSEIF:', $content); |
@@ -1654,13 +1654,13 @@ discard block |
||
| 1654 | 1654 | } |
| 1655 | 1655 | list($cmd, $text) = explode('>', $split, 2); |
| 1656 | 1656 | $cmd = str_replace("'", "\'", $cmd); |
| 1657 | - $content .= "<?php elseif(\$this->_parseCTagCMD('" . $cmd . "')): ?>"; |
|
| 1657 | + $content .= "<?php elseif(\$this->_parseCTagCMD('".$cmd."')): ?>"; |
|
| 1658 | 1658 | $content .= $text; |
| 1659 | 1659 | } |
| 1660 | 1660 | |
| 1661 | 1661 | $content = str_replace(array('<@ELSE>', '<@ENDIF>'), array('<?php else:?>', '<?php endif;?>'), $content); |
| 1662 | 1662 | ob_start(); |
| 1663 | - $content = eval('?>' . $content); |
|
| 1663 | + $content = eval('?>'.$content); |
|
| 1664 | 1664 | $content = ob_get_clean(); |
| 1665 | 1665 | $content = str_replace(array("{$sp}b", "{$sp}p", "{$sp}s", "{$sp}e"), array('<?php', '<?=', '<?', '?>'), $content); |
| 1666 | 1666 | |
@@ -1785,7 +1785,7 @@ discard block |
||
| 1785 | 1785 | $matches = $this->getTagsFromContent($content, $left, $right); |
| 1786 | 1786 | if (!empty($matches)) { |
| 1787 | 1787 | foreach ($matches[0] as $i => $v) { |
| 1788 | - $addBreakMatches[$i] = $v . "\n"; |
|
| 1788 | + $addBreakMatches[$i] = $v."\n"; |
|
| 1789 | 1789 | } |
| 1790 | 1790 | $content = str_replace($addBreakMatches, '', $content); |
| 1791 | 1791 | if (strpos($content, $left) !== false) { |
@@ -1818,8 +1818,8 @@ discard block |
||
| 1818 | 1818 | $s = &$matches[0][$i]; |
| 1819 | 1819 | if (strpos($content, $s) !== false) { |
| 1820 | 1820 | $content = str_replace($s, $v, $content); |
| 1821 | - } elseif($this->debug) { |
|
| 1822 | - $this->addLog('ignoreCommentedTagsContent parse error', $_SERVER['REQUEST_URI'] . $s, 2); |
|
| 1821 | + } elseif ($this->debug) { |
|
| 1822 | + $this->addLog('ignoreCommentedTagsContent parse error', $_SERVER['REQUEST_URI'].$s, 2); |
|
| 1823 | 1823 | } |
| 1824 | 1824 | } |
| 1825 | 1825 | return $content; |
@@ -1883,7 +1883,7 @@ discard block |
||
| 1883 | 1883 | $msg = ($msg === false) ? 'ob_get_contents() error' : $msg; |
| 1884 | 1884 | $this->messageQuit('PHP Parse Error', '', true, $error_info['type'], $error_info['file'], 'Plugin', $error_info['message'], $error_info['line'], $msg); |
| 1885 | 1885 | if ($this->isBackend()) { |
| 1886 | - $this->event->alert('An error occurred while loading. Please see the event log for more information.<p>' . $msg . '</p>'); |
|
| 1886 | + $this->event->alert('An error occurred while loading. Please see the event log for more information.<p>'.$msg.'</p>'); |
|
| 1887 | 1887 | } |
| 1888 | 1888 | } |
| 1889 | 1889 | } else { |
@@ -1929,7 +1929,7 @@ discard block |
||
| 1929 | 1929 | $echo = ($echo === false) ? 'ob_get_contents() error' : $echo; |
| 1930 | 1930 | $this->messageQuit('PHP Parse Error', '', true, $error_info['type'], $error_info['file'], 'Snippet', $error_info['message'], $error_info['line'], $echo); |
| 1931 | 1931 | if ($this->isBackend()) { |
| 1932 | - $this->event->alert('An error occurred while loading. Please see the event log for more information<p>' . $echo . $return . '</p>'); |
|
| 1932 | + $this->event->alert('An error occurred while loading. Please see the event log for more information<p>'.$echo.$return.'</p>'); |
|
| 1933 | 1933 | } |
| 1934 | 1934 | } |
| 1935 | 1935 | } |
@@ -1937,7 +1937,7 @@ discard block |
||
| 1937 | 1937 | if (is_array($return) || is_object($return)) { |
| 1938 | 1938 | return $return; |
| 1939 | 1939 | } else { |
| 1940 | - return $echo . $return; |
|
| 1940 | + return $echo.$return; |
|
| 1941 | 1941 | } |
| 1942 | 1942 | } |
| 1943 | 1943 | |
@@ -1975,8 +1975,8 @@ discard block |
||
| 1975 | 1975 | } |
| 1976 | 1976 | if (strpos($content, $s) !== false) { |
| 1977 | 1977 | $content = str_replace($s, $value, $content); |
| 1978 | - } elseif($this->debug) { |
|
| 1979 | - $this->addLog('evalSnippetsSGVar parse error', $_SERVER['REQUEST_URI'] . $s, 2); |
|
| 1978 | + } elseif ($this->debug) { |
|
| 1979 | + $this->addLog('evalSnippetsSGVar parse error', $_SERVER['REQUEST_URI'].$s, 2); |
|
| 1980 | 1980 | } |
| 1981 | 1981 | continue; |
| 1982 | 1982 | } |
@@ -1987,8 +1987,8 @@ discard block |
||
| 1987 | 1987 | |
| 1988 | 1988 | if (strpos($content, $s) !== false) { |
| 1989 | 1989 | $content = str_replace($s, $value, $content); |
| 1990 | - } elseif($this->debug) { |
|
| 1991 | - $this->addLog('evalSnippets parse error', $_SERVER['REQUEST_URI'] . $s, 2); |
|
| 1990 | + } elseif ($this->debug) { |
|
| 1991 | + $this->addLog('evalSnippets parse error', $_SERVER['REQUEST_URI'].$s, 2); |
|
| 1992 | 1992 | } |
| 1993 | 1993 | } |
| 1994 | 1994 | |
@@ -2080,7 +2080,7 @@ discard block |
||
| 2080 | 2080 | $eventtime = sprintf('%2.2f ms', $eventtime * 1000); |
| 2081 | 2081 | $code = str_replace("\t", ' ', $this->htmlspecialchars($value)); |
| 2082 | 2082 | $piece = str_replace("\t", ' ', $this->htmlspecialchars($piece)); |
| 2083 | - $print_r_params = str_replace("\t", ' ', $this->htmlspecialchars('$modx->event->params = ' . print_r($params, true))); |
|
| 2083 | + $print_r_params = str_replace("\t", ' ', $this->htmlspecialchars('$modx->event->params = '.print_r($params, true))); |
|
| 2084 | 2084 | $this->snippetsCode .= sprintf('<fieldset style="margin:1em;"><legend><b>%s</b>(%s)</legend><pre style="white-space: pre-wrap;background-color:#fff;width:90%%;">[[%s]]</pre><pre style="white-space: pre-wrap;background-color:#fff;width:90%%;">%s</pre><pre style="white-space: pre-wrap;background-color:#fff;width:90%%;">%s</pre></fieldset>', $snippetObject['name'], $eventtime, $piece, $print_r_params, $code); |
| 2085 | 2085 | $this->snippetsTime[] = array('sname' => $key, 'time' => $eventtime); |
| 2086 | 2086 | } |
@@ -2324,7 +2324,7 @@ discard block |
||
| 2324 | 2324 | $rs = $this->db->select('name,snippet,properties', '[+prefix+]site_snippets', $where); |
| 2325 | 2325 | $count = $this->db->getRecordCount($rs); |
| 2326 | 2326 | if (1 < $count) { |
| 2327 | - exit('Error $modx->_getSnippetObject()' . $snip_name); |
|
| 2327 | + exit('Error $modx->_getSnippetObject()'.$snip_name); |
|
| 2328 | 2328 | } |
| 2329 | 2329 | if ($count) { |
| 2330 | 2330 | $row = $this->db->getRow($rs); |
@@ -2350,7 +2350,7 @@ discard block |
||
| 2350 | 2350 | public function toAlias($text) |
| 2351 | 2351 | { |
| 2352 | 2352 | $suff = $this->config['friendly_url_suffix']; |
| 2353 | - return str_replace(array('.xml' . $suff, '.rss' . $suff, '.js' . $suff, '.css' . $suff, '.txt' . $suff, '.json' . $suff, '.pdf' . $suff), array('.xml', '.rss', '.js', '.css', '.txt', '.json', '.pdf'), $text); |
|
| 2353 | + return str_replace(array('.xml'.$suff, '.rss'.$suff, '.js'.$suff, '.css'.$suff, '.txt'.$suff, '.json'.$suff, '.pdf'.$suff), array('.xml', '.rss', '.js', '.css', '.txt', '.json', '.pdf'), $text); |
|
| 2354 | 2354 | } |
| 2355 | 2355 | |
| 2356 | 2356 | /** |
@@ -2382,7 +2382,7 @@ discard block |
||
| 2382 | 2382 | $suff = '/'; |
| 2383 | 2383 | } |
| 2384 | 2384 | |
| 2385 | - $url = ($dir != '' ? $dir . '/' : '') . $pre . $alias . $suff; |
|
| 2385 | + $url = ($dir != '' ? $dir.'/' : '').$pre.$alias.$suff; |
|
| 2386 | 2386 | } |
| 2387 | 2387 | |
| 2388 | 2388 | $evtOut = $this->invokeEvent('OnMakeDocUrl', array( |
@@ -2419,7 +2419,7 @@ discard block |
||
| 2419 | 2419 | preg_match_all('!\[\~([0-9]+)\~\]!ise', $documentSource, $match); |
| 2420 | 2420 | $ids = implode(',', array_unique($match['1'])); |
| 2421 | 2421 | if ($ids) { |
| 2422 | - $res = $this->db->select("id,alias,isfolder,parent,alias_visible", $this->getFullTableName('site_content'), "id IN (" . $ids . ") AND isfolder = '0'"); |
|
| 2422 | + $res = $this->db->select("id,alias,isfolder,parent,alias_visible", $this->getFullTableName('site_content'), "id IN (".$ids.") AND isfolder = '0'"); |
|
| 2423 | 2423 | while ($row = $this->db->getRow($res)) { |
| 2424 | 2424 | if ($this->config['use_alias_path'] == '1' && $row['parent'] != 0) { |
| 2425 | 2425 | $parent = $row['parent']; |
@@ -2430,7 +2430,7 @@ discard block |
||
| 2430 | 2430 | $parent = $this->aliasListing[$parent]['parent']; |
| 2431 | 2431 | } |
| 2432 | 2432 | |
| 2433 | - $aliases[$row['id']] = $path . '/' . $row['alias']; |
|
| 2433 | + $aliases[$row['id']] = $path.'/'.$row['alias']; |
|
| 2434 | 2434 | } else { |
| 2435 | 2435 | $aliases[$row['id']] = $row['alias']; |
| 2436 | 2436 | } |
@@ -2442,7 +2442,7 @@ discard block |
||
| 2442 | 2442 | $isfriendly = ($this->config['friendly_alias_urls'] == 1 ? 1 : 0); |
| 2443 | 2443 | $pref = $this->config['friendly_url_prefix']; |
| 2444 | 2444 | $suff = $this->config['friendly_url_suffix']; |
| 2445 | - $documentSource = preg_replace_callback($in, function ($m) use ($aliases, $isfolder, $isfriendly, $pref, $suff) { |
|
| 2445 | + $documentSource = preg_replace_callback($in, function($m) use ($aliases, $isfolder, $isfriendly, $pref, $suff) { |
|
| 2446 | 2446 | global $modx; |
| 2447 | 2447 | $thealias = $aliases[$m[1]]; |
| 2448 | 2448 | $thefolder = $isfolder[$m[1]]; |
@@ -2458,7 +2458,7 @@ discard block |
||
| 2458 | 2458 | |
| 2459 | 2459 | } else { |
| 2460 | 2460 | $in = '!\[\~([0-9]+)\~\]!is'; |
| 2461 | - $out = "index.php?id=" . '\1'; |
|
| 2461 | + $out = "index.php?id=".'\1'; |
|
| 2462 | 2462 | $documentSource = preg_replace($in, $out, $documentSource); |
| 2463 | 2463 | } |
| 2464 | 2464 | |
@@ -2479,7 +2479,7 @@ discard block |
||
| 2479 | 2479 | $scheme = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https' : 'http'; |
| 2480 | 2480 | $len_base_url = strlen($this->config['base_url']); |
| 2481 | 2481 | |
| 2482 | - $url_path = $q;//LANG |
|
| 2482 | + $url_path = $q; //LANG |
|
| 2483 | 2483 | |
| 2484 | 2484 | if (substr($url_path, 0, $len_base_url) === $this->config['base_url']) { |
| 2485 | 2485 | $url_path = substr($url_path, $len_base_url); |
@@ -2491,7 +2491,7 @@ discard block |
||
| 2491 | 2491 | $strictURL = substr($strictURL, $len_base_url); |
| 2492 | 2492 | } |
| 2493 | 2493 | $http_host = $_SERVER['HTTP_HOST']; |
| 2494 | - $requestedURL = "{$scheme}://{$http_host}" . '/' . $q; //LANG |
|
| 2494 | + $requestedURL = "{$scheme}://{$http_host}".'/'.$q; //LANG |
|
| 2495 | 2495 | |
| 2496 | 2496 | $site_url = $this->config['site_url']; |
| 2497 | 2497 | |
@@ -2507,7 +2507,7 @@ discard block |
||
| 2507 | 2507 | } |
| 2508 | 2508 | if ($this->config['base_url'] != $_SERVER['REQUEST_URI']) { |
| 2509 | 2509 | if (empty($_POST)) { |
| 2510 | - if (($this->config['base_url'] . '?' . $qstring) != $_SERVER['REQUEST_URI']) { |
|
| 2510 | + if (($this->config['base_url'].'?'.$qstring) != $_SERVER['REQUEST_URI']) { |
|
| 2511 | 2511 | $this->sendRedirect($url, 0, 'REDIRECT_HEADER', 'HTTP/1.0 301 Moved Permanently'); |
| 2512 | 2512 | exit(0); |
| 2513 | 2513 | } |
@@ -2570,7 +2570,7 @@ discard block |
||
| 2570 | 2570 | $docgrp = implode(",", $docgrp); |
| 2571 | 2571 | } |
| 2572 | 2572 | // get document |
| 2573 | - $access = ($this->isFrontend() ? "sc.privateweb=0" : "1='" . $_SESSION['mgrRole'] . "' OR sc.privatemgr=0") . (!$docgrp ? "" : " OR dg.document_group IN ($docgrp)"); |
|
| 2573 | + $access = ($this->isFrontend() ? "sc.privateweb=0" : "1='".$_SESSION['mgrRole']."' OR sc.privatemgr=0").(!$docgrp ? "" : " OR dg.document_group IN ($docgrp)"); |
|
| 2574 | 2574 | $rs = $this->db->select('sc.*', "{$tblsc} sc |
| 2575 | 2575 | LEFT JOIN {$tbldg} dg ON dg.document = sc.id", "sc.{$method} = '{$identifier}' AND ({$access})", "", 1); |
| 2576 | 2576 | if ($this->db->getRecordCount($rs) < 1) { |
@@ -2606,9 +2606,9 @@ discard block |
||
| 2606 | 2606 | } |
| 2607 | 2607 | if ($documentObject['template']) { |
| 2608 | 2608 | // load TVs and merge with document - Orig by Apodigm - Docvars |
| 2609 | - $rs = $this->db->select("tv.*, IF(tvc.value!='',tvc.value,tv.default_text) as value", $this->getFullTableName("site_tmplvars") . " tv |
|
| 2610 | - INNER JOIN " . $this->getFullTableName("site_tmplvar_templates") . " tvtpl ON tvtpl.tmplvarid = tv.id |
|
| 2611 | - LEFT JOIN " . $this->getFullTableName("site_tmplvar_contentvalues") . " tvc ON tvc.tmplvarid=tv.id AND tvc.contentid = '{$documentObject['id']}'", "tvtpl.templateid = '{$documentObject['template']}'"); |
|
| 2609 | + $rs = $this->db->select("tv.*, IF(tvc.value!='',tvc.value,tv.default_text) as value", $this->getFullTableName("site_tmplvars")." tv |
|
| 2610 | + INNER JOIN " . $this->getFullTableName("site_tmplvar_templates")." tvtpl ON tvtpl.tmplvarid = tv.id |
|
| 2611 | + LEFT JOIN " . $this->getFullTableName("site_tmplvar_contentvalues")." tvc ON tvc.tmplvarid=tv.id AND tvc.contentid = '{$documentObject['id']}'", "tvtpl.templateid = '{$documentObject['template']}'"); |
|
| 2612 | 2612 | $tmplvars = array(); |
| 2613 | 2613 | while ($row = $this->db->getRow($rs)) { |
| 2614 | 2614 | $tmplvars[$row['name']] = array( |
@@ -2654,7 +2654,7 @@ discard block |
||
| 2654 | 2654 | $st = md5($source); |
| 2655 | 2655 | } |
| 2656 | 2656 | if ($this->dumpSnippets == 1) { |
| 2657 | - $this->snippetsCode .= "<fieldset><legend><b style='color: #821517;'>PARSE PASS " . ($i + 1) . "</b></legend><p>The following snippets (if any) were parsed during this pass.</p>"; |
|
| 2657 | + $this->snippetsCode .= "<fieldset><legend><b style='color: #821517;'>PARSE PASS ".($i + 1)."</b></legend><p>The following snippets (if any) were parsed during this pass.</p>"; |
|
| 2658 | 2658 | } |
| 2659 | 2659 | |
| 2660 | 2660 | // invoke OnParseDocument event |
@@ -2740,7 +2740,7 @@ discard block |
||
| 2740 | 2740 | |
| 2741 | 2741 | // Check use_alias_path and check if $this->virtualDir is set to anything, then parse the path |
| 2742 | 2742 | if ($this->config['use_alias_path'] == 1) { |
| 2743 | - $alias = (strlen($this->virtualDir) > 0 ? $this->virtualDir . '/' : '') . $this->documentIdentifier; |
|
| 2743 | + $alias = (strlen($this->virtualDir) > 0 ? $this->virtualDir.'/' : '').$this->documentIdentifier; |
|
| 2744 | 2744 | if (isset($this->documentListing[$alias])) { |
| 2745 | 2745 | $this->documentIdentifier = $this->documentListing[$alias]; |
| 2746 | 2746 | } else { |
@@ -2801,7 +2801,7 @@ discard block |
||
| 2801 | 2801 | } else { |
| 2802 | 2802 | $docAlias = $this->db->escape($this->documentIdentifier); |
| 2803 | 2803 | $rs = $this->db->select('id', $this->getFullTableName('site_content'), "deleted=0 and alias='{$docAlias}'"); |
| 2804 | - $this->documentIdentifier = (int)$this->db->getValue($rs); |
|
| 2804 | + $this->documentIdentifier = (int) $this->db->getValue($rs); |
|
| 2805 | 2805 | } |
| 2806 | 2806 | } |
| 2807 | 2807 | $this->documentMethod = 'id'; |
@@ -2854,7 +2854,7 @@ discard block |
||
| 2854 | 2854 | $_REQUEST[$n] = $_GET[$n] = $v; |
| 2855 | 2855 | } |
| 2856 | 2856 | } |
| 2857 | - $_SERVER['PHP_SELF'] = $this->config['base_url'] . $qp['path']; |
|
| 2857 | + $_SERVER['PHP_SELF'] = $this->config['base_url'].$qp['path']; |
|
| 2858 | 2858 | $this->q = $qp['path']; |
| 2859 | 2859 | return $qp['path']; |
| 2860 | 2860 | } |
@@ -2948,7 +2948,7 @@ discard block |
||
| 2948 | 2948 | $this->sendErrorPage(); |
| 2949 | 2949 | } else { |
| 2950 | 2950 | // Inculde the necessary files to check document permissions |
| 2951 | - include_once(MODX_MANAGER_PATH . 'processors/user_documents_permissions.class.php'); |
|
| 2951 | + include_once(MODX_MANAGER_PATH.'processors/user_documents_permissions.class.php'); |
|
| 2952 | 2952 | $udperms = new udperms(); |
| 2953 | 2953 | $udperms->user = $this->getLoginUserID(); |
| 2954 | 2954 | $udperms->document = $this->documentIdentifier; |
@@ -3002,7 +3002,7 @@ discard block |
||
| 3002 | 3002 | while ($id && $height--) { |
| 3003 | 3003 | $thisid = $id; |
| 3004 | 3004 | if ($this->config['aliaslistingfolder'] == 1) { |
| 3005 | - $id = isset($this->aliasListing[$id]['parent']) ? $this->aliasListing[$id]['parent'] : $this->db->getValue("SELECT `parent` FROM " . $this->getFullTableName("site_content") . " WHERE `id` = '{$id}' LIMIT 0,1"); |
|
| 3005 | + $id = isset($this->aliasListing[$id]['parent']) ? $this->aliasListing[$id]['parent'] : $this->db->getValue("SELECT `parent` FROM ".$this->getFullTableName("site_content")." WHERE `id` = '{$id}' LIMIT 0,1"); |
|
| 3006 | 3006 | if (!$id || $id == '0') { |
| 3007 | 3007 | break; |
| 3008 | 3008 | } |
@@ -3053,15 +3053,15 @@ discard block |
||
| 3053 | 3053 | |
| 3054 | 3054 | if ($this->config['aliaslistingfolder'] == 1) { |
| 3055 | 3055 | |
| 3056 | - $res = $this->db->select("id,alias,isfolder,parent", $this->getFullTableName('site_content'), "parent IN (" . $id . ") AND deleted = '0'"); |
|
| 3056 | + $res = $this->db->select("id,alias,isfolder,parent", $this->getFullTableName('site_content'), "parent IN (".$id.") AND deleted = '0'"); |
|
| 3057 | 3057 | $idx = array(); |
| 3058 | 3058 | while ($row = $this->db->getRow($res)) { |
| 3059 | 3059 | $pAlias = ''; |
| 3060 | 3060 | if (isset($this->aliasListing[$row['parent']])) { |
| 3061 | - $pAlias .= !empty($this->aliasListing[$row['parent']]['path']) ? $this->aliasListing[$row['parent']]['path'] . '/' : ''; |
|
| 3062 | - $pAlias .= !empty($this->aliasListing[$row['parent']]['alias']) ? $this->aliasListing[$row['parent']]['alias'] . '/' : ''; |
|
| 3061 | + $pAlias .= !empty($this->aliasListing[$row['parent']]['path']) ? $this->aliasListing[$row['parent']]['path'].'/' : ''; |
|
| 3062 | + $pAlias .= !empty($this->aliasListing[$row['parent']]['alias']) ? $this->aliasListing[$row['parent']]['alias'].'/' : ''; |
|
| 3063 | 3063 | }; |
| 3064 | - $children[$pAlias . $row['alias']] = $row['id']; |
|
| 3064 | + $children[$pAlias.$row['alias']] = $row['id']; |
|
| 3065 | 3065 | if ($row['isfolder'] == 1) { |
| 3066 | 3066 | $idx[] = $row['id']; |
| 3067 | 3067 | } |
@@ -3093,7 +3093,7 @@ discard block |
||
| 3093 | 3093 | $depth--; |
| 3094 | 3094 | |
| 3095 | 3095 | foreach ($documentMap_cache[$id] as $childId) { |
| 3096 | - $pkey = (strlen($this->aliasListing[$childId]['path']) ? "{$this->aliasListing[$childId]['path']}/" : '') . $this->aliasListing[$childId]['alias']; |
|
| 3096 | + $pkey = (strlen($this->aliasListing[$childId]['path']) ? "{$this->aliasListing[$childId]['path']}/" : '').$this->aliasListing[$childId]['alias']; |
|
| 3097 | 3097 | if (!strlen($pkey)) { |
| 3098 | 3098 | $pkey = "{$childId}"; |
| 3099 | 3099 | } |
@@ -3122,7 +3122,7 @@ discard block |
||
| 3122 | 3122 | if (substr(strtolower($url), 0, 11) == "javascript:") { |
| 3123 | 3123 | $fnc = substr($url, 11); |
| 3124 | 3124 | } elseif ($url) { |
| 3125 | - $fnc = "window.location.href='" . addslashes($url) . "';"; |
|
| 3125 | + $fnc = "window.location.href='".addslashes($url)."';"; |
|
| 3126 | 3126 | } else { |
| 3127 | 3127 | $fnc = "history.back(-1);"; |
| 3128 | 3128 | } |
@@ -3131,7 +3131,7 @@ discard block |
||
| 3131 | 3131 | <meta http-equiv=\"Content-Type\" content=\"text/html; charset={$modx_manager_charset};\"> |
| 3132 | 3132 | <script> |
| 3133 | 3133 | function __alertQuit() { |
| 3134 | - alert('" . addslashes($msg) . "'); |
|
| 3134 | + alert('".addslashes($msg)."'); |
|
| 3135 | 3135 | {$fnc} |
| 3136 | 3136 | } |
| 3137 | 3137 | window.setTimeout('__alertQuit();',100); |
@@ -3155,7 +3155,7 @@ discard block |
||
| 3155 | 3155 | if ($pms) { |
| 3156 | 3156 | $state = ($pms[$pm] == 1); |
| 3157 | 3157 | } |
| 3158 | - return (int)$state; |
|
| 3158 | + return (int) $state; |
|
| 3159 | 3159 | } |
| 3160 | 3160 | |
| 3161 | 3161 | /** |
@@ -3236,7 +3236,7 @@ discard block |
||
| 3236 | 3236 | $this->lockedElements = array(); |
| 3237 | 3237 | $this->cleanupExpiredLocks(); |
| 3238 | 3238 | |
| 3239 | - $rs = $this->db->select('sid,internalKey,elementType,elementId,lasthit,username', $this->getFullTableName('active_user_locks') . " ul |
|
| 3239 | + $rs = $this->db->select('sid,internalKey,elementType,elementId,lasthit,username', $this->getFullTableName('active_user_locks')." ul |
|
| 3240 | 3240 | LEFT JOIN {$this->getFullTableName('manager_users')} mu on ul.internalKey = mu.id"); |
| 3241 | 3241 | while ($row = $this->db->getRow($rs)) { |
| 3242 | 3242 | $this->lockedElements[$row['elementType']][$row['elementId']] = array( |
@@ -3272,7 +3272,7 @@ discard block |
||
| 3272 | 3272 | foreach ($rs as $row) { |
| 3273 | 3273 | $userSids[] = $row['sid']; |
| 3274 | 3274 | } |
| 3275 | - $userSids = "'" . implode("','", $userSids) . "'"; |
|
| 3275 | + $userSids = "'".implode("','", $userSids)."'"; |
|
| 3276 | 3276 | $this->db->delete($this->getFullTableName('active_user_locks'), "sid NOT IN({$userSids})"); |
| 3277 | 3277 | } else { |
| 3278 | 3278 | $this->db->delete($this->getFullTableName('active_user_locks')); |
@@ -3469,8 +3469,8 @@ discard block |
||
| 3469 | 3469 | if (isset($this->config['send_errormail']) && $this->config['send_errormail'] !== '0') { |
| 3470 | 3470 | if ($this->config['send_errormail'] <= $type) { |
| 3471 | 3471 | $this->sendmail(array( |
| 3472 | - 'subject' => 'MODX System Error on ' . $this->config['site_name'], |
|
| 3473 | - 'body' => 'Source: ' . $source . ' - The details of the error could be seen in the MODX system events log.', |
|
| 3472 | + 'subject' => 'MODX System Error on '.$this->config['site_name'], |
|
| 3473 | + 'body' => 'Source: '.$source.' - The details of the error could be seen in the MODX system events log.', |
|
| 3474 | 3474 | 'type' => 'text' |
| 3475 | 3475 | )); |
| 3476 | 3476 | } |
@@ -3518,7 +3518,7 @@ discard block |
||
| 3518 | 3518 | $p['fromname'] = $userinfo['username']; |
| 3519 | 3519 | } |
| 3520 | 3520 | if ($msg === '' && !isset($p['body'])) { |
| 3521 | - $p['body'] = $_SERVER['REQUEST_URI'] . "\n" . $_SERVER['HTTP_USER_AGENT'] . "\n" . $_SERVER['HTTP_REFERER']; |
|
| 3521 | + $p['body'] = $_SERVER['REQUEST_URI']."\n".$_SERVER['HTTP_USER_AGENT']."\n".$_SERVER['HTTP_REFERER']; |
|
| 3522 | 3522 | } elseif (is_string($msg) && 0 < strlen($msg)) { |
| 3523 | 3523 | $p['body'] = $msg; |
| 3524 | 3524 | } |
@@ -3558,8 +3558,8 @@ discard block |
||
| 3558 | 3558 | $files = array(); |
| 3559 | 3559 | } |
| 3560 | 3560 | foreach ($files as $f) { |
| 3561 | - if (file_exists(MODX_BASE_PATH . $f) && is_file(MODX_BASE_PATH . $f) && is_readable(MODX_BASE_PATH . $f)) { |
|
| 3562 | - $this->mail->AddAttachment(MODX_BASE_PATH . $f); |
|
| 3561 | + if (file_exists(MODX_BASE_PATH.$f) && is_file(MODX_BASE_PATH.$f) && is_readable(MODX_BASE_PATH.$f)) { |
|
| 3562 | + $this->mail->AddAttachment(MODX_BASE_PATH.$f); |
|
| 3563 | 3563 | } |
| 3564 | 3564 | } |
| 3565 | 3565 | $rs = $this->mail->send(); |
@@ -3604,7 +3604,7 @@ discard block |
||
| 3604 | 3604 | */ |
| 3605 | 3605 | public function isFrontend() |
| 3606 | 3606 | { |
| 3607 | - return ! $this->isBackend(); |
|
| 3607 | + return !$this->isBackend(); |
|
| 3608 | 3608 | } |
| 3609 | 3609 | |
| 3610 | 3610 | /** |
@@ -3629,14 +3629,14 @@ discard block |
||
| 3629 | 3629 | $tblsc = $this->getFullTableName("site_content"); |
| 3630 | 3630 | $tbldg = $this->getFullTableName("document_groups"); |
| 3631 | 3631 | // modify field names to use sc. table reference |
| 3632 | - $fields = 'sc.' . implode(',sc.', array_filter(array_map('trim', explode(',', $fields)))); |
|
| 3633 | - $sort = 'sc.' . implode(',sc.', array_filter(array_map('trim', explode(',', $sort)))); |
|
| 3632 | + $fields = 'sc.'.implode(',sc.', array_filter(array_map('trim', explode(',', $fields)))); |
|
| 3633 | + $sort = 'sc.'.implode(',sc.', array_filter(array_map('trim', explode(',', $sort)))); |
|
| 3634 | 3634 | // get document groups for current user |
| 3635 | 3635 | if ($docgrp = $this->getUserDocGroups()) { |
| 3636 | 3636 | $docgrp = implode(",", $docgrp); |
| 3637 | 3637 | } |
| 3638 | 3638 | // build query |
| 3639 | - $access = ($this->isFrontend() ? "sc.privateweb=0" : "1='" . $_SESSION['mgrRole'] . "' OR sc.privatemgr=0") . (!$docgrp ? "" : " OR dg.document_group IN ($docgrp)"); |
|
| 3639 | + $access = ($this->isFrontend() ? "sc.privateweb=0" : "1='".$_SESSION['mgrRole']."' OR sc.privatemgr=0").(!$docgrp ? "" : " OR dg.document_group IN ($docgrp)"); |
|
| 3640 | 3640 | $result = $this->db->select("DISTINCT {$fields}", "{$tblsc} sc |
| 3641 | 3641 | LEFT JOIN {$tbldg} dg on dg.document = sc.id", "sc.parent = '{$id}' AND ({$access}) GROUP BY sc.id", "{$sort} {$dir}"); |
| 3642 | 3642 | $resourceArray = $this->db->makeArray($result); |
@@ -3666,14 +3666,14 @@ discard block |
||
| 3666 | 3666 | $tbldg = $this->getFullTableName("document_groups"); |
| 3667 | 3667 | |
| 3668 | 3668 | // modify field names to use sc. table reference |
| 3669 | - $fields = 'sc.' . implode(',sc.', array_filter(array_map('trim', explode(',', $fields)))); |
|
| 3670 | - $sort = 'sc.' . implode(',sc.', array_filter(array_map('trim', explode(',', $sort)))); |
|
| 3669 | + $fields = 'sc.'.implode(',sc.', array_filter(array_map('trim', explode(',', $fields)))); |
|
| 3670 | + $sort = 'sc.'.implode(',sc.', array_filter(array_map('trim', explode(',', $sort)))); |
|
| 3671 | 3671 | // get document groups for current user |
| 3672 | 3672 | if ($docgrp = $this->getUserDocGroups()) { |
| 3673 | 3673 | $docgrp = implode(",", $docgrp); |
| 3674 | 3674 | } |
| 3675 | 3675 | // build query |
| 3676 | - $access = ($this->isFrontend() ? "sc.privateweb=0" : "1='" . $_SESSION['mgrRole'] . "' OR sc.privatemgr=0") . (!$docgrp ? "" : " OR dg.document_group IN ($docgrp)"); |
|
| 3676 | + $access = ($this->isFrontend() ? "sc.privateweb=0" : "1='".$_SESSION['mgrRole']."' OR sc.privatemgr=0").(!$docgrp ? "" : " OR dg.document_group IN ($docgrp)"); |
|
| 3677 | 3677 | $result = $this->db->select("DISTINCT {$fields}", "{$tblsc} sc |
| 3678 | 3678 | LEFT JOIN {$tbldg} dg on dg.document = sc.id", "sc.parent = '{$id}' AND sc.published=1 AND sc.deleted=0 AND ({$access}) GROUP BY sc.id", "{$sort} {$dir}"); |
| 3679 | 3679 | $resourceArray = $this->db->makeArray($result); |
@@ -3708,16 +3708,16 @@ discard block |
||
| 3708 | 3708 | return $this->tmpCache[__FUNCTION__][$cacheKey]; |
| 3709 | 3709 | } |
| 3710 | 3710 | |
| 3711 | - $published = ($published !== 'all') ? 'AND sc.published = ' . $published : ''; |
|
| 3712 | - $deleted = ($deleted !== 'all') ? 'AND sc.deleted = ' . $deleted : ''; |
|
| 3711 | + $published = ($published !== 'all') ? 'AND sc.published = '.$published : ''; |
|
| 3712 | + $deleted = ($deleted !== 'all') ? 'AND sc.deleted = '.$deleted : ''; |
|
| 3713 | 3713 | |
| 3714 | 3714 | if ($where != '') { |
| 3715 | - $where = 'AND ' . $where; |
|
| 3715 | + $where = 'AND '.$where; |
|
| 3716 | 3716 | } |
| 3717 | 3717 | |
| 3718 | 3718 | // modify field names to use sc. table reference |
| 3719 | - $fields = 'sc.' . implode(',sc.', array_filter(array_map('trim', explode(',', $fields)))); |
|
| 3720 | - $sort = ($sort == '') ? '' : 'sc.' . implode(',sc.', array_filter(array_map('trim', explode(',', $sort)))); |
|
| 3719 | + $fields = 'sc.'.implode(',sc.', array_filter(array_map('trim', explode(',', $fields)))); |
|
| 3720 | + $sort = ($sort == '') ? '' : 'sc.'.implode(',sc.', array_filter(array_map('trim', explode(',', $sort)))); |
|
| 3721 | 3721 | |
| 3722 | 3722 | // get document groups for current user |
| 3723 | 3723 | if ($docgrp = $this->getUserDocGroups()) { |
@@ -3725,7 +3725,7 @@ discard block |
||
| 3725 | 3725 | } |
| 3726 | 3726 | |
| 3727 | 3727 | // build query |
| 3728 | - $access = ($this->isFrontend() ? 'sc.privateweb=0' : '1="' . $_SESSION['mgrRole'] . '" OR sc.privatemgr=0') . (!$docgrp ? '' : ' OR dg.document_group IN (' . $docgrp . ')'); |
|
| 3728 | + $access = ($this->isFrontend() ? 'sc.privateweb=0' : '1="'.$_SESSION['mgrRole'].'" OR sc.privatemgr=0').(!$docgrp ? '' : ' OR dg.document_group IN ('.$docgrp.')'); |
|
| 3729 | 3729 | |
| 3730 | 3730 | $tblsc = $this->getFullTableName('site_content'); |
| 3731 | 3731 | $tbldg = $this->getFullTableName('document_groups'); |
@@ -3777,10 +3777,10 @@ discard block |
||
| 3777 | 3777 | return false; |
| 3778 | 3778 | } else { |
| 3779 | 3779 | // modify field names to use sc. table reference |
| 3780 | - $fields = 'sc.' . implode(',sc.', array_filter(array_map('trim', explode(',', $fields)))); |
|
| 3781 | - $sort = ($sort == '') ? '' : 'sc.' . implode(',sc.', array_filter(array_map('trim', explode(',', $sort)))); |
|
| 3780 | + $fields = 'sc.'.implode(',sc.', array_filter(array_map('trim', explode(',', $fields)))); |
|
| 3781 | + $sort = ($sort == '') ? '' : 'sc.'.implode(',sc.', array_filter(array_map('trim', explode(',', $sort)))); |
|
| 3782 | 3782 | if ($where != '') { |
| 3783 | - $where = 'AND ' . $where; |
|
| 3783 | + $where = 'AND '.$where; |
|
| 3784 | 3784 | } |
| 3785 | 3785 | |
| 3786 | 3786 | $published = ($published !== 'all') ? "AND sc.published = '{$published}'" : ''; |
@@ -3791,13 +3791,13 @@ discard block |
||
| 3791 | 3791 | $docgrp = implode(',', $docgrp); |
| 3792 | 3792 | } |
| 3793 | 3793 | |
| 3794 | - $access = ($this->isFrontend() ? 'sc.privateweb=0' : '1="' . $_SESSION['mgrRole'] . '" OR sc.privatemgr=0') . (!$docgrp ? '' : ' OR dg.document_group IN (' . $docgrp . ')'); |
|
| 3794 | + $access = ($this->isFrontend() ? 'sc.privateweb=0' : '1="'.$_SESSION['mgrRole'].'" OR sc.privatemgr=0').(!$docgrp ? '' : ' OR dg.document_group IN ('.$docgrp.')'); |
|
| 3795 | 3795 | |
| 3796 | 3796 | $tblsc = $this->getFullTableName('site_content'); |
| 3797 | 3797 | $tbldg = $this->getFullTableName('document_groups'); |
| 3798 | 3798 | |
| 3799 | 3799 | $result = $this->db->select("DISTINCT {$fields}", "{$tblsc} sc |
| 3800 | - LEFT JOIN {$tbldg} dg on dg.document = sc.id", "(sc.id IN (" . implode(',', $ids) . ") {$published} {$deleted} {$where}) AND ({$access}) GROUP BY sc.id", ($sort ? "{$sort} {$dir}" : ""), $limit); |
|
| 3800 | + LEFT JOIN {$tbldg} dg on dg.document = sc.id", "(sc.id IN (".implode(',', $ids).") {$published} {$deleted} {$where}) AND ({$access}) GROUP BY sc.id", ($sort ? "{$sort} {$dir}" : ""), $limit); |
|
| 3801 | 3801 | |
| 3802 | 3802 | $resourceArray = $this->db->makeArray($result); |
| 3803 | 3803 | |
@@ -3902,12 +3902,12 @@ discard block |
||
| 3902 | 3902 | $tbldg = $this->getFullTableName("document_groups"); |
| 3903 | 3903 | $activeSql = $active == 1 ? "AND sc.published=1 AND sc.deleted=0" : ""; |
| 3904 | 3904 | // modify field names to use sc. table reference |
| 3905 | - $fields = 'sc.' . implode(',sc.', array_filter(array_map('trim', explode(',', $fields)))); |
|
| 3905 | + $fields = 'sc.'.implode(',sc.', array_filter(array_map('trim', explode(',', $fields)))); |
|
| 3906 | 3906 | // get document groups for current user |
| 3907 | 3907 | if ($docgrp = $this->getUserDocGroups()) { |
| 3908 | 3908 | $docgrp = implode(",", $docgrp); |
| 3909 | 3909 | } |
| 3910 | - $access = ($this->isFrontend() ? "sc.privateweb=0" : "1='" . $_SESSION['mgrRole'] . "' OR sc.privatemgr=0") . (!$docgrp ? "" : " OR dg.document_group IN ($docgrp)"); |
|
| 3910 | + $access = ($this->isFrontend() ? "sc.privateweb=0" : "1='".$_SESSION['mgrRole']."' OR sc.privatemgr=0").(!$docgrp ? "" : " OR dg.document_group IN ($docgrp)"); |
|
| 3911 | 3911 | $result = $this->db->select($fields, "{$tblsc} sc LEFT JOIN {$tbldg} dg on dg.document = sc.id", "(sc.id='{$pageid}' {$activeSql}) AND ({$access})", "", 1); |
| 3912 | 3912 | $pageInfo = $this->db->getRow($result); |
| 3913 | 3913 | |
@@ -3954,7 +3954,7 @@ discard block |
||
| 3954 | 3954 | { |
| 3955 | 3955 | if ($this->currentSnippet) { |
| 3956 | 3956 | $tbl = $this->getFullTableName("site_snippets"); |
| 3957 | - $rs = $this->db->select('id', $tbl, "name='" . $this->db->escape($this->currentSnippet) . "'", '', 1); |
|
| 3957 | + $rs = $this->db->select('id', $tbl, "name='".$this->db->escape($this->currentSnippet)."'", '', 1); |
|
| 3958 | 3958 | if ($snippetId = $this->db->getValue($rs)) { |
| 3959 | 3959 | return $snippetId; |
| 3960 | 3960 | } |
@@ -3981,23 +3981,23 @@ discard block |
||
| 3981 | 3981 | */ |
| 3982 | 3982 | public function clearCache($type = '', $report = false) |
| 3983 | 3983 | { |
| 3984 | - $cache_dir = MODX_BASE_PATH . $this->getCacheFolder(); |
|
| 3984 | + $cache_dir = MODX_BASE_PATH.$this->getCacheFolder(); |
|
| 3985 | 3985 | if (is_array($type)) { |
| 3986 | 3986 | foreach ($type as $_) { |
| 3987 | 3987 | $this->clearCache($_, $report); |
| 3988 | 3988 | } |
| 3989 | 3989 | } elseif ($type == 'full') { |
| 3990 | - include_once(MODX_MANAGER_PATH . 'processors/cache_sync.class.processor.php'); |
|
| 3990 | + include_once(MODX_MANAGER_PATH.'processors/cache_sync.class.processor.php'); |
|
| 3991 | 3991 | $sync = new synccache(); |
| 3992 | 3992 | $sync->setCachepath($cache_dir); |
| 3993 | 3993 | $sync->setReport($report); |
| 3994 | 3994 | $sync->emptyCache(); |
| 3995 | 3995 | } elseif (preg_match('@^[1-9][0-9]*$@', $type)) { |
| 3996 | 3996 | $key = ($this->config['cache_type'] == 2) ? $this->makePageCacheKey($type) : $type; |
| 3997 | - $file_name = "docid_" . $key . "_*.pageCache.php"; |
|
| 3998 | - $cache_path = $cache_dir . $file_name; |
|
| 3997 | + $file_name = "docid_".$key."_*.pageCache.php"; |
|
| 3998 | + $cache_path = $cache_dir.$file_name; |
|
| 3999 | 3999 | $files = glob($cache_path); |
| 4000 | - $files[] = $cache_dir . "docid_" . $key . ".pageCache.php"; |
|
| 4000 | + $files[] = $cache_dir."docid_".$key.".pageCache.php"; |
|
| 4001 | 4001 | foreach ($files as $file) { |
| 4002 | 4002 | if (!is_file($file)) { |
| 4003 | 4003 | continue; |
@@ -4005,7 +4005,7 @@ discard block |
||
| 4005 | 4005 | unlink($file); |
| 4006 | 4006 | } |
| 4007 | 4007 | } else { |
| 4008 | - $files = glob($cache_dir . '*'); |
|
| 4008 | + $files = glob($cache_dir.'*'); |
|
| 4009 | 4009 | foreach ($files as $file) { |
| 4010 | 4010 | $name = basename($file); |
| 4011 | 4011 | if (strpos($name, '.pageCache.php') === false) { |
@@ -4074,7 +4074,7 @@ discard block |
||
| 4074 | 4074 | $f_url_suffix = '/'; |
| 4075 | 4075 | } |
| 4076 | 4076 | |
| 4077 | - $alPath = !empty ($al['path']) ? $al['path'] . '/' : ''; |
|
| 4077 | + $alPath = !empty ($al['path']) ? $al['path'].'/' : ''; |
|
| 4078 | 4078 | |
| 4079 | 4079 | if ($al && $al['alias']) { |
| 4080 | 4080 | $alias = $al['alias']; |
@@ -4082,7 +4082,7 @@ discard block |
||
| 4082 | 4082 | |
| 4083 | 4083 | } |
| 4084 | 4084 | |
| 4085 | - $alias = $alPath . $f_url_prefix . $alias . $f_url_suffix; |
|
| 4085 | + $alias = $alPath.$f_url_prefix.$alias.$f_url_suffix; |
|
| 4086 | 4086 | $url = "{$alias}{$args}"; |
| 4087 | 4087 | } else { |
| 4088 | 4088 | $url = "index.php?id={$id}{$args}"; |
@@ -4101,7 +4101,7 @@ discard block |
||
| 4101 | 4101 | } |
| 4102 | 4102 | |
| 4103 | 4103 | //TODO: check to make sure that $site_url incudes the url :port (e.g. :8080) |
| 4104 | - $host = $scheme == 'full' ? $this->config['site_url'] : $scheme . '://' . $_SERVER['HTTP_HOST'] . $host; |
|
| 4104 | + $host = $scheme == 'full' ? $this->config['site_url'] : $scheme.'://'.$_SERVER['HTTP_HOST'].$host; |
|
| 4105 | 4105 | } |
| 4106 | 4106 | |
| 4107 | 4107 | //fix strictUrl by Bumkaka |
@@ -4110,9 +4110,9 @@ discard block |
||
| 4110 | 4110 | } |
| 4111 | 4111 | |
| 4112 | 4112 | if ($this->config['xhtml_urls']) { |
| 4113 | - $url = preg_replace("/&(?!amp;)/", "&", $host . $virtualDir . $url); |
|
| 4113 | + $url = preg_replace("/&(?!amp;)/", "&", $host.$virtualDir.$url); |
|
| 4114 | 4114 | } else { |
| 4115 | - $url = $host . $virtualDir . $url; |
|
| 4115 | + $url = $host.$virtualDir.$url; |
|
| 4116 | 4116 | } |
| 4117 | 4117 | |
| 4118 | 4118 | $evtOut = $this->invokeEvent('OnMakeDocUrl', array( |
@@ -4136,21 +4136,21 @@ discard block |
||
| 4136 | 4136 | if (isset($this->aliasListing[$id])) { |
| 4137 | 4137 | $out = $this->aliasListing[$id]; |
| 4138 | 4138 | } else { |
| 4139 | - $q = $this->db->query("SELECT id,alias,isfolder,parent FROM " . $this->getFullTableName("site_content") . " WHERE id=" . (int)$id); |
|
| 4139 | + $q = $this->db->query("SELECT id,alias,isfolder,parent FROM ".$this->getFullTableName("site_content")." WHERE id=".(int) $id); |
|
| 4140 | 4140 | if ($this->db->getRecordCount($q) == '1') { |
| 4141 | 4141 | $q = $this->db->getRow($q); |
| 4142 | 4142 | $this->aliasListing[$id] = array( |
| 4143 | - 'id' => (int)$q['id'], |
|
| 4143 | + 'id' => (int) $q['id'], |
|
| 4144 | 4144 | 'alias' => $q['alias'] == '' ? $q['id'] : $q['alias'], |
| 4145 | - 'parent' => (int)$q['parent'], |
|
| 4146 | - 'isfolder' => (int)$q['isfolder'], |
|
| 4145 | + 'parent' => (int) $q['parent'], |
|
| 4146 | + 'isfolder' => (int) $q['isfolder'], |
|
| 4147 | 4147 | ); |
| 4148 | 4148 | if ($this->aliasListing[$id]['parent'] > 0) { |
| 4149 | 4149 | //fix alias_path_usage |
| 4150 | 4150 | if ($this->config['use_alias_path'] == '1') { |
| 4151 | 4151 | //&& $tmp['path'] != '' - fix error slash with epty path |
| 4152 | 4152 | $tmp = $this->getAliasListing($this->aliasListing[$id]['parent']); |
| 4153 | - $this->aliasListing[$id]['path'] = $tmp['path'] . ($tmp['alias_visible'] ? (($tmp['parent'] > 0 && $tmp['path'] != '') ? '/' : '') . $tmp['alias'] : ''); |
|
| 4153 | + $this->aliasListing[$id]['path'] = $tmp['path'].($tmp['alias_visible'] ? (($tmp['parent'] > 0 && $tmp['path'] != '') ? '/' : '').$tmp['alias'] : ''); |
|
| 4154 | 4154 | } else { |
| 4155 | 4155 | $this->aliasListing[$id]['path'] = ''; |
| 4156 | 4156 | } |
@@ -4191,7 +4191,7 @@ discard block |
||
| 4191 | 4191 | $out = array(); |
| 4192 | 4192 | if (empty($this->version) || !is_array($this->version)) { |
| 4193 | 4193 | //include for compatibility modx version < 1.0.10 |
| 4194 | - include MODX_MANAGER_PATH . "includes/version.inc.php"; |
|
| 4194 | + include MODX_MANAGER_PATH."includes/version.inc.php"; |
|
| 4195 | 4195 | $this->version = array(); |
| 4196 | 4196 | $this->version['version'] = isset($modx_version) ? $modx_version : ''; |
| 4197 | 4197 | $this->version['branch'] = isset($modx_branch) ? $modx_branch : ''; |
@@ -4213,18 +4213,18 @@ discard block |
||
| 4213 | 4213 | { |
| 4214 | 4214 | if (isset ($this->snippetCache[$snippetName])) { |
| 4215 | 4215 | $snippet = $this->snippetCache[$snippetName]; |
| 4216 | - $properties = !empty($this->snippetCache[$snippetName . "Props"]) ? $this->snippetCache[$snippetName . "Props"] : ''; |
|
| 4216 | + $properties = !empty($this->snippetCache[$snippetName."Props"]) ? $this->snippetCache[$snippetName."Props"] : ''; |
|
| 4217 | 4217 | } else { // not in cache so let's check the db |
| 4218 | - $sql = "SELECT ss.`name`, ss.`snippet`, ss.`properties`, sm.properties as `sharedproperties` FROM " . $this->getFullTableName("site_snippets") . " as ss LEFT JOIN " . $this->getFullTableName('site_modules') . " as sm on sm.guid=ss.moduleguid WHERE ss.`name`='" . $this->db->escape($snippetName) . "' AND ss.disabled=0;"; |
|
| 4218 | + $sql = "SELECT ss.`name`, ss.`snippet`, ss.`properties`, sm.properties as `sharedproperties` FROM ".$this->getFullTableName("site_snippets")." as ss LEFT JOIN ".$this->getFullTableName('site_modules')." as sm on sm.guid=ss.moduleguid WHERE ss.`name`='".$this->db->escape($snippetName)."' AND ss.disabled=0;"; |
|
| 4219 | 4219 | $result = $this->db->query($sql); |
| 4220 | 4220 | if ($this->db->getRecordCount($result) == 1) { |
| 4221 | 4221 | $row = $this->db->getRow($result); |
| 4222 | 4222 | $snippet = $this->snippetCache[$snippetName] = $row['snippet']; |
| 4223 | 4223 | $mergedProperties = array_merge($this->parseProperties($row['properties']), $this->parseProperties($row['sharedproperties'])); |
| 4224 | - $properties = $this->snippetCache[$snippetName . "Props"] = json_encode($mergedProperties); |
|
| 4224 | + $properties = $this->snippetCache[$snippetName."Props"] = json_encode($mergedProperties); |
|
| 4225 | 4225 | } else { |
| 4226 | 4226 | $snippet = $this->snippetCache[$snippetName] = "return false;"; |
| 4227 | - $properties = $this->snippetCache[$snippetName . "Props"] = ''; |
|
| 4227 | + $properties = $this->snippetCache[$snippetName."Props"] = ''; |
|
| 4228 | 4228 | } |
| 4229 | 4229 | } |
| 4230 | 4230 | // load default params/properties |
@@ -4327,8 +4327,8 @@ discard block |
||
| 4327 | 4327 | } |
| 4328 | 4328 | if (strpos($tpl, $s) !== false) { |
| 4329 | 4329 | $tpl = str_replace($s, $value, $tpl); |
| 4330 | - } elseif($this->debug) { |
|
| 4331 | - $this->addLog('parseText parse error', $_SERVER['REQUEST_URI'] . $s, 2); |
|
| 4330 | + } elseif ($this->debug) { |
|
| 4331 | + $this->addLog('parseText parse error', $_SERVER['REQUEST_URI'].$s, 2); |
|
| 4332 | 4332 | } |
| 4333 | 4333 | } |
| 4334 | 4334 | |
@@ -4377,7 +4377,7 @@ discard block |
||
| 4377 | 4377 | case 'CODE': |
| 4378 | 4378 | break; |
| 4379 | 4379 | case 'FILE': |
| 4380 | - $template = file_get_contents(MODX_BASE_PATH . $template); |
|
| 4380 | + $template = file_get_contents(MODX_BASE_PATH.$template); |
|
| 4381 | 4381 | break; |
| 4382 | 4382 | case 'CHUNK': |
| 4383 | 4383 | $template = $this->getChunk($template); |
@@ -4430,7 +4430,7 @@ discard block |
||
| 4430 | 4430 | } |
| 4431 | 4431 | |
| 4432 | 4432 | if (empty($mode)) { |
| 4433 | - $strTime = strftime($dateFormat . " %H:%M:%S", $timestamp); |
|
| 4433 | + $strTime = strftime($dateFormat." %H:%M:%S", $timestamp); |
|
| 4434 | 4434 | } elseif ($mode == 'dateOnly') { |
| 4435 | 4435 | $strTime = strftime($dateFormat, $timestamp); |
| 4436 | 4436 | } elseif ($mode == 'formatOnly') { |
@@ -4526,7 +4526,7 @@ discard block |
||
| 4526 | 4526 | if ($v === 'value') { |
| 4527 | 4527 | unset($_[$i]); |
| 4528 | 4528 | } else { |
| 4529 | - $_[$i] = 'tv.' . $v; |
|
| 4529 | + $_[$i] = 'tv.'.$v; |
|
| 4530 | 4530 | } |
| 4531 | 4531 | } |
| 4532 | 4532 | $fields = join(',', $_); |
@@ -4535,12 +4535,12 @@ discard block |
||
| 4535 | 4535 | } |
| 4536 | 4536 | |
| 4537 | 4537 | if ($tvsort != '') { |
| 4538 | - $tvsort = 'tv.' . join(',tv.', array_filter(array_map('trim', explode(',', $tvsort)))); |
|
| 4538 | + $tvsort = 'tv.'.join(',tv.', array_filter(array_map('trim', explode(',', $tvsort)))); |
|
| 4539 | 4539 | } |
| 4540 | 4540 | if ($tvidnames == "*") { |
| 4541 | 4541 | $query = "tv.id<>0"; |
| 4542 | 4542 | } else { |
| 4543 | - $query = (is_numeric($tvidnames[0]) ? "tv.id" : "tv.name") . " IN ('" . join("','", $tvidnames) . "')"; |
|
| 4543 | + $query = (is_numeric($tvidnames[0]) ? "tv.id" : "tv.name")." IN ('".join("','", $tvidnames)."')"; |
|
| 4544 | 4544 | } |
| 4545 | 4545 | |
| 4546 | 4546 | $this->getUserDocGroups(); |
@@ -4684,7 +4684,7 @@ discard block |
||
| 4684 | 4684 | return $this->tmpCache[__FUNCTION__][$cacheKey]; |
| 4685 | 4685 | } |
| 4686 | 4686 | |
| 4687 | - if (($idnames != '*' && !is_array($idnames)) || empty($idnames) ) { |
|
| 4687 | + if (($idnames != '*' && !is_array($idnames)) || empty($idnames)) { |
|
| 4688 | 4688 | return false; |
| 4689 | 4689 | } else { |
| 4690 | 4690 | |
@@ -4702,23 +4702,23 @@ discard block |
||
| 4702 | 4702 | } |
| 4703 | 4703 | |
| 4704 | 4704 | // get user defined template variables |
| 4705 | - $fields = ($fields == '') ? 'tv.*' : 'tv.' . implode(',tv.', array_filter(array_map('trim', explode(',', $fields)))); |
|
| 4706 | - $sort = ($sort == '') ? '' : 'tv.' . implode(',tv.', array_filter(array_map('trim', explode(',', $sort)))); |
|
| 4705 | + $fields = ($fields == '') ? 'tv.*' : 'tv.'.implode(',tv.', array_filter(array_map('trim', explode(',', $fields)))); |
|
| 4706 | + $sort = ($sort == '') ? '' : 'tv.'.implode(',tv.', array_filter(array_map('trim', explode(',', $sort)))); |
|
| 4707 | 4707 | |
| 4708 | 4708 | if ($idnames == '*') { |
| 4709 | 4709 | $query = 'tv.id<>0'; |
| 4710 | 4710 | } else { |
| 4711 | - $query = (is_numeric($idnames[0]) ? 'tv.id' : 'tv.name') . " IN ('" . implode("','", $idnames) . "')"; |
|
| 4711 | + $query = (is_numeric($idnames[0]) ? 'tv.id' : 'tv.name')." IN ('".implode("','", $idnames)."')"; |
|
| 4712 | 4712 | } |
| 4713 | 4713 | |
| 4714 | - $rs = $this->db->select("{$fields}, IF(tvc.value != '', tvc.value, tv.default_text) as value", $this->getFullTableName('site_tmplvars') . " tv |
|
| 4715 | - INNER JOIN " . $this->getFullTableName('site_tmplvar_templates') . " tvtpl ON tvtpl.tmplvarid = tv.id |
|
| 4716 | - LEFT JOIN " . $this->getFullTableName('site_tmplvar_contentvalues') . " tvc ON tvc.tmplvarid=tv.id AND tvc.contentid = '{$docid}'", "{$query} AND tvtpl.templateid = '{$docRow['template']}'", ($sort ? "{$sort} {$dir}" : "")); |
|
| 4714 | + $rs = $this->db->select("{$fields}, IF(tvc.value != '', tvc.value, tv.default_text) as value", $this->getFullTableName('site_tmplvars')." tv |
|
| 4715 | + INNER JOIN " . $this->getFullTableName('site_tmplvar_templates')." tvtpl ON tvtpl.tmplvarid = tv.id |
|
| 4716 | + LEFT JOIN " . $this->getFullTableName('site_tmplvar_contentvalues')." tvc ON tvc.tmplvarid=tv.id AND tvc.contentid = '{$docid}'", "{$query} AND tvtpl.templateid = '{$docRow['template']}'", ($sort ? "{$sort} {$dir}" : "")); |
|
| 4717 | 4717 | |
| 4718 | 4718 | $result = $this->db->makeArray($rs); |
| 4719 | 4719 | |
| 4720 | 4720 | // get default/built-in template variables |
| 4721 | - if(is_array($docRow)){ |
|
| 4721 | + if (is_array($docRow)) { |
|
| 4722 | 4722 | ksort($docRow); |
| 4723 | 4723 | |
| 4724 | 4724 | foreach ($docRow as $key => $value) { |
@@ -4756,7 +4756,7 @@ discard block |
||
| 4756 | 4756 | */ |
| 4757 | 4757 | public function getTemplateVarOutput($idnames = array(), $docid = '', $published = 1, $sep = '') |
| 4758 | 4758 | { |
| 4759 | - if (is_array($idnames) && empty($idnames) ) { |
|
| 4759 | + if (is_array($idnames) && empty($idnames)) { |
|
| 4760 | 4760 | return false; |
| 4761 | 4761 | } else { |
| 4762 | 4762 | $output = array(); |
@@ -4769,9 +4769,9 @@ discard block |
||
| 4769 | 4769 | if ($result == false) { |
| 4770 | 4770 | return false; |
| 4771 | 4771 | } else { |
| 4772 | - $baspath = MODX_MANAGER_PATH . 'includes'; |
|
| 4773 | - include_once $baspath . '/tmplvars.format.inc.php'; |
|
| 4774 | - include_once $baspath . '/tmplvars.commands.inc.php'; |
|
| 4772 | + $baspath = MODX_MANAGER_PATH.'includes'; |
|
| 4773 | + include_once $baspath.'/tmplvars.format.inc.php'; |
|
| 4774 | + include_once $baspath.'/tmplvars.commands.inc.php'; |
|
| 4775 | 4775 | |
| 4776 | 4776 | for ($i = 0; $i < count($result); $i++) { |
| 4777 | 4777 | $row = $result[$i]; |
@@ -4796,7 +4796,7 @@ discard block |
||
| 4796 | 4796 | */ |
| 4797 | 4797 | public function getFullTableName($tbl) |
| 4798 | 4798 | { |
| 4799 | - return $this->db->config['dbase'] . ".`" . $this->db->config['table_prefix'] . $tbl . "`"; |
|
| 4799 | + return $this->db->config['dbase'].".`".$this->db->config['table_prefix'].$tbl."`"; |
|
| 4800 | 4800 | } |
| 4801 | 4801 | |
| 4802 | 4802 | /** |
@@ -4875,7 +4875,7 @@ discard block |
||
| 4875 | 4875 | public function getCachePath() |
| 4876 | 4876 | { |
| 4877 | 4877 | global $base_url; |
| 4878 | - $pth = $base_url . $this->getCacheFolder(); |
|
| 4878 | + $pth = $base_url.$this->getCacheFolder(); |
|
| 4879 | 4879 | return $pth; |
| 4880 | 4880 | } |
| 4881 | 4881 | |
@@ -4927,8 +4927,8 @@ discard block |
||
| 4927 | 4927 | $out = false; |
| 4928 | 4928 | |
| 4929 | 4929 | if (!empty($context)) { |
| 4930 | - if (is_scalar($context) && isset($_SESSION[$context . 'Validated'])) { |
|
| 4931 | - $out = $_SESSION[$context . 'InternalKey']; |
|
| 4930 | + if (is_scalar($context) && isset($_SESSION[$context.'Validated'])) { |
|
| 4931 | + $out = $_SESSION[$context.'InternalKey']; |
|
| 4932 | 4932 | } |
| 4933 | 4933 | } else { |
| 4934 | 4934 | switch (true) { |
@@ -4956,8 +4956,8 @@ discard block |
||
| 4956 | 4956 | $out = false; |
| 4957 | 4957 | |
| 4958 | 4958 | if (!empty($context)) { |
| 4959 | - if (is_scalar($context) && isset($_SESSION[$context . 'Validated'])) { |
|
| 4960 | - $out = $_SESSION[$context . 'Shortname']; |
|
| 4959 | + if (is_scalar($context) && isset($_SESSION[$context.'Validated'])) { |
|
| 4960 | + $out = $_SESSION[$context.'Shortname']; |
|
| 4961 | 4961 | } |
| 4962 | 4962 | } else { |
| 4963 | 4963 | switch (true) { |
@@ -5028,8 +5028,8 @@ discard block |
||
| 5028 | 5028 | */ |
| 5029 | 5029 | public function getWebUserInfo($uid) |
| 5030 | 5030 | { |
| 5031 | - $rs = $this->db->select('wu.username, wu.password, wua.*', $this->getFullTableName("web_users") . " wu |
|
| 5032 | - INNER JOIN " . $this->getFullTableName("web_user_attributes") . " wua ON wua.internalkey=wu.id", "wu.id='{$uid}'"); |
|
| 5031 | + $rs = $this->db->select('wu.username, wu.password, wua.*', $this->getFullTableName("web_users")." wu |
|
| 5032 | + INNER JOIN " . $this->getFullTableName("web_user_attributes")." wua ON wua.internalkey=wu.id", "wu.id='{$uid}'"); |
|
| 5033 | 5033 | if ($row = $this->db->getRow($rs)) { |
| 5034 | 5034 | if (!isset($row['usertype']) or !$row["usertype"]) { |
| 5035 | 5035 | $row["usertype"] = "web"; |
@@ -5065,7 +5065,7 @@ discard block |
||
| 5065 | 5065 | } else if (is_array($dg)) { |
| 5066 | 5066 | // resolve ids to names |
| 5067 | 5067 | $dgn = array(); |
| 5068 | - $ds = $this->db->select('name', $this->getFullTableName("documentgroup_names"), "id IN (" . implode(",", $dg) . ")"); |
|
| 5068 | + $ds = $this->db->select('name', $this->getFullTableName("documentgroup_names"), "id IN (".implode(",", $dg).")"); |
|
| 5069 | 5069 | while ($row = $this->db->getRow($ds)) { |
| 5070 | 5070 | $dgn[] = $row['name']; |
| 5071 | 5071 | } |
@@ -5093,7 +5093,7 @@ discard block |
||
| 5093 | 5093 | $rt = false; |
| 5094 | 5094 | if ($_SESSION["webValidated"] == 1) { |
| 5095 | 5095 | $tbl = $this->getFullTableName("web_users"); |
| 5096 | - $ds = $this->db->select('id, username, password', $tbl, "id='" . $this->getLoginUserID() . "'"); |
|
| 5096 | + $ds = $this->db->select('id, username, password', $tbl, "id='".$this->getLoginUserID()."'"); |
|
| 5097 | 5097 | if ($row = $this->db->getRow($ds)) { |
| 5098 | 5098 | if ($row["password"] == md5($oldPwd)) { |
| 5099 | 5099 | if (strlen($newPwd) < 6) { |
@@ -5103,7 +5103,7 @@ discard block |
||
| 5103 | 5103 | } else { |
| 5104 | 5104 | $this->db->update(array( |
| 5105 | 5105 | 'password' => $this->db->escape($newPwd), |
| 5106 | - ), $tbl, "id='" . $this->getLoginUserID() . "'"); |
|
| 5106 | + ), $tbl, "id='".$this->getLoginUserID()."'"); |
|
| 5107 | 5107 | // invoke OnWebChangePassword event |
| 5108 | 5108 | $this->invokeEvent("OnWebChangePassword", array( |
| 5109 | 5109 | "userid" => $row["id"], |
@@ -5134,8 +5134,8 @@ discard block |
||
| 5134 | 5134 | // check cache |
| 5135 | 5135 | $grpNames = isset ($_SESSION['webUserGroupNames']) ? $_SESSION['webUserGroupNames'] : false; |
| 5136 | 5136 | if (!is_array($grpNames)) { |
| 5137 | - $rs = $this->db->select('wgn.name', $this->getFullTableName("webgroup_names") . " wgn |
|
| 5138 | - INNER JOIN " . $this->getFullTableName("web_groups") . " wg ON wg.webgroup=wgn.id AND wg.webuser='" . $this->getLoginUserID() . "'"); |
|
| 5137 | + $rs = $this->db->select('wgn.name', $this->getFullTableName("webgroup_names")." wgn |
|
| 5138 | + INNER JOIN " . $this->getFullTableName("web_groups")." wg ON wg.webgroup=wgn.id AND wg.webuser='".$this->getLoginUserID()."'"); |
|
| 5139 | 5139 | $grpNames = $this->db->getColumn("name", $rs); |
| 5140 | 5140 | // save to cache |
| 5141 | 5141 | $_SESSION['webUserGroupNames'] = $grpNames; |
@@ -5168,7 +5168,7 @@ discard block |
||
| 5168 | 5168 | if (strpos(strtolower($src), "<style") !== false || strpos(strtolower($src), "<link") !== false) { |
| 5169 | 5169 | $this->sjscripts[$nextpos] = $src; |
| 5170 | 5170 | } else { |
| 5171 | - $this->sjscripts[$nextpos] = "\t" . '<link rel="stylesheet" type="text/css" href="' . $src . '" ' . ($media ? 'media="' . $media . '" ' : '') . '/>'; |
|
| 5171 | + $this->sjscripts[$nextpos] = "\t".'<link rel="stylesheet" type="text/css" href="'.$src.'" '.($media ? 'media="'.$media.'" ' : '').'/>'; |
|
| 5172 | 5172 | } |
| 5173 | 5173 | } |
| 5174 | 5174 | |
@@ -5247,7 +5247,7 @@ discard block |
||
| 5247 | 5247 | } |
| 5248 | 5248 | |
| 5249 | 5249 | if ($useThisVer && $plaintext != true && (strpos(strtolower($src), "<script") === false)) { |
| 5250 | - $src = "\t" . '<script type="text/javascript" src="' . $src . '"></script>'; |
|
| 5250 | + $src = "\t".'<script type="text/javascript" src="'.$src.'"></script>'; |
|
| 5251 | 5251 | } |
| 5252 | 5252 | if ($startup) { |
| 5253 | 5253 | $pos = isset($overwritepos) ? $overwritepos : max(array_merge(array(0), array_keys($this->sjscripts))) + 1; |
@@ -5393,7 +5393,7 @@ discard block |
||
| 5393 | 5393 | $eventtime = $this->getMicroTime() - $eventtime; |
| 5394 | 5394 | $this->pluginsCode .= sprintf('<fieldset><legend><b>%s / %s</b> (%2.2f ms)</legend>', $evtName, $pluginName, $eventtime * 1000); |
| 5395 | 5395 | foreach ($parameter as $k => $v) { |
| 5396 | - $this->pluginsCode .= "{$k} => " . print_r($v, true) . '<br>'; |
|
| 5396 | + $this->pluginsCode .= "{$k} => ".print_r($v, true).'<br>'; |
|
| 5397 | 5397 | } |
| 5398 | 5398 | $this->pluginsCode .= '</fieldset><br />'; |
| 5399 | 5399 | $this->pluginsTime["{$evtName} / {$pluginName}"] += $eventtime; |
@@ -5421,13 +5421,13 @@ discard block |
||
| 5421 | 5421 | $plugin = array(); |
| 5422 | 5422 | if (isset ($this->pluginCache[$pluginName])) { |
| 5423 | 5423 | $pluginCode = $this->pluginCache[$pluginName]; |
| 5424 | - $pluginProperties = isset($this->pluginCache[$pluginName . "Props"]) ? $this->pluginCache[$pluginName . "Props"] : ''; |
|
| 5424 | + $pluginProperties = isset($this->pluginCache[$pluginName."Props"]) ? $this->pluginCache[$pluginName."Props"] : ''; |
|
| 5425 | 5425 | } else { |
| 5426 | 5426 | $pluginName = $this->db->escape($pluginName); |
| 5427 | 5427 | $result = $this->db->select('name, plugincode, properties', $this->getFullTableName("site_plugins"), "name='{$pluginName}' AND disabled=0"); |
| 5428 | 5428 | if ($row = $this->db->getRow($result)) { |
| 5429 | 5429 | $pluginCode = $this->pluginCache[$row['name']] = $row['plugincode']; |
| 5430 | - $pluginProperties = $this->pluginCache[$row['name'] . "Props"] = $row['properties']; |
|
| 5430 | + $pluginProperties = $this->pluginCache[$row['name']."Props"] = $row['properties']; |
|
| 5431 | 5431 | } else { |
| 5432 | 5432 | $pluginCode = $this->pluginCache[$pluginName] = "return false;"; |
| 5433 | 5433 | $pluginProperties = ''; |
@@ -5534,7 +5534,7 @@ discard block |
||
| 5534 | 5534 | public function parseDocBlockFromFile($element_dir, $filename, $escapeValues = false) |
| 5535 | 5535 | { |
| 5536 | 5536 | $params = array(); |
| 5537 | - $fullpath = $element_dir . '/' . $filename; |
|
| 5537 | + $fullpath = $element_dir.'/'.$filename; |
|
| 5538 | 5538 | if (is_readable($fullpath)) { |
| 5539 | 5539 | $tpl = @fopen($fullpath, "r"); |
| 5540 | 5540 | if ($tpl) { |
@@ -5701,8 +5701,8 @@ discard block |
||
| 5701 | 5701 | $ph = array('site_url' => MODX_SITE_URL); |
| 5702 | 5702 | $regexUrl = "/((http|https|ftp|ftps)\:\/\/[^\/]+(\/[^\s]+[^,.?!:;\s])?)/"; |
| 5703 | 5703 | $regexEmail = '#([0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-wyz][a-z](fo|g|l|m|mes|o|op|pa|ro|seum|t|u|v|z)?)#i'; |
| 5704 | - $emailSubject = isset($parsed['name']) ? '?subject=' . $parsed['name'] : ''; |
|
| 5705 | - $emailSubject .= isset($parsed['version']) ? ' v' . $parsed['version'] : ''; |
|
| 5704 | + $emailSubject = isset($parsed['name']) ? '?subject='.$parsed['name'] : ''; |
|
| 5705 | + $emailSubject .= isset($parsed['version']) ? ' v'.$parsed['version'] : ''; |
|
| 5706 | 5706 | foreach ($parsed as $key => $val) { |
| 5707 | 5707 | if (is_array($val)) { |
| 5708 | 5708 | foreach ($val as $key2 => $val2) { |
@@ -5711,7 +5711,7 @@ discard block |
||
| 5711 | 5711 | $val2 = preg_replace($regexUrl, "<a href=\"{$url[0]}\" target=\"_blank\">{$url[0]}</a> ", $val2); |
| 5712 | 5712 | } |
| 5713 | 5713 | if (preg_match($regexEmail, $val2, $url)) { |
| 5714 | - $val2 = preg_replace($regexEmail, '<a href="mailto:\\1' . $emailSubject . '">\\1</a>', $val2); |
|
| 5714 | + $val2 = preg_replace($regexEmail, '<a href="mailto:\\1'.$emailSubject.'">\\1</a>', $val2); |
|
| 5715 | 5715 | } |
| 5716 | 5716 | $parsed[$key][$key2] = $val2; |
| 5717 | 5717 | } |
@@ -5721,7 +5721,7 @@ discard block |
||
| 5721 | 5721 | $val = preg_replace($regexUrl, "<a href=\"{$url[0]}\" target=\"_blank\">{$url[0]}</a> ", $val); |
| 5722 | 5722 | } |
| 5723 | 5723 | if (preg_match($regexEmail, $val, $url)) { |
| 5724 | - $val = preg_replace($regexEmail, '<a href="mailto:\\1' . $emailSubject . '">\\1</a>', $val); |
|
| 5724 | + $val = preg_replace($regexEmail, '<a href="mailto:\\1'.$emailSubject.'">\\1</a>', $val); |
|
| 5725 | 5725 | } |
| 5726 | 5726 | $parsed[$key] = $val; |
| 5727 | 5727 | } |
@@ -5735,32 +5735,32 @@ discard block |
||
| 5735 | 5735 | ); |
| 5736 | 5736 | |
| 5737 | 5737 | $nl = "\n"; |
| 5738 | - $list = isset($parsed['logo']) ? '<img src="' . $this->config['base_url'] . ltrim($parsed['logo'], "/") . '" style="float:right;max-width:100px;height:auto;" />' . $nl : ''; |
|
| 5739 | - $list .= '<p>' . $nl; |
|
| 5740 | - $list .= isset($parsed['name']) ? '<strong>' . $parsed['name'] . '</strong><br/>' . $nl : ''; |
|
| 5741 | - $list .= isset($parsed['description']) ? $parsed['description'] . $nl : ''; |
|
| 5742 | - $list .= '</p><br/>' . $nl; |
|
| 5743 | - $list .= isset($parsed['version']) ? '<p><strong>' . $_lang['version'] . ':</strong> ' . $parsed['version'] . '</p>' . $nl : ''; |
|
| 5744 | - $list .= isset($parsed['license']) ? '<p><strong>' . $_lang['license'] . ':</strong> ' . $parsed['license'] . '</p>' . $nl : ''; |
|
| 5745 | - $list .= isset($parsed['lastupdate']) ? '<p><strong>' . $_lang['last_update'] . ':</strong> ' . $parsed['lastupdate'] . '</p>' . $nl : ''; |
|
| 5746 | - $list .= '<br/>' . $nl; |
|
| 5738 | + $list = isset($parsed['logo']) ? '<img src="'.$this->config['base_url'].ltrim($parsed['logo'], "/").'" style="float:right;max-width:100px;height:auto;" />'.$nl : ''; |
|
| 5739 | + $list .= '<p>'.$nl; |
|
| 5740 | + $list .= isset($parsed['name']) ? '<strong>'.$parsed['name'].'</strong><br/>'.$nl : ''; |
|
| 5741 | + $list .= isset($parsed['description']) ? $parsed['description'].$nl : ''; |
|
| 5742 | + $list .= '</p><br/>'.$nl; |
|
| 5743 | + $list .= isset($parsed['version']) ? '<p><strong>'.$_lang['version'].':</strong> '.$parsed['version'].'</p>'.$nl : ''; |
|
| 5744 | + $list .= isset($parsed['license']) ? '<p><strong>'.$_lang['license'].':</strong> '.$parsed['license'].'</p>'.$nl : ''; |
|
| 5745 | + $list .= isset($parsed['lastupdate']) ? '<p><strong>'.$_lang['last_update'].':</strong> '.$parsed['lastupdate'].'</p>'.$nl : ''; |
|
| 5746 | + $list .= '<br/>'.$nl; |
|
| 5747 | 5747 | $first = true; |
| 5748 | 5748 | foreach ($arrayParams as $param => $label) { |
| 5749 | 5749 | if (isset($parsed[$param])) { |
| 5750 | 5750 | if ($first) { |
| 5751 | - $list .= '<p><strong>' . $_lang['references'] . '</strong></p>' . $nl; |
|
| 5752 | - $list .= '<ul class="docBlockList">' . $nl; |
|
| 5751 | + $list .= '<p><strong>'.$_lang['references'].'</strong></p>'.$nl; |
|
| 5752 | + $list .= '<ul class="docBlockList">'.$nl; |
|
| 5753 | 5753 | $first = false; |
| 5754 | 5754 | } |
| 5755 | - $list .= ' <li><strong>' . $label . '</strong>' . $nl; |
|
| 5756 | - $list .= ' <ul>' . $nl; |
|
| 5755 | + $list .= ' <li><strong>'.$label.'</strong>'.$nl; |
|
| 5756 | + $list .= ' <ul>'.$nl; |
|
| 5757 | 5757 | foreach ($parsed[$param] as $val) { |
| 5758 | - $list .= ' <li>' . $val . '</li>' . $nl; |
|
| 5758 | + $list .= ' <li>'.$val.'</li>'.$nl; |
|
| 5759 | 5759 | } |
| 5760 | - $list .= ' </ul></li>' . $nl; |
|
| 5760 | + $list .= ' </ul></li>'.$nl; |
|
| 5761 | 5761 | } |
| 5762 | 5762 | } |
| 5763 | - $list .= !$first ? '</ul>' . $nl : ''; |
|
| 5763 | + $list .= !$first ? '</ul>'.$nl : ''; |
|
| 5764 | 5764 | |
| 5765 | 5765 | return $list; |
| 5766 | 5766 | } |
@@ -5836,7 +5836,7 @@ discard block |
||
| 5836 | 5836 | */ |
| 5837 | 5837 | public function addSnippet($name, $phpCode) |
| 5838 | 5838 | { |
| 5839 | - $this->snippetCache['#' . $name] = $phpCode; |
|
| 5839 | + $this->snippetCache['#'.$name] = $phpCode; |
|
| 5840 | 5840 | } |
| 5841 | 5841 | |
| 5842 | 5842 | /** |
@@ -5845,7 +5845,7 @@ discard block |
||
| 5845 | 5845 | */ |
| 5846 | 5846 | public function addChunk($name, $text) |
| 5847 | 5847 | { |
| 5848 | - $this->chunkCache['#' . $name] = $text; |
|
| 5848 | + $this->chunkCache['#'.$name] = $text; |
|
| 5849 | 5849 | } |
| 5850 | 5850 | |
| 5851 | 5851 | /** |
@@ -5881,7 +5881,7 @@ discard block |
||
| 5881 | 5881 | } |
| 5882 | 5882 | |
| 5883 | 5883 | if (!$isSafe) { |
| 5884 | - $msg = $phpcode . "\n" . $this->currentSnippet . "\n" . print_r($_SERVER, true); |
|
| 5884 | + $msg = $phpcode."\n".$this->currentSnippet."\n".print_r($_SERVER, true); |
|
| 5885 | 5885 | $title = sprintf('Unknown eval was executed (%s)', $this->htmlspecialchars(substr(trim($phpcode), 0, 50))); |
| 5886 | 5886 | $this->messageQuit($title, '', true, '', '', 'Parser', $msg); |
| 5887 | 5887 | return; |
@@ -5895,7 +5895,7 @@ discard block |
||
| 5895 | 5895 | return 'array()'; |
| 5896 | 5896 | } |
| 5897 | 5897 | |
| 5898 | - $output = $echo . $return; |
|
| 5898 | + $output = $echo.$return; |
|
| 5899 | 5899 | modx_sanitize_gpc($output); |
| 5900 | 5900 | return $this->htmlspecialchars($output); // Maybe, all html tags are dangerous |
| 5901 | 5901 | } |
@@ -5913,8 +5913,8 @@ discard block |
||
| 5913 | 5913 | |
| 5914 | 5914 | $safe = explode(',', $safe_functions); |
| 5915 | 5915 | |
| 5916 | - $phpcode = rtrim($phpcode, ';') . ';'; |
|
| 5917 | - $tokens = token_get_all('<?php ' . $phpcode); |
|
| 5916 | + $phpcode = rtrim($phpcode, ';').';'; |
|
| 5917 | + $tokens = token_get_all('<?php '.$phpcode); |
|
| 5918 | 5918 | foreach ($tokens as $i => $token) { |
| 5919 | 5919 | if (!is_array($token)) { |
| 5920 | 5920 | continue; |
@@ -5950,7 +5950,7 @@ discard block |
||
| 5950 | 5950 | public function atBindFileContent($str = '') |
| 5951 | 5951 | { |
| 5952 | 5952 | |
| 5953 | - $search_path = array('assets/tvs/', 'assets/chunks/', 'assets/templates/', $this->config['rb_base_url'] . 'files/', ''); |
|
| 5953 | + $search_path = array('assets/tvs/', 'assets/chunks/', 'assets/templates/', $this->config['rb_base_url'].'files/', ''); |
|
| 5954 | 5954 | |
| 5955 | 5955 | if (stripos($str, '@FILE') !== 0) { |
| 5956 | 5956 | return $str; |
@@ -5973,7 +5973,7 @@ discard block |
||
| 5973 | 5973 | $errorMsg = sprintf("Could not retrieve string '%s'.", $str); |
| 5974 | 5974 | |
| 5975 | 5975 | foreach ($search_path as $path) { |
| 5976 | - $file_path = MODX_BASE_PATH . $path . $str; |
|
| 5976 | + $file_path = MODX_BASE_PATH.$path.$str; |
|
| 5977 | 5977 | if (strpos($file_path, MODX_MANAGER_PATH) === 0) { |
| 5978 | 5978 | return $errorMsg; |
| 5979 | 5979 | } elseif (is_file($file_path)) { |
@@ -5987,7 +5987,7 @@ discard block |
||
| 5987 | 5987 | return $errorMsg; |
| 5988 | 5988 | } |
| 5989 | 5989 | |
| 5990 | - $content = (string)file_get_contents($file_path); |
|
| 5990 | + $content = (string) file_get_contents($file_path); |
|
| 5991 | 5991 | if ($content === false) { |
| 5992 | 5992 | return $errorMsg; |
| 5993 | 5993 | } |
@@ -6100,22 +6100,22 @@ discard block |
||
| 6100 | 6100 | |
| 6101 | 6101 | $version = isset ($GLOBALS['modx_version']) ? $GLOBALS['modx_version'] : ''; |
| 6102 | 6102 | $release_date = isset ($GLOBALS['release_date']) ? $GLOBALS['release_date'] : ''; |
| 6103 | - $request_uri = "http://" . $_SERVER['HTTP_HOST'] . ($_SERVER["SERVER_PORT"] == 80 ? "" : (":" . $_SERVER["SERVER_PORT"])) . $_SERVER['REQUEST_URI']; |
|
| 6103 | + $request_uri = "http://".$_SERVER['HTTP_HOST'].($_SERVER["SERVER_PORT"] == 80 ? "" : (":".$_SERVER["SERVER_PORT"])).$_SERVER['REQUEST_URI']; |
|
| 6104 | 6104 | $request_uri = $this->htmlspecialchars($request_uri, ENT_QUOTES, $this->config['modx_charset']); |
| 6105 | 6105 | $ua = $this->htmlspecialchars($_SERVER['HTTP_USER_AGENT'], ENT_QUOTES, $this->config['modx_charset']); |
| 6106 | 6106 | $referer = $this->htmlspecialchars($_SERVER['HTTP_REFERER'], ENT_QUOTES, $this->config['modx_charset']); |
| 6107 | 6107 | if ($is_error) { |
| 6108 | 6108 | $str = '<h2 style="color:red">« Evo Parse Error »</h2>'; |
| 6109 | 6109 | if ($msg != 'PHP Parse Error') { |
| 6110 | - $str .= '<h3 style="color:red">' . $msg . '</h3>'; |
|
| 6110 | + $str .= '<h3 style="color:red">'.$msg.'</h3>'; |
|
| 6111 | 6111 | } |
| 6112 | 6112 | } else { |
| 6113 | 6113 | $str = '<h2 style="color:#003399">« Evo Debug/ stop message »</h2>'; |
| 6114 | - $str .= '<h3 style="color:#003399">' . $msg . '</h3>'; |
|
| 6114 | + $str .= '<h3 style="color:#003399">'.$msg.'</h3>'; |
|
| 6115 | 6115 | } |
| 6116 | 6116 | |
| 6117 | 6117 | if (!empty ($query)) { |
| 6118 | - $str .= '<div style="font-weight:bold;border:1px solid #ccc;padding:8px;color:#333;background-color:#ffffcd;margin-bottom:15px;">SQL > <span id="sqlHolder">' . $query . '</span></div>'; |
|
| 6118 | + $str .= '<div style="font-weight:bold;border:1px solid #ccc;padding:8px;color:#333;background-color:#ffffcd;margin-bottom:15px;">SQL > <span id="sqlHolder">'.$query.'</span></div>'; |
|
| 6119 | 6119 | } |
| 6120 | 6120 | |
| 6121 | 6121 | $errortype = array( |
@@ -6138,13 +6138,13 @@ discard block |
||
| 6138 | 6138 | |
| 6139 | 6139 | if (!empty($nr) || !empty($file)) { |
| 6140 | 6140 | if ($text != '') { |
| 6141 | - $str .= '<div style="font-weight:bold;border:1px solid #ccc;padding:8px;color:#333;background-color:#ffffcd;margin-bottom:15px;">Error : ' . $text . '</div>'; |
|
| 6141 | + $str .= '<div style="font-weight:bold;border:1px solid #ccc;padding:8px;color:#333;background-color:#ffffcd;margin-bottom:15px;">Error : '.$text.'</div>'; |
|
| 6142 | 6142 | } |
| 6143 | 6143 | if ($output != '') { |
| 6144 | - $str .= '<div style="font-weight:bold;border:1px solid #ccc;padding:8px;color:#333;background-color:#ffffcd;margin-bottom:15px;">' . $output . '</div>'; |
|
| 6144 | + $str .= '<div style="font-weight:bold;border:1px solid #ccc;padding:8px;color:#333;background-color:#ffffcd;margin-bottom:15px;">'.$output.'</div>'; |
|
| 6145 | 6145 | } |
| 6146 | 6146 | if ($nr !== '') { |
| 6147 | - $table[] = array('ErrorType[num]', $errortype [$nr] . "[" . $nr . "]"); |
|
| 6147 | + $table[] = array('ErrorType[num]', $errortype [$nr]."[".$nr."]"); |
|
| 6148 | 6148 | } |
| 6149 | 6149 | if ($file) { |
| 6150 | 6150 | $table[] = array('File', $file); |
@@ -6164,7 +6164,7 @@ discard block |
||
| 6164 | 6164 | } |
| 6165 | 6165 | |
| 6166 | 6166 | if (!empty($this->event->activePlugin)) { |
| 6167 | - $table[] = array('Current Plugin', $this->event->activePlugin . '(' . $this->event->name . ')'); |
|
| 6167 | + $table[] = array('Current Plugin', $this->event->activePlugin.'('.$this->event->name.')'); |
|
| 6168 | 6168 | } |
| 6169 | 6169 | |
| 6170 | 6170 | $str .= $MakeTable->create($table, array('Error information', '')); |
@@ -6174,17 +6174,17 @@ discard block |
||
| 6174 | 6174 | $table[] = array('REQUEST_URI', $request_uri); |
| 6175 | 6175 | |
| 6176 | 6176 | if ($this->manager->action) { |
| 6177 | - include_once(MODX_MANAGER_PATH . 'includes/actionlist.inc.php'); |
|
| 6177 | + include_once(MODX_MANAGER_PATH.'includes/actionlist.inc.php'); |
|
| 6178 | 6178 | global $action_list; |
| 6179 | 6179 | $actionName = (isset($action_list[$this->manager->action])) ? " - {$action_list[$this->manager->action]}" : ''; |
| 6180 | 6180 | |
| 6181 | - $table[] = array('Manager action', $this->manager->action . $actionName); |
|
| 6181 | + $table[] = array('Manager action', $this->manager->action.$actionName); |
|
| 6182 | 6182 | } |
| 6183 | 6183 | |
| 6184 | 6184 | if (preg_match('@^[0-9]+@', $this->documentIdentifier)) { |
| 6185 | 6185 | $resource = $this->getDocumentObject('id', $this->documentIdentifier); |
| 6186 | 6186 | $url = $this->makeUrl($this->documentIdentifier, '', '', 'full'); |
| 6187 | - $table[] = array('Resource', '[' . $this->documentIdentifier . '] <a href="' . $url . '" target="_blank">' . $resource['pagetitle'] . '</a>'); |
|
| 6187 | + $table[] = array('Resource', '['.$this->documentIdentifier.'] <a href="'.$url.'" target="_blank">'.$resource['pagetitle'].'</a>'); |
|
| 6188 | 6188 | } |
| 6189 | 6189 | $table[] = array('Referer', $referer); |
| 6190 | 6190 | $table[] = array('User Agent', $ua); |
@@ -6205,7 +6205,7 @@ discard block |
||
| 6205 | 6205 | |
| 6206 | 6206 | $mem = memory_get_peak_usage(true); |
| 6207 | 6207 | $total_mem = $mem - $this->mstart; |
| 6208 | - $total_mem = ($total_mem / 1024 / 1024) . ' mb'; |
|
| 6208 | + $total_mem = ($total_mem / 1024 / 1024).' mb'; |
|
| 6209 | 6209 | |
| 6210 | 6210 | $queryTime = $this->queryTime; |
| 6211 | 6211 | $phpTime = $totalTime - $queryTime; |
@@ -6226,18 +6226,18 @@ discard block |
||
| 6226 | 6226 | $str .= $this->get_backtrace(debug_backtrace()); |
| 6227 | 6227 | // Log error |
| 6228 | 6228 | if (!empty($this->currentSnippet)) { |
| 6229 | - $source = 'Snippet - ' . $this->currentSnippet; |
|
| 6229 | + $source = 'Snippet - '.$this->currentSnippet; |
|
| 6230 | 6230 | } elseif (!empty($this->event->activePlugin)) { |
| 6231 | - $source = 'Plugin - ' . $this->event->activePlugin; |
|
| 6231 | + $source = 'Plugin - '.$this->event->activePlugin; |
|
| 6232 | 6232 | } elseif ($source !== '') { |
| 6233 | - $source = 'Parser - ' . $source; |
|
| 6233 | + $source = 'Parser - '.$source; |
|
| 6234 | 6234 | } elseif ($query !== '') { |
| 6235 | 6235 | $source = 'SQL Query'; |
| 6236 | 6236 | } else { |
| 6237 | 6237 | $source = 'Parser'; |
| 6238 | 6238 | } |
| 6239 | 6239 | if ($msg) { |
| 6240 | - $source .= ' / ' . $msg; |
|
| 6240 | + $source .= ' / '.$msg; |
|
| 6241 | 6241 | } |
| 6242 | 6242 | if (isset($actionName) && !empty($actionName)) { |
| 6243 | 6243 | $source .= $actionName; |
@@ -6269,12 +6269,12 @@ discard block |
||
| 6269 | 6269 | |
| 6270 | 6270 | // Display error |
| 6271 | 6271 | if (isset($_SESSION['mgrValidated'])) { |
| 6272 | - echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html><head><title>EVO Content Manager ' . $version . ' » ' . $release_date . '</title> |
|
| 6272 | + echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html><head><title>EVO Content Manager '.$version.' » '.$release_date.'</title> |
|
| 6273 | 6273 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
| 6274 | - <link rel="stylesheet" type="text/css" href="' . $this->config['site_manager_url'] . 'media/style/' . $this->config['manager_theme'] . '/style.css" /> |
|
| 6274 | + <link rel="stylesheet" type="text/css" href="' . $this->config['site_manager_url'].'media/style/'.$this->config['manager_theme'].'/style.css" /> |
|
| 6275 | 6275 | <style type="text/css">body { padding:10px; } td {font:inherit;}</style> |
| 6276 | 6276 | </head><body> |
| 6277 | - ' . $str . '</body></html>'; |
|
| 6277 | + ' . $str.'</body></html>'; |
|
| 6278 | 6278 | |
| 6279 | 6279 | } else { |
| 6280 | 6280 | echo 'Error'; |
@@ -6312,7 +6312,7 @@ discard block |
||
| 6312 | 6312 | switch ($val['type']) { |
| 6313 | 6313 | case '->': |
| 6314 | 6314 | case '::': |
| 6315 | - $functionName = $val['function'] = $val['class'] . $val['type'] . $val['function']; |
|
| 6315 | + $functionName = $val['function'] = $val['class'].$val['type'].$val['function']; |
|
| 6316 | 6316 | break; |
| 6317 | 6317 | default: |
| 6318 | 6318 | $functionName = $val['function']; |
@@ -6322,7 +6322,7 @@ discard block |
||
| 6322 | 6322 | $args = array_pad(array(), $_, '$var'); |
| 6323 | 6323 | $args = implode(", ", $args); |
| 6324 | 6324 | $modx = &$this; |
| 6325 | - $args = preg_replace_callback('/\$var/', function () use ($modx, &$tmp, $val) { |
|
| 6325 | + $args = preg_replace_callback('/\$var/', function() use ($modx, &$tmp, $val) { |
|
| 6326 | 6326 | $arg = $val['args'][$tmp - 1]; |
| 6327 | 6327 | switch (true) { |
| 6328 | 6328 | case is_null($arg): { |
@@ -6334,7 +6334,7 @@ discard block |
||
| 6334 | 6334 | break; |
| 6335 | 6335 | } |
| 6336 | 6336 | case is_scalar($arg): { |
| 6337 | - $out = strlen($arg) > 20 ? 'string $var' . $tmp : ("'" . $this->htmlspecialchars(str_replace("'", "\\'", $arg)) . "'"); |
|
| 6337 | + $out = strlen($arg) > 20 ? 'string $var'.$tmp : ("'".$this->htmlspecialchars(str_replace("'", "\\'", $arg))."'"); |
|
| 6338 | 6338 | break; |
| 6339 | 6339 | } |
| 6340 | 6340 | case is_bool($arg): { |
@@ -6342,23 +6342,23 @@ discard block |
||
| 6342 | 6342 | break; |
| 6343 | 6343 | } |
| 6344 | 6344 | case is_array($arg): { |
| 6345 | - $out = 'array $var' . $tmp; |
|
| 6345 | + $out = 'array $var'.$tmp; |
|
| 6346 | 6346 | break; |
| 6347 | 6347 | } |
| 6348 | 6348 | case is_object($arg): { |
| 6349 | - $out = get_class($arg) . ' $var' . $tmp; |
|
| 6349 | + $out = get_class($arg).' $var'.$tmp; |
|
| 6350 | 6350 | break; |
| 6351 | 6351 | } |
| 6352 | 6352 | default: { |
| 6353 | - $out = '$var' . $tmp; |
|
| 6353 | + $out = '$var'.$tmp; |
|
| 6354 | 6354 | } |
| 6355 | 6355 | } |
| 6356 | 6356 | $tmp++; |
| 6357 | 6357 | return $out; |
| 6358 | 6358 | }, $args); |
| 6359 | 6359 | $line = array( |
| 6360 | - "<strong>" . $functionName . "</strong>(" . $args . ")", |
|
| 6361 | - $path . " on line " . $val['line'] |
|
| 6360 | + "<strong>".$functionName."</strong>(".$args.")", |
|
| 6361 | + $path." on line ".$val['line'] |
|
| 6362 | 6362 | ); |
| 6363 | 6363 | $table[] = array(implode("<br />", $line)); |
| 6364 | 6364 | } |
@@ -6399,7 +6399,7 @@ discard block |
||
| 6399 | 6399 | $alias = strip_tags($alias); // strip HTML |
| 6400 | 6400 | $alias = preg_replace('/[^\.A-Za-z0-9 _-]/', '', $alias); // strip non-alphanumeric characters |
| 6401 | 6401 | $alias = preg_replace('/\s+/', '-', $alias); // convert white-space to dash |
| 6402 | - $alias = preg_replace('/-+/', '-', $alias); // convert multiple dashes to one |
|
| 6402 | + $alias = preg_replace('/-+/', '-', $alias); // convert multiple dashes to one |
|
| 6403 | 6403 | $alias = trim($alias, '-'); // trim excess |
| 6404 | 6404 | return $alias; |
| 6405 | 6405 | } |
@@ -6415,7 +6415,7 @@ discard block |
||
| 6415 | 6415 | $precisions = count($sizes) - 1; |
| 6416 | 6416 | foreach ($sizes as $unit => $bytes) { |
| 6417 | 6417 | if ($size >= $bytes) { |
| 6418 | - return number_format($size / $bytes, $precisions) . ' ' . $unit; |
|
| 6418 | + return number_format($size / $bytes, $precisions).' '.$unit; |
|
| 6419 | 6419 | } |
| 6420 | 6420 | $precisions--; |
| 6421 | 6421 | } |
@@ -6519,10 +6519,10 @@ discard block |
||
| 6519 | 6519 | |
| 6520 | 6520 | if (strpos($str, MODX_MANAGER_PATH) === 0) { |
| 6521 | 6521 | return false; |
| 6522 | - } elseif (is_file(MODX_BASE_PATH . $str)) { |
|
| 6523 | - $file_path = MODX_BASE_PATH . $str; |
|
| 6524 | - } elseif (is_file(MODX_BASE_PATH . "{$tpl_dir}{$str}")) { |
|
| 6525 | - $file_path = MODX_BASE_PATH . $tpl_dir . $str; |
|
| 6522 | + } elseif (is_file(MODX_BASE_PATH.$str)) { |
|
| 6523 | + $file_path = MODX_BASE_PATH.$str; |
|
| 6524 | + } elseif (is_file(MODX_BASE_PATH."{$tpl_dir}{$str}")) { |
|
| 6525 | + $file_path = MODX_BASE_PATH.$tpl_dir.$str; |
|
| 6526 | 6526 | } else { |
| 6527 | 6527 | return false; |
| 6528 | 6528 | } |
@@ -6648,7 +6648,7 @@ discard block |
||
| 6648 | 6648 | $title = 'no title'; |
| 6649 | 6649 | } |
| 6650 | 6650 | if (is_array($msg)) { |
| 6651 | - $msg = '<pre>' . print_r($msg, true) . '</pre>'; |
|
| 6651 | + $msg = '<pre>'.print_r($msg, true).'</pre>'; |
|
| 6652 | 6652 | } elseif ($msg === '') { |
| 6653 | 6653 | $msg = $_SERVER['REQUEST_URI']; |
| 6654 | 6654 | } |
@@ -6693,7 +6693,7 @@ discard block |
||
| 6693 | 6693 | if (is_array($SystemAlertMsgQueque)) { |
| 6694 | 6694 | $title = ''; |
| 6695 | 6695 | if ($this->name && $this->activePlugin) { |
| 6696 | - $title = "<div><b>" . $this->activePlugin . "</b> - <span style='color:maroon;'>" . $this->name . "</span></div>"; |
|
| 6696 | + $title = "<div><b>".$this->activePlugin."</b> - <span style='color:maroon;'>".$this->name."</span></div>"; |
|
| 6697 | 6697 | } |
| 6698 | 6698 | $SystemAlertMsgQueque[] = "$title<div style='margin-left:10px;margin-top:3px;'>$msg</div>"; |
| 6699 | 6699 | } |
@@ -695,13 +695,15 @@ discard block |
||
| 695 | 695 | $this->virtualDir = ''; |
| 696 | 696 | } |
| 697 | 697 | |
| 698 | - if (preg_match('@^[1-9][0-9]*$@', $q) && !isset($this->documentListing[$q])) { /* we got an ID returned, check to make sure it's not an alias */ |
|
| 698 | + if (preg_match('@^[1-9][0-9]*$@', $q) && !isset($this->documentListing[$q])) { |
|
| 699 | +/* we got an ID returned, check to make sure it's not an alias */ |
|
| 699 | 700 | /* FS#476 and FS#308: check that id is valid in terms of virtualDir structure */ |
| 700 | 701 | if ($this->config['use_alias_path'] == 1) { |
| 701 | 702 | if (($this->virtualDir != '' && !isset($this->documentListing[$this->virtualDir . '/' . $q]) || ($this->virtualDir == '' && !isset($this->documentListing[$q]))) && (($this->virtualDir != '' && isset($this->documentListing[$this->virtualDir]) && in_array($q, $this->getChildIds($this->documentListing[$this->virtualDir], 1))) || ($this->virtualDir == '' && in_array($q, $this->getChildIds(0, 1))))) { |
| 702 | 703 | $this->documentMethod = 'id'; |
| 703 | 704 | return $q; |
| 704 | - } else { /* not a valid id in terms of virtualDir, treat as alias */ |
|
| 705 | + } else { |
|
| 706 | +/* not a valid id in terms of virtualDir, treat as alias */ |
|
| 705 | 707 | $this->documentMethod = 'alias'; |
| 706 | 708 | return $q; |
| 707 | 709 | } |
@@ -709,7 +711,8 @@ discard block |
||
| 709 | 711 | $this->documentMethod = 'id'; |
| 710 | 712 | return $q; |
| 711 | 713 | } |
| 712 | - } else { /* we didn't get an ID back, so instead we assume it's an alias */ |
|
| 714 | + } else { |
|
| 715 | +/* we didn't get an ID back, so instead we assume it's an alias */ |
|
| 713 | 716 | if ($this->config['friendly_alias_urls'] != 1) { |
| 714 | 717 | $q = $qOrig; |
| 715 | 718 | } |
@@ -739,13 +742,14 @@ discard block |
||
| 739 | 742 | * @param $id |
| 740 | 743 | * @return array|mixed|null|string |
| 741 | 744 | */ |
| 742 | - public function makePageCacheKey($id){ |
|
| 745 | + public function makePageCacheKey($id) |
|
| 746 | + { |
|
| 743 | 747 | $hash = $id; |
| 744 | 748 | $tmp = null; |
| 745 | 749 | $params = array(); |
| 746 | - if(!empty($this->systemCacheKey)){ |
|
| 750 | + if(!empty($this->systemCacheKey)) { |
|
| 747 | 751 | $hash = $this->systemCacheKey; |
| 748 | - }else { |
|
| 752 | + } else { |
|
| 749 | 753 | if (!empty($_GET)) { |
| 750 | 754 | // Sort GET parameters so that the order of parameters on the HTTP request don't affect the generated cache ID. |
| 751 | 755 | $params = $_GET; |
@@ -754,7 +758,7 @@ discard block |
||
| 754 | 758 | } |
| 755 | 759 | } |
| 756 | 760 | $evtOut = $this->invokeEvent("OnMakePageCacheKey", array ("hash" => $hash, "id" => $id, 'params' => $params)); |
| 757 | - if (is_array($evtOut) && count($evtOut) > 0){ |
|
| 761 | + if (is_array($evtOut) && count($evtOut) > 0) { |
|
| 758 | 762 | $tmp = array_pop($evtOut); |
| 759 | 763 | } |
| 760 | 764 | return empty($tmp) ? $hash : $tmp; |
@@ -1165,10 +1169,18 @@ discard block |
||
| 1165 | 1169 | return array(); |
| 1166 | 1170 | } |
| 1167 | 1171 | $spacer = md5('<<<EVO>>>'); |
| 1168 | - if($left==='{{' && strpos($content,';}}')!==false) $content = str_replace(';}}', sprintf(';}%s}', $spacer),$content); |
|
| 1169 | - if($left==='{{' && strpos($content,'{{}}')!==false) $content = str_replace('{{}}',sprintf('{%$1s{}%$1s}',$spacer),$content); |
|
| 1170 | - if($left==='[[' && strpos($content,']]]]')!==false) $content = str_replace(']]]]',sprintf(']]%s]]', $spacer),$content); |
|
| 1171 | - if($left==='[[' && strpos($content,']]]')!==false) $content = str_replace(']]]', sprintf(']%s]]', $spacer),$content); |
|
| 1172 | + if($left==='{{' && strpos($content,';}}')!==false) { |
|
| 1173 | + $content = str_replace(';}}', sprintf(';}%s}', $spacer),$content); |
|
| 1174 | + } |
|
| 1175 | + if($left==='{{' && strpos($content,'{{}}')!==false) { |
|
| 1176 | + $content = str_replace('{{}}',sprintf('{%$1s{}%$1s}',$spacer),$content); |
|
| 1177 | + } |
|
| 1178 | + if($left==='[[' && strpos($content,']]]]')!==false) { |
|
| 1179 | + $content = str_replace(']]]]',sprintf(']]%s]]', $spacer),$content); |
|
| 1180 | + } |
|
| 1181 | + if($left==='[[' && strpos($content,']]]')!==false) { |
|
| 1182 | + $content = str_replace(']]]', sprintf(']%s]]', $spacer),$content); |
|
| 1183 | + } |
|
| 1172 | 1184 | |
| 1173 | 1185 | $pos['<![CDATA['] = strpos($content, '<![CDATA['); |
| 1174 | 1186 | $pos[']]>'] = strpos($content, ']]>'); |
@@ -1221,7 +1233,8 @@ discard block |
||
| 1221 | 1233 | } |
| 1222 | 1234 | } |
| 1223 | 1235 | |
| 1224 | - if (!in_array($fetch, $tags)) { // Avoid double Matches |
|
| 1236 | + if (!in_array($fetch, $tags)) { |
|
| 1237 | +// Avoid double Matches |
|
| 1225 | 1238 | $tags[] = $fetch; // Fetch |
| 1226 | 1239 | }; |
| 1227 | 1240 | $fetch = ''; // and reset |
@@ -1239,7 +1252,9 @@ discard block |
||
| 1239 | 1252 | } |
| 1240 | 1253 | } |
| 1241 | 1254 | foreach($tags as $i=>$tag) { |
| 1242 | - if(strpos($tag,$spacer)!==false) $tags[$i] = str_replace($spacer, '', $tag); |
|
| 1255 | + if(strpos($tag,$spacer)!==false) { |
|
| 1256 | + $tags[$i] = str_replace($spacer, '', $tag); |
|
| 1257 | + } |
|
| 1243 | 1258 | } |
| 1244 | 1259 | return $tags; |
| 1245 | 1260 | } |
@@ -1279,7 +1294,10 @@ discard block |
||
| 1279 | 1294 | } |
| 1280 | 1295 | |
| 1281 | 1296 | foreach ($matches[1] as $i => $key) { |
| 1282 | - if(strpos($key,'[+')!==false) continue; // Allow chunk {{chunk?¶m=`xxx`}} with [*tv_name_[+param+]*] as content |
|
| 1297 | + if(strpos($key,'[+')!==false) { |
|
| 1298 | + continue; |
|
| 1299 | + } |
|
| 1300 | + // Allow chunk {{chunk?¶m=`xxx`}} with [*tv_name_[+param+]*] as content |
|
| 1283 | 1301 | if (substr($key, 0, 1) == '#') { |
| 1284 | 1302 | $key = substr($key, 1); |
| 1285 | 1303 | } // remove # for QuickEdit format |
@@ -2004,7 +2022,8 @@ discard block |
||
| 2004 | 2022 | * @return mixed|string |
| 2005 | 2023 | */ |
| 2006 | 2024 | public function _getSGVar($value) |
| 2007 | - { // Get super globals |
|
| 2025 | + { |
|
| 2026 | +// Get super globals |
|
| 2008 | 2027 | $key = $value; |
| 2009 | 2028 | $_ = $this->config['enable_filter']; |
| 2010 | 2029 | $this->config['enable_filter'] = 1; |
@@ -2409,7 +2428,8 @@ discard block |
||
| 2409 | 2428 | if ($this->config['friendly_urls'] == 1) { |
| 2410 | 2429 | $aliases = array(); |
| 2411 | 2430 | if (is_array($this->documentListing)) { |
| 2412 | - foreach ($this->documentListing as $path => $docid) { // This is big Loop on large site! |
|
| 2431 | + foreach ($this->documentListing as $path => $docid) { |
|
| 2432 | +// This is big Loop on large site! |
|
| 2413 | 2433 | $aliases[$docid] = $path; |
| 2414 | 2434 | $isfolder[$docid] = $this->aliasListing[$docid]['isfolder']; |
| 2415 | 2435 | } |
@@ -2442,7 +2462,7 @@ discard block |
||
| 2442 | 2462 | $isfriendly = ($this->config['friendly_alias_urls'] == 1 ? 1 : 0); |
| 2443 | 2463 | $pref = $this->config['friendly_url_prefix']; |
| 2444 | 2464 | $suff = $this->config['friendly_url_suffix']; |
| 2445 | - $documentSource = preg_replace_callback($in, function ($m) use ($aliases, $isfolder, $isfriendly, $pref, $suff) { |
|
| 2465 | + $documentSource = preg_replace_callback($in, function ($m) use ($aliases, $isfolder, $isfriendly, $pref, $suff){ |
|
| 2446 | 2466 | global $modx; |
| 2447 | 2467 | $thealias = $aliases[$m[1]]; |
| 2448 | 2468 | $thefolder = $isfolder[$m[1]]; |
@@ -4214,7 +4234,8 @@ discard block |
||
| 4214 | 4234 | if (isset ($this->snippetCache[$snippetName])) { |
| 4215 | 4235 | $snippet = $this->snippetCache[$snippetName]; |
| 4216 | 4236 | $properties = !empty($this->snippetCache[$snippetName . "Props"]) ? $this->snippetCache[$snippetName . "Props"] : ''; |
| 4217 | - } else { // not in cache so let's check the db |
|
| 4237 | + } else { |
|
| 4238 | +// not in cache so let's check the db |
|
| 4218 | 4239 | $sql = "SELECT ss.`name`, ss.`snippet`, ss.`properties`, sm.properties as `sharedproperties` FROM " . $this->getFullTableName("site_snippets") . " as ss LEFT JOIN " . $this->getFullTableName('site_modules') . " as sm on sm.guid=ss.moduleguid WHERE ss.`name`='" . $this->db->escape($snippetName) . "' AND ss.disabled=0;"; |
| 4219 | 4240 | $result = $this->db->query($sql); |
| 4220 | 4241 | if ($this->db->getRecordCount($result) == 1) { |
@@ -4718,7 +4739,7 @@ discard block |
||
| 4718 | 4739 | $result = $this->db->makeArray($rs); |
| 4719 | 4740 | |
| 4720 | 4741 | // get default/built-in template variables |
| 4721 | - if(is_array($docRow)){ |
|
| 4742 | + if(is_array($docRow)) { |
|
| 4722 | 4743 | ksort($docRow); |
| 4723 | 4744 | |
| 4724 | 4745 | foreach ($docRow as $key => $value) { |
@@ -5197,12 +5218,16 @@ discard block |
||
| 5197 | 5218 | return ''; |
| 5198 | 5219 | } // nothing to register |
| 5199 | 5220 | if (!is_array($options)) { |
| 5200 | - if (is_bool($options)) // backward compatibility with old plaintext parameter |
|
| 5221 | + if (is_bool($options)) { |
|
| 5222 | + // backward compatibility with old plaintext parameter |
|
| 5201 | 5223 | { |
| 5202 | 5224 | $options = array('plaintext' => $options); |
| 5203 | - } elseif (is_string($options)) // Also allow script name as 2nd param |
|
| 5225 | + } |
|
| 5226 | + } elseif (is_string($options)) { |
|
| 5227 | + // Also allow script name as 2nd param |
|
| 5204 | 5228 | { |
| 5205 | 5229 | $options = array('name' => $options); |
| 5230 | + } |
|
| 5206 | 5231 | } else { |
| 5207 | 5232 | $options = array(); |
| 5208 | 5233 | } |
@@ -5214,7 +5239,8 @@ discard block |
||
| 5214 | 5239 | unset($overwritepos); // probably unnecessary--just making sure |
| 5215 | 5240 | |
| 5216 | 5241 | $useThisVer = true; |
| 5217 | - if (isset($this->loadedjscripts[$key])) { // a matching script was found |
|
| 5242 | + if (isset($this->loadedjscripts[$key])) { |
|
| 5243 | +// a matching script was found |
|
| 5218 | 5244 | // if existing script is a startup script, make sure the candidate is also a startup script |
| 5219 | 5245 | if ($this->loadedjscripts[$key]['startup']) { |
| 5220 | 5246 | $startup = true; |
@@ -5234,7 +5260,8 @@ discard block |
||
| 5234 | 5260 | // overwrite the old script (the position may be important for dependent scripts) |
| 5235 | 5261 | $overwritepos = $this->loadedjscripts[$key]['pos']; |
| 5236 | 5262 | } |
| 5237 | - } else { // Use the original version |
|
| 5263 | + } else { |
|
| 5264 | +// Use the original version |
|
| 5238 | 5265 | if ($startup == true && $this->loadedjscripts[$key]['startup'] == false) { |
| 5239 | 5266 | // need to move the exisiting script to the head |
| 5240 | 5267 | $version = $this->loadedjscripts[$key][$version]; |
@@ -5358,7 +5385,8 @@ discard block |
||
| 5358 | 5385 | } |
| 5359 | 5386 | |
| 5360 | 5387 | $results = null; |
| 5361 | - foreach ($this->pluginEvent[$evtName] as $pluginName) { // start for loop |
|
| 5388 | + foreach ($this->pluginEvent[$evtName] as $pluginName) { |
|
| 5389 | +// start for loop |
|
| 5362 | 5390 | if ($this->dumpPlugins) { |
| 5363 | 5391 | $eventtime = $this->getMicroTime(); |
| 5364 | 5392 | } |
@@ -5906,7 +5934,8 @@ discard block |
||
| 5906 | 5934 | * @return bool |
| 5907 | 5935 | */ |
| 5908 | 5936 | public function isSafeCode($phpcode = '', $safe_functions = '') |
| 5909 | - { // return true or false |
|
| 5937 | + { |
|
| 5938 | +// return true or false |
|
| 5910 | 5939 | if ($safe_functions == '') { |
| 5911 | 5940 | return false; |
| 5912 | 5941 | } |
@@ -6322,7 +6351,7 @@ discard block |
||
| 6322 | 6351 | $args = array_pad(array(), $_, '$var'); |
| 6323 | 6352 | $args = implode(", ", $args); |
| 6324 | 6353 | $modx = &$this; |
| 6325 | - $args = preg_replace_callback('/\$var/', function () use ($modx, &$tmp, $val) { |
|
| 6354 | + $args = preg_replace_callback('/\$var/', function () use ($modx, &$tmp, $val){ |
|
| 6326 | 6355 | $arg = $val['args'][$tmp - 1]; |
| 6327 | 6356 | switch (true) { |
| 6328 | 6357 | case is_null($arg): { |
@@ -1,12 +1,12 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -$installMode = isset($_POST['installmode']) ? (int)$_POST['installmode'] : 0; |
|
| 2 | +$installMode = isset($_POST['installmode']) ? (int) $_POST['installmode'] : 0; |
|
| 3 | 3 | |
| 4 | 4 | // Determine upgradeability |
| 5 | -$upgradeable= 0; |
|
| 5 | +$upgradeable = 0; |
|
| 6 | 6 | if ($installMode === 0) { |
| 7 | - $database_name= ''; |
|
| 8 | - $database_server= 'localhost'; |
|
| 9 | - $table_prefix= substr(md5(time()), rand(0, 27), rand(3, 5))."_"; |
|
| 7 | + $database_name = ''; |
|
| 8 | + $database_server = 'localhost'; |
|
| 9 | + $table_prefix = substr(md5(time()), rand(0, 27), rand(3, 5))."_"; |
|
| 10 | 10 | } else { |
| 11 | 11 | $database_name = ''; |
| 12 | 12 | if (!is_file($base_path.MGR_DIR.'/includes/config.inc.php')) $upgradeable = 0; |
@@ -17,13 +17,13 @@ discard block |
||
| 17 | 17 | if ($dbase) { |
| 18 | 18 | $database_name = trim($dbase, '`'); |
| 19 | 19 | if (!$conn = mysqli_connect($database_server, $database_user, $database_password)) |
| 20 | - $upgradeable = (isset($_POST['installmode']) && $_POST['installmode']=='new') ? 0 : 2; |
|
| 21 | - elseif (! mysqli_select_db($conn, trim($dbase, '`'))) |
|
| 22 | - $upgradeable = (isset($_POST['installmode']) && $_POST['installmode']=='new') ? 0 : 2; |
|
| 20 | + $upgradeable = (isset($_POST['installmode']) && $_POST['installmode'] == 'new') ? 0 : 2; |
|
| 21 | + elseif (!mysqli_select_db($conn, trim($dbase, '`'))) |
|
| 22 | + $upgradeable = (isset($_POST['installmode']) && $_POST['installmode'] == 'new') ? 0 : 2; |
|
| 23 | 23 | else |
| 24 | 24 | $upgradeable = 1; |
| 25 | 25 | } |
| 26 | - else $upgradable= 2; |
|
| 26 | + else $upgradable = 2; |
|
| 27 | 27 | } |
| 28 | 28 | } |
| 29 | 29 | |
@@ -49,28 +49,28 @@ discard block |
||
| 49 | 49 | $database_connection_method = 'SET CHARACTER SET'; |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | -$ph['database_name'] = isset($_POST['database_name']) ? $_POST['database_name']: $database_name; |
|
| 53 | -$ph['tableprefix'] = isset($_POST['tableprefix']) ? $_POST['tableprefix']: $table_prefix; |
|
| 52 | +$ph['database_name'] = isset($_POST['database_name']) ? $_POST['database_name'] : $database_name; |
|
| 53 | +$ph['tableprefix'] = isset($_POST['tableprefix']) ? $_POST['tableprefix'] : $table_prefix; |
|
| 54 | 54 | $ph['selected_set_character_set'] = isset($database_connection_method) && $database_connection_method == 'SET CHARACTER SET' ? 'selected' : ''; |
| 55 | 55 | $ph['selected_set_names'] = isset($database_connection_method) && $database_connection_method == 'SET NAMES' ? 'selected' : ''; |
| 56 | 56 | $ph['show#connection_method'] = (($installMode == 0) || ($installMode == 2)) ? 'block' : 'none'; |
| 57 | -$ph['database_collation'] = isset($_POST['database_collation']) ? $_POST['database_collation']: $database_collation; |
|
| 58 | -$ph['show#AUH'] = ($installMode == 0) ? 'block':'none'; |
|
| 59 | -$ph['cmsadmin'] = isset($_POST['cmsadmin']) ? $_POST['cmsadmin']:'admin'; |
|
| 60 | -$ph['cmsadminemail'] = isset($_POST['cmsadminemail']) ? $_POST['cmsadminemail']:""; |
|
| 61 | -$ph['cmspassword'] = isset($_POST['cmspassword']) ? $_POST['cmspassword']:""; |
|
| 62 | -$ph['cmspasswordconfirm'] = isset($_POST['cmspasswordconfirm']) ? $_POST['cmspasswordconfirm']:""; |
|
| 57 | +$ph['database_collation'] = isset($_POST['database_collation']) ? $_POST['database_collation'] : $database_collation; |
|
| 58 | +$ph['show#AUH'] = ($installMode == 0) ? 'block' : 'none'; |
|
| 59 | +$ph['cmsadmin'] = isset($_POST['cmsadmin']) ? $_POST['cmsadmin'] : 'admin'; |
|
| 60 | +$ph['cmsadminemail'] = isset($_POST['cmsadminemail']) ? $_POST['cmsadminemail'] : ""; |
|
| 61 | +$ph['cmspassword'] = isset($_POST['cmspassword']) ? $_POST['cmspassword'] : ""; |
|
| 62 | +$ph['cmspasswordconfirm'] = isset($_POST['cmspasswordconfirm']) ? $_POST['cmspasswordconfirm'] : ""; |
|
| 63 | 63 | $ph['managerLangs'] = getLangs($install_language); |
| 64 | 64 | $ph['install_language'] = $install_language; |
| 65 | 65 | $ph['installMode'] = $installMode; |
| 66 | -$ph['checkedChkagree'] = isset($_POST['chkagree']) ? 'checked':""; |
|
| 66 | +$ph['checkedChkagree'] = isset($_POST['chkagree']) ? 'checked' : ""; |
|
| 67 | 67 | $ph['database_connection_method'] = isset($database_connection_method) ? $database_connection_method : ''; |
| 68 | -$ph['databasehost'] = isset($_POST['databasehost']) ? $_POST['databasehost']: $database_server; |
|
| 69 | -$ph['databaseloginname'] = isset($_SESSION['databaseloginname']) ? $_SESSION['databaseloginname']: ''; |
|
| 70 | -$ph['databaseloginpassword'] = isset($_SESSION['databaseloginpassword']) ? $_SESSION['databaseloginpassword']: ""; |
|
| 68 | +$ph['databasehost'] = isset($_POST['databasehost']) ? $_POST['databasehost'] : $database_server; |
|
| 69 | +$ph['databaseloginname'] = isset($_SESSION['databaseloginname']) ? $_SESSION['databaseloginname'] : ''; |
|
| 70 | +$ph['databaseloginpassword'] = isset($_SESSION['databaseloginpassword']) ? $_SESSION['databaseloginpassword'] : ""; |
|
| 71 | 71 | $ph['MGR_DIR'] = MGR_DIR; |
| 72 | 72 | |
| 73 | 73 | $content = file_get_contents('./actions/tpl_connection.html'); |
| 74 | -$content = parse($content, $_lang, '[%','%]'); |
|
| 74 | +$content = parse($content, $_lang, '[%', '%]'); |
|
| 75 | 75 | $content = parse($content, $ph); |
| 76 | 76 | echo $content; |
@@ -9,21 +9,24 @@ |
||
| 9 | 9 | $table_prefix= substr(md5(time()), rand(0, 27), rand(3, 5))."_"; |
| 10 | 10 | } else { |
| 11 | 11 | $database_name = ''; |
| 12 | - if (!is_file($base_path.MGR_DIR.'/includes/config.inc.php')) $upgradeable = 0; |
|
| 13 | - else { |
|
| 12 | + if (!is_file($base_path.MGR_DIR.'/includes/config.inc.php')) { |
|
| 13 | + $upgradeable = 0; |
|
| 14 | + } else { |
|
| 14 | 15 | // Include the file so we can test its validity |
| 15 | 16 | include($base_path.MGR_DIR.'/includes/config.inc.php'); |
| 16 | 17 | // We need to have all connection settings - but prefix may be empty so we have to ignore it |
| 17 | 18 | if ($dbase) { |
| 18 | 19 | $database_name = trim($dbase, '`'); |
| 19 | - if (!$conn = mysqli_connect($database_server, $database_user, $database_password)) |
|
| 20 | - $upgradeable = (isset($_POST['installmode']) && $_POST['installmode']=='new') ? 0 : 2; |
|
| 21 | - elseif (! mysqli_select_db($conn, trim($dbase, '`'))) |
|
| 22 | - $upgradeable = (isset($_POST['installmode']) && $_POST['installmode']=='new') ? 0 : 2; |
|
| 23 | - else |
|
| 24 | - $upgradeable = 1; |
|
| 20 | + if (!$conn = mysqli_connect($database_server, $database_user, $database_password)) { |
|
| 21 | + $upgradeable = (isset($_POST['installmode']) && $_POST['installmode']=='new') ? 0 : 2; |
|
| 22 | + } elseif (! mysqli_select_db($conn, trim($dbase, '`'))) { |
|
| 23 | + $upgradeable = (isset($_POST['installmode']) && $_POST['installmode']=='new') ? 0 : 2; |
|
| 24 | + } else { |
|
| 25 | + $upgradeable = 1; |
|
| 26 | + } |
|
| 27 | + } else { |
|
| 28 | + $upgradable= 2; |
|
| 25 | 29 | } |
| 26 | - else $upgradable= 2; |
|
| 27 | 30 | } |
| 28 | 31 | } |
| 29 | 32 | |
@@ -4,141 +4,141 @@ |
||
| 4 | 4 | // SNUFFKIN/ Alex 2004 |
| 5 | 5 | |
| 6 | 6 | class SqlParser { |
| 7 | - public $host; |
|
| 8 | - public $dbname; |
|
| 9 | - public $prefix; |
|
| 10 | - public $user; |
|
| 11 | - public $password; |
|
| 12 | - public $mysqlErrors; |
|
| 13 | - public $conn; |
|
| 14 | - public $installFailed; |
|
| 15 | - public $sitename; |
|
| 16 | - public $adminname; |
|
| 17 | - public $adminemail; |
|
| 18 | - public $adminpass; |
|
| 19 | - public $managerlanguage; |
|
| 20 | - public $mode; |
|
| 21 | - public $fileManagerPath; |
|
| 22 | - public $imgPath; |
|
| 23 | - public $imgUrl; |
|
| 24 | - public $dbMODx; |
|
| 25 | - public $dbVersion; |
|
| 7 | + public $host; |
|
| 8 | + public $dbname; |
|
| 9 | + public $prefix; |
|
| 10 | + public $user; |
|
| 11 | + public $password; |
|
| 12 | + public $mysqlErrors; |
|
| 13 | + public $conn; |
|
| 14 | + public $installFailed; |
|
| 15 | + public $sitename; |
|
| 16 | + public $adminname; |
|
| 17 | + public $adminemail; |
|
| 18 | + public $adminpass; |
|
| 19 | + public $managerlanguage; |
|
| 20 | + public $mode; |
|
| 21 | + public $fileManagerPath; |
|
| 22 | + public $imgPath; |
|
| 23 | + public $imgUrl; |
|
| 24 | + public $dbMODx; |
|
| 25 | + public $dbVersion; |
|
| 26 | 26 | public $connection_charset; |
| 27 | 27 | public $connection_method; |
| 28 | 28 | public $ignoreDuplicateErrors; |
| 29 | 29 | public $autoTemplateLogic; |
| 30 | 30 | |
| 31 | - public function __construct($host, $user, $password, $db, $prefix='modx_', $adminname, $adminemail, $adminpass, $connection_charset= 'utf8', $managerlanguage='english', $connection_method = 'SET CHARACTER SET', $auto_template_logic = 'parent') { |
|
| 32 | - $this->host = $host; |
|
| 33 | - $this->dbname = $db; |
|
| 34 | - $this->prefix = $prefix; |
|
| 35 | - $this->user = $user; |
|
| 36 | - $this->password = $password; |
|
| 37 | - $this->adminpass = $adminpass; |
|
| 38 | - $this->adminname = $adminname; |
|
| 39 | - $this->adminemail = $adminemail; |
|
| 40 | - $this->connection_charset = $connection_charset; |
|
| 41 | - $this->connection_method = $connection_method; |
|
| 42 | - $this->ignoreDuplicateErrors = false; |
|
| 43 | - $this->managerlanguage = $managerlanguage; |
|
| 31 | + public function __construct($host, $user, $password, $db, $prefix='modx_', $adminname, $adminemail, $adminpass, $connection_charset= 'utf8', $managerlanguage='english', $connection_method = 'SET CHARACTER SET', $auto_template_logic = 'parent') { |
|
| 32 | + $this->host = $host; |
|
| 33 | + $this->dbname = $db; |
|
| 34 | + $this->prefix = $prefix; |
|
| 35 | + $this->user = $user; |
|
| 36 | + $this->password = $password; |
|
| 37 | + $this->adminpass = $adminpass; |
|
| 38 | + $this->adminname = $adminname; |
|
| 39 | + $this->adminemail = $adminemail; |
|
| 40 | + $this->connection_charset = $connection_charset; |
|
| 41 | + $this->connection_method = $connection_method; |
|
| 42 | + $this->ignoreDuplicateErrors = false; |
|
| 43 | + $this->managerlanguage = $managerlanguage; |
|
| 44 | 44 | $this->autoTemplateLogic = $auto_template_logic; |
| 45 | - } |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - public function connect() { |
|
| 48 | - $this->conn = mysqli_connect($this->host, $this->user, $this->password); |
|
| 49 | - mysqli_select_db($this->conn, $this->dbname); |
|
| 50 | - if (function_exists('mysqli_set_charset')) mysqli_set_charset($this->conn, $this->connection_charset); |
|
| 47 | + public function connect() { |
|
| 48 | + $this->conn = mysqli_connect($this->host, $this->user, $this->password); |
|
| 49 | + mysqli_select_db($this->conn, $this->dbname); |
|
| 50 | + if (function_exists('mysqli_set_charset')) mysqli_set_charset($this->conn, $this->connection_charset); |
|
| 51 | 51 | |
| 52 | - $this->dbVersion = 3.23; // assume version 3.23 |
|
| 53 | - if(function_exists("mysqli_get_server_info")) { |
|
| 54 | - $ver = mysqli_get_server_info($this->conn); |
|
| 55 | - $this->dbMODx = version_compare($ver,"4.0.2"); |
|
| 56 | - $this->dbVersion = (float) $ver; // Typecasting (float) instead of floatval() [PHP < 4.2] |
|
| 57 | - } |
|
| 52 | + $this->dbVersion = 3.23; // assume version 3.23 |
|
| 53 | + if(function_exists("mysqli_get_server_info")) { |
|
| 54 | + $ver = mysqli_get_server_info($this->conn); |
|
| 55 | + $this->dbMODx = version_compare($ver,"4.0.2"); |
|
| 56 | + $this->dbVersion = (float) $ver; // Typecasting (float) instead of floatval() [PHP < 4.2] |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | 59 | mysqli_query($this->conn,"{$this->connection_method} {$this->connection_charset}"); |
| 60 | - } |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | 62 | public function process($filename) { |
| 63 | - global $custom_placeholders; |
|
| 64 | - |
|
| 65 | - // check to make sure file exists |
|
| 66 | - if (!file_exists($filename)) { |
|
| 67 | - $this->mysqlErrors[] = array("error" => "File '$filename' not found"); |
|
| 68 | - $this->installFailed = true ; |
|
| 69 | - return false; |
|
| 70 | - } |
|
| 71 | - |
|
| 72 | - $fh = fopen($filename, 'r'); |
|
| 73 | - $idata = ''; |
|
| 74 | - |
|
| 75 | - while (!feof($fh)) { |
|
| 76 | - $idata .= fread($fh, 1024); |
|
| 77 | - } |
|
| 78 | - |
|
| 79 | - fclose($fh); |
|
| 80 | - $idata = str_replace("\r", '', $idata); |
|
| 81 | - |
|
| 82 | - // check if in upgrade mode |
|
| 83 | - if ($this->mode === 'upd') { |
|
| 84 | - // remove non-upgradeable parts |
|
| 85 | - $s = strpos($idata,'non-upgrade-able[['); |
|
| 86 | - $e = strpos($idata,']]non-upgrade-able') + 17; |
|
| 87 | - if($s && $e) { |
|
| 88 | - $idata = str_replace(substr($idata, $s,$e-$s),' Removed non upgradeable items', $idata); |
|
| 63 | + global $custom_placeholders; |
|
| 64 | + |
|
| 65 | + // check to make sure file exists |
|
| 66 | + if (!file_exists($filename)) { |
|
| 67 | + $this->mysqlErrors[] = array("error" => "File '$filename' not found"); |
|
| 68 | + $this->installFailed = true ; |
|
| 69 | + return false; |
|
| 70 | + } |
|
| 71 | + |
|
| 72 | + $fh = fopen($filename, 'r'); |
|
| 73 | + $idata = ''; |
|
| 74 | + |
|
| 75 | + while (!feof($fh)) { |
|
| 76 | + $idata .= fread($fh, 1024); |
|
| 77 | + } |
|
| 78 | + |
|
| 79 | + fclose($fh); |
|
| 80 | + $idata = str_replace("\r", '', $idata); |
|
| 81 | + |
|
| 82 | + // check if in upgrade mode |
|
| 83 | + if ($this->mode === 'upd') { |
|
| 84 | + // remove non-upgradeable parts |
|
| 85 | + $s = strpos($idata,'non-upgrade-able[['); |
|
| 86 | + $e = strpos($idata,']]non-upgrade-able') + 17; |
|
| 87 | + if($s && $e) { |
|
| 88 | + $idata = str_replace(substr($idata, $s,$e-$s),' Removed non upgradeable items', $idata); |
|
| 89 | 89 | } |
| 90 | - } |
|
| 91 | - |
|
| 92 | - // replace {} tags |
|
| 93 | - $idata = str_replace('{PREFIX}', $this->prefix, $idata); |
|
| 94 | - $idata = str_replace('{ADMIN}', $this->adminname, $idata); |
|
| 95 | - $idata = str_replace('{ADMINEMAIL}', $this->adminemail, $idata); |
|
| 96 | - $idata = str_replace('{ADMINPASS}', $this->adminpass, $idata); |
|
| 97 | - $idata = str_replace('{IMAGEPATH}', $this->imgPath, $idata); |
|
| 98 | - $idata = str_replace('{IMAGEURL}', $this->imgUrl, $idata); |
|
| 99 | - $idata = str_replace('{FILEMANAGERPATH}', $this->fileManagerPath, $idata); |
|
| 100 | - $idata = str_replace('{MANAGERLANGUAGE}', $this->managerlanguage, $idata); |
|
| 101 | - $idata = str_replace('{AUTOTEMPLATELOGIC}', $this->autoTemplateLogic, $idata); |
|
| 102 | - /*$idata = str_replace('{VERSION}', $modx_version, $idata);*/ |
|
| 103 | - |
|
| 104 | - // Replace custom placeholders |
|
| 105 | - foreach($custom_placeholders as $key=>$val) { |
|
| 106 | - if (strpos($idata, '{'.$key.'}') !== false) { |
|
| 107 | - $idata = str_replace('{'.$key.'}', $val, $idata); |
|
| 108 | - } |
|
| 109 | - } |
|
| 110 | - |
|
| 111 | - $sql_array = explode("\n\n", $idata); |
|
| 112 | - |
|
| 113 | - $num = 0; |
|
| 114 | - foreach($sql_array as $sql_entry) { |
|
| 115 | - $sql_do = trim($sql_entry, "\r\n; "); |
|
| 116 | - |
|
| 117 | - if (preg_match('/^\#/', $sql_do)) continue; |
|
| 118 | - |
|
| 119 | - // strip out comments and \n for mysql 3.x |
|
| 120 | - if ($this->dbVersion <4.0) { |
|
| 121 | - $sql_do = preg_replace("~COMMENT.*[^']?'.*[^']?'~","",$sql_do); |
|
| 122 | - $sql_do = str_replace('\r', "", $sql_do); |
|
| 123 | - $sql_do = str_replace('\n', "", $sql_do); |
|
| 124 | - } |
|
| 125 | - |
|
| 126 | - |
|
| 127 | - $num = $num + 1; |
|
| 128 | - if ($sql_do) mysqli_query($this->conn, $sql_do); |
|
| 129 | - if(mysqli_error($this->conn)) { |
|
| 130 | - // Ignore duplicate and drop errors - Raymond |
|
| 131 | - if ($this->ignoreDuplicateErrors){ |
|
| 132 | - if (mysqli_errno($this->conn) == 1060 || mysqli_errno($this->conn) == 1061 || mysqli_errno($this->conn) == 1062 ||mysqli_errno($this->conn) == 1091) continue; |
|
| 133 | - } |
|
| 134 | - // End Ignore duplicate |
|
| 135 | - $this->mysqlErrors[] = array("error" => mysqli_error($this->conn), "sql" => $sql_do); |
|
| 136 | - $this->installFailed = true; |
|
| 137 | - } |
|
| 138 | - } |
|
| 139 | - } |
|
| 90 | + } |
|
| 91 | + |
|
| 92 | + // replace {} tags |
|
| 93 | + $idata = str_replace('{PREFIX}', $this->prefix, $idata); |
|
| 94 | + $idata = str_replace('{ADMIN}', $this->adminname, $idata); |
|
| 95 | + $idata = str_replace('{ADMINEMAIL}', $this->adminemail, $idata); |
|
| 96 | + $idata = str_replace('{ADMINPASS}', $this->adminpass, $idata); |
|
| 97 | + $idata = str_replace('{IMAGEPATH}', $this->imgPath, $idata); |
|
| 98 | + $idata = str_replace('{IMAGEURL}', $this->imgUrl, $idata); |
|
| 99 | + $idata = str_replace('{FILEMANAGERPATH}', $this->fileManagerPath, $idata); |
|
| 100 | + $idata = str_replace('{MANAGERLANGUAGE}', $this->managerlanguage, $idata); |
|
| 101 | + $idata = str_replace('{AUTOTEMPLATELOGIC}', $this->autoTemplateLogic, $idata); |
|
| 102 | + /*$idata = str_replace('{VERSION}', $modx_version, $idata);*/ |
|
| 103 | + |
|
| 104 | + // Replace custom placeholders |
|
| 105 | + foreach($custom_placeholders as $key=>$val) { |
|
| 106 | + if (strpos($idata, '{'.$key.'}') !== false) { |
|
| 107 | + $idata = str_replace('{'.$key.'}', $val, $idata); |
|
| 108 | + } |
|
| 109 | + } |
|
| 110 | + |
|
| 111 | + $sql_array = explode("\n\n", $idata); |
|
| 112 | + |
|
| 113 | + $num = 0; |
|
| 114 | + foreach($sql_array as $sql_entry) { |
|
| 115 | + $sql_do = trim($sql_entry, "\r\n; "); |
|
| 116 | + |
|
| 117 | + if (preg_match('/^\#/', $sql_do)) continue; |
|
| 118 | + |
|
| 119 | + // strip out comments and \n for mysql 3.x |
|
| 120 | + if ($this->dbVersion <4.0) { |
|
| 121 | + $sql_do = preg_replace("~COMMENT.*[^']?'.*[^']?'~","",$sql_do); |
|
| 122 | + $sql_do = str_replace('\r', "", $sql_do); |
|
| 123 | + $sql_do = str_replace('\n', "", $sql_do); |
|
| 124 | + } |
|
| 125 | + |
|
| 126 | + |
|
| 127 | + $num = $num + 1; |
|
| 128 | + if ($sql_do) mysqli_query($this->conn, $sql_do); |
|
| 129 | + if(mysqli_error($this->conn)) { |
|
| 130 | + // Ignore duplicate and drop errors - Raymond |
|
| 131 | + if ($this->ignoreDuplicateErrors){ |
|
| 132 | + if (mysqli_errno($this->conn) == 1060 || mysqli_errno($this->conn) == 1061 || mysqli_errno($this->conn) == 1062 ||mysqli_errno($this->conn) == 1091) continue; |
|
| 133 | + } |
|
| 134 | + // End Ignore duplicate |
|
| 135 | + $this->mysqlErrors[] = array("error" => mysqli_error($this->conn), "sql" => $sql_do); |
|
| 136 | + $this->installFailed = true; |
|
| 137 | + } |
|
| 138 | + } |
|
| 139 | + } |
|
| 140 | 140 | |
| 141 | 141 | public function close() { |
| 142 | - mysqli_close($this->conn); |
|
| 143 | - } |
|
| 142 | + mysqli_close($this->conn); |
|
| 143 | + } |
|
| 144 | 144 | } |
@@ -3,7 +3,7 @@ discard block |
||
| 3 | 3 | // MySQL Dump Parser |
| 4 | 4 | // SNUFFKIN/ Alex 2004 |
| 5 | 5 | |
| 6 | -class SqlParser { |
|
| 6 | +class SqlParser{ |
|
| 7 | 7 | public $host; |
| 8 | 8 | public $dbname; |
| 9 | 9 | public $prefix; |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | public $ignoreDuplicateErrors; |
| 29 | 29 | public $autoTemplateLogic; |
| 30 | 30 | |
| 31 | - public function __construct($host, $user, $password, $db, $prefix='modx_', $adminname, $adminemail, $adminpass, $connection_charset= 'utf8', $managerlanguage='english', $connection_method = 'SET CHARACTER SET', $auto_template_logic = 'parent') { |
|
| 31 | + public function __construct($host, $user, $password, $db, $prefix = 'modx_', $adminname, $adminemail, $adminpass, $connection_charset = 'utf8', $managerlanguage = 'english', $connection_method = 'SET CHARACTER SET', $auto_template_logic = 'parent'){ |
|
| 32 | 32 | $this->host = $host; |
| 33 | 33 | $this->dbname = $db; |
| 34 | 34 | $this->prefix = $prefix; |
@@ -44,28 +44,28 @@ discard block |
||
| 44 | 44 | $this->autoTemplateLogic = $auto_template_logic; |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - public function connect() { |
|
| 47 | + public function connect(){ |
|
| 48 | 48 | $this->conn = mysqli_connect($this->host, $this->user, $this->password); |
| 49 | 49 | mysqli_select_db($this->conn, $this->dbname); |
| 50 | 50 | if (function_exists('mysqli_set_charset')) mysqli_set_charset($this->conn, $this->connection_charset); |
| 51 | 51 | |
| 52 | 52 | $this->dbVersion = 3.23; // assume version 3.23 |
| 53 | - if(function_exists("mysqli_get_server_info")) { |
|
| 53 | + if (function_exists("mysqli_get_server_info")) { |
|
| 54 | 54 | $ver = mysqli_get_server_info($this->conn); |
| 55 | - $this->dbMODx = version_compare($ver,"4.0.2"); |
|
| 55 | + $this->dbMODx = version_compare($ver, "4.0.2"); |
|
| 56 | 56 | $this->dbVersion = (float) $ver; // Typecasting (float) instead of floatval() [PHP < 4.2] |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | - mysqli_query($this->conn,"{$this->connection_method} {$this->connection_charset}"); |
|
| 59 | + mysqli_query($this->conn, "{$this->connection_method} {$this->connection_charset}"); |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | - public function process($filename) { |
|
| 62 | + public function process($filename){ |
|
| 63 | 63 | global $custom_placeholders; |
| 64 | 64 | |
| 65 | 65 | // check to make sure file exists |
| 66 | 66 | if (!file_exists($filename)) { |
| 67 | 67 | $this->mysqlErrors[] = array("error" => "File '$filename' not found"); |
| 68 | - $this->installFailed = true ; |
|
| 68 | + $this->installFailed = true; |
|
| 69 | 69 | return false; |
| 70 | 70 | } |
| 71 | 71 | |
@@ -82,10 +82,10 @@ discard block |
||
| 82 | 82 | // check if in upgrade mode |
| 83 | 83 | if ($this->mode === 'upd') { |
| 84 | 84 | // remove non-upgradeable parts |
| 85 | - $s = strpos($idata,'non-upgrade-able[['); |
|
| 86 | - $e = strpos($idata,']]non-upgrade-able') + 17; |
|
| 87 | - if($s && $e) { |
|
| 88 | - $idata = str_replace(substr($idata, $s,$e-$s),' Removed non upgradeable items', $idata); |
|
| 85 | + $s = strpos($idata, 'non-upgrade-able[['); |
|
| 86 | + $e = strpos($idata, ']]non-upgrade-able') + 17; |
|
| 87 | + if ($s && $e) { |
|
| 88 | + $idata = str_replace(substr($idata, $s, $e - $s), ' Removed non upgradeable items', $idata); |
|
| 89 | 89 | } |
| 90 | 90 | } |
| 91 | 91 | |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | /*$idata = str_replace('{VERSION}', $modx_version, $idata);*/ |
| 103 | 103 | |
| 104 | 104 | // Replace custom placeholders |
| 105 | - foreach($custom_placeholders as $key=>$val) { |
|
| 105 | + foreach ($custom_placeholders as $key=>$val) { |
|
| 106 | 106 | if (strpos($idata, '{'.$key.'}') !== false) { |
| 107 | 107 | $idata = str_replace('{'.$key.'}', $val, $idata); |
| 108 | 108 | } |
@@ -111,14 +111,14 @@ discard block |
||
| 111 | 111 | $sql_array = explode("\n\n", $idata); |
| 112 | 112 | |
| 113 | 113 | $num = 0; |
| 114 | - foreach($sql_array as $sql_entry) { |
|
| 114 | + foreach ($sql_array as $sql_entry) { |
|
| 115 | 115 | $sql_do = trim($sql_entry, "\r\n; "); |
| 116 | 116 | |
| 117 | 117 | if (preg_match('/^\#/', $sql_do)) continue; |
| 118 | 118 | |
| 119 | 119 | // strip out comments and \n for mysql 3.x |
| 120 | - if ($this->dbVersion <4.0) { |
|
| 121 | - $sql_do = preg_replace("~COMMENT.*[^']?'.*[^']?'~","",$sql_do); |
|
| 120 | + if ($this->dbVersion < 4.0) { |
|
| 121 | + $sql_do = preg_replace("~COMMENT.*[^']?'.*[^']?'~", "", $sql_do); |
|
| 122 | 122 | $sql_do = str_replace('\r', "", $sql_do); |
| 123 | 123 | $sql_do = str_replace('\n', "", $sql_do); |
| 124 | 124 | } |
@@ -126,10 +126,10 @@ discard block |
||
| 126 | 126 | |
| 127 | 127 | $num = $num + 1; |
| 128 | 128 | if ($sql_do) mysqli_query($this->conn, $sql_do); |
| 129 | - if(mysqli_error($this->conn)) { |
|
| 129 | + if (mysqli_error($this->conn)) { |
|
| 130 | 130 | // Ignore duplicate and drop errors - Raymond |
| 131 | - if ($this->ignoreDuplicateErrors){ |
|
| 132 | - if (mysqli_errno($this->conn) == 1060 || mysqli_errno($this->conn) == 1061 || mysqli_errno($this->conn) == 1062 ||mysqli_errno($this->conn) == 1091) continue; |
|
| 131 | + if ($this->ignoreDuplicateErrors) { |
|
| 132 | + if (mysqli_errno($this->conn) == 1060 || mysqli_errno($this->conn) == 1061 || mysqli_errno($this->conn) == 1062 || mysqli_errno($this->conn) == 1091) continue; |
|
| 133 | 133 | } |
| 134 | 134 | // End Ignore duplicate |
| 135 | 135 | $this->mysqlErrors[] = array("error" => mysqli_error($this->conn), "sql" => $sql_do); |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | } |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | - public function close() { |
|
| 141 | + public function close(){ |
|
| 142 | 142 | mysqli_close($this->conn); |
| 143 | 143 | } |
| 144 | 144 | } |
@@ -3,7 +3,8 @@ discard block |
||
| 3 | 3 | // MySQL Dump Parser |
| 4 | 4 | // SNUFFKIN/ Alex 2004 |
| 5 | 5 | |
| 6 | -class SqlParser { |
|
| 6 | +class SqlParser |
|
| 7 | +{ |
|
| 7 | 8 | public $host; |
| 8 | 9 | public $dbname; |
| 9 | 10 | public $prefix; |
@@ -28,7 +29,8 @@ discard block |
||
| 28 | 29 | public $ignoreDuplicateErrors; |
| 29 | 30 | public $autoTemplateLogic; |
| 30 | 31 | |
| 31 | - public function __construct($host, $user, $password, $db, $prefix='modx_', $adminname, $adminemail, $adminpass, $connection_charset= 'utf8', $managerlanguage='english', $connection_method = 'SET CHARACTER SET', $auto_template_logic = 'parent') { |
|
| 32 | + public function __construct($host, $user, $password, $db, $prefix='modx_', $adminname, $adminemail, $adminpass, $connection_charset= 'utf8', $managerlanguage='english', $connection_method = 'SET CHARACTER SET', $auto_template_logic = 'parent') |
|
| 33 | + { |
|
| 32 | 34 | $this->host = $host; |
| 33 | 35 | $this->dbname = $db; |
| 34 | 36 | $this->prefix = $prefix; |
@@ -44,10 +46,13 @@ discard block |
||
| 44 | 46 | $this->autoTemplateLogic = $auto_template_logic; |
| 45 | 47 | } |
| 46 | 48 | |
| 47 | - public function connect() { |
|
| 49 | + public function connect() |
|
| 50 | + { |
|
| 48 | 51 | $this->conn = mysqli_connect($this->host, $this->user, $this->password); |
| 49 | 52 | mysqli_select_db($this->conn, $this->dbname); |
| 50 | - if (function_exists('mysqli_set_charset')) mysqli_set_charset($this->conn, $this->connection_charset); |
|
| 53 | + if (function_exists('mysqli_set_charset')) { |
|
| 54 | + mysqli_set_charset($this->conn, $this->connection_charset); |
|
| 55 | + } |
|
| 51 | 56 | |
| 52 | 57 | $this->dbVersion = 3.23; // assume version 3.23 |
| 53 | 58 | if(function_exists("mysqli_get_server_info")) { |
@@ -59,7 +64,8 @@ discard block |
||
| 59 | 64 | mysqli_query($this->conn,"{$this->connection_method} {$this->connection_charset}"); |
| 60 | 65 | } |
| 61 | 66 | |
| 62 | - public function process($filename) { |
|
| 67 | + public function process($filename) |
|
| 68 | + { |
|
| 63 | 69 | global $custom_placeholders; |
| 64 | 70 | |
| 65 | 71 | // check to make sure file exists |
@@ -114,7 +120,9 @@ discard block |
||
| 114 | 120 | foreach($sql_array as $sql_entry) { |
| 115 | 121 | $sql_do = trim($sql_entry, "\r\n; "); |
| 116 | 122 | |
| 117 | - if (preg_match('/^\#/', $sql_do)) continue; |
|
| 123 | + if (preg_match('/^\#/', $sql_do)) { |
|
| 124 | + continue; |
|
| 125 | + } |
|
| 118 | 126 | |
| 119 | 127 | // strip out comments and \n for mysql 3.x |
| 120 | 128 | if ($this->dbVersion <4.0) { |
@@ -125,11 +133,15 @@ discard block |
||
| 125 | 133 | |
| 126 | 134 | |
| 127 | 135 | $num = $num + 1; |
| 128 | - if ($sql_do) mysqli_query($this->conn, $sql_do); |
|
| 136 | + if ($sql_do) { |
|
| 137 | + mysqli_query($this->conn, $sql_do); |
|
| 138 | + } |
|
| 129 | 139 | if(mysqli_error($this->conn)) { |
| 130 | 140 | // Ignore duplicate and drop errors - Raymond |
| 131 | - if ($this->ignoreDuplicateErrors){ |
|
| 132 | - if (mysqli_errno($this->conn) == 1060 || mysqli_errno($this->conn) == 1061 || mysqli_errno($this->conn) == 1062 ||mysqli_errno($this->conn) == 1091) continue; |
|
| 141 | + if ($this->ignoreDuplicateErrors) { |
|
| 142 | + if (mysqli_errno($this->conn) == 1060 || mysqli_errno($this->conn) == 1061 || mysqli_errno($this->conn) == 1062 ||mysqli_errno($this->conn) == 1091) { |
|
| 143 | + continue; |
|
| 144 | + } |
|
| 133 | 145 | } |
| 134 | 146 | // End Ignore duplicate |
| 135 | 147 | $this->mysqlErrors[] = array("error" => mysqli_error($this->conn), "sql" => $sql_do); |
@@ -138,7 +150,8 @@ discard block |
||
| 138 | 150 | } |
| 139 | 151 | } |
| 140 | 152 | |
| 141 | - public function close() { |
|
| 153 | + public function close() |
|
| 154 | + { |
|
| 142 | 155 | mysqli_close($this->conn); |
| 143 | 156 | } |
| 144 | 157 | } |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
| 2 | +if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
| 3 | 3 | die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
| 4 | 4 | } |
| 5 | 5 | if (!$modx->hasPermission('bk_manager')) { |
@@ -9,10 +9,10 @@ discard block |
||
| 9 | 9 | $dbase = trim($dbase, '`'); |
| 10 | 10 | |
| 11 | 11 | if (!isset($modx->config['snapshot_path'])) { |
| 12 | - if (is_dir(MODX_BASE_PATH . 'temp/backup/')) { |
|
| 13 | - $modx->config['snapshot_path'] = MODX_BASE_PATH . 'temp/backup/'; |
|
| 12 | + if (is_dir(MODX_BASE_PATH.'temp/backup/')) { |
|
| 13 | + $modx->config['snapshot_path'] = MODX_BASE_PATH.'temp/backup/'; |
|
| 14 | 14 | } else { |
| 15 | - $modx->config['snapshot_path'] = MODX_BASE_PATH . 'assets/backup/'; |
|
| 15 | + $modx->config['snapshot_path'] = MODX_BASE_PATH.'assets/backup/'; |
|
| 16 | 16 | } |
| 17 | 17 | } |
| 18 | 18 | |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | if ($mode == 'restore1') { |
| 24 | 24 | if (isset($_POST['textarea']) && !empty($_POST['textarea'])) { |
| 25 | 25 | $source = trim($_POST['textarea']); |
| 26 | - $_SESSION['textarea'] = $source . "\n"; |
|
| 26 | + $_SESSION['textarea'] = $source."\n"; |
|
| 27 | 27 | } else { |
| 28 | 28 | $source = file_get_contents($_FILES['sqlfile']['tmp_name']); |
| 29 | 29 | } |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | header('Location: index.php?r=9&a=93'); |
| 32 | 32 | exit; |
| 33 | 33 | } elseif ($mode == 'restore2') { |
| 34 | - $path = $modx->config['snapshot_path'] . $_POST['filename']; |
|
| 34 | + $path = $modx->config['snapshot_path'].$_POST['filename']; |
|
| 35 | 35 | if (file_exists($path)) { |
| 36 | 36 | $source = file_get_contents($path); |
| 37 | 37 | import_sql($source); |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | if (!is_writable(rtrim($modx->config['snapshot_path'], '/'))) { |
| 78 | 78 | $modx->webAlertAndQuit(parsePlaceholder($_lang["bkmgr_alert_mkdir"], array('snapshot_path' => $modx->config['snapshot_path']))); |
| 79 | 79 | } |
| 80 | - $sql = "SHOW TABLE STATUS FROM `{$dbase}` LIKE '" . $modx->db->escape($modx->db->config['table_prefix']) . "%'"; |
|
| 80 | + $sql = "SHOW TABLE STATUS FROM `{$dbase}` LIKE '".$modx->db->escape($modx->db->config['table_prefix'])."%'"; |
|
| 81 | 81 | $rs = $modx->db->query($sql); |
| 82 | 82 | $tables = $modx->db->getColumn('Name', $rs); |
| 83 | 83 | $today = date('Y-m-d_H-i-s'); |
@@ -109,18 +109,18 @@ discard block |
||
| 109 | 109 | $modx->webAlertAndQuit('Unable to Backup Database'); |
| 110 | 110 | } |
| 111 | 111 | } else { |
| 112 | - include_once MODX_MANAGER_PATH . "includes/header.inc.php"; // start normal header |
|
| 112 | + include_once MODX_MANAGER_PATH."includes/header.inc.php"; // start normal header |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | if (isset($_SESSION['result_msg']) && $_SESSION['result_msg'] != '') { |
| 116 | 116 | switch ($_SESSION['result_msg']) { |
| 117 | 117 | case 'import_ok': |
| 118 | - $ph['result_msg_import'] = '<div class="alert alert-success">' . $_lang["bkmgr_import_ok"] . '</div>'; |
|
| 119 | - $ph['result_msg_snapshot'] = '<div class="alert alert-success">' . $_lang["bkmgr_import_ok"] . '</div>'; |
|
| 118 | + $ph['result_msg_import'] = '<div class="alert alert-success">'.$_lang["bkmgr_import_ok"].'</div>'; |
|
| 119 | + $ph['result_msg_snapshot'] = '<div class="alert alert-success">'.$_lang["bkmgr_import_ok"].'</div>'; |
|
| 120 | 120 | break; |
| 121 | 121 | case 'snapshot_ok': |
| 122 | 122 | $ph['result_msg_import'] = ''; |
| 123 | - $ph['result_msg_snapshot'] = '<div class="alert alert-success">' . $_lang["bkmgr_snapshot_ok"] . '</div>'; |
|
| 123 | + $ph['result_msg_snapshot'] = '<div class="alert alert-success">'.$_lang["bkmgr_snapshot_ok"].'</div>'; |
|
| 124 | 124 | break; |
| 125 | 125 | } |
| 126 | 126 | $_SESSION['result_msg'] = ''; |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | f.style.display = 'none'; |
| 180 | 180 | } |
| 181 | 181 | } |
| 182 | - <?= (isset($_REQUEST['r']) ? " doRefresh(" . $_REQUEST['r'] . ");" : "") ?> |
|
| 182 | + <?= (isset($_REQUEST['r']) ? " doRefresh(".$_REQUEST['r'].");" : "") ?> |
|
| 183 | 183 | |
| 184 | 184 | </script> |
| 185 | 185 | |
@@ -223,7 +223,7 @@ discard block |
||
| 223 | 223 | </thead> |
| 224 | 224 | <tbody> |
| 225 | 225 | <?php |
| 226 | - $sql = "SHOW TABLE STATUS FROM `{$dbase}` LIKE '" . $modx->db->escape($modx->db->config['table_prefix']) . "%'"; |
|
| 226 | + $sql = "SHOW TABLE STATUS FROM `{$dbase}` LIKE '".$modx->db->escape($modx->db->config['table_prefix'])."%'"; |
|
| 227 | 227 | $rs = $modx->db->query($sql); |
| 228 | 228 | $i = 0; |
| 229 | 229 | while ($db_status = $modx->db->getRow($rs)) { |
@@ -233,29 +233,29 @@ discard block |
||
| 233 | 233 | $table_string = ''; |
| 234 | 234 | } |
| 235 | 235 | |
| 236 | - echo '<tr>' . "\n" . '<td><label class="form-check form-check-label"><input type="checkbox" name="chk[]" class="form-check-input" value="' . $db_status['Name'] . '"' . (strstr($table_string, $db_status['Name']) === false ? '' : ' checked="checked"') . ' /><b class="text-primary">' . $db_status['Name'] . '</b></label></td>' . "\n"; |
|
| 237 | - echo '<td class="text-xs-center">' . (!empty($db_status['Comment']) ? '<i class="' . $_style['actions_help'] . '" data-tooltip="' . $db_status['Comment'] . '"></i>' : '') . '</td>' . "\n"; |
|
| 238 | - echo '<td class="text-xs-right">' . $db_status['Rows'] . '</td>' . "\n"; |
|
| 239 | - echo '<td class="text-xs-right">' . $db_status['Collation'] . '</td>' . "\n"; |
|
| 236 | + echo '<tr>'."\n".'<td><label class="form-check form-check-label"><input type="checkbox" name="chk[]" class="form-check-input" value="'.$db_status['Name'].'"'.(strstr($table_string, $db_status['Name']) === false ? '' : ' checked="checked"').' /><b class="text-primary">'.$db_status['Name'].'</b></label></td>'."\n"; |
|
| 237 | + echo '<td class="text-xs-center">'.(!empty($db_status['Comment']) ? '<i class="'.$_style['actions_help'].'" data-tooltip="'.$db_status['Comment'].'"></i>' : '').'</td>'."\n"; |
|
| 238 | + echo '<td class="text-xs-right">'.$db_status['Rows'].'</td>'."\n"; |
|
| 239 | + echo '<td class="text-xs-right">'.$db_status['Collation'].'</td>'."\n"; |
|
| 240 | 240 | |
| 241 | 241 | // Enable record deletion for certain tables (TRUNCATE TABLE) if they're not already empty |
| 242 | 242 | $truncateable = array( |
| 243 | - $modx->db->config['table_prefix'] . 'event_log', |
|
| 244 | - $modx->db->config['table_prefix'] . 'manager_log', |
|
| 243 | + $modx->db->config['table_prefix'].'event_log', |
|
| 244 | + $modx->db->config['table_prefix'].'manager_log', |
|
| 245 | 245 | ); |
| 246 | 246 | if ($modx->hasPermission('settings') && in_array($db_status['Name'], $truncateable) && $db_status['Rows'] > 0) { |
| 247 | - echo '<td class="text-xs-right"><a class="text-danger" href="index.php?a=54&mode=' . $action . '&u=' . $db_status['Name'] . '" title="' . $_lang['truncate_table'] . '">' . $modx->nicesize($db_status['Data_length'] + $db_status['Data_free']) . '</a>' . '</td>' . "\n"; |
|
| 247 | + echo '<td class="text-xs-right"><a class="text-danger" href="index.php?a=54&mode='.$action.'&u='.$db_status['Name'].'" title="'.$_lang['truncate_table'].'">'.$modx->nicesize($db_status['Data_length'] + $db_status['Data_free']).'</a>'.'</td>'."\n"; |
|
| 248 | 248 | } else { |
| 249 | - echo '<td class="text-xs-right">' . $modx->nicesize($db_status['Data_length'] + $db_status['Data_free']) . '</td>' . "\n"; |
|
| 249 | + echo '<td class="text-xs-right">'.$modx->nicesize($db_status['Data_length'] + $db_status['Data_free']).'</td>'."\n"; |
|
| 250 | 250 | } |
| 251 | 251 | |
| 252 | 252 | if ($modx->hasPermission('settings')) { |
| 253 | - echo '<td class="text-xs-right">' . ($db_status['Data_free'] > 0 ? '<a class="text-danger" href="index.php?a=54&mode=' . $action . '&t=' . $db_status['Name'] . '" title="' . $_lang['optimize_table'] . '">' . $modx->nicesize($db_status['Data_free']) . '</a>' : '-') . '</td>' . "\n"; |
|
| 253 | + echo '<td class="text-xs-right">'.($db_status['Data_free'] > 0 ? '<a class="text-danger" href="index.php?a=54&mode='.$action.'&t='.$db_status['Name'].'" title="'.$_lang['optimize_table'].'">'.$modx->nicesize($db_status['Data_free']).'</a>' : '-').'</td>'."\n"; |
|
| 254 | 254 | } else { |
| 255 | - echo '<td class="text-xs-right">' . ($db_status['Data_free'] > 0 ? $modx->nicesize($db_status['Data_free']) : '-') . '</td>' . "\n"; |
|
| 255 | + echo '<td class="text-xs-right">'.($db_status['Data_free'] > 0 ? $modx->nicesize($db_status['Data_free']) : '-').'</td>'."\n"; |
|
| 256 | 256 | } |
| 257 | 257 | |
| 258 | - echo '<td class="text-xs-right">' . $modx->nicesize($db_status['Data_length'] - $db_status['Data_free']) . '</td>' . "\n" . '<td class="text-xs-right">' . $modx->nicesize($db_status['Index_length']) . '</td>' . "\n" . '<td class="text-xs-right">' . $modx->nicesize($db_status['Index_length'] + $db_status['Data_length'] + $db_status['Data_free']) . '</td>' . "\n" . "</tr>"; |
|
| 258 | + echo '<td class="text-xs-right">'.$modx->nicesize($db_status['Data_length'] - $db_status['Data_free']).'</td>'."\n".'<td class="text-xs-right">'.$modx->nicesize($db_status['Index_length']).'</td>'."\n".'<td class="text-xs-right">'.$modx->nicesize($db_status['Index_length'] + $db_status['Data_length'] + $db_status['Data_free']).'</td>'."\n"."</tr>"; |
|
| 259 | 259 | |
| 260 | 260 | $total = $total + $db_status['Index_length'] + $db_status['Data_length']; |
| 261 | 261 | $totaloverhead = $totaloverhead + $db_status['Data_free']; |
@@ -266,9 +266,9 @@ discard block |
||
| 266 | 266 | <tr> |
| 267 | 267 | <td class="text-xs-right"><?= $_lang['database_table_totals'] ?></td> |
| 268 | 268 | <td colspan="4"> </td> |
| 269 | - <td class="text-xs-right"><?= $totaloverhead > 0 ? '<b class="text-danger">' . $modx->nicesize($totaloverhead) . '</b><br />(' . number_format($totaloverhead) . ' B)' : '-' ?></td> |
|
| 269 | + <td class="text-xs-right"><?= $totaloverhead > 0 ? '<b class="text-danger">'.$modx->nicesize($totaloverhead).'</b><br />('.number_format($totaloverhead).' B)' : '-' ?></td> |
|
| 270 | 270 | <td colspan="2"> </td> |
| 271 | - <td class="text-xs-right"><?= "<b>" . $modx->nicesize($total) . "</b><br />(" . number_format($total) . " B)" ?></td> |
|
| 271 | + <td class="text-xs-right"><?= "<b>".$modx->nicesize($total)."</b><br />(".number_format($total)." B)" ?></td> |
|
| 272 | 272 | </tr> |
| 273 | 273 | </tfoot> |
| 274 | 274 | </table> |
@@ -319,7 +319,7 @@ discard block |
||
| 319 | 319 | foreach ($last_result['0'] as $k => $v) { |
| 320 | 320 | $title[] = $k; |
| 321 | 321 | } |
| 322 | - $result = '<thead><tr><th>' . implode('</th><th>', $title) . '</th></tr></thead>'; |
|
| 322 | + $result = '<thead><tr><th>'.implode('</th><th>', $title).'</th></tr></thead>'; |
|
| 323 | 323 | $result .= '<tbody>'; |
| 324 | 324 | foreach ($last_result as $row) { |
| 325 | 325 | $result_value = array(); |
@@ -327,11 +327,11 @@ discard block |
||
| 327 | 327 | foreach ($row as $k => $v) { |
| 328 | 328 | $result_value[] = $v; |
| 329 | 329 | } |
| 330 | - $result .= '<tr><td>' . implode('</td><td>', $result_value) . '</td></tr>'; |
|
| 330 | + $result .= '<tr><td>'.implode('</td><td>', $result_value).'</td></tr>'; |
|
| 331 | 331 | } |
| 332 | 332 | } |
| 333 | 333 | $result .= '</tbody>'; |
| 334 | - $result = '<table class="table data">' . $result . '</table>'; |
|
| 334 | + $result = '<table class="table data">'.$result.'</table>'; |
|
| 335 | 335 | } |
| 336 | 336 | } |
| 337 | 337 | |
@@ -433,7 +433,7 @@ discard block |
||
| 433 | 433 | while ($count < 11) { |
| 434 | 434 | $line = fgets($file); |
| 435 | 435 | foreach ($detailFields as $label) { |
| 436 | - $fileLabel = '# ' . $label; |
|
| 436 | + $fileLabel = '# '.$label; |
|
| 437 | 437 | if (strpos($line, $fileLabel) !== false) { |
| 438 | 438 | $details[$label] = htmlentities(trim(str_replace(array( |
| 439 | 439 | $fileLabel, |
@@ -446,10 +446,10 @@ discard block |
||
| 446 | 446 | }; |
| 447 | 447 | fclose($file); |
| 448 | 448 | |
| 449 | - $tooltip = "Generation Time: " . $details["Generation Time"] . "\n"; |
|
| 450 | - $tooltip .= "Server version: " . $details["Server version"] . "\n"; |
|
| 451 | - $tooltip .= "PHP Version: " . $details["PHP Version"] . "\n"; |
|
| 452 | - $tooltip .= "Host: " . $details["Host"] . "\n"; |
|
| 449 | + $tooltip = "Generation Time: ".$details["Generation Time"]."\n"; |
|
| 450 | + $tooltip .= "Server version: ".$details["Server version"]."\n"; |
|
| 451 | + $tooltip .= "PHP Version: ".$details["PHP Version"]."\n"; |
|
| 452 | + $tooltip .= "Host: ".$details["Host"]."\n"; |
|
| 453 | 453 | ?> |
| 454 | 454 | <tr> |
| 455 | 455 | <td><?= $filename ?></td> |
@@ -481,7 +481,7 @@ discard block |
||
| 481 | 481 | <?php |
| 482 | 482 | |
| 483 | 483 | if (is_numeric($_GET['tab'])) { |
| 484 | - echo '<script type="text/javascript">tpDBM.setSelectedIndex( ' . $_GET['tab'] . ' );</script>'; |
|
| 484 | + echo '<script type="text/javascript">tpDBM.setSelectedIndex( '.$_GET['tab'].' );</script>'; |
|
| 485 | 485 | } |
| 486 | 486 | |
| 487 | 487 | include_once "footer.inc.php"; // send footer |
@@ -535,7 +535,7 @@ discard block |
||
| 535 | 535 | |
| 536 | 536 | // Set line feed |
| 537 | 537 | $lf = "\n"; |
| 538 | - $tempfile_path = $modx->config['base_path'] . 'assets/backup/temp.php'; |
|
| 538 | + $tempfile_path = $modx->config['base_path'].'assets/backup/temp.php'; |
|
| 539 | 539 | |
| 540 | 540 | $result = $modx->db->query('SHOW TABLES'); |
| 541 | 541 | $tables = $this->result2Array(0, $result); |
@@ -548,15 +548,15 @@ discard block |
||
| 548 | 548 | |
| 549 | 549 | // Set header |
| 550 | 550 | $output = "#{$lf}"; |
| 551 | - $output .= "# " . addslashes($modx->config['site_name']) . " Database Dump{$lf}"; |
|
| 551 | + $output .= "# ".addslashes($modx->config['site_name'])." Database Dump{$lf}"; |
|
| 552 | 552 | $output .= "# MODX Version:{$version['version']}{$lf}"; |
| 553 | 553 | $output .= "# {$lf}"; |
| 554 | 554 | $output .= "# Host: {$this->database_server}{$lf}"; |
| 555 | - $output .= "# Generation Time: " . $modx->toDateFormat(time()) . $lf; |
|
| 556 | - $output .= "# Server version: " . $modx->db->getVersion() . $lf; |
|
| 557 | - $output .= "# PHP Version: " . phpversion() . $lf; |
|
| 555 | + $output .= "# Generation Time: ".$modx->toDateFormat(time()).$lf; |
|
| 556 | + $output .= "# Server version: ".$modx->db->getVersion().$lf; |
|
| 557 | + $output .= "# PHP Version: ".phpversion().$lf; |
|
| 558 | 558 | $output .= "# Database: `{$this->dbname}`{$lf}"; |
| 559 | - $output .= "# Description: " . trim($_REQUEST['backup_title']) . "{$lf}"; |
|
| 559 | + $output .= "# Description: ".trim($_REQUEST['backup_title'])."{$lf}"; |
|
| 560 | 560 | $output .= "#"; |
| 561 | 561 | file_put_contents($tempfile_path, $output, FILE_APPEND | LOCK_EX); |
| 562 | 562 | $output = ''; |
@@ -575,7 +575,7 @@ discard block |
||
| 575 | 575 | } |
| 576 | 576 | } |
| 577 | 577 | if ($callBack === 'snapshot') { |
| 578 | - if (!preg_match('@^' . $modx->db->config['table_prefix'] . '@', $tblval)) { |
|
| 578 | + if (!preg_match('@^'.$modx->db->config['table_prefix'].'@', $tblval)) { |
|
| 579 | 579 | continue; |
| 580 | 580 | } |
| 581 | 581 | } |
@@ -597,7 +597,7 @@ discard block |
||
| 597 | 597 | $insertdump = $lf; |
| 598 | 598 | $insertdump .= "INSERT INTO `{$tblval}` VALUES ("; |
| 599 | 599 | $arr = $this->object2Array($row); |
| 600 | - if( ! is_array($arr)) $arr = array(); |
|
| 600 | + if (!is_array($arr)) $arr = array(); |
|
| 601 | 601 | foreach ($arr as $key => $value) { |
| 602 | 602 | if (is_null($value)) { |
| 603 | 603 | $value = 'NULL'; |
@@ -610,9 +610,9 @@ discard block |
||
| 610 | 610 | ), '\\n', $value); |
| 611 | 611 | $value = "'{$value}'"; |
| 612 | 612 | } |
| 613 | - $insertdump .= $value . ','; |
|
| 613 | + $insertdump .= $value.','; |
|
| 614 | 614 | } |
| 615 | - $output .= rtrim($insertdump, ',') . ");\n"; |
|
| 615 | + $output .= rtrim($insertdump, ',').");\n"; |
|
| 616 | 616 | if (1048576 < strlen($output)) { |
| 617 | 617 | file_put_contents($tempfile_path, $output, FILE_APPEND | LOCK_EX); |
| 618 | 618 | $output = ''; |
@@ -597,7 +597,9 @@ |
||
| 597 | 597 | $insertdump = $lf; |
| 598 | 598 | $insertdump .= "INSERT INTO `{$tblval}` VALUES ("; |
| 599 | 599 | $arr = $this->object2Array($row); |
| 600 | - if( ! is_array($arr)) $arr = array(); |
|
| 600 | + if( ! is_array($arr)) { |
|
| 601 | + $arr = array(); |
|
| 602 | + } |
|
| 601 | 603 | foreach ($arr as $key => $value) { |
| 602 | 604 | if (is_null($value)) { |
| 603 | 605 | $value = 'NULL'; |
@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | */ |
| 10 | 10 | public $db; |
| 11 | 11 | public $db_tbl = array(); |
| 12 | - public $elements = array( 'templates', 'tmplvars', 'htmlsnippets', 'snippets', 'plugins', 'modules' ); |
|
| 12 | + public $elements = array('templates', 'tmplvars', 'htmlsnippets', 'snippets', 'plugins', 'modules'); |
|
| 13 | 13 | |
| 14 | 14 | public function __construct() |
| 15 | 15 | { |
@@ -18,9 +18,9 @@ discard block |
||
| 18 | 18 | $this->db = & $modx->db; |
| 19 | 19 | $this->db_tbl['categories'] = $modx->getFullTableName('categories'); |
| 20 | 20 | |
| 21 | - foreach( $this->elements as $element ) |
|
| 21 | + foreach ($this->elements as $element) |
|
| 22 | 22 | { |
| 23 | - $this->db_tbl[$element] = $modx->getFullTableName('site_' . $element ); |
|
| 23 | + $this->db_tbl[$element] = $modx->getFullTableName('site_'.$element); |
|
| 24 | 24 | } |
| 25 | 25 | } |
| 26 | 26 | |
@@ -40,54 +40,54 @@ discard block |
||
| 40 | 40 | ) |
| 41 | 41 | ); |
| 42 | 42 | |
| 43 | - if( !empty( $categories ) ) |
|
| 43 | + if (!empty($categories)) |
|
| 44 | 44 | { |
| 45 | 45 | return $categories; |
| 46 | 46 | } |
| 47 | 47 | return false; |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | - public function getCategory( $search, $where = 'category' ) |
|
| 50 | + public function getCategory($search, $where = 'category') |
|
| 51 | 51 | { |
| 52 | 52 | $category = $this->db->getRow( |
| 53 | 53 | $this->db->select( |
| 54 | 54 | '*', |
| 55 | 55 | $this->db_tbl['categories'], |
| 56 | - "`" . $where . "` = '" . $search . "'" |
|
| 56 | + "`".$where."` = '".$search."'" |
|
| 57 | 57 | ) |
| 58 | 58 | ); |
| 59 | 59 | return $category; |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | - public function getCategoryValue( $value, $search, $where = 'category' ) |
|
| 62 | + public function getCategoryValue($value, $search, $where = 'category') |
|
| 63 | 63 | { |
| 64 | 64 | $_value = $this->db->getValue( |
| 65 | 65 | $this->db->select( |
| 66 | - '`' . $value . '`', |
|
| 66 | + '`'.$value.'`', |
|
| 67 | 67 | $this->db_tbl['categories'], |
| 68 | - "`" . $where . "` = '" . $search . "'" |
|
| 68 | + "`".$where."` = '".$search."'" |
|
| 69 | 69 | ) |
| 70 | 70 | ); |
| 71 | 71 | return $_value; |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - public function getAssignedElements( $category_id, $element ) |
|
| 74 | + public function getAssignedElements($category_id, $element) |
|
| 75 | 75 | { |
| 76 | - if( in_array( $element, $this->elements, true ) ) |
|
| 76 | + if (in_array($element, $this->elements, true)) |
|
| 77 | 77 | { |
| 78 | 78 | $elements = $this->db->makeArray( |
| 79 | 79 | $this->db->select( |
| 80 | 80 | '*', |
| 81 | 81 | $this->db_tbl[$element], |
| 82 | - "`category` = '" . $category_id . "'" |
|
| 82 | + "`category` = '".$category_id."'" |
|
| 83 | 83 | ) |
| 84 | 84 | ); |
| 85 | 85 | |
| 86 | 86 | // correct the name of templates |
| 87 | - if( $element === 'templates' ) |
|
| 87 | + if ($element === 'templates') |
|
| 88 | 88 | { |
| 89 | 89 | $_elements_count = count($elements); |
| 90 | - for( $i=0; $i < $_elements_count; $i++ ) |
|
| 90 | + for ($i = 0; $i < $_elements_count; $i++) |
|
| 91 | 91 | { |
| 92 | 92 | $elements[$i]['name'] = $elements[$i]['templatename']; |
| 93 | 93 | } |
@@ -97,56 +97,56 @@ discard block |
||
| 97 | 97 | return false; |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | - public function getAllAssignedElements( $category_id ) |
|
| 100 | + public function getAllAssignedElements($category_id) |
|
| 101 | 101 | { |
| 102 | 102 | $elements = array(); |
| 103 | - foreach( $this->elements as $element ) |
|
| 103 | + foreach ($this->elements as $element) |
|
| 104 | 104 | { |
| 105 | - $elements[$element] = $this->getAssignedElements( $category_id, $element ); |
|
| 105 | + $elements[$element] = $this->getAssignedElements($category_id, $element); |
|
| 106 | 106 | } |
| 107 | 107 | return $elements; |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - public function deleteCategory( $category_id ) |
|
| 110 | + public function deleteCategory($category_id) |
|
| 111 | 111 | { |
| 112 | 112 | $_update = array('category' => 0); |
| 113 | - foreach( $this->elements as $element ) |
|
| 113 | + foreach ($this->elements as $element) |
|
| 114 | 114 | { |
| 115 | 115 | $this->db->update( |
| 116 | 116 | $_update, |
| 117 | 117 | $this->db_tbl[$element], |
| 118 | - "`category` = '" . $category_id . "'" |
|
| 118 | + "`category` = '".$category_id."'" |
|
| 119 | 119 | ); |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | $this->db->delete( |
| 123 | 123 | $this->db_tbl['categories'], |
| 124 | - "`id` = '" . $category_id . "'" |
|
| 124 | + "`id` = '".$category_id."'" |
|
| 125 | 125 | ); |
| 126 | 126 | |
| 127 | 127 | return $this->db->getAffectedRows() === 1; |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | - public function updateCategory( $category_id, $data = array() ) |
|
| 130 | + public function updateCategory($category_id, $data = array()) |
|
| 131 | 131 | { |
| 132 | - if( empty( $data ) |
|
| 133 | - || empty( $category_id ) ) |
|
| 132 | + if (empty($data) |
|
| 133 | + || empty($category_id)) |
|
| 134 | 134 | { |
| 135 | 135 | return false; |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | $_update = array( |
| 139 | - 'category' => $this->db->escape( $data['category'] ), |
|
| 140 | - 'rank' => (int)$data['rank'] |
|
| 139 | + 'category' => $this->db->escape($data['category']), |
|
| 140 | + 'rank' => (int) $data['rank'] |
|
| 141 | 141 | ); |
| 142 | 142 | |
| 143 | 143 | $this->db->update( |
| 144 | 144 | $_update, |
| 145 | 145 | $this->db_tbl['categories'], |
| 146 | - "`id` = '" . (int)$category_id . "'" |
|
| 146 | + "`id` = '".(int) $category_id."'" |
|
| 147 | 147 | ); |
| 148 | 148 | |
| 149 | - if( $this->db->getAffectedRows() === 1 ) |
|
| 149 | + if ($this->db->getAffectedRows() === 1) |
|
| 150 | 150 | { |
| 151 | 151 | return true; |
| 152 | 152 | } |
@@ -154,16 +154,16 @@ discard block |
||
| 154 | 154 | return false; |
| 155 | 155 | } |
| 156 | 156 | |
| 157 | - public function addCategory( $category_name, $category_rank ) |
|
| 157 | + public function addCategory($category_name, $category_rank) |
|
| 158 | 158 | { |
| 159 | - if( $this->isCategoryExists( $category_name ) ) |
|
| 159 | + if ($this->isCategoryExists($category_name)) |
|
| 160 | 160 | { |
| 161 | 161 | return false; |
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | $_insert = array( |
| 165 | - 'category' => $this->db->escape( $category_name ), |
|
| 166 | - 'rank' => (int)$category_rank |
|
| 165 | + 'category' => $this->db->escape($category_name), |
|
| 166 | + 'rank' => (int) $category_rank |
|
| 167 | 167 | ); |
| 168 | 168 | |
| 169 | 169 | $this->db->insert( |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | $this->db_tbl['categories'] |
| 172 | 172 | ); |
| 173 | 173 | |
| 174 | - if( $this->db->getAffectedRows() === 1 ) |
|
| 174 | + if ($this->db->getAffectedRows() === 1) |
|
| 175 | 175 | { |
| 176 | 176 | return $this->db->getInsertId(); |
| 177 | 177 | } |
@@ -179,19 +179,19 @@ discard block |
||
| 179 | 179 | return false; |
| 180 | 180 | } |
| 181 | 181 | |
| 182 | - public function isCategoryExists( $category_name ) |
|
| 182 | + public function isCategoryExists($category_name) |
|
| 183 | 183 | { |
| 184 | - $category = $this->db->escape( $category_name ); |
|
| 184 | + $category = $this->db->escape($category_name); |
|
| 185 | 185 | |
| 186 | 186 | $category_id = $this->db->getValue( |
| 187 | 187 | $this->db->select( |
| 188 | 188 | '`id`', |
| 189 | 189 | $this->db_tbl['categories'], |
| 190 | - "`category` = '" . $category . "'" |
|
| 190 | + "`category` = '".$category."'" |
|
| 191 | 191 | ) |
| 192 | 192 | ); |
| 193 | 193 | |
| 194 | - if( $this->db->getAffectedRows() === 1 ) |
|
| 194 | + if ($this->db->getAffectedRows() === 1) |
|
| 195 | 195 | { |
| 196 | 196 | return $category_id; |
| 197 | 197 | } |
@@ -1,17 +1,17 @@ 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('import_static')) { |
| 6 | - $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 6 | + $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 7 | 7 | } |
| 8 | 8 | |
| 9 | 9 | // Files to upload |
| 10 | 10 | $allowedfiles = array( |
| 11 | - 'html', |
|
| 12 | - 'htm', |
|
| 13 | - 'shtml', |
|
| 14 | - 'xml' |
|
| 11 | + 'html', |
|
| 12 | + 'htm', |
|
| 13 | + 'shtml', |
|
| 14 | + 'xml' |
|
| 15 | 15 | ); |
| 16 | 16 | ?> |
| 17 | 17 | <script language="javascript"> |
@@ -43,9 +43,9 @@ discard block |
||
| 43 | 43 | <div class="tab-page"> |
| 44 | 44 | <div class="container container-body"> |
| 45 | 45 | <?php |
| 46 | - if(!isset($_POST['import'])) { |
|
| 47 | - echo "<div class=\"element-edit-message\">" . $_lang['import_site_message'] . "</div>"; |
|
| 48 | - ?> |
|
| 46 | + if(!isset($_POST['import'])) { |
|
| 47 | + echo "<div class=\"element-edit-message\">" . $_lang['import_site_message'] . "</div>"; |
|
| 48 | + ?> |
|
| 49 | 49 | <form action="index.php" method="post" name="importFrm"> |
| 50 | 50 | <input type="hidden" name="import" value="import" /> |
| 51 | 51 | <input type="hidden" name="a" value="95" /> |
@@ -85,375 +85,375 @@ discard block |
||
| 85 | 85 | <a href="javascript:;" class="btn btn-primary" onclick="window.importFrm.submit();"><i class="<?= $_style["actions_save"] ?>"></i> <?= $_lang["import_site_start"] ?></a> |
| 86 | 86 | </form> |
| 87 | 87 | <?php |
| 88 | - } else { |
|
| 89 | - run(); |
|
| 90 | - $modx->clearCache('full'); |
|
| 91 | - ?> |
|
| 88 | + } else { |
|
| 89 | + run(); |
|
| 90 | + $modx->clearCache('full'); |
|
| 91 | + ?> |
|
| 92 | 92 | <a href="javascript:;" class="btn btn-primary" onclick="window.location.href='index.php?a=2';"><i class="<?= $_style["actions_close"] ?>"></i> <?= $_lang["close"] ?></a> |
| 93 | 93 | <script type="text/javascript"> |
| 94 | 94 | top.mainMenu.reloadtree(); |
| 95 | 95 | parent.tree.ca = 'open'; |
| 96 | 96 | </script> |
| 97 | 97 | <?php |
| 98 | - } |
|
| 99 | - ?> |
|
| 98 | + } |
|
| 99 | + ?> |
|
| 100 | 100 | </div> |
| 101 | 101 | </div> |
| 102 | 102 | |
| 103 | 103 | <?php |
| 104 | 104 | function run() { |
| 105 | - global $modx, $_lang; |
|
| 105 | + global $modx, $_lang; |
|
| 106 | 106 | |
| 107 | - $tbl_site_content = $modx->getFullTableName('site_content'); |
|
| 108 | - $output = ''; |
|
| 109 | - $maxtime = $_POST['maxtime']; |
|
| 107 | + $tbl_site_content = $modx->getFullTableName('site_content'); |
|
| 108 | + $output = ''; |
|
| 109 | + $maxtime = $_POST['maxtime']; |
|
| 110 | 110 | |
| 111 | - if(!is_numeric($maxtime)) { |
|
| 112 | - $maxtime = 30; |
|
| 113 | - } |
|
| 111 | + if(!is_numeric($maxtime)) { |
|
| 112 | + $maxtime = 30; |
|
| 113 | + } |
|
| 114 | 114 | |
| 115 | - @set_time_limit($maxtime); |
|
| 115 | + @set_time_limit($maxtime); |
|
| 116 | 116 | |
| 117 | - $mtime = microtime(); |
|
| 118 | - $mtime = explode(' ', $mtime); |
|
| 119 | - $mtime = $mtime[1] + $mtime[0]; |
|
| 120 | - $importstart = $mtime; |
|
| 117 | + $mtime = microtime(); |
|
| 118 | + $mtime = explode(' ', $mtime); |
|
| 119 | + $mtime = $mtime[1] + $mtime[0]; |
|
| 120 | + $importstart = $mtime; |
|
| 121 | 121 | |
| 122 | - if($_POST['reset'] == 'on') { |
|
| 123 | - $modx->db->truncate($tbl_site_content); |
|
| 124 | - $modx->db->query("ALTER TABLE {$tbl_site_content} AUTO_INCREMENT = 1"); |
|
| 125 | - } |
|
| 122 | + if($_POST['reset'] == 'on') { |
|
| 123 | + $modx->db->truncate($tbl_site_content); |
|
| 124 | + $modx->db->query("ALTER TABLE {$tbl_site_content} AUTO_INCREMENT = 1"); |
|
| 125 | + } |
|
| 126 | 126 | |
| 127 | - $parent = intval($_POST['parent']); |
|
| 127 | + $parent = intval($_POST['parent']); |
|
| 128 | 128 | |
| 129 | - if(is_dir(MODX_BASE_PATH . 'temp/import')) { |
|
| 130 | - $filedir = MODX_BASE_PATH . 'temp/import/'; |
|
| 131 | - } elseif(is_dir(MODX_BASE_PATH . 'assets/import')) { |
|
| 132 | - $filedir = MODX_BASE_PATH . 'assets/import/'; |
|
| 133 | - } else { |
|
| 129 | + if(is_dir(MODX_BASE_PATH . 'temp/import')) { |
|
| 130 | + $filedir = MODX_BASE_PATH . 'temp/import/'; |
|
| 131 | + } elseif(is_dir(MODX_BASE_PATH . 'assets/import')) { |
|
| 132 | + $filedir = MODX_BASE_PATH . 'assets/import/'; |
|
| 133 | + } else { |
|
| 134 | 134 | $filedir = ''; |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | - $filesfound = 0; |
|
| 137 | + $filesfound = 0; |
|
| 138 | 138 | |
| 139 | - $files = getFiles($filedir); |
|
| 140 | - $files = pop_index($files); |
|
| 139 | + $files = getFiles($filedir); |
|
| 140 | + $files = pop_index($files); |
|
| 141 | 141 | |
| 142 | - // no. of files to import |
|
| 143 | - $output .= sprintf('<p>' . $_lang['import_files_found'] . '</p>', $filesfound); |
|
| 142 | + // no. of files to import |
|
| 143 | + $output .= sprintf('<p>' . $_lang['import_files_found'] . '</p>', $filesfound); |
|
| 144 | 144 | |
| 145 | - // import files |
|
| 146 | - if(0 < count($files)) { |
|
| 147 | - $modx->db->update(array('isfolder' => 1), $tbl_site_content, "id='{$parent}'"); |
|
| 148 | - importFiles($parent, $filedir, $files, 'root'); |
|
| 149 | - } |
|
| 145 | + // import files |
|
| 146 | + if(0 < count($files)) { |
|
| 147 | + $modx->db->update(array('isfolder' => 1), $tbl_site_content, "id='{$parent}'"); |
|
| 148 | + importFiles($parent, $filedir, $files, 'root'); |
|
| 149 | + } |
|
| 150 | 150 | |
| 151 | - $mtime = microtime(); |
|
| 152 | - $mtime = explode(' ', $mtime); |
|
| 153 | - $mtime = $mtime[1] + $mtime[0]; |
|
| 154 | - $importend = $mtime; |
|
| 155 | - $totaltime = ($importend - $importstart); |
|
| 156 | - $output .= sprintf('<p>' . $_lang['import_site_time'] . '</p>', round($totaltime, 3)); |
|
| 151 | + $mtime = microtime(); |
|
| 152 | + $mtime = explode(' ', $mtime); |
|
| 153 | + $mtime = $mtime[1] + $mtime[0]; |
|
| 154 | + $importend = $mtime; |
|
| 155 | + $totaltime = ($importend - $importstart); |
|
| 156 | + $output .= sprintf('<p>' . $_lang['import_site_time'] . '</p>', round($totaltime, 3)); |
|
| 157 | 157 | |
| 158 | - if($_POST['convert_link'] == 'on') { |
|
| 159 | - convertLink(); |
|
| 160 | - } |
|
| 158 | + if($_POST['convert_link'] == 'on') { |
|
| 159 | + convertLink(); |
|
| 160 | + } |
|
| 161 | 161 | |
| 162 | - return $output; |
|
| 162 | + return $output; |
|
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | function importFiles($parent, $filedir, $files, $mode) { |
| 166 | - global $modx; |
|
| 167 | - global $_lang, $allowedfiles; |
|
| 168 | - global $search_default, $cache_default, $publish_default; |
|
| 169 | - |
|
| 170 | - $tbl_site_content = $modx->getFullTableName('site_content'); |
|
| 171 | - $tbl_system_settings = $modx->getFullTableName('system_settings'); |
|
| 172 | - |
|
| 173 | - $createdby = $modx->getLoginUserID(); |
|
| 174 | - if(!is_array($files)) { |
|
| 175 | - return; |
|
| 176 | - } |
|
| 177 | - if($_POST['object'] == 'all') { |
|
| 178 | - $modx->config['default_template'] = '0'; |
|
| 179 | - $richtext = '0'; |
|
| 180 | - } else { |
|
| 181 | - $richtext = '1'; |
|
| 182 | - } |
|
| 183 | - |
|
| 184 | - foreach($files as $id => $value) { |
|
| 185 | - if(is_array($value)) { |
|
| 186 | - // create folder |
|
| 187 | - $alias = $id; |
|
| 188 | - printf('<span>' . $_lang['import_site_importing_document'] . '</span>', $alias); |
|
| 189 | - $field = array(); |
|
| 190 | - $field['type'] = 'document'; |
|
| 191 | - $field['contentType'] = 'text/html'; |
|
| 192 | - $field['published'] = $publish_default; |
|
| 193 | - $field['parent'] = $parent; |
|
| 194 | - $field['alias'] = $modx->stripAlias($alias); |
|
| 195 | - $field['richtext'] = $richtext; |
|
| 196 | - $field['template'] = $modx->config['default_template']; |
|
| 197 | - $field['searchable'] = $search_default; |
|
| 198 | - $field['cacheable'] = $cache_default; |
|
| 199 | - $field['createdby'] = $createdby; |
|
| 200 | - $field['isfolder'] = 1; |
|
| 201 | - $field['menuindex'] = 1; |
|
| 202 | - $find = false; |
|
| 203 | - foreach(array( |
|
| 204 | - 'index.html', |
|
| 205 | - 'index.htm' |
|
| 206 | - ) as $filename) { |
|
| 207 | - $filepath = $filedir . $alias . '/' . $filename; |
|
| 208 | - if($find === false && file_exists($filepath)) { |
|
| 209 | - $file = getFileContent($filepath); |
|
| 210 | - list($pagetitle, $content, $description) = treatContent($file, $filename, $alias); |
|
| 211 | - |
|
| 212 | - $date = filemtime($filepath); |
|
| 213 | - $field['pagetitle'] = $pagetitle; |
|
| 214 | - $field['longtitle'] = $pagetitle; |
|
| 215 | - $field['description'] = $description; |
|
| 216 | - $field['content'] = $modx->db->escape($content); |
|
| 217 | - $field['createdon'] = $date; |
|
| 218 | - $field['editedon'] = $date; |
|
| 219 | - $newid = $modx->db->insert($field, $tbl_site_content); |
|
| 220 | - if($newid) { |
|
| 221 | - $find = true; |
|
| 222 | - echo ' - <span class="success">' . $_lang['import_site_success'] . '</span><br />' . "\n"; |
|
| 223 | - importFiles($newid, $filedir . $alias . '/', $value, 'sub'); |
|
| 224 | - } else { |
|
| 225 | - echo '<span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_db_error"] . $modx->db->getLastError(); |
|
| 226 | - exit; |
|
| 227 | - } |
|
| 228 | - } |
|
| 229 | - } |
|
| 230 | - if($find === false) { |
|
| 231 | - $date = time(); |
|
| 232 | - $field['pagetitle'] = '---'; |
|
| 233 | - $field['content'] = ''; |
|
| 234 | - $field['createdon'] = $date; |
|
| 235 | - $field['editedon'] = $date; |
|
| 236 | - $field['hidemenu'] = '1'; |
|
| 237 | - $newid = $modx->db->insert($field, $tbl_site_content); |
|
| 238 | - if($newid) { |
|
| 239 | - $find = true; |
|
| 240 | - echo ' - <span class="success">' . $_lang['import_site_success'] . '</span><br />' . "\n"; |
|
| 241 | - importFiles($newid, $filedir . $alias . '/', $value, 'sub'); |
|
| 242 | - } else { |
|
| 243 | - echo '<span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_db_error"] . $modx->db->getLastError(); |
|
| 244 | - exit; |
|
| 245 | - } |
|
| 246 | - } |
|
| 247 | - } else { |
|
| 248 | - // create document |
|
| 249 | - if($mode == 'sub' && $value == 'index.html') { |
|
| 250 | - continue; |
|
| 251 | - } |
|
| 252 | - $filename = $value; |
|
| 253 | - $fparts = explode('.', $value); |
|
| 254 | - $alias = $fparts[0]; |
|
| 255 | - $ext = (count($fparts) > 1) ? $fparts[count($fparts) - 1] : ""; |
|
| 256 | - printf("<span>" . $_lang['import_site_importing_document'] . "</span>", $filename); |
|
| 257 | - |
|
| 258 | - if(!in_array($ext, $allowedfiles)) { |
|
| 259 | - echo ' - <span class="fail">' . $_lang["import_site_skip"] . '</span><br />' . "\n"; |
|
| 260 | - } else { |
|
| 261 | - $filepath = $filedir . $filename; |
|
| 262 | - $file = getFileContent($filepath); |
|
| 263 | - list($pagetitle, $content, $description) = treatContent($file, $filename, $alias); |
|
| 264 | - |
|
| 265 | - $date = filemtime($filepath); |
|
| 266 | - $field = array(); |
|
| 267 | - $field['type'] = 'document'; |
|
| 268 | - $field['contentType'] = 'text/html'; |
|
| 269 | - $field['pagetitle'] = $pagetitle; |
|
| 270 | - $field['longtitle'] = $pagetitle; |
|
| 271 | - $field['description'] = $description; |
|
| 272 | - $field['alias'] = $modx->stripAlias($alias); |
|
| 273 | - $field['published'] = $publish_default; |
|
| 274 | - $field['parent'] = $parent; |
|
| 275 | - $field['content'] = $modx->db->escape($content); |
|
| 276 | - $field['richtext'] = $richtext; |
|
| 277 | - $field['template'] = $modx->config['default_template']; |
|
| 278 | - $field['searchable'] = $search_default; |
|
| 279 | - $field['cacheable'] = $cache_default; |
|
| 280 | - $field['createdby'] = $createdby; |
|
| 281 | - $field['createdon'] = $date; |
|
| 282 | - $field['editedon'] = $date; |
|
| 283 | - $field['isfolder'] = 0; |
|
| 284 | - $field['menuindex'] = ($alias == 'index') ? 0 : 2; |
|
| 285 | - $newid = $modx->db->insert($field, $tbl_site_content); |
|
| 286 | - if($newid) { |
|
| 287 | - echo ' - <span class="success">' . $_lang['import_site_success'] . '</span><br />' . "\n"; |
|
| 288 | - } else { |
|
| 289 | - echo '<span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_db_error"] . $modx->db->getLastError(); |
|
| 290 | - exit; |
|
| 291 | - } |
|
| 292 | - |
|
| 293 | - $is_site_start = false; |
|
| 294 | - if($filename == 'index.html') { |
|
| 295 | - $is_site_start = true; |
|
| 296 | - } |
|
| 297 | - if($is_site_start == true && $_POST['reset'] == 'on') { |
|
| 298 | - $modx->db->update(array('setting_value' => $newid), $tbl_system_settings, "setting_name='site_start'"); |
|
| 299 | - $modx->db->update(array('menuindex' => 0), $tbl_site_content, "id='{$newid}'"); |
|
| 300 | - } |
|
| 301 | - } |
|
| 302 | - } |
|
| 303 | - } |
|
| 166 | + global $modx; |
|
| 167 | + global $_lang, $allowedfiles; |
|
| 168 | + global $search_default, $cache_default, $publish_default; |
|
| 169 | + |
|
| 170 | + $tbl_site_content = $modx->getFullTableName('site_content'); |
|
| 171 | + $tbl_system_settings = $modx->getFullTableName('system_settings'); |
|
| 172 | + |
|
| 173 | + $createdby = $modx->getLoginUserID(); |
|
| 174 | + if(!is_array($files)) { |
|
| 175 | + return; |
|
| 176 | + } |
|
| 177 | + if($_POST['object'] == 'all') { |
|
| 178 | + $modx->config['default_template'] = '0'; |
|
| 179 | + $richtext = '0'; |
|
| 180 | + } else { |
|
| 181 | + $richtext = '1'; |
|
| 182 | + } |
|
| 183 | + |
|
| 184 | + foreach($files as $id => $value) { |
|
| 185 | + if(is_array($value)) { |
|
| 186 | + // create folder |
|
| 187 | + $alias = $id; |
|
| 188 | + printf('<span>' . $_lang['import_site_importing_document'] . '</span>', $alias); |
|
| 189 | + $field = array(); |
|
| 190 | + $field['type'] = 'document'; |
|
| 191 | + $field['contentType'] = 'text/html'; |
|
| 192 | + $field['published'] = $publish_default; |
|
| 193 | + $field['parent'] = $parent; |
|
| 194 | + $field['alias'] = $modx->stripAlias($alias); |
|
| 195 | + $field['richtext'] = $richtext; |
|
| 196 | + $field['template'] = $modx->config['default_template']; |
|
| 197 | + $field['searchable'] = $search_default; |
|
| 198 | + $field['cacheable'] = $cache_default; |
|
| 199 | + $field['createdby'] = $createdby; |
|
| 200 | + $field['isfolder'] = 1; |
|
| 201 | + $field['menuindex'] = 1; |
|
| 202 | + $find = false; |
|
| 203 | + foreach(array( |
|
| 204 | + 'index.html', |
|
| 205 | + 'index.htm' |
|
| 206 | + ) as $filename) { |
|
| 207 | + $filepath = $filedir . $alias . '/' . $filename; |
|
| 208 | + if($find === false && file_exists($filepath)) { |
|
| 209 | + $file = getFileContent($filepath); |
|
| 210 | + list($pagetitle, $content, $description) = treatContent($file, $filename, $alias); |
|
| 211 | + |
|
| 212 | + $date = filemtime($filepath); |
|
| 213 | + $field['pagetitle'] = $pagetitle; |
|
| 214 | + $field['longtitle'] = $pagetitle; |
|
| 215 | + $field['description'] = $description; |
|
| 216 | + $field['content'] = $modx->db->escape($content); |
|
| 217 | + $field['createdon'] = $date; |
|
| 218 | + $field['editedon'] = $date; |
|
| 219 | + $newid = $modx->db->insert($field, $tbl_site_content); |
|
| 220 | + if($newid) { |
|
| 221 | + $find = true; |
|
| 222 | + echo ' - <span class="success">' . $_lang['import_site_success'] . '</span><br />' . "\n"; |
|
| 223 | + importFiles($newid, $filedir . $alias . '/', $value, 'sub'); |
|
| 224 | + } else { |
|
| 225 | + echo '<span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_db_error"] . $modx->db->getLastError(); |
|
| 226 | + exit; |
|
| 227 | + } |
|
| 228 | + } |
|
| 229 | + } |
|
| 230 | + if($find === false) { |
|
| 231 | + $date = time(); |
|
| 232 | + $field['pagetitle'] = '---'; |
|
| 233 | + $field['content'] = ''; |
|
| 234 | + $field['createdon'] = $date; |
|
| 235 | + $field['editedon'] = $date; |
|
| 236 | + $field['hidemenu'] = '1'; |
|
| 237 | + $newid = $modx->db->insert($field, $tbl_site_content); |
|
| 238 | + if($newid) { |
|
| 239 | + $find = true; |
|
| 240 | + echo ' - <span class="success">' . $_lang['import_site_success'] . '</span><br />' . "\n"; |
|
| 241 | + importFiles($newid, $filedir . $alias . '/', $value, 'sub'); |
|
| 242 | + } else { |
|
| 243 | + echo '<span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_db_error"] . $modx->db->getLastError(); |
|
| 244 | + exit; |
|
| 245 | + } |
|
| 246 | + } |
|
| 247 | + } else { |
|
| 248 | + // create document |
|
| 249 | + if($mode == 'sub' && $value == 'index.html') { |
|
| 250 | + continue; |
|
| 251 | + } |
|
| 252 | + $filename = $value; |
|
| 253 | + $fparts = explode('.', $value); |
|
| 254 | + $alias = $fparts[0]; |
|
| 255 | + $ext = (count($fparts) > 1) ? $fparts[count($fparts) - 1] : ""; |
|
| 256 | + printf("<span>" . $_lang['import_site_importing_document'] . "</span>", $filename); |
|
| 257 | + |
|
| 258 | + if(!in_array($ext, $allowedfiles)) { |
|
| 259 | + echo ' - <span class="fail">' . $_lang["import_site_skip"] . '</span><br />' . "\n"; |
|
| 260 | + } else { |
|
| 261 | + $filepath = $filedir . $filename; |
|
| 262 | + $file = getFileContent($filepath); |
|
| 263 | + list($pagetitle, $content, $description) = treatContent($file, $filename, $alias); |
|
| 264 | + |
|
| 265 | + $date = filemtime($filepath); |
|
| 266 | + $field = array(); |
|
| 267 | + $field['type'] = 'document'; |
|
| 268 | + $field['contentType'] = 'text/html'; |
|
| 269 | + $field['pagetitle'] = $pagetitle; |
|
| 270 | + $field['longtitle'] = $pagetitle; |
|
| 271 | + $field['description'] = $description; |
|
| 272 | + $field['alias'] = $modx->stripAlias($alias); |
|
| 273 | + $field['published'] = $publish_default; |
|
| 274 | + $field['parent'] = $parent; |
|
| 275 | + $field['content'] = $modx->db->escape($content); |
|
| 276 | + $field['richtext'] = $richtext; |
|
| 277 | + $field['template'] = $modx->config['default_template']; |
|
| 278 | + $field['searchable'] = $search_default; |
|
| 279 | + $field['cacheable'] = $cache_default; |
|
| 280 | + $field['createdby'] = $createdby; |
|
| 281 | + $field['createdon'] = $date; |
|
| 282 | + $field['editedon'] = $date; |
|
| 283 | + $field['isfolder'] = 0; |
|
| 284 | + $field['menuindex'] = ($alias == 'index') ? 0 : 2; |
|
| 285 | + $newid = $modx->db->insert($field, $tbl_site_content); |
|
| 286 | + if($newid) { |
|
| 287 | + echo ' - <span class="success">' . $_lang['import_site_success'] . '</span><br />' . "\n"; |
|
| 288 | + } else { |
|
| 289 | + echo '<span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_db_error"] . $modx->db->getLastError(); |
|
| 290 | + exit; |
|
| 291 | + } |
|
| 292 | + |
|
| 293 | + $is_site_start = false; |
|
| 294 | + if($filename == 'index.html') { |
|
| 295 | + $is_site_start = true; |
|
| 296 | + } |
|
| 297 | + if($is_site_start == true && $_POST['reset'] == 'on') { |
|
| 298 | + $modx->db->update(array('setting_value' => $newid), $tbl_system_settings, "setting_name='site_start'"); |
|
| 299 | + $modx->db->update(array('menuindex' => 0), $tbl_site_content, "id='{$newid}'"); |
|
| 300 | + } |
|
| 301 | + } |
|
| 302 | + } |
|
| 303 | + } |
|
| 304 | 304 | } |
| 305 | 305 | |
| 306 | 306 | function getFiles($directory, $listing = array(), $count = 0) { |
| 307 | - global $_lang; |
|
| 308 | - global $filesfound; |
|
| 309 | - $dummy = $count; |
|
| 310 | - if( ! empty($directory) && $files = scandir($directory)) { |
|
| 311 | - foreach($files as $file) { |
|
| 312 | - if($file == '.' || $file == '..') { |
|
| 313 | - continue; |
|
| 314 | - } elseif($h = @opendir($directory . $file . "/")) { |
|
| 315 | - closedir($h); |
|
| 316 | - $count = -1; |
|
| 317 | - $listing[$file] = getFiles($directory . $file . "/", array(), $count + 1); |
|
| 318 | - } elseif(strpos($file, '.htm') !== false) { |
|
| 319 | - $listing[$dummy] = $file; |
|
| 320 | - $dummy = $dummy + 1; |
|
| 321 | - $filesfound++; |
|
| 322 | - } |
|
| 323 | - } |
|
| 324 | - } else { |
|
| 325 | - echo '<p><span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_no_open_dir"] . $directory . ".</p>"; |
|
| 326 | - } |
|
| 327 | - return ($listing); |
|
| 307 | + global $_lang; |
|
| 308 | + global $filesfound; |
|
| 309 | + $dummy = $count; |
|
| 310 | + if( ! empty($directory) && $files = scandir($directory)) { |
|
| 311 | + foreach($files as $file) { |
|
| 312 | + if($file == '.' || $file == '..') { |
|
| 313 | + continue; |
|
| 314 | + } elseif($h = @opendir($directory . $file . "/")) { |
|
| 315 | + closedir($h); |
|
| 316 | + $count = -1; |
|
| 317 | + $listing[$file] = getFiles($directory . $file . "/", array(), $count + 1); |
|
| 318 | + } elseif(strpos($file, '.htm') !== false) { |
|
| 319 | + $listing[$dummy] = $file; |
|
| 320 | + $dummy = $dummy + 1; |
|
| 321 | + $filesfound++; |
|
| 322 | + } |
|
| 323 | + } |
|
| 324 | + } else { |
|
| 325 | + echo '<p><span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_no_open_dir"] . $directory . ".</p>"; |
|
| 326 | + } |
|
| 327 | + return ($listing); |
|
| 328 | 328 | } |
| 329 | 329 | |
| 330 | 330 | function getFileContent($filepath) { |
| 331 | - global $_lang; |
|
| 332 | - // get the file |
|
| 333 | - if(!$buffer = file_get_contents($filepath)) { |
|
| 334 | - echo '<p><span class="fail">' . $_lang['import_site_failed'] . "</span> " . $_lang["import_site_failed_no_retrieve_file"] . $filepath . ".</p>"; |
|
| 335 | - } else { |
|
| 336 | - return $buffer; |
|
| 337 | - } |
|
| 331 | + global $_lang; |
|
| 332 | + // get the file |
|
| 333 | + if(!$buffer = file_get_contents($filepath)) { |
|
| 334 | + echo '<p><span class="fail">' . $_lang['import_site_failed'] . "</span> " . $_lang["import_site_failed_no_retrieve_file"] . $filepath . ".</p>"; |
|
| 335 | + } else { |
|
| 336 | + return $buffer; |
|
| 337 | + } |
|
| 338 | 338 | } |
| 339 | 339 | |
| 340 | 340 | function pop_index($array) { |
| 341 | - $new_array = array(); |
|
| 342 | - foreach($array as $k => $v) { |
|
| 343 | - if($v !== 'index.html' && $v !== 'index.htm') { |
|
| 344 | - $new_array[$k] = $v; |
|
| 345 | - } else { |
|
| 346 | - array_unshift($new_array, $v); |
|
| 347 | - } |
|
| 348 | - } |
|
| 349 | - foreach($array as $k => $v) { |
|
| 350 | - if(is_array($v)) { |
|
| 351 | - $new_array[$k] = $v; |
|
| 352 | - } |
|
| 353 | - } |
|
| 354 | - return $new_array; |
|
| 341 | + $new_array = array(); |
|
| 342 | + foreach($array as $k => $v) { |
|
| 343 | + if($v !== 'index.html' && $v !== 'index.htm') { |
|
| 344 | + $new_array[$k] = $v; |
|
| 345 | + } else { |
|
| 346 | + array_unshift($new_array, $v); |
|
| 347 | + } |
|
| 348 | + } |
|
| 349 | + foreach($array as $k => $v) { |
|
| 350 | + if(is_array($v)) { |
|
| 351 | + $new_array[$k] = $v; |
|
| 352 | + } |
|
| 353 | + } |
|
| 354 | + return $new_array; |
|
| 355 | 355 | } |
| 356 | 356 | |
| 357 | 357 | function treatContent($src, $filename, $alias) { |
| 358 | - global $modx; |
|
| 359 | - |
|
| 360 | - $src = mb_convert_encoding($src, $modx->config['modx_charset'], 'UTF-8,SJIS-win,eucJP-win,SJIS,EUC-JP,ASCII'); |
|
| 361 | - |
|
| 362 | - if(preg_match("@<title>(.*)</title>@i", $src, $matches)) { |
|
| 363 | - $pagetitle = ($matches[1] !== '') ? $matches[1] : $filename; |
|
| 364 | - $pagetitle = str_replace('[*pagetitle*]', '', $pagetitle); |
|
| 365 | - } else { |
|
| 366 | - $pagetitle = $alias; |
|
| 367 | - } |
|
| 368 | - if(!$pagetitle) { |
|
| 369 | - $pagetitle = $alias; |
|
| 370 | - } |
|
| 371 | - |
|
| 372 | - if(preg_match('@<meta[^>]+"description"[^>]+content=[\'"](.*)[\'"].+>@i', $src, $matches)) { |
|
| 373 | - $description = ($matches[1] !== '') ? $matches[1] : $filename; |
|
| 374 | - $description = str_replace('[*description*]', '', $description); |
|
| 375 | - } else { |
|
| 376 | - $description = ''; |
|
| 377 | - } |
|
| 378 | - |
|
| 379 | - if((preg_match("@<body[^>]*>(.*)[^<]+</body>@is", $src, $matches)) && $_POST['object'] == 'body') { |
|
| 380 | - $content = $matches[1]; |
|
| 381 | - } else { |
|
| 382 | - $content = $src; |
|
| 383 | - $s = '/(<meta[^>]+charset\s*=)[^>"\'=]+(.+>)/i'; |
|
| 384 | - $r = '$1' . $modx->config['modx_charset'] . '$2'; |
|
| 385 | - $content = preg_replace($s, $r, $content); |
|
| 386 | - $content = preg_replace('@<title>.*</title>@i', "<title>[*pagetitle*]</title>", $content); |
|
| 387 | - } |
|
| 388 | - $content = str_replace('[*content*]', '[ *content* ]', $content); |
|
| 389 | - $content = trim($content); |
|
| 390 | - $pagetitle = $modx->db->escape($pagetitle); |
|
| 391 | - return array( |
|
| 392 | - $pagetitle, |
|
| 393 | - $content, |
|
| 394 | - $description |
|
| 395 | - ); |
|
| 358 | + global $modx; |
|
| 359 | + |
|
| 360 | + $src = mb_convert_encoding($src, $modx->config['modx_charset'], 'UTF-8,SJIS-win,eucJP-win,SJIS,EUC-JP,ASCII'); |
|
| 361 | + |
|
| 362 | + if(preg_match("@<title>(.*)</title>@i", $src, $matches)) { |
|
| 363 | + $pagetitle = ($matches[1] !== '') ? $matches[1] : $filename; |
|
| 364 | + $pagetitle = str_replace('[*pagetitle*]', '', $pagetitle); |
|
| 365 | + } else { |
|
| 366 | + $pagetitle = $alias; |
|
| 367 | + } |
|
| 368 | + if(!$pagetitle) { |
|
| 369 | + $pagetitle = $alias; |
|
| 370 | + } |
|
| 371 | + |
|
| 372 | + if(preg_match('@<meta[^>]+"description"[^>]+content=[\'"](.*)[\'"].+>@i', $src, $matches)) { |
|
| 373 | + $description = ($matches[1] !== '') ? $matches[1] : $filename; |
|
| 374 | + $description = str_replace('[*description*]', '', $description); |
|
| 375 | + } else { |
|
| 376 | + $description = ''; |
|
| 377 | + } |
|
| 378 | + |
|
| 379 | + if((preg_match("@<body[^>]*>(.*)[^<]+</body>@is", $src, $matches)) && $_POST['object'] == 'body') { |
|
| 380 | + $content = $matches[1]; |
|
| 381 | + } else { |
|
| 382 | + $content = $src; |
|
| 383 | + $s = '/(<meta[^>]+charset\s*=)[^>"\'=]+(.+>)/i'; |
|
| 384 | + $r = '$1' . $modx->config['modx_charset'] . '$2'; |
|
| 385 | + $content = preg_replace($s, $r, $content); |
|
| 386 | + $content = preg_replace('@<title>.*</title>@i', "<title>[*pagetitle*]</title>", $content); |
|
| 387 | + } |
|
| 388 | + $content = str_replace('[*content*]', '[ *content* ]', $content); |
|
| 389 | + $content = trim($content); |
|
| 390 | + $pagetitle = $modx->db->escape($pagetitle); |
|
| 391 | + return array( |
|
| 392 | + $pagetitle, |
|
| 393 | + $content, |
|
| 394 | + $description |
|
| 395 | + ); |
|
| 396 | 396 | } |
| 397 | 397 | |
| 398 | 398 | function convertLink() { |
| 399 | - global $modx; |
|
| 400 | - $tbl_site_content = $modx->getFullTableName('site_content'); |
|
| 399 | + global $modx; |
|
| 400 | + $tbl_site_content = $modx->getFullTableName('site_content'); |
|
| 401 | 401 | |
| 402 | - $rs = $modx->db->select('id,content', $tbl_site_content); |
|
| 403 | - $p = array(); |
|
| 402 | + $rs = $modx->db->select('id,content', $tbl_site_content); |
|
| 403 | + $p = array(); |
|
| 404 | 404 | $target = array(); |
| 405 | - $dir = ''; |
|
| 406 | - while($row = $modx->db->getRow($rs)) { |
|
| 407 | - $id = $row['id']; |
|
| 408 | - $array = explode('<a href=', $row['content']); |
|
| 409 | - $c = 0; |
|
| 410 | - foreach($array as $v) { |
|
| 411 | - if($v[0] === '"') { |
|
| 412 | - $v = substr($v, 1); |
|
| 413 | - list($href, $v) = explode('"', $v, 2); |
|
| 414 | - $_ = $href; |
|
| 415 | - if(strpos($_, $modx->config['site_url']) !== false) { |
|
| 416 | - $_ = $modx->config['base_url'] . str_replace($modx->config['site_url'], '', $_); |
|
| 417 | - } |
|
| 418 | - if($_[0] === '/') { |
|
| 419 | - $_ = substr($_, 1); |
|
| 420 | - } |
|
| 421 | - $_ = str_replace('/index.html', '.html', $_); |
|
| 422 | - $level = substr_count($_, '../'); |
|
| 423 | - if(1 < $level) { |
|
| 424 | - if(!isset($p[$id])) { |
|
| 425 | - $p[$id] = $modx->getParentIds($id); |
|
| 426 | - } |
|
| 427 | - $k = array_keys($p[$id]); |
|
| 428 | - while(0 < $level) { |
|
| 429 | - $dir = array_shift($k); |
|
| 430 | - $level--; |
|
| 431 | - } |
|
| 432 | - if($dir != '') { |
|
| 433 | - $dir .= '/'; |
|
| 434 | - } |
|
| 435 | - } else { |
|
| 436 | - $dir = ''; |
|
| 437 | - } |
|
| 438 | - |
|
| 439 | - $_ = trim($_, './'); |
|
| 440 | - if(strpos($_, '/') !== false) { |
|
| 441 | - $_ = substr($_, strrpos($_, '/')); |
|
| 442 | - } |
|
| 443 | - $_ = $dir . str_replace('.html', '', $_); |
|
| 444 | - if(!isset($target[$_])) { |
|
| 445 | - $target[$_] = $modx->getIdFromAlias($_); |
|
| 446 | - } |
|
| 447 | - $target[$_] = trim($target[$_]); |
|
| 448 | - if(!empty($target[$_])) { |
|
| 449 | - $href = '[~' . $target[$_] . '~]'; |
|
| 450 | - } |
|
| 451 | - $array[$c] = '<a href="' . $href . '"' . $v; |
|
| 452 | - } |
|
| 453 | - $c++; |
|
| 454 | - } |
|
| 455 | - $content = implode('', $array); |
|
| 456 | - $f['content'] = $modx->db->escape($content); |
|
| 457 | - $modx->db->update($f, $tbl_site_content, "id='{$id}'"); |
|
| 458 | - } |
|
| 405 | + $dir = ''; |
|
| 406 | + while($row = $modx->db->getRow($rs)) { |
|
| 407 | + $id = $row['id']; |
|
| 408 | + $array = explode('<a href=', $row['content']); |
|
| 409 | + $c = 0; |
|
| 410 | + foreach($array as $v) { |
|
| 411 | + if($v[0] === '"') { |
|
| 412 | + $v = substr($v, 1); |
|
| 413 | + list($href, $v) = explode('"', $v, 2); |
|
| 414 | + $_ = $href; |
|
| 415 | + if(strpos($_, $modx->config['site_url']) !== false) { |
|
| 416 | + $_ = $modx->config['base_url'] . str_replace($modx->config['site_url'], '', $_); |
|
| 417 | + } |
|
| 418 | + if($_[0] === '/') { |
|
| 419 | + $_ = substr($_, 1); |
|
| 420 | + } |
|
| 421 | + $_ = str_replace('/index.html', '.html', $_); |
|
| 422 | + $level = substr_count($_, '../'); |
|
| 423 | + if(1 < $level) { |
|
| 424 | + if(!isset($p[$id])) { |
|
| 425 | + $p[$id] = $modx->getParentIds($id); |
|
| 426 | + } |
|
| 427 | + $k = array_keys($p[$id]); |
|
| 428 | + while(0 < $level) { |
|
| 429 | + $dir = array_shift($k); |
|
| 430 | + $level--; |
|
| 431 | + } |
|
| 432 | + if($dir != '') { |
|
| 433 | + $dir .= '/'; |
|
| 434 | + } |
|
| 435 | + } else { |
|
| 436 | + $dir = ''; |
|
| 437 | + } |
|
| 438 | + |
|
| 439 | + $_ = trim($_, './'); |
|
| 440 | + if(strpos($_, '/') !== false) { |
|
| 441 | + $_ = substr($_, strrpos($_, '/')); |
|
| 442 | + } |
|
| 443 | + $_ = $dir . str_replace('.html', '', $_); |
|
| 444 | + if(!isset($target[$_])) { |
|
| 445 | + $target[$_] = $modx->getIdFromAlias($_); |
|
| 446 | + } |
|
| 447 | + $target[$_] = trim($target[$_]); |
|
| 448 | + if(!empty($target[$_])) { |
|
| 449 | + $href = '[~' . $target[$_] . '~]'; |
|
| 450 | + } |
|
| 451 | + $array[$c] = '<a href="' . $href . '"' . $v; |
|
| 452 | + } |
|
| 453 | + $c++; |
|
| 454 | + } |
|
| 455 | + $content = implode('', $array); |
|
| 456 | + $f['content'] = $modx->db->escape($content); |
|
| 457 | + $modx->db->update($f, $tbl_site_content, "id='{$id}'"); |
|
| 458 | + } |
|
| 459 | 459 | } |
@@ -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('import_static')) { |
|
| 5 | +if (!$modx->hasPermission('import_static')) { |
|
| 6 | 6 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
| 7 | 7 | } |
| 8 | 8 | |
@@ -43,8 +43,8 @@ discard block |
||
| 43 | 43 | <div class="tab-page"> |
| 44 | 44 | <div class="container container-body"> |
| 45 | 45 | <?php |
| 46 | - if(!isset($_POST['import'])) { |
|
| 47 | - echo "<div class=\"element-edit-message\">" . $_lang['import_site_message'] . "</div>"; |
|
| 46 | + if (!isset($_POST['import'])) { |
|
| 47 | + echo "<div class=\"element-edit-message\">".$_lang['import_site_message']."</div>"; |
|
| 48 | 48 | ?> |
| 49 | 49 | <form action="index.php" method="post" name="importFrm"> |
| 50 | 50 | <input type="hidden" name="import" value="import" /> |
@@ -101,14 +101,14 @@ discard block |
||
| 101 | 101 | </div> |
| 102 | 102 | |
| 103 | 103 | <?php |
| 104 | -function run() { |
|
| 104 | +function run(){ |
|
| 105 | 105 | global $modx, $_lang; |
| 106 | 106 | |
| 107 | 107 | $tbl_site_content = $modx->getFullTableName('site_content'); |
| 108 | 108 | $output = ''; |
| 109 | 109 | $maxtime = $_POST['maxtime']; |
| 110 | 110 | |
| 111 | - if(!is_numeric($maxtime)) { |
|
| 111 | + if (!is_numeric($maxtime)) { |
|
| 112 | 112 | $maxtime = 30; |
| 113 | 113 | } |
| 114 | 114 | |
@@ -119,17 +119,17 @@ discard block |
||
| 119 | 119 | $mtime = $mtime[1] + $mtime[0]; |
| 120 | 120 | $importstart = $mtime; |
| 121 | 121 | |
| 122 | - if($_POST['reset'] == 'on') { |
|
| 122 | + if ($_POST['reset'] == 'on') { |
|
| 123 | 123 | $modx->db->truncate($tbl_site_content); |
| 124 | 124 | $modx->db->query("ALTER TABLE {$tbl_site_content} AUTO_INCREMENT = 1"); |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | $parent = intval($_POST['parent']); |
| 128 | 128 | |
| 129 | - if(is_dir(MODX_BASE_PATH . 'temp/import')) { |
|
| 130 | - $filedir = MODX_BASE_PATH . 'temp/import/'; |
|
| 131 | - } elseif(is_dir(MODX_BASE_PATH . 'assets/import')) { |
|
| 132 | - $filedir = MODX_BASE_PATH . 'assets/import/'; |
|
| 129 | + if (is_dir(MODX_BASE_PATH.'temp/import')) { |
|
| 130 | + $filedir = MODX_BASE_PATH.'temp/import/'; |
|
| 131 | + } elseif (is_dir(MODX_BASE_PATH.'assets/import')) { |
|
| 132 | + $filedir = MODX_BASE_PATH.'assets/import/'; |
|
| 133 | 133 | } else { |
| 134 | 134 | $filedir = ''; |
| 135 | 135 | } |
@@ -140,10 +140,10 @@ discard block |
||
| 140 | 140 | $files = pop_index($files); |
| 141 | 141 | |
| 142 | 142 | // no. of files to import |
| 143 | - $output .= sprintf('<p>' . $_lang['import_files_found'] . '</p>', $filesfound); |
|
| 143 | + $output .= sprintf('<p>'.$_lang['import_files_found'].'</p>', $filesfound); |
|
| 144 | 144 | |
| 145 | 145 | // import files |
| 146 | - if(0 < count($files)) { |
|
| 146 | + if (0 < count($files)) { |
|
| 147 | 147 | $modx->db->update(array('isfolder' => 1), $tbl_site_content, "id='{$parent}'"); |
| 148 | 148 | importFiles($parent, $filedir, $files, 'root'); |
| 149 | 149 | } |
@@ -153,16 +153,16 @@ discard block |
||
| 153 | 153 | $mtime = $mtime[1] + $mtime[0]; |
| 154 | 154 | $importend = $mtime; |
| 155 | 155 | $totaltime = ($importend - $importstart); |
| 156 | - $output .= sprintf('<p>' . $_lang['import_site_time'] . '</p>', round($totaltime, 3)); |
|
| 156 | + $output .= sprintf('<p>'.$_lang['import_site_time'].'</p>', round($totaltime, 3)); |
|
| 157 | 157 | |
| 158 | - if($_POST['convert_link'] == 'on') { |
|
| 158 | + if ($_POST['convert_link'] == 'on') { |
|
| 159 | 159 | convertLink(); |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | return $output; |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | -function importFiles($parent, $filedir, $files, $mode) { |
|
| 165 | +function importFiles($parent, $filedir, $files, $mode){ |
|
| 166 | 166 | global $modx; |
| 167 | 167 | global $_lang, $allowedfiles; |
| 168 | 168 | global $search_default, $cache_default, $publish_default; |
@@ -171,21 +171,21 @@ discard block |
||
| 171 | 171 | $tbl_system_settings = $modx->getFullTableName('system_settings'); |
| 172 | 172 | |
| 173 | 173 | $createdby = $modx->getLoginUserID(); |
| 174 | - if(!is_array($files)) { |
|
| 174 | + if (!is_array($files)) { |
|
| 175 | 175 | return; |
| 176 | 176 | } |
| 177 | - if($_POST['object'] == 'all') { |
|
| 177 | + if ($_POST['object'] == 'all') { |
|
| 178 | 178 | $modx->config['default_template'] = '0'; |
| 179 | 179 | $richtext = '0'; |
| 180 | 180 | } else { |
| 181 | 181 | $richtext = '1'; |
| 182 | 182 | } |
| 183 | 183 | |
| 184 | - foreach($files as $id => $value) { |
|
| 185 | - if(is_array($value)) { |
|
| 184 | + foreach ($files as $id => $value) { |
|
| 185 | + if (is_array($value)) { |
|
| 186 | 186 | // create folder |
| 187 | 187 | $alias = $id; |
| 188 | - printf('<span>' . $_lang['import_site_importing_document'] . '</span>', $alias); |
|
| 188 | + printf('<span>'.$_lang['import_site_importing_document'].'</span>', $alias); |
|
| 189 | 189 | $field = array(); |
| 190 | 190 | $field['type'] = 'document'; |
| 191 | 191 | $field['contentType'] = 'text/html'; |
@@ -200,12 +200,12 @@ discard block |
||
| 200 | 200 | $field['isfolder'] = 1; |
| 201 | 201 | $field['menuindex'] = 1; |
| 202 | 202 | $find = false; |
| 203 | - foreach(array( |
|
| 203 | + foreach (array( |
|
| 204 | 204 | 'index.html', |
| 205 | 205 | 'index.htm' |
| 206 | 206 | ) as $filename) { |
| 207 | - $filepath = $filedir . $alias . '/' . $filename; |
|
| 208 | - if($find === false && file_exists($filepath)) { |
|
| 207 | + $filepath = $filedir.$alias.'/'.$filename; |
|
| 208 | + if ($find === false && file_exists($filepath)) { |
|
| 209 | 209 | $file = getFileContent($filepath); |
| 210 | 210 | list($pagetitle, $content, $description) = treatContent($file, $filename, $alias); |
| 211 | 211 | |
@@ -217,17 +217,17 @@ discard block |
||
| 217 | 217 | $field['createdon'] = $date; |
| 218 | 218 | $field['editedon'] = $date; |
| 219 | 219 | $newid = $modx->db->insert($field, $tbl_site_content); |
| 220 | - if($newid) { |
|
| 220 | + if ($newid) { |
|
| 221 | 221 | $find = true; |
| 222 | - echo ' - <span class="success">' . $_lang['import_site_success'] . '</span><br />' . "\n"; |
|
| 223 | - importFiles($newid, $filedir . $alias . '/', $value, 'sub'); |
|
| 222 | + echo ' - <span class="success">'.$_lang['import_site_success'].'</span><br />'."\n"; |
|
| 223 | + importFiles($newid, $filedir.$alias.'/', $value, 'sub'); |
|
| 224 | 224 | } else { |
| 225 | - echo '<span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_db_error"] . $modx->db->getLastError(); |
|
| 225 | + echo '<span class="fail">'.$_lang["import_site_failed"]."</span> ".$_lang["import_site_failed_db_error"].$modx->db->getLastError(); |
|
| 226 | 226 | exit; |
| 227 | 227 | } |
| 228 | 228 | } |
| 229 | 229 | } |
| 230 | - if($find === false) { |
|
| 230 | + if ($find === false) { |
|
| 231 | 231 | $date = time(); |
| 232 | 232 | $field['pagetitle'] = '---'; |
| 233 | 233 | $field['content'] = ''; |
@@ -235,30 +235,30 @@ discard block |
||
| 235 | 235 | $field['editedon'] = $date; |
| 236 | 236 | $field['hidemenu'] = '1'; |
| 237 | 237 | $newid = $modx->db->insert($field, $tbl_site_content); |
| 238 | - if($newid) { |
|
| 238 | + if ($newid) { |
|
| 239 | 239 | $find = true; |
| 240 | - echo ' - <span class="success">' . $_lang['import_site_success'] . '</span><br />' . "\n"; |
|
| 241 | - importFiles($newid, $filedir . $alias . '/', $value, 'sub'); |
|
| 240 | + echo ' - <span class="success">'.$_lang['import_site_success'].'</span><br />'."\n"; |
|
| 241 | + importFiles($newid, $filedir.$alias.'/', $value, 'sub'); |
|
| 242 | 242 | } else { |
| 243 | - echo '<span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_db_error"] . $modx->db->getLastError(); |
|
| 243 | + echo '<span class="fail">'.$_lang["import_site_failed"]."</span> ".$_lang["import_site_failed_db_error"].$modx->db->getLastError(); |
|
| 244 | 244 | exit; |
| 245 | 245 | } |
| 246 | 246 | } |
| 247 | 247 | } else { |
| 248 | 248 | // create document |
| 249 | - if($mode == 'sub' && $value == 'index.html') { |
|
| 249 | + if ($mode == 'sub' && $value == 'index.html') { |
|
| 250 | 250 | continue; |
| 251 | 251 | } |
| 252 | 252 | $filename = $value; |
| 253 | 253 | $fparts = explode('.', $value); |
| 254 | 254 | $alias = $fparts[0]; |
| 255 | 255 | $ext = (count($fparts) > 1) ? $fparts[count($fparts) - 1] : ""; |
| 256 | - printf("<span>" . $_lang['import_site_importing_document'] . "</span>", $filename); |
|
| 256 | + printf("<span>".$_lang['import_site_importing_document']."</span>", $filename); |
|
| 257 | 257 | |
| 258 | - if(!in_array($ext, $allowedfiles)) { |
|
| 259 | - echo ' - <span class="fail">' . $_lang["import_site_skip"] . '</span><br />' . "\n"; |
|
| 258 | + if (!in_array($ext, $allowedfiles)) { |
|
| 259 | + echo ' - <span class="fail">'.$_lang["import_site_skip"].'</span><br />'."\n"; |
|
| 260 | 260 | } else { |
| 261 | - $filepath = $filedir . $filename; |
|
| 261 | + $filepath = $filedir.$filename; |
|
| 262 | 262 | $file = getFileContent($filepath); |
| 263 | 263 | list($pagetitle, $content, $description) = treatContent($file, $filename, $alias); |
| 264 | 264 | |
@@ -283,18 +283,18 @@ discard block |
||
| 283 | 283 | $field['isfolder'] = 0; |
| 284 | 284 | $field['menuindex'] = ($alias == 'index') ? 0 : 2; |
| 285 | 285 | $newid = $modx->db->insert($field, $tbl_site_content); |
| 286 | - if($newid) { |
|
| 287 | - echo ' - <span class="success">' . $_lang['import_site_success'] . '</span><br />' . "\n"; |
|
| 286 | + if ($newid) { |
|
| 287 | + echo ' - <span class="success">'.$_lang['import_site_success'].'</span><br />'."\n"; |
|
| 288 | 288 | } else { |
| 289 | - echo '<span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_db_error"] . $modx->db->getLastError(); |
|
| 289 | + echo '<span class="fail">'.$_lang["import_site_failed"]."</span> ".$_lang["import_site_failed_db_error"].$modx->db->getLastError(); |
|
| 290 | 290 | exit; |
| 291 | 291 | } |
| 292 | 292 | |
| 293 | 293 | $is_site_start = false; |
| 294 | - if($filename == 'index.html') { |
|
| 294 | + if ($filename == 'index.html') { |
|
| 295 | 295 | $is_site_start = true; |
| 296 | 296 | } |
| 297 | - if($is_site_start == true && $_POST['reset'] == 'on') { |
|
| 297 | + if ($is_site_start == true && $_POST['reset'] == 'on') { |
|
| 298 | 298 | $modx->db->update(array('setting_value' => $newid), $tbl_system_settings, "setting_name='site_start'"); |
| 299 | 299 | $modx->db->update(array('menuindex' => 0), $tbl_site_content, "id='{$newid}'"); |
| 300 | 300 | } |
@@ -303,85 +303,85 @@ discard block |
||
| 303 | 303 | } |
| 304 | 304 | } |
| 305 | 305 | |
| 306 | -function getFiles($directory, $listing = array(), $count = 0) { |
|
| 306 | +function getFiles($directory, $listing = array(), $count = 0){ |
|
| 307 | 307 | global $_lang; |
| 308 | 308 | global $filesfound; |
| 309 | 309 | $dummy = $count; |
| 310 | - if( ! empty($directory) && $files = scandir($directory)) { |
|
| 311 | - foreach($files as $file) { |
|
| 312 | - if($file == '.' || $file == '..') { |
|
| 310 | + if (!empty($directory) && $files = scandir($directory)) { |
|
| 311 | + foreach ($files as $file) { |
|
| 312 | + if ($file == '.' || $file == '..') { |
|
| 313 | 313 | continue; |
| 314 | - } elseif($h = @opendir($directory . $file . "/")) { |
|
| 314 | + } elseif ($h = @opendir($directory.$file."/")) { |
|
| 315 | 315 | closedir($h); |
| 316 | 316 | $count = -1; |
| 317 | - $listing[$file] = getFiles($directory . $file . "/", array(), $count + 1); |
|
| 318 | - } elseif(strpos($file, '.htm') !== false) { |
|
| 317 | + $listing[$file] = getFiles($directory.$file."/", array(), $count + 1); |
|
| 318 | + } elseif (strpos($file, '.htm') !== false) { |
|
| 319 | 319 | $listing[$dummy] = $file; |
| 320 | 320 | $dummy = $dummy + 1; |
| 321 | 321 | $filesfound++; |
| 322 | 322 | } |
| 323 | 323 | } |
| 324 | 324 | } else { |
| 325 | - echo '<p><span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_no_open_dir"] . $directory . ".</p>"; |
|
| 325 | + echo '<p><span class="fail">'.$_lang["import_site_failed"]."</span> ".$_lang["import_site_failed_no_open_dir"].$directory.".</p>"; |
|
| 326 | 326 | } |
| 327 | 327 | return ($listing); |
| 328 | 328 | } |
| 329 | 329 | |
| 330 | -function getFileContent($filepath) { |
|
| 330 | +function getFileContent($filepath){ |
|
| 331 | 331 | global $_lang; |
| 332 | 332 | // get the file |
| 333 | - if(!$buffer = file_get_contents($filepath)) { |
|
| 334 | - echo '<p><span class="fail">' . $_lang['import_site_failed'] . "</span> " . $_lang["import_site_failed_no_retrieve_file"] . $filepath . ".</p>"; |
|
| 333 | + if (!$buffer = file_get_contents($filepath)) { |
|
| 334 | + echo '<p><span class="fail">'.$_lang['import_site_failed']."</span> ".$_lang["import_site_failed_no_retrieve_file"].$filepath.".</p>"; |
|
| 335 | 335 | } else { |
| 336 | 336 | return $buffer; |
| 337 | 337 | } |
| 338 | 338 | } |
| 339 | 339 | |
| 340 | -function pop_index($array) { |
|
| 340 | +function pop_index($array){ |
|
| 341 | 341 | $new_array = array(); |
| 342 | - foreach($array as $k => $v) { |
|
| 343 | - if($v !== 'index.html' && $v !== 'index.htm') { |
|
| 342 | + foreach ($array as $k => $v) { |
|
| 343 | + if ($v !== 'index.html' && $v !== 'index.htm') { |
|
| 344 | 344 | $new_array[$k] = $v; |
| 345 | 345 | } else { |
| 346 | 346 | array_unshift($new_array, $v); |
| 347 | 347 | } |
| 348 | 348 | } |
| 349 | - foreach($array as $k => $v) { |
|
| 350 | - if(is_array($v)) { |
|
| 349 | + foreach ($array as $k => $v) { |
|
| 350 | + if (is_array($v)) { |
|
| 351 | 351 | $new_array[$k] = $v; |
| 352 | 352 | } |
| 353 | 353 | } |
| 354 | 354 | return $new_array; |
| 355 | 355 | } |
| 356 | 356 | |
| 357 | -function treatContent($src, $filename, $alias) { |
|
| 357 | +function treatContent($src, $filename, $alias){ |
|
| 358 | 358 | global $modx; |
| 359 | 359 | |
| 360 | 360 | $src = mb_convert_encoding($src, $modx->config['modx_charset'], 'UTF-8,SJIS-win,eucJP-win,SJIS,EUC-JP,ASCII'); |
| 361 | 361 | |
| 362 | - if(preg_match("@<title>(.*)</title>@i", $src, $matches)) { |
|
| 362 | + if (preg_match("@<title>(.*)</title>@i", $src, $matches)) { |
|
| 363 | 363 | $pagetitle = ($matches[1] !== '') ? $matches[1] : $filename; |
| 364 | 364 | $pagetitle = str_replace('[*pagetitle*]', '', $pagetitle); |
| 365 | 365 | } else { |
| 366 | 366 | $pagetitle = $alias; |
| 367 | 367 | } |
| 368 | - if(!$pagetitle) { |
|
| 368 | + if (!$pagetitle) { |
|
| 369 | 369 | $pagetitle = $alias; |
| 370 | 370 | } |
| 371 | 371 | |
| 372 | - if(preg_match('@<meta[^>]+"description"[^>]+content=[\'"](.*)[\'"].+>@i', $src, $matches)) { |
|
| 372 | + if (preg_match('@<meta[^>]+"description"[^>]+content=[\'"](.*)[\'"].+>@i', $src, $matches)) { |
|
| 373 | 373 | $description = ($matches[1] !== '') ? $matches[1] : $filename; |
| 374 | 374 | $description = str_replace('[*description*]', '', $description); |
| 375 | 375 | } else { |
| 376 | 376 | $description = ''; |
| 377 | 377 | } |
| 378 | 378 | |
| 379 | - if((preg_match("@<body[^>]*>(.*)[^<]+</body>@is", $src, $matches)) && $_POST['object'] == 'body') { |
|
| 379 | + if ((preg_match("@<body[^>]*>(.*)[^<]+</body>@is", $src, $matches)) && $_POST['object'] == 'body') { |
|
| 380 | 380 | $content = $matches[1]; |
| 381 | 381 | } else { |
| 382 | 382 | $content = $src; |
| 383 | 383 | $s = '/(<meta[^>]+charset\s*=)[^>"\'=]+(.+>)/i'; |
| 384 | - $r = '$1' . $modx->config['modx_charset'] . '$2'; |
|
| 384 | + $r = '$1'.$modx->config['modx_charset'].'$2'; |
|
| 385 | 385 | $content = preg_replace($s, $r, $content); |
| 386 | 386 | $content = preg_replace('@<title>.*</title>@i', "<title>[*pagetitle*]</title>", $content); |
| 387 | 387 | } |
@@ -395,7 +395,7 @@ discard block |
||
| 395 | 395 | ); |
| 396 | 396 | } |
| 397 | 397 | |
| 398 | -function convertLink() { |
|
| 398 | +function convertLink(){ |
|
| 399 | 399 | global $modx; |
| 400 | 400 | $tbl_site_content = $modx->getFullTableName('site_content'); |
| 401 | 401 | |
@@ -403,33 +403,33 @@ discard block |
||
| 403 | 403 | $p = array(); |
| 404 | 404 | $target = array(); |
| 405 | 405 | $dir = ''; |
| 406 | - while($row = $modx->db->getRow($rs)) { |
|
| 406 | + while ($row = $modx->db->getRow($rs)) { |
|
| 407 | 407 | $id = $row['id']; |
| 408 | 408 | $array = explode('<a href=', $row['content']); |
| 409 | 409 | $c = 0; |
| 410 | - foreach($array as $v) { |
|
| 411 | - if($v[0] === '"') { |
|
| 410 | + foreach ($array as $v) { |
|
| 411 | + if ($v[0] === '"') { |
|
| 412 | 412 | $v = substr($v, 1); |
| 413 | 413 | list($href, $v) = explode('"', $v, 2); |
| 414 | 414 | $_ = $href; |
| 415 | - if(strpos($_, $modx->config['site_url']) !== false) { |
|
| 416 | - $_ = $modx->config['base_url'] . str_replace($modx->config['site_url'], '', $_); |
|
| 415 | + if (strpos($_, $modx->config['site_url']) !== false) { |
|
| 416 | + $_ = $modx->config['base_url'].str_replace($modx->config['site_url'], '', $_); |
|
| 417 | 417 | } |
| 418 | - if($_[0] === '/') { |
|
| 418 | + if ($_[0] === '/') { |
|
| 419 | 419 | $_ = substr($_, 1); |
| 420 | 420 | } |
| 421 | 421 | $_ = str_replace('/index.html', '.html', $_); |
| 422 | 422 | $level = substr_count($_, '../'); |
| 423 | - if(1 < $level) { |
|
| 424 | - if(!isset($p[$id])) { |
|
| 423 | + if (1 < $level) { |
|
| 424 | + if (!isset($p[$id])) { |
|
| 425 | 425 | $p[$id] = $modx->getParentIds($id); |
| 426 | 426 | } |
| 427 | 427 | $k = array_keys($p[$id]); |
| 428 | - while(0 < $level) { |
|
| 428 | + while (0 < $level) { |
|
| 429 | 429 | $dir = array_shift($k); |
| 430 | 430 | $level--; |
| 431 | 431 | } |
| 432 | - if($dir != '') { |
|
| 432 | + if ($dir != '') { |
|
| 433 | 433 | $dir .= '/'; |
| 434 | 434 | } |
| 435 | 435 | } else { |
@@ -437,18 +437,18 @@ discard block |
||
| 437 | 437 | } |
| 438 | 438 | |
| 439 | 439 | $_ = trim($_, './'); |
| 440 | - if(strpos($_, '/') !== false) { |
|
| 440 | + if (strpos($_, '/') !== false) { |
|
| 441 | 441 | $_ = substr($_, strrpos($_, '/')); |
| 442 | 442 | } |
| 443 | - $_ = $dir . str_replace('.html', '', $_); |
|
| 444 | - if(!isset($target[$_])) { |
|
| 443 | + $_ = $dir.str_replace('.html', '', $_); |
|
| 444 | + if (!isset($target[$_])) { |
|
| 445 | 445 | $target[$_] = $modx->getIdFromAlias($_); |
| 446 | 446 | } |
| 447 | 447 | $target[$_] = trim($target[$_]); |
| 448 | - if(!empty($target[$_])) { |
|
| 449 | - $href = '[~' . $target[$_] . '~]'; |
|
| 448 | + if (!empty($target[$_])) { |
|
| 449 | + $href = '[~'.$target[$_].'~]'; |
|
| 450 | 450 | } |
| 451 | - $array[$c] = '<a href="' . $href . '"' . $v; |
|
| 451 | + $array[$c] = '<a href="'.$href.'"'.$v; |
|
| 452 | 452 | } |
| 453 | 453 | $c++; |
| 454 | 454 | } |
@@ -101,7 +101,8 @@ discard block |
||
| 101 | 101 | </div> |
| 102 | 102 | |
| 103 | 103 | <?php |
| 104 | -function run() { |
|
| 104 | +function run() |
|
| 105 | +{ |
|
| 105 | 106 | global $modx, $_lang; |
| 106 | 107 | |
| 107 | 108 | $tbl_site_content = $modx->getFullTableName('site_content'); |
@@ -162,7 +163,8 @@ discard block |
||
| 162 | 163 | return $output; |
| 163 | 164 | } |
| 164 | 165 | |
| 165 | -function importFiles($parent, $filedir, $files, $mode) { |
|
| 166 | +function importFiles($parent, $filedir, $files, $mode) |
|
| 167 | +{ |
|
| 166 | 168 | global $modx; |
| 167 | 169 | global $_lang, $allowedfiles; |
| 168 | 170 | global $search_default, $cache_default, $publish_default; |
@@ -303,7 +305,8 @@ discard block |
||
| 303 | 305 | } |
| 304 | 306 | } |
| 305 | 307 | |
| 306 | -function getFiles($directory, $listing = array(), $count = 0) { |
|
| 308 | +function getFiles($directory, $listing = array(), $count = 0) |
|
| 309 | +{ |
|
| 307 | 310 | global $_lang; |
| 308 | 311 | global $filesfound; |
| 309 | 312 | $dummy = $count; |
@@ -327,7 +330,8 @@ discard block |
||
| 327 | 330 | return ($listing); |
| 328 | 331 | } |
| 329 | 332 | |
| 330 | -function getFileContent($filepath) { |
|
| 333 | +function getFileContent($filepath) |
|
| 334 | +{ |
|
| 331 | 335 | global $_lang; |
| 332 | 336 | // get the file |
| 333 | 337 | if(!$buffer = file_get_contents($filepath)) { |
@@ -337,7 +341,8 @@ discard block |
||
| 337 | 341 | } |
| 338 | 342 | } |
| 339 | 343 | |
| 340 | -function pop_index($array) { |
|
| 344 | +function pop_index($array) |
|
| 345 | +{ |
|
| 341 | 346 | $new_array = array(); |
| 342 | 347 | foreach($array as $k => $v) { |
| 343 | 348 | if($v !== 'index.html' && $v !== 'index.htm') { |
@@ -354,7 +359,8 @@ discard block |
||
| 354 | 359 | return $new_array; |
| 355 | 360 | } |
| 356 | 361 | |
| 357 | -function treatContent($src, $filename, $alias) { |
|
| 362 | +function treatContent($src, $filename, $alias) |
|
| 363 | +{ |
|
| 358 | 364 | global $modx; |
| 359 | 365 | |
| 360 | 366 | $src = mb_convert_encoding($src, $modx->config['modx_charset'], 'UTF-8,SJIS-win,eucJP-win,SJIS,EUC-JP,ASCII'); |
@@ -395,7 +401,8 @@ discard block |
||
| 395 | 401 | ); |
| 396 | 402 | } |
| 397 | 403 | |
| 398 | -function convertLink() { |
|
| 404 | +function convertLink() |
|
| 405 | +{ |
|
| 399 | 406 | global $modx; |
| 400 | 407 | $tbl_site_content = $modx->getFullTableName('site_content'); |
| 401 | 408 | |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
| 2 | +if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
| 3 | 3 | die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
| 4 | 4 | } |
| 5 | 5 | if (!$modx->hasPermission('file_manager')) { |
@@ -9,15 +9,15 @@ discard block |
||
| 9 | 9 | $newToken = makeToken(); |
| 10 | 10 | |
| 11 | 11 | // settings |
| 12 | -$theme_image_path = $modx->config['site_manager_url'] . 'media/style/' . $modx->config['manager_theme'] . '/images/'; |
|
| 12 | +$theme_image_path = $modx->config['site_manager_url'].'media/style/'.$modx->config['manager_theme'].'/images/'; |
|
| 13 | 13 | $excludes = array( |
| 14 | 14 | '.', |
| 15 | 15 | '..', |
| 16 | 16 | '.svn' |
| 17 | 17 | ); |
| 18 | -$alias_suffix = (!empty($friendly_url_suffix)) ? ',' . ltrim($friendly_url_suffix, '.') : ''; |
|
| 19 | -$editablefiles = explode(',', 'txt,php,tpl,less,sass,shtml,html,htm,xml,js,css,pageCache,htaccess,json' . $alias_suffix); |
|
| 20 | -$inlineviewablefiles = explode(',', 'txt,php,tpl,less,sass,html,htm,xml,js,css,pageCache,htaccess,json' . $alias_suffix); |
|
| 18 | +$alias_suffix = (!empty($friendly_url_suffix)) ? ','.ltrim($friendly_url_suffix, '.') : ''; |
|
| 19 | +$editablefiles = explode(',', 'txt,php,tpl,less,sass,shtml,html,htm,xml,js,css,pageCache,htaccess,json'.$alias_suffix); |
|
| 20 | +$inlineviewablefiles = explode(',', 'txt,php,tpl,less,sass,html,htm,xml,js,css,pageCache,htaccess,json'.$alias_suffix); |
|
| 21 | 21 | $viewablefiles = explode(',', 'jpg,gif,png,ico'); |
| 22 | 22 | |
| 23 | 23 | $editablefiles = add_dot($editablefiles); |
@@ -30,31 +30,31 @@ discard block |
||
| 30 | 30 | { |
| 31 | 31 | */ |
| 32 | 32 | $protected_path[] = $modx->config['site_manager_path']; |
| 33 | -$protected_path[] = $modx->config['base_path'] . 'temp/backup'; |
|
| 34 | -$protected_path[] = $modx->config['base_path'] . 'assets/backup'; |
|
| 33 | +$protected_path[] = $modx->config['base_path'].'temp/backup'; |
|
| 34 | +$protected_path[] = $modx->config['base_path'].'assets/backup'; |
|
| 35 | 35 | |
| 36 | 36 | if (!$modx->hasPermission('save_plugin')) { |
| 37 | - $protected_path[] = $modx->config['base_path'] . 'assets/plugins'; |
|
| 37 | + $protected_path[] = $modx->config['base_path'].'assets/plugins'; |
|
| 38 | 38 | } |
| 39 | 39 | if (!$modx->hasPermission('save_snippet')) { |
| 40 | - $protected_path[] = $modx->config['base_path'] . 'assets/snippets'; |
|
| 40 | + $protected_path[] = $modx->config['base_path'].'assets/snippets'; |
|
| 41 | 41 | } |
| 42 | 42 | if (!$modx->hasPermission('save_template')) { |
| 43 | - $protected_path[] = $modx->config['base_path'] . 'assets/templates'; |
|
| 43 | + $protected_path[] = $modx->config['base_path'].'assets/templates'; |
|
| 44 | 44 | } |
| 45 | 45 | if (!$modx->hasPermission('save_module')) { |
| 46 | - $protected_path[] = $modx->config['base_path'] . 'assets/modules'; |
|
| 46 | + $protected_path[] = $modx->config['base_path'].'assets/modules'; |
|
| 47 | 47 | } |
| 48 | 48 | if (!$modx->hasPermission('empty_cache')) { |
| 49 | - $protected_path[] = $modx->config['base_path'] . 'assets/cache'; |
|
| 49 | + $protected_path[] = $modx->config['base_path'].'assets/cache'; |
|
| 50 | 50 | } |
| 51 | 51 | if (!$modx->hasPermission('import_static')) { |
| 52 | - $protected_path[] = $modx->config['base_path'] . 'temp/import'; |
|
| 53 | - $protected_path[] = $modx->config['base_path'] . 'assets/import'; |
|
| 52 | + $protected_path[] = $modx->config['base_path'].'temp/import'; |
|
| 53 | + $protected_path[] = $modx->config['base_path'].'assets/import'; |
|
| 54 | 54 | } |
| 55 | 55 | if (!$modx->hasPermission('export_static')) { |
| 56 | - $protected_path[] = $modx->config['base_path'] . 'temp/export'; |
|
| 57 | - $protected_path[] = $modx->config['base_path'] . 'assets/export'; |
|
| 56 | + $protected_path[] = $modx->config['base_path'].'temp/export'; |
|
| 57 | + $protected_path[] = $modx->config['base_path'].'assets/export'; |
|
| 58 | 58 | } |
| 59 | 59 | /* |
| 60 | 60 | } |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | { |
| 80 | 80 | $count = count($array); |
| 81 | 81 | for ($i = 0; $i < $count; $i++) { |
| 82 | - $array[$i] = '.' . strtolower(trim($array[$i])); // add a dot :) |
|
| 82 | + $array[$i] = '.'.strtolower(trim($array[$i])); // add a dot :) |
|
| 83 | 83 | } |
| 84 | 84 | return $array; |
| 85 | 85 | } |
@@ -104,15 +104,15 @@ discard block |
||
| 104 | 104 | $rw = realpath('../'); |
| 105 | 105 | $webstart_path = str_replace('\\', '/', str_replace($rw, '', $rf)); |
| 106 | 106 | if (substr($webstart_path, 0, 1) == '/') { |
| 107 | - $webstart_path = '..' . $webstart_path; |
|
| 107 | + $webstart_path = '..'.$webstart_path; |
|
| 108 | 108 | } else { |
| 109 | - $webstart_path = '../' . $webstart_path; |
|
| 109 | + $webstart_path = '../'.$webstart_path; |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | ?> |
| 113 | 113 | <script type="text/javascript"> |
| 114 | 114 | |
| 115 | - var current_path = '<?= $startpath;?>'; |
|
| 115 | + var current_path = '<?= $startpath; ?>'; |
|
| 116 | 116 | |
| 117 | 117 | function viewfile (url) |
| 118 | 118 | { |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | function unzipFile (file) |
| 149 | 149 | { |
| 150 | 150 | if (confirmUnzip()) { |
| 151 | - window.location.href = "index.php?a=31&mode=unzip&path=" + current_path + '/&file=' + file + "&token=<?= $newToken;?>"; |
|
| 151 | + window.location.href = "index.php?a=31&mode=unzip&path=" + current_path + '/&file=' + file + "&token=<?= $newToken; ?>"; |
|
| 152 | 152 | return false; |
| 153 | 153 | } |
| 154 | 154 | } |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | function deleteFolder (folder, status) |
| 171 | 171 | { |
| 172 | 172 | if (confirmDeleteFolder(status)) { |
| 173 | - window.location.href = "index.php?a=31&mode=deletefolder&path=" + current_path + "&folderpath=" + current_path + '/' + folder + "&token=<?= $newToken;?>"; |
|
| 173 | + window.location.href = "index.php?a=31&mode=deletefolder&path=" + current_path + "&folderpath=" + current_path + '/' + folder + "&token=<?= $newToken; ?>"; |
|
| 174 | 174 | return false; |
| 175 | 175 | } |
| 176 | 176 | } |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | function deleteFile (file) |
| 179 | 179 | { |
| 180 | 180 | if (confirmDelete()) { |
| 181 | - window.location.href = "index.php?a=31&mode=delete&path=" + current_path + '/' + file + "&token=<?= $newToken;?>"; |
|
| 181 | + window.location.href = "index.php?a=31&mode=delete&path=" + current_path + '/' + file + "&token=<?= $newToken; ?>"; |
|
| 182 | 182 | return false; |
| 183 | 183 | } |
| 184 | 184 | } |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | { |
| 188 | 188 | var newFilename = prompt("<?= $_lang["files_dynamic_new_file_name"] ?>", file); |
| 189 | 189 | if (newFilename !== null && newFilename !== file) { |
| 190 | - window.location.href = "index.php?a=31&mode=duplicate&path=" + current_path + '/' + file + "&newFilename=" + newFilename + "&token=<?= $newToken;?>"; |
|
| 190 | + window.location.href = "index.php?a=31&mode=duplicate&path=" + current_path + '/' + file + "&newFilename=" + newFilename + "&token=<?= $newToken; ?>"; |
|
| 191 | 191 | } |
| 192 | 192 | } |
| 193 | 193 | |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | { |
| 196 | 196 | var newDirname = prompt("<?= $_lang["files_dynamic_new_folder_name"] ?>", dir); |
| 197 | 197 | if (newDirname !== null && newDirname !== dir) { |
| 198 | - window.location.href = "index.php?a=31&mode=renameFolder&path=" + current_path + '&dirname=' + dir + "&newDirname=" + newDirname + "&token=<?= $newToken;?>"; |
|
| 198 | + window.location.href = "index.php?a=31&mode=renameFolder&path=" + current_path + '&dirname=' + dir + "&newDirname=" + newDirname + "&token=<?= $newToken; ?>"; |
|
| 199 | 199 | } |
| 200 | 200 | } |
| 201 | 201 | |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | { |
| 204 | 204 | var newFilename = prompt("<?= $_lang["files_dynamic_new_file_name"] ?>", file); |
| 205 | 205 | if (newFilename !== null && newFilename !== file) { |
| 206 | - window.location.href = "index.php?a=31&mode=renameFile&path=" + current_path + '/' + file + "&newFilename=" + newFilename + "&token=<?= $newToken;?>"; |
|
| 206 | + window.location.href = "index.php?a=31&mode=renameFile&path=" + current_path + '/' + file + "&newFilename=" + newFilename + "&token=<?= $newToken; ?>"; |
|
| 207 | 207 | } |
| 208 | 208 | } |
| 209 | 209 | |
@@ -222,7 +222,7 @@ discard block |
||
| 222 | 222 | <?php endif ?> |
| 223 | 223 | <?php |
| 224 | 224 | if (isset($_GET['mode']) && $_GET['mode'] !== 'drill') { |
| 225 | - $href = 'a=31&path=' . urlencode($_REQUEST['path']); |
|
| 225 | + $href = 'a=31&path='.urlencode($_REQUEST['path']); |
|
| 226 | 226 | } else { |
| 227 | 227 | $href = 'a=2'; |
| 228 | 228 | } |
@@ -232,12 +232,12 @@ discard block |
||
| 232 | 232 | $tpl = '<a class="btn btn-secondary" href="[+href+]" onclick="return getFolderName(this);"><i class="[+image+]"></i><span>[+subject+]</span></a>'; |
| 233 | 233 | $ph['image'] = $_style['files_folder-open']; |
| 234 | 234 | $ph['subject'] = $_lang['add_folder']; |
| 235 | - $ph['href'] = 'index.php?a=31&mode=newfolder&path=' . urlencode($startpath) . '&name='; |
|
| 235 | + $ph['href'] = 'index.php?a=31&mode=newfolder&path='.urlencode($startpath).'&name='; |
|
| 236 | 236 | $_ = parsePlaceholder($tpl, $ph); |
| 237 | 237 | |
| 238 | - $tpl = '<a class="btn btn-secondary" href="[+href+]" onclick="return getFileName(this);"><i class="[+image+]"></i><span>' . $_lang['files.dynamic.php1'] . '</span></a>'; |
|
| 238 | + $tpl = '<a class="btn btn-secondary" href="[+href+]" onclick="return getFileName(this);"><i class="[+image+]"></i><span>'.$_lang['files.dynamic.php1'].'</span></a>'; |
|
| 239 | 239 | $ph['image'] = $_style['files_page_html']; |
| 240 | - $ph['href'] = 'index.php?a=31&mode=newfile&path=' . urlencode($startpath) . '&name='; |
|
| 240 | + $ph['href'] = 'index.php?a=31&mode=newfile&path='.urlencode($startpath).'&name='; |
|
| 241 | 241 | $_ .= parsePlaceholder($tpl, $ph); |
| 242 | 242 | echo $_; |
| 243 | 243 | } |
@@ -267,12 +267,12 @@ discard block |
||
| 267 | 267 | $ph = array(); |
| 268 | 268 | $ph['style_path'] = $theme_image_path; |
| 269 | 269 | // To Top Level with folder icon to the left |
| 270 | - if ($startpath == $filemanager_path || $startpath . '/' == $filemanager_path) { |
|
| 271 | - $ph['image'] = '' . $_style['files_top'] . ''; |
|
| 270 | + if ($startpath == $filemanager_path || $startpath.'/' == $filemanager_path) { |
|
| 271 | + $ph['image'] = ''.$_style['files_top'].''; |
|
| 272 | 272 | $ph['subject'] = '<span>Top</span>'; |
| 273 | 273 | } else { |
| 274 | - $ph['image'] = '' . $_style['files_top'] . ''; |
|
| 275 | - $ph['subject'] = '<a href="index.php?a=31&mode=drill&path=' . $filemanager_path . '">Top</a>/'; |
|
| 274 | + $ph['image'] = ''.$_style['files_top'].''; |
|
| 275 | + $ph['subject'] = '<a href="index.php?a=31&mode=drill&path='.$filemanager_path.'">Top</a>/'; |
|
| 276 | 276 | } |
| 277 | 277 | |
| 278 | 278 | echo parsePlaceholder($tpl, $ph); |
@@ -289,12 +289,12 @@ discard block |
||
| 289 | 289 | if (empty($v)) { |
| 290 | 290 | continue; |
| 291 | 291 | } |
| 292 | - $path .= rtrim($v, '/') . '/'; |
|
| 292 | + $path .= rtrim($v, '/').'/'; |
|
| 293 | 293 | if (1 < $count) { |
| 294 | - $href = 'index.php?a=31&mode=drill&path=' . urlencode($filemanager_path . $path); |
|
| 295 | - $pieces[$i] = '<a href="' . $href . '">' . trim($v, '/') . '</a>'; |
|
| 294 | + $href = 'index.php?a=31&mode=drill&path='.urlencode($filemanager_path.$path); |
|
| 295 | + $pieces[$i] = '<a href="'.$href.'">'.trim($v, '/').'</a>'; |
|
| 296 | 296 | } else { |
| 297 | - $pieces[$i] = '<span>' . trim($v, '/') . '</span>'; |
|
| 297 | + $pieces[$i] = '<span>'.trim($v, '/').'</span>'; |
|
| 298 | 298 | } |
| 299 | 299 | $count--; |
| 300 | 300 | } |
@@ -307,16 +307,16 @@ discard block |
||
| 307 | 307 | </div> |
| 308 | 308 | <?php |
| 309 | 309 | // check to see user isn't trying to move below the document_root |
| 310 | - if (substr(strtolower(str_replace('//', '/', $startpath . "/")), 0, $len) != strtolower(str_replace('//', '/', $filemanager_path . '/'))) { |
|
| 310 | + if (substr(strtolower(str_replace('//', '/', $startpath."/")), 0, $len) != strtolower(str_replace('//', '/', $filemanager_path.'/'))) { |
|
| 311 | 311 | $modx->webAlertAndQuit($_lang["files_access_denied"]); |
| 312 | 312 | } |
| 313 | 313 | |
| 314 | 314 | // Unzip .zip files - by Raymond |
| 315 | 315 | if ($enablefileunzip && $_REQUEST['mode'] == 'unzip' && is_writable($startpath)) { |
| 316 | - if (!$err = unzip(realpath("{$startpath}/" . $_REQUEST['file']), realpath($startpath))) { |
|
| 317 | - echo '<span class="warning"><b>' . $_lang['file_unzip_fail'] . ($err === 0 ? 'Missing zip library (php_zip.dll / zip.so)' : '') . '</b></span><br /><br />'; |
|
| 316 | + if (!$err = unzip(realpath("{$startpath}/".$_REQUEST['file']), realpath($startpath))) { |
|
| 317 | + echo '<span class="warning"><b>'.$_lang['file_unzip_fail'].($err === 0 ? 'Missing zip library (php_zip.dll / zip.so)' : '').'</b></span><br /><br />'; |
|
| 318 | 318 | } else { |
| 319 | - echo '<span class="success"><b>' . $_lang['file_unzip'] . '</b></span><br /><br />'; |
|
| 319 | + echo '<span class="success"><b>'.$_lang['file_unzip'].'</b></span><br /><br />'; |
|
| 320 | 320 | } |
| 321 | 321 | } |
| 322 | 322 | // End Unzip - Raymond |
@@ -328,9 +328,9 @@ discard block |
||
| 328 | 328 | if ($_REQUEST['mode'] == 'deletefolder') { |
| 329 | 329 | $folder = $_REQUEST['folderpath']; |
| 330 | 330 | if (!$token_check || !@rrmdir($folder)) { |
| 331 | - echo '<span class="warning"><b>' . $_lang['file_folder_not_deleted'] . '</b></span><br /><br />'; |
|
| 331 | + echo '<span class="warning"><b>'.$_lang['file_folder_not_deleted'].'</b></span><br /><br />'; |
|
| 332 | 332 | } else { |
| 333 | - echo '<span class="success"><b>' . $_lang['file_folder_deleted'] . '</b></span><br /><br />'; |
|
| 333 | + echo '<span class="success"><b>'.$_lang['file_folder_deleted'].'</b></span><br /><br />'; |
|
| 334 | 334 | } |
| 335 | 335 | } |
| 336 | 336 | |
@@ -341,10 +341,10 @@ discard block |
||
| 341 | 341 | if (!mkdirs("{$startpath}/{$foldername}", 0777)) { |
| 342 | 342 | echo '<span class="warning"><b>', $_lang['file_folder_not_created'], '</b></span><br /><br />'; |
| 343 | 343 | } else { |
| 344 | - if (!@chmod($startpath . '/' . $foldername, $newfolderaccessmode)) { |
|
| 345 | - echo '<span class="warning"><b>' . $_lang['file_folder_chmod_error'] . '</b></span><br /><br />'; |
|
| 344 | + if (!@chmod($startpath.'/'.$foldername, $newfolderaccessmode)) { |
|
| 345 | + echo '<span class="warning"><b>'.$_lang['file_folder_chmod_error'].'</b></span><br /><br />'; |
|
| 346 | 346 | } else { |
| 347 | - echo '<span class="success"><b>' . $_lang['file_folder_created'] . '</b></span><br /><br />'; |
|
| 347 | + echo '<span class="success"><b>'.$_lang['file_folder_created'].'</b></span><br /><br />'; |
|
| 348 | 348 | } |
| 349 | 349 | } |
| 350 | 350 | umask($old_umask); |
@@ -356,7 +356,7 @@ discard block |
||
| 356 | 356 | $filename = $modx->db->escape($filename); |
| 357 | 357 | |
| 358 | 358 | if (!checkExtension($filename)) { |
| 359 | - echo '<span class="warning"><b>' . $_lang['files_filetype_notok'] . '</b></span><br /><br />'; |
|
| 359 | + echo '<span class="warning"><b>'.$_lang['files_filetype_notok'].'</b></span><br /><br />'; |
|
| 360 | 360 | } elseif (preg_match('@(\\\\|\/|\:|\;|\,|\*|\?|\"|\<|\>|\||\?)@', $filename) !== 0) { |
| 361 | 361 | echo $_lang['files.dynamic.php3']; |
| 362 | 362 | } else { |
@@ -378,11 +378,11 @@ discard block |
||
| 378 | 378 | $newFilename = $modx->db->escape($newFilename); |
| 379 | 379 | |
| 380 | 380 | if (!checkExtension($newFilename)) { |
| 381 | - echo '<span class="warning"><b>' . $_lang['files_filetype_notok'] . '</b></span><br /><br />'; |
|
| 381 | + echo '<span class="warning"><b>'.$_lang['files_filetype_notok'].'</b></span><br /><br />'; |
|
| 382 | 382 | } elseif (preg_match('@(\\\\|\/|\:|\;|\,|\*|\?|\"|\<|\>|\||\?)@', $newFilename) !== 0) { |
| 383 | 383 | echo $_lang['files.dynamic.php3']; |
| 384 | 384 | } else { |
| 385 | - if (!copy($filename, MODX_BASE_PATH . $newFilename)) { |
|
| 385 | + if (!copy($filename, MODX_BASE_PATH.$newFilename)) { |
|
| 386 | 386 | echo $_lang['files.dynamic.php5']; |
| 387 | 387 | } |
| 388 | 388 | umask($old_umask); |
@@ -391,7 +391,7 @@ discard block |
||
| 391 | 391 | // Rename folder here |
| 392 | 392 | if ($_REQUEST['mode'] == 'renameFolder') { |
| 393 | 393 | $old_umask = umask(0); |
| 394 | - $dirname = $_REQUEST['path'] . '/' . $_REQUEST['dirname']; |
|
| 394 | + $dirname = $_REQUEST['path'].'/'.$_REQUEST['dirname']; |
|
| 395 | 395 | $dirname = $modx->db->escape($dirname); |
| 396 | 396 | $newDirname = str_replace(array( |
| 397 | 397 | '..\\', |
@@ -403,7 +403,7 @@ discard block |
||
| 403 | 403 | |
| 404 | 404 | if (preg_match('@(\\\\|\/|\:|\;|\,|\*|\?|\"|\<|\>|\||\?)@', $newDirname) !== 0) { |
| 405 | 405 | echo $_lang['files.dynamic.php3']; |
| 406 | - } else if (!rename($dirname, $_REQUEST['path'] . '/' . $newDirname)) { |
|
| 406 | + } else if (!rename($dirname, $_REQUEST['path'].'/'.$newDirname)) { |
|
| 407 | 407 | echo '<span class="warning"><b>', $_lang['file_folder_not_created'], '</b></span><br /><br />'; |
| 408 | 408 | } |
| 409 | 409 | umask($old_umask); |
@@ -423,11 +423,11 @@ discard block |
||
| 423 | 423 | $newFilename = $modx->db->escape($newFilename); |
| 424 | 424 | |
| 425 | 425 | if (!checkExtension($newFilename)) { |
| 426 | - echo '<span class="warning"><b>' . $_lang['files_filetype_notok'] . '</b></span><br /><br />'; |
|
| 426 | + echo '<span class="warning"><b>'.$_lang['files_filetype_notok'].'</b></span><br /><br />'; |
|
| 427 | 427 | } elseif (preg_match('@(\\\\|\/|\:|\;|\,|\*|\?|\"|\<|\>|\||\?)@', $newFilename) !== 0) { |
| 428 | 428 | echo $_lang['files.dynamic.php3']; |
| 429 | 429 | } else { |
| 430 | - if (!rename($filename, $path . '/' . $newFilename)) { |
|
| 430 | + if (!rename($filename, $path.'/'.$newFilename)) { |
|
| 431 | 431 | echo $_lang['files.dynamic.php5']; |
| 432 | 432 | } |
| 433 | 433 | umask($old_umask); |
@@ -460,7 +460,7 @@ discard block |
||
| 460 | 460 | ls($startpath); |
| 461 | 461 | echo "\n\n\n"; |
| 462 | 462 | if ($folders == 0 && $files == 0) { |
| 463 | - echo '<tr><td colspan="4"><i class="' . $_style['files_deleted_folder'] . ' FilesDeletedFolder"></i> <span style="color:#888;cursor:default;"> ' . $_lang['files_directory_is_empty'] . ' </span></td></tr>'; |
|
| 463 | + echo '<tr><td colspan="4"><i class="'.$_style['files_deleted_folder'].' FilesDeletedFolder"></i> <span style="color:#888;cursor:default;"> '.$_lang['files_directory_is_empty'].' </span></td></tr>'; |
|
| 464 | 464 | } |
| 465 | 465 | ?> |
| 466 | 466 | </table> |
@@ -469,10 +469,10 @@ discard block |
||
| 469 | 469 | <div class="container"> |
| 470 | 470 | <p> |
| 471 | 471 | <?php |
| 472 | - echo $_lang['files_directories'] . ': <b>' . $folders . '</b> '; |
|
| 473 | - echo $_lang['files_files'] . ': <b>' . $files . '</b> '; |
|
| 474 | - echo $_lang['files_data'] . ': <b><span dir="ltr">' . $modx->nicesize($filesizes) . '</span></b> '; |
|
| 475 | - echo $_lang['files_dirwritable'] . ' <b>' . (is_writable($startpath) == 1 ? $_lang['yes'] . '.' : $_lang['no']) . '.</b>' |
|
| 472 | + echo $_lang['files_directories'].': <b>'.$folders.'</b> '; |
|
| 473 | + echo $_lang['files_files'].': <b>'.$files.'</b> '; |
|
| 474 | + echo $_lang['files_data'].': <b><span dir="ltr">'.$modx->nicesize($filesizes).'</span></b> '; |
|
| 475 | + echo $_lang['files_dirwritable'].' <b>'.(is_writable($startpath) == 1 ? $_lang['yes'].'.' : $_lang['no']).'.</b>' |
|
| 476 | 476 | ?> |
| 477 | 477 | </p> |
| 478 | 478 | |
@@ -497,7 +497,7 @@ discard block |
||
| 497 | 497 | </form> |
| 498 | 498 | <?php |
| 499 | 499 | } else { |
| 500 | - echo "<p>" . $_lang['files_upload_inhibited_msg'] . "</p>"; |
|
| 500 | + echo "<p>".$_lang['files_upload_inhibited_msg']."</p>"; |
|
| 501 | 501 | } |
| 502 | 502 | ?> |
| 503 | 503 | <div id="imageviewer"></div> |
@@ -576,7 +576,7 @@ discard block |
||
| 576 | 576 | if ($file == $selFile) { |
| 577 | 577 | $icon = isset($icons[$mode]) ? $icons[$mode] : $icons['default']; |
| 578 | 578 | } |
| 579 | - return '<i class="' . $icon . ' FilesPage"></i>'; |
|
| 579 | + return '<i class="'.$icon.' FilesPage"></i>'; |
|
| 580 | 580 | } |
| 581 | 581 | |
| 582 | 582 | function markRow($file, $selFile, $mode) |
@@ -588,7 +588,7 @@ discard block |
||
| 588 | 588 | ); |
| 589 | 589 | if ($file == $selFile) { |
| 590 | 590 | $class = isset($classNames[$mode]) ? $classNames[$mode] : $classNames['default']; |
| 591 | - return ' class="' . $class . '"'; |
|
| 591 | + return ' class="'.$class.'"'; |
|
| 592 | 592 | } |
| 593 | 593 | return ''; |
| 594 | 594 | } |
@@ -599,7 +599,7 @@ discard block |
||
| 599 | 599 | global $excludes, $protected_path, $editablefiles, $inlineviewablefiles, $viewablefiles, $enablefileunzip, $enablefiledownload, $uploadablefiles, $folders, $files, $filesizes, $len, $dirs_array, $files_array, $webstart_path, $modx; |
| 600 | 600 | $dircounter = 0; |
| 601 | 601 | $filecounter = 0; |
| 602 | - $curpath = str_replace('//', '/', $curpath . '/'); |
|
| 602 | + $curpath = str_replace('//', '/', $curpath.'/'); |
|
| 603 | 603 | |
| 604 | 604 | if (!is_dir($curpath)) { |
| 605 | 605 | echo 'Invalid path "', $curpath, '"<br />'; |
@@ -609,7 +609,7 @@ discard block |
||
| 609 | 609 | |
| 610 | 610 | // first, get info |
| 611 | 611 | foreach ($dir as $file) { |
| 612 | - $newpath = $curpath . $file; |
|
| 612 | + $newpath = $curpath.$file; |
|
| 613 | 613 | if ($file === '..' || $file === '.') { |
| 614 | 614 | continue; |
| 615 | 615 | } |
@@ -619,7 +619,7 @@ discard block |
||
| 619 | 619 | if ($file === '..' || $file === '.') { |
| 620 | 620 | continue; |
| 621 | 621 | } elseif (!in_array($file, $excludes) && !in_array($newpath, $protected_path)) { |
| 622 | - $dirs_array[$dircounter]['text'] = '<i class="' . $_style['files_folder'] . ' FilesFolder"></i> <a href="index.php?a=31&mode=drill&path=' . urlencode($newpath) . '"><b>' . $file . '</b></a>'; |
|
| 622 | + $dirs_array[$dircounter]['text'] = '<i class="'.$_style['files_folder'].' FilesFolder"></i> <a href="index.php?a=31&mode=drill&path='.urlencode($newpath).'"><b>'.$file.'</b></a>'; |
|
| 623 | 623 | |
| 624 | 624 | $dfiles = scandir($newpath); |
| 625 | 625 | foreach ($dfiles as $i => $infile) { |
@@ -632,13 +632,13 @@ discard block |
||
| 632 | 632 | } |
| 633 | 633 | $file_exists = (0 < count($dfiles)) ? 'file_exists' : ''; |
| 634 | 634 | |
| 635 | - $dirs_array[$dircounter]['delete'] = is_writable($curpath) ? '<a href="javascript: deleteFolder(\'' . urlencode($file) . '\',\'' . $file_exists . '\');"><i class="' . $_style['files_delete'] . '" title="' . $_lang['file_delete_folder'] . '"></i></a>' : ''; |
|
| 635 | + $dirs_array[$dircounter]['delete'] = is_writable($curpath) ? '<a href="javascript: deleteFolder(\''.urlencode($file).'\',\''.$file_exists.'\');"><i class="'.$_style['files_delete'].'" title="'.$_lang['file_delete_folder'].'"></i></a>' : ''; |
|
| 636 | 636 | } else { |
| 637 | - $dirs_array[$dircounter]['text'] = '<span><i class="' . $_style['files_deleted_folder'] . ' FilesDeletedFolder"></i> ' . $file . '</span>'; |
|
| 638 | - $dirs_array[$dircounter]['delete'] = is_writable($curpath) ? '<span class="disabled"><i class="' . $_style['files_delete'] . '" title="' . $_lang['file_delete_folder'] . '"></i></span>' : ''; |
|
| 637 | + $dirs_array[$dircounter]['text'] = '<span><i class="'.$_style['files_deleted_folder'].' FilesDeletedFolder"></i> '.$file.'</span>'; |
|
| 638 | + $dirs_array[$dircounter]['delete'] = is_writable($curpath) ? '<span class="disabled"><i class="'.$_style['files_delete'].'" title="'.$_lang['file_delete_folder'].'"></i></span>' : ''; |
|
| 639 | 639 | } |
| 640 | 640 | |
| 641 | - $dirs_array[$dircounter]['rename'] = is_writable($curpath) ? '<a href="javascript:renameFolder(\'' . urlencode($file) . '\');"><i class="' . $_style['files_rename'] . '" title="' . $_lang['rename'] . '"></i></a> ' : ''; |
|
| 641 | + $dirs_array[$dircounter]['rename'] = is_writable($curpath) ? '<a href="javascript:renameFolder(\''.urlencode($file).'\');"><i class="'.$_style['files_rename'].'" title="'.$_lang['rename'].'"></i></a> ' : ''; |
|
| 642 | 642 | |
| 643 | 643 | // increment the counter |
| 644 | 644 | $dircounter++; |
@@ -646,14 +646,14 @@ discard block |
||
| 646 | 646 | $type = getExtension($newpath); |
| 647 | 647 | $files_array[$filecounter]['file'] = $newpath; |
| 648 | 648 | $files_array[$filecounter]['stats'] = lstat($newpath); |
| 649 | - $files_array[$filecounter]['text'] = determineIcon($newpath, $_REQUEST['path'], $_REQUEST['mode']) . ' ' . $file; |
|
| 650 | - $files_array[$filecounter]['view'] = (in_array($type, $viewablefiles)) ? '<a href="javascript:;" onclick="viewfile(\'' . $webstart_path . substr($newpath, $len, strlen($newpath)) . '\');"><i class="' . $_style['files_view'] . '" title="' . $_lang['files_viewfile'] . '"></i></a>' : (($enablefiledownload && in_array($type, $uploadablefiles)) ? '<a href="' . $webstart_path . implode('/', array_map('rawurlencode', explode('/', substr($newpath, $len, strlen($newpath))))) . '" style="cursor:pointer;"><i class="' . $_style['files_download'] . '" title="' . $_lang['file_download_file'] . '"></i></a>' : '<span class="disabled"><i class="' . $_style['files_view'] . '" title="' . $_lang['files_viewfile'] . '"></i></span>'); |
|
| 651 | - $files_array[$filecounter]['view'] = (in_array($type, $inlineviewablefiles)) ? '<a href="index.php?a=31&mode=view&path=' . urlencode($newpath) . '"><i class="' . $_style['files_view'] . '" title="' . $_lang['files_viewfile'] . '"></i></a>' : $files_array[$filecounter]['view']; |
|
| 652 | - $files_array[$filecounter]['unzip'] = ($enablefileunzip && $type == '.zip') ? '<a href="javascript:unzipFile(\'' . urlencode($file) . '\');"><i class="' . $_style['files_unzip'] . '" title="' . $_lang['file_download_unzip'] . '"></i></a>' : ''; |
|
| 653 | - $files_array[$filecounter]['edit'] = (in_array($type, $editablefiles) && is_writable($curpath) && is_writable($newpath)) ? '<a href="index.php?a=31&mode=edit&path=' . urlencode($newpath) . '#file_editfile"><i class="' . $_style['files_edit'] . '" title="' . $_lang['files_editfile'] . '"></i></a>' : '<span class="disabled"><i class="' . $_style['files_edit'] . '" title="' . $_lang['files_editfile'] . '"></i></span>'; |
|
| 654 | - $files_array[$filecounter]['duplicate'] = (in_array($type, $editablefiles) && is_writable($curpath) && is_writable($newpath)) ? '<a href="javascript:duplicateFile(\'' . urlencode($file) . '\');"><i class="' . $_style['files_duplicate'] . '" title="' . $_lang['duplicate'] . '"></i></a>' : '<span class="disabled"><i class="' . $_style['files_duplicate'] . '" align="absmiddle" title="' . $_lang['duplicate'] . '"></i></span>'; |
|
| 655 | - $files_array[$filecounter]['rename'] = (in_array($type, $editablefiles) && is_writable($curpath) && is_writable($newpath)) ? '<a href="javascript:renameFile(\'' . urlencode($file) . '\');"><i class="' . $_style['files_rename'] . '" align="absmiddle" title="' . $_lang['rename'] . '"></i></a>' : '<span class="disabled"><i class="' . $_style['files_rename'] . '" align="absmiddle" title="' . $_lang['rename'] . '"></i></span>'; |
|
| 656 | - $files_array[$filecounter]['delete'] = is_writable($curpath) && is_writable($newpath) ? '<a href="javascript:deleteFile(\'' . urlencode($file) . '\');"><i class="' . $_style['files_delete'] . '" title="' . $_lang['file_delete_file'] . '"></i></a>' : '<span class="disabled"><i class="' . $_style['files_delete'] . '" title="' . $_lang['file_delete_file'] . '"></i></span>'; |
|
| 649 | + $files_array[$filecounter]['text'] = determineIcon($newpath, $_REQUEST['path'], $_REQUEST['mode']).' '.$file; |
|
| 650 | + $files_array[$filecounter]['view'] = (in_array($type, $viewablefiles)) ? '<a href="javascript:;" onclick="viewfile(\''.$webstart_path.substr($newpath, $len, strlen($newpath)).'\');"><i class="'.$_style['files_view'].'" title="'.$_lang['files_viewfile'].'"></i></a>' : (($enablefiledownload && in_array($type, $uploadablefiles)) ? '<a href="'.$webstart_path.implode('/', array_map('rawurlencode', explode('/', substr($newpath, $len, strlen($newpath))))).'" style="cursor:pointer;"><i class="'.$_style['files_download'].'" title="'.$_lang['file_download_file'].'"></i></a>' : '<span class="disabled"><i class="'.$_style['files_view'].'" title="'.$_lang['files_viewfile'].'"></i></span>'); |
|
| 651 | + $files_array[$filecounter]['view'] = (in_array($type, $inlineviewablefiles)) ? '<a href="index.php?a=31&mode=view&path='.urlencode($newpath).'"><i class="'.$_style['files_view'].'" title="'.$_lang['files_viewfile'].'"></i></a>' : $files_array[$filecounter]['view']; |
|
| 652 | + $files_array[$filecounter]['unzip'] = ($enablefileunzip && $type == '.zip') ? '<a href="javascript:unzipFile(\''.urlencode($file).'\');"><i class="'.$_style['files_unzip'].'" title="'.$_lang['file_download_unzip'].'"></i></a>' : ''; |
|
| 653 | + $files_array[$filecounter]['edit'] = (in_array($type, $editablefiles) && is_writable($curpath) && is_writable($newpath)) ? '<a href="index.php?a=31&mode=edit&path='.urlencode($newpath).'#file_editfile"><i class="'.$_style['files_edit'].'" title="'.$_lang['files_editfile'].'"></i></a>' : '<span class="disabled"><i class="'.$_style['files_edit'].'" title="'.$_lang['files_editfile'].'"></i></span>'; |
|
| 654 | + $files_array[$filecounter]['duplicate'] = (in_array($type, $editablefiles) && is_writable($curpath) && is_writable($newpath)) ? '<a href="javascript:duplicateFile(\''.urlencode($file).'\');"><i class="'.$_style['files_duplicate'].'" title="'.$_lang['duplicate'].'"></i></a>' : '<span class="disabled"><i class="'.$_style['files_duplicate'].'" align="absmiddle" title="'.$_lang['duplicate'].'"></i></span>'; |
|
| 655 | + $files_array[$filecounter]['rename'] = (in_array($type, $editablefiles) && is_writable($curpath) && is_writable($newpath)) ? '<a href="javascript:renameFile(\''.urlencode($file).'\');"><i class="'.$_style['files_rename'].'" align="absmiddle" title="'.$_lang['rename'].'"></i></a>' : '<span class="disabled"><i class="'.$_style['files_rename'].'" align="absmiddle" title="'.$_lang['rename'].'"></i></span>'; |
|
| 656 | + $files_array[$filecounter]['delete'] = is_writable($curpath) && is_writable($newpath) ? '<a href="javascript:deleteFile(\''.urlencode($file).'\');"><i class="'.$_style['files_delete'].'" title="'.$_lang['file_delete_file'].'"></i></a>' : '<span class="disabled"><i class="'.$_style['files_delete'].'" title="'.$_lang['file_delete_file'].'"></i></span>'; |
|
| 657 | 657 | |
| 658 | 658 | // increment the counter |
| 659 | 659 | $filecounter++; |
@@ -666,9 +666,9 @@ discard block |
||
| 666 | 666 | for ($i = 0; $i < $folders; $i++) { |
| 667 | 667 | $filesizes += $dirs_array[$i]['stats']['7']; |
| 668 | 668 | echo '<tr>'; |
| 669 | - echo '<td>' . $dirs_array[$i]['text'] . '</td>'; |
|
| 670 | - echo '<td class="text-nowrap">' . $modx->toDateFormat($dirs_array[$i]['stats']['9']) . '</td>'; |
|
| 671 | - echo '<td class="text-right">' . $modx->nicesize($dirs_array[$i]['stats']['7']) . '</td>'; |
|
| 669 | + echo '<td>'.$dirs_array[$i]['text'].'</td>'; |
|
| 670 | + echo '<td class="text-nowrap">'.$modx->toDateFormat($dirs_array[$i]['stats']['9']).'</td>'; |
|
| 671 | + echo '<td class="text-right">'.$modx->nicesize($dirs_array[$i]['stats']['7']).'</td>'; |
|
| 672 | 672 | echo '<td class="actions text-right">'; |
| 673 | 673 | echo $dirs_array[$i]['rename']; |
| 674 | 674 | echo $dirs_array[$i]['delete']; |
@@ -681,10 +681,10 @@ discard block |
||
| 681 | 681 | sort($files_array); // sorting the array alphabetically (Thanks pxl8r!) |
| 682 | 682 | for ($i = 0; $i < $files; $i++) { |
| 683 | 683 | $filesizes += $files_array[$i]['stats']['7']; |
| 684 | - echo '<tr ' . markRow($files_array[$i]['file'], $_REQUEST['path'], $_REQUEST['mode']) . '>'; |
|
| 685 | - echo '<td>' . $files_array[$i]['text'] . '</td>'; |
|
| 686 | - echo '<td class="text-nowrap">' . $modx->toDateFormat($files_array[$i]['stats']['9']) . '</td>'; |
|
| 687 | - echo '<td class="text-right">' . $modx->nicesize($files_array[$i]['stats']['7']) . '</td>'; |
|
| 684 | + echo '<tr '.markRow($files_array[$i]['file'], $_REQUEST['path'], $_REQUEST['mode']).'>'; |
|
| 685 | + echo '<td>'.$files_array[$i]['text'].'</td>'; |
|
| 686 | + echo '<td class="text-nowrap">'.$modx->toDateFormat($files_array[$i]['stats']['9']).'</td>'; |
|
| 687 | + echo '<td class="text-right">'.$modx->nicesize($files_array[$i]['stats']['7']).'</td>'; |
|
| 688 | 688 | echo '<td class="actions text-right">'; |
| 689 | 689 | echo $files_array[$i]['unzip']; |
| 690 | 690 | echo $files_array[$i]['view']; |
@@ -792,17 +792,17 @@ discard block |
||
| 792 | 792 | $zip = zip_open($file); |
| 793 | 793 | if ($zip) { |
| 794 | 794 | $old_umask = umask(0); |
| 795 | - $path = rtrim($path, '/') . '/'; |
|
| 795 | + $path = rtrim($path, '/').'/'; |
|
| 796 | 796 | while ($zip_entry = zip_read($zip)) { |
| 797 | 797 | if (zip_entry_filesize($zip_entry) > 0) { |
| 798 | 798 | // str_replace must be used under windows to convert "/" into "\" |
| 799 | 799 | $zip_entry_name = zip_entry_name($zip_entry); |
| 800 | - $complete_path = $path . str_replace('\\', '/', dirname($zip_entry_name)); |
|
| 801 | - $complete_name = $path . str_replace('\\', '/', $zip_entry_name); |
|
| 800 | + $complete_path = $path.str_replace('\\', '/', dirname($zip_entry_name)); |
|
| 801 | + $complete_name = $path.str_replace('\\', '/', $zip_entry_name); |
|
| 802 | 802 | if (!file_exists($complete_path)) { |
| 803 | 803 | $tmp = ''; |
| 804 | 804 | foreach (explode('/', $complete_path) AS $k) { |
| 805 | - $tmp .= $k . '/'; |
|
| 805 | + $tmp .= $k.'/'; |
|
| 806 | 806 | if (!is_dir($tmp)) { |
| 807 | 807 | mkdir($tmp, 0777); |
| 808 | 808 | } |
@@ -823,7 +823,7 @@ discard block |
||
| 823 | 823 | |
| 824 | 824 | function rrmdir($dir) |
| 825 | 825 | { |
| 826 | - foreach (glob($dir . '/*') as $file) { |
|
| 826 | + foreach (glob($dir.'/*') as $file) { |
|
| 827 | 827 | if (is_dir($file)) { |
| 828 | 828 | rrmdir($file); |
| 829 | 829 | } else { |
@@ -839,7 +839,7 @@ discard block |
||
| 839 | 839 | $msg = ''; |
| 840 | 840 | foreach ($_FILES['userfile']['name'] as $i => $name) { |
| 841 | 841 | if (empty($_FILES['userfile']['tmp_name'][$i])) continue; |
| 842 | - $userfile= array(); |
|
| 842 | + $userfile = array(); |
|
| 843 | 843 | |
| 844 | 844 | $userfile['tmp_name'] = $_FILES['userfile']['tmp_name'][$i]; |
| 845 | 845 | $userfile['error'] = $_FILES['userfile']['error'][$i]; |
@@ -856,12 +856,12 @@ discard block |
||
| 856 | 856 | $userfile['type'] = $_FILES['userfile']['type'][$i]; |
| 857 | 857 | |
| 858 | 858 | // this seems to be an upload action. |
| 859 | - $path = $modx->config['site_url'] . substr($startpath, strlen($filemanager_path), strlen($startpath)); |
|
| 860 | - $path = rtrim($path, '/') . '/' . $userfile['name']; |
|
| 859 | + $path = $modx->config['site_url'].substr($startpath, strlen($filemanager_path), strlen($startpath)); |
|
| 860 | + $path = rtrim($path, '/').'/'.$userfile['name']; |
|
| 861 | 861 | $msg .= $path; |
| 862 | 862 | if ($userfile['error'] == 0) { |
| 863 | - $img = (strpos($userfile['type'], 'image') !== false) ? '<br /><img src="' . $path . '" height="75" />' : ''; |
|
| 864 | - $msg .= "<p>" . $_lang['files_file_type'] . $userfile['type'] . ", " . $modx->nicesize(filesize($userfile['tmp_name'])) . $img . '</p>'; |
|
| 863 | + $img = (strpos($userfile['type'], 'image') !== false) ? '<br /><img src="'.$path.'" height="75" />' : ''; |
|
| 864 | + $msg .= "<p>".$_lang['files_file_type'].$userfile['type'].", ".$modx->nicesize(filesize($userfile['tmp_name'])).$img.'</p>'; |
|
| 865 | 865 | } |
| 866 | 866 | |
| 867 | 867 | $userfilename = $userfile['tmp_name']; |
@@ -869,15 +869,15 @@ discard block |
||
| 869 | 869 | if (is_uploaded_file($userfilename)) { |
| 870 | 870 | // file is uploaded file, process it! |
| 871 | 871 | if (!checkExtension($userfile['name'])) { |
| 872 | - $msg .= '<p><span class="warning">' . $_lang['files_filetype_notok'] . '</span></p>'; |
|
| 872 | + $msg .= '<p><span class="warning">'.$_lang['files_filetype_notok'].'</span></p>'; |
|
| 873 | 873 | } else { |
| 874 | - if (@move_uploaded_file($userfile['tmp_name'], $_POST['path'] . '/' . $userfile['name'])) { |
|
| 874 | + if (@move_uploaded_file($userfile['tmp_name'], $_POST['path'].'/'.$userfile['name'])) { |
|
| 875 | 875 | // Ryan: Repair broken permissions issue with file manager |
| 876 | 876 | if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') { |
| 877 | - @chmod($_POST['path'] . "/" . $userfile['name'], $new_file_permissions); |
|
| 877 | + @chmod($_POST['path']."/".$userfile['name'], $new_file_permissions); |
|
| 878 | 878 | } |
| 879 | 879 | // Ryan: End |
| 880 | - $msg .= '<p><span class="success">' . $_lang['files_upload_ok'] . '</span></p><hr/>'; |
|
| 880 | + $msg .= '<p><span class="success">'.$_lang['files_upload_ok'].'</span></p><hr/>'; |
|
| 881 | 881 | |
| 882 | 882 | // invoke OnFileManagerUpload event |
| 883 | 883 | $modx->invokeEvent('OnFileManagerUpload', array( |
@@ -885,13 +885,13 @@ discard block |
||
| 885 | 885 | 'filename' => $userfile['name'] |
| 886 | 886 | )); |
| 887 | 887 | // Log the change |
| 888 | - logFileChange('upload', $_POST['path'] . '/' . $userfile['name']); |
|
| 888 | + logFileChange('upload', $_POST['path'].'/'.$userfile['name']); |
|
| 889 | 889 | } else { |
| 890 | - $msg .= '<p><span class="warning">' . $_lang['files_upload_copyfailed'] . '</span> ' . $_lang["files_upload_permissions_error"] . '</p>'; |
|
| 890 | + $msg .= '<p><span class="warning">'.$_lang['files_upload_copyfailed'].'</span> '.$_lang["files_upload_permissions_error"].'</p>'; |
|
| 891 | 891 | } |
| 892 | 892 | } |
| 893 | 893 | } else { |
| 894 | - $msg .= '<br /><span class="warning"><b>' . $_lang['files_upload_error'] . ':</b>'; |
|
| 894 | + $msg .= '<br /><span class="warning"><b>'.$_lang['files_upload_error'].':</b>'; |
|
| 895 | 895 | switch ($userfile['error']) { |
| 896 | 896 | case 0: //no error; possible file attack! |
| 897 | 897 | $msg .= $_lang['files_upload_error0']; |
@@ -915,7 +915,7 @@ discard block |
||
| 915 | 915 | $msg .= '</span><br />'; |
| 916 | 916 | } |
| 917 | 917 | } |
| 918 | - return $msg . '<br/>'; |
|
| 918 | + return $msg.'<br/>'; |
|
| 919 | 919 | } |
| 920 | 920 | |
| 921 | 921 | function textsave() |
@@ -928,9 +928,9 @@ discard block |
||
| 928 | 928 | |
| 929 | 929 | // Write $content to our opened file. |
| 930 | 930 | if (file_put_contents($filename, $content) === false) { |
| 931 | - $msg .= '<span class="warning"><b>' . $_lang['file_not_saved'] . '</b></span><br /><br />'; |
|
| 931 | + $msg .= '<span class="warning"><b>'.$_lang['file_not_saved'].'</b></span><br /><br />'; |
|
| 932 | 932 | } else { |
| 933 | - $msg .= '<span class="success"><b>' . $_lang['file_saved'] . '</b></span><br /><br />'; |
|
| 933 | + $msg .= '<span class="success"><b>'.$_lang['file_saved'].'</b></span><br /><br />'; |
|
| 934 | 934 | $_REQUEST['mode'] = 'edit'; |
| 935 | 935 | } |
| 936 | 936 | // Log the change |
@@ -946,9 +946,9 @@ discard block |
||
| 946 | 946 | |
| 947 | 947 | $file = $_REQUEST['path']; |
| 948 | 948 | if (!$token_check || !@unlink($file)) { |
| 949 | - $msg .= '<span class="warning"><b>' . $_lang['file_not_deleted'] . '</b></span><br /><br />'; |
|
| 949 | + $msg .= '<span class="warning"><b>'.$_lang['file_not_deleted'].'</b></span><br /><br />'; |
|
| 950 | 950 | } else { |
| 951 | - $msg .= '<span class="success"><b>' . $_lang['file_deleted'] . '</b></span><br /><br />'; |
|
| 951 | + $msg .= '<span class="success"><b>'.$_lang['file_deleted'].'</b></span><br /><br />'; |
|
| 952 | 952 | } |
| 953 | 953 | |
| 954 | 954 | // Log the change |
@@ -733,7 +733,8 @@ discard block |
||
| 733 | 733 | } |
| 734 | 734 | |
| 735 | 735 | function mkdirs($strPath, $mode) |
| 736 | -{ // recursive mkdir function |
|
| 736 | +{ |
|
| 737 | +// recursive mkdir function |
|
| 737 | 738 | if (is_dir($strPath)) { |
| 738 | 739 | return true; |
| 739 | 740 | } |
@@ -838,7 +839,9 @@ discard block |
||
| 838 | 839 | global $modx, $_lang, $startpath, $filemanager_path, $uploadablefiles, $new_file_permissions; |
| 839 | 840 | $msg = ''; |
| 840 | 841 | foreach ($_FILES['userfile']['name'] as $i => $name) { |
| 841 | - if (empty($_FILES['userfile']['tmp_name'][$i])) continue; |
|
| 842 | + if (empty($_FILES['userfile']['tmp_name'][$i])) { |
|
| 843 | + continue; |
|
| 844 | + } |
|
| 842 | 845 | $userfile= array(); |
| 843 | 846 | |
| 844 | 847 | $userfile['tmp_name'] = $_FILES['userfile']['tmp_name'][$i]; |