diff --git a/classes/Admin.php b/classes/Admin.php index 53218fd..6b5da92 100644 --- a/classes/Admin.php +++ b/classes/Admin.php @@ -1,11 +1,10 @@ user_exists($username)) + if (!$accounts->user_exists($username)) { throw new ExceptionDisplay('Cannot change password: username does not exist.'); } - if (!$accounts -> is_valid_user(new User($username, sha1($old_pass)))) + if (!$accounts->is_valid_user(new User($username, sha1($old_pass)))) { throw new ExceptionDisplay('Incorrect old password.'); } global $config; - $h = @fopen($config -> __get('user_list'), 'wb'); + $h = @fopen($config->__get('user_list'), 'wb'); if ($h === false) { throw new ExceptionDisplay("Could not open file $user_list for writing." @@ -208,11 +207,11 @@ class Admin } foreach ($accounts as $this_user) { - if (strcasecmp($this_user -> username, $username) === 0) + if (strcasecmp($this_user->username, $username) === 0) { - $this_user = new User($username, sha1($new_pass1), $this_user -> level, $this_user -> home_dir); + $this_user = new User($username, sha1($new_pass1), $this_user->level, $this_user->home_dir); } - fwrite($h, $this_user -> __toString()); + fwrite($h, $this_user->__toString()); } fclose($h); $_SESSION['password'] = sha1($new_pass1); @@ -232,12 +231,12 @@ class Admin throw new ExceptionDisplay('Invalid user level.'); } $accounts = new Accounts(); - if (!$accounts -> user_exists($username)) + if (!$accounts->user_exists($username)) { throw new ExceptionDisplay('Cannot change level: username does not exist.'); } global $config; - $h = @fopen($config -> __get('user_list'), 'wb'); + $h = @fopen($config->__get('user_list'), 'wb'); if ($h === false) { throw new ExceptionDisplay("Could not open file $user_list for writing." @@ -245,11 +244,11 @@ class Admin } foreach ($accounts as $this_user) { - if (strcasecmp($this_user -> username, $username) === 0) + if (strcasecmp($this_user->username, $username) === 0) { - $this_user = new User($username, $this_user -> sha1_pass, $new_level, $this_user -> home_dir); + $this_user = new User($username, $this_user->sha1_pass, $new_level, $this_user->home_dir); } - fwrite($h, $this_user -> __toString()); + fwrite($h, $this_user->__toString()); } fclose($h); throw new ExceptionDisplay('User level successfully changed.'); @@ -281,18 +280,18 @@ class Admin } } $list = new Accounts(); - if ($list -> user_exists($username)) + if ($list->user_exists($username)) { throw new ExceptionDisplay('This username already exists.'); } global $config; - $h = @fopen($config -> __get('user_list'), 'ab'); + $h = @fopen($config->__get('user_list'), 'ab'); if ($h === false) { throw new ExceptionDisplay('User list file could not be opened for writing.'); } $new_user = new User($username, sha1($pass1), $level, $home_dir); - fwrite($h, $new_user -> __toString()); + fwrite($h, $new_user->__toString()); fclose($h); throw new ExceptionDisplay('User successfully added.'); } @@ -303,12 +302,12 @@ class Admin private static function del_user($username) { $accounts = new Accounts(); - if (!$accounts -> user_exists($username)) + if (!$accounts->user_exists($username)) { throw new ExceptionDisplay('Cannot delete user: username does not exist.'); } global $config; - $h = @fopen($config -> __get('user_list'), 'wb'); + $h = @fopen($config->__get('user_list'), 'wb'); if ($h === false) { throw new ExceptionDisplay("Could not open file $user_list for writing." @@ -316,9 +315,9 @@ class Admin } foreach ($accounts as $this_user) { - if (strcasecmp($this_user -> username, $username) !== 0) + if (strcasecmp($this_user->username, $username) !== 0) { - fwrite($h, $this_user -> __toString()); + fwrite($h, $this_user->__toString()); } } fclose($h); @@ -334,8 +333,12 @@ class Admin { throw new ExceptionDisplay('You must be logged in to access this section.'); } - $this -> level = $current_user -> level; - $this -> username = $current_user -> username; + $this->level = $current_user->level; + $this->username = $current_user->username; + + global $request, $words; + $this->request = is_object($request) ? $request : new RequestVars('', false); + $this->language = $words; } /** @@ -348,12 +351,12 @@ class Admin if (in_array(strtolower($action), $mod_actions)) { - if ($this -> level < MODERATOR) + if ($this->level < MODERATOR) { throw new ExceptionDisplay('You must be a moderator to access this section.'); } } - else if ($this -> level < ADMIN) + else if ($this->level < ADMIN) { throw new ExceptionDisplay('You must be an administrator to access this section.'); } @@ -397,31 +400,29 @@ class Admin global $config; if (DOWNLOAD_COUNT) { - self::update_file_info($config -> __get('download_count'), $old, $new); + self::update_file_info($config->__get('download_count'), $old, $new); } if (DESCRIPTION_FILE) { - self::update_file_info($config -> __get('description_file'), $old, $new); + self::update_file_info($config->__get('description_file'), $old, $new); } throw new ExceptionDisplay('File renamed successfully.'); } throw new ExceptionDisplay('Error renaming file.'); } global $words, $subdir; - throw new ExceptionDisplay('
' . $words -> __get('renaming') - . ' ' . Url::html_output($_GET['filename']) - . '
' . $words -> __get('new filename')
- . ':
('
- . $words -> __get('you can also move the file by specifying a path')
- . ')
' . $words->__get('renaming') . ' ' . Url::html_output($_GET['filename']) . '
+' . $words->__get('new filename') . ':
+ (' . $words->__get('you can also move the file by specifying a path') . ')
' - . $words -> __get('are you sure you want to delete the file') - . ' ' . Url::html_output($_GET['filename']) . '?
' - . ''); + . $words->__get('are you sure you want to delete the file') . ' ' . Url::html_output($_GET['filename']) . '?' + . ''); } case 'add_user': { @@ -472,29 +468,29 @@ class Admin $_POST['pass2'], (int)$_POST['level'], $_POST['home_dir']); } global $words; - throw new ExceptionDisplay($words -> __get('add user') + throw new ExceptionDisplay($words->__get('add user') . ':'); + . $words->__get('add user') . '" />'); } case 'change_password': { if (isset($_POST['pass1'], $_POST['pass2'], $_POST['old_pass'])) { - self::change_password($this -> username, $_POST['old_pass'], + self::change_password($this->username, $_POST['old_pass'], $_POST['pass1'], $_POST['pass2']); } throw new ExceptionDisplay(''); + . $words->__get('guest') . ' '); } case 'del_user': { @@ -531,23 +527,23 @@ class Admin } global $words; throw new ExceptionDisplay('' - . $words -> __get('are you sure you want to remove the user') + . $words->__get('are you sure you want to remove the user') . ' '.$_POST['username'] . '?
' - . ''); + . $words->__get('yes, delete') . '" />'); } global $words; $accounts = new Accounts(); - $out = '' . $words -> __get('select user to remove') - . ':
'); + throw new ExceptionDisplay($out . ''); } case 'edit_description': { @@ -558,11 +554,11 @@ class Admin if (isset($_GET['description'])) { global $descriptions, $config; - if (DESCRIPTION_FILE && $descriptions -> is_set($filename)) + if (DESCRIPTION_FILE && $descriptions->is_set($filename)) //if it's already set, update the old description { //update the new description on disk - $h = @fopen($config -> __get('description_file'), 'wb'); + $h = @fopen($config->__get('description_file'), 'wb'); if ($h === false) { throw new ExceptionDisplay('Could not open description file for writing.' . ' Make sure PHP has write permission to this file.'); @@ -574,12 +570,12 @@ class Admin fclose($h); //update the new description in memory - $descriptions -> set($filename, $_GET['description']); + $descriptions->set($filename, $_GET['description']); } else if ($_GET['description'] != '') //if it's not set, add it to the end { - $h = @fopen($config -> __get('description_file'), 'ab'); + $h = @fopen($config->__get('description_file'), 'ab'); if ($h === false) { throw new ExceptionDisplay('Could not open description file for writing.' . ' Make sure PHP has write permission to this file.'); @@ -588,24 +584,24 @@ class Admin fclose($h); //read the description file with the updated data - $descriptions = new ConfigData($config -> __get('description_file')); + $descriptions = new ConfigData($config->__get('description_file')); } } else { global $words, $subdir, $descriptions; - $current_desc = (DESCRIPTION_FILE && $descriptions -> is_set($filename) ? $descriptions -> __get($filename) : ''); + $current_desc = (DESCRIPTION_FILE && $descriptions->is_set($filename) ? $descriptions->__get($filename) : ''); throw new ExceptionDisplay('' - . $words -> __get('enter the new description for the file') + . $words->__get('enter the new description for the file') . ' ' . Url::html_output($_GET['filename']) - . ':
'); + . $words->__get('change') . '" />'); } } else @@ -624,7 +620,7 @@ class Admin if (isset($_GET['add']) && $_GET['add'] != '') { global $config; - $h = @fopen($config -> __get('hidden_files'), 'ab'); + $h = @fopen($config->__get('hidden_files'), 'ab'); if ($h === false) { throw new ExceptionDisplay('Unable to open hidden files list for writing.'); @@ -636,7 +632,7 @@ class Admin if (isset($_GET['remove'])) { global $config; - $h = @fopen($config -> __get('hidden_files'), 'wb'); + $h = @fopen($config->__get('hidden_files'), 'wb'); if ($h === false) { throw new ExceptionDisplay('Unable to open hidden files list for writing.'); @@ -652,23 +648,23 @@ class Admin throw new ExceptionDisplay('Hidden file removed.'); } global $words; - $str = 'You can also use wildcards (?, *, +) for each entry.
'
. 'If you want to do the opposite of "hidden files" - show only certain files - '
. 'put a colon in front of those entries.
' . $words -> __get('enter the new name') + throw new ExceptionDisplay('
' . $words->__get('enter the new name') . ':
' + . Url::html_output($this->request->server('PHP_SELF')) . '">
' . '
|
Enter the name of the remote file you would like to copy: -http:// @@ -838,7 +850,7 @@ class Admin { unset($_SESSION['ftp']); $text = ' Logout successful. Go back. '; } else if (isset($_SESSION['ftp'])) @@ -859,7 +871,7 @@ class Admin { global $dir; $name = rawurldecode($_GET['filename']); - $ftp -> put_file($dir . $name, Item::get_basename($name)); + $ftp->put_file($dir . $name, Item::get_basename($name)); throw new ExceptionDisplay('File successfully transferred to FTP server.'); } if (isset($_GET['transfer']) && $_GET['transfer'] != '') @@ -867,36 +879,36 @@ class Admin { global $dir; $name = rawurldecode($_GET['transfer']); - $ftp -> get_file($dir . Item::get_basename($name), $name); + $ftp->get_file($dir . Item::get_basename($name), $name); throw new ExceptionDisplay('File successfully transferred from FTP server.'); } global $words; - $text = '
Logout of FTP server
-
- ' - . $words -> __get('reconfigure script') . ' + ' + . $words->__get('reconfigure script') . '
- '
- . $words -> __get('edit list of hidden files') . '
-
- ' . $words -> __get('create new directory in this folder')
- . '
- '
- . $words -> __get('view entries from log file') . '
-
- '
- . $words -> __get('add new user') . '
- |