@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | var $role; |
| 8 | 8 | var $duplicateDoc = false; |
| 9 | 9 | |
| 10 | - function checkPermissions() { |
|
| 10 | + function checkPermissions(){ |
|
| 11 | 11 | |
| 12 | 12 | global $udperms_allowroot; |
| 13 | 13 | global $modx; |
@@ -19,23 +19,23 @@ discard block |
||
| 19 | 19 | $document = $this->document; |
| 20 | 20 | $role = $this->role; |
| 21 | 21 | |
| 22 | - if($role==1) { |
|
| 23 | - return true; // administrator - grant all document permissions |
|
| 22 | + if ($role == 1) { |
|
| 23 | + return true; // administrator - grant all document permissions |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | - if($modx->config['use_udperms']==0 || $modx->config['use_udperms']=="" || !isset($modx->config['use_udperms'])) { |
|
| 26 | + if ($modx->config['use_udperms'] == 0 || $modx->config['use_udperms'] == "" || !isset($modx->config['use_udperms'])) { |
|
| 27 | 27 | return true; // permissions aren't in use |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | $parent = $modx->db->getValue($modx->db->select('parent', $tblsc, "id='{$this->document}'")); |
| 31 | - if($document == 0 && $parent == NULL && $udperms_allowroot == 1) return true; // User is allowed to create new document in root |
|
| 32 | - if (($this->duplicateDoc==true || $document==0) && $parent==0 && $udperms_allowroot==0) { |
|
| 31 | + if ($document == 0 && $parent == NULL && $udperms_allowroot == 1) return true; // User is allowed to create new document in root |
|
| 32 | + if (($this->duplicateDoc == true || $document == 0) && $parent == 0 && $udperms_allowroot == 0) { |
|
| 33 | 33 | return false; // deny duplicate || create new document at root if Allow Root is No |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | // get document groups for current user |
| 37 | - if($_SESSION['mgrDocgroups']) { |
|
| 38 | - $docgrp = implode(" || dg.document_group = ",$_SESSION['mgrDocgroups']); |
|
| 37 | + if ($_SESSION['mgrDocgroups']) { |
|
| 38 | + $docgrp = implode(" || dg.document_group = ", $_SESSION['mgrDocgroups']); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | /* Note: |
@@ -46,17 +46,17 @@ discard block |
||
| 46 | 46 | are private to the manager users will not be private to web users if the |
| 47 | 47 | document group is not assigned to a web user group and visa versa. |
| 48 | 48 | */ |
| 49 | - $permissionsok = false; // set permissions to false |
|
| 49 | + $permissionsok = false; // set permissions to false |
|
| 50 | 50 | |
| 51 | 51 | $rs = $modx->db->select( |
| 52 | 52 | 'count(DISTINCT sc.id)', |
| 53 | 53 | "{$tblsc} AS sc |
| 54 | 54 | LEFT JOIN {$tbldg} AS dg on dg.document = sc.id |
| 55 | 55 | LEFT JOIN {$tbldgn} dgn ON dgn.id = dg.document_group", |
| 56 | - "sc.id='{$this->document}' AND (". ( (!$docgrp) ? null : "dg.document_group = ".$docgrp." ||" ) . " sc.privatemgr = 0)" |
|
| 56 | + "sc.id='{$this->document}' AND (".((!$docgrp) ? null : "dg.document_group = ".$docgrp." ||")." sc.privatemgr = 0)" |
|
| 57 | 57 | ); |
| 58 | 58 | $limit = $modx->db->getValue($rs); |
| 59 | - if($limit==1) $permissionsok = true; |
|
| 59 | + if ($limit == 1) $permissionsok = true; |
|
| 60 | 60 | |
| 61 | 61 | return $permissionsok; |
| 62 | 62 | } |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | if (isset($this->aliases[$id])) { |
| 62 | 62 | if ($this->aliasVisible[$id] == 1) { |
| 63 | 63 | if ($path != '') { |
| 64 | - $path = $this->aliases[$id] . '/' . $path; |
|
| 64 | + $path = $this->aliases[$id].'/'.$path; |
|
| 65 | 65 | } else { |
| 66 | 66 | $path = $this->aliases[$id]; |
| 67 | 67 | } |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | $modx->messageQuit("Cache path not set."); |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | - $files = glob(realpath($this->cachePath) . '/*.pageCache.php'); |
|
| 83 | + $files = glob(realpath($this->cachePath).'/*.pageCache.php'); |
|
| 84 | 84 | $filesincache = count($files); |
| 85 | 85 | $deletedfiles = array(); |
| 86 | 86 | while ($file = array_shift($files)) { |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | } |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | - if(function_exists('opcache_get_status')) { |
|
| 96 | + if (function_exists('opcache_get_status')) { |
|
| 97 | 97 | $opcache = opcache_get_status(); |
| 98 | 98 | if (!empty($opcache['opcache_enabled'])) { |
| 99 | 99 | opcache_reset(); |
@@ -113,9 +113,9 @@ discard block |
||
| 113 | 113 | if (isset($opcache)) { |
| 114 | 114 | echo '<p>Opcache empty.</p>'; |
| 115 | 115 | } |
| 116 | - echo '<p>' . $_lang['cache_files_deleted'] . '</p><ul>'; |
|
| 116 | + echo '<p>'.$_lang['cache_files_deleted'].'</p><ul>'; |
|
| 117 | 117 | foreach ($deletedfiles as $deletedfile) { |
| 118 | - echo '<li>' . $deletedfile . '</li>'; |
|
| 118 | + echo '<li>'.$deletedfile.'</li>'; |
|
| 119 | 119 | } |
| 120 | 120 | echo '</ul>'; |
| 121 | 121 | } |
@@ -131,11 +131,11 @@ discard block |
||
| 131 | 131 | |
| 132 | 132 | |
| 133 | 133 | // write the file |
| 134 | - $content = '<?php' . "\n"; |
|
| 135 | - $content .= '$recent_update=\'' . $this->request_time . '\';' . "\n"; |
|
| 136 | - $content .= '$cacheRefreshTime=\'' . $cacheRefreshTime . '\';' . "\n"; |
|
| 134 | + $content = '<?php'."\n"; |
|
| 135 | + $content .= '$recent_update=\''.$this->request_time.'\';'."\n"; |
|
| 136 | + $content .= '$cacheRefreshTime=\''.$cacheRefreshTime.'\';'."\n"; |
|
| 137 | 137 | |
| 138 | - $filename = $this->cachePath . '/sitePublishing.idx.php'; |
|
| 138 | + $filename = $this->cachePath.'/sitePublishing.idx.php'; |
|
| 139 | 139 | if (!$handle = fopen($filename, 'w')) { |
| 140 | 140 | exit("Cannot open file ({$filename}"); |
| 141 | 141 | } |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | // update publish time file |
| 156 | 156 | $timesArr = array(); |
| 157 | 157 | |
| 158 | - $result = $modx->db->select('MIN(pub_date) AS minpub', '[+prefix+]site_content', 'pub_date>' . $this->request_time); |
|
| 158 | + $result = $modx->db->select('MIN(pub_date) AS minpub', '[+prefix+]site_content', 'pub_date>'.$this->request_time); |
|
| 159 | 159 | if (!$result) { |
| 160 | 160 | echo "Couldn't determine next publish event!"; |
| 161 | 161 | } |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | $timesArr[] = $minpub; |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | - $result = $modx->db->select('MIN(unpub_date) AS minunpub', '[+prefix+]site_content', 'unpub_date>' . $this->request_time); |
|
| 168 | + $result = $modx->db->select('MIN(unpub_date) AS minunpub', '[+prefix+]site_content', 'unpub_date>'.$this->request_time); |
|
| 169 | 169 | if (!$result) { |
| 170 | 170 | echo "Couldn't determine next unpublish event!"; |
| 171 | 171 | } |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | $config = array(); |
| 204 | 204 | $content .= '$c=&$this->config;'; |
| 205 | 205 | while (list($key, $value) = $modx->db->getRow($rs, 'num')) { |
| 206 | - $content .= '$c[\'' . $key . '\']="' . $this->escapeDoubleQuotes($value) . '";'; |
|
| 206 | + $content .= '$c[\''.$key.'\']="'.$this->escapeDoubleQuotes($value).'";'; |
|
| 207 | 207 | $config[$key] = $value; |
| 208 | 208 | } |
| 209 | 209 | |
@@ -241,23 +241,23 @@ discard block |
||
| 241 | 241 | $docid = $doc['id']; |
| 242 | 242 | if ($use_alias_path) { |
| 243 | 243 | $tmpPath = $this->getParents($doc['parent']); |
| 244 | - $alias = (strlen($tmpPath) > 0 ? "$tmpPath/" : '') . $doc['alias']; |
|
| 244 | + $alias = (strlen($tmpPath) > 0 ? "$tmpPath/" : '').$doc['alias']; |
|
| 245 | 245 | $key = $alias; |
| 246 | 246 | } else { |
| 247 | 247 | $key = $doc['alias']; |
| 248 | 248 | } |
| 249 | 249 | |
| 250 | 250 | $doc['path'] = $tmpPath; |
| 251 | - $content .= '$a[' . $docid . ']=array(\'id\'=>' . $docid . ',\'alias\'=>\'' . $doc['alias'] . '\',\'path\'=>\'' . $doc['path'] . '\',\'parent\'=>' . $doc['parent'] . ',\'isfolder\'=>' . $doc['isfolder'] . ',\'alias_visible\'=>' . $doc['alias_visible'] . ');'; |
|
| 252 | - $content .= '$d[\'' . $key . '\']=' . $docid . ';'; |
|
| 253 | - $content .= '$m[]=array(' . $doc['parent'] . '=>' . $docid . ');'; |
|
| 251 | + $content .= '$a['.$docid.']=array(\'id\'=>'.$docid.',\'alias\'=>\''.$doc['alias'].'\',\'path\'=>\''.$doc['path'].'\',\'parent\'=>'.$doc['parent'].',\'isfolder\'=>'.$doc['isfolder'].',\'alias_visible\'=>'.$doc['alias_visible'].');'; |
|
| 252 | + $content .= '$d[\''.$key.'\']='.$docid.';'; |
|
| 253 | + $content .= '$m[]=array('.$doc['parent'].'=>'.$docid.');'; |
|
| 254 | 254 | } |
| 255 | 255 | |
| 256 | 256 | // get content types |
| 257 | 257 | $rs = $modx->db->select('id, contentType', '[+prefix+]site_content', "contentType!='text/html'"); |
| 258 | 258 | $content .= '$c=&$this->contentTypes;'; |
| 259 | 259 | while ($doc = $modx->db->getRow($rs)) { |
| 260 | - $content .= '$c[\'' . $doc['id'] . '\']=\'' . $doc['contentType'] . '\';'; |
|
| 260 | + $content .= '$c[\''.$doc['id'].'\']=\''.$doc['contentType'].'\';'; |
|
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | // WRITE Chunks to cache file |
@@ -267,7 +267,7 @@ discard block |
||
| 267 | 267 | if ($modx->config['minifyphp_incache']) { |
| 268 | 268 | $doc['snippet'] = $this->php_strip_whitespace($doc['snippet']); |
| 269 | 269 | } |
| 270 | - $content .= '$c[\'' . $doc['name'] . '\']=\'' . ($doc['disabled'] ? '' : $this->escapeSingleQuotes($doc['snippet'])) . '\';'; |
|
| 270 | + $content .= '$c[\''.$doc['name'].'\']=\''.($doc['disabled'] ? '' : $this->escapeSingleQuotes($doc['snippet'])).'\';'; |
|
| 271 | 271 | } |
| 272 | 272 | |
| 273 | 273 | // WRITE snippets to cache file |
@@ -278,18 +278,18 @@ discard block |
||
| 278 | 278 | while ($row = $modx->db->getRow($rs)) { |
| 279 | 279 | $key = $row['name']; |
| 280 | 280 | if ($row['disabled']) { |
| 281 | - $content .= '$s[\'' . $key . '\']=\'return false;\';'; |
|
| 281 | + $content .= '$s[\''.$key.'\']=\'return false;\';'; |
|
| 282 | 282 | } else { |
| 283 | 283 | $value = trim($row['snippet']); |
| 284 | 284 | if ($modx->config['minifyphp_incache']) { |
| 285 | 285 | $value = $this->php_strip_whitespace($value); |
| 286 | 286 | } |
| 287 | - $content .= '$s[\'' . $key . '\']=\'' . $this->escapeSingleQuotes($value) . '\';'; |
|
| 287 | + $content .= '$s[\''.$key.'\']=\''.$this->escapeSingleQuotes($value).'\';'; |
|
| 288 | 288 | $properties = $modx->parseProperties($row['properties']); |
| 289 | 289 | $sharedproperties = $modx->parseProperties($row['sharedproperties']); |
| 290 | 290 | $properties = array_merge($sharedproperties, $properties); |
| 291 | 291 | if (0 < count($properties)) { |
| 292 | - $content .= '$s[\'' . $key . 'Props\']=\'' . $this->escapeSingleQuotes(json_encode($properties)) . '\';'; |
|
| 292 | + $content .= '$s[\''.$key.'Props\']=\''.$this->escapeSingleQuotes(json_encode($properties)).'\';'; |
|
| 293 | 293 | } |
| 294 | 294 | } |
| 295 | 295 | } |
@@ -307,13 +307,13 @@ discard block |
||
| 307 | 307 | if ($modx->config['minifyphp_incache']) { |
| 308 | 308 | $value = $this->php_strip_whitespace($value); |
| 309 | 309 | } |
| 310 | - $content .= '$p[\'' . $key . '\']=\'' . $this->escapeSingleQuotes($value) . '\';'; |
|
| 310 | + $content .= '$p[\''.$key.'\']=\''.$this->escapeSingleQuotes($value).'\';'; |
|
| 311 | 311 | if ($row['properties'] != '' || $row['sharedproperties'] != '') { |
| 312 | 312 | $properties = $modx->parseProperties($row['properties']); |
| 313 | 313 | $sharedproperties = $modx->parseProperties($row['sharedproperties']); |
| 314 | 314 | $properties = array_merge($sharedproperties, $properties); |
| 315 | 315 | if (0 < count($properties)) { |
| 316 | - $content .= '$p[\'' . $key . 'Props\']=\'' . $this->escapeSingleQuotes(json_encode($properties)) . '\';'; |
|
| 316 | + $content .= '$p[\''.$key.'Props\']=\''.$this->escapeSingleQuotes(json_encode($properties)).'\';'; |
|
| 317 | 317 | } |
| 318 | 318 | } |
| 319 | 319 | } |
@@ -336,13 +336,13 @@ discard block |
||
| 336 | 336 | } |
| 337 | 337 | foreach ($events as $evtname => $pluginnames) { |
| 338 | 338 | $events[$evtname] = $pluginnames; |
| 339 | - $content .= '$e[\'' . $evtname . '\']=array(\'' . implode('\',\'', $this->escapeSingleQuotes($pluginnames)) . '\');'; |
|
| 339 | + $content .= '$e[\''.$evtname.'\']=array(\''.implode('\',\'', $this->escapeSingleQuotes($pluginnames)).'\');'; |
|
| 340 | 340 | } |
| 341 | 341 | |
| 342 | 342 | $content .= "\n"; |
| 343 | 343 | |
| 344 | 344 | // close and write the file |
| 345 | - $filename = $this->cachePath . 'siteCache.idx.php'; |
|
| 345 | + $filename = $this->cachePath.'siteCache.idx.php'; |
|
| 346 | 346 | |
| 347 | 347 | // invoke OnBeforeCacheUpdate event |
| 348 | 348 | if ($modx) { |
@@ -353,8 +353,8 @@ discard block |
||
| 353 | 353 | exit("Cannot write main MODX cache file! Make sure the assets/cache directory is writable!"); |
| 354 | 354 | } |
| 355 | 355 | |
| 356 | - if (!is_file($this->cachePath . '/.htaccess')) { |
|
| 357 | - file_put_contents($this->cachePath . '/.htaccess', "order deny,allow\ndeny from all\n"); |
|
| 356 | + if (!is_file($this->cachePath.'/.htaccess')) { |
|
| 357 | + file_put_contents($this->cachePath.'/.htaccess', "order deny,allow\ndeny from all\n"); |
|
| 358 | 358 | } |
| 359 | 359 | |
| 360 | 360 | // invoke OnCacheUpdate event |
@@ -371,7 +371,7 @@ discard block |
||
| 371 | 371 | |
| 372 | 372 | $source = trim($source); |
| 373 | 373 | if (substr($source, 0, 5) !== '<?php') { |
| 374 | - $source = '<?php ' . $source; |
|
| 374 | + $source = '<?php '.$source; |
|
| 375 | 375 | } |
| 376 | 376 | |
| 377 | 377 | $tokens = token_get_all($source); |
@@ -427,7 +427,7 @@ discard block |
||
| 427 | 427 | $_ .= $text; |
| 428 | 428 | } |
| 429 | 429 | } |
| 430 | - $source = preg_replace(array('@^<\?php@i', '|\s+|', '|<!--|', '|-->|', '|-->\s+<!--|'), array('', ' ', "\n" . '<!--', '-->' . "\n", '-->' . "\n" . '<!--'), $_); |
|
| 430 | + $source = preg_replace(array('@^<\?php@i', '|\s+|', '|<!--|', '|-->|', '|-->\s+<!--|'), array('', ' ', "\n".'<!--', '-->'."\n", '-->'."\n".'<!--'), $_); |
|
| 431 | 431 | $source = trim($source); |
| 432 | 432 | return $source; |
| 433 | 433 | } |
@@ -12,25 +12,25 @@ |
||
| 12 | 12 | * |
| 13 | 13 | */ |
| 14 | 14 | |
| 15 | -$msg =''; |
|
| 15 | +$msg = ''; |
|
| 16 | 16 | $pth = dirname(dirname(dirname(__FILE__)))."/install/"; |
| 17 | -$pth = str_replace("\\","/",$pth); |
|
| 18 | -if(isset($_GET["rminstall"])) { |
|
| 19 | - if(is_dir($pth)) { |
|
| 20 | - if(!rmdirRecursive($pth)) $msg="An error occured while attempting to remove the install folder"; |
|
| 17 | +$pth = str_replace("\\", "/", $pth); |
|
| 18 | +if (isset($_GET["rminstall"])) { |
|
| 19 | + if (is_dir($pth)) { |
|
| 20 | + if (!rmdirRecursive($pth)) $msg = "An error occured while attempting to remove the install folder"; |
|
| 21 | 21 | } |
| 22 | 22 | } |
| 23 | -if($msg) echo "<script>alert('".addslashes($msg)."');</script>"; |
|
| 23 | +if ($msg) echo "<script>alert('".addslashes($msg)."');</script>"; |
|
| 24 | 24 | echo "<script>window.location='../index.php?a=2';</script>"; |
| 25 | 25 | |
| 26 | 26 | // rmdirRecursive - detects symbollic links on unix |
| 27 | -function rmdirRecursive($path,$followLinks=false) { |
|
| 28 | - $dir = opendir($path) ; |
|
| 27 | +function rmdirRecursive($path, $followLinks = false){ |
|
| 28 | + $dir = opendir($path); |
|
| 29 | 29 | while ($entry = readdir($dir)) { |
| 30 | 30 | if (is_file("$path/$entry") || ((!$followLinks) && is_link("$path/$entry"))) { |
| 31 | - @unlink( "$path/$entry" ); |
|
| 31 | + @unlink("$path/$entry"); |
|
| 32 | 32 | } |
| 33 | - elseif (is_dir("$path/$entry") && $entry!='.' && $entry!='..') { |
|
| 33 | + elseif (is_dir("$path/$entry") && $entry != '.' && $entry != '..') { |
|
| 34 | 34 | rmdirRecursive("$path/$entry"); // recursive |
| 35 | 35 | } |
| 36 | 36 | } |
@@ -1,23 +1,23 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if(!isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { |
|
| 2 | +if (!isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { |
|
| 3 | 3 | header('HTTP/1.0 404 Not Found'); |
| 4 | 4 | exit('error'); |
| 5 | 5 | } |
| 6 | -define('IN_MANAGER_MODE', true); // we use this to make sure files are accessed through |
|
| 6 | +define('IN_MANAGER_MODE', true); // we use this to make sure files are accessed through |
|
| 7 | 7 | define('MODX_API_MODE', true); |
| 8 | -include_once(__DIR__ . '/../../index.php'); |
|
| 8 | +include_once(__DIR__.'/../../index.php'); |
|
| 9 | 9 | $modx->db->connect(); |
| 10 | 10 | $modx->getSettings(); |
| 11 | 11 | $modx->invokeEvent('OnManagerPageInit'); |
| 12 | 12 | $modx->loadExtension('ManagerAPI'); |
| 13 | 13 | $modx->loadExtension('phpass'); |
| 14 | 14 | |
| 15 | -$core_path = MODX_MANAGER_PATH . 'includes/'; |
|
| 15 | +$core_path = MODX_MANAGER_PATH.'includes/'; |
|
| 16 | 16 | // include_once the language file |
| 17 | 17 | $_lang = array(); |
| 18 | 18 | include_once("{$core_path}lang/english.inc.php"); |
| 19 | 19 | |
| 20 | -if($manager_language !== 'english' && is_file("{$core_path}lang/{$manager_language}.inc.php")) { |
|
| 20 | +if ($manager_language !== 'english' && is_file("{$core_path}lang/{$manager_language}.inc.php")) { |
|
| 21 | 21 | include_once("{$core_path}lang/{$manager_language}.inc.php"); |
| 22 | 22 | } |
| 23 | 23 | |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | include_once("{$core_path}log.class.inc.php"); |
| 26 | 26 | |
| 27 | 27 | // Initialize System Alert Message Queque |
| 28 | -if(!isset($_SESSION['SystemAlertMsgQueque'])) { |
|
| 28 | +if (!isset($_SESSION['SystemAlertMsgQueque'])) { |
|
| 29 | 29 | $_SESSION['SystemAlertMsgQueque'] = array(); |
| 30 | 30 | } |
| 31 | 31 | $SystemAlertMsgQueque = &$_SESSION['SystemAlertMsgQueque']; |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | $rs = $modx->db->select($fields, $from, $where); |
| 52 | 52 | $limit = $modx->db->getRecordCount($rs); |
| 53 | 53 | |
| 54 | -if($limit == 0 || $limit > 1) { |
|
| 54 | +if ($limit == 0 || $limit > 1) { |
|
| 55 | 55 | jsAlert($_lang['login_processor_unknown_user']); |
| 56 | 56 | return; |
| 57 | 57 | } |
@@ -73,32 +73,32 @@ discard block |
||
| 73 | 73 | |
| 74 | 74 | // get the user settings from the database |
| 75 | 75 | $rs = $modx->db->select('setting_name, setting_value', '[+prefix+]user_settings', "user='{$internalKey}' AND setting_value!=''"); |
| 76 | -while($row = $modx->db->getRow($rs)) { |
|
| 76 | +while ($row = $modx->db->getRow($rs)) { |
|
| 77 | 77 | extract($row); |
| 78 | 78 | ${$setting_name} = $setting_value; |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | // blocked due to number of login errors. |
| 82 | -if($failedlogins >= $failed_allowed && $blockeduntildate > time()) { |
|
| 82 | +if ($failedlogins >= $failed_allowed && $blockeduntildate > time()) { |
|
| 83 | 83 | @session_destroy(); |
| 84 | 84 | session_unset(); |
| 85 | - if($cip = getenv("HTTP_CLIENT_IP")) { |
|
| 85 | + if ($cip = getenv("HTTP_CLIENT_IP")) { |
|
| 86 | 86 | $ip = $cip; |
| 87 | - } elseif($cip = getenv("HTTP_X_FORWARDED_FOR")) { |
|
| 87 | + } elseif ($cip = getenv("HTTP_X_FORWARDED_FOR")) { |
|
| 88 | 88 | $ip = $cip; |
| 89 | - } elseif($cip = getenv("REMOTE_ADDR")) { |
|
| 89 | + } elseif ($cip = getenv("REMOTE_ADDR")) { |
|
| 90 | 90 | $ip = $cip; |
| 91 | 91 | } else { |
| 92 | 92 | $ip = "UNKNOWN"; |
| 93 | 93 | } |
| 94 | 94 | $log = new logHandler; |
| 95 | - $log->initAndWriteLog("Login Fail (Temporary Block)", $internalKey, $username, "119", $internalKey, "IP: " . $ip); |
|
| 95 | + $log->initAndWriteLog("Login Fail (Temporary Block)", $internalKey, $username, "119", $internalKey, "IP: ".$ip); |
|
| 96 | 96 | jsAlert($_lang['login_processor_many_failed_logins']); |
| 97 | 97 | return; |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | // blocked due to number of login errors, but get to try again |
| 101 | -if($failedlogins >= $failed_allowed && $blockeduntildate < time()) { |
|
| 101 | +if ($failedlogins >= $failed_allowed && $blockeduntildate < time()) { |
|
| 102 | 102 | $fields = array(); |
| 103 | 103 | $fields['failedlogincount'] = '0'; |
| 104 | 104 | $fields['blockeduntil'] = time() - 1; |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | // this user has been blocked by an admin, so no way he's loggin in! |
| 109 | -if($blocked == '1') { |
|
| 109 | +if ($blocked == '1') { |
|
| 110 | 110 | @session_destroy(); |
| 111 | 111 | session_unset(); |
| 112 | 112 | jsAlert($_lang['login_processor_blocked1']); |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | // blockuntil: this user has a block until date |
| 117 | -if($blockeduntildate > time()) { |
|
| 117 | +if ($blockeduntildate > time()) { |
|
| 118 | 118 | @session_destroy(); |
| 119 | 119 | session_unset(); |
| 120 | 120 | jsAlert($_lang['login_processor_blocked2']); |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | // blockafter: this user has a block after date |
| 125 | -if($blockedafterdate > 0 && $blockedafterdate < time()) { |
|
| 125 | +if ($blockedafterdate > 0 && $blockedafterdate < time()) { |
|
| 126 | 126 | @session_destroy(); |
| 127 | 127 | session_unset(); |
| 128 | 128 | jsAlert($_lang['login_processor_blocked3']); |
@@ -130,24 +130,24 @@ discard block |
||
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | // allowed ip |
| 133 | -if($allowed_ip) { |
|
| 134 | - if(($hostname = gethostbyaddr($_SERVER['REMOTE_ADDR'])) && ($hostname != $_SERVER['REMOTE_ADDR'])) { |
|
| 135 | - if(gethostbyname($hostname) != $_SERVER['REMOTE_ADDR']) { |
|
| 133 | +if ($allowed_ip) { |
|
| 134 | + if (($hostname = gethostbyaddr($_SERVER['REMOTE_ADDR'])) && ($hostname != $_SERVER['REMOTE_ADDR'])) { |
|
| 135 | + if (gethostbyname($hostname) != $_SERVER['REMOTE_ADDR']) { |
|
| 136 | 136 | jsAlert($_lang['login_processor_remotehost_ip']); |
| 137 | 137 | return; |
| 138 | 138 | } |
| 139 | 139 | } |
| 140 | - if(!in_array($_SERVER['REMOTE_ADDR'], array_filter(array_map('trim', explode(',', $allowed_ip))))) { |
|
| 140 | + if (!in_array($_SERVER['REMOTE_ADDR'], array_filter(array_map('trim', explode(',', $allowed_ip))))) { |
|
| 141 | 141 | jsAlert($_lang['login_processor_remote_ip']); |
| 142 | 142 | return; |
| 143 | 143 | } |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | // allowed days |
| 147 | -if($allowed_days) { |
|
| 147 | +if ($allowed_days) { |
|
| 148 | 148 | $date = getdate(); |
| 149 | 149 | $day = $date['wday'] + 1; |
| 150 | - if(strpos($allowed_days, $day) === false) { |
|
| 150 | + if (strpos($allowed_days, $day) === false) { |
|
| 151 | 151 | jsAlert($_lang['login_processor_date']); |
| 152 | 152 | return; |
| 153 | 153 | } |
@@ -164,33 +164,33 @@ discard block |
||
| 164 | 164 | |
| 165 | 165 | // check if plugin authenticated the user |
| 166 | 166 | $matchPassword = false; |
| 167 | -if(!isset($rt) || !$rt || (is_array($rt) && !in_array(true, $rt))) { |
|
| 167 | +if (!isset($rt) || !$rt || (is_array($rt) && !in_array(true, $rt))) { |
|
| 168 | 168 | // check user password - local authentication |
| 169 | 169 | $hashType = $modx->manager->getHashType($dbasePassword); |
| 170 | - if($hashType == 'phpass') { |
|
| 170 | + if ($hashType == 'phpass') { |
|
| 171 | 171 | $matchPassword = login($username, $_REQUEST['password'], $dbasePassword); |
| 172 | - } elseif($hashType == 'md5') { |
|
| 172 | + } elseif ($hashType == 'md5') { |
|
| 173 | 173 | $matchPassword = loginMD5($internalKey, $_REQUEST['password'], $dbasePassword, $username); |
| 174 | - } elseif($hashType == 'v1') { |
|
| 174 | + } elseif ($hashType == 'v1') { |
|
| 175 | 175 | $matchPassword = loginV1($internalKey, $_REQUEST['password'], $dbasePassword, $username); |
| 176 | 176 | } else { |
| 177 | 177 | $matchPassword = false; |
| 178 | 178 | } |
| 179 | -} else if($rt === true || (is_array($rt) && in_array(true, $rt))) { |
|
| 179 | +} else if ($rt === true || (is_array($rt) && in_array(true, $rt))) { |
|
| 180 | 180 | $matchPassword = true; |
| 181 | 181 | } |
| 182 | 182 | |
| 183 | -if(!$matchPassword) { |
|
| 183 | +if (!$matchPassword) { |
|
| 184 | 184 | jsAlert($_lang['login_processor_wrong_password']); |
| 185 | 185 | incrementFailedLoginCount($internalKey, $failedlogins, $failed_allowed, $blocked_minutes); |
| 186 | 186 | return; |
| 187 | 187 | } |
| 188 | 188 | |
| 189 | -if($modx->config['use_captcha'] == 1) { |
|
| 190 | - if(!isset ($_SESSION['veriword'])) { |
|
| 189 | +if ($modx->config['use_captcha'] == 1) { |
|
| 190 | + if (!isset ($_SESSION['veriword'])) { |
|
| 191 | 191 | jsAlert($_lang['login_processor_captcha_config']); |
| 192 | 192 | return; |
| 193 | - } elseif($_SESSION['veriword'] != $captcha_code) { |
|
| 193 | + } elseif ($_SESSION['veriword'] != $captcha_code) { |
|
| 194 | 194 | jsAlert($_lang['login_processor_bad_code']); |
| 195 | 195 | incrementFailedLoginCount($internalKey, $failedlogins, $failed_allowed, $blocked_minutes); |
| 196 | 196 | return; |
@@ -218,17 +218,17 @@ discard block |
||
| 218 | 218 | $_SESSION['mgrPermissions'] = $modx->db->getRow($rs); |
| 219 | 219 | |
| 220 | 220 | // successful login so reset fail count and update key values |
| 221 | -$modx->db->update('failedlogincount=0, ' . 'logincount=logincount+1, ' . 'lastlogin=thislogin, ' . 'thislogin=' . time() . ', ' . "sessionid='{$currentsessionid}'", '[+prefix+]user_attributes', "internalKey='{$internalKey}'"); |
|
| 221 | +$modx->db->update('failedlogincount=0, '.'logincount=logincount+1, '.'lastlogin=thislogin, '.'thislogin='.time().', '."sessionid='{$currentsessionid}'", '[+prefix+]user_attributes', "internalKey='{$internalKey}'"); |
|
| 222 | 222 | |
| 223 | 223 | // get user's document groups |
| 224 | 224 | $i = 0; |
| 225 | -$rs = $modx->db->select('uga.documentgroup', $modx->getFullTableName('member_groups') . ' ug |
|
| 226 | - INNER JOIN ' . $modx->getFullTableName('membergroup_access') . ' uga ON uga.membergroup=ug.user_group', "ug.member='{$internalKey}'"); |
|
| 225 | +$rs = $modx->db->select('uga.documentgroup', $modx->getFullTableName('member_groups').' ug |
|
| 226 | + INNER JOIN ' . $modx->getFullTableName('membergroup_access').' uga ON uga.membergroup=ug.user_group', "ug.member='{$internalKey}'"); |
|
| 227 | 227 | $_SESSION['mgrDocgroups'] = $modx->db->getColumn('documentgroup', $rs); |
| 228 | 228 | |
| 229 | 229 | $_SESSION['mgrToken'] = md5($currentsessionid); |
| 230 | 230 | |
| 231 | -if($rememberme == '1') { |
|
| 231 | +if ($rememberme == '1') { |
|
| 232 | 232 | $_SESSION['modx.mgr.session.cookie.lifetime'] = intval($modx->config['session.cookie.lifetime']); |
| 233 | 233 | |
| 234 | 234 | // Set a cookie separate from the session cookie with the username in it. |
@@ -236,7 +236,7 @@ discard block |
||
| 236 | 236 | global $https_port; |
| 237 | 237 | |
| 238 | 238 | $secure = ((isset ($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on') || $_SERVER['SERVER_PORT'] == $https_port); |
| 239 | - if(version_compare(PHP_VERSION, '5.2', '<')) { |
|
| 239 | + if (version_compare(PHP_VERSION, '5.2', '<')) { |
|
| 240 | 240 | setcookie('modx_remember_manager', $_SESSION['mgrShortname'], time() + 60 * 60 * 24 * 365, MODX_BASE_URL, '; HttpOnly', $secure); |
| 241 | 241 | } else { |
| 242 | 242 | setcookie('modx_remember_manager', $_SESSION['mgrShortname'], time() + 60 * 60 * 24 * 365, MODX_BASE_URL, NULL, $secure, true); |
@@ -251,9 +251,9 @@ discard block |
||
| 251 | 251 | // Check if user already has an active session, if not check if user pressed logout end of last session |
| 252 | 252 | $rs = $modx->db->select('lasthit', $modx->getFullTableName('active_user_sessions'), "internalKey='{$internalKey}'"); |
| 253 | 253 | $activeSession = $modx->db->getValue($rs); |
| 254 | -if(!$activeSession) { |
|
| 254 | +if (!$activeSession) { |
|
| 255 | 255 | $rs = $modx->db->select('lasthit', $modx->getFullTableName('active_users'), "internalKey='{$internalKey}' AND action != 8"); |
| 256 | - if($lastHit = $modx->db->getValue($rs)) { |
|
| 256 | + if ($lastHit = $modx->db->getValue($rs)) { |
|
| 257 | 257 | $_SESSION['show_logout_reminder'] = array( |
| 258 | 258 | 'type' => 'logout_reminder', |
| 259 | 259 | 'lastHit' => $lastHit |
@@ -275,16 +275,16 @@ discard block |
||
| 275 | 275 | // check if we should redirect user to a web page |
| 276 | 276 | $rs = $modx->db->select('setting_value', '[+prefix+]user_settings', "user='{$internalKey}' AND setting_name='manager_login_startup'"); |
| 277 | 277 | $id = intval($modx->db->getValue($rs)); |
| 278 | -if($id > 0) { |
|
| 279 | - $header = 'Location: ' . $modx->makeUrl($id, '', '', 'full'); |
|
| 280 | - if($_POST['ajax'] == 1) { |
|
| 278 | +if ($id > 0) { |
|
| 279 | + $header = 'Location: '.$modx->makeUrl($id, '', '', 'full'); |
|
| 280 | + if ($_POST['ajax'] == 1) { |
|
| 281 | 281 | echo $header; |
| 282 | 282 | } else { |
| 283 | 283 | header($header); |
| 284 | 284 | } |
| 285 | 285 | } else { |
| 286 | - $header = 'Location: ' . MODX_MANAGER_URL; |
|
| 287 | - if($_POST['ajax'] == 1) { |
|
| 286 | + $header = 'Location: '.MODX_MANAGER_URL; |
|
| 287 | + if ($_POST['ajax'] == 1) { |
|
| 288 | 288 | echo $header; |
| 289 | 289 | } else { |
| 290 | 290 | header($header); |
@@ -292,35 +292,35 @@ discard block |
||
| 292 | 292 | } |
| 293 | 293 | |
| 294 | 294 | // show javascript alert |
| 295 | -function jsAlert($msg) { |
|
| 295 | +function jsAlert($msg){ |
|
| 296 | 296 | global $modx; |
| 297 | - if($_POST['ajax'] != 1) { |
|
| 298 | - echo "<script>window.setTimeout(\"alert('" . addslashes($modx->db->escape($msg)) . "')\",10);history.go(-1)</script>"; |
|
| 297 | + if ($_POST['ajax'] != 1) { |
|
| 298 | + echo "<script>window.setTimeout(\"alert('".addslashes($modx->db->escape($msg))."')\",10);history.go(-1)</script>"; |
|
| 299 | 299 | } else { |
| 300 | - echo $msg . "\n"; |
|
| 300 | + echo $msg."\n"; |
|
| 301 | 301 | } |
| 302 | 302 | } |
| 303 | 303 | |
| 304 | -function login($username, $givenPassword, $dbasePassword) { |
|
| 304 | +function login($username, $givenPassword, $dbasePassword){ |
|
| 305 | 305 | global $modx; |
| 306 | 306 | return $modx->phpass->CheckPassword($givenPassword, $dbasePassword); |
| 307 | 307 | } |
| 308 | 308 | |
| 309 | -function loginV1($internalKey, $givenPassword, $dbasePassword, $username) { |
|
| 309 | +function loginV1($internalKey, $givenPassword, $dbasePassword, $username){ |
|
| 310 | 310 | global $modx; |
| 311 | 311 | |
| 312 | 312 | $user_algo = $modx->manager->getV1UserHashAlgorithm($internalKey); |
| 313 | 313 | |
| 314 | - if(!isset($modx->config['pwd_hash_algo']) || empty($modx->config['pwd_hash_algo'])) { |
|
| 314 | + if (!isset($modx->config['pwd_hash_algo']) || empty($modx->config['pwd_hash_algo'])) { |
|
| 315 | 315 | $modx->config['pwd_hash_algo'] = 'UNCRYPT'; |
| 316 | 316 | } |
| 317 | 317 | |
| 318 | - if($user_algo !== $modx->config['pwd_hash_algo']) { |
|
| 318 | + if ($user_algo !== $modx->config['pwd_hash_algo']) { |
|
| 319 | 319 | $bk_pwd_hash_algo = $modx->config['pwd_hash_algo']; |
| 320 | 320 | $modx->config['pwd_hash_algo'] = $user_algo; |
| 321 | 321 | } |
| 322 | 322 | |
| 323 | - if($dbasePassword != $modx->manager->genV1Hash($givenPassword, $internalKey)) { |
|
| 323 | + if ($dbasePassword != $modx->manager->genV1Hash($givenPassword, $internalKey)) { |
|
| 324 | 324 | return false; |
| 325 | 325 | } |
| 326 | 326 | |
@@ -329,17 +329,17 @@ discard block |
||
| 329 | 329 | return true; |
| 330 | 330 | } |
| 331 | 331 | |
| 332 | -function loginMD5($internalKey, $givenPassword, $dbasePassword, $username) { |
|
| 332 | +function loginMD5($internalKey, $givenPassword, $dbasePassword, $username){ |
|
| 333 | 333 | global $modx; |
| 334 | 334 | |
| 335 | - if($dbasePassword != md5($givenPassword)) { |
|
| 335 | + if ($dbasePassword != md5($givenPassword)) { |
|
| 336 | 336 | return false; |
| 337 | 337 | } |
| 338 | 338 | updateNewHash($username, $givenPassword); |
| 339 | 339 | return true; |
| 340 | 340 | } |
| 341 | 341 | |
| 342 | -function updateNewHash($username, $password) { |
|
| 342 | +function updateNewHash($username, $password){ |
|
| 343 | 343 | global $modx; |
| 344 | 344 | |
| 345 | 345 | $field = array(); |
@@ -347,23 +347,23 @@ discard block |
||
| 347 | 347 | $modx->db->update($field, '[+prefix+]manager_users', "username='{$username}'"); |
| 348 | 348 | } |
| 349 | 349 | |
| 350 | -function incrementFailedLoginCount($internalKey, $failedlogins, $failed_allowed, $blocked_minutes) { |
|
| 350 | +function incrementFailedLoginCount($internalKey, $failedlogins, $failed_allowed, $blocked_minutes){ |
|
| 351 | 351 | global $modx; |
| 352 | 352 | |
| 353 | 353 | $failedlogins += 1; |
| 354 | 354 | |
| 355 | 355 | $fields = array('failedlogincount' => $failedlogins); |
| 356 | - if($failedlogins >= $failed_allowed) //block user for too many fail attempts |
|
| 356 | + if ($failedlogins >= $failed_allowed) //block user for too many fail attempts |
|
| 357 | 357 | { |
| 358 | 358 | $fields['blockeduntil'] = time() + ($blocked_minutes * 60); |
| 359 | 359 | } |
| 360 | 360 | |
| 361 | 361 | $modx->db->update($fields, '[+prefix+]user_attributes', "internalKey='{$internalKey}'"); |
| 362 | 362 | |
| 363 | - if($failedlogins < $failed_allowed) { |
|
| 363 | + if ($failedlogins < $failed_allowed) { |
|
| 364 | 364 | //sleep to help prevent brute force attacks |
| 365 | 365 | $sleep = (int) $failedlogins / 2; |
| 366 | - if($sleep > 5) { |
|
| 366 | + if ($sleep > 5) { |
|
| 367 | 367 | $sleep = 5; |
| 368 | 368 | } |
| 369 | 369 | sleep($sleep); |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | $sitemenu['site'] = array( |
| 22 | 22 | 'site', |
| 23 | 23 | 'main', |
| 24 | - '<i class="fa fa-home"></i>' . $_lang['home'], |
|
| 24 | + '<i class="fa fa-home"></i>'.$_lang['home'], |
|
| 25 | 25 | 'index.php?a=2', |
| 26 | 26 | $_lang['home'], |
| 27 | 27 | '', |
@@ -32,11 +32,11 @@ discard block |
||
| 32 | 32 | 'active' |
| 33 | 33 | ); |
| 34 | 34 | |
| 35 | -if($modx->hasPermission('edit_template') || $modx->hasPermission('edit_snippet') || $modx->hasPermission('edit_chunk') || $modx->hasPermission('edit_plugin') || $modx->hasPermission('file_manager')) {
|
|
| 35 | +if ($modx->hasPermission('edit_template') || $modx->hasPermission('edit_snippet') || $modx->hasPermission('edit_chunk') || $modx->hasPermission('edit_plugin') || $modx->hasPermission('file_manager')) {
|
|
| 36 | 36 | $sitemenu['elements'] = array( |
| 37 | 37 | 'elements', |
| 38 | 38 | 'main', |
| 39 | - '<i class="fa fa-th"></i>' . $_lang['elements'], |
|
| 39 | + '<i class="fa fa-th"></i>'.$_lang['elements'], |
|
| 40 | 40 | 'javascript:;', |
| 41 | 41 | $_lang['elements'], |
| 42 | 42 | ' return false;', |
@@ -48,11 +48,11 @@ discard block |
||
| 48 | 48 | ); |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | -if($modx->hasPermission('exec_module')) {
|
|
| 51 | +if ($modx->hasPermission('exec_module')) {
|
|
| 52 | 52 | $sitemenu['modules'] = array( |
| 53 | 53 | 'modules', |
| 54 | 54 | 'main', |
| 55 | - '<i class="'.$_style['icons_modules'] .'"></i>' . $_lang['modules'], |
|
| 55 | + '<i class="'.$_style['icons_modules'].'"></i>'.$_lang['modules'], |
|
| 56 | 56 | 'javascript:;', |
| 57 | 57 | $_lang['modules'], |
| 58 | 58 | ' return false;', |
@@ -64,11 +64,11 @@ discard block |
||
| 64 | 64 | ); |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | -if($modx->hasPermission('edit_user') || $modx->hasPermission('edit_web_user') || $modx->hasPermission('edit_role') || $modx->hasPermission('access_permissions') || $modx->hasPermission('web_access_permissions')) {
|
|
| 67 | +if ($modx->hasPermission('edit_user') || $modx->hasPermission('edit_web_user') || $modx->hasPermission('edit_role') || $modx->hasPermission('access_permissions') || $modx->hasPermission('web_access_permissions')) {
|
|
| 68 | 68 | $sitemenu['users'] = array( |
| 69 | 69 | 'users', |
| 70 | 70 | 'main', |
| 71 | - '<i class="fa fa-users"></i>' . $_lang['users'], |
|
| 71 | + '<i class="fa fa-users"></i>'.$_lang['users'], |
|
| 72 | 72 | 'javascript:;', |
| 73 | 73 | $_lang['users'], |
| 74 | 74 | ' return false;', |
@@ -80,11 +80,11 @@ discard block |
||
| 80 | 80 | ); |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | -if($modx->hasPermission('empty_cache') || $modx->hasPermission('bk_manager') || $modx->hasPermission('remove_locks') || $modx->hasPermission('import_static') || $modx->hasPermission('export_static')) {
|
|
| 83 | +if ($modx->hasPermission('empty_cache') || $modx->hasPermission('bk_manager') || $modx->hasPermission('remove_locks') || $modx->hasPermission('import_static') || $modx->hasPermission('export_static')) {
|
|
| 84 | 84 | $sitemenu['tools'] = array( |
| 85 | 85 | 'tools', |
| 86 | 86 | 'main', |
| 87 | - '<i class="fa fa-wrench"></i>' . $_lang['tools'], |
|
| 87 | + '<i class="fa fa-wrench"></i>'.$_lang['tools'], |
|
| 88 | 88 | 'javascript:;', |
| 89 | 89 | $_lang['tools'], |
| 90 | 90 | ' return false;', |
@@ -97,12 +97,12 @@ discard block |
||
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | $tab = 0; |
| 100 | -if($modx->hasPermission('edit_template')) {
|
|
| 100 | +if ($modx->hasPermission('edit_template')) {
|
|
| 101 | 101 | $sitemenu['element_templates'] = array( |
| 102 | 102 | 'element_templates', |
| 103 | 103 | 'elements', |
| 104 | - '<i class="fa fa-newspaper-o"></i>' . $_lang['manage_templates'] . '<i class="fa fa-angle-right toggle"></i>', |
|
| 105 | - 'index.php?a=76&tab=' . $tab++, |
|
| 104 | + '<i class="fa fa-newspaper-o"></i>'.$_lang['manage_templates'].'<i class="fa fa-angle-right toggle"></i>', |
|
| 105 | + 'index.php?a=76&tab='.$tab++, |
|
| 106 | 106 | $_lang['manage_templates'], |
| 107 | 107 | '', |
| 108 | 108 | 'new_template,edit_template', |
@@ -112,12 +112,12 @@ discard block |
||
| 112 | 112 | 'dropdown-toggle' |
| 113 | 113 | ); |
| 114 | 114 | } |
| 115 | -if($modx->hasPermission('edit_template') && $modx->hasPermission('edit_snippet') && $modx->hasPermission('edit_chunk') && $modx->hasPermission('edit_plugin')) {
|
|
| 115 | +if ($modx->hasPermission('edit_template') && $modx->hasPermission('edit_snippet') && $modx->hasPermission('edit_chunk') && $modx->hasPermission('edit_plugin')) {
|
|
| 116 | 116 | $sitemenu['element_tplvars'] = array( |
| 117 | 117 | 'element_tplvars', |
| 118 | 118 | 'elements', |
| 119 | - '<i class="fa fa-list-alt"></i>' . $_lang['tmplvars'] . '<i class="fa fa-angle-right toggle"></i>', |
|
| 120 | - 'index.php?a=76&tab=' . $tab++, |
|
| 119 | + '<i class="fa fa-list-alt"></i>'.$_lang['tmplvars'].'<i class="fa fa-angle-right toggle"></i>', |
|
| 120 | + 'index.php?a=76&tab='.$tab++, |
|
| 121 | 121 | $_lang['tmplvars'], |
| 122 | 122 | '', |
| 123 | 123 | 'new_template,edit_template', |
@@ -127,12 +127,12 @@ discard block |
||
| 127 | 127 | 'dropdown-toggle' |
| 128 | 128 | ); |
| 129 | 129 | } |
| 130 | -if($modx->hasPermission('edit_chunk')) {
|
|
| 130 | +if ($modx->hasPermission('edit_chunk')) {
|
|
| 131 | 131 | $sitemenu['element_htmlsnippets'] = array( |
| 132 | 132 | 'element_htmlsnippets', |
| 133 | 133 | 'elements', |
| 134 | - '<i class="fa fa-th-large"></i>' . $_lang['manage_htmlsnippets'] . '<i class="fa fa-angle-right toggle"></i>', |
|
| 135 | - 'index.php?a=76&tab=' . $tab++, |
|
| 134 | + '<i class="fa fa-th-large"></i>'.$_lang['manage_htmlsnippets'].'<i class="fa fa-angle-right toggle"></i>', |
|
| 135 | + 'index.php?a=76&tab='.$tab++, |
|
| 136 | 136 | $_lang['manage_htmlsnippets'], |
| 137 | 137 | '', |
| 138 | 138 | 'new_chunk,edit_chunk', |
@@ -142,12 +142,12 @@ discard block |
||
| 142 | 142 | 'dropdown-toggle' |
| 143 | 143 | ); |
| 144 | 144 | } |
| 145 | -if($modx->hasPermission('edit_snippet')) {
|
|
| 145 | +if ($modx->hasPermission('edit_snippet')) {
|
|
| 146 | 146 | $sitemenu['element_snippets'] = array( |
| 147 | 147 | 'element_snippets', |
| 148 | 148 | 'elements', |
| 149 | - '<i class="fa fa-code"></i>' . $_lang['manage_snippets'] . '<i class="fa fa-angle-right toggle"></i>', |
|
| 150 | - 'index.php?a=76&tab=' . $tab++, |
|
| 149 | + '<i class="fa fa-code"></i>'.$_lang['manage_snippets'].'<i class="fa fa-angle-right toggle"></i>', |
|
| 150 | + 'index.php?a=76&tab='.$tab++, |
|
| 151 | 151 | $_lang['manage_snippets'], |
| 152 | 152 | '', |
| 153 | 153 | 'new_snippet,edit_snippet', |
@@ -157,12 +157,12 @@ discard block |
||
| 157 | 157 | 'dropdown-toggle' |
| 158 | 158 | ); |
| 159 | 159 | } |
| 160 | -if($modx->hasPermission('edit_plugin')) {
|
|
| 160 | +if ($modx->hasPermission('edit_plugin')) {
|
|
| 161 | 161 | $sitemenu['element_plugins'] = array( |
| 162 | 162 | 'element_plugins', |
| 163 | 163 | 'elements', |
| 164 | - '<i class="fa fa-plug"></i>' . $_lang['manage_plugins'] . '<i class="fa fa-angle-right toggle"></i>', |
|
| 165 | - 'index.php?a=76&tab=' . $tab++, |
|
| 164 | + '<i class="fa fa-plug"></i>'.$_lang['manage_plugins'].'<i class="fa fa-angle-right toggle"></i>', |
|
| 165 | + 'index.php?a=76&tab='.$tab++, |
|
| 166 | 166 | $_lang['manage_plugins'], |
| 167 | 167 | '', |
| 168 | 168 | 'new_plugin,edit_plugin', |
@@ -174,11 +174,11 @@ discard block |
||
| 174 | 174 | } |
| 175 | 175 | //$sitemenu['element_categories'] = array('element_categories','elements',$_lang['element_categories'],'index.php?a=76&tab=5',$_lang['element_categories'],'','new_template,edit_template,new_snippet,edit_snippet,new_chunk,edit_chunk,new_plugin,edit_plugin','main',1,60,'');
|
| 176 | 176 | |
| 177 | -if($modx->hasPermission('file_manager')) {
|
|
| 177 | +if ($modx->hasPermission('file_manager')) {
|
|
| 178 | 178 | $sitemenu['manage_files'] = array( |
| 179 | 179 | 'manage_files', |
| 180 | 180 | 'elements', |
| 181 | - '<i class="fa fa-folder-open-o"></i>' . $_lang['manage_files'], |
|
| 181 | + '<i class="fa fa-folder-open-o"></i>'.$_lang['manage_files'], |
|
| 182 | 182 | 'index.php?a=31', |
| 183 | 183 | $_lang['manage_files'], |
| 184 | 184 | '', |
@@ -189,11 +189,11 @@ discard block |
||
| 189 | 189 | '' |
| 190 | 190 | ); |
| 191 | 191 | } |
| 192 | -if($modx->hasPermission('category_manager')) {
|
|
| 192 | +if ($modx->hasPermission('category_manager')) {
|
|
| 193 | 193 | $sitemenu['manage_categories'] = array( |
| 194 | 194 | 'manage_categories', |
| 195 | 195 | 'elements', |
| 196 | - '<i class="fa fa-object-group"></i>' . $_lang['manage_categories'], |
|
| 196 | + '<i class="fa fa-object-group"></i>'.$_lang['manage_categories'], |
|
| 197 | 197 | 'index.php?a=120', |
| 198 | 198 | $_lang['manage_categories'], |
| 199 | 199 | '', |
@@ -206,11 +206,11 @@ discard block |
||
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | // Modules Menu Items |
| 209 | -if($modx->hasPermission('new_module') || $modx->hasPermission('edit_module') || $modx->hasPermission('save_module')) {
|
|
| 209 | +if ($modx->hasPermission('new_module') || $modx->hasPermission('edit_module') || $modx->hasPermission('save_module')) {
|
|
| 210 | 210 | $sitemenu['new_module'] = array( |
| 211 | 211 | 'new_module', |
| 212 | 212 | 'modules', |
| 213 | - '<i class="'.$_style['icons_modules'] .'"></i>' . $_lang['module_management'], |
|
| 213 | + '<i class="'.$_style['icons_modules'].'"></i>'.$_lang['module_management'], |
|
| 214 | 214 | 'index.php?a=106', |
| 215 | 215 | $_lang['module_management'], |
| 216 | 216 | '', |
@@ -222,24 +222,24 @@ discard block |
||
| 222 | 222 | ); |
| 223 | 223 | } |
| 224 | 224 | |
| 225 | -if($modx->hasPermission('exec_module')) {
|
|
| 226 | - if($_SESSION['mgrRole'] != 1 && !empty($modx->config['use_udperms'])) {
|
|
| 225 | +if ($modx->hasPermission('exec_module')) {
|
|
| 226 | + if ($_SESSION['mgrRole'] != 1 && !empty($modx->config['use_udperms'])) {
|
|
| 227 | 227 | $rs = $modx->db->query('SELECT DISTINCT sm.id, sm.name, sm.icon, mg.member
|
| 228 | - FROM ' . $modx->getFullTableName('site_modules') . ' AS sm
|
|
| 229 | - LEFT JOIN ' . $modx->getFullTableName('site_module_access') . ' AS sma ON sma.module = sm.id
|
|
| 230 | - LEFT JOIN ' . $modx->getFullTableName('member_groups') . ' AS mg ON sma.usergroup = mg.user_group
|
|
| 231 | - WHERE (mg.member IS NULL OR mg.member = ' . $modx->getLoginUserID() . ') AND sm.disabled != 1 AND sm.locked != 1 |
|
| 228 | + FROM ' . $modx->getFullTableName('site_modules').' AS sm
|
|
| 229 | + LEFT JOIN ' . $modx->getFullTableName('site_module_access').' AS sma ON sma.module = sm.id
|
|
| 230 | + LEFT JOIN ' . $modx->getFullTableName('member_groups').' AS mg ON sma.usergroup = mg.user_group
|
|
| 231 | + WHERE (mg.member IS NULL OR mg.member = ' . $modx->getLoginUserID().') AND sm.disabled != 1 AND sm.locked != 1 |
|
| 232 | 232 | ORDER BY sm.name'); |
| 233 | 233 | } else {
|
| 234 | 234 | $rs = $modx->db->select('*', $modx->getFullTableName('site_modules'), 'disabled != 1', 'name');
|
| 235 | 235 | } |
| 236 | - if($modx->db->getRecordCount($rs)) {
|
|
| 236 | + if ($modx->db->getRecordCount($rs)) {
|
|
| 237 | 237 | while ($row = $modx->db->getRow($rs)) {
|
| 238 | - $sitemenu['module' . $row['id']] = array( |
|
| 239 | - 'module' . $row['id'], |
|
| 238 | + $sitemenu['module'.$row['id']] = array( |
|
| 239 | + 'module'.$row['id'], |
|
| 240 | 240 | 'modules', |
| 241 | - ($row['icon'] != '' ? '<i class="'.$row['icon'].'"></i>' : '<i class="'.$_style['icons_module'].'"></i>') . $row['name'], |
|
| 242 | - 'index.php?a=112&id=' . $row['id'], |
|
| 241 | + ($row['icon'] != '' ? '<i class="'.$row['icon'].'"></i>' : '<i class="'.$_style['icons_module'].'"></i>').$row['name'], |
|
| 242 | + 'index.php?a=112&id='.$row['id'], |
|
| 243 | 243 | $row['name'], |
| 244 | 244 | '', |
| 245 | 245 | '', |
@@ -254,11 +254,11 @@ discard block |
||
| 254 | 254 | |
| 255 | 255 | // security menu items (users) |
| 256 | 256 | |
| 257 | -if($modx->hasPermission('edit_user')) {
|
|
| 257 | +if ($modx->hasPermission('edit_user')) {
|
|
| 258 | 258 | $sitemenu['user_management_title'] = array( |
| 259 | 259 | 'user_management_title', |
| 260 | 260 | 'users', |
| 261 | - '<i class="fa fa fa-user"></i>' . $_lang['user_management_title'] . '<i class="fa fa-angle-right toggle"></i>', |
|
| 261 | + '<i class="fa fa fa-user"></i>'.$_lang['user_management_title'].'<i class="fa fa-angle-right toggle"></i>', |
|
| 262 | 262 | 'index.php?a=75', |
| 263 | 263 | $_lang['user_management_title'], |
| 264 | 264 | '', |
@@ -270,11 +270,11 @@ discard block |
||
| 270 | 270 | ); |
| 271 | 271 | } |
| 272 | 272 | |
| 273 | -if($modx->hasPermission('edit_web_user')) {
|
|
| 273 | +if ($modx->hasPermission('edit_web_user')) {
|
|
| 274 | 274 | $sitemenu['web_user_management_title'] = array( |
| 275 | 275 | 'web_user_management_title', |
| 276 | 276 | 'users', |
| 277 | - '<i class="fa fa-users"></i>' . $_lang['web_user_management_title'] . '<i class="fa fa-angle-right toggle"></i>', |
|
| 277 | + '<i class="fa fa-users"></i>'.$_lang['web_user_management_title'].'<i class="fa fa-angle-right toggle"></i>', |
|
| 278 | 278 | 'index.php?a=99', |
| 279 | 279 | $_lang['web_user_management_title'], |
| 280 | 280 | '', |
@@ -286,11 +286,11 @@ discard block |
||
| 286 | 286 | ); |
| 287 | 287 | } |
| 288 | 288 | |
| 289 | -if($modx->hasPermission('edit_role')) {
|
|
| 289 | +if ($modx->hasPermission('edit_role')) {
|
|
| 290 | 290 | $sitemenu['role_management_title'] = array( |
| 291 | 291 | 'role_management_title', |
| 292 | 292 | 'users', |
| 293 | - '<i class="fa fa-legal"></i>' . $_lang['role_management_title'], |
|
| 293 | + '<i class="fa fa-legal"></i>'.$_lang['role_management_title'], |
|
| 294 | 294 | 'index.php?a=86', |
| 295 | 295 | $_lang['role_management_title'], |
| 296 | 296 | '', |
@@ -302,11 +302,11 @@ discard block |
||
| 302 | 302 | ); |
| 303 | 303 | } |
| 304 | 304 | |
| 305 | -if($modx->hasPermission('access_permissions')) {
|
|
| 305 | +if ($modx->hasPermission('access_permissions')) {
|
|
| 306 | 306 | $sitemenu['manager_permissions'] = array( |
| 307 | 307 | 'manager_permissions', |
| 308 | 308 | 'users', |
| 309 | - '<i class="fa fa-male"></i>' . $_lang['manager_permissions'], |
|
| 309 | + '<i class="fa fa-male"></i>'.$_lang['manager_permissions'], |
|
| 310 | 310 | 'index.php?a=40', |
| 311 | 311 | $_lang['manager_permissions'], |
| 312 | 312 | '', |
@@ -318,11 +318,11 @@ discard block |
||
| 318 | 318 | ); |
| 319 | 319 | } |
| 320 | 320 | |
| 321 | -if($modx->hasPermission('web_access_permissions')) {
|
|
| 321 | +if ($modx->hasPermission('web_access_permissions')) {
|
|
| 322 | 322 | $sitemenu['web_permissions'] = array( |
| 323 | 323 | 'web_permissions', |
| 324 | 324 | 'users', |
| 325 | - '<i class="fa fa-universal-access"></i>' . $_lang['web_permissions'], |
|
| 325 | + '<i class="fa fa-universal-access"></i>'.$_lang['web_permissions'], |
|
| 326 | 326 | 'index.php?a=91', |
| 327 | 327 | $_lang['web_permissions'], |
| 328 | 328 | '', |
@@ -339,7 +339,7 @@ discard block |
||
| 339 | 339 | $sitemenu['refresh_site'] = array( |
| 340 | 340 | 'refresh_site', |
| 341 | 341 | 'tools', |
| 342 | - '<i class="fa fa-recycle"></i>' . $_lang['refresh_site'], |
|
| 342 | + '<i class="fa fa-recycle"></i>'.$_lang['refresh_site'], |
|
| 343 | 343 | 'index.php?a=26', |
| 344 | 344 | $_lang['refresh_site'], |
| 345 | 345 | '', |
@@ -353,7 +353,7 @@ discard block |
||
| 353 | 353 | 'a', // tag |
| 354 | 354 | 'javascript:;', // href |
| 355 | 355 | 'btn btn-secondary', // class or btn-success |
| 356 | - 'modx.popup({url:\'index.php?a=26\', title:\'' . $_lang['refresh_site'] . '\', icon: \'fa-recycle\', iframe: \'ajax\', selector: \'.tab-page>.container\', position: \'right top\', width: \'auto\', maxheight: \'50%\', wrap: \'body\' })', // onclick
|
|
| 356 | + 'modx.popup({url:\'index.php?a=26\', title:\''.$_lang['refresh_site'].'\', icon: \'fa-recycle\', iframe: \'ajax\', selector: \'.tab-page>.container\', position: \'right top\', width: \'auto\', maxheight: \'50%\', wrap: \'body\' })', // onclick
|
|
| 357 | 357 | $_lang['refresh_site'], // title |
| 358 | 358 | '<i class="fa fa-recycle"></i>' // innerHTML |
| 359 | 359 | ) |
@@ -363,7 +363,7 @@ discard block |
||
| 363 | 363 | $sitemenu['search'] = array( |
| 364 | 364 | 'search', |
| 365 | 365 | 'tools', |
| 366 | - '<i class="fa fa-search"></i>' . $_lang['search'], |
|
| 366 | + '<i class="fa fa-search"></i>'.$_lang['search'], |
|
| 367 | 367 | 'index.php?a=71', |
| 368 | 368 | $_lang['search'], |
| 369 | 369 | '', |
@@ -374,11 +374,11 @@ discard block |
||
| 374 | 374 | '' |
| 375 | 375 | ); |
| 376 | 376 | |
| 377 | -if($modx->hasPermission('bk_manager')) {
|
|
| 377 | +if ($modx->hasPermission('bk_manager')) {
|
|
| 378 | 378 | $sitemenu['bk_manager'] = array( |
| 379 | 379 | 'bk_manager', |
| 380 | 380 | 'tools', |
| 381 | - '<i class="fa fa-database"></i>' . $_lang['bk_manager'], |
|
| 381 | + '<i class="fa fa-database"></i>'.$_lang['bk_manager'], |
|
| 382 | 382 | 'index.php?a=93', |
| 383 | 383 | $_lang['bk_manager'], |
| 384 | 384 | '', |
@@ -390,11 +390,11 @@ discard block |
||
| 390 | 390 | ); |
| 391 | 391 | } |
| 392 | 392 | |
| 393 | -if($modx->hasPermission('remove_locks')) {
|
|
| 393 | +if ($modx->hasPermission('remove_locks')) {
|
|
| 394 | 394 | $sitemenu['remove_locks'] = array( |
| 395 | 395 | 'remove_locks', |
| 396 | 396 | 'tools', |
| 397 | - '<i class="fa fa-hourglass"></i>' . $_lang['remove_locks'], |
|
| 397 | + '<i class="fa fa-hourglass"></i>'.$_lang['remove_locks'], |
|
| 398 | 398 | 'javascript:modx.removeLocks();', |
| 399 | 399 | $_lang['remove_locks'], |
| 400 | 400 | '', |
@@ -406,11 +406,11 @@ discard block |
||
| 406 | 406 | ); |
| 407 | 407 | } |
| 408 | 408 | |
| 409 | -if($modx->hasPermission('import_static')) {
|
|
| 409 | +if ($modx->hasPermission('import_static')) {
|
|
| 410 | 410 | $sitemenu['import_site'] = array( |
| 411 | 411 | 'import_site', |
| 412 | 412 | 'tools', |
| 413 | - '<i class="fa fa-upload"></i>' . $_lang['import_site'], |
|
| 413 | + '<i class="fa fa-upload"></i>'.$_lang['import_site'], |
|
| 414 | 414 | 'index.php?a=95', |
| 415 | 415 | $_lang['import_site'], |
| 416 | 416 | '', |
@@ -422,11 +422,11 @@ discard block |
||
| 422 | 422 | ); |
| 423 | 423 | } |
| 424 | 424 | |
| 425 | -if($modx->hasPermission('export_static')) {
|
|
| 425 | +if ($modx->hasPermission('export_static')) {
|
|
| 426 | 426 | $sitemenu['export_site'] = array( |
| 427 | 427 | 'export_site', |
| 428 | 428 | 'tools', |
| 429 | - '<i class="fa fa-download"></i>' . $_lang['export_site'], |
|
| 429 | + '<i class="fa fa-download"></i>'.$_lang['export_site'], |
|
| 430 | 430 | 'index.php?a=83', |
| 431 | 431 | $_lang['export_site'], |
| 432 | 432 | '', |
@@ -439,20 +439,20 @@ discard block |
||
| 439 | 439 | } |
| 440 | 440 | |
| 441 | 441 | $menu = $modx->invokeEvent("OnManagerMenuPrerender", array('menu' => $sitemenu));
|
| 442 | -if(is_array($menu)) {
|
|
| 442 | +if (is_array($menu)) {
|
|
| 443 | 443 | $newmenu = array(); |
| 444 | - foreach($menu as $item){
|
|
| 445 | - if(is_array(unserialize($item))){
|
|
| 444 | + foreach ($menu as $item) {
|
|
| 445 | + if (is_array(unserialize($item))) {
|
|
| 446 | 446 | $newmenu = array_merge($newmenu, unserialize($item)); |
| 447 | 447 | } |
| 448 | 448 | } |
| 449 | - if(count($newmenu)> 0) $sitemenu = $newmenu; |
|
| 449 | + if (count($newmenu) > 0) $sitemenu = $newmenu; |
|
| 450 | 450 | } |
| 451 | 451 | |
| 452 | -if(file_exists(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/includes/menu.class.inc.php')) {
|
|
| 453 | - include_once(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/includes/menu.class.inc.php'); |
|
| 452 | +if (file_exists(MODX_MANAGER_PATH.'media/style/'.$modx->config['manager_theme'].'/includes/menu.class.inc.php')) {
|
|
| 453 | + include_once(MODX_MANAGER_PATH.'media/style/'.$modx->config['manager_theme'].'/includes/menu.class.inc.php'); |
|
| 454 | 454 | } else {
|
| 455 | - include_once(MODX_MANAGER_PATH . 'includes/menu.class.inc.php'); |
|
| 455 | + include_once(MODX_MANAGER_PATH.'includes/menu.class.inc.php'); |
|
| 456 | 456 | } |
| 457 | 457 | $menu = new EVOmenu(); |
| 458 | 458 | $menu->Build($sitemenu, array( |
@@ -1,13 +1,13 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -class DATEPICKER {
|
|
| 4 | - function __construct() {
|
|
| 3 | +class DATEPICKER{
|
|
| 4 | + function __construct(){
|
|
| 5 | 5 | } |
| 6 | 6 | |
| 7 | - function getDP() {
|
|
| 7 | + function getDP(){
|
|
| 8 | 8 | global $modx, $_lang; |
| 9 | 9 | |
| 10 | - $tpl = file_get_contents(dirname(__FILE__) . '/datepicker.tpl'); |
|
| 10 | + $tpl = file_get_contents(dirname(__FILE__).'/datepicker.tpl'); |
|
| 11 | 11 | return $modx->parseText($tpl, $_lang, '[%', '%]'); |
| 12 | 12 | } |
| 13 | 13 | } |
@@ -12,9 +12,9 @@ |
||
| 12 | 12 | * @link http://kcfinder.sunhater.com |
| 13 | 13 | */ |
| 14 | 14 | |
| 15 | -class type_img { |
|
| 15 | +class type_img{ |
|
| 16 | 16 | |
| 17 | - public function checkFile($file, array $config) { |
|
| 17 | + public function checkFile($file, array $config){ |
|
| 18 | 18 | |
| 19 | 19 | $driver = isset($config['imageDriversPriority']) |
| 20 | 20 | ? image::getDriver(explode(" ", $config['imageDriversPriority'])) : "gd"; |
@@ -12,9 +12,9 @@ discard block |
||
| 12 | 12 | * @link http://kcfinder.sunhater.com |
| 13 | 13 | */ |
| 14 | 14 | |
| 15 | -class type_mime { |
|
| 15 | +class type_mime{ |
|
| 16 | 16 | |
| 17 | - public function checkFile($file, array $config) { |
|
| 17 | + public function checkFile($file, array $config){ |
|
| 18 | 18 | if (!class_exists("finfo")) |
| 19 | 19 | return "Fileinfo PECL extension is missing."; |
| 20 | 20 | |
@@ -33,12 +33,12 @@ discard block |
||
| 33 | 33 | $mimes = $config['params']; |
| 34 | 34 | if (substr($mimes, 0, 1) == "!") { |
| 35 | 35 | $mimes = trim(substr($mimes, 1)); |
| 36 | - return in_array($type , explode(" ", $mimes)) |
|
| 36 | + return in_array($type, explode(" ", $mimes)) |
|
| 37 | 37 | ? "You can't upload such files." |
| 38 | 38 | : true; |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - return !in_array($type , explode(" ", $mimes)) |
|
| 41 | + return !in_array($type, explode(" ", $mimes)) |
|
| 42 | 42 | ? "You can't upload such files." |
| 43 | 43 | : true; |
| 44 | 44 | } |
@@ -12,12 +12,12 @@ discard block |
||
| 12 | 12 | * @link http://kcfinder.sunhater.com |
| 13 | 13 | */ |
| 14 | 14 | |
| 15 | -class browser extends uploader { |
|
| 15 | +class browser extends uploader{ |
|
| 16 | 16 | protected $action; |
| 17 | 17 | protected $thumbsDir; |
| 18 | 18 | protected $thumbsTypeDir; |
| 19 | 19 | |
| 20 | - public function __construct($modx) { |
|
| 20 | + public function __construct($modx){ |
|
| 21 | 21 | parent::__construct($modx); |
| 22 | 22 | |
| 23 | 23 | if (isset($this->post['dir'])) { |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | $this->get['dir'] = $dir; |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - $thumbsDir = $this->config['uploadDir'] . "/" . $this->config['thumbsDir']; |
|
| 35 | + $thumbsDir = $this->config['uploadDir']."/".$this->config['thumbsDir']; |
|
| 36 | 36 | if (( |
| 37 | 37 | !is_dir($thumbsDir) && |
| 38 | 38 | !@mkdir($thumbsDir, $this->config['dirPerms']) |
@@ -70,9 +70,9 @@ discard block |
||
| 70 | 70 | $this->config['theme'] = $this->get['theme']; |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | - public function action() { |
|
| 73 | + public function action(){ |
|
| 74 | 74 | $act = isset($this->get['act']) ? $this->get['act'] : "browser"; |
| 75 | - if(!preg_match('@^[0-9a-zA-Z_]+$@', $act)) $this->errorMsg("Unknown error."); |
|
| 75 | + if (!preg_match('@^[0-9a-zA-Z_]+$@', $act)) $this->errorMsg("Unknown error."); |
|
| 76 | 76 | if (!method_exists($this, "act_$act")) |
| 77 | 77 | $act = "browser"; |
| 78 | 78 | $this->action = $act; |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | $this->session['dir'] = $this->type; |
| 95 | 95 | else { |
| 96 | 96 | $type = $this->getTypeFromPath($this->session['dir']); |
| 97 | - $dir = $this->config['uploadDir'] . "/" . $this->session['dir']; |
|
| 97 | + $dir = $this->config['uploadDir']."/".$this->session['dir']; |
|
| 98 | 98 | if (($type != $this->type) || !is_dir($dir) || !is_readable($dir)) |
| 99 | 99 | $this->session['dir'] = $this->type; |
| 100 | 100 | } |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | : $return; |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | - protected function act_browser() { |
|
| 118 | + protected function act_browser(){ |
|
| 119 | 119 | if (isset($this->get['dir']) && |
| 120 | 120 | is_dir("{$this->typeDir}/{$this->get['dir']}") && |
| 121 | 121 | is_readable("{$this->typeDir}/{$this->get['dir']}") |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | return $this->output(); |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | - protected function act_init() { |
|
| 128 | + protected function act_init(){ |
|
| 129 | 129 | $tree = $this->getDirInfo($this->typeDir); |
| 130 | 130 | $tree['dirs'] = $this->getTree($this->session['dir']); |
| 131 | 131 | if (!is_array($tree['dirs']) || !count($tree['dirs'])) |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | return json_encode($data); |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | - protected function act_thumb() { |
|
| 143 | + protected function act_thumb(){ |
|
| 144 | 144 | $this->getDir($this->get['dir'], true); |
| 145 | 145 | if (!isset($this->get['file']) || !isset($this->get['dir'])) |
| 146 | 146 | $this->sendDefaultThumb(); |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | $this->sendDefaultThumb(); |
| 150 | 150 | $file = "{$this->thumbsDir}/{$this->type}/{$this->get['dir']}/$file"; |
| 151 | 151 | if (!is_file($file) || !is_readable($file)) { |
| 152 | - $file = "{$this->config['uploadDir']}/{$this->type}/{$this->get['dir']}/" . basename($file); |
|
| 152 | + $file = "{$this->config['uploadDir']}/{$this->type}/{$this->get['dir']}/".basename($file); |
|
| 153 | 153 | if (!is_file($file) || !is_readable($file)) |
| 154 | 154 | $this->sendDefaultThumb($file); |
| 155 | 155 | $image = image::factory($this->imageDriver, $file); |
@@ -171,13 +171,13 @@ discard block |
||
| 171 | 171 | httpCache::file($file, "image/jpeg"); |
| 172 | 172 | } |
| 173 | 173 | |
| 174 | - protected function act_expand() { |
|
| 174 | + protected function act_expand(){ |
|
| 175 | 175 | return json_encode(array('dirs' => $this->getDirs($this->postDir()))); |
| 176 | 176 | } |
| 177 | 177 | |
| 178 | - protected function act_chDir() { |
|
| 178 | + protected function act_chDir(){ |
|
| 179 | 179 | $this->postDir(); // Just for existing check |
| 180 | - $this->session['dir'] = $this->type . "/" . $this->post['dir']; |
|
| 180 | + $this->session['dir'] = $this->type."/".$this->post['dir']; |
|
| 181 | 181 | $dirWritable = dir::isWritable("{$this->config['uploadDir']}/{$this->session['dir']}"); |
| 182 | 182 | return json_encode(array( |
| 183 | 183 | 'files' => $this->getFiles($this->session['dir']), |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | )); |
| 186 | 186 | } |
| 187 | 187 | |
| 188 | - protected function act_newDir() { |
|
| 188 | + protected function act_newDir(){ |
|
| 189 | 189 | if (!$this->config['access']['dirs']['create'] || |
| 190 | 190 | !isset($this->post['dir']) || |
| 191 | 191 | !isset($this->post['newDir']) |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | return true; |
| 208 | 208 | } |
| 209 | 209 | |
| 210 | - protected function act_renameDir() { |
|
| 210 | + protected function act_renameDir(){ |
|
| 211 | 211 | if (!$this->config['access']['dirs']['rename'] || |
| 212 | 212 | !isset($this->post['dir']) || |
| 213 | 213 | !isset($this->post['newName']) |
@@ -222,15 +222,15 @@ discard block |
||
| 222 | 222 | $this->errorMsg("Unallowable characters in folder name."); |
| 223 | 223 | if (substr($newName, 0, 1) == ".") |
| 224 | 224 | $this->errorMsg("Folder name shouldn't begins with '.'"); |
| 225 | - if (!@rename($dir, dirname($dir) . "/$newName")) |
|
| 225 | + if (!@rename($dir, dirname($dir)."/$newName")) |
|
| 226 | 226 | $this->errorMsg("Cannot rename the folder."); |
| 227 | 227 | $thumbDir = "$this->thumbsTypeDir/{$this->post['dir']}"; |
| 228 | 228 | if (is_dir($thumbDir)) |
| 229 | - @rename($thumbDir, dirname($thumbDir) . "/$newName"); |
|
| 229 | + @rename($thumbDir, dirname($thumbDir)."/$newName"); |
|
| 230 | 230 | return json_encode(array('name' => $newName)); |
| 231 | 231 | } |
| 232 | 232 | |
| 233 | - protected function act_deleteDir() { |
|
| 233 | + protected function act_deleteDir(){ |
|
| 234 | 234 | if (!$this->config['access']['dirs']['delete'] || |
| 235 | 235 | !isset($this->post['dir']) || |
| 236 | 236 | !strlen(trim($this->post['dir'])) |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | return true; |
| 251 | 251 | } |
| 252 | 252 | |
| 253 | - protected function act_upload() { |
|
| 253 | + protected function act_upload(){ |
|
| 254 | 254 | if (!$this->config['access']['files']['upload'] || |
| 255 | 255 | !isset($this->post['dir']) |
| 256 | 256 | ) |
@@ -275,11 +275,11 @@ discard block |
||
| 275 | 275 | return $this->moveUploadFile($this->file, $dir); |
| 276 | 276 | } |
| 277 | 277 | |
| 278 | - protected function act_download() { |
|
| 278 | + protected function act_download(){ |
|
| 279 | 279 | $dir = $this->postDir(); |
| 280 | 280 | if (!isset($this->post['dir']) || |
| 281 | 281 | !isset($this->post['file']) || |
| 282 | - strpos($this->post['file'],'../')!==false || |
|
| 282 | + strpos($this->post['file'], '../') !== false || |
|
| 283 | 283 | (false === ($file = "$dir/{$this->post['file']}")) || |
| 284 | 284 | !file_exists($file) || !is_readable($file) |
| 285 | 285 | ) |
@@ -290,19 +290,19 @@ discard block |
||
| 290 | 290 | header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); |
| 291 | 291 | header("Cache-Control: private", false); |
| 292 | 292 | header("Content-Type: application/octet-stream"); |
| 293 | - header('Content-Disposition: attachment; filename="' . str_replace('"', "_", $this->post['file']) . '"'); |
|
| 293 | + header('Content-Disposition: attachment; filename="'.str_replace('"', "_", $this->post['file']).'"'); |
|
| 294 | 294 | header("Content-Transfer-Encoding: binary"); |
| 295 | - header("Content-Length: " . filesize($file)); |
|
| 295 | + header("Content-Length: ".filesize($file)); |
|
| 296 | 296 | readfile($file); |
| 297 | 297 | die; |
| 298 | 298 | } |
| 299 | 299 | |
| 300 | - protected function act_rename() { |
|
| 300 | + protected function act_rename(){ |
|
| 301 | 301 | $dir = $this->postDir(); |
| 302 | 302 | if (!$this->config['access']['files']['rename'] || |
| 303 | 303 | !isset($this->post['dir']) || |
| 304 | 304 | !isset($this->post['file']) || |
| 305 | - strpos($this->post['file'],'../')!==false || |
|
| 305 | + strpos($this->post['file'], '../') !== false || |
|
| 306 | 306 | !isset($this->post['newName']) || |
| 307 | 307 | (false === ($file = "$dir/{$this->post['file']}")) || |
| 308 | 308 | !file_exists($file) || !is_readable($file) || !file::isWritable($file) |
@@ -337,16 +337,16 @@ discard block |
||
| 337 | 337 | $thumbFile = "$thumbDir/{$this->post['file']}"; |
| 338 | 338 | |
| 339 | 339 | if (file_exists($thumbFile)) |
| 340 | - @rename($thumbFile, "$thumbDir/" . basename($newName)); |
|
| 340 | + @rename($thumbFile, "$thumbDir/".basename($newName)); |
|
| 341 | 341 | return true; |
| 342 | 342 | } |
| 343 | 343 | |
| 344 | - protected function act_delete() { |
|
| 344 | + protected function act_delete(){ |
|
| 345 | 345 | $dir = $this->postDir(); |
| 346 | 346 | if (!$this->config['access']['files']['delete'] || |
| 347 | 347 | !isset($this->post['dir']) || |
| 348 | 348 | !isset($this->post['file']) || |
| 349 | - strpos($this->post['file'],'../')!==false || |
|
| 349 | + strpos($this->post['file'], '../') !== false || |
|
| 350 | 350 | (false === ($file = "$dir/{$this->post['file']}")) || |
| 351 | 351 | !file_exists($file) || !is_readable($file) || !file::isWritable($file) || |
| 352 | 352 | !@unlink($file) |
@@ -358,7 +358,7 @@ discard block |
||
| 358 | 358 | return true; |
| 359 | 359 | } |
| 360 | 360 | |
| 361 | - protected function act_cp_cbd() { |
|
| 361 | + protected function act_cp_cbd(){ |
|
| 362 | 362 | $dir = $this->postDir(); |
| 363 | 363 | if (!$this->config['access']['files']['copy'] || |
| 364 | 364 | !isset($this->post['dir']) || |
@@ -369,7 +369,7 @@ discard block |
||
| 369 | 369 | $this->errorMsg("Unknown error."); |
| 370 | 370 | |
| 371 | 371 | $error = array(); |
| 372 | - foreach($this->post['files'] as $file) { |
|
| 372 | + foreach ($this->post['files'] as $file) { |
|
| 373 | 373 | $file = path::normalize($file); |
| 374 | 374 | if (substr($file, 0, 1) == ".") continue; |
| 375 | 375 | $type = explode("/", $file); |
@@ -382,11 +382,11 @@ discard block |
||
| 382 | 382 | if (!file_exists($path)) |
| 383 | 383 | $error[] = $this->label("The file '{file}' does not exist.", $replace); |
| 384 | 384 | elseif (substr($base, 0, 1) == ".") |
| 385 | - $error[] = "$base: " . $this->label("File name shouldn't begins with '.'"); |
|
| 385 | + $error[] = "$base: ".$this->label("File name shouldn't begins with '.'"); |
|
| 386 | 386 | elseif (!$this->validateExtension($ext, $type)) |
| 387 | - $error[] = "$base: " . $this->label("Denied file extension."); |
|
| 387 | + $error[] = "$base: ".$this->label("Denied file extension."); |
|
| 388 | 388 | elseif (file_exists("$dir/$base")) |
| 389 | - $error[] = "$base: " . $this->label("A file or folder with that name already exists."); |
|
| 389 | + $error[] = "$base: ".$this->label("A file or folder with that name already exists."); |
|
| 390 | 390 | elseif (!is_readable($path) || !is_file($path)) |
| 391 | 391 | $error[] = $this->label("Cannot read '{file}'.", $replace); |
| 392 | 392 | elseif (!@copy($path, "$dir/$base")) |
@@ -409,7 +409,7 @@ discard block |
||
| 409 | 409 | return true; |
| 410 | 410 | } |
| 411 | 411 | |
| 412 | - protected function act_mv_cbd() { |
|
| 412 | + protected function act_mv_cbd(){ |
|
| 413 | 413 | $dir = $this->postDir(); |
| 414 | 414 | if (!$this->config['access']['files']['move'] || |
| 415 | 415 | !isset($this->post['dir']) || |
@@ -420,7 +420,7 @@ discard block |
||
| 420 | 420 | $this->errorMsg("Unknown error."); |
| 421 | 421 | |
| 422 | 422 | $error = array(); |
| 423 | - foreach($this->post['files'] as $file) { |
|
| 423 | + foreach ($this->post['files'] as $file) { |
|
| 424 | 424 | $file = path::normalize($file); |
| 425 | 425 | if (substr($file, 0, 1) == ".") continue; |
| 426 | 426 | $type = explode("/", $file); |
@@ -433,11 +433,11 @@ discard block |
||
| 433 | 433 | if (!file_exists($path)) |
| 434 | 434 | $error[] = $this->label("The file '{file}' does not exist.", $replace); |
| 435 | 435 | elseif (substr($base, 0, 1) == ".") |
| 436 | - $error[] = "$base: " . $this->label("File name shouldn't begins with '.'"); |
|
| 436 | + $error[] = "$base: ".$this->label("File name shouldn't begins with '.'"); |
|
| 437 | 437 | elseif (!$this->validateExtension($ext, $type)) |
| 438 | - $error[] = "$base: " . $this->label("Denied file extension."); |
|
| 438 | + $error[] = "$base: ".$this->label("Denied file extension."); |
|
| 439 | 439 | elseif (file_exists("$dir/$base")) |
| 440 | - $error[] = "$base: " . $this->label("A file or folder with that name already exists."); |
|
| 440 | + $error[] = "$base: ".$this->label("A file or folder with that name already exists."); |
|
| 441 | 441 | elseif (!is_readable($path) || !is_file($path)) |
| 442 | 442 | $error[] = $this->label("Cannot read '{file}'.", $replace); |
| 443 | 443 | elseif (!file::isWritable($path) || !@rename($path, "$dir/$base")) |
@@ -460,7 +460,7 @@ discard block |
||
| 460 | 460 | return true; |
| 461 | 461 | } |
| 462 | 462 | |
| 463 | - protected function act_rm_cbd() { |
|
| 463 | + protected function act_rm_cbd(){ |
|
| 464 | 464 | if (!$this->config['access']['files']['delete'] || |
| 465 | 465 | !isset($this->post['files']) || |
| 466 | 466 | !is_array($this->post['files']) || |
@@ -469,7 +469,7 @@ discard block |
||
| 469 | 469 | $this->errorMsg("Unknown error."); |
| 470 | 470 | |
| 471 | 471 | $error = array(); |
| 472 | - foreach($this->post['files'] as $file) { |
|
| 472 | + foreach ($this->post['files'] as $file) { |
|
| 473 | 473 | $file = path::normalize($file); |
| 474 | 474 | if (substr($file, 0, 1) == ".") continue; |
| 475 | 475 | $type = explode("/", $file); |
@@ -492,25 +492,25 @@ discard block |
||
| 492 | 492 | return true; |
| 493 | 493 | } |
| 494 | 494 | |
| 495 | - protected function act_downloadDir() { |
|
| 495 | + protected function act_downloadDir(){ |
|
| 496 | 496 | $dir = $this->postDir(); |
| 497 | 497 | if (!isset($this->post['dir']) || $this->config['denyZipDownload']) |
| 498 | 498 | $this->errorMsg("Unknown error."); |
| 499 | - $filename = basename($dir) . ".zip"; |
|
| 499 | + $filename = basename($dir).".zip"; |
|
| 500 | 500 | do { |
| 501 | - $file = md5(time() . session_id()); |
|
| 501 | + $file = md5(time().session_id()); |
|
| 502 | 502 | $file = "{$this->config['uploadDir']}/$file.zip"; |
| 503 | 503 | } while (file_exists($file)); |
| 504 | 504 | new zipFolder($file, $dir); |
| 505 | 505 | header("Content-Type: application/x-zip"); |
| 506 | - header('Content-Disposition: attachment; filename="' . str_replace('"', "_", $filename) . '"'); |
|
| 507 | - header("Content-Length: " . filesize($file)); |
|
| 506 | + header('Content-Disposition: attachment; filename="'.str_replace('"', "_", $filename).'"'); |
|
| 507 | + header("Content-Length: ".filesize($file)); |
|
| 508 | 508 | readfile($file); |
| 509 | 509 | unlink($file); |
| 510 | 510 | die; |
| 511 | 511 | } |
| 512 | 512 | |
| 513 | - protected function act_downloadSelected() { |
|
| 513 | + protected function act_downloadSelected(){ |
|
| 514 | 514 | $dir = $this->postDir(); |
| 515 | 515 | if (!isset($this->post['dir']) || |
| 516 | 516 | !isset($this->post['files']) || |
@@ -531,7 +531,7 @@ discard block |
||
| 531 | 531 | } |
| 532 | 532 | |
| 533 | 533 | do { |
| 534 | - $file = md5(time() . session_id()); |
|
| 534 | + $file = md5(time().session_id()); |
|
| 535 | 535 | $file = "{$this->config['uploadDir']}/$file.zip"; |
| 536 | 536 | } while (file_exists($file)); |
| 537 | 537 | |
@@ -543,14 +543,14 @@ discard block |
||
| 543 | 543 | $zip->close(); |
| 544 | 544 | } |
| 545 | 545 | header("Content-Type: application/x-zip"); |
| 546 | - header('Content-Disposition: attachment; filename="selected_files_' . basename($file) . '"'); |
|
| 547 | - header("Content-Length: " . filesize($file)); |
|
| 546 | + header('Content-Disposition: attachment; filename="selected_files_'.basename($file).'"'); |
|
| 547 | + header("Content-Length: ".filesize($file)); |
|
| 548 | 548 | readfile($file); |
| 549 | 549 | unlink($file); |
| 550 | 550 | die; |
| 551 | 551 | } |
| 552 | 552 | |
| 553 | - protected function act_downloadClipboard() { |
|
| 553 | + protected function act_downloadClipboard(){ |
|
| 554 | 554 | if (!isset($this->post['files']) || |
| 555 | 555 | !is_array($this->post['files']) || |
| 556 | 556 | $this->config['denyZipDownload'] |
@@ -566,14 +566,14 @@ discard block |
||
| 566 | 566 | $type = $type[0]; |
| 567 | 567 | if ($type != $this->type) |
| 568 | 568 | continue; |
| 569 | - $file = $this->config['uploadDir'] . "/$file"; |
|
| 569 | + $file = $this->config['uploadDir']."/$file"; |
|
| 570 | 570 | if (!is_file($file) || !is_readable($file)) |
| 571 | 571 | continue; |
| 572 | 572 | $zipFiles[] = $file; |
| 573 | 573 | } |
| 574 | 574 | |
| 575 | 575 | do { |
| 576 | - $file = md5(time() . session_id()); |
|
| 576 | + $file = md5(time().session_id()); |
|
| 577 | 577 | $file = "{$this->config['uploadDir']}/$file.zip"; |
| 578 | 578 | } while (file_exists($file)); |
| 579 | 579 | |
@@ -585,14 +585,14 @@ discard block |
||
| 585 | 585 | $zip->close(); |
| 586 | 586 | } |
| 587 | 587 | header("Content-Type: application/x-zip"); |
| 588 | - header('Content-Disposition: attachment; filename="clipboard_' . basename($file) . '"'); |
|
| 589 | - header("Content-Length: " . filesize($file)); |
|
| 588 | + header('Content-Disposition: attachment; filename="clipboard_'.basename($file).'"'); |
|
| 589 | + header("Content-Length: ".filesize($file)); |
|
| 590 | 590 | readfile($file); |
| 591 | 591 | unlink($file); |
| 592 | 592 | die; |
| 593 | 593 | } |
| 594 | 594 | |
| 595 | - protected function act_check4Update() { |
|
| 595 | + protected function act_check4Update(){ |
|
| 596 | 596 | if ($this->config['denyUpdateCheck']) |
| 597 | 597 | return json_encode(array('version' => false)); |
| 598 | 598 | |
@@ -632,24 +632,24 @@ discard block |
||
| 632 | 632 | // Curl extension |
| 633 | 633 | ) {} elseif ( |
| 634 | 634 | function_exists("curl_init") && |
| 635 | - (false !== ( $curl = @curl_init($url) )) && |
|
| 636 | - ( @ob_start() || (@curl_close($curl) && false)) && |
|
| 637 | - ( @curl_exec($curl) || (@curl_close($curl) && false)) && |
|
| 638 | - ((false !== ( $ver = @ob_get_clean() )) || (@curl_close($curl) && false)) && |
|
| 639 | - ( @curl_close($curl) || true ) && |
|
| 635 | + (false !== ($curl = @curl_init($url))) && |
|
| 636 | + (@ob_start() || (@curl_close($curl) && false)) && |
|
| 637 | + (@curl_exec($curl) || (@curl_close($curl) && false)) && |
|
| 638 | + ((false !== ($ver = @ob_get_clean())) || (@curl_close($curl) && false)) && |
|
| 639 | + (@curl_close($curl) || true) && |
|
| 640 | 640 | preg_match($pattern, $ver) |
| 641 | 641 | |
| 642 | 642 | // Socket extension |
| 643 | 643 | ) {} elseif (function_exists('socket_create')) { |
| 644 | 644 | $cmd = |
| 645 | - "GET $path " . strtoupper($protocol) . "/1.1\r\n" . |
|
| 646 | - "Host: $host\r\n" . |
|
| 645 | + "GET $path ".strtoupper($protocol)."/1.1\r\n". |
|
| 646 | + "Host: $host\r\n". |
|
| 647 | 647 | "Connection: Close\r\n\r\n"; |
| 648 | 648 | |
| 649 | - if ((false !== ( $socket = @socket_create(AF_INET, SOCK_STREAM, SOL_TCP) )) && |
|
| 650 | - (false !== @socket_connect($socket, $host, $port) ) && |
|
| 651 | - (false !== @socket_write($socket, $cmd, strlen($cmd)) ) && |
|
| 652 | - (false !== ( $ver = @socket_read($socket, 2048) )) && |
|
| 649 | + if ((false !== ($socket = @socket_create(AF_INET, SOCK_STREAM, SOL_TCP))) && |
|
| 650 | + (false !== @socket_connect($socket, $host, $port)) && |
|
| 651 | + (false !== @socket_write($socket, $cmd, strlen($cmd))) && |
|
| 652 | + (false !== ($ver = @socket_read($socket, 2048))) && |
|
| 653 | 653 | preg_match($responsePattern, $ver, $match) |
| 654 | 654 | ) |
| 655 | 655 | $ver = $match[2]; |
@@ -666,7 +666,7 @@ discard block |
||
| 666 | 666 | return json_encode(array('version' => false)); |
| 667 | 667 | } |
| 668 | 668 | |
| 669 | - protected function moveUploadFile($file, $dir) { |
|
| 669 | + protected function moveUploadFile($file, $dir){ |
|
| 670 | 670 | $message = $this->checkUploadedFile($file); |
| 671 | 671 | |
| 672 | 672 | if ($message !== true) { |
@@ -676,28 +676,28 @@ discard block |
||
| 676 | 676 | } |
| 677 | 677 | |
| 678 | 678 | $filename = $this->normalizeFilename($file['name']); |
| 679 | - $target = "$dir/" . file::getInexistantFilename($filename, $dir); |
|
| 679 | + $target = "$dir/".file::getInexistantFilename($filename, $dir); |
|
| 680 | 680 | |
| 681 | 681 | if (!@move_uploaded_file($file['tmp_name'], $target) && |
| 682 | 682 | !@rename($file['tmp_name'], $target) && |
| 683 | 683 | !@copy($file['tmp_name'], $target) |
| 684 | 684 | ) { |
| 685 | 685 | @unlink($file['tmp_name']); |
| 686 | - return "{$file['name']}: " . $this->label("Cannot move uploaded file to target folder."); |
|
| 686 | + return "{$file['name']}: ".$this->label("Cannot move uploaded file to target folder."); |
|
| 687 | 687 | } elseif (function_exists('chmod')) |
| 688 | 688 | chmod($target, $this->config['filePerms']); |
| 689 | 689 | |
| 690 | - $this->modx->invokeEvent('OnFileBrowserUpload',array( |
|
| 690 | + $this->modx->invokeEvent('OnFileBrowserUpload', array( |
|
| 691 | 691 | 'filepath'=>realpath($dir), |
| 692 | - 'filename'=>str_replace("/","",str_replace($dir,"",realpath($target))) |
|
| 692 | + 'filename'=>str_replace("/", "", str_replace($dir, "", realpath($target))) |
|
| 693 | 693 | )); |
| 694 | 694 | |
| 695 | 695 | $this->makeThumb($target); |
| 696 | 696 | |
| 697 | - return "/" . basename($target); |
|
| 697 | + return "/".basename($target); |
|
| 698 | 698 | } |
| 699 | 699 | |
| 700 | - protected function sendDefaultThumb($file=null) { |
|
| 700 | + protected function sendDefaultThumb($file = null){ |
|
| 701 | 701 | if ($file !== null) { |
| 702 | 702 | $ext = file::getExtension($file); |
| 703 | 703 | $thumb = "themes/{$this->config['theme']}/img/files/big/$ext.png"; |
@@ -709,7 +709,7 @@ discard block |
||
| 709 | 709 | die; |
| 710 | 710 | } |
| 711 | 711 | |
| 712 | - protected function getFiles($dir) { |
|
| 712 | + protected function getFiles($dir){ |
|
| 713 | 713 | $thumbDir = "{$this->config['uploadDir']}/{$this->config['thumbsDir']}/$dir"; |
| 714 | 714 | $dir = "{$this->config['uploadDir']}/$dir"; |
| 715 | 715 | $return = array(); |
@@ -720,10 +720,10 @@ discard block |
||
| 720 | 720 | foreach ($files as $file) { |
| 721 | 721 | $ext = file::getExtension($file); |
| 722 | 722 | $smallThumb = false; |
| 723 | - if (in_array(strtolower($ext), array('png', 'jpg', 'gif', 'jpeg' )) ) { |
|
| 723 | + if (in_array(strtolower($ext), array('png', 'jpg', 'gif', 'jpeg'))) { |
|
| 724 | 724 | $size = @getimagesize($file); |
| 725 | 725 | if (is_array($size) && count($size)) { |
| 726 | - $thumb_file = "$thumbDir/" . basename($file); |
|
| 726 | + $thumb_file = "$thumbDir/".basename($file); |
|
| 727 | 727 | if (!is_file($thumb_file) || filemtime($file) > filemtime($thumb_file)) |
| 728 | 728 | $this->makeThumb($file); |
| 729 | 729 | $smallThumb = |
@@ -736,9 +736,9 @@ discard block |
||
| 736 | 736 | if ($stat === false) continue; |
| 737 | 737 | $name = basename($file); |
| 738 | 738 | $types = $this->config['types']; |
| 739 | - $types = explode(' ',$types['images'].' '.$types['image']); |
|
| 740 | - if (substr($name,0,1) == '.' && !$this->config['showHiddenFiles']) continue; |
|
| 741 | - if ($this->type == 'images' && !in_array(strtolower($ext),$types)) continue; |
|
| 739 | + $types = explode(' ', $types['images'].' '.$types['image']); |
|
| 740 | + if (substr($name, 0, 1) == '.' && !$this->config['showHiddenFiles']) continue; |
|
| 741 | + if ($this->type == 'images' && !in_array(strtolower($ext), $types)) continue; |
|
| 742 | 742 | $bigIcon = file_exists("themes/{$this->config['theme']}/img/files/big/$ext.png"); |
| 743 | 743 | $smallIcon = file_exists("themes/{$this->config['theme']}/img/files/small/$ext.png"); |
| 744 | 744 | $thumb = file_exists("$thumbDir/$name"); |
@@ -758,7 +758,7 @@ discard block |
||
| 758 | 758 | return $return; |
| 759 | 759 | } |
| 760 | 760 | |
| 761 | - protected function getTree($dir, $index=0) { |
|
| 761 | + protected function getTree($dir, $index = 0){ |
|
| 762 | 762 | $path = explode("/", $dir); |
| 763 | 763 | |
| 764 | 764 | $pdir = ""; |
@@ -793,25 +793,25 @@ discard block |
||
| 793 | 793 | return $dirs; |
| 794 | 794 | } |
| 795 | 795 | |
| 796 | - protected function postDir($existent=true) { |
|
| 796 | + protected function postDir($existent = true){ |
|
| 797 | 797 | $dir = $this->typeDir; |
| 798 | 798 | if (isset($this->post['dir'])) |
| 799 | - $dir .= "/" . $this->post['dir']; |
|
| 799 | + $dir .= "/".$this->post['dir']; |
|
| 800 | 800 | if ($existent && (!is_dir($dir) || !is_readable($dir))) |
| 801 | 801 | $this->errorMsg("Inexistant or inaccessible folder."); |
| 802 | 802 | return $dir; |
| 803 | 803 | } |
| 804 | 804 | |
| 805 | - protected function getDir($existent=true) { |
|
| 805 | + protected function getDir($existent = true){ |
|
| 806 | 806 | $dir = $this->typeDir; |
| 807 | 807 | if (isset($this->get['dir'])) |
| 808 | - $dir .= "/" . $this->get['dir']; |
|
| 808 | + $dir .= "/".$this->get['dir']; |
|
| 809 | 809 | if ($existent && (!is_dir($dir) || !is_readable($dir))) |
| 810 | 810 | $this->errorMsg("Inexistant or inaccessible folder."); |
| 811 | 811 | return $dir; |
| 812 | 812 | } |
| 813 | 813 | |
| 814 | - protected function getDirs($dir) { |
|
| 814 | + protected function getDirs($dir){ |
|
| 815 | 815 | $dirs = dir::content($dir, array('types' => "dir")); |
| 816 | 816 | $return = array(); |
| 817 | 817 | if (is_array($dirs)) { |
@@ -826,7 +826,7 @@ discard block |
||
| 826 | 826 | return $return; |
| 827 | 827 | } |
| 828 | 828 | |
| 829 | - protected function getDirInfo($dir, $removable=false) { |
|
| 829 | + protected function getDirInfo($dir, $removable = false){ |
|
| 830 | 830 | if ((substr(basename($dir), 0, 1) == ".") || !is_dir($dir) || !is_readable($dir)) |
| 831 | 831 | return false; |
| 832 | 832 | $dirs = dir::content($dir, array('types' => "dir")); |
@@ -853,7 +853,7 @@ discard block |
||
| 853 | 853 | return $info; |
| 854 | 854 | } |
| 855 | 855 | |
| 856 | - protected function output($data=null, $template=null) { |
|
| 856 | + protected function output($data = null, $template = null){ |
|
| 857 | 857 | if (!is_array($data)) $data = array(); |
| 858 | 858 | if ($template === null) |
| 859 | 859 | $template = $this->action; |
@@ -873,7 +873,7 @@ discard block |
||
| 873 | 873 | return ""; |
| 874 | 874 | } |
| 875 | 875 | |
| 876 | - protected function errorMsg($message, array $data=null) { |
|
| 876 | + protected function errorMsg($message, array $data = null){ |
|
| 877 | 877 | if (in_array($this->action, array("thumb", "upload", "download", "downloadDir"))) |
| 878 | 878 | die($this->label($message, $data)); |
| 879 | 879 | if (($this->action === null) || ($this->action == "browser")) |