@@ -565,6 +565,9 @@ discard block |
||
| 565 | 565 | |
| 566 | 566 | } |
| 567 | 567 | |
| 568 | +/** |
|
| 569 | + * @param string $file |
|
| 570 | + */ |
|
| 568 | 571 | function determineIcon($file, $selFile, $mode) |
| 569 | 572 | { |
| 570 | 573 | $icons = array( |
@@ -709,6 +712,9 @@ discard block |
||
| 709 | 712 | return $path; |
| 710 | 713 | } |
| 711 | 714 | |
| 715 | +/** |
|
| 716 | + * @param string $string |
|
| 717 | + */ |
|
| 712 | 718 | function getExtension($string) |
| 713 | 719 | { |
| 714 | 720 | $pos = strrpos($string, '.'); |
@@ -744,6 +750,9 @@ discard block |
||
| 744 | 750 | return @mkdir($strPath); |
| 745 | 751 | } |
| 746 | 752 | |
| 753 | +/** |
|
| 754 | + * @param string $type |
|
| 755 | + */ |
|
| 747 | 756 | function logFileChange($type, $filename) |
| 748 | 757 | { |
| 749 | 758 | //global $_lang; |
@@ -801,7 +801,7 @@ |
||
| 801 | 801 | $complete_name = $path . str_replace('\\', '/', $zip_entry_name); |
| 802 | 802 | if (!file_exists($complete_path)) { |
| 803 | 803 | $tmp = ''; |
| 804 | - foreach (explode('/', $complete_path) AS $k) { |
|
| 804 | + foreach (explode('/', $complete_path) as $k) { |
|
| 805 | 805 | $tmp .= $k . '/'; |
| 806 | 806 | if (!is_dir($tmp)) { |
| 807 | 807 | mkdir($tmp, 0777); |
@@ -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]; |
@@ -160,6 +160,11 @@ discard block |
||
| 160 | 160 | return $output; |
| 161 | 161 | } |
| 162 | 162 | |
| 163 | +/** |
|
| 164 | + * @param integer $parent |
|
| 165 | + * @param string $filedir |
|
| 166 | + * @param string $mode |
|
| 167 | + */ |
|
| 163 | 168 | function importFiles($parent, $filedir, $files, $mode) { |
| 164 | 169 | global $modx; |
| 165 | 170 | global $_lang, $allowedfiles; |
@@ -302,6 +307,9 @@ discard block |
||
| 302 | 307 | } |
| 303 | 308 | } |
| 304 | 309 | |
| 310 | +/** |
|
| 311 | + * @param string $directory |
|
| 312 | + */ |
|
| 305 | 313 | function getFiles($directory, $listing = array(), $count = 0) { |
| 306 | 314 | global $_lang; |
| 307 | 315 | global $filesfound; |
@@ -326,6 +334,9 @@ discard block |
||
| 326 | 334 | return ($listing); |
| 327 | 335 | } |
| 328 | 336 | |
| 337 | +/** |
|
| 338 | + * @param string $filepath |
|
| 339 | + */ |
|
| 329 | 340 | function getFileContent($filepath) { |
| 330 | 341 | global $_lang; |
| 331 | 342 | // get the file |
@@ -353,6 +364,9 @@ discard block |
||
| 353 | 364 | return $new_array; |
| 354 | 365 | } |
| 355 | 366 | |
| 367 | +/** |
|
| 368 | + * @param null|string $src |
|
| 369 | + */ |
|
| 356 | 370 | function treatContent($src, $filename, $alias) { |
| 357 | 371 | global $modx; |
| 358 | 372 | |
@@ -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,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 = (int)$_POST['parent']; |
|
| 127 | + $parent = (int)$_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 | - $parent = (int)$_POST['parent']; |
|
| 127 | + $parent = (int) $_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 | } |
@@ -504,6 +504,9 @@ |
||
| 504 | 504 | return $iconsPrivate; |
| 505 | 505 | } |
| 506 | 506 | |
| 507 | +/** |
|
| 508 | + * @return string |
|
| 509 | + */ |
|
| 507 | 510 | function getNodeTitle($nodeNameSource, $row) { |
| 508 | 511 | global $modx; |
| 509 | 512 | |
@@ -10,7 +10,8 @@ discard block |
||
| 10 | 10 | * @param $theme |
| 11 | 11 | * @param string $hereid |
| 12 | 12 | */ |
| 13 | -function makeHTML($indent, $parent, $expandAll, $theme, $hereid = '') { |
|
| 13 | +function makeHTML($indent, $parent, $expandAll, $theme, $hereid = '') |
|
| 14 | +{ |
|
| 14 | 15 | global $modx; |
| 15 | 16 | global $icons, $iconsPrivate, $_style; |
| 16 | 17 | global $_lang, $opened, $opened2, $closed2; //added global vars |
@@ -450,7 +451,8 @@ discard block |
||
| 450 | 451 | return $output; |
| 451 | 452 | } |
| 452 | 453 | |
| 453 | -function getIconInfo($_style) { |
|
| 454 | +function getIconInfo($_style) |
|
| 455 | +{ |
|
| 454 | 456 | if(!isset($_style['tree_page_gif'])) { |
| 455 | 457 | $_style['tree_page_gif'] = $_style['tree_page']; |
| 456 | 458 | } |
@@ -477,7 +479,8 @@ discard block |
||
| 477 | 479 | return $icons; |
| 478 | 480 | } |
| 479 | 481 | |
| 480 | -function getPrivateIconInfo($_style) { |
|
| 482 | +function getPrivateIconInfo($_style) |
|
| 483 | +{ |
|
| 481 | 484 | if(!isset($_style['tree_page_gif_secure'])) { |
| 482 | 485 | $_style['tree_page_gif_secure'] = $_style['tree_page_secure']; |
| 483 | 486 | } |
@@ -504,7 +507,8 @@ discard block |
||
| 504 | 507 | return $iconsPrivate; |
| 505 | 508 | } |
| 506 | 509 | |
| 507 | -function getNodeTitle($nodeNameSource, $row) { |
|
| 510 | +function getNodeTitle($nodeNameSource, $row) |
|
| 511 | +{ |
|
| 508 | 512 | global $modx; |
| 509 | 513 | |
| 510 | 514 | switch($nodeNameSource) { |
@@ -550,7 +554,8 @@ discard block |
||
| 550 | 554 | return $nodetitle; |
| 551 | 555 | } |
| 552 | 556 | |
| 553 | -function isDateNode($nodeNameSource) { |
|
| 557 | +function isDateNode($nodeNameSource) |
|
| 558 | +{ |
|
| 554 | 559 | switch($nodeNameSource) { |
| 555 | 560 | case 'createdon': |
| 556 | 561 | case 'editedon': |
@@ -563,13 +568,15 @@ discard block |
||
| 563 | 568 | } |
| 564 | 569 | } |
| 565 | 570 | |
| 566 | -function checkIsFolder($parent = 0, $isfolder = 1) { |
|
| 571 | +function checkIsFolder($parent = 0, $isfolder = 1) |
|
| 572 | +{ |
|
| 567 | 573 | global $modx; |
| 568 | 574 | |
| 569 | 575 | return (int) $modx->db->getValue($modx->db->query('SELECT count(*) FROM ' . $modx->getFullTableName('site_content') . ' WHERE parent=' . $parent . ' AND isfolder=' . $isfolder . ' ')); |
| 570 | 576 | } |
| 571 | 577 | |
| 572 | -function _htmlentities($array) { |
|
| 578 | +function _htmlentities($array) |
|
| 579 | +{ |
|
| 573 | 580 | global $modx; |
| 574 | 581 | |
| 575 | 582 | $array = json_encode($array, JSON_UNESCAPED_UNICODE); |
@@ -578,7 +585,8 @@ discard block |
||
| 578 | 585 | return $array; |
| 579 | 586 | } |
| 580 | 587 | |
| 581 | -function getTplSingleNode() { |
|
| 588 | +function getTplSingleNode() |
|
| 589 | +{ |
|
| 582 | 590 | return '<div id="node[+id+]"><a class="[+treeNodeClass+]" |
| 583 | 591 | onclick="modx.tree.treeAction(event,[+id+]);" |
| 584 | 592 | oncontextmenu="modx.tree.showPopup(event,[+id+],\'[+nodetitle_esc+]\');" |
@@ -602,7 +610,8 @@ discard block |
||
| 602 | 610 | title="[+title+]">[+nodetitleDisplay+][+weblinkDisplay+]</span>[+pageIdDisplay+]</a></div>'; |
| 603 | 611 | } |
| 604 | 612 | |
| 605 | -function getTplFolderNode() { |
|
| 613 | +function getTplFolderNode() |
|
| 614 | +{ |
|
| 606 | 615 | return '<div id="node[+id+]"><a class="[+treeNodeClass+]" |
| 607 | 616 | onclick="modx.tree.treeAction(event,[+id+]);" |
| 608 | 617 | oncontextmenu="modx.tree.showPopup(event,[+id+],\'[+nodetitle_esc+]\');" |
@@ -638,7 +647,8 @@ discard block |
||
| 638 | 647 | title="[+title+]">[+nodetitleDisplay+][+weblinkDisplay+]</span>[+pageIdDisplay+]</a><div>'; |
| 639 | 648 | } |
| 640 | 649 | |
| 641 | -function getTplFolderNodeNotChildren() { |
|
| 650 | +function getTplFolderNodeNotChildren() |
|
| 651 | +{ |
|
| 642 | 652 | return '<div id="node[+id+]"><a class="[+treeNodeClass+]" |
| 643 | 653 | onclick="modx.tree.treeAction(event,[+id+]);" |
| 644 | 654 | oncontextmenu="modx.tree.showPopup(event,[+id+],\'[+nodetitle_esc+]\');" |
@@ -670,7 +680,8 @@ discard block |
||
| 670 | 680 | title="[+title+]">[+nodetitleDisplay+][+weblinkDisplay+]</span>[+pageIdDisplay+]</a><div>'; |
| 671 | 681 | } |
| 672 | 682 | |
| 673 | -function dbug($str, $flag = false) { |
|
| 683 | +function dbug($str, $flag = false) |
|
| 684 | +{ |
|
| 674 | 685 | print('<pre>'); |
| 675 | 686 | print_r($str); |
| 676 | 687 | print('</pre>'); |
@@ -1,6 +1,6 @@ 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 | |
| 6 | 6 | /** |
@@ -11,575 +11,575 @@ discard block |
||
| 11 | 11 | * @param string $hereid |
| 12 | 12 | */ |
| 13 | 13 | function makeHTML($indent, $parent, $expandAll, $theme, $hereid = '') { |
| 14 | - global $modx; |
|
| 15 | - global $icons, $iconsPrivate, $_style; |
|
| 16 | - global $_lang, $opened, $opened2, $closed2; //added global vars |
|
| 17 | - global $modx_textdir; |
|
| 18 | - |
|
| 19 | - $output = ''; |
|
| 20 | - |
|
| 21 | - // setup spacer |
|
| 22 | - $level = 0; |
|
| 23 | - $spacer = '<span class="indent">'; |
|
| 24 | - for($i = 2; $i <= $indent; $i++) { |
|
| 25 | - $spacer .= '<i></i>'; |
|
| 26 | - $level++; |
|
| 27 | - } |
|
| 28 | - $spacer .= '</span>'; |
|
| 29 | - |
|
| 30 | - // manage order-by |
|
| 31 | - if(!isset($_SESSION['tree_sortby']) && !isset($_SESSION['tree_sortdir'])) { |
|
| 32 | - // This is the first startup, set default sort order |
|
| 33 | - $_SESSION['tree_sortby'] = 'menuindex'; |
|
| 34 | - $_SESSION['tree_sortdir'] = 'ASC'; |
|
| 35 | - } |
|
| 36 | - |
|
| 37 | - switch($_SESSION['tree_sortby']) { |
|
| 38 | - case 'createdon': |
|
| 39 | - case 'editedon': |
|
| 40 | - case 'publishedon': |
|
| 41 | - case 'pub_date': |
|
| 42 | - case 'unpub_date': |
|
| 43 | - $sortby = sprintf('CASE WHEN %s IS NULL THEN 1 ELSE 0 END, %s', 'sc.' . $_SESSION['tree_sortby'], 'sc.' . $_SESSION['tree_sortby']); |
|
| 44 | - break; |
|
| 45 | - default: |
|
| 46 | - $sortby = 'sc.' . $_SESSION['tree_sortby']; |
|
| 47 | - }; |
|
| 48 | - |
|
| 49 | - $orderby = $modx->db->escape($sortby . ' ' . $_SESSION['tree_sortdir']); |
|
| 50 | - |
|
| 51 | - // Folder sorting gets special setup ;) Add menuindex and pagetitle |
|
| 52 | - if($_SESSION['tree_sortby'] == 'isfolder') { |
|
| 53 | - $orderby .= ', menuindex ASC, pagetitle'; |
|
| 54 | - } |
|
| 55 | - |
|
| 56 | - $tblsc = $modx->getFullTableName('site_content'); |
|
| 57 | - $tbldg = $modx->getFullTableName('document_groups'); |
|
| 58 | - $tblst = $modx->getFullTableName('site_templates'); |
|
| 59 | - // get document groups for current user |
|
| 60 | - $docgrp = (isset($_SESSION['mgrDocgroups']) && is_array($_SESSION['mgrDocgroups'])) ? implode(',', $_SESSION['mgrDocgroups']) : ''; |
|
| 61 | - $showProtected = false; |
|
| 62 | - if(isset ($modx->config['tree_show_protected'])) { |
|
| 63 | - $showProtected = (boolean) $modx->config['tree_show_protected']; |
|
| 64 | - } |
|
| 65 | - $mgrRole = (isset ($_SESSION['mgrRole']) && (string) $_SESSION['mgrRole'] === '1') ? '1' : '0'; |
|
| 66 | - if($showProtected == false) { |
|
| 67 | - $access = "AND (1={$mgrRole} OR sc.privatemgr=0" . (!$docgrp ? ')' : " OR dg.document_group IN ({$docgrp}))"); |
|
| 68 | - } else { |
|
| 69 | - $access = ''; |
|
| 70 | - } |
|
| 71 | - $docgrp_cond = $docgrp ? "OR dg.document_group IN ({$docgrp})" : ''; |
|
| 72 | - $field = "DISTINCT sc.id, pagetitle, longtitle, menutitle, parent, isfolder, published, pub_date, unpub_date, richtext, searchable, cacheable, deleted, type, template, templatename, menuindex, donthit, hidemenu, alias, contentType, privateweb, privatemgr, |
|
| 14 | + global $modx; |
|
| 15 | + global $icons, $iconsPrivate, $_style; |
|
| 16 | + global $_lang, $opened, $opened2, $closed2; //added global vars |
|
| 17 | + global $modx_textdir; |
|
| 18 | + |
|
| 19 | + $output = ''; |
|
| 20 | + |
|
| 21 | + // setup spacer |
|
| 22 | + $level = 0; |
|
| 23 | + $spacer = '<span class="indent">'; |
|
| 24 | + for($i = 2; $i <= $indent; $i++) { |
|
| 25 | + $spacer .= '<i></i>'; |
|
| 26 | + $level++; |
|
| 27 | + } |
|
| 28 | + $spacer .= '</span>'; |
|
| 29 | + |
|
| 30 | + // manage order-by |
|
| 31 | + if(!isset($_SESSION['tree_sortby']) && !isset($_SESSION['tree_sortdir'])) { |
|
| 32 | + // This is the first startup, set default sort order |
|
| 33 | + $_SESSION['tree_sortby'] = 'menuindex'; |
|
| 34 | + $_SESSION['tree_sortdir'] = 'ASC'; |
|
| 35 | + } |
|
| 36 | + |
|
| 37 | + switch($_SESSION['tree_sortby']) { |
|
| 38 | + case 'createdon': |
|
| 39 | + case 'editedon': |
|
| 40 | + case 'publishedon': |
|
| 41 | + case 'pub_date': |
|
| 42 | + case 'unpub_date': |
|
| 43 | + $sortby = sprintf('CASE WHEN %s IS NULL THEN 1 ELSE 0 END, %s', 'sc.' . $_SESSION['tree_sortby'], 'sc.' . $_SESSION['tree_sortby']); |
|
| 44 | + break; |
|
| 45 | + default: |
|
| 46 | + $sortby = 'sc.' . $_SESSION['tree_sortby']; |
|
| 47 | + }; |
|
| 48 | + |
|
| 49 | + $orderby = $modx->db->escape($sortby . ' ' . $_SESSION['tree_sortdir']); |
|
| 50 | + |
|
| 51 | + // Folder sorting gets special setup ;) Add menuindex and pagetitle |
|
| 52 | + if($_SESSION['tree_sortby'] == 'isfolder') { |
|
| 53 | + $orderby .= ', menuindex ASC, pagetitle'; |
|
| 54 | + } |
|
| 55 | + |
|
| 56 | + $tblsc = $modx->getFullTableName('site_content'); |
|
| 57 | + $tbldg = $modx->getFullTableName('document_groups'); |
|
| 58 | + $tblst = $modx->getFullTableName('site_templates'); |
|
| 59 | + // get document groups for current user |
|
| 60 | + $docgrp = (isset($_SESSION['mgrDocgroups']) && is_array($_SESSION['mgrDocgroups'])) ? implode(',', $_SESSION['mgrDocgroups']) : ''; |
|
| 61 | + $showProtected = false; |
|
| 62 | + if(isset ($modx->config['tree_show_protected'])) { |
|
| 63 | + $showProtected = (boolean) $modx->config['tree_show_protected']; |
|
| 64 | + } |
|
| 65 | + $mgrRole = (isset ($_SESSION['mgrRole']) && (string) $_SESSION['mgrRole'] === '1') ? '1' : '0'; |
|
| 66 | + if($showProtected == false) { |
|
| 67 | + $access = "AND (1={$mgrRole} OR sc.privatemgr=0" . (!$docgrp ? ')' : " OR dg.document_group IN ({$docgrp}))"); |
|
| 68 | + } else { |
|
| 69 | + $access = ''; |
|
| 70 | + } |
|
| 71 | + $docgrp_cond = $docgrp ? "OR dg.document_group IN ({$docgrp})" : ''; |
|
| 72 | + $field = "DISTINCT sc.id, pagetitle, longtitle, menutitle, parent, isfolder, published, pub_date, unpub_date, richtext, searchable, cacheable, deleted, type, template, templatename, menuindex, donthit, hidemenu, alias, contentType, privateweb, privatemgr, |
|
| 73 | 73 | MAX(IF(1={$mgrRole} OR sc.privatemgr=0 {$docgrp_cond}, 1, 0)) AS hasAccess, GROUP_CONCAT(document_group SEPARATOR ',') AS roles"; |
| 74 | - $from = "{$tblsc} AS sc LEFT JOIN {$tbldg} dg on dg.document = sc.id LEFT JOIN {$tblst} st on st.id = sc.template"; |
|
| 75 | - $where = "(parent={$parent}) {$access} GROUP BY sc.id"; |
|
| 76 | - $result = $modx->db->select($field, $from, $where, $orderby); |
|
| 77 | - if($modx->db->getRecordCount($result) == 0) { |
|
| 78 | - $output .= sprintf('<div><a class="empty">%s%s <span class="empty">%s</span></a></div>', $spacer, $_style['tree_deletedpage'], $_lang['empty_folder']); |
|
| 79 | - } |
|
| 80 | - |
|
| 81 | - $nodeNameSource = $_SESSION['tree_nodename'] == 'default' ? $modx->config['resource_tree_node_name'] : $_SESSION['tree_nodename']; |
|
| 82 | - |
|
| 83 | - while($row = $modx->db->getRow($result)) { |
|
| 84 | - $node = ''; |
|
| 85 | - |
|
| 86 | - $nodetitle = getNodeTitle($nodeNameSource, $row); |
|
| 87 | - $nodetitleDisplay = $nodetitle; |
|
| 88 | - |
|
| 89 | - $treeNodeClass = 'node'; |
|
| 90 | - $treeNodeClass .= $row['hasAccess'] == 0 ? ' protected' : ''; |
|
| 91 | - |
|
| 92 | - if($row['deleted'] == 1) { |
|
| 93 | - $treeNodeClass .= ' deleted'; |
|
| 94 | - //$nodetitleDisplay = sprintf('<span class="deletedNode">%s</span>', $nodetitle); |
|
| 95 | - } elseif($row['published'] == 0) { |
|
| 96 | - $treeNodeClass .= ' unpublished'; |
|
| 97 | - //$nodetitleDisplay = sprintf('<span class="unpublishedNode">%s</span>', $nodetitle); |
|
| 98 | - } elseif($row['hidemenu'] == 1) { |
|
| 99 | - $treeNodeClass .= ' hidemenu'; |
|
| 100 | - //$nodetitleDisplay = sprintf('<span class="notInMenuNode%s">%s</span>', $protectedClass, $nodetitle); |
|
| 101 | - } else { |
|
| 102 | - //$nodetitleDisplay = sprintf('<span class="publishedNode%s">%s</span>', $protectedClass, $nodetitle); |
|
| 103 | - } |
|
| 104 | - |
|
| 105 | - if($row['id'] == $hereid) { |
|
| 106 | - $treeNodeClass .= ' current'; |
|
| 107 | - } |
|
| 108 | - |
|
| 109 | - $weblinkDisplay = $row['type'] == 'reference' ? sprintf(' %s', $_style['tree_linkgo']) : ''; |
|
| 110 | - $pageIdDisplay = '<small>(' . ($modx_textdir ? '‏' : '') . $row['id'] . ')</small>'; |
|
| 111 | - |
|
| 112 | - // Prepare displaying user-locks |
|
| 113 | - $lockedByUser = ''; |
|
| 114 | - $rowLock = $modx->elementIsLocked(7, $row['id'], true); |
|
| 115 | - if($rowLock && $modx->hasPermission('display_locks')) { |
|
| 116 | - if($rowLock['sid'] == $modx->sid) { |
|
| 117 | - $title = $modx->parseText($_lang["lock_element_editing"], array( |
|
| 118 | - 'element_type' => $_lang["lock_element_type_7"], |
|
| 119 | - 'lasthit_df' => $rowLock['lasthit_df'] |
|
| 120 | - )); |
|
| 121 | - $lockedByUser = '<span title="' . $title . '" class="editResource">' . $_style['tree_preview_resource'] . '</span>'; |
|
| 122 | - } else { |
|
| 123 | - $title = $modx->parseText($_lang["lock_element_locked_by"], array( |
|
| 124 | - 'element_type' => $_lang["lock_element_type_7"], |
|
| 125 | - 'username' => $rowLock['username'], |
|
| 126 | - 'lasthit_df' => $rowLock['lasthit_df'] |
|
| 127 | - )); |
|
| 128 | - if($modx->hasPermission('remove_locks')) { |
|
| 129 | - $lockedByUser = '<span onclick="modx.tree.unlockElement(7, ' . $row['id'] . ', this);return false;" title="' . $title . '" class="lockedResource">' . $_style['icons_secured'] . '</span>'; |
|
| 130 | - } else { |
|
| 131 | - $lockedByUser = '<span title="' . $title . '" class="lockedResource">' . $_style['icons_secured'] . '</span>'; |
|
| 132 | - } |
|
| 133 | - } |
|
| 134 | - } |
|
| 135 | - |
|
| 136 | - $url = $modx->makeUrl($row['id']); |
|
| 137 | - |
|
| 138 | - $title = ''; |
|
| 139 | - if(isDateNode($nodeNameSource)) { |
|
| 140 | - $title = $_lang['pagetitle'] . ': ' . $row['pagetitle'] . '[+lf+]'; |
|
| 141 | - } |
|
| 142 | - $title .= $_lang['id'] . ': ' . $row['id']; |
|
| 143 | - $title .= '[+lf+]' . $_lang['resource_opt_menu_title'] . ': ' . $row['menutitle']; |
|
| 144 | - $title .= '[+lf+]' . $_lang['resource_opt_menu_index'] . ': ' . $row['menuindex']; |
|
| 145 | - $title .= '[+lf+]' . $_lang['alias'] . ': ' . (!empty($row['alias']) ? $row['alias'] : '-'); |
|
| 146 | - $title .= '[+lf+]' . $_lang['template'] . ': ' . $row['templatename']; |
|
| 147 | - $title .= '[+lf+]' . $_lang['publish_date'] . ': ' . $modx->toDateFormat($row['pub_date']); |
|
| 148 | - $title .= '[+lf+]' . $_lang['unpublish_date'] . ': ' . $modx->toDateFormat($row['unpub_date']); |
|
| 149 | - $title .= '[+lf+]' . $_lang['page_data_web_access'] . ': ' . ($row['privateweb'] ? $_lang['private'] : $_lang['public']); |
|
| 150 | - $title .= '[+lf+]' . $_lang['page_data_mgr_access'] . ': ' . ($row['privatemgr'] ? $_lang['private'] : $_lang['public']); |
|
| 151 | - $title .= '[+lf+]' . $_lang['resource_opt_richtext'] . ': ' . ($row['richtext'] == 0 ? $_lang['no'] : $_lang['yes']); |
|
| 152 | - $title .= '[+lf+]' . $_lang['page_data_searchable'] . ': ' . ($row['searchable'] == 0 ? $_lang['no'] : $_lang['yes']); |
|
| 153 | - $title .= '[+lf+]' . $_lang['page_data_cacheable'] . ': ' . ($row['cacheable'] == 0 ? $_lang['no'] : $_lang['yes']); |
|
| 154 | - $title = $modx->htmlspecialchars($title); |
|
| 155 | - $title = str_replace('[+lf+]', ' ', $title); // replace line-breaks with empty space as fall-back |
|
| 156 | - |
|
| 157 | - $data = array( |
|
| 158 | - 'id' => $row['id'], |
|
| 159 | - 'pagetitle' => $row['pagetitle'], |
|
| 160 | - 'longtitle' => $row['longtitle'], |
|
| 161 | - 'menutitle' => $row['menutitle'], |
|
| 162 | - 'parent' => $parent, |
|
| 163 | - 'isfolder' => $row['isfolder'], |
|
| 164 | - 'published' => $row['published'], |
|
| 165 | - 'deleted' => $row['deleted'], |
|
| 166 | - 'type' => $row['type'], |
|
| 167 | - 'menuindex' => $row['menuindex'], |
|
| 168 | - 'donthit' => $row['donthit'], |
|
| 169 | - 'hidemenu' => $row['hidemenu'], |
|
| 170 | - 'alias' => $row['alias'], |
|
| 171 | - 'contenttype' => $row['contentType'], |
|
| 172 | - 'privateweb' => $row['privateweb'], |
|
| 173 | - 'privatemgr' => $row['privatemgr'], |
|
| 174 | - 'hasAccess' => $row['hasAccess'], |
|
| 175 | - 'template' => $row['template'], |
|
| 176 | - 'nodetitle' => $nodetitle, |
|
| 177 | - 'url' => $url, |
|
| 178 | - 'title' => $title, |
|
| 179 | - 'nodetitleDisplay' => $nodetitleDisplay, |
|
| 180 | - 'weblinkDisplay' => $weblinkDisplay, |
|
| 181 | - 'pageIdDisplay' => $pageIdDisplay, |
|
| 182 | - 'lockedByUser' => $lockedByUser, |
|
| 183 | - 'treeNodeClass' => $treeNodeClass, |
|
| 184 | - 'treeNodeSelected' => $row['id'] == $hereid ? ' treeNodeSelected' : '', |
|
| 185 | - 'tree_page_click' => $modx->config['tree_page_click'], |
|
| 186 | - 'showChildren' => 1, |
|
| 187 | - 'openFolder' => 1, |
|
| 188 | - 'contextmenu' => '', |
|
| 189 | - 'tree_minusnode' => $_style['tree_minusnode'], |
|
| 190 | - 'tree_plusnode' => $_style['tree_plusnode'], |
|
| 191 | - 'spacer' => $spacer, |
|
| 192 | - 'subMenuState' => '', |
|
| 193 | - 'level' => $level, |
|
| 194 | - 'isPrivate' => 0, |
|
| 195 | - 'roles' => ($row['roles'] ? $row['roles'] : '') |
|
| 196 | - ); |
|
| 197 | - |
|
| 198 | - $ph = $data; |
|
| 199 | - $ph['nodetitle_esc'] = addslashes($nodetitle); |
|
| 200 | - $ph['indent'] = $indent + 1; |
|
| 201 | - $ph['expandAll'] = $expandAll; |
|
| 202 | - $ph['isPrivate'] = ($row['privateweb'] || $row['privatemgr']) ? 1 : 0; |
|
| 203 | - |
|
| 204 | - if(!$row['isfolder']) { |
|
| 205 | - $tpl = getTplSingleNode(); |
|
| 206 | - switch($row['id']) { |
|
| 207 | - case $modx->config['site_start'] : |
|
| 208 | - $icon = $_style['tree_page_home']; |
|
| 209 | - break; |
|
| 210 | - case $modx->config['error_page'] : |
|
| 211 | - $icon = $_style['tree_page_404']; |
|
| 212 | - break; |
|
| 213 | - case $modx->config['site_unavailable_page'] : |
|
| 214 | - $icon = $_style['tree_page_hourglass']; |
|
| 215 | - break; |
|
| 216 | - case $modx->config['unauthorized_page'] : |
|
| 217 | - $icon = $_style['tree_page_info']; |
|
| 218 | - break; |
|
| 219 | - default: |
|
| 220 | - if(isset($icons[$row['contentType']])) { |
|
| 221 | - $icon = $icons[$row['contentType']]; |
|
| 222 | - } else { |
|
| 223 | - $icon = $_style['tree_page']; |
|
| 224 | - } |
|
| 225 | - } |
|
| 226 | - $ph['icon'] = $icon; |
|
| 227 | - |
|
| 228 | - // invoke OnManagerNodePrerender event |
|
| 229 | - $prenode = $modx->invokeEvent("OnManagerNodePrerender", array('ph' => $ph)); |
|
| 230 | - if(is_array($prenode)) { |
|
| 231 | - $phnew = array(); |
|
| 232 | - foreach($prenode as $pnode) { |
|
| 233 | - $phnew = array_merge($phnew, unserialize($pnode)); |
|
| 234 | - } |
|
| 235 | - $ph = (count($phnew) > 0) ? $phnew : $ph; |
|
| 236 | - } |
|
| 237 | - |
|
| 238 | - if($ph['contextmenu']) { |
|
| 239 | - $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"'; |
|
| 240 | - } |
|
| 241 | - |
|
| 242 | - if($_SESSION['tree_show_only_folders']) { |
|
| 243 | - if($row['parent'] == 0) { |
|
| 244 | - $node .= $modx->parseText($tpl, $ph); |
|
| 245 | - } else { |
|
| 246 | - $node .= ''; |
|
| 247 | - } |
|
| 248 | - } else { |
|
| 249 | - $node .= $modx->parseText($tpl, $ph); |
|
| 250 | - } |
|
| 251 | - |
|
| 252 | - } else { |
|
| 253 | - $ph['icon_folder_open'] = $_style['tree_folderopen_new']; |
|
| 254 | - $ph['icon_folder_close'] = $_style['tree_folder_new']; |
|
| 255 | - |
|
| 256 | - if($_SESSION['tree_show_only_folders']) { |
|
| 257 | - $tpl = getTplFolderNodeNotChildren(); |
|
| 258 | - $checkFolders = checkIsFolder($row['id'], 1) ? 1 : 0; // folders |
|
| 259 | - $checkDocs = checkIsFolder($row['id'], 0) ? 1 : 0; // no folders |
|
| 260 | - $ph['tree_page_click'] = 3; |
|
| 261 | - |
|
| 262 | - // expandAll: two type for partial expansion |
|
| 263 | - if($expandAll == 1 || ($expandAll == 2 && in_array($row['id'], $opened))) { |
|
| 264 | - if($expandAll == 1) { |
|
| 265 | - $opened2[] = $row['id']; |
|
| 266 | - } |
|
| 267 | - $ph['icon'] = $ph['icon_folder_open']; |
|
| 268 | - $ph['icon_node_toggle'] = $ph['tree_minusnode']; |
|
| 269 | - $ph['node_toggle'] = 1; |
|
| 270 | - $ph['subMenuState'] = ' open'; |
|
| 271 | - |
|
| 272 | - if(($checkDocs && !$checkFolders) || (!$checkDocs && !$checkFolders)) { |
|
| 273 | - $ph['showChildren'] = 1; |
|
| 274 | - $ph['icon_node_toggle'] = ''; |
|
| 275 | - $ph['icon'] = $ph['icon_folder_close']; |
|
| 276 | - } elseif(!$checkDocs && $checkFolders) { |
|
| 277 | - $ph['showChildren'] = 0; |
|
| 278 | - $ph['openFolder'] = 2; |
|
| 279 | - } else { |
|
| 280 | - $ph['openFolder'] = 2; |
|
| 281 | - } |
|
| 282 | - |
|
| 283 | - // invoke OnManagerNodePrerender event |
|
| 284 | - $prenode = $modx->invokeEvent("OnManagerNodePrerender", array( |
|
| 285 | - 'ph' => $ph, |
|
| 286 | - 'opened' => '1' |
|
| 287 | - )); |
|
| 288 | - if(is_array($prenode)) { |
|
| 289 | - $phnew = array(); |
|
| 290 | - foreach($prenode as $pnode) { |
|
| 291 | - $phnew = array_merge($phnew, unserialize($pnode)); |
|
| 292 | - } |
|
| 293 | - $ph = (count($phnew) > 0) ? $phnew : $ph; |
|
| 294 | - } |
|
| 295 | - |
|
| 296 | - if($ph['contextmenu']) { |
|
| 297 | - $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"'; |
|
| 298 | - } |
|
| 299 | - |
|
| 300 | - $node .= $modx->parseText($tpl, $ph); |
|
| 301 | - if($checkFolders) { |
|
| 302 | - $node .= makeHTML($indent + 1, $row['id'], $expandAll, $theme, $hereid); |
|
| 303 | - } |
|
| 304 | - $node .= '</div></div>'; |
|
| 305 | - } else { |
|
| 306 | - $closed2[] = $row['id']; |
|
| 307 | - $ph['icon'] = $ph['icon_folder_close']; |
|
| 308 | - $ph['icon_node_toggle'] = $ph['tree_plusnode']; |
|
| 309 | - $ph['node_toggle'] = 0; |
|
| 310 | - |
|
| 311 | - if(($checkDocs && !$checkFolders) || (!$checkDocs && !$checkFolders)) { |
|
| 312 | - $ph['showChildren'] = 1; |
|
| 313 | - $ph['icon_node_toggle'] = ''; |
|
| 314 | - } elseif(!$checkDocs && $checkFolders) { |
|
| 315 | - $ph['showChildren'] = 0; |
|
| 316 | - $ph['openFolder'] = 2; |
|
| 317 | - } else { |
|
| 318 | - $ph['openFolder'] = 2; |
|
| 319 | - } |
|
| 320 | - |
|
| 321 | - // invoke OnManagerNodePrerender event |
|
| 322 | - $prenode = $modx->invokeEvent("OnManagerNodePrerender", array( |
|
| 323 | - 'ph' => $ph, |
|
| 324 | - 'opened' => '0' |
|
| 325 | - )); |
|
| 326 | - if(is_array($prenode)) { |
|
| 327 | - $phnew = array(); |
|
| 328 | - foreach($prenode as $pnode) { |
|
| 329 | - $phnew = array_merge($phnew, unserialize($pnode)); |
|
| 330 | - } |
|
| 331 | - $ph = (count($phnew) > 0) ? $phnew : $ph; |
|
| 332 | - } |
|
| 333 | - |
|
| 334 | - if($ph['contextmenu']) { |
|
| 335 | - $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"'; |
|
| 336 | - } |
|
| 337 | - |
|
| 338 | - $node .= $modx->parseText($tpl, $ph); |
|
| 339 | - $node .= '</div></div>'; |
|
| 340 | - } |
|
| 341 | - } else { |
|
| 342 | - $tpl = getTplFolderNode(); |
|
| 343 | - // expandAll: two type for partial expansion |
|
| 344 | - if($expandAll == 1 || ($expandAll == 2 && in_array($row['id'], $opened))) { |
|
| 345 | - if($expandAll == 1) { |
|
| 346 | - $opened2[] = $row['id']; |
|
| 347 | - } |
|
| 348 | - $ph['icon'] = $ph['icon_folder_open']; |
|
| 349 | - $ph['icon_node_toggle'] = $ph['tree_minusnode']; |
|
| 350 | - $ph['node_toggle'] = 1; |
|
| 351 | - $ph['subMenuState'] = ' open'; |
|
| 352 | - |
|
| 353 | - if($ph['donthit'] == 1) { |
|
| 354 | - $ph['tree_page_click'] = 3; |
|
| 355 | - $ph['icon_node_toggle'] = ''; |
|
| 356 | - $ph['icon'] = $ph['icon_folder_close']; |
|
| 357 | - $ph['showChildren'] = 0; |
|
| 358 | - } |
|
| 359 | - |
|
| 360 | - // invoke OnManagerNodePrerender event |
|
| 361 | - $prenode = $modx->invokeEvent("OnManagerNodePrerender", array( |
|
| 362 | - 'ph' => $ph, |
|
| 363 | - 'opened' => '1' |
|
| 364 | - )); |
|
| 365 | - if(is_array($prenode)) { |
|
| 366 | - $phnew = array(); |
|
| 367 | - foreach($prenode as $pnode) { |
|
| 368 | - $phnew = array_merge($phnew, unserialize($pnode)); |
|
| 369 | - } |
|
| 370 | - $ph = (count($phnew) > 0) ? $phnew : $ph; |
|
| 371 | - if($ph['showChildren'] == 0) { |
|
| 372 | - unset($opened2[$row['id']]); |
|
| 373 | - $ph['node_toggle'] = 0; |
|
| 374 | - $ph['subMenuState'] = ''; |
|
| 375 | - } |
|
| 376 | - } |
|
| 377 | - |
|
| 378 | - if($ph['showChildren'] == 0) { |
|
| 379 | - $ph['icon_node_toggle'] = ''; |
|
| 380 | - $ph['donthit'] = 1; |
|
| 381 | - $ph['icon'] = $ph['icon_folder_close']; |
|
| 382 | - $tpl = getTplFolderNodeNotChildren(); |
|
| 383 | - } |
|
| 384 | - |
|
| 385 | - if($ph['contextmenu']) { |
|
| 386 | - $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"'; |
|
| 387 | - } |
|
| 388 | - |
|
| 389 | - $node .= $modx->parseText($tpl, $ph); |
|
| 390 | - if($ph['donthit'] == 0) { |
|
| 391 | - $node .= makeHTML($indent + 1, $row['id'], $expandAll, $theme, $hereid); |
|
| 392 | - } |
|
| 393 | - $node .= '</div></div>'; |
|
| 394 | - } else { |
|
| 395 | - $closed2[] = $row['id']; |
|
| 396 | - $ph['icon'] = $ph['icon_folder_close']; |
|
| 397 | - $ph['icon_node_toggle'] = $ph['tree_plusnode']; |
|
| 398 | - $ph['node_toggle'] = 0; |
|
| 399 | - |
|
| 400 | - if($ph['donthit'] == 1) { |
|
| 401 | - $ph['tree_page_click'] = 3; |
|
| 402 | - $ph['icon_node_toggle'] = ''; |
|
| 403 | - $ph['icon'] = $ph['icon_folder_close']; |
|
| 404 | - $ph['showChildren'] = 0; |
|
| 405 | - } |
|
| 406 | - |
|
| 407 | - // invoke OnManagerNodePrerender event |
|
| 408 | - $prenode = $modx->invokeEvent("OnManagerNodePrerender", array( |
|
| 409 | - 'ph' => $ph, |
|
| 410 | - 'opened' => '0' |
|
| 411 | - )); |
|
| 412 | - if(is_array($prenode)) { |
|
| 413 | - $phnew = array(); |
|
| 414 | - foreach($prenode as $pnode) { |
|
| 415 | - $phnew = array_merge($phnew, unserialize($pnode)); |
|
| 416 | - } |
|
| 417 | - $ph = (count($phnew) > 0) ? $phnew : $ph; |
|
| 418 | - } |
|
| 419 | - |
|
| 420 | - if($ph['showChildren'] == 0) { |
|
| 421 | - $ph['icon_node_toggle'] = ''; |
|
| 422 | - $ph['donthit'] = 1; |
|
| 423 | - $ph['icon'] = $ph['icon_folder_close']; |
|
| 424 | - $tpl = getTplFolderNodeNotChildren(); |
|
| 425 | - } |
|
| 426 | - |
|
| 427 | - if($ph['contextmenu']) { |
|
| 428 | - $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"'; |
|
| 429 | - } |
|
| 430 | - |
|
| 431 | - $node .= $modx->parseText($tpl, $ph); |
|
| 432 | - $node .= '</div></div>'; |
|
| 433 | - } |
|
| 434 | - } |
|
| 435 | - } |
|
| 436 | - |
|
| 437 | - // invoke OnManagerNodeRender event |
|
| 438 | - $data['node'] = $node; |
|
| 439 | - $evtOut = $modx->invokeEvent('OnManagerNodeRender', $data); |
|
| 440 | - if(is_array($evtOut)) { |
|
| 441 | - $evtOut = implode("\n", $evtOut); |
|
| 442 | - } |
|
| 443 | - if($evtOut != '') { |
|
| 444 | - $node = trim($evtOut); |
|
| 445 | - } |
|
| 446 | - |
|
| 447 | - $output .= $node; |
|
| 448 | - } |
|
| 449 | - |
|
| 450 | - return $output; |
|
| 74 | + $from = "{$tblsc} AS sc LEFT JOIN {$tbldg} dg on dg.document = sc.id LEFT JOIN {$tblst} st on st.id = sc.template"; |
|
| 75 | + $where = "(parent={$parent}) {$access} GROUP BY sc.id"; |
|
| 76 | + $result = $modx->db->select($field, $from, $where, $orderby); |
|
| 77 | + if($modx->db->getRecordCount($result) == 0) { |
|
| 78 | + $output .= sprintf('<div><a class="empty">%s%s <span class="empty">%s</span></a></div>', $spacer, $_style['tree_deletedpage'], $_lang['empty_folder']); |
|
| 79 | + } |
|
| 80 | + |
|
| 81 | + $nodeNameSource = $_SESSION['tree_nodename'] == 'default' ? $modx->config['resource_tree_node_name'] : $_SESSION['tree_nodename']; |
|
| 82 | + |
|
| 83 | + while($row = $modx->db->getRow($result)) { |
|
| 84 | + $node = ''; |
|
| 85 | + |
|
| 86 | + $nodetitle = getNodeTitle($nodeNameSource, $row); |
|
| 87 | + $nodetitleDisplay = $nodetitle; |
|
| 88 | + |
|
| 89 | + $treeNodeClass = 'node'; |
|
| 90 | + $treeNodeClass .= $row['hasAccess'] == 0 ? ' protected' : ''; |
|
| 91 | + |
|
| 92 | + if($row['deleted'] == 1) { |
|
| 93 | + $treeNodeClass .= ' deleted'; |
|
| 94 | + //$nodetitleDisplay = sprintf('<span class="deletedNode">%s</span>', $nodetitle); |
|
| 95 | + } elseif($row['published'] == 0) { |
|
| 96 | + $treeNodeClass .= ' unpublished'; |
|
| 97 | + //$nodetitleDisplay = sprintf('<span class="unpublishedNode">%s</span>', $nodetitle); |
|
| 98 | + } elseif($row['hidemenu'] == 1) { |
|
| 99 | + $treeNodeClass .= ' hidemenu'; |
|
| 100 | + //$nodetitleDisplay = sprintf('<span class="notInMenuNode%s">%s</span>', $protectedClass, $nodetitle); |
|
| 101 | + } else { |
|
| 102 | + //$nodetitleDisplay = sprintf('<span class="publishedNode%s">%s</span>', $protectedClass, $nodetitle); |
|
| 103 | + } |
|
| 104 | + |
|
| 105 | + if($row['id'] == $hereid) { |
|
| 106 | + $treeNodeClass .= ' current'; |
|
| 107 | + } |
|
| 108 | + |
|
| 109 | + $weblinkDisplay = $row['type'] == 'reference' ? sprintf(' %s', $_style['tree_linkgo']) : ''; |
|
| 110 | + $pageIdDisplay = '<small>(' . ($modx_textdir ? '‏' : '') . $row['id'] . ')</small>'; |
|
| 111 | + |
|
| 112 | + // Prepare displaying user-locks |
|
| 113 | + $lockedByUser = ''; |
|
| 114 | + $rowLock = $modx->elementIsLocked(7, $row['id'], true); |
|
| 115 | + if($rowLock && $modx->hasPermission('display_locks')) { |
|
| 116 | + if($rowLock['sid'] == $modx->sid) { |
|
| 117 | + $title = $modx->parseText($_lang["lock_element_editing"], array( |
|
| 118 | + 'element_type' => $_lang["lock_element_type_7"], |
|
| 119 | + 'lasthit_df' => $rowLock['lasthit_df'] |
|
| 120 | + )); |
|
| 121 | + $lockedByUser = '<span title="' . $title . '" class="editResource">' . $_style['tree_preview_resource'] . '</span>'; |
|
| 122 | + } else { |
|
| 123 | + $title = $modx->parseText($_lang["lock_element_locked_by"], array( |
|
| 124 | + 'element_type' => $_lang["lock_element_type_7"], |
|
| 125 | + 'username' => $rowLock['username'], |
|
| 126 | + 'lasthit_df' => $rowLock['lasthit_df'] |
|
| 127 | + )); |
|
| 128 | + if($modx->hasPermission('remove_locks')) { |
|
| 129 | + $lockedByUser = '<span onclick="modx.tree.unlockElement(7, ' . $row['id'] . ', this);return false;" title="' . $title . '" class="lockedResource">' . $_style['icons_secured'] . '</span>'; |
|
| 130 | + } else { |
|
| 131 | + $lockedByUser = '<span title="' . $title . '" class="lockedResource">' . $_style['icons_secured'] . '</span>'; |
|
| 132 | + } |
|
| 133 | + } |
|
| 134 | + } |
|
| 135 | + |
|
| 136 | + $url = $modx->makeUrl($row['id']); |
|
| 137 | + |
|
| 138 | + $title = ''; |
|
| 139 | + if(isDateNode($nodeNameSource)) { |
|
| 140 | + $title = $_lang['pagetitle'] . ': ' . $row['pagetitle'] . '[+lf+]'; |
|
| 141 | + } |
|
| 142 | + $title .= $_lang['id'] . ': ' . $row['id']; |
|
| 143 | + $title .= '[+lf+]' . $_lang['resource_opt_menu_title'] . ': ' . $row['menutitle']; |
|
| 144 | + $title .= '[+lf+]' . $_lang['resource_opt_menu_index'] . ': ' . $row['menuindex']; |
|
| 145 | + $title .= '[+lf+]' . $_lang['alias'] . ': ' . (!empty($row['alias']) ? $row['alias'] : '-'); |
|
| 146 | + $title .= '[+lf+]' . $_lang['template'] . ': ' . $row['templatename']; |
|
| 147 | + $title .= '[+lf+]' . $_lang['publish_date'] . ': ' . $modx->toDateFormat($row['pub_date']); |
|
| 148 | + $title .= '[+lf+]' . $_lang['unpublish_date'] . ': ' . $modx->toDateFormat($row['unpub_date']); |
|
| 149 | + $title .= '[+lf+]' . $_lang['page_data_web_access'] . ': ' . ($row['privateweb'] ? $_lang['private'] : $_lang['public']); |
|
| 150 | + $title .= '[+lf+]' . $_lang['page_data_mgr_access'] . ': ' . ($row['privatemgr'] ? $_lang['private'] : $_lang['public']); |
|
| 151 | + $title .= '[+lf+]' . $_lang['resource_opt_richtext'] . ': ' . ($row['richtext'] == 0 ? $_lang['no'] : $_lang['yes']); |
|
| 152 | + $title .= '[+lf+]' . $_lang['page_data_searchable'] . ': ' . ($row['searchable'] == 0 ? $_lang['no'] : $_lang['yes']); |
|
| 153 | + $title .= '[+lf+]' . $_lang['page_data_cacheable'] . ': ' . ($row['cacheable'] == 0 ? $_lang['no'] : $_lang['yes']); |
|
| 154 | + $title = $modx->htmlspecialchars($title); |
|
| 155 | + $title = str_replace('[+lf+]', ' ', $title); // replace line-breaks with empty space as fall-back |
|
| 156 | + |
|
| 157 | + $data = array( |
|
| 158 | + 'id' => $row['id'], |
|
| 159 | + 'pagetitle' => $row['pagetitle'], |
|
| 160 | + 'longtitle' => $row['longtitle'], |
|
| 161 | + 'menutitle' => $row['menutitle'], |
|
| 162 | + 'parent' => $parent, |
|
| 163 | + 'isfolder' => $row['isfolder'], |
|
| 164 | + 'published' => $row['published'], |
|
| 165 | + 'deleted' => $row['deleted'], |
|
| 166 | + 'type' => $row['type'], |
|
| 167 | + 'menuindex' => $row['menuindex'], |
|
| 168 | + 'donthit' => $row['donthit'], |
|
| 169 | + 'hidemenu' => $row['hidemenu'], |
|
| 170 | + 'alias' => $row['alias'], |
|
| 171 | + 'contenttype' => $row['contentType'], |
|
| 172 | + 'privateweb' => $row['privateweb'], |
|
| 173 | + 'privatemgr' => $row['privatemgr'], |
|
| 174 | + 'hasAccess' => $row['hasAccess'], |
|
| 175 | + 'template' => $row['template'], |
|
| 176 | + 'nodetitle' => $nodetitle, |
|
| 177 | + 'url' => $url, |
|
| 178 | + 'title' => $title, |
|
| 179 | + 'nodetitleDisplay' => $nodetitleDisplay, |
|
| 180 | + 'weblinkDisplay' => $weblinkDisplay, |
|
| 181 | + 'pageIdDisplay' => $pageIdDisplay, |
|
| 182 | + 'lockedByUser' => $lockedByUser, |
|
| 183 | + 'treeNodeClass' => $treeNodeClass, |
|
| 184 | + 'treeNodeSelected' => $row['id'] == $hereid ? ' treeNodeSelected' : '', |
|
| 185 | + 'tree_page_click' => $modx->config['tree_page_click'], |
|
| 186 | + 'showChildren' => 1, |
|
| 187 | + 'openFolder' => 1, |
|
| 188 | + 'contextmenu' => '', |
|
| 189 | + 'tree_minusnode' => $_style['tree_minusnode'], |
|
| 190 | + 'tree_plusnode' => $_style['tree_plusnode'], |
|
| 191 | + 'spacer' => $spacer, |
|
| 192 | + 'subMenuState' => '', |
|
| 193 | + 'level' => $level, |
|
| 194 | + 'isPrivate' => 0, |
|
| 195 | + 'roles' => ($row['roles'] ? $row['roles'] : '') |
|
| 196 | + ); |
|
| 197 | + |
|
| 198 | + $ph = $data; |
|
| 199 | + $ph['nodetitle_esc'] = addslashes($nodetitle); |
|
| 200 | + $ph['indent'] = $indent + 1; |
|
| 201 | + $ph['expandAll'] = $expandAll; |
|
| 202 | + $ph['isPrivate'] = ($row['privateweb'] || $row['privatemgr']) ? 1 : 0; |
|
| 203 | + |
|
| 204 | + if(!$row['isfolder']) { |
|
| 205 | + $tpl = getTplSingleNode(); |
|
| 206 | + switch($row['id']) { |
|
| 207 | + case $modx->config['site_start'] : |
|
| 208 | + $icon = $_style['tree_page_home']; |
|
| 209 | + break; |
|
| 210 | + case $modx->config['error_page'] : |
|
| 211 | + $icon = $_style['tree_page_404']; |
|
| 212 | + break; |
|
| 213 | + case $modx->config['site_unavailable_page'] : |
|
| 214 | + $icon = $_style['tree_page_hourglass']; |
|
| 215 | + break; |
|
| 216 | + case $modx->config['unauthorized_page'] : |
|
| 217 | + $icon = $_style['tree_page_info']; |
|
| 218 | + break; |
|
| 219 | + default: |
|
| 220 | + if(isset($icons[$row['contentType']])) { |
|
| 221 | + $icon = $icons[$row['contentType']]; |
|
| 222 | + } else { |
|
| 223 | + $icon = $_style['tree_page']; |
|
| 224 | + } |
|
| 225 | + } |
|
| 226 | + $ph['icon'] = $icon; |
|
| 227 | + |
|
| 228 | + // invoke OnManagerNodePrerender event |
|
| 229 | + $prenode = $modx->invokeEvent("OnManagerNodePrerender", array('ph' => $ph)); |
|
| 230 | + if(is_array($prenode)) { |
|
| 231 | + $phnew = array(); |
|
| 232 | + foreach($prenode as $pnode) { |
|
| 233 | + $phnew = array_merge($phnew, unserialize($pnode)); |
|
| 234 | + } |
|
| 235 | + $ph = (count($phnew) > 0) ? $phnew : $ph; |
|
| 236 | + } |
|
| 237 | + |
|
| 238 | + if($ph['contextmenu']) { |
|
| 239 | + $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"'; |
|
| 240 | + } |
|
| 241 | + |
|
| 242 | + if($_SESSION['tree_show_only_folders']) { |
|
| 243 | + if($row['parent'] == 0) { |
|
| 244 | + $node .= $modx->parseText($tpl, $ph); |
|
| 245 | + } else { |
|
| 246 | + $node .= ''; |
|
| 247 | + } |
|
| 248 | + } else { |
|
| 249 | + $node .= $modx->parseText($tpl, $ph); |
|
| 250 | + } |
|
| 251 | + |
|
| 252 | + } else { |
|
| 253 | + $ph['icon_folder_open'] = $_style['tree_folderopen_new']; |
|
| 254 | + $ph['icon_folder_close'] = $_style['tree_folder_new']; |
|
| 255 | + |
|
| 256 | + if($_SESSION['tree_show_only_folders']) { |
|
| 257 | + $tpl = getTplFolderNodeNotChildren(); |
|
| 258 | + $checkFolders = checkIsFolder($row['id'], 1) ? 1 : 0; // folders |
|
| 259 | + $checkDocs = checkIsFolder($row['id'], 0) ? 1 : 0; // no folders |
|
| 260 | + $ph['tree_page_click'] = 3; |
|
| 261 | + |
|
| 262 | + // expandAll: two type for partial expansion |
|
| 263 | + if($expandAll == 1 || ($expandAll == 2 && in_array($row['id'], $opened))) { |
|
| 264 | + if($expandAll == 1) { |
|
| 265 | + $opened2[] = $row['id']; |
|
| 266 | + } |
|
| 267 | + $ph['icon'] = $ph['icon_folder_open']; |
|
| 268 | + $ph['icon_node_toggle'] = $ph['tree_minusnode']; |
|
| 269 | + $ph['node_toggle'] = 1; |
|
| 270 | + $ph['subMenuState'] = ' open'; |
|
| 271 | + |
|
| 272 | + if(($checkDocs && !$checkFolders) || (!$checkDocs && !$checkFolders)) { |
|
| 273 | + $ph['showChildren'] = 1; |
|
| 274 | + $ph['icon_node_toggle'] = ''; |
|
| 275 | + $ph['icon'] = $ph['icon_folder_close']; |
|
| 276 | + } elseif(!$checkDocs && $checkFolders) { |
|
| 277 | + $ph['showChildren'] = 0; |
|
| 278 | + $ph['openFolder'] = 2; |
|
| 279 | + } else { |
|
| 280 | + $ph['openFolder'] = 2; |
|
| 281 | + } |
|
| 282 | + |
|
| 283 | + // invoke OnManagerNodePrerender event |
|
| 284 | + $prenode = $modx->invokeEvent("OnManagerNodePrerender", array( |
|
| 285 | + 'ph' => $ph, |
|
| 286 | + 'opened' => '1' |
|
| 287 | + )); |
|
| 288 | + if(is_array($prenode)) { |
|
| 289 | + $phnew = array(); |
|
| 290 | + foreach($prenode as $pnode) { |
|
| 291 | + $phnew = array_merge($phnew, unserialize($pnode)); |
|
| 292 | + } |
|
| 293 | + $ph = (count($phnew) > 0) ? $phnew : $ph; |
|
| 294 | + } |
|
| 295 | + |
|
| 296 | + if($ph['contextmenu']) { |
|
| 297 | + $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"'; |
|
| 298 | + } |
|
| 299 | + |
|
| 300 | + $node .= $modx->parseText($tpl, $ph); |
|
| 301 | + if($checkFolders) { |
|
| 302 | + $node .= makeHTML($indent + 1, $row['id'], $expandAll, $theme, $hereid); |
|
| 303 | + } |
|
| 304 | + $node .= '</div></div>'; |
|
| 305 | + } else { |
|
| 306 | + $closed2[] = $row['id']; |
|
| 307 | + $ph['icon'] = $ph['icon_folder_close']; |
|
| 308 | + $ph['icon_node_toggle'] = $ph['tree_plusnode']; |
|
| 309 | + $ph['node_toggle'] = 0; |
|
| 310 | + |
|
| 311 | + if(($checkDocs && !$checkFolders) || (!$checkDocs && !$checkFolders)) { |
|
| 312 | + $ph['showChildren'] = 1; |
|
| 313 | + $ph['icon_node_toggle'] = ''; |
|
| 314 | + } elseif(!$checkDocs && $checkFolders) { |
|
| 315 | + $ph['showChildren'] = 0; |
|
| 316 | + $ph['openFolder'] = 2; |
|
| 317 | + } else { |
|
| 318 | + $ph['openFolder'] = 2; |
|
| 319 | + } |
|
| 320 | + |
|
| 321 | + // invoke OnManagerNodePrerender event |
|
| 322 | + $prenode = $modx->invokeEvent("OnManagerNodePrerender", array( |
|
| 323 | + 'ph' => $ph, |
|
| 324 | + 'opened' => '0' |
|
| 325 | + )); |
|
| 326 | + if(is_array($prenode)) { |
|
| 327 | + $phnew = array(); |
|
| 328 | + foreach($prenode as $pnode) { |
|
| 329 | + $phnew = array_merge($phnew, unserialize($pnode)); |
|
| 330 | + } |
|
| 331 | + $ph = (count($phnew) > 0) ? $phnew : $ph; |
|
| 332 | + } |
|
| 333 | + |
|
| 334 | + if($ph['contextmenu']) { |
|
| 335 | + $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"'; |
|
| 336 | + } |
|
| 337 | + |
|
| 338 | + $node .= $modx->parseText($tpl, $ph); |
|
| 339 | + $node .= '</div></div>'; |
|
| 340 | + } |
|
| 341 | + } else { |
|
| 342 | + $tpl = getTplFolderNode(); |
|
| 343 | + // expandAll: two type for partial expansion |
|
| 344 | + if($expandAll == 1 || ($expandAll == 2 && in_array($row['id'], $opened))) { |
|
| 345 | + if($expandAll == 1) { |
|
| 346 | + $opened2[] = $row['id']; |
|
| 347 | + } |
|
| 348 | + $ph['icon'] = $ph['icon_folder_open']; |
|
| 349 | + $ph['icon_node_toggle'] = $ph['tree_minusnode']; |
|
| 350 | + $ph['node_toggle'] = 1; |
|
| 351 | + $ph['subMenuState'] = ' open'; |
|
| 352 | + |
|
| 353 | + if($ph['donthit'] == 1) { |
|
| 354 | + $ph['tree_page_click'] = 3; |
|
| 355 | + $ph['icon_node_toggle'] = ''; |
|
| 356 | + $ph['icon'] = $ph['icon_folder_close']; |
|
| 357 | + $ph['showChildren'] = 0; |
|
| 358 | + } |
|
| 359 | + |
|
| 360 | + // invoke OnManagerNodePrerender event |
|
| 361 | + $prenode = $modx->invokeEvent("OnManagerNodePrerender", array( |
|
| 362 | + 'ph' => $ph, |
|
| 363 | + 'opened' => '1' |
|
| 364 | + )); |
|
| 365 | + if(is_array($prenode)) { |
|
| 366 | + $phnew = array(); |
|
| 367 | + foreach($prenode as $pnode) { |
|
| 368 | + $phnew = array_merge($phnew, unserialize($pnode)); |
|
| 369 | + } |
|
| 370 | + $ph = (count($phnew) > 0) ? $phnew : $ph; |
|
| 371 | + if($ph['showChildren'] == 0) { |
|
| 372 | + unset($opened2[$row['id']]); |
|
| 373 | + $ph['node_toggle'] = 0; |
|
| 374 | + $ph['subMenuState'] = ''; |
|
| 375 | + } |
|
| 376 | + } |
|
| 377 | + |
|
| 378 | + if($ph['showChildren'] == 0) { |
|
| 379 | + $ph['icon_node_toggle'] = ''; |
|
| 380 | + $ph['donthit'] = 1; |
|
| 381 | + $ph['icon'] = $ph['icon_folder_close']; |
|
| 382 | + $tpl = getTplFolderNodeNotChildren(); |
|
| 383 | + } |
|
| 384 | + |
|
| 385 | + if($ph['contextmenu']) { |
|
| 386 | + $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"'; |
|
| 387 | + } |
|
| 388 | + |
|
| 389 | + $node .= $modx->parseText($tpl, $ph); |
|
| 390 | + if($ph['donthit'] == 0) { |
|
| 391 | + $node .= makeHTML($indent + 1, $row['id'], $expandAll, $theme, $hereid); |
|
| 392 | + } |
|
| 393 | + $node .= '</div></div>'; |
|
| 394 | + } else { |
|
| 395 | + $closed2[] = $row['id']; |
|
| 396 | + $ph['icon'] = $ph['icon_folder_close']; |
|
| 397 | + $ph['icon_node_toggle'] = $ph['tree_plusnode']; |
|
| 398 | + $ph['node_toggle'] = 0; |
|
| 399 | + |
|
| 400 | + if($ph['donthit'] == 1) { |
|
| 401 | + $ph['tree_page_click'] = 3; |
|
| 402 | + $ph['icon_node_toggle'] = ''; |
|
| 403 | + $ph['icon'] = $ph['icon_folder_close']; |
|
| 404 | + $ph['showChildren'] = 0; |
|
| 405 | + } |
|
| 406 | + |
|
| 407 | + // invoke OnManagerNodePrerender event |
|
| 408 | + $prenode = $modx->invokeEvent("OnManagerNodePrerender", array( |
|
| 409 | + 'ph' => $ph, |
|
| 410 | + 'opened' => '0' |
|
| 411 | + )); |
|
| 412 | + if(is_array($prenode)) { |
|
| 413 | + $phnew = array(); |
|
| 414 | + foreach($prenode as $pnode) { |
|
| 415 | + $phnew = array_merge($phnew, unserialize($pnode)); |
|
| 416 | + } |
|
| 417 | + $ph = (count($phnew) > 0) ? $phnew : $ph; |
|
| 418 | + } |
|
| 419 | + |
|
| 420 | + if($ph['showChildren'] == 0) { |
|
| 421 | + $ph['icon_node_toggle'] = ''; |
|
| 422 | + $ph['donthit'] = 1; |
|
| 423 | + $ph['icon'] = $ph['icon_folder_close']; |
|
| 424 | + $tpl = getTplFolderNodeNotChildren(); |
|
| 425 | + } |
|
| 426 | + |
|
| 427 | + if($ph['contextmenu']) { |
|
| 428 | + $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"'; |
|
| 429 | + } |
|
| 430 | + |
|
| 431 | + $node .= $modx->parseText($tpl, $ph); |
|
| 432 | + $node .= '</div></div>'; |
|
| 433 | + } |
|
| 434 | + } |
|
| 435 | + } |
|
| 436 | + |
|
| 437 | + // invoke OnManagerNodeRender event |
|
| 438 | + $data['node'] = $node; |
|
| 439 | + $evtOut = $modx->invokeEvent('OnManagerNodeRender', $data); |
|
| 440 | + if(is_array($evtOut)) { |
|
| 441 | + $evtOut = implode("\n", $evtOut); |
|
| 442 | + } |
|
| 443 | + if($evtOut != '') { |
|
| 444 | + $node = trim($evtOut); |
|
| 445 | + } |
|
| 446 | + |
|
| 447 | + $output .= $node; |
|
| 448 | + } |
|
| 449 | + |
|
| 450 | + return $output; |
|
| 451 | 451 | } |
| 452 | 452 | |
| 453 | 453 | function getIconInfo($_style) { |
| 454 | - if(!isset($_style['tree_page_gif'])) { |
|
| 455 | - $_style['tree_page_gif'] = $_style['tree_page']; |
|
| 456 | - } |
|
| 457 | - if(!isset($_style['tree_page_jpg'])) { |
|
| 458 | - $_style['tree_page_jpg'] = $_style['tree_page']; |
|
| 459 | - } |
|
| 460 | - if(!isset($_style['tree_page_png'])) { |
|
| 461 | - $_style['tree_page_png'] = $_style['tree_page']; |
|
| 462 | - } |
|
| 463 | - $icons = array( |
|
| 464 | - 'text/html' => $_style['tree_page_html'], |
|
| 465 | - 'text/plain' => $_style['tree_page'], |
|
| 466 | - 'text/xml' => $_style['tree_page_xml'], |
|
| 467 | - 'text/css' => $_style['tree_page_css'], |
|
| 468 | - 'text/javascript' => $_style['tree_page_js'], |
|
| 469 | - 'application/rss+xml' => $_style['tree_page_rss'], |
|
| 470 | - 'application/pdf' => $_style['tree_page_pdf'], |
|
| 471 | - 'application/vnd.ms-word' => $_style['tree_page_word'], |
|
| 472 | - 'application/vnd.ms-excel' => $_style['tree_page_excel'], |
|
| 473 | - 'image/gif' => $_style['tree_page_gif'], |
|
| 474 | - 'image/jpg' => $_style['tree_page_jpg'], |
|
| 475 | - 'image/png' => $_style['tree_page_png'] |
|
| 476 | - ); |
|
| 477 | - return $icons; |
|
| 454 | + if(!isset($_style['tree_page_gif'])) { |
|
| 455 | + $_style['tree_page_gif'] = $_style['tree_page']; |
|
| 456 | + } |
|
| 457 | + if(!isset($_style['tree_page_jpg'])) { |
|
| 458 | + $_style['tree_page_jpg'] = $_style['tree_page']; |
|
| 459 | + } |
|
| 460 | + if(!isset($_style['tree_page_png'])) { |
|
| 461 | + $_style['tree_page_png'] = $_style['tree_page']; |
|
| 462 | + } |
|
| 463 | + $icons = array( |
|
| 464 | + 'text/html' => $_style['tree_page_html'], |
|
| 465 | + 'text/plain' => $_style['tree_page'], |
|
| 466 | + 'text/xml' => $_style['tree_page_xml'], |
|
| 467 | + 'text/css' => $_style['tree_page_css'], |
|
| 468 | + 'text/javascript' => $_style['tree_page_js'], |
|
| 469 | + 'application/rss+xml' => $_style['tree_page_rss'], |
|
| 470 | + 'application/pdf' => $_style['tree_page_pdf'], |
|
| 471 | + 'application/vnd.ms-word' => $_style['tree_page_word'], |
|
| 472 | + 'application/vnd.ms-excel' => $_style['tree_page_excel'], |
|
| 473 | + 'image/gif' => $_style['tree_page_gif'], |
|
| 474 | + 'image/jpg' => $_style['tree_page_jpg'], |
|
| 475 | + 'image/png' => $_style['tree_page_png'] |
|
| 476 | + ); |
|
| 477 | + return $icons; |
|
| 478 | 478 | } |
| 479 | 479 | |
| 480 | 480 | function getPrivateIconInfo($_style) { |
| 481 | - if(!isset($_style['tree_page_gif_secure'])) { |
|
| 482 | - $_style['tree_page_gif_secure'] = $_style['tree_page_secure']; |
|
| 483 | - } |
|
| 484 | - if(!isset($_style['tree_page_jpg_secure'])) { |
|
| 485 | - $_style['tree_page_jpg_secure'] = $_style['tree_page_secure']; |
|
| 486 | - } |
|
| 487 | - if(!isset($_style['tree_page_png_secure'])) { |
|
| 488 | - $_style['tree_page_png_secure'] = $_style['tree_page_secure']; |
|
| 489 | - } |
|
| 490 | - $iconsPrivate = array( |
|
| 491 | - 'text/html' => $_style['tree_page_html_secure'], |
|
| 492 | - 'text/plain' => $_style['tree_page_secure'], |
|
| 493 | - 'text/xml' => $_style['tree_page_xml_secure'], |
|
| 494 | - 'text/css' => $_style['tree_page_css_secure'], |
|
| 495 | - 'text/javascript' => $_style['tree_page_js_secure'], |
|
| 496 | - 'application/rss+xml' => $_style['tree_page_rss_secure'], |
|
| 497 | - 'application/pdf' => $_style['tree_page_pdf_secure'], |
|
| 498 | - 'application/vnd.ms-word' => $_style['tree_page_word_secure'], |
|
| 499 | - 'application/vnd.ms-excel' => $_style['tree_page_excel_secure'], |
|
| 500 | - 'image/gif' => $_style['tree_page_gif_secure'], |
|
| 501 | - 'image/jpg' => $_style['tree_page_jpg_secure'], |
|
| 502 | - 'image/png' => $_style['tree_page_png_secure'] |
|
| 503 | - ); |
|
| 504 | - return $iconsPrivate; |
|
| 481 | + if(!isset($_style['tree_page_gif_secure'])) { |
|
| 482 | + $_style['tree_page_gif_secure'] = $_style['tree_page_secure']; |
|
| 483 | + } |
|
| 484 | + if(!isset($_style['tree_page_jpg_secure'])) { |
|
| 485 | + $_style['tree_page_jpg_secure'] = $_style['tree_page_secure']; |
|
| 486 | + } |
|
| 487 | + if(!isset($_style['tree_page_png_secure'])) { |
|
| 488 | + $_style['tree_page_png_secure'] = $_style['tree_page_secure']; |
|
| 489 | + } |
|
| 490 | + $iconsPrivate = array( |
|
| 491 | + 'text/html' => $_style['tree_page_html_secure'], |
|
| 492 | + 'text/plain' => $_style['tree_page_secure'], |
|
| 493 | + 'text/xml' => $_style['tree_page_xml_secure'], |
|
| 494 | + 'text/css' => $_style['tree_page_css_secure'], |
|
| 495 | + 'text/javascript' => $_style['tree_page_js_secure'], |
|
| 496 | + 'application/rss+xml' => $_style['tree_page_rss_secure'], |
|
| 497 | + 'application/pdf' => $_style['tree_page_pdf_secure'], |
|
| 498 | + 'application/vnd.ms-word' => $_style['tree_page_word_secure'], |
|
| 499 | + 'application/vnd.ms-excel' => $_style['tree_page_excel_secure'], |
|
| 500 | + 'image/gif' => $_style['tree_page_gif_secure'], |
|
| 501 | + 'image/jpg' => $_style['tree_page_jpg_secure'], |
|
| 502 | + 'image/png' => $_style['tree_page_png_secure'] |
|
| 503 | + ); |
|
| 504 | + return $iconsPrivate; |
|
| 505 | 505 | } |
| 506 | 506 | |
| 507 | 507 | function getNodeTitle($nodeNameSource, $row) { |
| 508 | - global $modx; |
|
| 509 | - |
|
| 510 | - switch($nodeNameSource) { |
|
| 511 | - case 'menutitle': |
|
| 512 | - $nodetitle = $row['menutitle'] ? $row['menutitle'] : $row['pagetitle']; |
|
| 513 | - break; |
|
| 514 | - case 'alias': |
|
| 515 | - $nodetitle = $row['alias'] ? $row['alias'] : $row['id']; |
|
| 516 | - if(strpos($row['alias'], '.') === false) { |
|
| 517 | - if($row['isfolder'] != 1 || $modx->config['make_folders'] != 1) { |
|
| 518 | - $nodetitle .= $modx->config['friendly_url_suffix']; |
|
| 519 | - } |
|
| 520 | - } |
|
| 521 | - $nodetitle = $modx->config['friendly_url_prefix'] . $nodetitle; |
|
| 522 | - break; |
|
| 523 | - case 'pagetitle': |
|
| 524 | - $nodetitle = $row['pagetitle']; |
|
| 525 | - break; |
|
| 526 | - case 'longtitle': |
|
| 527 | - $nodetitle = $row['longtitle'] ? $row['longtitle'] : $row['pagetitle']; |
|
| 528 | - break; |
|
| 529 | - case 'createdon': |
|
| 530 | - case 'editedon': |
|
| 531 | - case 'publishedon': |
|
| 532 | - case 'pub_date': |
|
| 533 | - case 'unpub_date': |
|
| 534 | - $doc = $modx->getDocumentObject('id', $row['id']); |
|
| 535 | - $date = $doc[$nodeNameSource]; |
|
| 536 | - if(!empty($date)) { |
|
| 537 | - $nodetitle = $modx->toDateFormat($date); |
|
| 538 | - } else { |
|
| 539 | - $nodetitle = '- - -'; |
|
| 540 | - } |
|
| 541 | - break; |
|
| 542 | - default: |
|
| 543 | - $nodetitle = $row['pagetitle']; |
|
| 544 | - } |
|
| 545 | - $nodetitle = $modx->htmlspecialchars(str_replace(array( |
|
| 546 | - "\r\n", |
|
| 547 | - "\n", |
|
| 548 | - "\r" |
|
| 549 | - ), ' ', $nodetitle), ENT_COMPAT); |
|
| 550 | - return $nodetitle; |
|
| 508 | + global $modx; |
|
| 509 | + |
|
| 510 | + switch($nodeNameSource) { |
|
| 511 | + case 'menutitle': |
|
| 512 | + $nodetitle = $row['menutitle'] ? $row['menutitle'] : $row['pagetitle']; |
|
| 513 | + break; |
|
| 514 | + case 'alias': |
|
| 515 | + $nodetitle = $row['alias'] ? $row['alias'] : $row['id']; |
|
| 516 | + if(strpos($row['alias'], '.') === false) { |
|
| 517 | + if($row['isfolder'] != 1 || $modx->config['make_folders'] != 1) { |
|
| 518 | + $nodetitle .= $modx->config['friendly_url_suffix']; |
|
| 519 | + } |
|
| 520 | + } |
|
| 521 | + $nodetitle = $modx->config['friendly_url_prefix'] . $nodetitle; |
|
| 522 | + break; |
|
| 523 | + case 'pagetitle': |
|
| 524 | + $nodetitle = $row['pagetitle']; |
|
| 525 | + break; |
|
| 526 | + case 'longtitle': |
|
| 527 | + $nodetitle = $row['longtitle'] ? $row['longtitle'] : $row['pagetitle']; |
|
| 528 | + break; |
|
| 529 | + case 'createdon': |
|
| 530 | + case 'editedon': |
|
| 531 | + case 'publishedon': |
|
| 532 | + case 'pub_date': |
|
| 533 | + case 'unpub_date': |
|
| 534 | + $doc = $modx->getDocumentObject('id', $row['id']); |
|
| 535 | + $date = $doc[$nodeNameSource]; |
|
| 536 | + if(!empty($date)) { |
|
| 537 | + $nodetitle = $modx->toDateFormat($date); |
|
| 538 | + } else { |
|
| 539 | + $nodetitle = '- - -'; |
|
| 540 | + } |
|
| 541 | + break; |
|
| 542 | + default: |
|
| 543 | + $nodetitle = $row['pagetitle']; |
|
| 544 | + } |
|
| 545 | + $nodetitle = $modx->htmlspecialchars(str_replace(array( |
|
| 546 | + "\r\n", |
|
| 547 | + "\n", |
|
| 548 | + "\r" |
|
| 549 | + ), ' ', $nodetitle), ENT_COMPAT); |
|
| 550 | + return $nodetitle; |
|
| 551 | 551 | } |
| 552 | 552 | |
| 553 | 553 | function isDateNode($nodeNameSource) { |
| 554 | - switch($nodeNameSource) { |
|
| 555 | - case 'createdon': |
|
| 556 | - case 'editedon': |
|
| 557 | - case 'publishedon': |
|
| 558 | - case 'pub_date': |
|
| 559 | - case 'unpub_date': |
|
| 560 | - return true; |
|
| 561 | - default: |
|
| 562 | - return false; |
|
| 563 | - } |
|
| 554 | + switch($nodeNameSource) { |
|
| 555 | + case 'createdon': |
|
| 556 | + case 'editedon': |
|
| 557 | + case 'publishedon': |
|
| 558 | + case 'pub_date': |
|
| 559 | + case 'unpub_date': |
|
| 560 | + return true; |
|
| 561 | + default: |
|
| 562 | + return false; |
|
| 563 | + } |
|
| 564 | 564 | } |
| 565 | 565 | |
| 566 | 566 | function checkIsFolder($parent = 0, $isfolder = 1) { |
| 567 | - global $modx; |
|
| 567 | + global $modx; |
|
| 568 | 568 | |
| 569 | - return (int) $modx->db->getValue($modx->db->query('SELECT count(*) FROM ' . $modx->getFullTableName('site_content') . ' WHERE parent=' . $parent . ' AND isfolder=' . $isfolder . ' ')); |
|
| 569 | + return (int) $modx->db->getValue($modx->db->query('SELECT count(*) FROM ' . $modx->getFullTableName('site_content') . ' WHERE parent=' . $parent . ' AND isfolder=' . $isfolder . ' ')); |
|
| 570 | 570 | } |
| 571 | 571 | |
| 572 | 572 | function _htmlentities($array) { |
| 573 | - global $modx; |
|
| 573 | + global $modx; |
|
| 574 | 574 | |
| 575 | - $array = json_encode($array, JSON_UNESCAPED_UNICODE); |
|
| 576 | - $array = htmlentities($array, ENT_COMPAT, $modx->config['modx_charset']); |
|
| 575 | + $array = json_encode($array, JSON_UNESCAPED_UNICODE); |
|
| 576 | + $array = htmlentities($array, ENT_COMPAT, $modx->config['modx_charset']); |
|
| 577 | 577 | |
| 578 | - return $array; |
|
| 578 | + return $array; |
|
| 579 | 579 | } |
| 580 | 580 | |
| 581 | 581 | function getTplSingleNode() { |
| 582 | - return '<div id="node[+id+]"><a class="[+treeNodeClass+]" |
|
| 582 | + return '<div id="node[+id+]"><a class="[+treeNodeClass+]" |
|
| 583 | 583 | onclick="modx.tree.treeAction(event,[+id+]);" |
| 584 | 584 | oncontextmenu="modx.tree.showPopup(event,[+id+],\'[+nodetitle_esc+]\');" |
| 585 | 585 | data-id="[+id+]" |
@@ -603,7 +603,7 @@ discard block |
||
| 603 | 603 | } |
| 604 | 604 | |
| 605 | 605 | function getTplFolderNode() { |
| 606 | - return '<div id="node[+id+]"><a class="[+treeNodeClass+]" |
|
| 606 | + return '<div id="node[+id+]"><a class="[+treeNodeClass+]" |
|
| 607 | 607 | onclick="modx.tree.treeAction(event,[+id+]);" |
| 608 | 608 | oncontextmenu="modx.tree.showPopup(event,[+id+],\'[+nodetitle_esc+]\');" |
| 609 | 609 | data-id="[+id+]" |
@@ -639,7 +639,7 @@ discard block |
||
| 639 | 639 | } |
| 640 | 640 | |
| 641 | 641 | function getTplFolderNodeNotChildren() { |
| 642 | - return '<div id="node[+id+]"><a class="[+treeNodeClass+]" |
|
| 642 | + return '<div id="node[+id+]"><a class="[+treeNodeClass+]" |
|
| 643 | 643 | onclick="modx.tree.treeAction(event,[+id+]);" |
| 644 | 644 | oncontextmenu="modx.tree.showPopup(event,[+id+],\'[+nodetitle_esc+]\');" |
| 645 | 645 | data-id="[+id+]" |
@@ -671,10 +671,10 @@ discard block |
||
| 671 | 671 | } |
| 672 | 672 | |
| 673 | 673 | function dbug($str, $flag = false) { |
| 674 | - print('<pre>'); |
|
| 675 | - print_r($str); |
|
| 676 | - print('</pre>'); |
|
| 677 | - if($flag) { |
|
| 678 | - exit; |
|
| 679 | - } |
|
| 674 | + print('<pre>'); |
|
| 675 | + print_r($str); |
|
| 676 | + print('</pre>'); |
|
| 677 | + if($flag) { |
|
| 678 | + exit; |
|
| 679 | + } |
|
| 680 | 680 | } |
@@ -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 | |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | * @param $theme |
| 11 | 11 | * @param string $hereid |
| 12 | 12 | */ |
| 13 | -function makeHTML($indent, $parent, $expandAll, $theme, $hereid = '') { |
|
| 13 | +function makeHTML($indent, $parent, $expandAll, $theme, $hereid = ''){ |
|
| 14 | 14 | global $modx; |
| 15 | 15 | global $icons, $iconsPrivate, $_style; |
| 16 | 16 | global $_lang, $opened, $opened2, $closed2; //added global vars |
@@ -21,35 +21,35 @@ discard block |
||
| 21 | 21 | // setup spacer |
| 22 | 22 | $level = 0; |
| 23 | 23 | $spacer = '<span class="indent">'; |
| 24 | - for($i = 2; $i <= $indent; $i++) { |
|
| 24 | + for ($i = 2; $i <= $indent; $i++) { |
|
| 25 | 25 | $spacer .= '<i></i>'; |
| 26 | 26 | $level++; |
| 27 | 27 | } |
| 28 | 28 | $spacer .= '</span>'; |
| 29 | 29 | |
| 30 | 30 | // manage order-by |
| 31 | - if(!isset($_SESSION['tree_sortby']) && !isset($_SESSION['tree_sortdir'])) { |
|
| 31 | + if (!isset($_SESSION['tree_sortby']) && !isset($_SESSION['tree_sortdir'])) { |
|
| 32 | 32 | // This is the first startup, set default sort order |
| 33 | 33 | $_SESSION['tree_sortby'] = 'menuindex'; |
| 34 | 34 | $_SESSION['tree_sortdir'] = 'ASC'; |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - switch($_SESSION['tree_sortby']) { |
|
| 37 | + switch ($_SESSION['tree_sortby']) { |
|
| 38 | 38 | case 'createdon': |
| 39 | 39 | case 'editedon': |
| 40 | 40 | case 'publishedon': |
| 41 | 41 | case 'pub_date': |
| 42 | 42 | case 'unpub_date': |
| 43 | - $sortby = sprintf('CASE WHEN %s IS NULL THEN 1 ELSE 0 END, %s', 'sc.' . $_SESSION['tree_sortby'], 'sc.' . $_SESSION['tree_sortby']); |
|
| 43 | + $sortby = sprintf('CASE WHEN %s IS NULL THEN 1 ELSE 0 END, %s', 'sc.'.$_SESSION['tree_sortby'], 'sc.'.$_SESSION['tree_sortby']); |
|
| 44 | 44 | break; |
| 45 | 45 | default: |
| 46 | - $sortby = 'sc.' . $_SESSION['tree_sortby']; |
|
| 46 | + $sortby = 'sc.'.$_SESSION['tree_sortby']; |
|
| 47 | 47 | }; |
| 48 | 48 | |
| 49 | - $orderby = $modx->db->escape($sortby . ' ' . $_SESSION['tree_sortdir']); |
|
| 49 | + $orderby = $modx->db->escape($sortby.' '.$_SESSION['tree_sortdir']); |
|
| 50 | 50 | |
| 51 | 51 | // Folder sorting gets special setup ;) Add menuindex and pagetitle |
| 52 | - if($_SESSION['tree_sortby'] == 'isfolder') { |
|
| 52 | + if ($_SESSION['tree_sortby'] == 'isfolder') { |
|
| 53 | 53 | $orderby .= ', menuindex ASC, pagetitle'; |
| 54 | 54 | } |
| 55 | 55 | |
@@ -59,12 +59,12 @@ discard block |
||
| 59 | 59 | // get document groups for current user |
| 60 | 60 | $docgrp = (isset($_SESSION['mgrDocgroups']) && is_array($_SESSION['mgrDocgroups'])) ? implode(',', $_SESSION['mgrDocgroups']) : ''; |
| 61 | 61 | $showProtected = false; |
| 62 | - if(isset ($modx->config['tree_show_protected'])) { |
|
| 62 | + if (isset ($modx->config['tree_show_protected'])) { |
|
| 63 | 63 | $showProtected = (boolean) $modx->config['tree_show_protected']; |
| 64 | 64 | } |
| 65 | 65 | $mgrRole = (isset ($_SESSION['mgrRole']) && (string) $_SESSION['mgrRole'] === '1') ? '1' : '0'; |
| 66 | - if($showProtected == false) { |
|
| 67 | - $access = "AND (1={$mgrRole} OR sc.privatemgr=0" . (!$docgrp ? ')' : " OR dg.document_group IN ({$docgrp}))"); |
|
| 66 | + if ($showProtected == false) { |
|
| 67 | + $access = "AND (1={$mgrRole} OR sc.privatemgr=0".(!$docgrp ? ')' : " OR dg.document_group IN ({$docgrp}))"); |
|
| 68 | 68 | } else { |
| 69 | 69 | $access = ''; |
| 70 | 70 | } |
@@ -74,13 +74,13 @@ discard block |
||
| 74 | 74 | $from = "{$tblsc} AS sc LEFT JOIN {$tbldg} dg on dg.document = sc.id LEFT JOIN {$tblst} st on st.id = sc.template"; |
| 75 | 75 | $where = "(parent={$parent}) {$access} GROUP BY sc.id"; |
| 76 | 76 | $result = $modx->db->select($field, $from, $where, $orderby); |
| 77 | - if($modx->db->getRecordCount($result) == 0) { |
|
| 77 | + if ($modx->db->getRecordCount($result) == 0) { |
|
| 78 | 78 | $output .= sprintf('<div><a class="empty">%s%s <span class="empty">%s</span></a></div>', $spacer, $_style['tree_deletedpage'], $_lang['empty_folder']); |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | $nodeNameSource = $_SESSION['tree_nodename'] == 'default' ? $modx->config['resource_tree_node_name'] : $_SESSION['tree_nodename']; |
| 82 | 82 | |
| 83 | - while($row = $modx->db->getRow($result)) { |
|
| 83 | + while ($row = $modx->db->getRow($result)) { |
|
| 84 | 84 | $node = ''; |
| 85 | 85 | |
| 86 | 86 | $nodetitle = getNodeTitle($nodeNameSource, $row); |
@@ -89,46 +89,46 @@ discard block |
||
| 89 | 89 | $treeNodeClass = 'node'; |
| 90 | 90 | $treeNodeClass .= $row['hasAccess'] == 0 ? ' protected' : ''; |
| 91 | 91 | |
| 92 | - if($row['deleted'] == 1) { |
|
| 92 | + if ($row['deleted'] == 1) { |
|
| 93 | 93 | $treeNodeClass .= ' deleted'; |
| 94 | 94 | //$nodetitleDisplay = sprintf('<span class="deletedNode">%s</span>', $nodetitle); |
| 95 | - } elseif($row['published'] == 0) { |
|
| 95 | + } elseif ($row['published'] == 0) { |
|
| 96 | 96 | $treeNodeClass .= ' unpublished'; |
| 97 | 97 | //$nodetitleDisplay = sprintf('<span class="unpublishedNode">%s</span>', $nodetitle); |
| 98 | - } elseif($row['hidemenu'] == 1) { |
|
| 98 | + } elseif ($row['hidemenu'] == 1) { |
|
| 99 | 99 | $treeNodeClass .= ' hidemenu'; |
| 100 | 100 | //$nodetitleDisplay = sprintf('<span class="notInMenuNode%s">%s</span>', $protectedClass, $nodetitle); |
| 101 | 101 | } else { |
| 102 | 102 | //$nodetitleDisplay = sprintf('<span class="publishedNode%s">%s</span>', $protectedClass, $nodetitle); |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | - if($row['id'] == $hereid) { |
|
| 105 | + if ($row['id'] == $hereid) { |
|
| 106 | 106 | $treeNodeClass .= ' current'; |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | $weblinkDisplay = $row['type'] == 'reference' ? sprintf(' %s', $_style['tree_linkgo']) : ''; |
| 110 | - $pageIdDisplay = '<small>(' . ($modx_textdir ? '‏' : '') . $row['id'] . ')</small>'; |
|
| 110 | + $pageIdDisplay = '<small>('.($modx_textdir ? '‏' : '').$row['id'].')</small>'; |
|
| 111 | 111 | |
| 112 | 112 | // Prepare displaying user-locks |
| 113 | 113 | $lockedByUser = ''; |
| 114 | 114 | $rowLock = $modx->elementIsLocked(7, $row['id'], true); |
| 115 | - if($rowLock && $modx->hasPermission('display_locks')) { |
|
| 116 | - if($rowLock['sid'] == $modx->sid) { |
|
| 115 | + if ($rowLock && $modx->hasPermission('display_locks')) { |
|
| 116 | + if ($rowLock['sid'] == $modx->sid) { |
|
| 117 | 117 | $title = $modx->parseText($_lang["lock_element_editing"], array( |
| 118 | 118 | 'element_type' => $_lang["lock_element_type_7"], |
| 119 | 119 | 'lasthit_df' => $rowLock['lasthit_df'] |
| 120 | 120 | )); |
| 121 | - $lockedByUser = '<span title="' . $title . '" class="editResource">' . $_style['tree_preview_resource'] . '</span>'; |
|
| 121 | + $lockedByUser = '<span title="'.$title.'" class="editResource">'.$_style['tree_preview_resource'].'</span>'; |
|
| 122 | 122 | } else { |
| 123 | 123 | $title = $modx->parseText($_lang["lock_element_locked_by"], array( |
| 124 | 124 | 'element_type' => $_lang["lock_element_type_7"], |
| 125 | 125 | 'username' => $rowLock['username'], |
| 126 | 126 | 'lasthit_df' => $rowLock['lasthit_df'] |
| 127 | 127 | )); |
| 128 | - if($modx->hasPermission('remove_locks')) { |
|
| 129 | - $lockedByUser = '<span onclick="modx.tree.unlockElement(7, ' . $row['id'] . ', this);return false;" title="' . $title . '" class="lockedResource">' . $_style['icons_secured'] . '</span>'; |
|
| 128 | + if ($modx->hasPermission('remove_locks')) { |
|
| 129 | + $lockedByUser = '<span onclick="modx.tree.unlockElement(7, '.$row['id'].', this);return false;" title="'.$title.'" class="lockedResource">'.$_style['icons_secured'].'</span>'; |
|
| 130 | 130 | } else { |
| 131 | - $lockedByUser = '<span title="' . $title . '" class="lockedResource">' . $_style['icons_secured'] . '</span>'; |
|
| 131 | + $lockedByUser = '<span title="'.$title.'" class="lockedResource">'.$_style['icons_secured'].'</span>'; |
|
| 132 | 132 | } |
| 133 | 133 | } |
| 134 | 134 | } |
@@ -136,23 +136,23 @@ discard block |
||
| 136 | 136 | $url = $modx->makeUrl($row['id']); |
| 137 | 137 | |
| 138 | 138 | $title = ''; |
| 139 | - if(isDateNode($nodeNameSource)) { |
|
| 140 | - $title = $_lang['pagetitle'] . ': ' . $row['pagetitle'] . '[+lf+]'; |
|
| 139 | + if (isDateNode($nodeNameSource)) { |
|
| 140 | + $title = $_lang['pagetitle'].': '.$row['pagetitle'].'[+lf+]'; |
|
| 141 | 141 | } |
| 142 | - $title .= $_lang['id'] . ': ' . $row['id']; |
|
| 143 | - $title .= '[+lf+]' . $_lang['resource_opt_menu_title'] . ': ' . $row['menutitle']; |
|
| 144 | - $title .= '[+lf+]' . $_lang['resource_opt_menu_index'] . ': ' . $row['menuindex']; |
|
| 145 | - $title .= '[+lf+]' . $_lang['alias'] . ': ' . (!empty($row['alias']) ? $row['alias'] : '-'); |
|
| 146 | - $title .= '[+lf+]' . $_lang['template'] . ': ' . $row['templatename']; |
|
| 147 | - $title .= '[+lf+]' . $_lang['publish_date'] . ': ' . $modx->toDateFormat($row['pub_date']); |
|
| 148 | - $title .= '[+lf+]' . $_lang['unpublish_date'] . ': ' . $modx->toDateFormat($row['unpub_date']); |
|
| 149 | - $title .= '[+lf+]' . $_lang['page_data_web_access'] . ': ' . ($row['privateweb'] ? $_lang['private'] : $_lang['public']); |
|
| 150 | - $title .= '[+lf+]' . $_lang['page_data_mgr_access'] . ': ' . ($row['privatemgr'] ? $_lang['private'] : $_lang['public']); |
|
| 151 | - $title .= '[+lf+]' . $_lang['resource_opt_richtext'] . ': ' . ($row['richtext'] == 0 ? $_lang['no'] : $_lang['yes']); |
|
| 152 | - $title .= '[+lf+]' . $_lang['page_data_searchable'] . ': ' . ($row['searchable'] == 0 ? $_lang['no'] : $_lang['yes']); |
|
| 153 | - $title .= '[+lf+]' . $_lang['page_data_cacheable'] . ': ' . ($row['cacheable'] == 0 ? $_lang['no'] : $_lang['yes']); |
|
| 142 | + $title .= $_lang['id'].': '.$row['id']; |
|
| 143 | + $title .= '[+lf+]'.$_lang['resource_opt_menu_title'].': '.$row['menutitle']; |
|
| 144 | + $title .= '[+lf+]'.$_lang['resource_opt_menu_index'].': '.$row['menuindex']; |
|
| 145 | + $title .= '[+lf+]'.$_lang['alias'].': '.(!empty($row['alias']) ? $row['alias'] : '-'); |
|
| 146 | + $title .= '[+lf+]'.$_lang['template'].': '.$row['templatename']; |
|
| 147 | + $title .= '[+lf+]'.$_lang['publish_date'].': '.$modx->toDateFormat($row['pub_date']); |
|
| 148 | + $title .= '[+lf+]'.$_lang['unpublish_date'].': '.$modx->toDateFormat($row['unpub_date']); |
|
| 149 | + $title .= '[+lf+]'.$_lang['page_data_web_access'].': '.($row['privateweb'] ? $_lang['private'] : $_lang['public']); |
|
| 150 | + $title .= '[+lf+]'.$_lang['page_data_mgr_access'].': '.($row['privatemgr'] ? $_lang['private'] : $_lang['public']); |
|
| 151 | + $title .= '[+lf+]'.$_lang['resource_opt_richtext'].': '.($row['richtext'] == 0 ? $_lang['no'] : $_lang['yes']); |
|
| 152 | + $title .= '[+lf+]'.$_lang['page_data_searchable'].': '.($row['searchable'] == 0 ? $_lang['no'] : $_lang['yes']); |
|
| 153 | + $title .= '[+lf+]'.$_lang['page_data_cacheable'].': '.($row['cacheable'] == 0 ? $_lang['no'] : $_lang['yes']); |
|
| 154 | 154 | $title = $modx->htmlspecialchars($title); |
| 155 | - $title = str_replace('[+lf+]', ' ', $title); // replace line-breaks with empty space as fall-back |
|
| 155 | + $title = str_replace('[+lf+]', ' ', $title); // replace line-breaks with empty space as fall-back |
|
| 156 | 156 | |
| 157 | 157 | $data = array( |
| 158 | 158 | 'id' => $row['id'], |
@@ -201,9 +201,9 @@ discard block |
||
| 201 | 201 | $ph['expandAll'] = $expandAll; |
| 202 | 202 | $ph['isPrivate'] = ($row['privateweb'] || $row['privatemgr']) ? 1 : 0; |
| 203 | 203 | |
| 204 | - if(!$row['isfolder']) { |
|
| 204 | + if (!$row['isfolder']) { |
|
| 205 | 205 | $tpl = getTplSingleNode(); |
| 206 | - switch($row['id']) { |
|
| 206 | + switch ($row['id']) { |
|
| 207 | 207 | case $modx->config['site_start'] : |
| 208 | 208 | $icon = $_style['tree_page_home']; |
| 209 | 209 | break; |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | $icon = $_style['tree_page_info']; |
| 218 | 218 | break; |
| 219 | 219 | default: |
| 220 | - if(isset($icons[$row['contentType']])) { |
|
| 220 | + if (isset($icons[$row['contentType']])) { |
|
| 221 | 221 | $icon = $icons[$row['contentType']]; |
| 222 | 222 | } else { |
| 223 | 223 | $icon = $_style['tree_page']; |
@@ -227,20 +227,20 @@ discard block |
||
| 227 | 227 | |
| 228 | 228 | // invoke OnManagerNodePrerender event |
| 229 | 229 | $prenode = $modx->invokeEvent("OnManagerNodePrerender", array('ph' => $ph)); |
| 230 | - if(is_array($prenode)) { |
|
| 230 | + if (is_array($prenode)) { |
|
| 231 | 231 | $phnew = array(); |
| 232 | - foreach($prenode as $pnode) { |
|
| 232 | + foreach ($prenode as $pnode) { |
|
| 233 | 233 | $phnew = array_merge($phnew, unserialize($pnode)); |
| 234 | 234 | } |
| 235 | 235 | $ph = (count($phnew) > 0) ? $phnew : $ph; |
| 236 | 236 | } |
| 237 | 237 | |
| 238 | - if($ph['contextmenu']) { |
|
| 239 | - $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"'; |
|
| 238 | + if ($ph['contextmenu']) { |
|
| 239 | + $ph['contextmenu'] = ' data-contextmenu="'._htmlentities($ph['contextmenu']).'"'; |
|
| 240 | 240 | } |
| 241 | 241 | |
| 242 | - if($_SESSION['tree_show_only_folders']) { |
|
| 243 | - if($row['parent'] == 0) { |
|
| 242 | + if ($_SESSION['tree_show_only_folders']) { |
|
| 243 | + if ($row['parent'] == 0) { |
|
| 244 | 244 | $node .= $modx->parseText($tpl, $ph); |
| 245 | 245 | } else { |
| 246 | 246 | $node .= ''; |
@@ -253,15 +253,15 @@ discard block |
||
| 253 | 253 | $ph['icon_folder_open'] = $_style['tree_folderopen_new']; |
| 254 | 254 | $ph['icon_folder_close'] = $_style['tree_folder_new']; |
| 255 | 255 | |
| 256 | - if($_SESSION['tree_show_only_folders']) { |
|
| 256 | + if ($_SESSION['tree_show_only_folders']) { |
|
| 257 | 257 | $tpl = getTplFolderNodeNotChildren(); |
| 258 | 258 | $checkFolders = checkIsFolder($row['id'], 1) ? 1 : 0; // folders |
| 259 | 259 | $checkDocs = checkIsFolder($row['id'], 0) ? 1 : 0; // no folders |
| 260 | 260 | $ph['tree_page_click'] = 3; |
| 261 | 261 | |
| 262 | 262 | // expandAll: two type for partial expansion |
| 263 | - if($expandAll == 1 || ($expandAll == 2 && in_array($row['id'], $opened))) { |
|
| 264 | - if($expandAll == 1) { |
|
| 263 | + if ($expandAll == 1 || ($expandAll == 2 && in_array($row['id'], $opened))) { |
|
| 264 | + if ($expandAll == 1) { |
|
| 265 | 265 | $opened2[] = $row['id']; |
| 266 | 266 | } |
| 267 | 267 | $ph['icon'] = $ph['icon_folder_open']; |
@@ -269,11 +269,11 @@ discard block |
||
| 269 | 269 | $ph['node_toggle'] = 1; |
| 270 | 270 | $ph['subMenuState'] = ' open'; |
| 271 | 271 | |
| 272 | - if(($checkDocs && !$checkFolders) || (!$checkDocs && !$checkFolders)) { |
|
| 272 | + if (($checkDocs && !$checkFolders) || (!$checkDocs && !$checkFolders)) { |
|
| 273 | 273 | $ph['showChildren'] = 1; |
| 274 | 274 | $ph['icon_node_toggle'] = ''; |
| 275 | 275 | $ph['icon'] = $ph['icon_folder_close']; |
| 276 | - } elseif(!$checkDocs && $checkFolders) { |
|
| 276 | + } elseif (!$checkDocs && $checkFolders) { |
|
| 277 | 277 | $ph['showChildren'] = 0; |
| 278 | 278 | $ph['openFolder'] = 2; |
| 279 | 279 | } else { |
@@ -285,20 +285,20 @@ discard block |
||
| 285 | 285 | 'ph' => $ph, |
| 286 | 286 | 'opened' => '1' |
| 287 | 287 | )); |
| 288 | - if(is_array($prenode)) { |
|
| 288 | + if (is_array($prenode)) { |
|
| 289 | 289 | $phnew = array(); |
| 290 | - foreach($prenode as $pnode) { |
|
| 290 | + foreach ($prenode as $pnode) { |
|
| 291 | 291 | $phnew = array_merge($phnew, unserialize($pnode)); |
| 292 | 292 | } |
| 293 | 293 | $ph = (count($phnew) > 0) ? $phnew : $ph; |
| 294 | 294 | } |
| 295 | 295 | |
| 296 | - if($ph['contextmenu']) { |
|
| 297 | - $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"'; |
|
| 296 | + if ($ph['contextmenu']) { |
|
| 297 | + $ph['contextmenu'] = ' data-contextmenu="'._htmlentities($ph['contextmenu']).'"'; |
|
| 298 | 298 | } |
| 299 | 299 | |
| 300 | 300 | $node .= $modx->parseText($tpl, $ph); |
| 301 | - if($checkFolders) { |
|
| 301 | + if ($checkFolders) { |
|
| 302 | 302 | $node .= makeHTML($indent + 1, $row['id'], $expandAll, $theme, $hereid); |
| 303 | 303 | } |
| 304 | 304 | $node .= '</div></div>'; |
@@ -308,10 +308,10 @@ discard block |
||
| 308 | 308 | $ph['icon_node_toggle'] = $ph['tree_plusnode']; |
| 309 | 309 | $ph['node_toggle'] = 0; |
| 310 | 310 | |
| 311 | - if(($checkDocs && !$checkFolders) || (!$checkDocs && !$checkFolders)) { |
|
| 311 | + if (($checkDocs && !$checkFolders) || (!$checkDocs && !$checkFolders)) { |
|
| 312 | 312 | $ph['showChildren'] = 1; |
| 313 | 313 | $ph['icon_node_toggle'] = ''; |
| 314 | - } elseif(!$checkDocs && $checkFolders) { |
|
| 314 | + } elseif (!$checkDocs && $checkFolders) { |
|
| 315 | 315 | $ph['showChildren'] = 0; |
| 316 | 316 | $ph['openFolder'] = 2; |
| 317 | 317 | } else { |
@@ -323,16 +323,16 @@ discard block |
||
| 323 | 323 | 'ph' => $ph, |
| 324 | 324 | 'opened' => '0' |
| 325 | 325 | )); |
| 326 | - if(is_array($prenode)) { |
|
| 326 | + if (is_array($prenode)) { |
|
| 327 | 327 | $phnew = array(); |
| 328 | - foreach($prenode as $pnode) { |
|
| 328 | + foreach ($prenode as $pnode) { |
|
| 329 | 329 | $phnew = array_merge($phnew, unserialize($pnode)); |
| 330 | 330 | } |
| 331 | 331 | $ph = (count($phnew) > 0) ? $phnew : $ph; |
| 332 | 332 | } |
| 333 | 333 | |
| 334 | - if($ph['contextmenu']) { |
|
| 335 | - $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"'; |
|
| 334 | + if ($ph['contextmenu']) { |
|
| 335 | + $ph['contextmenu'] = ' data-contextmenu="'._htmlentities($ph['contextmenu']).'"'; |
|
| 336 | 336 | } |
| 337 | 337 | |
| 338 | 338 | $node .= $modx->parseText($tpl, $ph); |
@@ -341,8 +341,8 @@ discard block |
||
| 341 | 341 | } else { |
| 342 | 342 | $tpl = getTplFolderNode(); |
| 343 | 343 | // expandAll: two type for partial expansion |
| 344 | - if($expandAll == 1 || ($expandAll == 2 && in_array($row['id'], $opened))) { |
|
| 345 | - if($expandAll == 1) { |
|
| 344 | + if ($expandAll == 1 || ($expandAll == 2 && in_array($row['id'], $opened))) { |
|
| 345 | + if ($expandAll == 1) { |
|
| 346 | 346 | $opened2[] = $row['id']; |
| 347 | 347 | } |
| 348 | 348 | $ph['icon'] = $ph['icon_folder_open']; |
@@ -350,7 +350,7 @@ discard block |
||
| 350 | 350 | $ph['node_toggle'] = 1; |
| 351 | 351 | $ph['subMenuState'] = ' open'; |
| 352 | 352 | |
| 353 | - if($ph['donthit'] == 1) { |
|
| 353 | + if ($ph['donthit'] == 1) { |
|
| 354 | 354 | $ph['tree_page_click'] = 3; |
| 355 | 355 | $ph['icon_node_toggle'] = ''; |
| 356 | 356 | $ph['icon'] = $ph['icon_folder_close']; |
@@ -362,32 +362,32 @@ discard block |
||
| 362 | 362 | 'ph' => $ph, |
| 363 | 363 | 'opened' => '1' |
| 364 | 364 | )); |
| 365 | - if(is_array($prenode)) { |
|
| 365 | + if (is_array($prenode)) { |
|
| 366 | 366 | $phnew = array(); |
| 367 | - foreach($prenode as $pnode) { |
|
| 367 | + foreach ($prenode as $pnode) { |
|
| 368 | 368 | $phnew = array_merge($phnew, unserialize($pnode)); |
| 369 | 369 | } |
| 370 | 370 | $ph = (count($phnew) > 0) ? $phnew : $ph; |
| 371 | - if($ph['showChildren'] == 0) { |
|
| 371 | + if ($ph['showChildren'] == 0) { |
|
| 372 | 372 | unset($opened2[$row['id']]); |
| 373 | 373 | $ph['node_toggle'] = 0; |
| 374 | 374 | $ph['subMenuState'] = ''; |
| 375 | 375 | } |
| 376 | 376 | } |
| 377 | 377 | |
| 378 | - if($ph['showChildren'] == 0) { |
|
| 378 | + if ($ph['showChildren'] == 0) { |
|
| 379 | 379 | $ph['icon_node_toggle'] = ''; |
| 380 | 380 | $ph['donthit'] = 1; |
| 381 | 381 | $ph['icon'] = $ph['icon_folder_close']; |
| 382 | 382 | $tpl = getTplFolderNodeNotChildren(); |
| 383 | 383 | } |
| 384 | 384 | |
| 385 | - if($ph['contextmenu']) { |
|
| 386 | - $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"'; |
|
| 385 | + if ($ph['contextmenu']) { |
|
| 386 | + $ph['contextmenu'] = ' data-contextmenu="'._htmlentities($ph['contextmenu']).'"'; |
|
| 387 | 387 | } |
| 388 | 388 | |
| 389 | 389 | $node .= $modx->parseText($tpl, $ph); |
| 390 | - if($ph['donthit'] == 0) { |
|
| 390 | + if ($ph['donthit'] == 0) { |
|
| 391 | 391 | $node .= makeHTML($indent + 1, $row['id'], $expandAll, $theme, $hereid); |
| 392 | 392 | } |
| 393 | 393 | $node .= '</div></div>'; |
@@ -397,7 +397,7 @@ discard block |
||
| 397 | 397 | $ph['icon_node_toggle'] = $ph['tree_plusnode']; |
| 398 | 398 | $ph['node_toggle'] = 0; |
| 399 | 399 | |
| 400 | - if($ph['donthit'] == 1) { |
|
| 400 | + if ($ph['donthit'] == 1) { |
|
| 401 | 401 | $ph['tree_page_click'] = 3; |
| 402 | 402 | $ph['icon_node_toggle'] = ''; |
| 403 | 403 | $ph['icon'] = $ph['icon_folder_close']; |
@@ -409,23 +409,23 @@ discard block |
||
| 409 | 409 | 'ph' => $ph, |
| 410 | 410 | 'opened' => '0' |
| 411 | 411 | )); |
| 412 | - if(is_array($prenode)) { |
|
| 412 | + if (is_array($prenode)) { |
|
| 413 | 413 | $phnew = array(); |
| 414 | - foreach($prenode as $pnode) { |
|
| 414 | + foreach ($prenode as $pnode) { |
|
| 415 | 415 | $phnew = array_merge($phnew, unserialize($pnode)); |
| 416 | 416 | } |
| 417 | 417 | $ph = (count($phnew) > 0) ? $phnew : $ph; |
| 418 | 418 | } |
| 419 | 419 | |
| 420 | - if($ph['showChildren'] == 0) { |
|
| 420 | + if ($ph['showChildren'] == 0) { |
|
| 421 | 421 | $ph['icon_node_toggle'] = ''; |
| 422 | 422 | $ph['donthit'] = 1; |
| 423 | 423 | $ph['icon'] = $ph['icon_folder_close']; |
| 424 | 424 | $tpl = getTplFolderNodeNotChildren(); |
| 425 | 425 | } |
| 426 | 426 | |
| 427 | - if($ph['contextmenu']) { |
|
| 428 | - $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"'; |
|
| 427 | + if ($ph['contextmenu']) { |
|
| 428 | + $ph['contextmenu'] = ' data-contextmenu="'._htmlentities($ph['contextmenu']).'"'; |
|
| 429 | 429 | } |
| 430 | 430 | |
| 431 | 431 | $node .= $modx->parseText($tpl, $ph); |
@@ -437,10 +437,10 @@ discard block |
||
| 437 | 437 | // invoke OnManagerNodeRender event |
| 438 | 438 | $data['node'] = $node; |
| 439 | 439 | $evtOut = $modx->invokeEvent('OnManagerNodeRender', $data); |
| 440 | - if(is_array($evtOut)) { |
|
| 440 | + if (is_array($evtOut)) { |
|
| 441 | 441 | $evtOut = implode("\n", $evtOut); |
| 442 | 442 | } |
| 443 | - if($evtOut != '') { |
|
| 443 | + if ($evtOut != '') { |
|
| 444 | 444 | $node = trim($evtOut); |
| 445 | 445 | } |
| 446 | 446 | |
@@ -450,14 +450,14 @@ discard block |
||
| 450 | 450 | return $output; |
| 451 | 451 | } |
| 452 | 452 | |
| 453 | -function getIconInfo($_style) { |
|
| 454 | - if(!isset($_style['tree_page_gif'])) { |
|
| 453 | +function getIconInfo($_style){ |
|
| 454 | + if (!isset($_style['tree_page_gif'])) { |
|
| 455 | 455 | $_style['tree_page_gif'] = $_style['tree_page']; |
| 456 | 456 | } |
| 457 | - if(!isset($_style['tree_page_jpg'])) { |
|
| 457 | + if (!isset($_style['tree_page_jpg'])) { |
|
| 458 | 458 | $_style['tree_page_jpg'] = $_style['tree_page']; |
| 459 | 459 | } |
| 460 | - if(!isset($_style['tree_page_png'])) { |
|
| 460 | + if (!isset($_style['tree_page_png'])) { |
|
| 461 | 461 | $_style['tree_page_png'] = $_style['tree_page']; |
| 462 | 462 | } |
| 463 | 463 | $icons = array( |
@@ -477,14 +477,14 @@ discard block |
||
| 477 | 477 | return $icons; |
| 478 | 478 | } |
| 479 | 479 | |
| 480 | -function getPrivateIconInfo($_style) { |
|
| 481 | - if(!isset($_style['tree_page_gif_secure'])) { |
|
| 480 | +function getPrivateIconInfo($_style){ |
|
| 481 | + if (!isset($_style['tree_page_gif_secure'])) { |
|
| 482 | 482 | $_style['tree_page_gif_secure'] = $_style['tree_page_secure']; |
| 483 | 483 | } |
| 484 | - if(!isset($_style['tree_page_jpg_secure'])) { |
|
| 484 | + if (!isset($_style['tree_page_jpg_secure'])) { |
|
| 485 | 485 | $_style['tree_page_jpg_secure'] = $_style['tree_page_secure']; |
| 486 | 486 | } |
| 487 | - if(!isset($_style['tree_page_png_secure'])) { |
|
| 487 | + if (!isset($_style['tree_page_png_secure'])) { |
|
| 488 | 488 | $_style['tree_page_png_secure'] = $_style['tree_page_secure']; |
| 489 | 489 | } |
| 490 | 490 | $iconsPrivate = array( |
@@ -504,21 +504,21 @@ discard block |
||
| 504 | 504 | return $iconsPrivate; |
| 505 | 505 | } |
| 506 | 506 | |
| 507 | -function getNodeTitle($nodeNameSource, $row) { |
|
| 507 | +function getNodeTitle($nodeNameSource, $row){ |
|
| 508 | 508 | global $modx; |
| 509 | 509 | |
| 510 | - switch($nodeNameSource) { |
|
| 510 | + switch ($nodeNameSource) { |
|
| 511 | 511 | case 'menutitle': |
| 512 | 512 | $nodetitle = $row['menutitle'] ? $row['menutitle'] : $row['pagetitle']; |
| 513 | 513 | break; |
| 514 | 514 | case 'alias': |
| 515 | 515 | $nodetitle = $row['alias'] ? $row['alias'] : $row['id']; |
| 516 | - if(strpos($row['alias'], '.') === false) { |
|
| 517 | - if($row['isfolder'] != 1 || $modx->config['make_folders'] != 1) { |
|
| 516 | + if (strpos($row['alias'], '.') === false) { |
|
| 517 | + if ($row['isfolder'] != 1 || $modx->config['make_folders'] != 1) { |
|
| 518 | 518 | $nodetitle .= $modx->config['friendly_url_suffix']; |
| 519 | 519 | } |
| 520 | 520 | } |
| 521 | - $nodetitle = $modx->config['friendly_url_prefix'] . $nodetitle; |
|
| 521 | + $nodetitle = $modx->config['friendly_url_prefix'].$nodetitle; |
|
| 522 | 522 | break; |
| 523 | 523 | case 'pagetitle': |
| 524 | 524 | $nodetitle = $row['pagetitle']; |
@@ -533,7 +533,7 @@ discard block |
||
| 533 | 533 | case 'unpub_date': |
| 534 | 534 | $doc = $modx->getDocumentObject('id', $row['id']); |
| 535 | 535 | $date = $doc[$nodeNameSource]; |
| 536 | - if(!empty($date)) { |
|
| 536 | + if (!empty($date)) { |
|
| 537 | 537 | $nodetitle = $modx->toDateFormat($date); |
| 538 | 538 | } else { |
| 539 | 539 | $nodetitle = '- - -'; |
@@ -550,8 +550,8 @@ discard block |
||
| 550 | 550 | return $nodetitle; |
| 551 | 551 | } |
| 552 | 552 | |
| 553 | -function isDateNode($nodeNameSource) { |
|
| 554 | - switch($nodeNameSource) { |
|
| 553 | +function isDateNode($nodeNameSource){ |
|
| 554 | + switch ($nodeNameSource) { |
|
| 555 | 555 | case 'createdon': |
| 556 | 556 | case 'editedon': |
| 557 | 557 | case 'publishedon': |
@@ -563,13 +563,13 @@ discard block |
||
| 563 | 563 | } |
| 564 | 564 | } |
| 565 | 565 | |
| 566 | -function checkIsFolder($parent = 0, $isfolder = 1) { |
|
| 566 | +function checkIsFolder($parent = 0, $isfolder = 1){ |
|
| 567 | 567 | global $modx; |
| 568 | 568 | |
| 569 | - return (int) $modx->db->getValue($modx->db->query('SELECT count(*) FROM ' . $modx->getFullTableName('site_content') . ' WHERE parent=' . $parent . ' AND isfolder=' . $isfolder . ' ')); |
|
| 569 | + return (int) $modx->db->getValue($modx->db->query('SELECT count(*) FROM '.$modx->getFullTableName('site_content').' WHERE parent='.$parent.' AND isfolder='.$isfolder.' ')); |
|
| 570 | 570 | } |
| 571 | 571 | |
| 572 | -function _htmlentities($array) { |
|
| 572 | +function _htmlentities($array){ |
|
| 573 | 573 | global $modx; |
| 574 | 574 | |
| 575 | 575 | $array = json_encode($array, JSON_UNESCAPED_UNICODE); |
@@ -578,7 +578,7 @@ discard block |
||
| 578 | 578 | return $array; |
| 579 | 579 | } |
| 580 | 580 | |
| 581 | -function getTplSingleNode() { |
|
| 581 | +function getTplSingleNode(){ |
|
| 582 | 582 | return '<div id="node[+id+]"><a class="[+treeNodeClass+]" |
| 583 | 583 | onclick="modx.tree.treeAction(event,[+id+]);" |
| 584 | 584 | oncontextmenu="modx.tree.showPopup(event,[+id+],\'[+nodetitle_esc+]\');" |
@@ -602,7 +602,7 @@ discard block |
||
| 602 | 602 | title="[+title+]">[+nodetitleDisplay+][+weblinkDisplay+]</span>[+pageIdDisplay+]</a></div>'; |
| 603 | 603 | } |
| 604 | 604 | |
| 605 | -function getTplFolderNode() { |
|
| 605 | +function getTplFolderNode(){ |
|
| 606 | 606 | return '<div id="node[+id+]"><a class="[+treeNodeClass+]" |
| 607 | 607 | onclick="modx.tree.treeAction(event,[+id+]);" |
| 608 | 608 | oncontextmenu="modx.tree.showPopup(event,[+id+],\'[+nodetitle_esc+]\');" |
@@ -638,7 +638,7 @@ discard block |
||
| 638 | 638 | title="[+title+]">[+nodetitleDisplay+][+weblinkDisplay+]</span>[+pageIdDisplay+]</a><div>'; |
| 639 | 639 | } |
| 640 | 640 | |
| 641 | -function getTplFolderNodeNotChildren() { |
|
| 641 | +function getTplFolderNodeNotChildren(){ |
|
| 642 | 642 | return '<div id="node[+id+]"><a class="[+treeNodeClass+]" |
| 643 | 643 | onclick="modx.tree.treeAction(event,[+id+]);" |
| 644 | 644 | oncontextmenu="modx.tree.showPopup(event,[+id+],\'[+nodetitle_esc+]\');" |
@@ -670,11 +670,11 @@ discard block |
||
| 670 | 670 | title="[+title+]">[+nodetitleDisplay+][+weblinkDisplay+]</span>[+pageIdDisplay+]</a><div>'; |
| 671 | 671 | } |
| 672 | 672 | |
| 673 | -function dbug($str, $flag = false) { |
|
| 673 | +function dbug($str, $flag = false){ |
|
| 674 | 674 | print('<pre>'); |
| 675 | 675 | print_r($str); |
| 676 | 676 | print('</pre>'); |
| 677 | - if($flag) { |
|
| 677 | + if ($flag) { |
|
| 678 | 678 | exit; |
| 679 | 679 | } |
| 680 | 680 | } |
@@ -3,6 +3,9 @@ |
||
| 3 | 3 | //Kyle Jaebker - 08/07/06 |
| 4 | 4 | |
| 5 | 5 | //Create a new category |
| 6 | +/** |
|
| 7 | + * @param string $newCat |
|
| 8 | + */ |
|
| 6 | 9 | function newCategory($newCat) { |
| 7 | 10 | global $modx; |
| 8 | 11 | $useTable = $modx->getFullTableName('categories'); |
@@ -19,9 +19,9 @@ discard block |
||
| 19 | 19 | $useTable = $modx->getFullTableName('categories'); |
| 20 | 20 | $newCat = $modx->db->escape($newCat); |
| 21 | 21 | $cats = $modx->db->select('id', $modx->getFullTableName('categories'), "category='{$newCat}'"); |
| 22 | - if($cat = $modx->db->getValue($cats)) { |
|
| 23 | - return $cat; |
|
| 24 | - } |
|
| 22 | + if($cat = $modx->db->getValue($cats)) { |
|
| 23 | + return $cat; |
|
| 24 | + } |
|
| 25 | 25 | return 0; |
| 26 | 26 | } |
| 27 | 27 | //Check for category, create new if not exists |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | global $modx; |
| 36 | 36 | $useTable = $modx->getFullTableName('categories'); |
| 37 | 37 | $cats = $modx->db->select('id, category', $modx->getFullTableName('categories'), '', 'category'); |
| 38 | - $resourceArray = array(); |
|
| 38 | + $resourceArray = array(); |
|
| 39 | 39 | while($row = $modx->db->getRow($cats)) { |
| 40 | 40 | $row['category'] = stripslashes($row['category']); |
| 41 | 41 | $resourceArray[] = $row; |
@@ -3,7 +3,7 @@ discard block |
||
| 3 | 3 | //Kyle Jaebker - 08/07/06 |
| 4 | 4 | |
| 5 | 5 | //Create a new category |
| 6 | -function newCategory($newCat) { |
|
| 6 | +function newCategory($newCat){ |
|
| 7 | 7 | global $modx; |
| 8 | 8 | $useTable = $modx->getFullTableName('categories'); |
| 9 | 9 | $categoryId = $modx->db->insert( |
@@ -14,36 +14,36 @@ discard block |
||
| 14 | 14 | return $categoryId; |
| 15 | 15 | } |
| 16 | 16 | //check if new category already exists |
| 17 | -function checkCategory($newCat = '') { |
|
| 17 | +function checkCategory($newCat = ''){ |
|
| 18 | 18 | global $modx; |
| 19 | 19 | $useTable = $modx->getFullTableName('categories'); |
| 20 | 20 | $newCat = $modx->db->escape($newCat); |
| 21 | 21 | $cats = $modx->db->select('id', $modx->getFullTableName('categories'), "category='{$newCat}'"); |
| 22 | - if($cat = $modx->db->getValue($cats)) { |
|
| 22 | + if ($cat = $modx->db->getValue($cats)) { |
|
| 23 | 23 | return $cat; |
| 24 | 24 | } |
| 25 | 25 | return 0; |
| 26 | 26 | } |
| 27 | 27 | //Check for category, create new if not exists |
| 28 | -function getCategory($category='') { |
|
| 28 | +function getCategory($category = ''){ |
|
| 29 | 29 | $categoryId = checkCategory($category); |
| 30 | - if(!$categoryId) $categoryId = newCategory($category); |
|
| 30 | + if (!$categoryId) $categoryId = newCategory($category); |
|
| 31 | 31 | return $categoryId; |
| 32 | 32 | } |
| 33 | 33 | //Get all categories |
| 34 | -function getCategories() { |
|
| 34 | +function getCategories(){ |
|
| 35 | 35 | global $modx; |
| 36 | 36 | $useTable = $modx->getFullTableName('categories'); |
| 37 | 37 | $cats = $modx->db->select('id, category', $modx->getFullTableName('categories'), '', 'category'); |
| 38 | 38 | $resourceArray = array(); |
| 39 | - while($row = $modx->db->getRow($cats)) { |
|
| 39 | + while ($row = $modx->db->getRow($cats)) { |
|
| 40 | 40 | $row['category'] = stripslashes($row['category']); |
| 41 | 41 | $resourceArray[] = $row; |
| 42 | 42 | } |
| 43 | 43 | return $resourceArray; |
| 44 | 44 | } |
| 45 | 45 | //Delete category & associations |
| 46 | -function deleteCategory($catId=0) { |
|
| 46 | +function deleteCategory($catId = 0){ |
|
| 47 | 47 | global $modx; |
| 48 | 48 | if ($catId) { |
| 49 | 49 | $resetTables = array('site_plugins', 'site_snippets', 'site_htmlsnippets', 'site_templates', 'site_tmplvars', 'site_modules'); |
@@ -3,18 +3,22 @@ discard block |
||
| 3 | 3 | //Kyle Jaebker - 08/07/06 |
| 4 | 4 | |
| 5 | 5 | //Create a new category |
| 6 | -function newCategory($newCat) { |
|
| 6 | +function newCategory($newCat) |
|
| 7 | +{ |
|
| 7 | 8 | global $modx; |
| 8 | 9 | $useTable = $modx->getFullTableName('categories'); |
| 9 | 10 | $categoryId = $modx->db->insert( |
| 10 | 11 | array( |
| 11 | 12 | 'category' => $modx->db->escape($newCat), |
| 12 | 13 | ), $useTable); |
| 13 | - if (!$categoryId) $categoryId = 0; |
|
| 14 | + if (!$categoryId) { |
|
| 15 | + $categoryId = 0; |
|
| 16 | + } |
|
| 14 | 17 | return $categoryId; |
| 15 | 18 | } |
| 16 | 19 | //check if new category already exists |
| 17 | -function checkCategory($newCat = '') { |
|
| 20 | +function checkCategory($newCat = '') |
|
| 21 | +{ |
|
| 18 | 22 | global $modx; |
| 19 | 23 | $useTable = $modx->getFullTableName('categories'); |
| 20 | 24 | $newCat = $modx->db->escape($newCat); |
@@ -25,13 +29,17 @@ discard block |
||
| 25 | 29 | return 0; |
| 26 | 30 | } |
| 27 | 31 | //Check for category, create new if not exists |
| 28 | -function getCategory($category='') { |
|
| 32 | +function getCategory($category='') |
|
| 33 | +{ |
|
| 29 | 34 | $categoryId = checkCategory($category); |
| 30 | - if(!$categoryId) $categoryId = newCategory($category); |
|
| 35 | + if(!$categoryId) { |
|
| 36 | + $categoryId = newCategory($category); |
|
| 37 | + } |
|
| 31 | 38 | return $categoryId; |
| 32 | 39 | } |
| 33 | 40 | //Get all categories |
| 34 | -function getCategories() { |
|
| 41 | +function getCategories() |
|
| 42 | +{ |
|
| 35 | 43 | global $modx; |
| 36 | 44 | $useTable = $modx->getFullTableName('categories'); |
| 37 | 45 | $cats = $modx->db->select('id, category', $modx->getFullTableName('categories'), '', 'category'); |
@@ -43,7 +51,8 @@ discard block |
||
| 43 | 51 | return $resourceArray; |
| 44 | 52 | } |
| 45 | 53 | //Delete category & associations |
| 46 | -function deleteCategory($catId=0) { |
|
| 54 | +function deleteCategory($catId=0) |
|
| 55 | +{ |
|
| 47 | 56 | global $modx; |
| 48 | 57 | if ($catId) { |
| 49 | 58 | $resetTables = array('site_plugins', 'site_snippets', 'site_htmlsnippets', 'site_templates', 'site_tmplvars', 'site_modules'); |
@@ -3968,7 +3968,7 @@ |
||
| 3968 | 3968 | * @param int|string $options Either a PATHINFO_* constant, |
| 3969 | 3969 | * or a string name to return only the specified piece |
| 3970 | 3970 | * |
| 3971 | - * @return string|array |
|
| 3971 | + * @return string |
|
| 3972 | 3972 | */ |
| 3973 | 3973 | public static function mb_pathinfo($path, $options = null) |
| 3974 | 3974 | { |
@@ -1076,10 +1076,10 @@ discard block |
||
| 1076 | 1076 | $list = imap_rfc822_parse_adrlist($addrstr, ''); |
| 1077 | 1077 | foreach ($list as $address) { |
| 1078 | 1078 | if ('.SYNTAX-ERROR.' != $address->host) { |
| 1079 | - if (static::validateAddress($address->mailbox . '@' . $address->host)) { |
|
| 1079 | + if (static::validateAddress($address->mailbox.'@'.$address->host)) { |
|
| 1080 | 1080 | $addresses[] = [ |
| 1081 | 1081 | 'name' => (property_exists($address, 'personal') ? $address->personal : ''), |
| 1082 | - 'address' => $address->mailbox . '@' . $address->host, |
|
| 1082 | + 'address' => $address->mailbox.'@'.$address->host, |
|
| 1083 | 1083 | ]; |
| 1084 | 1084 | } |
| 1085 | 1085 | } |
@@ -1225,14 +1225,14 @@ discard block |
||
| 1225 | 1225 | * Feel free to use and redistribute this code. But please keep this copyright notice. |
| 1226 | 1226 | */ |
| 1227 | 1227 | return (bool) preg_match( |
| 1228 | - '/^(?!(?>(?1)"?(?>\\\[ -~]|[^"])"?(?1)){255,})(?!(?>(?1)"?(?>\\\[ -~]|[^"])"?(?1)){65,}@)' . |
|
| 1229 | - '((?>(?>(?>((?>(?>(?>\x0D\x0A)?[\t ])+|(?>[\t ]*\x0D\x0A)?[\t ]+)?)(\((?>(?2)' . |
|
| 1230 | - '(?>[\x01-\x08\x0B\x0C\x0E-\'*-\[\]-\x7F]|\\\[\x00-\x7F]|(?3)))*(?2)\)))+(?2))|(?2))?)' . |
|
| 1231 | - '([!#-\'*+\/-9=?^-~-]+|"(?>(?2)(?>[\x01-\x08\x0B\x0C\x0E-!#-\[\]-\x7F]|\\\[\x00-\x7F]))*' . |
|
| 1232 | - '(?2)")(?>(?1)\.(?1)(?4))*(?1)@(?!(?1)[a-z0-9-]{64,})(?1)(?>([a-z0-9](?>[a-z0-9-]*[a-z0-9])?)' . |
|
| 1233 | - '(?>(?1)\.(?!(?1)[a-z0-9-]{64,})(?1)(?5)){0,126}|\[(?:(?>IPv6:(?>([a-f0-9]{1,4})(?>:(?6)){7}' . |
|
| 1234 | - '|(?!(?:.*[a-f0-9][:\]]){8,})((?6)(?>:(?6)){0,6})?::(?7)?))|(?>(?>IPv6:(?>(?6)(?>:(?6)){5}:' . |
|
| 1235 | - '|(?!(?:.*[a-f0-9]:){6,})(?8)?::(?>((?6)(?>:(?6)){0,4}):)?))?(25[0-5]|2[0-4][0-9]|1[0-9]{2}' . |
|
| 1228 | + '/^(?!(?>(?1)"?(?>\\\[ -~]|[^"])"?(?1)){255,})(?!(?>(?1)"?(?>\\\[ -~]|[^"])"?(?1)){65,}@)'. |
|
| 1229 | + '((?>(?>(?>((?>(?>(?>\x0D\x0A)?[\t ])+|(?>[\t ]*\x0D\x0A)?[\t ]+)?)(\((?>(?2)'. |
|
| 1230 | + '(?>[\x01-\x08\x0B\x0C\x0E-\'*-\[\]-\x7F]|\\\[\x00-\x7F]|(?3)))*(?2)\)))+(?2))|(?2))?)'. |
|
| 1231 | + '([!#-\'*+\/-9=?^-~-]+|"(?>(?2)(?>[\x01-\x08\x0B\x0C\x0E-!#-\[\]-\x7F]|\\\[\x00-\x7F]))*'. |
|
| 1232 | + '(?2)")(?>(?1)\.(?1)(?4))*(?1)@(?!(?1)[a-z0-9-]{64,})(?1)(?>([a-z0-9](?>[a-z0-9-]*[a-z0-9])?)'. |
|
| 1233 | + '(?>(?1)\.(?!(?1)[a-z0-9-]{64,})(?1)(?5)){0,126}|\[(?:(?>IPv6:(?>([a-f0-9]{1,4})(?>:(?6)){7}'. |
|
| 1234 | + '|(?!(?:.*[a-f0-9][:\]]){8,})((?6)(?>:(?6)){0,6})?::(?7)?))|(?>(?>IPv6:(?>(?6)(?>:(?6)){5}:'. |
|
| 1235 | + '|(?!(?:.*[a-f0-9]:){6,})(?8)?::(?>((?6)(?>:(?6)){0,4}):)?))?(25[0-5]|2[0-4][0-9]|1[0-9]{2}'. |
|
| 1236 | 1236 | '|[1-9]?[0-9])(?>\.(?9)){3}))\])(?1)$/isD', |
| 1237 | 1237 | $address |
| 1238 | 1238 | ); |
@@ -1243,7 +1243,7 @@ discard block |
||
| 1243 | 1243 | * @see http://www.whatwg.org/specs/web-apps/current-work/#e-mail-state-(type=email) |
| 1244 | 1244 | */ |
| 1245 | 1245 | return (bool) preg_match( |
| 1246 | - '/^[a-zA-Z0-9.!#$%&\'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}' . |
|
| 1246 | + '/^[a-zA-Z0-9.!#$%&\'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}'. |
|
| 1247 | 1247 | '[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/sD', |
| 1248 | 1248 | $address |
| 1249 | 1249 | ); |
@@ -1294,7 +1294,7 @@ discard block |
||
| 1294 | 1294 | $errorcode = 0; |
| 1295 | 1295 | $punycode = idn_to_ascii($domain, $errorcode, INTL_IDNA_VARIANT_UTS46); |
| 1296 | 1296 | if (false !== $punycode) { |
| 1297 | - return substr($address, 0, $pos) . $punycode; |
|
| 1297 | + return substr($address, 0, $pos).$punycode; |
|
| 1298 | 1298 | } |
| 1299 | 1299 | } |
| 1300 | 1300 | } |
@@ -1358,8 +1358,8 @@ discard block |
||
| 1358 | 1358 | and version_compare(PHP_VERSION, '7.1.3', '<'))) |
| 1359 | 1359 | ) { |
| 1360 | 1360 | trigger_error( |
| 1361 | - 'Your version of PHP is affected by a bug that may result in corrupted messages.' . |
|
| 1362 | - ' To fix it, switch to sending using SMTP, disable the mail.add_x_header option in' . |
|
| 1361 | + 'Your version of PHP is affected by a bug that may result in corrupted messages.'. |
|
| 1362 | + ' To fix it, switch to sending using SMTP, disable the mail.add_x_header option in'. |
|
| 1363 | 1363 | ' your php.ini, switch to MacOS or Linux, or upgrade your PHP to version 7.0.17+ or 7.1.3+.', |
| 1364 | 1364 | E_USER_WARNING |
| 1365 | 1365 | ); |
@@ -1443,12 +1443,12 @@ discard block |
||
| 1443 | 1443 | ) |
| 1444 | 1444 | ) { |
| 1445 | 1445 | $header_dkim = $this->DKIM_Add( |
| 1446 | - $this->MIMEHeader . $this->mailHeader, |
|
| 1446 | + $this->MIMEHeader.$this->mailHeader, |
|
| 1447 | 1447 | $this->encodeHeader($this->secureHeader($this->Subject)), |
| 1448 | 1448 | $this->MIMEBody |
| 1449 | 1449 | ); |
| 1450 | - $this->MIMEHeader = rtrim($this->MIMEHeader, "\r\n ") . static::$LE . |
|
| 1451 | - static::normalizeBreaks($header_dkim) . static::$LE; |
|
| 1450 | + $this->MIMEHeader = rtrim($this->MIMEHeader, "\r\n ").static::$LE. |
|
| 1451 | + static::normalizeBreaks($header_dkim).static::$LE; |
|
| 1452 | 1452 | } |
| 1453 | 1453 | |
| 1454 | 1454 | return true; |
@@ -1482,7 +1482,7 @@ discard block |
||
| 1482 | 1482 | case 'mail': |
| 1483 | 1483 | return $this->mailSend($this->MIMEHeader, $this->MIMEBody); |
| 1484 | 1484 | default: |
| 1485 | - $sendMethod = $this->Mailer . 'Send'; |
|
| 1485 | + $sendMethod = $this->Mailer.'Send'; |
|
| 1486 | 1486 | if (method_exists($this, $sendMethod)) { |
| 1487 | 1487 | return $this->$sendMethod($this->MIMEHeader, $this->MIMEBody); |
| 1488 | 1488 | } |
@@ -1535,9 +1535,9 @@ discard block |
||
| 1535 | 1535 | foreach ($this->SingleToArray as $toAddr) { |
| 1536 | 1536 | $mail = @popen($sendmail, 'w'); |
| 1537 | 1537 | if (!$mail) { |
| 1538 | - throw new Exception($this->lang('execute') . $this->Sendmail, self::STOP_CRITICAL); |
|
| 1538 | + throw new Exception($this->lang('execute').$this->Sendmail, self::STOP_CRITICAL); |
|
| 1539 | 1539 | } |
| 1540 | - fwrite($mail, 'To: ' . $toAddr . "\n"); |
|
| 1540 | + fwrite($mail, 'To: '.$toAddr."\n"); |
|
| 1541 | 1541 | fwrite($mail, $header); |
| 1542 | 1542 | fwrite($mail, $body); |
| 1543 | 1543 | $result = pclose($mail); |
@@ -1552,13 +1552,13 @@ discard block |
||
| 1552 | 1552 | [] |
| 1553 | 1553 | ); |
| 1554 | 1554 | if (0 !== $result) { |
| 1555 | - throw new Exception($this->lang('execute') . $this->Sendmail, self::STOP_CRITICAL); |
|
| 1555 | + throw new Exception($this->lang('execute').$this->Sendmail, self::STOP_CRITICAL); |
|
| 1556 | 1556 | } |
| 1557 | 1557 | } |
| 1558 | 1558 | } else { |
| 1559 | 1559 | $mail = @popen($sendmail, 'w'); |
| 1560 | 1560 | if (!$mail) { |
| 1561 | - throw new Exception($this->lang('execute') . $this->Sendmail, self::STOP_CRITICAL); |
|
| 1561 | + throw new Exception($this->lang('execute').$this->Sendmail, self::STOP_CRITICAL); |
|
| 1562 | 1562 | } |
| 1563 | 1563 | fwrite($mail, $header); |
| 1564 | 1564 | fwrite($mail, $body); |
@@ -1574,7 +1574,7 @@ discard block |
||
| 1574 | 1574 | [] |
| 1575 | 1575 | ); |
| 1576 | 1576 | if (0 !== $result) { |
| 1577 | - throw new Exception($this->lang('execute') . $this->Sendmail, self::STOP_CRITICAL); |
|
| 1577 | + throw new Exception($this->lang('execute').$this->Sendmail, self::STOP_CRITICAL); |
|
| 1578 | 1578 | } |
| 1579 | 1579 | } |
| 1580 | 1580 | |
@@ -1732,7 +1732,7 @@ discard block |
||
| 1732 | 1732 | $smtp_from = $this->Sender; |
| 1733 | 1733 | } |
| 1734 | 1734 | if (!$this->smtp->mail($smtp_from)) { |
| 1735 | - $this->setError($this->lang('from_failed') . $smtp_from . ' : ' . implode(',', $this->smtp->getError())); |
|
| 1735 | + $this->setError($this->lang('from_failed').$smtp_from.' : '.implode(',', $this->smtp->getError())); |
|
| 1736 | 1736 | throw new Exception($this->ErrorInfo, self::STOP_CRITICAL); |
| 1737 | 1737 | } |
| 1738 | 1738 | |
@@ -1753,7 +1753,7 @@ discard block |
||
| 1753 | 1753 | } |
| 1754 | 1754 | |
| 1755 | 1755 | // Only send the DATA command if we have viable recipients |
| 1756 | - if ((count($this->all_recipients) > count($bad_rcpt)) and !$this->smtp->data($header . $body)) { |
|
| 1756 | + if ((count($this->all_recipients) > count($bad_rcpt)) and !$this->smtp->data($header.$body)) { |
|
| 1757 | 1757 | throw new Exception($this->lang('data_not_accepted'), self::STOP_CRITICAL); |
| 1758 | 1758 | } |
| 1759 | 1759 | |
@@ -1783,10 +1783,10 @@ discard block |
||
| 1783 | 1783 | if (count($bad_rcpt) > 0) { |
| 1784 | 1784 | $errstr = ''; |
| 1785 | 1785 | foreach ($bad_rcpt as $bad) { |
| 1786 | - $errstr .= $bad['to'] . ': ' . $bad['error']; |
|
| 1786 | + $errstr .= $bad['to'].': '.$bad['error']; |
|
| 1787 | 1787 | } |
| 1788 | 1788 | throw new Exception( |
| 1789 | - $this->lang('recipients_failed') . $errstr, |
|
| 1789 | + $this->lang('recipients_failed').$errstr, |
|
| 1790 | 1790 | self::STOP_CONTINUE |
| 1791 | 1791 | ); |
| 1792 | 1792 | } |
@@ -1836,7 +1836,7 @@ discard block |
||
| 1836 | 1836 | trim($hostentry), |
| 1837 | 1837 | $hostinfo |
| 1838 | 1838 | )) { |
| 1839 | - static::edebug($this->lang('connect_host') . ' ' . $hostentry); |
|
| 1839 | + static::edebug($this->lang('connect_host').' '.$hostentry); |
|
| 1840 | 1840 | // Not a valid host entry |
| 1841 | 1841 | continue; |
| 1842 | 1842 | } |
@@ -1848,7 +1848,7 @@ discard block |
||
| 1848 | 1848 | |
| 1849 | 1849 | //Check the host name is a valid name or IP address before trying to use it |
| 1850 | 1850 | if (!static::isValidHost($hostinfo[3])) { |
| 1851 | - static::edebug($this->lang('connect_host') . ' ' . $hostentry); |
|
| 1851 | + static::edebug($this->lang('connect_host').' '.$hostentry); |
|
| 1852 | 1852 | continue; |
| 1853 | 1853 | } |
| 1854 | 1854 | $prefix = ''; |
@@ -1868,7 +1868,7 @@ discard block |
||
| 1868 | 1868 | if ('tls' === $secure or 'ssl' === $secure) { |
| 1869 | 1869 | //Check for an OpenSSL constant rather than using extension_loaded, which is sometimes disabled |
| 1870 | 1870 | if (!$sslext) { |
| 1871 | - throw new Exception($this->lang('extension_missing') . 'openssl', self::STOP_CRITICAL); |
|
| 1871 | + throw new Exception($this->lang('extension_missing').'openssl', self::STOP_CRITICAL); |
|
| 1872 | 1872 | } |
| 1873 | 1873 | } |
| 1874 | 1874 | $host = $hostinfo[3]; |
@@ -1877,7 +1877,7 @@ discard block |
||
| 1877 | 1877 | if ($tport > 0 and $tport < 65536) { |
| 1878 | 1878 | $port = $tport; |
| 1879 | 1879 | } |
| 1880 | - if ($this->smtp->connect($prefix . $host, $port, $this->Timeout, $options)) { |
|
| 1880 | + if ($this->smtp->connect($prefix.$host, $port, $this->Timeout, $options)) { |
|
| 1881 | 1881 | try { |
| 1882 | 1882 | if ($this->Helo) { |
| 1883 | 1883 | $hello = $this->Helo; |
@@ -1994,14 +1994,14 @@ discard block |
||
| 1994 | 1994 | ]; |
| 1995 | 1995 | if (empty($lang_path)) { |
| 1996 | 1996 | // Calculate an absolute path so it can work if CWD is not here |
| 1997 | - $lang_path = __DIR__ . DIRECTORY_SEPARATOR . 'language' . DIRECTORY_SEPARATOR; |
|
| 1997 | + $lang_path = __DIR__.DIRECTORY_SEPARATOR.'language'.DIRECTORY_SEPARATOR; |
|
| 1998 | 1998 | } |
| 1999 | 1999 | //Validate $langcode |
| 2000 | 2000 | if (!preg_match('/^[a-z]{2}(?:_[a-zA-Z]{2})?$/', $langcode)) { |
| 2001 | 2001 | $langcode = 'en'; |
| 2002 | 2002 | } |
| 2003 | 2003 | $foundlang = true; |
| 2004 | - $lang_file = $lang_path . 'phpmailer.lang-' . $langcode . '.php'; |
|
| 2004 | + $lang_file = $lang_path.'phpmailer.lang-'.$langcode.'.php'; |
|
| 2005 | 2005 | // There is no English translation file |
| 2006 | 2006 | if ('en' != $langcode) { |
| 2007 | 2007 | // Make sure language file path is readable |
@@ -2046,7 +2046,7 @@ discard block |
||
| 2046 | 2046 | $addresses[] = $this->addrFormat($address); |
| 2047 | 2047 | } |
| 2048 | 2048 | |
| 2049 | - return $type . ': ' . implode(', ', $addresses) . static::$LE; |
|
| 2049 | + return $type.': '.implode(', ', $addresses).static::$LE; |
|
| 2050 | 2050 | } |
| 2051 | 2051 | |
| 2052 | 2052 | /** |
@@ -2063,9 +2063,9 @@ discard block |
||
| 2063 | 2063 | return $this->secureHeader($addr[0]); |
| 2064 | 2064 | } |
| 2065 | 2065 | |
| 2066 | - return $this->encodeHeader($this->secureHeader($addr[1]), 'phrase') . ' <' . $this->secureHeader( |
|
| 2066 | + return $this->encodeHeader($this->secureHeader($addr[1]), 'phrase').' <'.$this->secureHeader( |
|
| 2067 | 2067 | $addr[0] |
| 2068 | - ) . '>'; |
|
| 2068 | + ).'>'; |
|
| 2069 | 2069 | } |
| 2070 | 2070 | |
| 2071 | 2071 | /** |
@@ -2122,10 +2122,10 @@ discard block |
||
| 2122 | 2122 | } |
| 2123 | 2123 | $part = substr($word, 0, $len); |
| 2124 | 2124 | $word = substr($word, $len); |
| 2125 | - $buf .= ' ' . $part; |
|
| 2126 | - $message .= $buf . sprintf('=%s', static::$LE); |
|
| 2125 | + $buf .= ' '.$part; |
|
| 2126 | + $message .= $buf.sprintf('=%s', static::$LE); |
|
| 2127 | 2127 | } else { |
| 2128 | - $message .= $buf . $soft_break; |
|
| 2128 | + $message .= $buf.$soft_break; |
|
| 2129 | 2129 | } |
| 2130 | 2130 | $buf = ''; |
| 2131 | 2131 | } |
@@ -2145,7 +2145,7 @@ discard block |
||
| 2145 | 2145 | $word = substr($word, $len); |
| 2146 | 2146 | |
| 2147 | 2147 | if (strlen($word) > 0) { |
| 2148 | - $message .= $part . sprintf('=%s', static::$LE); |
|
| 2148 | + $message .= $part.sprintf('=%s', static::$LE); |
|
| 2149 | 2149 | } else { |
| 2150 | 2150 | $buf = $part; |
| 2151 | 2151 | } |
@@ -2158,13 +2158,13 @@ discard block |
||
| 2158 | 2158 | $buf .= $word; |
| 2159 | 2159 | |
| 2160 | 2160 | if (strlen($buf) > $length and '' != $buf_o) { |
| 2161 | - $message .= $buf_o . $soft_break; |
|
| 2161 | + $message .= $buf_o.$soft_break; |
|
| 2162 | 2162 | $buf = $word; |
| 2163 | 2163 | } |
| 2164 | 2164 | } |
| 2165 | 2165 | $firstword = false; |
| 2166 | 2166 | } |
| 2167 | - $message .= $buf . static::$LE; |
|
| 2167 | + $message .= $buf.static::$LE; |
|
| 2168 | 2168 | } |
| 2169 | 2169 | |
| 2170 | 2170 | return $message; |
@@ -2310,7 +2310,7 @@ discard block |
||
| 2310 | 2310 | if ('' == $this->XMailer) { |
| 2311 | 2311 | $result .= $this->headerLine( |
| 2312 | 2312 | 'X-Mailer', |
| 2313 | - 'PHPMailer ' . self::VERSION . ' (https://github.com/PHPMailer/PHPMailer)' |
|
| 2313 | + 'PHPMailer '.self::VERSION.' (https://github.com/PHPMailer/PHPMailer)' |
|
| 2314 | 2314 | ); |
| 2315 | 2315 | } else { |
| 2316 | 2316 | $myXmailer = trim($this->XMailer); |
@@ -2320,7 +2320,7 @@ discard block |
||
| 2320 | 2320 | } |
| 2321 | 2321 | |
| 2322 | 2322 | if ('' != $this->ConfirmReadingTo) { |
| 2323 | - $result .= $this->headerLine('Disposition-Notification-To', '<' . $this->ConfirmReadingTo . '>'); |
|
| 2323 | + $result .= $this->headerLine('Disposition-Notification-To', '<'.$this->ConfirmReadingTo.'>'); |
|
| 2324 | 2324 | } |
| 2325 | 2325 | |
| 2326 | 2326 | // Add custom headers |
@@ -2350,23 +2350,23 @@ discard block |
||
| 2350 | 2350 | switch ($this->message_type) { |
| 2351 | 2351 | case 'inline': |
| 2352 | 2352 | $result .= $this->headerLine('Content-Type', 'multipart/related;'); |
| 2353 | - $result .= $this->textLine("\tboundary=\"" . $this->boundary[1] . '"'); |
|
| 2353 | + $result .= $this->textLine("\tboundary=\"".$this->boundary[1].'"'); |
|
| 2354 | 2354 | break; |
| 2355 | 2355 | case 'attach': |
| 2356 | 2356 | case 'inline_attach': |
| 2357 | 2357 | case 'alt_attach': |
| 2358 | 2358 | case 'alt_inline_attach': |
| 2359 | 2359 | $result .= $this->headerLine('Content-Type', 'multipart/mixed;'); |
| 2360 | - $result .= $this->textLine("\tboundary=\"" . $this->boundary[1] . '"'); |
|
| 2360 | + $result .= $this->textLine("\tboundary=\"".$this->boundary[1].'"'); |
|
| 2361 | 2361 | break; |
| 2362 | 2362 | case 'alt': |
| 2363 | 2363 | case 'alt_inline': |
| 2364 | 2364 | $result .= $this->headerLine('Content-Type', 'multipart/alternative;'); |
| 2365 | - $result .= $this->textLine("\tboundary=\"" . $this->boundary[1] . '"'); |
|
| 2365 | + $result .= $this->textLine("\tboundary=\"".$this->boundary[1].'"'); |
|
| 2366 | 2366 | break; |
| 2367 | 2367 | default: |
| 2368 | 2368 | // Catches case 'plain': and case '': |
| 2369 | - $result .= $this->textLine('Content-Type: ' . $this->ContentType . '; charset=' . $this->CharSet); |
|
| 2369 | + $result .= $this->textLine('Content-Type: '.$this->ContentType.'; charset='.$this->CharSet); |
|
| 2370 | 2370 | $ismultipart = false; |
| 2371 | 2371 | break; |
| 2372 | 2372 | } |
@@ -2401,7 +2401,7 @@ discard block |
||
| 2401 | 2401 | */ |
| 2402 | 2402 | public function getSentMIMEMessage() |
| 2403 | 2403 | { |
| 2404 | - return rtrim($this->MIMEHeader . $this->mailHeader, "\n\r") . static::$LE . static::$LE . $this->MIMEBody; |
|
| 2404 | + return rtrim($this->MIMEHeader.$this->mailHeader, "\n\r").static::$LE.static::$LE.$this->MIMEBody; |
|
| 2405 | 2405 | } |
| 2406 | 2406 | |
| 2407 | 2407 | /** |
@@ -2438,12 +2438,12 @@ discard block |
||
| 2438 | 2438 | $body = ''; |
| 2439 | 2439 | //Create unique IDs and preset boundaries |
| 2440 | 2440 | $this->uniqueid = $this->generateId(); |
| 2441 | - $this->boundary[1] = 'b1_' . $this->uniqueid; |
|
| 2442 | - $this->boundary[2] = 'b2_' . $this->uniqueid; |
|
| 2443 | - $this->boundary[3] = 'b3_' . $this->uniqueid; |
|
| 2441 | + $this->boundary[1] = 'b1_'.$this->uniqueid; |
|
| 2442 | + $this->boundary[2] = 'b2_'.$this->uniqueid; |
|
| 2443 | + $this->boundary[3] = 'b3_'.$this->uniqueid; |
|
| 2444 | 2444 | |
| 2445 | 2445 | if ($this->sign_key_file) { |
| 2446 | - $body .= $this->getMailMIME() . static::$LE; |
|
| 2446 | + $body .= $this->getMailMIME().static::$LE; |
|
| 2447 | 2447 | } |
| 2448 | 2448 | |
| 2449 | 2449 | $this->setWordWrap(); |
@@ -2476,7 +2476,7 @@ discard block |
||
| 2476 | 2476 | $altBodyEncoding = 'quoted-printable'; |
| 2477 | 2477 | } |
| 2478 | 2478 | //Use this as a preamble in all multipart message types |
| 2479 | - $mimepre = 'This is a multi-part message in MIME format.' . static::$LE; |
|
| 2479 | + $mimepre = 'This is a multi-part message in MIME format.'.static::$LE; |
|
| 2480 | 2480 | switch ($this->message_type) { |
| 2481 | 2481 | case 'inline': |
| 2482 | 2482 | $body .= $mimepre; |
@@ -2494,9 +2494,9 @@ discard block |
||
| 2494 | 2494 | break; |
| 2495 | 2495 | case 'inline_attach': |
| 2496 | 2496 | $body .= $mimepre; |
| 2497 | - $body .= $this->textLine('--' . $this->boundary[1]); |
|
| 2497 | + $body .= $this->textLine('--'.$this->boundary[1]); |
|
| 2498 | 2498 | $body .= $this->headerLine('Content-Type', 'multipart/related;'); |
| 2499 | - $body .= $this->textLine("\tboundary=\"" . $this->boundary[2] . '"'); |
|
| 2499 | + $body .= $this->textLine("\tboundary=\"".$this->boundary[2].'"'); |
|
| 2500 | 2500 | $body .= static::$LE; |
| 2501 | 2501 | $body .= $this->getBoundary($this->boundary[2], $bodyCharSet, '', $bodyEncoding); |
| 2502 | 2502 | $body .= $this->encodeString($this->Body, $bodyEncoding); |
@@ -2525,9 +2525,9 @@ discard block |
||
| 2525 | 2525 | $body .= $this->getBoundary($this->boundary[1], $altBodyCharSet, 'text/plain', $altBodyEncoding); |
| 2526 | 2526 | $body .= $this->encodeString($this->AltBody, $altBodyEncoding); |
| 2527 | 2527 | $body .= static::$LE; |
| 2528 | - $body .= $this->textLine('--' . $this->boundary[1]); |
|
| 2528 | + $body .= $this->textLine('--'.$this->boundary[1]); |
|
| 2529 | 2529 | $body .= $this->headerLine('Content-Type', 'multipart/related;'); |
| 2530 | - $body .= $this->textLine("\tboundary=\"" . $this->boundary[2] . '"'); |
|
| 2530 | + $body .= $this->textLine("\tboundary=\"".$this->boundary[2].'"'); |
|
| 2531 | 2531 | $body .= static::$LE; |
| 2532 | 2532 | $body .= $this->getBoundary($this->boundary[2], $bodyCharSet, 'text/html', $bodyEncoding); |
| 2533 | 2533 | $body .= $this->encodeString($this->Body, $bodyEncoding); |
@@ -2538,9 +2538,9 @@ discard block |
||
| 2538 | 2538 | break; |
| 2539 | 2539 | case 'alt_attach': |
| 2540 | 2540 | $body .= $mimepre; |
| 2541 | - $body .= $this->textLine('--' . $this->boundary[1]); |
|
| 2541 | + $body .= $this->textLine('--'.$this->boundary[1]); |
|
| 2542 | 2542 | $body .= $this->headerLine('Content-Type', 'multipart/alternative;'); |
| 2543 | - $body .= $this->textLine("\tboundary=\"" . $this->boundary[2] . '"'); |
|
| 2543 | + $body .= $this->textLine("\tboundary=\"".$this->boundary[2].'"'); |
|
| 2544 | 2544 | $body .= static::$LE; |
| 2545 | 2545 | $body .= $this->getBoundary($this->boundary[2], $altBodyCharSet, 'text/plain', $altBodyEncoding); |
| 2546 | 2546 | $body .= $this->encodeString($this->AltBody, $altBodyEncoding); |
@@ -2558,16 +2558,16 @@ discard block |
||
| 2558 | 2558 | break; |
| 2559 | 2559 | case 'alt_inline_attach': |
| 2560 | 2560 | $body .= $mimepre; |
| 2561 | - $body .= $this->textLine('--' . $this->boundary[1]); |
|
| 2561 | + $body .= $this->textLine('--'.$this->boundary[1]); |
|
| 2562 | 2562 | $body .= $this->headerLine('Content-Type', 'multipart/alternative;'); |
| 2563 | - $body .= $this->textLine("\tboundary=\"" . $this->boundary[2] . '"'); |
|
| 2563 | + $body .= $this->textLine("\tboundary=\"".$this->boundary[2].'"'); |
|
| 2564 | 2564 | $body .= static::$LE; |
| 2565 | 2565 | $body .= $this->getBoundary($this->boundary[2], $altBodyCharSet, 'text/plain', $altBodyEncoding); |
| 2566 | 2566 | $body .= $this->encodeString($this->AltBody, $altBodyEncoding); |
| 2567 | 2567 | $body .= static::$LE; |
| 2568 | - $body .= $this->textLine('--' . $this->boundary[2]); |
|
| 2568 | + $body .= $this->textLine('--'.$this->boundary[2]); |
|
| 2569 | 2569 | $body .= $this->headerLine('Content-Type', 'multipart/related;'); |
| 2570 | - $body .= $this->textLine("\tboundary=\"" . $this->boundary[3] . '"'); |
|
| 2570 | + $body .= $this->textLine("\tboundary=\"".$this->boundary[3].'"'); |
|
| 2571 | 2571 | $body .= static::$LE; |
| 2572 | 2572 | $body .= $this->getBoundary($this->boundary[3], $bodyCharSet, 'text/html', $bodyEncoding); |
| 2573 | 2573 | $body .= $this->encodeString($this->Body, $bodyEncoding); |
@@ -2594,12 +2594,12 @@ discard block |
||
| 2594 | 2594 | } elseif ($this->sign_key_file) { |
| 2595 | 2595 | try { |
| 2596 | 2596 | if (!defined('PKCS7_TEXT')) { |
| 2597 | - throw new Exception($this->lang('extension_missing') . 'openssl'); |
|
| 2597 | + throw new Exception($this->lang('extension_missing').'openssl'); |
|
| 2598 | 2598 | } |
| 2599 | 2599 | // @TODO would be nice to use php://temp streams here |
| 2600 | 2600 | $file = tempnam(sys_get_temp_dir(), 'mail'); |
| 2601 | 2601 | if (false === file_put_contents($file, $body)) { |
| 2602 | - throw new Exception($this->lang('signing') . ' Could not write temp file'); |
|
| 2602 | + throw new Exception($this->lang('signing').' Could not write temp file'); |
|
| 2603 | 2603 | } |
| 2604 | 2604 | $signed = tempnam(sys_get_temp_dir(), 'signed'); |
| 2605 | 2605 | //Workaround for PHP bug https://bugs.php.net/bug.php?id=69197 |
@@ -2607,16 +2607,16 @@ discard block |
||
| 2607 | 2607 | $sign = @openssl_pkcs7_sign( |
| 2608 | 2608 | $file, |
| 2609 | 2609 | $signed, |
| 2610 | - 'file://' . realpath($this->sign_cert_file), |
|
| 2611 | - ['file://' . realpath($this->sign_key_file), $this->sign_key_pass], |
|
| 2610 | + 'file://'.realpath($this->sign_cert_file), |
|
| 2611 | + ['file://'.realpath($this->sign_key_file), $this->sign_key_pass], |
|
| 2612 | 2612 | [] |
| 2613 | 2613 | ); |
| 2614 | 2614 | } else { |
| 2615 | 2615 | $sign = @openssl_pkcs7_sign( |
| 2616 | 2616 | $file, |
| 2617 | 2617 | $signed, |
| 2618 | - 'file://' . realpath($this->sign_cert_file), |
|
| 2619 | - ['file://' . realpath($this->sign_key_file), $this->sign_key_pass], |
|
| 2618 | + 'file://'.realpath($this->sign_cert_file), |
|
| 2619 | + ['file://'.realpath($this->sign_key_file), $this->sign_key_pass], |
|
| 2620 | 2620 | [], |
| 2621 | 2621 | PKCS7_DETACHED, |
| 2622 | 2622 | $this->sign_extracerts_file |
@@ -2628,11 +2628,11 @@ discard block |
||
| 2628 | 2628 | @unlink($signed); |
| 2629 | 2629 | //The message returned by openssl contains both headers and body, so need to split them up |
| 2630 | 2630 | $parts = explode("\n\n", $body, 2); |
| 2631 | - $this->MIMEHeader .= $parts[0] . static::$LE . static::$LE; |
|
| 2631 | + $this->MIMEHeader .= $parts[0].static::$LE.static::$LE; |
|
| 2632 | 2632 | $body = $parts[1]; |
| 2633 | 2633 | } else { |
| 2634 | 2634 | @unlink($signed); |
| 2635 | - throw new Exception($this->lang('signing') . openssl_error_string()); |
|
| 2635 | + throw new Exception($this->lang('signing').openssl_error_string()); |
|
| 2636 | 2636 | } |
| 2637 | 2637 | } catch (Exception $exc) { |
| 2638 | 2638 | $body = ''; |
@@ -2667,7 +2667,7 @@ discard block |
||
| 2667 | 2667 | if ('' == $encoding) { |
| 2668 | 2668 | $encoding = $this->Encoding; |
| 2669 | 2669 | } |
| 2670 | - $result .= $this->textLine('--' . $boundary); |
|
| 2670 | + $result .= $this->textLine('--'.$boundary); |
|
| 2671 | 2671 | $result .= sprintf('Content-Type: %s; charset=%s', $contentType, $charSet); |
| 2672 | 2672 | $result .= static::$LE; |
| 2673 | 2673 | // RFC1341 part 5 says 7bit is assumed if not specified |
@@ -2688,7 +2688,7 @@ discard block |
||
| 2688 | 2688 | */ |
| 2689 | 2689 | protected function endBoundary($boundary) |
| 2690 | 2690 | { |
| 2691 | - return static::$LE . '--' . $boundary . '--' . static::$LE; |
|
| 2691 | + return static::$LE.'--'.$boundary.'--'.static::$LE; |
|
| 2692 | 2692 | } |
| 2693 | 2693 | |
| 2694 | 2694 | /** |
@@ -2724,7 +2724,7 @@ discard block |
||
| 2724 | 2724 | */ |
| 2725 | 2725 | public function headerLine($name, $value) |
| 2726 | 2726 | { |
| 2727 | - return $name . ': ' . $value . static::$LE; |
|
| 2727 | + return $name.': '.$value.static::$LE; |
|
| 2728 | 2728 | } |
| 2729 | 2729 | |
| 2730 | 2730 | /** |
@@ -2736,7 +2736,7 @@ discard block |
||
| 2736 | 2736 | */ |
| 2737 | 2737 | public function textLine($value) |
| 2738 | 2738 | { |
| 2739 | - return $value . static::$LE; |
|
| 2739 | + return $value.static::$LE; |
|
| 2740 | 2740 | } |
| 2741 | 2741 | |
| 2742 | 2742 | /** |
@@ -2758,7 +2758,7 @@ discard block |
||
| 2758 | 2758 | { |
| 2759 | 2759 | try { |
| 2760 | 2760 | if (!@is_file($path)) { |
| 2761 | - throw new Exception($this->lang('file_access') . $path, self::STOP_CONTINUE); |
|
| 2761 | + throw new Exception($this->lang('file_access').$path, self::STOP_CONTINUE); |
|
| 2762 | 2762 | } |
| 2763 | 2763 | |
| 2764 | 2764 | // If a MIME type is not specified, try to work it out from the file name |
@@ -2885,7 +2885,7 @@ discard block |
||
| 2885 | 2885 | 'Content-Disposition: %s; filename="%s"%s', |
| 2886 | 2886 | $disposition, |
| 2887 | 2887 | $encoded_name, |
| 2888 | - static::$LE . static::$LE |
|
| 2888 | + static::$LE.static::$LE |
|
| 2889 | 2889 | ); |
| 2890 | 2890 | } else { |
| 2891 | 2891 | if (!empty($encoded_name)) { |
@@ -2893,13 +2893,13 @@ discard block |
||
| 2893 | 2893 | 'Content-Disposition: %s; filename=%s%s', |
| 2894 | 2894 | $disposition, |
| 2895 | 2895 | $encoded_name, |
| 2896 | - static::$LE . static::$LE |
|
| 2896 | + static::$LE.static::$LE |
|
| 2897 | 2897 | ); |
| 2898 | 2898 | } else { |
| 2899 | 2899 | $mime[] = sprintf( |
| 2900 | 2900 | 'Content-Disposition: %s%s', |
| 2901 | 2901 | $disposition, |
| 2902 | - static::$LE . static::$LE |
|
| 2902 | + static::$LE.static::$LE |
|
| 2903 | 2903 | ); |
| 2904 | 2904 | } |
| 2905 | 2905 | } |
@@ -2940,11 +2940,11 @@ discard block |
||
| 2940 | 2940 | { |
| 2941 | 2941 | try { |
| 2942 | 2942 | if (!file_exists($path)) { |
| 2943 | - throw new Exception($this->lang('file_open') . $path, self::STOP_CONTINUE); |
|
| 2943 | + throw new Exception($this->lang('file_open').$path, self::STOP_CONTINUE); |
|
| 2944 | 2944 | } |
| 2945 | 2945 | $file_buffer = file_get_contents($path); |
| 2946 | 2946 | if (false === $file_buffer) { |
| 2947 | - throw new Exception($this->lang('file_open') . $path, self::STOP_CONTINUE); |
|
| 2947 | + throw new Exception($this->lang('file_open').$path, self::STOP_CONTINUE); |
|
| 2948 | 2948 | } |
| 2949 | 2949 | $file_buffer = $this->encodeString($file_buffer, $encoding); |
| 2950 | 2950 | |
@@ -2991,7 +2991,7 @@ discard block |
||
| 2991 | 2991 | $encoded = $this->encodeQP($str); |
| 2992 | 2992 | break; |
| 2993 | 2993 | default: |
| 2994 | - $this->setError($this->lang('encoding') . $encoding); |
|
| 2994 | + $this->setError($this->lang('encoding').$encoding); |
|
| 2995 | 2995 | break; |
| 2996 | 2996 | } |
| 2997 | 2997 | |
@@ -3057,7 +3057,7 @@ discard block |
||
| 3057 | 3057 | $maxlen -= $maxlen % 4; |
| 3058 | 3058 | $encoded = trim(chunk_split($encoded, $maxlen, "\n")); |
| 3059 | 3059 | } |
| 3060 | - $encoded = preg_replace('/^(.*)$/m', ' =?' . $this->CharSet . "?$encoding?\\1?=", $encoded); |
|
| 3060 | + $encoded = preg_replace('/^(.*)$/m', ' =?'.$this->CharSet."?$encoding?\\1?=", $encoded); |
|
| 3061 | 3061 | } elseif ($matchcount > 0) { |
| 3062 | 3062 | //1 or more chars need encoding, use Q-encode |
| 3063 | 3063 | $encoding = 'Q'; |
@@ -3065,8 +3065,8 @@ discard block |
||
| 3065 | 3065 | $maxlen = static::STD_LINE_LENGTH - $lengthsub - 8 - strlen($this->CharSet); |
| 3066 | 3066 | $encoded = $this->encodeQ($str, $position); |
| 3067 | 3067 | $encoded = $this->wrapText($encoded, $maxlen, true); |
| 3068 | - $encoded = str_replace('=' . static::$LE, "\n", trim($encoded)); |
|
| 3069 | - $encoded = preg_replace('/^(.*)$/m', ' =?' . $this->CharSet . "?$encoding?\\1?=", $encoded); |
|
| 3068 | + $encoded = str_replace('='.static::$LE, "\n", trim($encoded)); |
|
| 3069 | + $encoded = preg_replace('/^(.*)$/m', ' =?'.$this->CharSet."?$encoding?\\1?=", $encoded); |
|
| 3070 | 3070 | } elseif (strlen($str) > $maxlen) { |
| 3071 | 3071 | //No chars need encoding, but line is too long, so fold it |
| 3072 | 3072 | $encoded = trim($this->wrapText($str, $maxlen, false)); |
@@ -3127,7 +3127,7 @@ discard block |
||
| 3127 | 3127 | */ |
| 3128 | 3128 | public function base64EncodeWrapMB($str, $linebreak = null) |
| 3129 | 3129 | { |
| 3130 | - $start = '=?' . $this->CharSet . '?B?'; |
|
| 3130 | + $start = '=?'.$this->CharSet.'?B?'; |
|
| 3131 | 3131 | $end = '?='; |
| 3132 | 3132 | $encoded = ''; |
| 3133 | 3133 | if (null === $linebreak) { |
@@ -3150,7 +3150,7 @@ discard block |
||
| 3150 | 3150 | $chunk = base64_encode($chunk); |
| 3151 | 3151 | ++$lookBack; |
| 3152 | 3152 | } while (strlen($chunk) > $length); |
| 3153 | - $encoded .= $chunk . $linebreak; |
|
| 3153 | + $encoded .= $chunk.$linebreak; |
|
| 3154 | 3154 | } |
| 3155 | 3155 | |
| 3156 | 3156 | // Chomp the last linefeed |
@@ -3203,7 +3203,7 @@ discard block |
||
| 3203 | 3203 | // RFC 2047 section 5.1 |
| 3204 | 3204 | // Replace every high ascii, control, =, ? and _ characters |
| 3205 | 3205 | /** @noinspection SuspiciousAssignmentsInspection */ |
| 3206 | - $pattern = '\000-\011\013\014\016-\037\075\077\137\177-\377' . $pattern; |
|
| 3206 | + $pattern = '\000-\011\013\014\016-\037\075\077\137\177-\377'.$pattern; |
|
| 3207 | 3207 | break; |
| 3208 | 3208 | } |
| 3209 | 3209 | $matches = []; |
@@ -3216,7 +3216,7 @@ discard block |
||
| 3216 | 3216 | array_unshift($matches[0], '='); |
| 3217 | 3217 | } |
| 3218 | 3218 | foreach (array_unique($matches[0]) as $char) { |
| 3219 | - $encoded = str_replace($char, '=' . sprintf('%02X', ord($char)), $encoded); |
|
| 3219 | + $encoded = str_replace($char, '='.sprintf('%02X', ord($char)), $encoded); |
|
| 3220 | 3220 | } |
| 3221 | 3221 | } |
| 3222 | 3222 | // Replace spaces with _ (more readable than =20) |
@@ -3241,7 +3241,7 @@ discard block |
||
| 3241 | 3241 | $encoding = 'base64', |
| 3242 | 3242 | $type = '', |
| 3243 | 3243 | $disposition = 'attachment' |
| 3244 | - ) { |
|
| 3244 | + ){ |
|
| 3245 | 3245 | // If a MIME type is not specified, try to work it out from the file name |
| 3246 | 3246 | if ('' == $type) { |
| 3247 | 3247 | $type = static::filenameToType($filename); |
@@ -3281,7 +3281,7 @@ discard block |
||
| 3281 | 3281 | public function addEmbeddedImage($path, $cid, $name = '', $encoding = 'base64', $type = '', $disposition = 'inline') |
| 3282 | 3282 | { |
| 3283 | 3283 | if (!@is_file($path)) { |
| 3284 | - $this->setError($this->lang('file_access') . $path); |
|
| 3284 | + $this->setError($this->lang('file_access').$path); |
|
| 3285 | 3285 | |
| 3286 | 3286 | return false; |
| 3287 | 3287 | } |
@@ -3335,7 +3335,7 @@ discard block |
||
| 3335 | 3335 | $encoding = 'base64', |
| 3336 | 3336 | $type = '', |
| 3337 | 3337 | $disposition = 'inline' |
| 3338 | - ) { |
|
| 3338 | + ){ |
|
| 3339 | 3339 | // If a MIME type is not specified, try to work it out from the name |
| 3340 | 3340 | if ('' == $type and !empty($name)) { |
| 3341 | 3341 | $type = static::filenameToType($name); |
@@ -3425,7 +3425,7 @@ discard block |
||
| 3425 | 3425 | { |
| 3426 | 3426 | $this->RecipientsQueue = array_filter( |
| 3427 | 3427 | $this->RecipientsQueue, |
| 3428 | - function ($params) use ($kind) { |
|
| 3428 | + function($params) use ($kind) { |
|
| 3429 | 3429 | return $params[0] != $kind; |
| 3430 | 3430 | } |
| 3431 | 3431 | ); |
@@ -3515,15 +3515,15 @@ discard block |
||
| 3515 | 3515 | if ('smtp' == $this->Mailer and null !== $this->smtp) { |
| 3516 | 3516 | $lasterror = $this->smtp->getError(); |
| 3517 | 3517 | if (!empty($lasterror['error'])) { |
| 3518 | - $msg .= $this->lang('smtp_error') . $lasterror['error']; |
|
| 3518 | + $msg .= $this->lang('smtp_error').$lasterror['error']; |
|
| 3519 | 3519 | if (!empty($lasterror['detail'])) { |
| 3520 | - $msg .= ' Detail: ' . $lasterror['detail']; |
|
| 3520 | + $msg .= ' Detail: '.$lasterror['detail']; |
|
| 3521 | 3521 | } |
| 3522 | 3522 | if (!empty($lasterror['smtp_code'])) { |
| 3523 | - $msg .= ' SMTP code: ' . $lasterror['smtp_code']; |
|
| 3523 | + $msg .= ' SMTP code: '.$lasterror['smtp_code']; |
|
| 3524 | 3524 | } |
| 3525 | 3525 | if (!empty($lasterror['smtp_code_ex'])) { |
| 3526 | - $msg .= ' Additional SMTP info: ' . $lasterror['smtp_code_ex']; |
|
| 3526 | + $msg .= ' Additional SMTP info: '.$lasterror['smtp_code_ex']; |
|
| 3527 | 3527 | } |
| 3528 | 3528 | } |
| 3529 | 3529 | } |
@@ -3596,7 +3596,7 @@ discard block |
||
| 3596 | 3596 | //Is it a valid IPv4 address? |
| 3597 | 3597 | return (bool) filter_var($host, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4); |
| 3598 | 3598 | } |
| 3599 | - if (filter_var('http://' . $host, FILTER_VALIDATE_URL, FILTER_FLAG_HOST_REQUIRED)) { |
|
| 3599 | + if (filter_var('http://'.$host, FILTER_VALIDATE_URL, FILTER_FLAG_HOST_REQUIRED)) { |
|
| 3600 | 3600 | //Is it a syntactically valid hostname? |
| 3601 | 3601 | return true; |
| 3602 | 3602 | } |
@@ -3622,7 +3622,7 @@ discard block |
||
| 3622 | 3622 | //Include a link to troubleshooting docs on SMTP connection failure |
| 3623 | 3623 | //this is by far the biggest cause of support questions |
| 3624 | 3624 | //but it's usually not PHPMailer's fault. |
| 3625 | - return $this->language[$key] . ' https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting'; |
|
| 3625 | + return $this->language[$key].' https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting'; |
|
| 3626 | 3626 | } |
| 3627 | 3627 | |
| 3628 | 3628 | return $this->language[$key]; |
@@ -3710,14 +3710,14 @@ discard block |
||
| 3710 | 3710 | } |
| 3711 | 3711 | //Hash the decoded data, not the URL so that the same data-URI image used in multiple places |
| 3712 | 3712 | //will only be embedded once, even if it used a different encoding |
| 3713 | - $cid = hash('sha256', $data) . '@phpmailer.0'; // RFC2392 S 2 |
|
| 3713 | + $cid = hash('sha256', $data).'@phpmailer.0'; // RFC2392 S 2 |
|
| 3714 | 3714 | |
| 3715 | 3715 | if (!$this->cidExists($cid)) { |
| 3716 | - $this->addStringEmbeddedImage($data, $cid, 'embed' . $imgindex, 'base64', $match[1]); |
|
| 3716 | + $this->addStringEmbeddedImage($data, $cid, 'embed'.$imgindex, 'base64', $match[1]); |
|
| 3717 | 3717 | } |
| 3718 | 3718 | $message = str_replace( |
| 3719 | 3719 | $images[0][$imgindex], |
| 3720 | - $images[1][$imgindex] . '="cid:' . $cid . '"', |
|
| 3720 | + $images[1][$imgindex].'="cid:'.$cid.'"', |
|
| 3721 | 3721 | $message |
| 3722 | 3722 | ); |
| 3723 | 3723 | continue; |
@@ -3736,7 +3736,7 @@ discard block |
||
| 3736 | 3736 | if ('.' == $directory) { |
| 3737 | 3737 | $directory = ''; |
| 3738 | 3738 | } |
| 3739 | - $cid = hash('sha256', $url) . '@phpmailer.0'; // RFC2392 S 2 |
|
| 3739 | + $cid = hash('sha256', $url).'@phpmailer.0'; // RFC2392 S 2 |
|
| 3740 | 3740 | if (strlen($basedir) > 1 and '/' != substr($basedir, -1)) { |
| 3741 | 3741 | $basedir .= '/'; |
| 3742 | 3742 | } |
@@ -3744,7 +3744,7 @@ discard block |
||
| 3744 | 3744 | $directory .= '/'; |
| 3745 | 3745 | } |
| 3746 | 3746 | if ($this->addEmbeddedImage( |
| 3747 | - $basedir . $directory . $filename, |
|
| 3747 | + $basedir.$directory.$filename, |
|
| 3748 | 3748 | $cid, |
| 3749 | 3749 | $filename, |
| 3750 | 3750 | 'base64', |
@@ -3752,8 +3752,8 @@ discard block |
||
| 3752 | 3752 | ) |
| 3753 | 3753 | ) { |
| 3754 | 3754 | $message = preg_replace( |
| 3755 | - '/' . $images[1][$imgindex] . '=["\']' . preg_quote($url, '/') . '["\']/Ui', |
|
| 3756 | - $images[1][$imgindex] . '="cid:' . $cid . '"', |
|
| 3755 | + '/'.$images[1][$imgindex].'=["\']'.preg_quote($url, '/').'["\']/Ui', |
|
| 3756 | + $images[1][$imgindex].'="cid:'.$cid.'"', |
|
| 3757 | 3757 | $message |
| 3758 | 3758 | ); |
| 3759 | 3759 | } |
@@ -4027,7 +4027,7 @@ discard block |
||
| 4027 | 4027 | |
| 4028 | 4028 | return true; |
| 4029 | 4029 | } |
| 4030 | - $this->setError($this->lang('variable_set') . $name); |
|
| 4030 | + $this->setError($this->lang('variable_set').$name); |
|
| 4031 | 4031 | |
| 4032 | 4032 | return false; |
| 4033 | 4033 | } |
@@ -4121,7 +4121,7 @@ discard block |
||
| 4121 | 4121 | if (((0x21 <= $ord) and ($ord <= 0x3A)) or $ord == 0x3C or ((0x3E <= $ord) and ($ord <= 0x7E))) { |
| 4122 | 4122 | $line .= $txt[$i]; |
| 4123 | 4123 | } else { |
| 4124 | - $line .= '=' . sprintf('%02X', $ord); |
|
| 4124 | + $line .= '='.sprintf('%02X', $ord); |
|
| 4125 | 4125 | } |
| 4126 | 4126 | } |
| 4127 | 4127 | |
@@ -4141,14 +4141,13 @@ discard block |
||
| 4141 | 4141 | { |
| 4142 | 4142 | if (!defined('PKCS7_TEXT')) { |
| 4143 | 4143 | if ($this->exceptions) { |
| 4144 | - throw new Exception($this->lang('extension_missing') . 'openssl'); |
|
| 4144 | + throw new Exception($this->lang('extension_missing').'openssl'); |
|
| 4145 | 4145 | } |
| 4146 | 4146 | |
| 4147 | 4147 | return ''; |
| 4148 | 4148 | } |
| 4149 | 4149 | $privKeyStr = !empty($this->DKIM_private_string) ? |
| 4150 | - $this->DKIM_private_string : |
|
| 4151 | - file_get_contents($this->DKIM_private); |
|
| 4150 | + $this->DKIM_private_string : file_get_contents($this->DKIM_private); |
|
| 4152 | 4151 | if ('' != $this->DKIM_passphrase) { |
| 4153 | 4152 | $privKey = openssl_pkey_get_private($privKeyStr, $this->DKIM_passphrase); |
| 4154 | 4153 | } else { |
@@ -4200,7 +4199,7 @@ discard block |
||
| 4200 | 4199 | //But then says to delete space before and after the colon. |
| 4201 | 4200 | //Net result is the same as trimming both ends of the value. |
| 4202 | 4201 | //by elimination, the same applies to the field name |
| 4203 | - $lines[$key] = trim($heading, " \t") . ':' . trim($value, " \t"); |
|
| 4202 | + $lines[$key] = trim($heading, " \t").':'.trim($value, " \t"); |
|
| 4204 | 4203 | } |
| 4205 | 4204 | |
| 4206 | 4205 | return implode("\r\n", $lines); |
@@ -4226,7 +4225,7 @@ discard block |
||
| 4226 | 4225 | $body = static::normalizeBreaks($body, "\r\n"); |
| 4227 | 4226 | |
| 4228 | 4227 | //Reduce multiple trailing line breaks to a single one |
| 4229 | - return rtrim($body, "\r\n") . "\r\n"; |
|
| 4228 | + return rtrim($body, "\r\n")."\r\n"; |
|
| 4230 | 4229 | } |
| 4231 | 4230 | |
| 4232 | 4231 | /** |
@@ -4282,33 +4281,33 @@ discard block |
||
| 4282 | 4281 | if ('' == $this->DKIM_identity) { |
| 4283 | 4282 | $ident = ''; |
| 4284 | 4283 | } else { |
| 4285 | - $ident = ' i=' . $this->DKIM_identity . ';'; |
|
| 4286 | - } |
|
| 4287 | - $dkimhdrs = 'DKIM-Signature: v=1; a=' . |
|
| 4288 | - $DKIMsignatureType . '; q=' . |
|
| 4289 | - $DKIMquery . '; l=' . |
|
| 4290 | - $DKIMlen . '; s=' . |
|
| 4291 | - $this->DKIM_selector . |
|
| 4292 | - ";\r\n" . |
|
| 4293 | - "\tt=" . $DKIMtime . '; c=' . $DKIMcanonicalization . ";\r\n" . |
|
| 4294 | - "\th=From:To:Date:Subject;\r\n" . |
|
| 4295 | - "\td=" . $this->DKIM_domain . ';' . $ident . "\r\n" . |
|
| 4296 | - "\tz=$from\r\n" . |
|
| 4297 | - "\t|$to\r\n" . |
|
| 4298 | - "\t|$date\r\n" . |
|
| 4299 | - "\t|$subject;\r\n" . |
|
| 4300 | - "\tbh=" . $DKIMb64 . ";\r\n" . |
|
| 4284 | + $ident = ' i='.$this->DKIM_identity.';'; |
|
| 4285 | + } |
|
| 4286 | + $dkimhdrs = 'DKIM-Signature: v=1; a='. |
|
| 4287 | + $DKIMsignatureType.'; q='. |
|
| 4288 | + $DKIMquery.'; l='. |
|
| 4289 | + $DKIMlen.'; s='. |
|
| 4290 | + $this->DKIM_selector. |
|
| 4291 | + ";\r\n". |
|
| 4292 | + "\tt=".$DKIMtime.'; c='.$DKIMcanonicalization.";\r\n". |
|
| 4293 | + "\th=From:To:Date:Subject;\r\n". |
|
| 4294 | + "\td=".$this->DKIM_domain.';'.$ident."\r\n". |
|
| 4295 | + "\tz=$from\r\n". |
|
| 4296 | + "\t|$to\r\n". |
|
| 4297 | + "\t|$date\r\n". |
|
| 4298 | + "\t|$subject;\r\n". |
|
| 4299 | + "\tbh=".$DKIMb64.";\r\n". |
|
| 4301 | 4300 | "\tb="; |
| 4302 | 4301 | $toSign = $this->DKIM_HeaderC( |
| 4303 | - $from_header . "\r\n" . |
|
| 4304 | - $to_header . "\r\n" . |
|
| 4305 | - $date_header . "\r\n" . |
|
| 4306 | - $subject_header . "\r\n" . |
|
| 4302 | + $from_header."\r\n". |
|
| 4303 | + $to_header."\r\n". |
|
| 4304 | + $date_header."\r\n". |
|
| 4305 | + $subject_header."\r\n". |
|
| 4307 | 4306 | $dkimhdrs |
| 4308 | 4307 | ); |
| 4309 | 4308 | $signed = $this->DKIM_Sign($toSign); |
| 4310 | 4309 | |
| 4311 | - return static::normalizeBreaks($dkimhdrs . $signed) . static::$LE; |
|
| 4310 | + return static::normalizeBreaks($dkimhdrs.$signed).static::$LE; |
|
| 4312 | 4311 | } |
| 4313 | 4312 | |
| 4314 | 4313 | /** |
@@ -4321,7 +4320,7 @@ discard block |
||
| 4321 | 4320 | */ |
| 4322 | 4321 | public static function hasLineLongerThanMax($str) |
| 4323 | 4322 | { |
| 4324 | - return (bool) preg_match('/^(.{' . (self::MAX_LINE_LENGTH + strlen(static::$LE)) . ',})/m', $str); |
|
| 4323 | + return (bool) preg_match('/^(.{'.(self::MAX_LINE_LENGTH + strlen(static::$LE)).',})/m', $str); |
|
| 4325 | 4324 | } |
| 4326 | 4325 | |
| 4327 | 4326 | /** |
@@ -2059,7 +2059,8 @@ discard block |
||
| 2059 | 2059 | */ |
| 2060 | 2060 | public function addrFormat($addr) |
| 2061 | 2061 | { |
| 2062 | - if (empty($addr[1])) { // No name provided |
|
| 2062 | + if (empty($addr[1])) { |
|
| 2063 | +// No name provided |
|
| 2063 | 2064 | return $this->secureHeader($addr[0]); |
| 2064 | 2065 | } |
| 2065 | 2066 | |
@@ -3425,7 +3426,7 @@ discard block |
||
| 3425 | 3426 | { |
| 3426 | 3427 | $this->RecipientsQueue = array_filter( |
| 3427 | 3428 | $this->RecipientsQueue, |
| 3428 | - function ($params) use ($kind) { |
|
| 3429 | + function ($params) use ($kind){ |
|
| 3429 | 3430 | return $params[0] != $kind; |
| 3430 | 3431 | } |
| 3431 | 3432 | ); |
@@ -209,7 +209,7 @@ |
||
| 209 | 209 | * Connect to a POP3 server. |
| 210 | 210 | * |
| 211 | 211 | * @param string $host |
| 212 | - * @param int|bool $port |
|
| 212 | + * @param integer $port |
|
| 213 | 213 | * @param int $tval |
| 214 | 214 | * |
| 215 | 215 | * @return bool |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | $username = '', |
| 150 | 150 | $password = '', |
| 151 | 151 | $debug_level = 0 |
| 152 | - ) { |
|
| 152 | + ){ |
|
| 153 | 153 | $pop = new self(); |
| 154 | 154 | |
| 155 | 155 | return $pop->authorise($host, $port, $timeout, $username, $password, $debug_level); |
@@ -288,11 +288,11 @@ discard block |
||
| 288 | 288 | } |
| 289 | 289 | |
| 290 | 290 | // Send the Username |
| 291 | - $this->sendString("USER $username" . static::LE); |
|
| 291 | + $this->sendString("USER $username".static::LE); |
|
| 292 | 292 | $pop3_response = $this->getResponse(); |
| 293 | 293 | if ($this->checkResponse($pop3_response)) { |
| 294 | 294 | // Send the Password |
| 295 | - $this->sendString("PASS $password" . static::LE); |
|
| 295 | + $this->sendString("PASS $password".static::LE); |
|
| 296 | 296 | $pop3_response = $this->getResponse(); |
| 297 | 297 | if ($this->checkResponse($pop3_response)) { |
| 298 | 298 | return true; |
@@ -412,7 +412,7 @@ discard block |
||
| 412 | 412 | protected function catchWarning($errno, $errstr, $errfile, $errline) |
| 413 | 413 | { |
| 414 | 414 | $this->setError( |
| 415 | - 'Connecting to the POP3 server raised a PHP warning:' . |
|
| 415 | + 'Connecting to the POP3 server raised a PHP warning:'. |
|
| 416 | 416 | "errno: $errno errstr: $errstr; errfile: $errfile; errline: $errline" |
| 417 | 417 | ); |
| 418 | 418 | } |
@@ -344,7 +344,8 @@ |
||
| 344 | 344 | protected function sendString($string) |
| 345 | 345 | { |
| 346 | 346 | if ($this->pop_conn) { |
| 347 | - if ($this->do_debug >= 2) { //Show client messages when debug >= 2 |
|
| 347 | + if ($this->do_debug >= 2) { |
|
| 348 | +//Show client messages when debug >= 2 |
|
| 348 | 349 | echo 'Client -> Server: ', $string; |
| 349 | 350 | } |
| 350 | 351 | |
@@ -288,11 +288,11 @@ |
||
| 288 | 288 | } |
| 289 | 289 | |
| 290 | 290 | // Send the Username |
| 291 | - $this->sendString("USER $username" . static::LE); |
|
| 291 | + $this->sendString("user $username" . static::LE); |
|
| 292 | 292 | $pop3_response = $this->getResponse(); |
| 293 | 293 | if ($this->checkResponse($pop3_response)) { |
| 294 | 294 | // Send the Password |
| 295 | - $this->sendString("PASS $password" . static::LE); |
|
| 295 | + $this->sendString("pass $password" . static::LE); |
|
| 296 | 296 | $pop3_response = $this->getResponse(); |
| 297 | 297 | if ($this->checkResponse($pop3_response)) { |
| 298 | 298 | return true; |
@@ -1314,7 +1314,7 @@ |
||
| 1314 | 1314 | * If no reply has been received yet, it will return null. |
| 1315 | 1315 | * If no pattern was matched, it will return false. |
| 1316 | 1316 | * |
| 1317 | - * @return bool|null|string |
|
| 1317 | + * @return string |
|
| 1318 | 1318 | * |
| 1319 | 1319 | * @see recordLastTransactionID() |
| 1320 | 1320 | */ |
@@ -307,7 +307,7 @@ discard block |
||
| 307 | 307 | } |
| 308 | 308 | // Connect to the SMTP server |
| 309 | 309 | $this->edebug( |
| 310 | - "Connection: opening to $host:$port, timeout=$timeout, options=" . |
|
| 310 | + "Connection: opening to $host:$port, timeout=$timeout, options=". |
|
| 311 | 311 | (count($options) > 0 ? var_export($options, true) : 'array()'), |
| 312 | 312 | self::DEBUG_CONNECTION |
| 313 | 313 | ); |
@@ -317,7 +317,7 @@ discard block |
||
| 317 | 317 | $socket_context = stream_context_create($options); |
| 318 | 318 | set_error_handler([$this, 'errorHandler']); |
| 319 | 319 | $this->smtp_conn = stream_socket_client( |
| 320 | - $host . ':' . $port, |
|
| 320 | + $host.':'.$port, |
|
| 321 | 321 | $errno, |
| 322 | 322 | $errstr, |
| 323 | 323 | $timeout, |
@@ -350,7 +350,7 @@ discard block |
||
| 350 | 350 | (string) $errstr |
| 351 | 351 | ); |
| 352 | 352 | $this->edebug( |
| 353 | - 'SMTP ERROR: ' . $this->error['error'] |
|
| 353 | + 'SMTP ERROR: '.$this->error['error'] |
|
| 354 | 354 | . ": $errstr ($errno)", |
| 355 | 355 | self::DEBUG_CLIENT |
| 356 | 356 | ); |
@@ -370,7 +370,7 @@ discard block |
||
| 370 | 370 | } |
| 371 | 371 | // Get any announcement |
| 372 | 372 | $announce = $this->get_lines(); |
| 373 | - $this->edebug('SERVER -> CLIENT: ' . $announce, self::DEBUG_SERVER); |
|
| 373 | + $this->edebug('SERVER -> CLIENT: '.$announce, self::DEBUG_SERVER); |
|
| 374 | 374 | |
| 375 | 375 | return true; |
| 376 | 376 | } |
@@ -426,7 +426,7 @@ discard block |
||
| 426 | 426 | $password, |
| 427 | 427 | $authtype = null, |
| 428 | 428 | $OAuth = null |
| 429 | - ) { |
|
| 429 | + ){ |
|
| 430 | 430 | if (!$this->server_caps) { |
| 431 | 431 | $this->setError('Authentication is not allowed before HELO/EHLO'); |
| 432 | 432 | |
@@ -443,15 +443,15 @@ discard block |
||
| 443 | 443 | return false; |
| 444 | 444 | } |
| 445 | 445 | |
| 446 | - $this->edebug('Auth method requested: ' . ($authtype ? $authtype : 'UNKNOWN'), self::DEBUG_LOWLEVEL); |
|
| 446 | + $this->edebug('Auth method requested: '.($authtype ? $authtype : 'UNKNOWN'), self::DEBUG_LOWLEVEL); |
|
| 447 | 447 | $this->edebug( |
| 448 | - 'Auth methods available on the server: ' . implode(',', $this->server_caps['AUTH']), |
|
| 448 | + 'Auth methods available on the server: '.implode(',', $this->server_caps['AUTH']), |
|
| 449 | 449 | self::DEBUG_LOWLEVEL |
| 450 | 450 | ); |
| 451 | 451 | |
| 452 | 452 | //If we have requested a specific auth type, check the server supports it before trying others |
| 453 | 453 | if (!in_array($authtype, $this->server_caps['AUTH'])) { |
| 454 | - $this->edebug('Requested auth method not available: ' . $authtype, self::DEBUG_LOWLEVEL); |
|
| 454 | + $this->edebug('Requested auth method not available: '.$authtype, self::DEBUG_LOWLEVEL); |
|
| 455 | 455 | $authtype = null; |
| 456 | 456 | } |
| 457 | 457 | |
@@ -469,7 +469,7 @@ discard block |
||
| 469 | 469 | |
| 470 | 470 | return false; |
| 471 | 471 | } |
| 472 | - self::edebug('Auth method selected: ' . $authtype, self::DEBUG_LOWLEVEL); |
|
| 472 | + self::edebug('Auth method selected: '.$authtype, self::DEBUG_LOWLEVEL); |
|
| 473 | 473 | } |
| 474 | 474 | |
| 475 | 475 | if (!in_array($authtype, $this->server_caps['AUTH'])) { |
@@ -489,7 +489,7 @@ discard block |
||
| 489 | 489 | // Send encoded username and password |
| 490 | 490 | if (!$this->sendCommand( |
| 491 | 491 | 'User & Password', |
| 492 | - base64_encode("\0" . $username . "\0" . $password), |
|
| 492 | + base64_encode("\0".$username."\0".$password), |
|
| 493 | 493 | 235 |
| 494 | 494 | ) |
| 495 | 495 | ) { |
@@ -517,7 +517,7 @@ discard block |
||
| 517 | 517 | $challenge = base64_decode(substr($this->last_reply, 4)); |
| 518 | 518 | |
| 519 | 519 | // Build the response |
| 520 | - $response = $username . ' ' . $this->hmac($challenge, $password); |
|
| 520 | + $response = $username.' '.$this->hmac($challenge, $password); |
|
| 521 | 521 | |
| 522 | 522 | // send encoded credentials |
| 523 | 523 | return $this->sendCommand('Username', base64_encode($response), 235); |
@@ -529,7 +529,7 @@ discard block |
||
| 529 | 529 | $oauth = $OAuth->getOauth64(); |
| 530 | 530 | |
| 531 | 531 | // Start authentication |
| 532 | - if (!$this->sendCommand('AUTH', 'AUTH XOAUTH2 ' . $oauth, 235)) { |
|
| 532 | + if (!$this->sendCommand('AUTH', 'AUTH XOAUTH2 '.$oauth, 235)) { |
|
| 533 | 533 | return false; |
| 534 | 534 | } |
| 535 | 535 | break; |
@@ -576,7 +576,7 @@ discard block |
||
| 576 | 576 | $k_ipad = $key ^ $ipad; |
| 577 | 577 | $k_opad = $key ^ $opad; |
| 578 | 578 | |
| 579 | - return md5($k_opad . pack('H*', md5($k_ipad . $data))); |
|
| 579 | + return md5($k_opad.pack('H*', md5($k_ipad.$data))); |
|
| 580 | 580 | } |
| 581 | 581 | |
| 582 | 582 | /** |
@@ -691,7 +691,7 @@ discard block |
||
| 691 | 691 | } |
| 692 | 692 | //If processing headers add a LWSP-char to the front of new line RFC822 section 3.1.1 |
| 693 | 693 | if ($in_headers) { |
| 694 | - $line = "\t" . $line; |
|
| 694 | + $line = "\t".$line; |
|
| 695 | 695 | } |
| 696 | 696 | } |
| 697 | 697 | $lines_out[] = $line; |
@@ -700,9 +700,9 @@ discard block |
||
| 700 | 700 | foreach ($lines_out as $line_out) { |
| 701 | 701 | //RFC2821 section 4.5.2 |
| 702 | 702 | if (!empty($line_out) and $line_out[0] == '.') { |
| 703 | - $line_out = '.' . $line_out; |
|
| 703 | + $line_out = '.'.$line_out; |
|
| 704 | 704 | } |
| 705 | - $this->client_send($line_out . static::LE, 'DATA'); |
|
| 705 | + $this->client_send($line_out.static::LE, 'DATA'); |
|
| 706 | 706 | } |
| 707 | 707 | } |
| 708 | 708 | |
@@ -748,7 +748,7 @@ discard block |
||
| 748 | 748 | */ |
| 749 | 749 | protected function sendHello($hello, $host) |
| 750 | 750 | { |
| 751 | - $noerror = $this->sendCommand($hello, $hello . ' ' . $host, 250); |
|
| 751 | + $noerror = $this->sendCommand($hello, $hello.' '.$host, 250); |
|
| 752 | 752 | $this->helo_rply = $this->last_reply; |
| 753 | 753 | if ($noerror) { |
| 754 | 754 | $this->parseHelloFields($hello); |
@@ -819,7 +819,7 @@ discard block |
||
| 819 | 819 | |
| 820 | 820 | return $this->sendCommand( |
| 821 | 821 | 'MAIL FROM', |
| 822 | - 'MAIL FROM:<' . $from . '>' . $useVerp, |
|
| 822 | + 'MAIL FROM:<'.$from.'>'.$useVerp, |
|
| 823 | 823 | 250 |
| 824 | 824 | ); |
| 825 | 825 | } |
@@ -859,7 +859,7 @@ discard block |
||
| 859 | 859 | { |
| 860 | 860 | return $this->sendCommand( |
| 861 | 861 | 'RCPT TO', |
| 862 | - 'RCPT TO:<' . $address . '>', |
|
| 862 | + 'RCPT TO:<'.$address.'>', |
|
| 863 | 863 | [250, 251] |
| 864 | 864 | ); |
| 865 | 865 | } |
@@ -898,7 +898,7 @@ discard block |
||
| 898 | 898 | |
| 899 | 899 | return false; |
| 900 | 900 | } |
| 901 | - $this->client_send($commandstring . static::LE, $command); |
|
| 901 | + $this->client_send($commandstring.static::LE, $command); |
|
| 902 | 902 | |
| 903 | 903 | $this->last_reply = $this->get_lines(); |
| 904 | 904 | // Fetch SMTP code and possible error code explanation |
@@ -908,8 +908,8 @@ discard block |
||
| 908 | 908 | $code_ex = (count($matches) > 2 ? $matches[2] : null); |
| 909 | 909 | // Cut off error code from each response line |
| 910 | 910 | $detail = preg_replace( |
| 911 | - "/{$code}[ -]" . |
|
| 912 | - ($code_ex ? str_replace('.', '\\.', $code_ex) . ' ' : '') . '/m', |
|
| 911 | + "/{$code}[ -]". |
|
| 912 | + ($code_ex ? str_replace('.', '\\.', $code_ex).' ' : '').'/m', |
|
| 913 | 913 | '', |
| 914 | 914 | $this->last_reply |
| 915 | 915 | ); |
@@ -920,7 +920,7 @@ discard block |
||
| 920 | 920 | $detail = substr($this->last_reply, 4); |
| 921 | 921 | } |
| 922 | 922 | |
| 923 | - $this->edebug('SERVER -> CLIENT: ' . $this->last_reply, self::DEBUG_SERVER); |
|
| 923 | + $this->edebug('SERVER -> CLIENT: '.$this->last_reply, self::DEBUG_SERVER); |
|
| 924 | 924 | |
| 925 | 925 | if (!in_array($code, (array) $expect)) { |
| 926 | 926 | $this->setError( |
@@ -930,7 +930,7 @@ discard block |
||
| 930 | 930 | $code_ex |
| 931 | 931 | ); |
| 932 | 932 | $this->edebug( |
| 933 | - 'SMTP ERROR: ' . $this->error['error'] . ': ' . $this->last_reply, |
|
| 933 | + 'SMTP ERROR: '.$this->error['error'].': '.$this->last_reply, |
|
| 934 | 934 | self::DEBUG_CLIENT |
| 935 | 935 | ); |
| 936 | 936 | |
@@ -996,7 +996,7 @@ discard block |
||
| 996 | 996 | public function turn() |
| 997 | 997 | { |
| 998 | 998 | $this->setError('The SMTP TURN command is not implemented'); |
| 999 | - $this->edebug('SMTP NOTICE: ' . $this->error['error'], self::DEBUG_CLIENT); |
|
| 999 | + $this->edebug('SMTP NOTICE: '.$this->error['error'], self::DEBUG_CLIENT); |
|
| 1000 | 1000 | |
| 1001 | 1001 | return false; |
| 1002 | 1002 | } |
@@ -1017,7 +1017,7 @@ discard block |
||
| 1017 | 1017 | in_array($command, ['User & Password', 'Username', 'Password'], true)) { |
| 1018 | 1018 | $this->edebug('CLIENT -> SERVER: <credentials hidden>', self::DEBUG_CLIENT); |
| 1019 | 1019 | } else { |
| 1020 | - $this->edebug('CLIENT -> SERVER: ' . $data, self::DEBUG_CLIENT); |
|
| 1020 | + $this->edebug('CLIENT -> SERVER: '.$data, self::DEBUG_CLIENT); |
|
| 1021 | 1021 | } |
| 1022 | 1022 | set_error_handler([$this, 'errorHandler']); |
| 1023 | 1023 | $result = fwrite($this->smtp_conn, $data); |
@@ -1123,14 +1123,14 @@ discard block |
||
| 1123 | 1123 | //Must pass vars in here as params are by reference |
| 1124 | 1124 | if (!stream_select($selR, $selW, $selW, $this->Timelimit)) { |
| 1125 | 1125 | $this->edebug( |
| 1126 | - 'SMTP -> get_lines(): timed-out (' . $this->Timeout . ' sec)', |
|
| 1126 | + 'SMTP -> get_lines(): timed-out ('.$this->Timeout.' sec)', |
|
| 1127 | 1127 | self::DEBUG_LOWLEVEL |
| 1128 | 1128 | ); |
| 1129 | 1129 | break; |
| 1130 | 1130 | } |
| 1131 | 1131 | //Deliberate noise suppression - errors are handled afterwards |
| 1132 | 1132 | $str = @fgets($this->smtp_conn, 515); |
| 1133 | - $this->edebug('SMTP INBOUND: "' . trim($str) . '"', self::DEBUG_LOWLEVEL); |
|
| 1133 | + $this->edebug('SMTP INBOUND: "'.trim($str).'"', self::DEBUG_LOWLEVEL); |
|
| 1134 | 1134 | $data .= $str; |
| 1135 | 1135 | // If response is only 3 chars (not valid, but RFC5321 S4.2 says it must be handled), |
| 1136 | 1136 | // or 4th character is a space, we are done reading, break the loop, |
@@ -1142,7 +1142,7 @@ discard block |
||
| 1142 | 1142 | $info = stream_get_meta_data($this->smtp_conn); |
| 1143 | 1143 | if ($info['timed_out']) { |
| 1144 | 1144 | $this->edebug( |
| 1145 | - 'SMTP -> get_lines(): timed-out (' . $this->Timeout . ' sec)', |
|
| 1145 | + 'SMTP -> get_lines(): timed-out ('.$this->Timeout.' sec)', |
|
| 1146 | 1146 | self::DEBUG_LOWLEVEL |
| 1147 | 1147 | ); |
| 1148 | 1148 | break; |
@@ -1150,8 +1150,8 @@ discard block |
||
| 1150 | 1150 | // Now check if reads took too long |
| 1151 | 1151 | if ($endtime and time() > $endtime) { |
| 1152 | 1152 | $this->edebug( |
| 1153 | - 'SMTP -> get_lines(): timelimit reached (' . |
|
| 1154 | - $this->Timelimit . ' sec)', |
|
| 1153 | + 'SMTP -> get_lines(): timelimit reached ('. |
|
| 1154 | + $this->Timelimit.' sec)', |
|
| 1155 | 1155 | self::DEBUG_LOWLEVEL |
| 1156 | 1156 | ); |
| 1157 | 1157 | break; |
@@ -888,7 +888,7 @@ discard block |
||
| 888 | 888 | protected function sendCommand($command, $commandstring, $expect) |
| 889 | 889 | { |
| 890 | 890 | if (!$this->connected()) { |
| 891 | - $this->setError("Called $command without being connected"); |
|
| 891 | + $this->setError("called $command without being connected"); |
|
| 892 | 892 | |
| 893 | 893 | return false; |
| 894 | 894 | } |
@@ -970,7 +970,7 @@ discard block |
||
| 970 | 970 | */ |
| 971 | 971 | public function verify($name) |
| 972 | 972 | { |
| 973 | - return $this->sendCommand('VRFY', "VRFY $name", [250, 251]); |
|
| 973 | + return $this->sendCommand('VRFY', "vrfy $name", [250, 251]); |
|
| 974 | 974 | } |
| 975 | 975 | |
| 976 | 976 | /** |
@@ -192,6 +192,9 @@ |
||
| 192 | 192 | return $_; |
| 193 | 193 | } |
| 194 | 194 | |
| 195 | + /** |
|
| 196 | + * @param string $checksum |
|
| 197 | + */ |
|
| 195 | 198 | function setSystemChecksum($checksum) { |
| 196 | 199 | global $modx; |
| 197 | 200 | $tbl_system_settings = $modx->getFullTableName('system_settings'); |
@@ -10,215 +10,215 @@ |
||
| 10 | 10 | // Content manager wrapper class |
| 11 | 11 | class ManagerAPI { |
| 12 | 12 | |
| 13 | - var $action; // action directive |
|
| 13 | + var $action; // action directive |
|
| 14 | 14 | |
| 15 | - function __construct(){ |
|
| 16 | - global $action; |
|
| 17 | - $this->action = $action; // set action directive |
|
| 18 | - } |
|
| 15 | + function __construct(){ |
|
| 16 | + global $action; |
|
| 17 | + $this->action = $action; // set action directive |
|
| 18 | + } |
|
| 19 | 19 | |
| 20 | - function initPageViewState($id=0){ |
|
| 21 | - global $_PAGE; |
|
| 22 | - $vsid = isset($_SESSION["mgrPageViewSID"]) ? $_SESSION["mgrPageViewSID"] : ''; |
|
| 23 | - if($vsid!=$this->action) { |
|
| 24 | - $_SESSION["mgrPageViewSDATA"] = array(); // new view state |
|
| 25 | - $_SESSION["mgrPageViewSID"] = $id>0 ? $id:$this->action; // set id |
|
| 26 | - } |
|
| 27 | - $_PAGE['vs'] = &$_SESSION["mgrPageViewSDATA"]; // restore viewstate |
|
| 28 | - } |
|
| 20 | + function initPageViewState($id=0){ |
|
| 21 | + global $_PAGE; |
|
| 22 | + $vsid = isset($_SESSION["mgrPageViewSID"]) ? $_SESSION["mgrPageViewSID"] : ''; |
|
| 23 | + if($vsid!=$this->action) { |
|
| 24 | + $_SESSION["mgrPageViewSDATA"] = array(); // new view state |
|
| 25 | + $_SESSION["mgrPageViewSID"] = $id>0 ? $id:$this->action; // set id |
|
| 26 | + } |
|
| 27 | + $_PAGE['vs'] = &$_SESSION["mgrPageViewSDATA"]; // restore viewstate |
|
| 28 | + } |
|
| 29 | 29 | |
| 30 | - // save page view state - not really necessary, |
|
| 31 | - function savePageViewState($id=0){ |
|
| 32 | - global $_PAGE; |
|
| 33 | - $_SESSION["mgrPageViewSDATA"] = $_PAGE['vs']; |
|
| 34 | - $_SESSION["mgrPageViewSID"] = $id>0 ? $id:$this->action; |
|
| 35 | - } |
|
| 30 | + // save page view state - not really necessary, |
|
| 31 | + function savePageViewState($id=0){ |
|
| 32 | + global $_PAGE; |
|
| 33 | + $_SESSION["mgrPageViewSDATA"] = $_PAGE['vs']; |
|
| 34 | + $_SESSION["mgrPageViewSID"] = $id>0 ? $id:$this->action; |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | - // check for saved form |
|
| 38 | - function hasFormValues() { |
|
| 39 | - if(isset($_SESSION["mgrFormValueId"])) { |
|
| 40 | - if($this->action==$_SESSION["mgrFormValueId"]) { |
|
| 41 | - return true; |
|
| 42 | - } |
|
| 43 | - else { |
|
| 44 | - $this->clearSavedFormValues(); |
|
| 45 | - } |
|
| 46 | - } |
|
| 47 | - return false; |
|
| 48 | - } |
|
| 49 | - // saved form post from $_POST |
|
| 50 | - function saveFormValues($id=0){ |
|
| 51 | - $_SESSION["mgrFormValues"] = $_POST; |
|
| 52 | - $_SESSION["mgrFormValueId"] = $id>0 ? $id:$this->action; |
|
| 53 | - } |
|
| 54 | - // load saved form values into $_POST |
|
| 55 | - function loadFormValues(){ |
|
| 37 | + // check for saved form |
|
| 38 | + function hasFormValues() { |
|
| 39 | + if(isset($_SESSION["mgrFormValueId"])) { |
|
| 40 | + if($this->action==$_SESSION["mgrFormValueId"]) { |
|
| 41 | + return true; |
|
| 42 | + } |
|
| 43 | + else { |
|
| 44 | + $this->clearSavedFormValues(); |
|
| 45 | + } |
|
| 46 | + } |
|
| 47 | + return false; |
|
| 48 | + } |
|
| 49 | + // saved form post from $_POST |
|
| 50 | + function saveFormValues($id=0){ |
|
| 51 | + $_SESSION["mgrFormValues"] = $_POST; |
|
| 52 | + $_SESSION["mgrFormValueId"] = $id>0 ? $id:$this->action; |
|
| 53 | + } |
|
| 54 | + // load saved form values into $_POST |
|
| 55 | + function loadFormValues(){ |
|
| 56 | 56 | |
| 57 | - if(!$this->hasFormValues()) return false; |
|
| 57 | + if(!$this->hasFormValues()) return false; |
|
| 58 | 58 | |
| 59 | - $p = $_SESSION["mgrFormValues"]; |
|
| 60 | - $this->clearSavedFormValues(); |
|
| 61 | - foreach($p as $k=>$v) { |
|
| 62 | - $_POST[$k]=$v; |
|
| 63 | - } |
|
| 64 | - return true; |
|
| 65 | - } |
|
| 66 | - // clear form post |
|
| 67 | - function clearSavedFormValues(){ |
|
| 68 | - unset($_SESSION["mgrFormValues"]); |
|
| 69 | - unset($_SESSION["mgrFormValueId"]); |
|
| 70 | - } |
|
| 59 | + $p = $_SESSION["mgrFormValues"]; |
|
| 60 | + $this->clearSavedFormValues(); |
|
| 61 | + foreach($p as $k=>$v) { |
|
| 62 | + $_POST[$k]=$v; |
|
| 63 | + } |
|
| 64 | + return true; |
|
| 65 | + } |
|
| 66 | + // clear form post |
|
| 67 | + function clearSavedFormValues(){ |
|
| 68 | + unset($_SESSION["mgrFormValues"]); |
|
| 69 | + unset($_SESSION["mgrFormValueId"]); |
|
| 70 | + } |
|
| 71 | 71 | |
| 72 | - function getHashType($db_value='') { // md5 | v1 | phpass |
|
| 73 | - $c = substr($db_value,0,1); |
|
| 74 | - if($c==='$') return 'phpass'; |
|
| 75 | - elseif(strlen($db_value)===32) return 'md5'; |
|
| 76 | - elseif($c!=='$' && strpos($db_value,'>')!==false) return 'v1'; |
|
| 77 | - else return 'unknown'; |
|
| 78 | - } |
|
| 72 | + function getHashType($db_value='') { // md5 | v1 | phpass |
|
| 73 | + $c = substr($db_value,0,1); |
|
| 74 | + if($c==='$') return 'phpass'; |
|
| 75 | + elseif(strlen($db_value)===32) return 'md5'; |
|
| 76 | + elseif($c!=='$' && strpos($db_value,'>')!==false) return 'v1'; |
|
| 77 | + else return 'unknown'; |
|
| 78 | + } |
|
| 79 | 79 | |
| 80 | - function genV1Hash($password, $seed='1') |
|
| 81 | - { // $seed is user_id basically |
|
| 82 | - global $modx; |
|
| 80 | + function genV1Hash($password, $seed='1') |
|
| 81 | + { // $seed is user_id basically |
|
| 82 | + global $modx; |
|
| 83 | 83 | |
| 84 | - if(isset($modx->config['pwd_hash_algo']) && !empty($modx->config['pwd_hash_algo'])) |
|
| 85 | - $algorithm = $modx->config['pwd_hash_algo']; |
|
| 86 | - else $algorithm = 'UNCRYPT'; |
|
| 84 | + if(isset($modx->config['pwd_hash_algo']) && !empty($modx->config['pwd_hash_algo'])) |
|
| 85 | + $algorithm = $modx->config['pwd_hash_algo']; |
|
| 86 | + else $algorithm = 'UNCRYPT'; |
|
| 87 | 87 | |
| 88 | - $salt = md5($password . $seed); |
|
| 88 | + $salt = md5($password . $seed); |
|
| 89 | 89 | |
| 90 | - switch($algorithm) |
|
| 91 | - { |
|
| 92 | - case 'BLOWFISH_Y': |
|
| 93 | - $salt = '$2y$07$' . substr($salt,0,22); |
|
| 94 | - break; |
|
| 95 | - case 'BLOWFISH_A': |
|
| 96 | - $salt = '$2a$07$' . substr($salt,0,22); |
|
| 97 | - break; |
|
| 98 | - case 'SHA512': |
|
| 99 | - $salt = '$6$' . substr($salt,0,16); |
|
| 100 | - break; |
|
| 101 | - case 'SHA256': |
|
| 102 | - $salt = '$5$' . substr($salt,0,16); |
|
| 103 | - break; |
|
| 104 | - case 'MD5': |
|
| 105 | - $salt = '$1$' . substr($salt,0,8); |
|
| 106 | - break; |
|
| 107 | - } |
|
| 90 | + switch($algorithm) |
|
| 91 | + { |
|
| 92 | + case 'BLOWFISH_Y': |
|
| 93 | + $salt = '$2y$07$' . substr($salt,0,22); |
|
| 94 | + break; |
|
| 95 | + case 'BLOWFISH_A': |
|
| 96 | + $salt = '$2a$07$' . substr($salt,0,22); |
|
| 97 | + break; |
|
| 98 | + case 'SHA512': |
|
| 99 | + $salt = '$6$' . substr($salt,0,16); |
|
| 100 | + break; |
|
| 101 | + case 'SHA256': |
|
| 102 | + $salt = '$5$' . substr($salt,0,16); |
|
| 103 | + break; |
|
| 104 | + case 'MD5': |
|
| 105 | + $salt = '$1$' . substr($salt,0,8); |
|
| 106 | + break; |
|
| 107 | + } |
|
| 108 | 108 | |
| 109 | - if($algorithm!=='UNCRYPT') |
|
| 110 | - { |
|
| 111 | - $password = sha1($password) . crypt($password,$salt); |
|
| 112 | - } |
|
| 113 | - else $password = sha1($salt.$password); |
|
| 109 | + if($algorithm!=='UNCRYPT') |
|
| 110 | + { |
|
| 111 | + $password = sha1($password) . crypt($password,$salt); |
|
| 112 | + } |
|
| 113 | + else $password = sha1($salt.$password); |
|
| 114 | 114 | |
| 115 | - $result = strtolower($algorithm) . '>' . md5($salt.$password) . substr(md5($salt),0,8); |
|
| 115 | + $result = strtolower($algorithm) . '>' . md5($salt.$password) . substr(md5($salt),0,8); |
|
| 116 | 116 | |
| 117 | - return $result; |
|
| 118 | - } |
|
| 117 | + return $result; |
|
| 118 | + } |
|
| 119 | 119 | |
| 120 | - function getV1UserHashAlgorithm($uid) |
|
| 121 | - { |
|
| 122 | - global $modx; |
|
| 123 | - $tbl_manager_users = $modx->getFullTableName('manager_users'); |
|
| 124 | - $rs = $modx->db->select('password',$tbl_manager_users,"id='{$uid}'"); |
|
| 125 | - $password = $modx->db->getValue($rs); |
|
| 120 | + function getV1UserHashAlgorithm($uid) |
|
| 121 | + { |
|
| 122 | + global $modx; |
|
| 123 | + $tbl_manager_users = $modx->getFullTableName('manager_users'); |
|
| 124 | + $rs = $modx->db->select('password',$tbl_manager_users,"id='{$uid}'"); |
|
| 125 | + $password = $modx->db->getValue($rs); |
|
| 126 | 126 | |
| 127 | - if(strpos($password,'>')===false) $algo = 'NOSALT'; |
|
| 128 | - else |
|
| 129 | - { |
|
| 130 | - $algo = substr($password,0,strpos($password,'>')); |
|
| 131 | - } |
|
| 132 | - return strtoupper($algo); |
|
| 133 | - } |
|
| 127 | + if(strpos($password,'>')===false) $algo = 'NOSALT'; |
|
| 128 | + else |
|
| 129 | + { |
|
| 130 | + $algo = substr($password,0,strpos($password,'>')); |
|
| 131 | + } |
|
| 132 | + return strtoupper($algo); |
|
| 133 | + } |
|
| 134 | 134 | |
| 135 | - function checkHashAlgorithm($algorithm='') |
|
| 136 | - { |
|
| 137 | - $result = false; |
|
| 138 | - if (!empty($algorithm)) |
|
| 139 | - { |
|
| 140 | - switch ($algorithm) |
|
| 141 | - { |
|
| 142 | - case 'BLOWFISH_Y': |
|
| 143 | - if (defined('CRYPT_BLOWFISH') && CRYPT_BLOWFISH == 1) |
|
| 144 | - { |
|
| 145 | - if (version_compare('5.3.7', PHP_VERSION) <= 0) $result = true; |
|
| 146 | - } |
|
| 147 | - break; |
|
| 148 | - case 'BLOWFISH_A': |
|
| 149 | - if (defined('CRYPT_BLOWFISH') && CRYPT_BLOWFISH == 1) $result = true; |
|
| 150 | - break; |
|
| 151 | - case 'SHA512': |
|
| 152 | - if (defined('CRYPT_SHA512') && CRYPT_SHA512 == 1) $result = true; |
|
| 153 | - break; |
|
| 154 | - case 'SHA256': |
|
| 155 | - if (defined('CRYPT_SHA256') && CRYPT_SHA256 == 1) $result = true; |
|
| 156 | - break; |
|
| 157 | - case 'MD5': |
|
| 158 | - if (defined('CRYPT_MD5') && CRYPT_MD5 == 1 && PHP_VERSION != '5.3.7') $result = true; |
|
| 159 | - break; |
|
| 160 | - case 'UNCRYPT': |
|
| 161 | - $result = true; |
|
| 162 | - break; |
|
| 163 | - } |
|
| 164 | - } |
|
| 165 | - return $result; |
|
| 166 | - } |
|
| 135 | + function checkHashAlgorithm($algorithm='') |
|
| 136 | + { |
|
| 137 | + $result = false; |
|
| 138 | + if (!empty($algorithm)) |
|
| 139 | + { |
|
| 140 | + switch ($algorithm) |
|
| 141 | + { |
|
| 142 | + case 'BLOWFISH_Y': |
|
| 143 | + if (defined('CRYPT_BLOWFISH') && CRYPT_BLOWFISH == 1) |
|
| 144 | + { |
|
| 145 | + if (version_compare('5.3.7', PHP_VERSION) <= 0) $result = true; |
|
| 146 | + } |
|
| 147 | + break; |
|
| 148 | + case 'BLOWFISH_A': |
|
| 149 | + if (defined('CRYPT_BLOWFISH') && CRYPT_BLOWFISH == 1) $result = true; |
|
| 150 | + break; |
|
| 151 | + case 'SHA512': |
|
| 152 | + if (defined('CRYPT_SHA512') && CRYPT_SHA512 == 1) $result = true; |
|
| 153 | + break; |
|
| 154 | + case 'SHA256': |
|
| 155 | + if (defined('CRYPT_SHA256') && CRYPT_SHA256 == 1) $result = true; |
|
| 156 | + break; |
|
| 157 | + case 'MD5': |
|
| 158 | + if (defined('CRYPT_MD5') && CRYPT_MD5 == 1 && PHP_VERSION != '5.3.7') $result = true; |
|
| 159 | + break; |
|
| 160 | + case 'UNCRYPT': |
|
| 161 | + $result = true; |
|
| 162 | + break; |
|
| 163 | + } |
|
| 164 | + } |
|
| 165 | + return $result; |
|
| 166 | + } |
|
| 167 | 167 | |
| 168 | - function getSystemChecksum($check_files) { |
|
| 169 | - $_ = array(); |
|
| 170 | - $check_files = trim($check_files); |
|
| 171 | - $check_files = explode("\n", $check_files); |
|
| 172 | - foreach($check_files as $file) { |
|
| 173 | - $file = trim($file); |
|
| 174 | - $file = MODX_BASE_PATH . $file; |
|
| 175 | - if(!is_file($file)) continue; |
|
| 176 | - $_[$file]= md5_file($file); |
|
| 177 | - } |
|
| 178 | - return serialize($_); |
|
| 179 | - } |
|
| 168 | + function getSystemChecksum($check_files) { |
|
| 169 | + $_ = array(); |
|
| 170 | + $check_files = trim($check_files); |
|
| 171 | + $check_files = explode("\n", $check_files); |
|
| 172 | + foreach($check_files as $file) { |
|
| 173 | + $file = trim($file); |
|
| 174 | + $file = MODX_BASE_PATH . $file; |
|
| 175 | + if(!is_file($file)) continue; |
|
| 176 | + $_[$file]= md5_file($file); |
|
| 177 | + } |
|
| 178 | + return serialize($_); |
|
| 179 | + } |
|
| 180 | 180 | |
| 181 | - function getModifiedSystemFilesList($check_files, $checksum) { |
|
| 182 | - $_ = array(); |
|
| 183 | - $check_files = trim($check_files); |
|
| 184 | - $check_files = explode("\n", $check_files); |
|
| 185 | - $checksum = unserialize($checksum); |
|
| 186 | - foreach($check_files as $file) { |
|
| 187 | - $file = trim($file); |
|
| 188 | - $filePath = MODX_BASE_PATH . $file; |
|
| 189 | - if(!is_file($filePath)) continue; |
|
| 190 | - if(md5_file($filePath) != $checksum[$filePath]) $_[] = $file; |
|
| 191 | - } |
|
| 192 | - return $_; |
|
| 193 | - } |
|
| 181 | + function getModifiedSystemFilesList($check_files, $checksum) { |
|
| 182 | + $_ = array(); |
|
| 183 | + $check_files = trim($check_files); |
|
| 184 | + $check_files = explode("\n", $check_files); |
|
| 185 | + $checksum = unserialize($checksum); |
|
| 186 | + foreach($check_files as $file) { |
|
| 187 | + $file = trim($file); |
|
| 188 | + $filePath = MODX_BASE_PATH . $file; |
|
| 189 | + if(!is_file($filePath)) continue; |
|
| 190 | + if(md5_file($filePath) != $checksum[$filePath]) $_[] = $file; |
|
| 191 | + } |
|
| 192 | + return $_; |
|
| 193 | + } |
|
| 194 | 194 | |
| 195 | - function setSystemChecksum($checksum) { |
|
| 196 | - global $modx; |
|
| 197 | - $tbl_system_settings = $modx->getFullTableName('system_settings'); |
|
| 198 | - $sql = "REPLACE INTO {$tbl_system_settings} (setting_name, setting_value) VALUES ('sys_files_checksum','" . $modx->db->escape($checksum) . "')"; |
|
| 195 | + function setSystemChecksum($checksum) { |
|
| 196 | + global $modx; |
|
| 197 | + $tbl_system_settings = $modx->getFullTableName('system_settings'); |
|
| 198 | + $sql = "REPLACE INTO {$tbl_system_settings} (setting_name, setting_value) VALUES ('sys_files_checksum','" . $modx->db->escape($checksum) . "')"; |
|
| 199 | 199 | $modx->db->query($sql); |
| 200 | - } |
|
| 200 | + } |
|
| 201 | 201 | |
| 202 | - function checkSystemChecksum() { |
|
| 203 | - global $modx; |
|
| 202 | + function checkSystemChecksum() { |
|
| 203 | + global $modx; |
|
| 204 | 204 | |
| 205 | - if(!isset($modx->config['check_files_onlogin']) || empty($modx->config['check_files_onlogin'])) return '0'; |
|
| 205 | + if(!isset($modx->config['check_files_onlogin']) || empty($modx->config['check_files_onlogin'])) return '0'; |
|
| 206 | 206 | |
| 207 | - $current = $this->getSystemChecksum($modx->config['check_files_onlogin']); |
|
| 208 | - if(empty($current)) return '0'; |
|
| 207 | + $current = $this->getSystemChecksum($modx->config['check_files_onlogin']); |
|
| 208 | + if(empty($current)) return '0'; |
|
| 209 | 209 | |
| 210 | - if(!isset($modx->config['sys_files_checksum']) || empty($modx->config['sys_files_checksum'])) |
|
| 211 | - { |
|
| 212 | - $this->setSystemChecksum($current); |
|
| 213 | - return '0'; |
|
| 214 | - } |
|
| 215 | - if($current===$modx->config['sys_files_checksum']) $result = '0'; |
|
| 216 | - else { |
|
| 217 | - $result = $this->getModifiedSystemFilesList($modx->config['check_files_onlogin'], $modx->config['sys_files_checksum']); |
|
| 218 | - } |
|
| 210 | + if(!isset($modx->config['sys_files_checksum']) || empty($modx->config['sys_files_checksum'])) |
|
| 211 | + { |
|
| 212 | + $this->setSystemChecksum($current); |
|
| 213 | + return '0'; |
|
| 214 | + } |
|
| 215 | + if($current===$modx->config['sys_files_checksum']) $result = '0'; |
|
| 216 | + else { |
|
| 217 | + $result = $this->getModifiedSystemFilesList($modx->config['check_files_onlogin'], $modx->config['sys_files_checksum']); |
|
| 218 | + } |
|
| 219 | 219 | |
| 220 | - return $result; |
|
| 221 | - } |
|
| 220 | + return $result; |
|
| 221 | + } |
|
| 222 | 222 | |
| 223 | 223 | function getLastUserSetting($key=false) { |
| 224 | 224 | global $modx; |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | global $_PAGE; // page view state object. Usage $_PAGE['vs']['propertyname'] = $value; |
| 9 | 9 | |
| 10 | 10 | // Content manager wrapper class |
| 11 | -class ManagerAPI { |
|
| 11 | +class ManagerAPI{ |
|
| 12 | 12 | |
| 13 | 13 | var $action; // action directive |
| 14 | 14 | |
@@ -17,27 +17,27 @@ discard block |
||
| 17 | 17 | $this->action = $action; // set action directive |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | - function initPageViewState($id=0){ |
|
| 20 | + function initPageViewState($id = 0){ |
|
| 21 | 21 | global $_PAGE; |
| 22 | 22 | $vsid = isset($_SESSION["mgrPageViewSID"]) ? $_SESSION["mgrPageViewSID"] : ''; |
| 23 | - if($vsid!=$this->action) { |
|
| 23 | + if ($vsid != $this->action) { |
|
| 24 | 24 | $_SESSION["mgrPageViewSDATA"] = array(); // new view state |
| 25 | - $_SESSION["mgrPageViewSID"] = $id>0 ? $id:$this->action; // set id |
|
| 25 | + $_SESSION["mgrPageViewSID"] = $id > 0 ? $id : $this->action; // set id |
|
| 26 | 26 | } |
| 27 | 27 | $_PAGE['vs'] = &$_SESSION["mgrPageViewSDATA"]; // restore viewstate |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | // save page view state - not really necessary, |
| 31 | - function savePageViewState($id=0){ |
|
| 31 | + function savePageViewState($id = 0){ |
|
| 32 | 32 | global $_PAGE; |
| 33 | 33 | $_SESSION["mgrPageViewSDATA"] = $_PAGE['vs']; |
| 34 | - $_SESSION["mgrPageViewSID"] = $id>0 ? $id:$this->action; |
|
| 34 | + $_SESSION["mgrPageViewSID"] = $id > 0 ? $id : $this->action; |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | // check for saved form |
| 38 | - function hasFormValues() { |
|
| 39 | - if(isset($_SESSION["mgrFormValueId"])) { |
|
| 40 | - if($this->action==$_SESSION["mgrFormValueId"]) { |
|
| 38 | + function hasFormValues(){ |
|
| 39 | + if (isset($_SESSION["mgrFormValueId"])) { |
|
| 40 | + if ($this->action == $_SESSION["mgrFormValueId"]) { |
|
| 41 | 41 | return true; |
| 42 | 42 | } |
| 43 | 43 | else { |
@@ -47,19 +47,19 @@ discard block |
||
| 47 | 47 | return false; |
| 48 | 48 | } |
| 49 | 49 | // saved form post from $_POST |
| 50 | - function saveFormValues($id=0){ |
|
| 50 | + function saveFormValues($id = 0){ |
|
| 51 | 51 | $_SESSION["mgrFormValues"] = $_POST; |
| 52 | - $_SESSION["mgrFormValueId"] = $id>0 ? $id:$this->action; |
|
| 52 | + $_SESSION["mgrFormValueId"] = $id > 0 ? $id : $this->action; |
|
| 53 | 53 | } |
| 54 | 54 | // load saved form values into $_POST |
| 55 | 55 | function loadFormValues(){ |
| 56 | 56 | |
| 57 | - if(!$this->hasFormValues()) return false; |
|
| 57 | + if (!$this->hasFormValues()) return false; |
|
| 58 | 58 | |
| 59 | 59 | $p = $_SESSION["mgrFormValues"]; |
| 60 | 60 | $this->clearSavedFormValues(); |
| 61 | - foreach($p as $k=>$v) { |
|
| 62 | - $_POST[$k]=$v; |
|
| 61 | + foreach ($p as $k=>$v) { |
|
| 62 | + $_POST[$k] = $v; |
|
| 63 | 63 | } |
| 64 | 64 | return true; |
| 65 | 65 | } |
@@ -69,50 +69,50 @@ discard block |
||
| 69 | 69 | unset($_SESSION["mgrFormValueId"]); |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - function getHashType($db_value='') { // md5 | v1 | phpass |
|
| 73 | - $c = substr($db_value,0,1); |
|
| 74 | - if($c==='$') return 'phpass'; |
|
| 75 | - elseif(strlen($db_value)===32) return 'md5'; |
|
| 76 | - elseif($c!=='$' && strpos($db_value,'>')!==false) return 'v1'; |
|
| 72 | + function getHashType($db_value = ''){ // md5 | v1 | phpass |
|
| 73 | + $c = substr($db_value, 0, 1); |
|
| 74 | + if ($c === '$') return 'phpass'; |
|
| 75 | + elseif (strlen($db_value) === 32) return 'md5'; |
|
| 76 | + elseif ($c !== '$' && strpos($db_value, '>') !== false) return 'v1'; |
|
| 77 | 77 | else return 'unknown'; |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | - function genV1Hash($password, $seed='1') |
|
| 80 | + function genV1Hash($password, $seed = '1') |
|
| 81 | 81 | { // $seed is user_id basically |
| 82 | 82 | global $modx; |
| 83 | 83 | |
| 84 | - if(isset($modx->config['pwd_hash_algo']) && !empty($modx->config['pwd_hash_algo'])) |
|
| 84 | + if (isset($modx->config['pwd_hash_algo']) && !empty($modx->config['pwd_hash_algo'])) |
|
| 85 | 85 | $algorithm = $modx->config['pwd_hash_algo']; |
| 86 | 86 | else $algorithm = 'UNCRYPT'; |
| 87 | 87 | |
| 88 | - $salt = md5($password . $seed); |
|
| 88 | + $salt = md5($password.$seed); |
|
| 89 | 89 | |
| 90 | - switch($algorithm) |
|
| 90 | + switch ($algorithm) |
|
| 91 | 91 | { |
| 92 | 92 | case 'BLOWFISH_Y': |
| 93 | - $salt = '$2y$07$' . substr($salt,0,22); |
|
| 93 | + $salt = '$2y$07$'.substr($salt, 0, 22); |
|
| 94 | 94 | break; |
| 95 | 95 | case 'BLOWFISH_A': |
| 96 | - $salt = '$2a$07$' . substr($salt,0,22); |
|
| 96 | + $salt = '$2a$07$'.substr($salt, 0, 22); |
|
| 97 | 97 | break; |
| 98 | 98 | case 'SHA512': |
| 99 | - $salt = '$6$' . substr($salt,0,16); |
|
| 99 | + $salt = '$6$'.substr($salt, 0, 16); |
|
| 100 | 100 | break; |
| 101 | 101 | case 'SHA256': |
| 102 | - $salt = '$5$' . substr($salt,0,16); |
|
| 102 | + $salt = '$5$'.substr($salt, 0, 16); |
|
| 103 | 103 | break; |
| 104 | 104 | case 'MD5': |
| 105 | - $salt = '$1$' . substr($salt,0,8); |
|
| 105 | + $salt = '$1$'.substr($salt, 0, 8); |
|
| 106 | 106 | break; |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | - if($algorithm!=='UNCRYPT') |
|
| 109 | + if ($algorithm !== 'UNCRYPT') |
|
| 110 | 110 | { |
| 111 | - $password = sha1($password) . crypt($password,$salt); |
|
| 111 | + $password = sha1($password).crypt($password, $salt); |
|
| 112 | 112 | } |
| 113 | 113 | else $password = sha1($salt.$password); |
| 114 | 114 | |
| 115 | - $result = strtolower($algorithm) . '>' . md5($salt.$password) . substr(md5($salt),0,8); |
|
| 115 | + $result = strtolower($algorithm).'>'.md5($salt.$password).substr(md5($salt), 0, 8); |
|
| 116 | 116 | |
| 117 | 117 | return $result; |
| 118 | 118 | } |
@@ -121,18 +121,18 @@ discard block |
||
| 121 | 121 | { |
| 122 | 122 | global $modx; |
| 123 | 123 | $tbl_manager_users = $modx->getFullTableName('manager_users'); |
| 124 | - $rs = $modx->db->select('password',$tbl_manager_users,"id='{$uid}'"); |
|
| 124 | + $rs = $modx->db->select('password', $tbl_manager_users, "id='{$uid}'"); |
|
| 125 | 125 | $password = $modx->db->getValue($rs); |
| 126 | 126 | |
| 127 | - if(strpos($password,'>')===false) $algo = 'NOSALT'; |
|
| 127 | + if (strpos($password, '>') === false) $algo = 'NOSALT'; |
|
| 128 | 128 | else |
| 129 | 129 | { |
| 130 | - $algo = substr($password,0,strpos($password,'>')); |
|
| 130 | + $algo = substr($password, 0, strpos($password, '>')); |
|
| 131 | 131 | } |
| 132 | 132 | return strtoupper($algo); |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | - function checkHashAlgorithm($algorithm='') |
|
| 135 | + function checkHashAlgorithm($algorithm = '') |
|
| 136 | 136 | { |
| 137 | 137 | $result = false; |
| 138 | 138 | if (!empty($algorithm)) |
@@ -165,54 +165,54 @@ discard block |
||
| 165 | 165 | return $result; |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | - function getSystemChecksum($check_files) { |
|
| 168 | + function getSystemChecksum($check_files){ |
|
| 169 | 169 | $_ = array(); |
| 170 | 170 | $check_files = trim($check_files); |
| 171 | 171 | $check_files = explode("\n", $check_files); |
| 172 | - foreach($check_files as $file) { |
|
| 172 | + foreach ($check_files as $file) { |
|
| 173 | 173 | $file = trim($file); |
| 174 | - $file = MODX_BASE_PATH . $file; |
|
| 175 | - if(!is_file($file)) continue; |
|
| 176 | - $_[$file]= md5_file($file); |
|
| 174 | + $file = MODX_BASE_PATH.$file; |
|
| 175 | + if (!is_file($file)) continue; |
|
| 176 | + $_[$file] = md5_file($file); |
|
| 177 | 177 | } |
| 178 | 178 | return serialize($_); |
| 179 | 179 | } |
| 180 | 180 | |
| 181 | - function getModifiedSystemFilesList($check_files, $checksum) { |
|
| 181 | + function getModifiedSystemFilesList($check_files, $checksum){ |
|
| 182 | 182 | $_ = array(); |
| 183 | 183 | $check_files = trim($check_files); |
| 184 | 184 | $check_files = explode("\n", $check_files); |
| 185 | 185 | $checksum = unserialize($checksum); |
| 186 | - foreach($check_files as $file) { |
|
| 186 | + foreach ($check_files as $file) { |
|
| 187 | 187 | $file = trim($file); |
| 188 | - $filePath = MODX_BASE_PATH . $file; |
|
| 189 | - if(!is_file($filePath)) continue; |
|
| 190 | - if(md5_file($filePath) != $checksum[$filePath]) $_[] = $file; |
|
| 188 | + $filePath = MODX_BASE_PATH.$file; |
|
| 189 | + if (!is_file($filePath)) continue; |
|
| 190 | + if (md5_file($filePath) != $checksum[$filePath]) $_[] = $file; |
|
| 191 | 191 | } |
| 192 | 192 | return $_; |
| 193 | 193 | } |
| 194 | 194 | |
| 195 | - function setSystemChecksum($checksum) { |
|
| 195 | + function setSystemChecksum($checksum){ |
|
| 196 | 196 | global $modx; |
| 197 | 197 | $tbl_system_settings = $modx->getFullTableName('system_settings'); |
| 198 | - $sql = "REPLACE INTO {$tbl_system_settings} (setting_name, setting_value) VALUES ('sys_files_checksum','" . $modx->db->escape($checksum) . "')"; |
|
| 198 | + $sql = "REPLACE INTO {$tbl_system_settings} (setting_name, setting_value) VALUES ('sys_files_checksum','".$modx->db->escape($checksum)."')"; |
|
| 199 | 199 | $modx->db->query($sql); |
| 200 | 200 | } |
| 201 | 201 | |
| 202 | - function checkSystemChecksum() { |
|
| 202 | + function checkSystemChecksum(){ |
|
| 203 | 203 | global $modx; |
| 204 | 204 | |
| 205 | - if(!isset($modx->config['check_files_onlogin']) || empty($modx->config['check_files_onlogin'])) return '0'; |
|
| 205 | + if (!isset($modx->config['check_files_onlogin']) || empty($modx->config['check_files_onlogin'])) return '0'; |
|
| 206 | 206 | |
| 207 | 207 | $current = $this->getSystemChecksum($modx->config['check_files_onlogin']); |
| 208 | - if(empty($current)) return '0'; |
|
| 208 | + if (empty($current)) return '0'; |
|
| 209 | 209 | |
| 210 | - if(!isset($modx->config['sys_files_checksum']) || empty($modx->config['sys_files_checksum'])) |
|
| 210 | + if (!isset($modx->config['sys_files_checksum']) || empty($modx->config['sys_files_checksum'])) |
|
| 211 | 211 | { |
| 212 | 212 | $this->setSystemChecksum($current); |
| 213 | 213 | return '0'; |
| 214 | 214 | } |
| 215 | - if($current===$modx->config['sys_files_checksum']) $result = '0'; |
|
| 215 | + if ($current === $modx->config['sys_files_checksum']) $result = '0'; |
|
| 216 | 216 | else { |
| 217 | 217 | $result = $this->getModifiedSystemFilesList($modx->config['check_files_onlogin'], $modx->config['sys_files_checksum']); |
| 218 | 218 | } |
@@ -220,28 +220,28 @@ discard block |
||
| 220 | 220 | return $result; |
| 221 | 221 | } |
| 222 | 222 | |
| 223 | - function getLastUserSetting($key=false) { |
|
| 223 | + function getLastUserSetting($key = false){ |
|
| 224 | 224 | global $modx; |
| 225 | 225 | |
| 226 | 226 | $rs = $modx->db->select('*', $modx->getFullTableName('user_settings'), "user = '{$_SESSION['mgrInternalKey']}'"); |
| 227 | 227 | |
| 228 | - $usersettings = array (); |
|
| 228 | + $usersettings = array(); |
|
| 229 | 229 | while ($row = $modx->db->getRow($rs)) { |
| 230 | - if(substr($row['setting_name'], 0, 6) == '_LAST_') { |
|
| 230 | + if (substr($row['setting_name'], 0, 6) == '_LAST_') { |
|
| 231 | 231 | $name = substr($row['setting_name'], 6); |
| 232 | 232 | $usersettings[$name] = $row['setting_value']; |
| 233 | 233 | } |
| 234 | 234 | } |
| 235 | 235 | |
| 236 | - if(!$key) return $usersettings; |
|
| 236 | + if (!$key) return $usersettings; |
|
| 237 | 237 | else return isset($usersettings[$key]) ? $usersettings[$key] : NULL; |
| 238 | 238 | } |
| 239 | 239 | |
| 240 | - function saveLastUserSetting($settings, $val='') { |
|
| 240 | + function saveLastUserSetting($settings, $val = ''){ |
|
| 241 | 241 | global $modx; |
| 242 | 242 | |
| 243 | - if(!empty($settings)) { |
|
| 244 | - if(!is_array($settings)) $settings = array($settings=>$val); |
|
| 243 | + if (!empty($settings)) { |
|
| 244 | + if (!is_array($settings)) $settings = array($settings=>$val); |
|
| 245 | 245 | |
| 246 | 246 | foreach ($settings as $key => $val) { |
| 247 | 247 | $f = array(); |
@@ -256,7 +256,7 @@ discard block |
||
| 256 | 256 | } |
| 257 | 257 | } |
| 258 | 258 | |
| 259 | - function loadDatePicker($path) { |
|
| 259 | + function loadDatePicker($path){ |
|
| 260 | 260 | global $modx; |
| 261 | 261 | include_once($path); |
| 262 | 262 | $dp = new DATEPICKER(); |
@@ -8,16 +8,19 @@ discard block |
||
| 8 | 8 | global $_PAGE; // page view state object. Usage $_PAGE['vs']['propertyname'] = $value; |
| 9 | 9 | |
| 10 | 10 | // Content manager wrapper class |
| 11 | -class ManagerAPI { |
|
| 11 | +class ManagerAPI |
|
| 12 | +{ |
|
| 12 | 13 | |
| 13 | 14 | var $action; // action directive |
| 14 | 15 | |
| 15 | - function __construct(){ |
|
| 16 | + function __construct() |
|
| 17 | + { |
|
| 16 | 18 | global $action; |
| 17 | 19 | $this->action = $action; // set action directive |
| 18 | 20 | } |
| 19 | 21 | |
| 20 | - function initPageViewState($id=0){ |
|
| 22 | + function initPageViewState($id=0) |
|
| 23 | + { |
|
| 21 | 24 | global $_PAGE; |
| 22 | 25 | $vsid = isset($_SESSION["mgrPageViewSID"]) ? $_SESSION["mgrPageViewSID"] : ''; |
| 23 | 26 | if($vsid!=$this->action) { |
@@ -28,33 +31,38 @@ discard block |
||
| 28 | 31 | } |
| 29 | 32 | |
| 30 | 33 | // save page view state - not really necessary, |
| 31 | - function savePageViewState($id=0){ |
|
| 34 | + function savePageViewState($id=0) |
|
| 35 | + { |
|
| 32 | 36 | global $_PAGE; |
| 33 | 37 | $_SESSION["mgrPageViewSDATA"] = $_PAGE['vs']; |
| 34 | 38 | $_SESSION["mgrPageViewSID"] = $id>0 ? $id:$this->action; |
| 35 | 39 | } |
| 36 | 40 | |
| 37 | 41 | // check for saved form |
| 38 | - function hasFormValues() { |
|
| 39 | - if(isset($_SESSION["mgrFormValueId"])) { |
|
| 42 | + function hasFormValues() |
|
| 43 | + { |
|
| 44 | + if(isset($_SESSION["mgrFormValueId"])) { |
|
| 40 | 45 | if($this->action==$_SESSION["mgrFormValueId"]) { |
| 41 | 46 | return true; |
| 42 | - } |
|
| 43 | - else { |
|
| 47 | + } else { |
|
| 44 | 48 | $this->clearSavedFormValues(); |
| 45 | 49 | } |
| 46 | 50 | } |
| 47 | 51 | return false; |
| 48 | 52 | } |
| 49 | 53 | // saved form post from $_POST |
| 50 | - function saveFormValues($id=0){ |
|
| 54 | + function saveFormValues($id=0) |
|
| 55 | + { |
|
| 51 | 56 | $_SESSION["mgrFormValues"] = $_POST; |
| 52 | 57 | $_SESSION["mgrFormValueId"] = $id>0 ? $id:$this->action; |
| 53 | 58 | } |
| 54 | 59 | // load saved form values into $_POST |
| 55 | - function loadFormValues(){ |
|
| 60 | + function loadFormValues() |
|
| 61 | + { |
|
| 56 | 62 | |
| 57 | - if(!$this->hasFormValues()) return false; |
|
| 63 | + if(!$this->hasFormValues()) { |
|
| 64 | + return false; |
|
| 65 | + } |
|
| 58 | 66 | |
| 59 | 67 | $p = $_SESSION["mgrFormValues"]; |
| 60 | 68 | $this->clearSavedFormValues(); |
@@ -64,31 +72,41 @@ discard block |
||
| 64 | 72 | return true; |
| 65 | 73 | } |
| 66 | 74 | // clear form post |
| 67 | - function clearSavedFormValues(){ |
|
| 75 | + function clearSavedFormValues() |
|
| 76 | + { |
|
| 68 | 77 | unset($_SESSION["mgrFormValues"]); |
| 69 | 78 | unset($_SESSION["mgrFormValueId"]); |
| 70 | 79 | } |
| 71 | 80 | |
| 72 | - function getHashType($db_value='') { // md5 | v1 | phpass |
|
| 81 | + function getHashType($db_value='') |
|
| 82 | + { |
|
| 83 | +// md5 | v1 | phpass |
|
| 73 | 84 | $c = substr($db_value,0,1); |
| 74 | - if($c==='$') return 'phpass'; |
|
| 75 | - elseif(strlen($db_value)===32) return 'md5'; |
|
| 76 | - elseif($c!=='$' && strpos($db_value,'>')!==false) return 'v1'; |
|
| 77 | - else return 'unknown'; |
|
| 85 | + if($c==='$') { |
|
| 86 | + return 'phpass'; |
|
| 87 | + } elseif(strlen($db_value)===32) { |
|
| 88 | + return 'md5'; |
|
| 89 | + } elseif($c!=='$' && strpos($db_value,'>')!==false) { |
|
| 90 | + return 'v1'; |
|
| 91 | + } else { |
|
| 92 | + return 'unknown'; |
|
| 93 | + } |
|
| 78 | 94 | } |
| 79 | 95 | |
| 80 | 96 | function genV1Hash($password, $seed='1') |
| 81 | - { // $seed is user_id basically |
|
| 97 | + { |
|
| 98 | +// $seed is user_id basically |
|
| 82 | 99 | global $modx; |
| 83 | 100 | |
| 84 | - if(isset($modx->config['pwd_hash_algo']) && !empty($modx->config['pwd_hash_algo'])) |
|
| 85 | - $algorithm = $modx->config['pwd_hash_algo']; |
|
| 86 | - else $algorithm = 'UNCRYPT'; |
|
| 101 | + if(isset($modx->config['pwd_hash_algo']) && !empty($modx->config['pwd_hash_algo'])) { |
|
| 102 | + $algorithm = $modx->config['pwd_hash_algo']; |
|
| 103 | + } else { |
|
| 104 | + $algorithm = 'UNCRYPT'; |
|
| 105 | + } |
|
| 87 | 106 | |
| 88 | 107 | $salt = md5($password . $seed); |
| 89 | 108 | |
| 90 | - switch($algorithm) |
|
| 91 | - { |
|
| 109 | + switch($algorithm) { |
|
| 92 | 110 | case 'BLOWFISH_Y': |
| 93 | 111 | $salt = '$2y$07$' . substr($salt,0,22); |
| 94 | 112 | break; |
@@ -106,11 +124,11 @@ discard block |
||
| 106 | 124 | break; |
| 107 | 125 | } |
| 108 | 126 | |
| 109 | - if($algorithm!=='UNCRYPT') |
|
| 110 | - { |
|
| 127 | + if($algorithm!=='UNCRYPT') { |
|
| 111 | 128 | $password = sha1($password) . crypt($password,$salt); |
| 129 | + } else { |
|
| 130 | + $password = sha1($salt.$password); |
|
| 112 | 131 | } |
| 113 | - else $password = sha1($salt.$password); |
|
| 114 | 132 | |
| 115 | 133 | $result = strtolower($algorithm) . '>' . md5($salt.$password) . substr(md5($salt),0,8); |
| 116 | 134 | |
@@ -124,9 +142,9 @@ discard block |
||
| 124 | 142 | $rs = $modx->db->select('password',$tbl_manager_users,"id='{$uid}'"); |
| 125 | 143 | $password = $modx->db->getValue($rs); |
| 126 | 144 | |
| 127 | - if(strpos($password,'>')===false) $algo = 'NOSALT'; |
|
| 128 | - else |
|
| 129 | - { |
|
| 145 | + if(strpos($password,'>')===false) { |
|
| 146 | + $algo = 'NOSALT'; |
|
| 147 | + } else { |
|
| 130 | 148 | $algo = substr($password,0,strpos($password,'>')); |
| 131 | 149 | } |
| 132 | 150 | return strtoupper($algo); |
@@ -135,27 +153,34 @@ discard block |
||
| 135 | 153 | function checkHashAlgorithm($algorithm='') |
| 136 | 154 | { |
| 137 | 155 | $result = false; |
| 138 | - if (!empty($algorithm)) |
|
| 139 | - { |
|
| 140 | - switch ($algorithm) |
|
| 141 | - { |
|
| 156 | + if (!empty($algorithm)) { |
|
| 157 | + switch ($algorithm) { |
|
| 142 | 158 | case 'BLOWFISH_Y': |
| 143 | - if (defined('CRYPT_BLOWFISH') && CRYPT_BLOWFISH == 1) |
|
| 144 | - { |
|
| 145 | - if (version_compare('5.3.7', PHP_VERSION) <= 0) $result = true; |
|
| 159 | + if (defined('CRYPT_BLOWFISH') && CRYPT_BLOWFISH == 1) { |
|
| 160 | + if (version_compare('5.3.7', PHP_VERSION) <= 0) { |
|
| 161 | + $result = true; |
|
| 162 | + } |
|
| 146 | 163 | } |
| 147 | 164 | break; |
| 148 | 165 | case 'BLOWFISH_A': |
| 149 | - if (defined('CRYPT_BLOWFISH') && CRYPT_BLOWFISH == 1) $result = true; |
|
| 166 | + if (defined('CRYPT_BLOWFISH') && CRYPT_BLOWFISH == 1) { |
|
| 167 | + $result = true; |
|
| 168 | + } |
|
| 150 | 169 | break; |
| 151 | 170 | case 'SHA512': |
| 152 | - if (defined('CRYPT_SHA512') && CRYPT_SHA512 == 1) $result = true; |
|
| 171 | + if (defined('CRYPT_SHA512') && CRYPT_SHA512 == 1) { |
|
| 172 | + $result = true; |
|
| 173 | + } |
|
| 153 | 174 | break; |
| 154 | 175 | case 'SHA256': |
| 155 | - if (defined('CRYPT_SHA256') && CRYPT_SHA256 == 1) $result = true; |
|
| 176 | + if (defined('CRYPT_SHA256') && CRYPT_SHA256 == 1) { |
|
| 177 | + $result = true; |
|
| 178 | + } |
|
| 156 | 179 | break; |
| 157 | 180 | case 'MD5': |
| 158 | - if (defined('CRYPT_MD5') && CRYPT_MD5 == 1 && PHP_VERSION != '5.3.7') $result = true; |
|
| 181 | + if (defined('CRYPT_MD5') && CRYPT_MD5 == 1 && PHP_VERSION != '5.3.7') { |
|
| 182 | + $result = true; |
|
| 183 | + } |
|
| 159 | 184 | break; |
| 160 | 185 | case 'UNCRYPT': |
| 161 | 186 | $result = true; |
@@ -165,20 +190,24 @@ discard block |
||
| 165 | 190 | return $result; |
| 166 | 191 | } |
| 167 | 192 | |
| 168 | - function getSystemChecksum($check_files) { |
|
| 193 | + function getSystemChecksum($check_files) |
|
| 194 | + { |
|
| 169 | 195 | $_ = array(); |
| 170 | 196 | $check_files = trim($check_files); |
| 171 | 197 | $check_files = explode("\n", $check_files); |
| 172 | 198 | foreach($check_files as $file) { |
| 173 | 199 | $file = trim($file); |
| 174 | 200 | $file = MODX_BASE_PATH . $file; |
| 175 | - if(!is_file($file)) continue; |
|
| 201 | + if(!is_file($file)) { |
|
| 202 | + continue; |
|
| 203 | + } |
|
| 176 | 204 | $_[$file]= md5_file($file); |
| 177 | 205 | } |
| 178 | 206 | return serialize($_); |
| 179 | 207 | } |
| 180 | 208 | |
| 181 | - function getModifiedSystemFilesList($check_files, $checksum) { |
|
| 209 | + function getModifiedSystemFilesList($check_files, $checksum) |
|
| 210 | + { |
|
| 182 | 211 | $_ = array(); |
| 183 | 212 | $check_files = trim($check_files); |
| 184 | 213 | $check_files = explode("\n", $check_files); |
@@ -186,41 +215,52 @@ discard block |
||
| 186 | 215 | foreach($check_files as $file) { |
| 187 | 216 | $file = trim($file); |
| 188 | 217 | $filePath = MODX_BASE_PATH . $file; |
| 189 | - if(!is_file($filePath)) continue; |
|
| 190 | - if(md5_file($filePath) != $checksum[$filePath]) $_[] = $file; |
|
| 218 | + if(!is_file($filePath)) { |
|
| 219 | + continue; |
|
| 220 | + } |
|
| 221 | + if(md5_file($filePath) != $checksum[$filePath]) { |
|
| 222 | + $_[] = $file; |
|
| 223 | + } |
|
| 191 | 224 | } |
| 192 | 225 | return $_; |
| 193 | 226 | } |
| 194 | 227 | |
| 195 | - function setSystemChecksum($checksum) { |
|
| 228 | + function setSystemChecksum($checksum) |
|
| 229 | + { |
|
| 196 | 230 | global $modx; |
| 197 | 231 | $tbl_system_settings = $modx->getFullTableName('system_settings'); |
| 198 | 232 | $sql = "REPLACE INTO {$tbl_system_settings} (setting_name, setting_value) VALUES ('sys_files_checksum','" . $modx->db->escape($checksum) . "')"; |
| 199 | 233 | $modx->db->query($sql); |
| 200 | 234 | } |
| 201 | 235 | |
| 202 | - function checkSystemChecksum() { |
|
| 236 | + function checkSystemChecksum() |
|
| 237 | + { |
|
| 203 | 238 | global $modx; |
| 204 | 239 | |
| 205 | - if(!isset($modx->config['check_files_onlogin']) || empty($modx->config['check_files_onlogin'])) return '0'; |
|
| 240 | + if(!isset($modx->config['check_files_onlogin']) || empty($modx->config['check_files_onlogin'])) { |
|
| 241 | + return '0'; |
|
| 242 | + } |
|
| 206 | 243 | |
| 207 | 244 | $current = $this->getSystemChecksum($modx->config['check_files_onlogin']); |
| 208 | - if(empty($current)) return '0'; |
|
| 245 | + if(empty($current)) { |
|
| 246 | + return '0'; |
|
| 247 | + } |
|
| 209 | 248 | |
| 210 | - if(!isset($modx->config['sys_files_checksum']) || empty($modx->config['sys_files_checksum'])) |
|
| 211 | - { |
|
| 249 | + if(!isset($modx->config['sys_files_checksum']) || empty($modx->config['sys_files_checksum'])) { |
|
| 212 | 250 | $this->setSystemChecksum($current); |
| 213 | 251 | return '0'; |
| 214 | 252 | } |
| 215 | - if($current===$modx->config['sys_files_checksum']) $result = '0'; |
|
| 216 | - else { |
|
| 253 | + if($current===$modx->config['sys_files_checksum']) { |
|
| 254 | + $result = '0'; |
|
| 255 | + } else { |
|
| 217 | 256 | $result = $this->getModifiedSystemFilesList($modx->config['check_files_onlogin'], $modx->config['sys_files_checksum']); |
| 218 | 257 | } |
| 219 | 258 | |
| 220 | 259 | return $result; |
| 221 | 260 | } |
| 222 | 261 | |
| 223 | - function getLastUserSetting($key=false) { |
|
| 262 | + function getLastUserSetting($key=false) |
|
| 263 | + { |
|
| 224 | 264 | global $modx; |
| 225 | 265 | |
| 226 | 266 | $rs = $modx->db->select('*', $modx->getFullTableName('user_settings'), "user = '{$_SESSION['mgrInternalKey']}'"); |
@@ -233,15 +273,21 @@ discard block |
||
| 233 | 273 | } |
| 234 | 274 | } |
| 235 | 275 | |
| 236 | - if(!$key) return $usersettings; |
|
| 237 | - else return isset($usersettings[$key]) ? $usersettings[$key] : NULL; |
|
| 276 | + if(!$key) { |
|
| 277 | + return $usersettings; |
|
| 278 | + } else { |
|
| 279 | + return isset($usersettings[$key]) ? $usersettings[$key] : NULL; |
|
| 280 | + } |
|
| 238 | 281 | } |
| 239 | 282 | |
| 240 | - function saveLastUserSetting($settings, $val='') { |
|
| 283 | + function saveLastUserSetting($settings, $val='') |
|
| 284 | + { |
|
| 241 | 285 | global $modx; |
| 242 | 286 | |
| 243 | 287 | if(!empty($settings)) { |
| 244 | - if(!is_array($settings)) $settings = array($settings=>$val); |
|
| 288 | + if(!is_array($settings)) { |
|
| 289 | + $settings = array($settings=>$val); |
|
| 290 | + } |
|
| 245 | 291 | |
| 246 | 292 | foreach ($settings as $key => $val) { |
| 247 | 293 | $f = array(); |
@@ -256,7 +302,8 @@ discard block |
||
| 256 | 302 | } |
| 257 | 303 | } |
| 258 | 304 | |
| 259 | - function loadDatePicker($path) { |
|
| 305 | + function loadDatePicker($path) |
|
| 306 | + { |
|
| 260 | 307 | global $modx; |
| 261 | 308 | include_once($path); |
| 262 | 309 | $dp = new DATEPICKER(); |
@@ -234,7 +234,7 @@ |
||
| 234 | 234 | } |
| 235 | 235 | |
| 236 | 236 | if(!$key) return $usersettings; |
| 237 | - else return isset($usersettings[$key]) ? $usersettings[$key] : NULL; |
|
| 237 | + else return isset($usersettings[$key]) ? $usersettings[$key] : null; |
|
| 238 | 238 | } |
| 239 | 239 | |
| 240 | 240 | function saveLastUserSetting($settings, $val='') { |
@@ -43,6 +43,9 @@ discard block |
||
| 43 | 43 | $this->random_state = microtime() . uniqid(mt_rand(), TRUE); |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | + /** |
|
| 47 | + * @param integer $count |
|
| 48 | + */ |
|
| 46 | 49 | function get_random_bytes($count) |
| 47 | 50 | { |
| 48 | 51 | $output = ''; |
@@ -66,6 +69,9 @@ discard block |
||
| 66 | 69 | return $output; |
| 67 | 70 | } |
| 68 | 71 | |
| 72 | + /** |
|
| 73 | + * @param integer $count |
|
| 74 | + */ |
|
| 69 | 75 | function encode64($input, $count) |
| 70 | 76 | { |
| 71 | 77 | $output = ''; |
@@ -89,6 +95,9 @@ discard block |
||
| 89 | 95 | return $output; |
| 90 | 96 | } |
| 91 | 97 | |
| 98 | + /** |
|
| 99 | + * @param string $input |
|
| 100 | + */ |
|
| 92 | 101 | function gensalt_private($input) |
| 93 | 102 | { |
| 94 | 103 | $output = '$P$'; |
@@ -137,6 +146,9 @@ discard block |
||
| 137 | 146 | return $output; |
| 138 | 147 | } |
| 139 | 148 | |
| 149 | + /** |
|
| 150 | + * @param string $input |
|
| 151 | + */ |
|
| 140 | 152 | function gensalt_extended($input) |
| 141 | 153 | { |
| 142 | 154 | $count_log2 = min($this->iteration_count_log2 + 8, 24); |
@@ -155,6 +167,9 @@ discard block |
||
| 155 | 167 | return $output; |
| 156 | 168 | } |
| 157 | 169 | |
| 170 | + /** |
|
| 171 | + * @param string $input |
|
| 172 | + */ |
|
| 158 | 173 | function gensalt_blowfish($input) |
| 159 | 174 | { |
| 160 | 175 | // This one needs to use a different order of characters and a |
@@ -24,13 +24,13 @@ discard block |
||
| 24 | 24 | // Obviously, since this code is in the public domain, the above are not |
| 25 | 25 | // requirements (there can be none), but merely suggestions. |
| 26 | 26 | // |
| 27 | -class PasswordHash { |
|
| 27 | +class PasswordHash{ |
|
| 28 | 28 | var $itoa64; |
| 29 | 29 | var $iteration_count_log2; |
| 30 | 30 | var $portable_hashes; |
| 31 | 31 | var $random_state; |
| 32 | 32 | |
| 33 | - function __construct($iteration_count_log2=8, $portable_hashes=true) |
|
| 33 | + function __construct($iteration_count_log2 = 8, $portable_hashes = true) |
|
| 34 | 34 | { |
| 35 | 35 | $this->itoa64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; |
| 36 | 36 | |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | |
| 41 | 41 | $this->portable_hashes = $portable_hashes; |
| 42 | 42 | |
| 43 | - $this->random_state = microtime() . uniqid(mt_rand(), TRUE); |
|
| 43 | + $this->random_state = microtime().uniqid(mt_rand(), TRUE); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | function get_random_bytes($count) |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | $output = ''; |
| 57 | 57 | for ($i = 0; $i < $count; $i += 16) { |
| 58 | 58 | $this->random_state = |
| 59 | - md5(microtime() . $this->random_state); |
|
| 59 | + md5(microtime().$this->random_state); |
|
| 60 | 60 | $output .= |
| 61 | 61 | pack('H*', md5($this->random_state)); |
| 62 | 62 | } |
@@ -126,9 +126,9 @@ discard block |
||
| 126 | 126 | // consequently in lower iteration counts and hashes that are |
| 127 | 127 | // quicker to crack (by non-PHP code). |
| 128 | 128 | |
| 129 | - $hash = md5($salt . $password, TRUE); |
|
| 129 | + $hash = md5($salt.$password, TRUE); |
|
| 130 | 130 | do { |
| 131 | - $hash = md5($hash . $password, TRUE); |
|
| 131 | + $hash = md5($hash.$password, TRUE); |
|
| 132 | 132 | } while (--$count); |
| 133 | 133 | |
| 134 | 134 | $output = substr($setting, 0, 12); |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | |
| 199 | 199 | function HashPassword($password) |
| 200 | 200 | { |
| 201 | - if ( strlen( $password ) > 4096 ) { |
|
| 201 | + if (strlen($password) > 4096) { |
|
| 202 | 202 | return '*'; |
| 203 | 203 | } |
| 204 | 204 | |
@@ -237,14 +237,14 @@ discard block |
||
| 237 | 237 | |
| 238 | 238 | function CheckPassword($password, $stored_hash) |
| 239 | 239 | { |
| 240 | - if ( strlen( $password ) > 4096 ) { |
|
| 240 | + if (strlen($password) > 4096) { |
|
| 241 | 241 | return false; |
| 242 | 242 | } |
| 243 | 243 | |
| 244 | 244 | $hash = $this->crypt_private($password, $stored_hash); |
| 245 | - if (substr($hash,0,1) === '*') |
|
| 245 | + if (substr($hash, 0, 1) === '*') |
|
| 246 | 246 | $hash = crypt($password, $stored_hash); |
| 247 | 247 | |
| 248 | - return ($hash===$stored_hash) ? true : false; |
|
| 248 | + return ($hash === $stored_hash) ? true : false; |
|
| 249 | 249 | } |
| 250 | 250 | } |
@@ -24,7 +24,8 @@ discard block |
||
| 24 | 24 | // Obviously, since this code is in the public domain, the above are not |
| 25 | 25 | // requirements (there can be none), but merely suggestions. |
| 26 | 26 | // |
| 27 | -class PasswordHash { |
|
| 27 | +class PasswordHash |
|
| 28 | +{ |
|
| 28 | 29 | var $itoa64; |
| 29 | 30 | var $iteration_count_log2; |
| 30 | 31 | var $portable_hashes; |
@@ -34,8 +35,9 @@ discard block |
||
| 34 | 35 | { |
| 35 | 36 | $this->itoa64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; |
| 36 | 37 | |
| 37 | - if ($iteration_count_log2 < 4 || $iteration_count_log2 > 31) |
|
| 38 | - $iteration_count_log2 = 8; |
|
| 38 | + if ($iteration_count_log2 < 4 || $iteration_count_log2 > 31) { |
|
| 39 | + $iteration_count_log2 = 8; |
|
| 40 | + } |
|
| 39 | 41 | $this->iteration_count_log2 = $iteration_count_log2; |
| 40 | 42 | |
| 41 | 43 | $this->portable_hashes = $portable_hashes; |
@@ -73,16 +75,20 @@ discard block |
||
| 73 | 75 | do { |
| 74 | 76 | $value = ord($input[$i++]); |
| 75 | 77 | $output .= $this->itoa64[$value & 0x3f]; |
| 76 | - if ($i < $count) |
|
| 77 | - $value |= ord($input[$i]) << 8; |
|
| 78 | + if ($i < $count) { |
|
| 79 | + $value |= ord($input[$i]) << 8; |
|
| 80 | + } |
|
| 78 | 81 | $output .= $this->itoa64[($value >> 6) & 0x3f]; |
| 79 | - if ($i++ >= $count) |
|
| 80 | - break; |
|
| 81 | - if ($i < $count) |
|
| 82 | - $value |= ord($input[$i]) << 16; |
|
| 82 | + if ($i++ >= $count) { |
|
| 83 | + break; |
|
| 84 | + } |
|
| 85 | + if ($i < $count) { |
|
| 86 | + $value |= ord($input[$i]) << 16; |
|
| 87 | + } |
|
| 83 | 88 | $output .= $this->itoa64[($value >> 12) & 0x3f]; |
| 84 | - if ($i++ >= $count) |
|
| 85 | - break; |
|
| 89 | + if ($i++ >= $count) { |
|
| 90 | + break; |
|
| 91 | + } |
|
| 86 | 92 | $output .= $this->itoa64[($value >> 18) & 0x3f]; |
| 87 | 93 | } while ($i < $count); |
| 88 | 94 | |
@@ -101,23 +107,27 @@ discard block |
||
| 101 | 107 | function crypt_private($password, $setting) |
| 102 | 108 | { |
| 103 | 109 | $output = '*0'; |
| 104 | - if (substr($setting, 0, 2) == $output) |
|
| 105 | - $output = '*1'; |
|
| 110 | + if (substr($setting, 0, 2) == $output) { |
|
| 111 | + $output = '*1'; |
|
| 112 | + } |
|
| 106 | 113 | |
| 107 | 114 | $id = substr($setting, 0, 3); |
| 108 | 115 | // We use "$P$", phpBB3 uses "$H$" for the same thing |
| 109 | - if ($id != '$P$' && $id != '$H$') |
|
| 110 | - return $output; |
|
| 116 | + if ($id != '$P$' && $id != '$H$') { |
|
| 117 | + return $output; |
|
| 118 | + } |
|
| 111 | 119 | |
| 112 | 120 | $count_log2 = strpos($this->itoa64, $setting[3]); |
| 113 | - if ($count_log2 < 7 || $count_log2 > 30) |
|
| 114 | - return $output; |
|
| 121 | + if ($count_log2 < 7 || $count_log2 > 30) { |
|
| 122 | + return $output; |
|
| 123 | + } |
|
| 115 | 124 | |
| 116 | 125 | $count = 1 << $count_log2; |
| 117 | 126 | |
| 118 | 127 | $salt = substr($setting, 4, 8); |
| 119 | - if (strlen($salt) != 8) |
|
| 120 | - return $output; |
|
| 128 | + if (strlen($salt) != 8) { |
|
| 129 | + return $output; |
|
| 130 | + } |
|
| 121 | 131 | |
| 122 | 132 | // We're kind of forced to use MD5 here since it's the only |
| 123 | 133 | // cryptographic primitive available in all versions of PHP |
@@ -208,26 +218,31 @@ discard block |
||
| 208 | 218 | $random = $this->get_random_bytes(16); |
| 209 | 219 | $hash = |
| 210 | 220 | crypt($password, $this->gensalt_blowfish($random)); |
| 211 | - if (strlen($hash) == 60) |
|
| 212 | - return $hash; |
|
| 221 | + if (strlen($hash) == 60) { |
|
| 222 | + return $hash; |
|
| 223 | + } |
|
| 213 | 224 | } |
| 214 | 225 | |
| 215 | 226 | if (CRYPT_EXT_DES == 1 && !$this->portable_hashes) { |
| 216 | - if (strlen($random) < 3) |
|
| 217 | - $random = $this->get_random_bytes(3); |
|
| 227 | + if (strlen($random) < 3) { |
|
| 228 | + $random = $this->get_random_bytes(3); |
|
| 229 | + } |
|
| 218 | 230 | $hash = |
| 219 | 231 | crypt($password, $this->gensalt_extended($random)); |
| 220 | - if (strlen($hash) == 20) |
|
| 221 | - return $hash; |
|
| 232 | + if (strlen($hash) == 20) { |
|
| 233 | + return $hash; |
|
| 234 | + } |
|
| 222 | 235 | } |
| 223 | 236 | |
| 224 | - if (strlen($random) < 6) |
|
| 225 | - $random = $this->get_random_bytes(6); |
|
| 237 | + if (strlen($random) < 6) { |
|
| 238 | + $random = $this->get_random_bytes(6); |
|
| 239 | + } |
|
| 226 | 240 | $hash = |
| 227 | 241 | $this->crypt_private($password, |
| 228 | 242 | $this->gensalt_private($random)); |
| 229 | - if (strlen($hash) == 34) |
|
| 230 | - return $hash; |
|
| 243 | + if (strlen($hash) == 34) { |
|
| 244 | + return $hash; |
|
| 245 | + } |
|
| 231 | 246 | |
| 232 | 247 | // Returning '*' on error is safe here, but would _not_ be safe |
| 233 | 248 | // in a crypt(3)-like function used _both_ for generating new |
@@ -242,8 +257,9 @@ discard block |
||
| 242 | 257 | } |
| 243 | 258 | |
| 244 | 259 | $hash = $this->crypt_private($password, $stored_hash); |
| 245 | - if (substr($hash,0,1) === '*') |
|
| 246 | - $hash = crypt($password, $stored_hash); |
|
| 260 | + if (substr($hash,0,1) === '*') { |
|
| 261 | + $hash = crypt($password, $stored_hash); |
|
| 262 | + } |
|
| 247 | 263 | |
| 248 | 264 | return ($hash===$stored_hash) ? true : false; |
| 249 | 265 | } |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | |
| 41 | 41 | $this->portable_hashes = $portable_hashes; |
| 42 | 42 | |
| 43 | - $this->random_state = microtime() . uniqid(mt_rand(), TRUE); |
|
| 43 | + $this->random_state = microtime() . uniqid(mt_rand(), true); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | function get_random_bytes($count) |
@@ -126,9 +126,9 @@ discard block |
||
| 126 | 126 | // consequently in lower iteration counts and hashes that are |
| 127 | 127 | // quicker to crack (by non-PHP code). |
| 128 | 128 | |
| 129 | - $hash = md5($salt . $password, TRUE); |
|
| 129 | + $hash = md5($salt . $password, true); |
|
| 130 | 130 | do { |
| 131 | - $hash = md5($hash . $password, TRUE); |
|
| 131 | + $hash = md5($hash . $password, true); |
|
| 132 | 132 | } while (--$count); |
| 133 | 133 | |
| 134 | 134 | $output = substr($setting, 0, 12); |