Warning: set_time_limit(): Cannot set time limit in safe mode in /home/www/dynamic/uv.ro/mesianic.uv.ro/public_html/main.php on line 580 classes/Accounts.php0000755000000000000000000001253111500513450011670 0ustar * @version 1.0.2 (July 21, 2004) * @package AutoIndex */ class Accounts implements Iterator { /** * @var array The list of valid accounts taken from the stored file */ private $userlist; /** * @var int The size of the $userlist array */ private $list_count; //begin implementation of Iterator /** * @var int $i is used to keep track of the current pointer inside the array when implementing Iterator */ private $i; /** * @return User The current element in the array */ public function current() { if ($this -> i < $this -> list_count) { return $this -> userlist[$this -> i]; } return false; } /** * Increments the internal array pointer, then returns the user at that * new position. * * @return User The current position of the pointer in the array */ public function next() { $this -> i++; return $this -> current(); } /** * Sets the internal array pointer to 0. */ public function rewind() { $this -> i = 0; } /** * @return bool True if $i is a valid array index */ public function valid() { return ($this -> i < $this -> list_count); } /** * @return int Returns $i, the key of the array */ public function key() { return $this -> i; } //end implementation of Iterator /** * Reads the user_list file, and fills the $contents array with the * valid users. */ public function __construct() { global $config; $file = @file($config -> __get('user_list')); if ($file === false) { throw new ExceptionDisplay('Cannot open user account file.'); } $this -> userlist = array(); foreach ($file as $line_num => $line) { $line = rtrim($line, "\r\n"); if (ConfigData::line_is_comment($line)) { continue; } $parts = explode("\t", $line); if (count($parts) !== 4) { throw new ExceptionDisplay('Incorrect format for user accounts file on line ' . ($line_num + 1)); } $this -> userlist[] = new User($parts[0], $parts[1], $parts[2], $parts[3]); } $this -> list_count = count($this -> userlist); $this -> i = 0; } /** * @param string $name Username to find the level of * @return int The level of the user */ public function get_level($name) { foreach ($this as $look) { if (strcasecmp($look -> username, $name) !== 0) { continue; } $lev = (int)$look -> level; if ($lev < BANNED || $lev > ADMIN) { throw new ExceptionDisplay('Invalid level for user ' . Url::html_output($name) . '.'); } return $lev; } throw new ExceptionDisplay('User ' . Url::html_output($name) . ' does not exist.'); } /** * @param string $name Username to find the home directory for * @return string The home directory of $name */ public function get_home_dir($name) { foreach ($this as $look) { if (strcasecmp($look -> username, $name) === 0) { return $look -> home_dir; } } throw new ExceptionDisplay('User ' . Url::html_output($name) . ' does not exist.'); } /** * Returns $name with the character case the same as it is in the accounts * file. * * @param string $name Username to find the stored case of * @return string */ public function get_stored_case($name) { foreach ($this as $look) { if (strcasecmp($look -> username, $name) === 0) { return $look -> username; } } throw new ExceptionDisplay('User ' . Url::html_output($name) . ' does not exist.'); } /** * @param User $user The user to determine if it is valid or not * @return bool True if the username and password are correct */ public function is_valid_user(User $user) { foreach ($this as $look) { if ($look -> equals($user)) { return true; } } return false; } /** * @param string $name Username to find if it exists or not * @return bool True if a user exists with the username $name */ public function user_exists($name) { foreach ($this as $look) { if (strcasecmp($look -> username, $name) === 0) { return true; } } return false; } } ?>classes/Admin.php0000755000000000000000000010723614531416442011162 0ustar * @version 1.1.1 (August 10, 2005) * @package AutoIndex */ class Admin { /** * @var int The level of the logged in user */ private $level; /** * @var string The name of the logged in user */ private $username; /** * @param string $path The path of the directory to create * @return bool True on success, false on failure */ public static function mkdir_recursive($path) { $path = Item::make_sure_slash($path); if (@is_dir($path)) { return true; } if (!self::mkdir_recursive(dirname($path))) { return false; } return @mkdir($path, 0755); } /** * Deletes a directory and all its contents. * * @param string $path The path of the directory to delete * @return bool True on success, false on failure */ private static function rmdir_recursive($path) { $path = Item::make_sure_slash($path); $list = @scandir($path); if ($list === false) { return false; } foreach ($list as $file) { if ($file == '' || $file == '.' || $file == '..') { continue; } $dir = "$path$file/"; @is_dir($dir) ? self::rmdir_recursive($dir) : @unlink($dir); } return @rmdir($path); } /** * Copies a remote file to the local server. * * @param string $protocol Either ftp:// or http:// * @param string $url The rest of the URL after the protocol */ private static function copy_remote_file($protocol, $url) { if ($protocol == '' || $url == '') { throw new ExceptionDisplay('Please go back and enter a file to copy.'); } global $dir; $local_file = $dir . Item::get_basename($url); if (file_exists($local_file)) { throw new ExceptionDisplay('The file already exists in this directory.'); } $remote = $protocol . $url; $r = fopen($remote, 'rb'); if ($r === false) { throw new ExceptionDisplay('Cannot open remote file for reading: ' . Url::html_output($remote) . ''); } $l = fopen($local_file, 'wb'); if ($l === false) { throw new ExceptionDisplay('Cannot open local file for writing.'); } while (true) { $temp = fread($r, 8192); if ($temp === '') { break; } fwrite($l, $temp); } fclose($l); fclose($r); } /** * @param string $filename The path to the file that stores the info * @param string $old_name The old name of the file or folder to update inside of $filename * @param string $new_name The new name of the file or folder */ private static function update_file_info($filename, $old_name, $new_name) { if (!is_file($filename)) { throw new ExceptionDisplay('The file ' . Url::html_output($filename) . ' does not exist.'); } $text = file_get_contents($filename); if ($text === false) { throw new ExceptionDisplay('Cannot open file ' . Url::html_output($filename) . ' for reading.'); } $h = fopen($filename, 'wb'); if ($h === false) { throw new ExceptionDisplay('Cannot open file ' . Url::html_output($filename) . ' for writing.'); } fwrite($h, preg_replace('/^' . preg_quote($old_name, '/') . '/m', $new_name, $text)); fclose($h); } /** * Validates a potential new password. * * @param string $pass1 The new password * @param string $pass2 The new password typed again */ private static function validate_new_password($pass1, $pass2) { if ($pass1 != $pass2) { throw new ExceptionDisplay('Passwords do not match.'); } if (strlen($pass1) < 6) { throw new ExceptionDisplay('Password must be at least 6 characters long.'); } } /** * Changes a user's password. * * @param string $username The username * @param string $old_pass The user's old password * @param string $new_pass1 The new password * @param string $new_pass2 The new password typed again */ private static function change_password($username, $old_pass, $new_pass1, $new_pass2) { self::validate_new_password($new_pass1, $new_pass2); $accounts = new Accounts(); 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)))) { throw new ExceptionDisplay('Incorrect old password.'); } global $config; $h = @fopen($config->__get('user_list'), 'wb'); if ($h === false) { throw new ExceptionDisplay("Could not open file $user_list for writing." . ' Make sure PHP has write permission to this file.'); } foreach ($accounts as $this_user) { if (strcasecmp($this_user->username, $username) === 0) { $this_user = new User($username, sha1($new_pass1), $this_user->level, $this_user->home_dir); } fwrite($h, $this_user->__toString()); } fclose($h); $_SESSION['password'] = sha1($new_pass1); throw new ExceptionDisplay('Password successfully changed.'); } /** * Changes a user's level. * * @param string $username The username * @param int $new_level The user's new level */ private static function change_user_level($username, $new_level) { if ($new_level < BANNED || $new_level > ADMIN) { throw new ExceptionDisplay('Invalid user level.'); } $accounts = new Accounts(); if (!$accounts->user_exists($username)) { throw new ExceptionDisplay('Cannot change level: username does not exist.'); } global $config; $h = @fopen($config->__get('user_list'), 'wb'); if ($h === false) { throw new ExceptionDisplay("Could not open file $user_list for writing." . ' Make sure PHP has write permission to this file.'); } foreach ($accounts as $this_user) { if (strcasecmp($this_user->username, $username) === 0) { $this_user = new User($username, $this_user->sha1_pass, $new_level, $this_user->home_dir); } fwrite($h, $this_user->__toString()); } fclose($h); throw new ExceptionDisplay('User level successfully changed.'); } /** * @param string $username The name of the new user to create * @param string $pass1 The raw password * @param string $pass2 The raw password repeated again for verification * @param int $level The level of the user (use GUEST USER ADMIN constants) * @param string $home_dir The home directory of the user, or blank for the default */ private static function add_user($username, $pass1, $pass2, $level, $home_dir = '') { self::validate_new_password($pass1, $pass2); $username_reg_exp = '/^[A-Za-z0-9_-]+$/'; if (!preg_match($username_reg_exp, $username)) { throw new ExceptionDisplay('The username must only contain alpha-numeric characters, underscores, or dashes.' . '
It must match the regular expression: ' . Url::html_output($username_reg_exp) . ''); } if ($home_dir != '') { $home_dir = Item::make_sure_slash($home_dir); if (!@is_dir($home_dir)) { throw new ExceptionDisplay('The user\'s home directory is not valid directory.'); } } $list = new Accounts(); if ($list->user_exists($username)) { throw new ExceptionDisplay('This username already exists.'); } global $config; $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()); fclose($h); throw new ExceptionDisplay('User successfully added.'); } /** * @param string $username Deletes user with the name $username */ private static function del_user($username) { $accounts = new Accounts(); if (!$accounts->user_exists($username)) { throw new ExceptionDisplay('Cannot delete user: username does not exist.'); } global $config; $h = @fopen($config->__get('user_list'), 'wb'); if ($h === false) { throw new ExceptionDisplay("Could not open file $user_list for writing." . ' Make sure PHP has write permission to this file.'); } foreach ($accounts as $this_user) { if (strcasecmp($this_user->username, $username) !== 0) { fwrite($h, $this_user->__toString()); } } fclose($h); throw new ExceptionDisplay('User successfully removed.'); } /** * @param User $current_user This user is checked to make sure it really is an admin */ public function __construct(User $current_user) { if (!($current_user instanceof UserLoggedIn)) { throw new ExceptionDisplay('You must be logged in to access this section.'); } $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; } /** * @param string $action */ public function action($action) { //This is a list of the actions moderators can do (otherwise, the user must be an admin) $mod_actions = array('edit_description', 'change_password', 'ftp'); if (in_array(strtolower($action), $mod_actions)) { if ($this->level < MODERATOR) { throw new ExceptionDisplay('You must be a moderator to access this section.'); } } else if ($this->level < ADMIN) { throw new ExceptionDisplay('You must be an administrator to access this section.'); } switch (strtolower($action)) { case 'config': { /** Include the config generator file. */ if (!@include_once(CONFIG_GENERATOR)) { throw new ExceptionDisplay('Error including file ' . CONFIG_GENERATOR . ''); } die(); } case 'rename': { if (!isset($_GET['filename'])) { throw new ExceptionDisplay('No filenames specified.'); } global $dir; $old = $dir . Url::clean_input($_GET['filename']); if (!file_exists($old)) { header('HTTP/1.0 404 Not Found'); throw new ExceptionDisplay('Specified file could not be found.'); } if (isset($_GET['new_name'])) { $new = $dir . Url::clean_input($_GET['new_name']); if ($old == $new) { throw new ExceptionDisplay('Filename unchanged.'); } if (file_exists($new)) { throw new ExceptionDisplay('Cannot overwrite existing file.'); } if (rename($old, $new)) { global $config; if (DOWNLOAD_COUNT) { self::update_file_info($config->__get('download_count'), $old, $new); } if (DESCRIPTION_FILE) { 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') . ')

' . ' ' . ' ' . '

'); } case 'delete': { global $request, $config; $autoindex_u = empty($request->server('PHP_SELF')) ? $config->__get('base_dir') : $request->server('PHP_SELF'); $autoindex_a = str_replace(array('&logout=true', '&logout=true'), array('', ''), $autoindex_u); if ($request->is_not_set_get('filename')) { throw new ExceptionDisplay('No filename specified. Redirection header could not be sent.
' . "Continue here: Main Index"); } if ($request->is_set_get('sure')) { global $dir; $to_delete = $dir . Url::clean_input($request->get('filename')); if (!file_exists($to_delete)) { header('HTTP/1.0 404 Not Found'); throw new ExceptionDisplay('Specified file could not be found. Redirection header could not be sent.
' . "Continue here: Main Index"); } if (is_dir($to_delete)) { if (self::rmdir_recursive($to_delete)) { throw new ExceptionDisplay('Folder successfully deleted. Redirection header could not be sent.
' . "Continue here: Main Index"); } throw new ExceptionDisplay('Error deleting folder. Redirection header could not be sent.
' . "Continue here: Main Index"); } if (unlink($to_delete)) { throw new ExceptionDisplay('File successfully deleted. Redirection header could not be sent.
' . "Continue here: Main Index"); } header("Location: $autoindex_a"); throw new ExceptionDisplay('Error deleting file. Redirection header could not be sent.
' . "Continue here: Main Index"); } global $words, $subdir; throw new ExceptionDisplay('

' . $words->__get('are you sure you want to delete the file') . ' ' . Url::html_output($request->get('filename')) . '?

' . '

' . '' . '

'); } case 'add_user': { if (isset($_POST['username'], $_POST['pass1'], $_POST['pass2'], $_POST['level'], $_POST['home_dir'])) { self::add_user($_POST['username'], $_POST['pass1'], $_POST['pass2'], (int)$_POST['level'], $_POST['home_dir']); } global $words; throw new ExceptionDisplay($words->__get('add user') . ':

' . $words->__get('username') . ':
' . $words->__get('password') . ':
' . $words->__get('password') . ':
' . $words->__get('level') . ':

Home Directory: ' . '
(leave blank to use the default base directory)

'); } case 'change_password': { if (isset($_POST['pass1'], $_POST['pass2'], $_POST['old_pass'])) { self::change_password($this->username, $_POST['old_pass'], $_POST['pass1'], $_POST['pass2']); } throw new ExceptionDisplay('

Old password:
New password:
New password:

'); } case 'change_user_level': { if (isset($_POST['username'], $_POST['level'])) { self::change_user_level($_POST['username'], (int)$_POST['level']); } $accounts = new Accounts(); $out = '

Select user:

Select new level:

'); } case 'del_user': { if (isset($_POST['username'])) { if (isset($_POST['sure'])) { self::del_user($_POST['username']); } global $words; throw new ExceptionDisplay('

' . $words->__get('are you sure you want to remove the user') . ' '.$_POST['username'] . '?

' . '
' . '

'); } global $words; $accounts = new Accounts(); $out = '

' . $words->__get('select user to remove') . ':

'); } case 'edit_description': { if (isset($_GET['filename'])) { global $dir; $filename = $dir . $_GET['filename']; if (isset($_GET['description'])) { global $descriptions, $config; 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'); if ($h === false) { throw new ExceptionDisplay('Could not open description file for writing.' . ' Make sure PHP has write permission to this file.'); } foreach ($descriptions as $file => $info) { fwrite($h, "$file\t" . (($file == $filename) ? $_GET['description'] : $info) . "\n"); } fclose($h); //update the new description in memory $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'); if ($h === false) { throw new ExceptionDisplay('Could not open description file for writing.' . ' Make sure PHP has write permission to this file.'); } fwrite($h, "$filename\t" . $_GET['description'] . "\n"); fclose($h); //read the description file with the updated data $descriptions = new ConfigData($config->__get('description_file')); } } else { global $words, $subdir, $descriptions; $current_desc = (DESCRIPTION_FILE && $descriptions->is_set($filename) ? $descriptions->__get($filename) : ''); throw new ExceptionDisplay('

' . $words->__get('enter the new description for the file') . ' ' . Url::html_output($_GET['filename']) . ':

' . '

'); } } else { throw new ExceptionDisplay('No filename specified.'); } break; } case 'edit_hidden': { if (!HIDDEN_FILES) { throw new ExceptionDisplay('The file hiding system is not in use. To enable it, reconfigure the script.'); } global $hidden_list; if (isset($_GET['add']) && $_GET['add'] != '') { global $config; $h = @fopen($config->__get('hidden_files'), 'ab'); if ($h === false) { throw new ExceptionDisplay('Unable to open hidden files list for writing.'); } fwrite($h, $_GET['add'] . "\n"); fclose($h); throw new ExceptionDisplay('Hidden file added.'); } if (isset($_GET['remove'])) { global $config; $h = @fopen($config->__get('hidden_files'), 'wb'); if ($h === false) { throw new ExceptionDisplay('Unable to open hidden files list for writing.'); } foreach ($hidden_list as $hid) { if ($hid != $_GET['remove']) { fwrite($h, $hid . "\n"); } } fclose($h); throw new ExceptionDisplay('Hidden file removed.'); } global $words; $str = '

' . $words->__get('add a new hidden file') . ':

' . '

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.

' . '

'; $str .= '

' . $words->__get('remove a hidden file') . ':

'; throw new ExceptionDisplay($str); } case 'edit_banned': { if (!BANNED_LIST) { throw new ExceptionDisplay('The banning system is not in use. To enable it, reconfigure the script.'); } if (isset($_GET['add']) && $_GET['add'] != '') { global $config; $h = @fopen($config->__get('banned_list'), 'ab'); if ($h === false) { throw new ExceptionDisplay('Unable to open banned_list for writing.'); } fwrite($h, $_GET['add'] . "\n"); fclose($h); throw new ExceptionDisplay('Ban added.'); } if (isset($_GET['remove'])) { global $b_list, $config; $h = @fopen($config->__get('banned_list'), 'wb'); if ($h === false) { throw new ExceptionDisplay('Unable to open banned_list for writing.'); } foreach ($b_list as $ban) { if ($ban != $_GET['remove']) { fwrite($h, $ban . "\n"); } } fclose($h); throw new ExceptionDisplay('Ban removed.'); } global $b_list, $words, $request; $str = '

' . $words->__get('add a new ban') . ':

' . '

'; $str .= '

' . $words->__get('remove a ban') . ':

'; throw new ExceptionDisplay($str); } case 'stats': { if (!LOG_FILE) { throw new ExceptionDisplay('The logging system has not been enabled.'); } $stats = new Stats(); $stats->display(); break; } case 'view_log': { if (!LOG_FILE) { throw new ExceptionDisplay('The logging system has not been enabled.'); } global $log; if (isset($_GET['num'])) { $log->display((int)$_GET['num']); } global $words, $request; throw new ExceptionDisplay($words->__get('how many entries would you like to view') . '?
' . '
'); } case 'create_dir': { if (isset($_GET['name'])) { global $dir; if (!self::mkdir_recursive($dir . $_GET['name'])) { throw new ExceptionDisplay('Error creating new folder.'); } } else { global $words, $subdir; throw new ExceptionDisplay('

' . $words->__get('enter the new name') . ':

' . '

'); } break; } case 'copy_url': { if (isset($_GET['protocol'], $_GET['copy_file'])) { self::copy_remote_file(rawurldecode($_GET['protocol']), rawurldecode($_GET['copy_file'])); throw new ExceptionDisplay('Copy was successful.'); } global $dir; $text = '

Enter the name of the remote file you would like to copy:

http://
ftp://

'; echo new Display($text); die(); } case 'ftp': { if (isset($_POST['host'], $_POST['port'], $_POST['directory'], $_POST['ftp_username'], $_POST['ftp_password'])) { if ($_POST['host'] == '') { throw new ExceptionDisplay('Please go back and enter a hostname.'); } if ($_POST['ftp_username'] == '' && $_POST['ftp_password'] == '') //anonymous login { $_POST['ftp_username'] = 'anonymous'; $_POST['ftp_password'] = 'autoindex@sourceforge.net'; } if ($_POST['directory'] == '') { $_POST['directory'] = './'; } if ($_POST['port'] == '') { $_POST['port'] = 21; } $_SESSION['ftp'] = array( 'host' => $_POST['host'], 'port' => (int)$_POST['port'], 'directory' => Item::make_sure_slash($_POST['directory']), 'username' => $_POST['ftp_username'], 'password' => $_POST['ftp_password'], 'passive' => isset($_POST['passive']) ); } if (isset($_GET['set_dir'])) { $_SESSION['ftp']['directory'] = $_GET['set_dir']; } global $subdir; if (isset($_GET['ftp_logout'])) { unset($_SESSION['ftp']); $text = '

Logout successful. Go back.

'; } else if (isset($_SESSION['ftp'])) { try { $ftp = new Ftp($_SESSION['ftp']['host'], $_SESSION['ftp']['port'], $_SESSION['ftp']['passive'], $_SESSION['ftp']['directory'], $_SESSION['ftp']['username'], $_SESSION['ftp']['password']); } catch (ExceptionFatal $e) { unset($_SESSION['ftp']); throw $e; } if (isset($_GET['filename']) && $_GET['filename'] != '') //transfer local to FTP { global $dir; $name = rawurldecode($_GET['filename']); $ftp->put_file($dir . $name, Item::get_basename($name)); throw new ExceptionDisplay('File successfully transferred to FTP server.'); } if (isset($_GET['transfer']) && $_GET['transfer'] != '') //transfer FTP to local { global $dir; $name = rawurldecode($_GET['transfer']); $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
Back to index.

'; } else { $text = '

FTP server: port
Passive Mode

Username:
Password: (Leave these blank to login anonymously)

Directory:

Back to index.

'; } echo new Display($text); die(); } default: { throw new ExceptionDisplay('Invalid admin action.'); } } } /** * @return string The HTML text that makes up the admin panel */ public function __toString() { global $words, $subdir, $request; $str = ''; //only ADMIN accounts if ($this->level >= ADMIN) $str = '

' . $words->__get('reconfigure script') . '

' . $words->__get('edit list of hidden files') . '
' . $words->__get('edit ban list') . '

' . $words->__get('create new directory in this folder') . '
' . $words->__get('copy url') . '

' . $words->__get('view entries from log file') . '
' . $words->__get('view statistics from log file') . '

' . $words->__get('add new user') . '
' . $words->__get('delete user') . '
Change a user\'s level

'; //MODERATOR and ADMIN accounts if ($this->level >= MODERATOR) $str .= '

Change your password

FTP browser

'; return $str; } } ?>classes/ConfigData.php0000755000000000000000000002011214576276355012134 0ustar * @version 1.0.2 (January 13, 2005) * @package AutoIndex */ class ConfigData implements Iterator { /** * @var array A list of all the settings */ private $config; /** * @var string The name of the file to read the settings from */ private $filename; //begin implementation of Iterator /** * @var bool */ private $valid; /** * @return string */ #[\ReturnTypeWillChange] public function current() { return current($this->config); } /** * Increments the internal array pointer, and returns the new value. * * @return string */ #[\ReturnTypeWillChange] public function next() { $t = next($this->config); if ($t === false) { $this -> valid = false; } return $t; } /** * Sets the internal array pointer to the beginning. */ #[\ReturnTypeWillChange] public function rewind() { reset($this->config); } /** * @return bool */ #[\ReturnTypeWillChange] public function valid() { return $this->valid; } /** * @return string */ #[\ReturnTypeWillChange] public function key() { return key($this->config); } //end implementation of Iterator /** * @param string $line The line to test * @return bool True if $line starts with characters that mean it is a comment */ public static function line_is_comment($line) { $line = trim($line); return (($line == '') || preg_match('@^(//|<\?|\?>|/\*|\*/|#)@', $line)); } /** * @param string $file The filename to read the data from */ public function __construct($file) { if ($file === false) { return; } $this -> valid = true; $this -> filename = $file; $contents = file($file); if ($contents === false) { throw new ExceptionFatal('Error reading file ' . Url::html_output($file) . ''); } foreach ($contents as $i => $line) { $line = rtrim($line, "\r\n"); if (self::line_is_comment($line)) { continue; } $parts = explode("\t", $line, 2); if (count($parts) !== 2 || $parts[0] == '' || $parts[1] == '') { throw new ExceptionFatal('Incorrect format for file ' . Url::html_output($file) . ' on line ' . ($i + 1) . '.
Format is "variable name[tab]value"'); } if (isset($this -> config[$parts[0]])) { throw new ExceptionFatal('Error in ' . Url::html_output($file) . ' on line ' . ($i + 1) . '.
' . Url::html_output($parts[0]) . ' is already defined.'); } $this->config[$parts[0]] = $parts[1]; } } /** * @param string $file we do not use explode() in PHP7+ * The filename to read the data from */ public function dos_description($full_name, $file = './descript.ion') { if ($file === false) { return; } $this -> valid = true; //trim path $file_dir = trim(dirname($file)); //trim file name $file_name = trim(basename($full_name)); if (strpos($full_name, '.') !== false) { // Nested file $filename_ext = substr(strrchr($full_name, '.'), 1); } //rebuild path $file_path = $file_dir . "/{$file_name}"; $contents = file($file); if ($contents === false) { throw new ExceptionFatal('Error reading file ' . Url::html_output($file) . ''); } foreach ($contents as $i => $line) { $line = rtrim($line, "\r\n"); if (self::line_is_comment($line)) { continue; } $parts = explode($file_name, $line); if (count($parts) > 0) { //throw new ExceptionFatal('Incorrect format for file explode on ' . $full_name . ' line: ' . print_r($line, true) . ' ' . Url::html_output($file) . ' on line ' . ($i + 1) . '.
Format is "file name[space]value"'); return empty($parts[1]) ? $parts[0] : $parts[1]; } return false; } } /** * Returns a list of all files in $path that match the filename format * of themes files. * * There are two valid formats for the filename of a template folder.. * * @param string $path The directory to read from * @return array The list of valid theme names (based on directory name) */ public static function get_all_styles($path = PATH_TO_TEMPLATES) { if (($hndl = @opendir($path)) === false) { echo 'Did try to open dir: ' . $path; return false; } $themes_array = $installable_themes = array(); $style_id = 0; while (($sub_dir = readdir($hndl)) !== false) { // get the sub-template path if( !is_file(@realpath($path . $sub_dir)) && !is_link(@realpath($path . $sub_dir)) && $sub_dir != "." && $sub_dir != ".." && $sub_dir != "CVS" ) { if(@file_exists(realpath($path . $sub_dir . "/$sub_dir.css")) || @file_exists(realpath($path . $sub_dir . "/default.css")) ) { $themes[] = array('template' => $path . $sub_dir . '/', 'template_name' => $sub_dir, 'style_id' => $style_id++); } } } closedir($hndl); return $themes; } /** * $config[$key] will be set to $info. * * @param string $key * @param string $info */ public function set($key, $info) { $this->config[$key] = $info; } /** * This will look for the key $item, and add one to the $info (assuming * it is an integer). * * @param string $item The key to look for */ public function add_one($item) { if ($this->is_set($item)) { $h = fopen($this->filename, 'wb'); if ($h === false) { throw new ExceptionFatal('Could not open file ' . Url::html_output($this->filename) . ' for writing. Make sure PHP has write permission to this file.'); } foreach ($this as $current_item => $count) { fwrite($h, "$current_item\t" . (($current_item == $item) ? ((int)$count + 1) : $count) . "\n"); } } else { $h = fopen($this->filename, 'ab'); if ($h === false) { throw new ExceptionFatal('Could not open file ' . $this->filename . ' for writing.' . ' Make sure PHP has write permission to this file.'); } fwrite($h, "$item\t1\n"); } fclose($h); } /** * @param string $name The key to look for * @return bool True if $name is set */ public function is_set($name) { return isset($this->config[$name]); } /** * @param string $name The key to look for * @return string The value $name points to */ public function __get($name) { global $request; if ($request->is_set_get('style') && $name == 'template') { $style = $request->is_set('style') ? $request->variable('style', '') : 0; $themes = $this->get_all_styles($this->config['template_path']); $template_path = $request->is_set('style') ? $themes[$style]['template'] : $this->config['template']; return $template_path; } if (isset($this->config[$name])) { return $this->config[$name]; } throw new ExceptionFatal('Setting ' . Url::html_output($name) . ' is missing in file ' . Url::html_output($this -> filename) . '.'); } } ?>classes/Deactivated_Super_Globals.php0000755000000000000000000000751113770256216015170 0ustar request = $request; $this->name = $name; $this->super_global = $super_global; } /** * Calls trigger_error with the file and line number the super global was used in. */ private function error() { $file = ''; $line = 0; $message = 'Illegal use of $' . $this->name . '. You must use the request class to access input data. Found in %s on line %d. This error message was generated by deactivated_super_global.'; $backtrace = debug_backtrace(); if (isset($backtrace[1])) { $file = $backtrace[1]['file']; $line = $backtrace[1]['line']; } trigger_error(sprintf($message, $file, $line), E_USER_ERROR); } /** * Redirects isset to the correct request class call. * * @param string $offset The key of the super global being accessed. * * @return bool Whether the key on the super global exists. */ public function offsetExists($offset) { return $this->request->is_set($offset, $this->super_global); } /**#@+ * Part of the \ArrayAccess implementation, will always result in a FATAL error. */ public function offsetGet($offset) { $this->error(); } public function offsetSet($offset, $value) { $this->error(); } public function offsetUnset($offset) { $this->error(); } /**#@-*/ /** * Part of the \Countable implementation, will always result in a FATAL error */ public function count() { $this->error(); } /** * Part of the Traversable/IteratorAggregate implementation, will always result in a FATAL error */ public function getIterator() { $this->error(); } } // class deactivated_super_global ?>classes/DirItem.php0000755000000000000000000021315114525111235011454 0ustar * @version 1.0.1 (June 30, 2004) * @package AutoIndex */ class DirItem extends Item { /** * @var DirectoryList The list of this directory's contents */ private $temp_list; /** * @var string */ protected $description; protected $config; protected $request; /** * @return string Always returns 'dir', since this is a directory, not a file */ public function file_ext() { return 'dir'; } /** * @return int The total size in bytes of the folder (recursive) */ private function dir_size() { if (!isset($this->temp_list)) { $this->temp_list = new DirectoryList($this->parent_dir . $this->filename); } return $this->temp_list->size_recursive(); } /** * @return int The total number of files in the folder (recursive) */ public function num_subfiles() { if (!isset($this->temp_list)) { $this->temp_list = new DirectoryList($this->parent_dir . $this->filename); } return $this->temp_list->num_files(); } /** * @param string $path * @return string The parent directory of $path */ public static function get_parent_dir($path) { $path = str_replace('\\', '/', $path); while (preg_match('#/$#', $path)) //remove all slashes from the end { $path = substr($path, 0, -1); } $pos = strrpos($path, '/'); if ($pos === false) { return ''; } $path = substr($path, 0, $pos + 1); return (($path === false) ? '' : $path); } /** * @param string $parent_dir * @param string $filename */ public function __construct($parent_dir, $filename) { $filename = self::make_sure_slash($filename); parent::__construct($parent_dir, $filename); global $config, $subdir, $request; $this->downloads = ' '; $lang_arg = $request->is_request('lang', TYPE_NO_TAGS) ? '&lang=' . $request->request('lang') : ''; if ($filename == '../') //link to parent directory { if ($subdir != '') { global $words; $this->is_parent_dir = true; $this->filename = $words->__get('parent directory'); $this->icon = (ICON_PATH ? $config->__get('icon_path') . 'blank.png' : ''); $this->size = new Size(true); $this->link = Url::html_output($request->server('PHP_SELF')) . '?dir=' . Url::translate_uri(self::get_parent_dir($subdir)) . $lang_arg; $this->parent_dir = $this->new_icon = ''; $this->a_time = $this->m_time = false; } else { $this->is_parent_dir = $this->filename = false; } } else { //regular folder $file = $this->parent_dir . $filename; if (!is_dir($file)) { throw new ExceptionDisplay('Directory ' . Url::html_output($this->parent_dir . $filename) . ' does not exist.'); } if (!function_exists('mb_strlen')) { function mb_strlen($text) { strlen($text); } } $this->filename = $filename = substr($filename, 0, -1); $mb_strlen = mb_strlen($filename); if (($mb_strlen > 1) && ($mb_strlen < 6)) { $decoded_lang_name = self::decode_country_name($filename, 'language'); //Language Folders and Dirs with ICON files if (!empty($decoded_lang_name)) { $this->icon = FLAG_PATH ? $config->__get('flag_path') . $filename . '.png' : $config->__get('icon_path') . $filename . '.png'; } } //Special common folders switch ($filename) { case 'apps': case 'docs': case 'books': case 'Docs': case 'irc': case 'patch': case 'sega': case 'sky': case 'Fonts': case 'fonts': $this->icon = $config->__get('icon_path') . $filename . '.png'; break; case 'skin': case 'dev': case 'drv': case 'lib': case 'inc': case 'hlt': case 'util': case 'src': case 'demo': default: $this->icon = $config->__get('icon_path') . 'dir.png'; break; } if (($mb_strlen > 1) && ($mb_strlen < 25)) { $decoded_lang_name = self::decode_country_name($filename, 'language'); $file_name = substr($filename, 0, strrpos($filename, '.')); global $descriptions, $words, $request; if ($words->is_set($file_name)) { $description = ($words->is_set($file_name) ? $words->__get($file_name) : $file_name); } elseif (!empty($decoded_lang_name)) { $description = ($words->is_set($decoded_lang_name) ? $words->__get($decoded_lang_name) : $decoded_lang_name); } else { $description = ($words->is_set($file_name) ? $words->__get($file_name) : $file_name); } $this->description = ($words->is_set($description) ? $words->__get($description) : $description); } $this->link = Url::html_output($request->server('PHP_SELF')) . '?dir=' . Url::translate_uri(substr($this->parent_dir, strlen($config->__get('base_dir'))) . $filename) . $lang_arg; } } /** * function decode_lang from mx_traslator phpBB3 Extension * * $mx_user_lang = decode_country_name($lang['USER_LANG'], 'country'); * * @param unknown_type $file_dir * @param unknown_type $lang_country = 'country' or 'language' * @param array $langs_countries * @return unknown */ private function decode_country_name($file_dir, $lang_country = 'country', $langs_countries = false) { /* known languages */ switch ($file_dir) { case 'aa': $lang_name = 'AFAR'; $country_name = 'AFAR'; //Ethiopia break; case 'aae': $lang_name = 'AFRICAN-AMERICAN_ENGLISH'; $country_name = 'UNITED_STATES'; break; case 'ab': $lang_name = 'ABKHAZIAN'; $country_name = 'ABKHAZIA'; break; case 'ad': $lang_name = 'ANGOLA'; $country_name = 'ANGOLA'; break; case 'ae': $lang_name = 'AVESTAN'; $country_name = 'UNITED_ARAB_EMIRATES'; //Persia break; case 'af': $country_name = 'AFGHANISTAN'; // langs: pashto and dari $lang_name = 'AFRIKAANS'; // speakers: 6,855,082 - 13,4% break; case 'ag': $lang_name = 'ENGLISH-CREOLE'; $country_name = 'ANTIGUA_&_BARBUDA'; break; case 'ai': $lang_name = 'Anguilla'; $country_name = 'ANGUILLA'; break; case 'aj': case 'rup': $lang_name = 'AROMANIAN'; $country_name = 'BALCANS'; //$country_name = 'Aromaya'; break; case 'ak': $lang_name = 'AKAN'; $country_name = ''; break; case 'al': $lang_name = 'ALBANIAN'; $country_name = 'ALBANIA'; break; case 'am': $lang_name = 'AMHARIC'; //$lang_name = 'armenian'; $country_name = 'ARMENIA'; break; case 'an': $lang_name = 'ARAGONESE'; // //$country_name = 'Andorra'; $country_name = 'NETHERLAND_ANTILLES'; break; case 'ao': $lang_name = 'ANGOLIAN'; $country_name = 'ANGOLA'; break; case 'ap': $lang_name = 'ANGIKA'; $country_name = 'ANGA'; //India break; case 'ar': $lang_name = 'ARABIC'; $country_name = 'ARGENTINA'; break; case 'aru': $lang_name = 'AROMANIAN'; $country_name = 'BALCANS'; break; case 'arq': $lang_name = 'ALGERIAN_ARABIC'; //known as Darja or Dziria in Algeria $country_name = 'ALGERIA'; break; case 'arc': $country_name = 'ASHURIA'; $lang_name = 'ARAMEIC'; break; case 'ary': $lang_name = 'MOROCCAN_ARABIC'; //known as Moroccan Arabic or Moroccan Darija or Algerian Saharan Arabic $country_name = 'MOROCCO'; break; //jrb – Judeo-Arabic //yhd – Judeo-Iraqi Arabic //aju – Judeo-Moroccan Arabic //yud – Judeo-Tripolitanian Arabic //ajt – Judeo-Tunisian Arabic //jye – Judeo-Yemeni Arabic case 'jrb': $lang_name = 'JUDEO-ARABIC'; $country_name = 'JUDEA'; break; case 'kab': $lang_name = 'KABYLE'; //known as Kabyle (Tamazight) $country_name = 'ALGERIA'; break; case 'aq': $lang_name = ''; $country_name = 'ANTARCTICA'; break; case 'as': $lang_name = 'ASSAMESE'; $country_name = 'AMERICAN_SAMOA'; break; case 'at': $lang_name = 'GERMAN'; $country_name = 'AUSTRIA'; break; case 'av': $lang_name = 'AVARIC'; $country_name = ''; break; case 'av-da': case 'av_da': case 'av_DA': $lang_name = 'AVARIAN_KHANATE'; $country_name = 'Daghestanian'; break; case 'ay': $lang_name = 'AYMARA'; $country_name = ''; break; case 'aw': $lang_name = 'ARUBA'; $country_name = 'ARUBA'; break; case 'au': $lang_name = 'en-au'; // $country_name = 'AUSTRALIA'; break; case 'az': $lang_name = 'AZERBAIJANI'; $country_name = 'AZERBAIJAN'; break; case 'ax': $lang_name = 'FINNISH'; $country_name = 'ÅLAND_ISLANDS'; //The Åland Islands or Åland (Swedish: Åland, IPA: [ˈoːland]; Finnish: Ahvenanmaa) is an archipelago province at the entrance to the Gulf of Bothnia in the Baltic Sea belonging to Finland. break; case 'ba': $lang_name = 'BASHKIR'; //Baskortostán (Rusia) $country_name = 'BOSNIA_&_HERZEGOVINA'; //Bosnian, Croatian, Serbian break; //Bavarian (also known as Bavarian Austrian or Austro-Bavarian; Boarisch [ˈbɔɑrɪʃ] or Bairisch; //German: Bairisch [ˈbaɪʁɪʃ] (About this soundlisten); Hungarian: bajor. case 'bar': $lang_name = 'BAVARIAN'; $country_name = 'BAVARIA'; //Germany break; case 'bb': $lang_name = 'Barbados'; $country_name = 'BARBADOS'; break; case 'bd': $lang_name = 'Bangladesh'; $country_name = 'BANGLADESH'; break; case 'be': $lang_name = 'BELARUSIAN'; $country_name = 'BELGIUM'; break; case 'bf': $lang_name = 'Burkina Faso'; $country_name = 'BURKINA_FASO'; break; case 'bg': $lang_name = 'BULGARIAN'; $country_name = 'BULGARIA'; break; case 'bh': $lang_name = 'BHOJPURI'; // Bihar (India) $country_name = 'BAHRAIN'; // Mamlakat al-Ba?rayn (arabic) break; case 'bi': $lang_name = 'BISLAMA'; $country_name = 'BURUNDI'; break; case 'bj': $lang_name = 'BENIN'; $country_name = 'BENIN'; break; case 'bl': $lang_name = 'BONAIRE'; $country_name = 'BONAIRE'; break; case 'bm': $lang_name = 'BAMBARA'; $country_name = 'Bermuda'; break; case 'bn': $country_name = 'BRUNEI'; $lang_name = 'BENGALI'; break; case 'bo': $lang_name = 'TIBETAN'; $country_name = 'BOLIVIA'; break; case 'br': $lang_name = 'BRETON'; $country_name = 'BRAZIL'; //pt break; case 'bs': $lang_name = 'BOSNIAN'; $country_name = 'BAHAMAS'; break; case 'bt': $lang_name = 'Bhutan'; $country_name = 'Bhutan'; break; case 'bw': $lang_name = 'Botswana'; $country_name = 'BOTSWANA'; break; case 'bz': $lang_name = 'BELIZE'; $country_name = 'BELIZE'; break; case 'by': $lang_name = 'BELARUSIAN'; $country_name = 'Belarus'; break; case 'en-CM': case 'en_cm': $lang_name = 'CAMEROONIAN_PIDGIN_ENGLISH'; $country_name = 'Cameroon'; break; case 'wes': $lang_name = 'CAMEROONIAN'; //Kamtok $country_name = 'CAMEROON'; //Wes Cos break; case 'cm': $lang_name = 'CAMEROON'; $country_name = 'CAMEROON'; break; case 'ca': $lang_name = 'CATALAN'; $country_name = 'CANADA'; break; case 'cc': $lang_name = 'COA_A_COCOS'; //COA A Cocos dialect of Betawi Malay [ente (you) and ane (me)] and AU-English $country_name = 'COCOS_ISLANDS'; //CC Cocos (Keeling) Islands break; case 'cd': $lang_name = 'Congo Democratic Republic'; $country_name = 'CONGO_DEMOCRATIC_REPUBLIC'; break; //нохчийн мотт case 'ce': $lang_name = 'CHECHEN'; $country_name = 'Chechenya'; break; case 'cf': $lang_name = 'Central African Republic'; $country_name = 'CENTRAL_AFRICAN_REPUBLIC'; break; case 'cg': $lang_name = 'CONGO'; $country_name = 'CONGO'; break; case 'ch': $lang_name = 'CHAMORRO'; //Finu' Chamoru $country_name = 'SWITZERLAND'; break; case 'ci': $lang_name = 'Cote D-Ivoire'; $country_name = 'COTE_D-IVOIRE'; break; case 'ck': $lang_name = ''; $country_name = 'COOK_ISLANDS'; //CK Cook Islands break; case 'cl': $lang_name = 'Chile'; $country_name = 'CHILE'; break; case 'cn': //Chinese Macrolanguage case 'zh': //639-1: zh case 'chi': //639-2/B: chi case 'zho': //639-2/T and 639-3: zho $lang_name = 'CHINESE'; $country_name = 'CHINA'; break; //Chinese Individual Languages // 中文 // Fujian Province, Republic of China case 'cn-fj': // 閩東話 case 'cdo': //Chinese Min Dong $lang_name = 'CHINESE_DONG'; $country_name = 'CHINA'; break; //1. Bingzhou spoken in central Shanxi (the ancient Bing Province), including Taiyuan. //2. Lüliang spoken in western Shanxi (including Lüliang) and northern Shaanxi. //3. Shangdang spoken in the area of Changzhi (ancient Shangdang) in southeastern Shanxi. //4. Wutai spoken in parts of northern Shanxi (including Wutai County) and central Inner Mongolia. //5. Da–Bao spoken in parts of northern Shanxi and central Inner Mongolia, including Baotou. //6. Zhang-Hu spoken in Zhangjiakou in northwestern Hebei and parts of central Inner Mongolia, including Hohhot. //7. Han-Xin spoken in southeastern Shanxi, southern Hebei (including Handan) and northern Henan (including Xinxiang). //8. Zhi-Yan spoken in Zhidan County and Yanchuan County in northern Shaanxi. // 晋语 / 晉語 case 'cjy': //Chinese Jinyu 晉 $lang_name = 'CHINA_JINYU'; $country_name = 'CHINA'; break; // Cantonese is spoken in Hong Kong // 官話 case 'cmn': //Chinese Mandarin 普通话 (Pǔ tōng huà) literally translates into “common tongue.” $lang_name = 'CHINESE_MANDARIN'; $country_name = 'CHINA'; break; // Mandarin is spoken in Mainland China and Taiwan // 閩語 / 闽语 //semantic shift has occurred in Min or the rest of Chinese: //*tiaŋB 鼎 "wok". The Min form preserves the original meaning "cooking pot". //*dzhənA "rice field". scholars identify the Min word with chéng 塍 (MC zying) "raised path between fields", but Norman argues that it is cognate with céng 層 (MC dzong) "additional layer or floor". //*tšhioC 厝 "house". the Min word is cognate with shù 戍 (MC syuH) "to guard". //*tshyiC 喙 "mouth". In Min this form has displaced the common Chinese term kǒu 口. It is believed to be cognate with huì 喙 (MC xjwojH) "beak, bill, snout; to pant". //Austroasiatic origin for some Min words: //*-dəŋA "shaman" compared with Vietnamese đồng (/ɗoŋ2/) "to shamanize, to communicate with spirits" and Mon doŋ "to dance (as if) under demonic possession". //*kiɑnB 囝 "son" appears to be related to Vietnamese con (/kɔn/) and Mon kon "child". // Southern Min: // Datian Min; // Hokkien 話; Hokkien-Taiwanese 閩台泉漳語 - Philippine Hokkien 咱儂話. // Teochew; // Zhenan Min; // Zhongshan Min, etc. //Pu-Xian Min (Hinghwa); Putian dialect: Xianyou dialect. //Northern Min: Jian'ou dialect; Jianyang dialect; Chong'an dialect; Songxi dialect; Zhenghe dialect; //Shao-Jiang Min: Shaowu dialect, Jiangle dialect, Guangze dialect, Shunchang dialect; //http://www.shanxigov.cn/ //Central Min: Sanming dialect; Shaxian dialect; Yong'an dialect, //Leizhou Min : Leizhou Min. //Abbreviation //Simplified Chinese: 闽 //Traditional Chinese: 閩 //Literal meaning: Min [River] //莆仙片 case 'cpx': //Chinese Pu-Xian Min, Sing-iú-uā / 仙游話, (Xianyou dialect) http://www.putian.gov.cn/ $lang_name = 'CHINESE_PU-XIAN'; $country_name = 'CHINA'; break; // 徽語 case 'czh': //Chinese HuiZhou 惠州 http://www.huizhou.gov.cn/ | Song dynasty $lang_name = 'CHINESE_HUIZHOU'; $country_name = 'CHINA'; break; // 閩中片 case 'czo': //Chinese Min Zhong 閩中語 | 闽中语 http://zx.cq.gov.cn/ | Zhong-Xian | Zhong 忠县 $lang_name = 'CHINESE_ZHONG'; $country_name = 'CHINA'; break; // 東干話 SanMing: http://www.sm.gov.cn/ | Sha River (沙溪) case 'dng': //Ding Chinese $lang_name = 'DING_CHINESE'; $country_name = 'CHINA'; break; // 贛語 case 'gan': //Gan Chinese $lang_name = 'GAN_CHINESE'; $country_name = 'CHINA'; break; // 客家話 case 'hak': //Chinese Hakka $lang_name = 'CHINESE_HAKKA'; $country_name = 'CHINA'; break; case 'hsn': //Xiang Chinese 湘語/湘语 $lang_name = 'XIANG_CHINESE'; $country_name = 'CHINA'; break; // 文言 case 'lzh': //Literary Chinese $lang_name = 'LITERARY_CHINESE'; $country_name = 'CHINA'; break; // 閩北片 case 'mnp': //Min Bei Chinese $lang_name = 'MIN_BEI_CHINESE'; $country_name = 'CHINA'; break; // 閩南語 case 'nan': //Min Nan Chinese $lang_name = 'MIN_NAN_CHINESE'; $country_name = 'CHINA'; break; // 吴语 case 'wuu': //Wu Chinese $lang_name = 'WU_CHINESE'; $country_name = 'CHINA'; break; // 粵語 case 'yue': //Yue or Cartonese Chinese $lang_name = 'YUE_CHINESE'; $country_name = 'CHINA'; break; case 'co': $lang_name = 'CORSICAN'; // Corsica $country_name = 'COLUMBIA'; break; //Eeyou Istchee ᐄᔨᔨᐤ ᐊᔅᒌ case 'cr': $lang_name = 'CREE'; $country_name = 'COSTA_RICA'; break; case 'cs': $lang_name = 'CZECH'; $country_name = 'CZECH_REPUBLIC'; break; case 'cu': $lang_name = 'SLAVONIC'; $country_name = 'CUBA'; //langs: break; case 'cv': $country_name = 'CAPE_VERDE'; $lang_name = 'CHUVASH'; break; case 'cx': $lang_name = ''; // Malaysian Chinese origin and European Australians $country_name = 'CHRISTMAS_ISLAND'; break; case 'cy': $lang_name = 'CYPRUS'; $country_name = 'CYPRUS'; break; case 'cz': $lang_name = 'CZECH'; $country_name = 'CZECH_REPUBLIC'; break; case 'cw': $lang_name = 'PAPIAMENTU'; // Papiamentu (Portuguese-based Creole), Dutch, English $country_name = 'CURAÇÃO'; // Ilha da Curação (Island of Healing) break; case 'da': $lang_name = 'DANISH'; $country_name = 'DENMARK'; break; //Geman (Deutsch) /* deu – German gmh – Middle High German goh – Old High German gct – Colonia Tovar German bar – Bavarian cim – Cimbrian geh – Hutterite German ksh – Kölsch nds – Low German sli – Lower Silesian ltz – Luxembourgish vmf – Mainfränkisch mhn – Mòcheno pfl – Palatinate German pdc – Pennsylvania German pdt – Plautdietsch swg – Swabian German gsw – Swiss German uln – Unserdeutsch sxu – Upper Saxon wae – Walser German wep – Westphalian hrx – Riograndenser Hunsrückisch yec – Yenish */ //Germany 84,900,000 75,101,421 (91.8%) 5,600,000 (6.9%) De facto sole nationwide official language case 'de': case 'de-DE': case 'de_de': case 'deu': $lang_name = 'GERMAN'; $country_name = 'GERMANY'; break; //Belgium 11,420,163 73,000 (0.6%) 2,472,746 (22%) De jure official language in the German speaking community case 'de_be': case 'de-BE': $lang_name = 'BELGIUM_GERMAN'; $country_name = 'BELGIUM'; break; //Austria 8,838,171 8,040,960 (93%) 516,000 (6%) De jure sole nationwide official language case 'de_at': case 'de-AT': $lang_name = 'AUSTRIAN_GERMAN'; $country_name = 'AUSTRIA'; break; // Switzerland 8,508,904 5,329,393 (64.6%) 395,000 (5%) Co-official language at federal level; de jure sole official language in 17, co-official in 4 cantons (out of 26) case 'de_sw': case 'de-SW': $lang_name = 'SWISS_GERMAN'; $country_name = 'SWITZERLAND'; break; //Luxembourg 602,000 11,000 (2%) 380,000 (67.5%) De jure nationwide co-official language case 'de_lu': case 'de-LU': case 'ltz': $lang_name = 'LUXEMBOURG_GERMAN'; $country_name = 'LUXEMBOURG'; break; //Liechtenstein 37,370 32,075 (85.8%) 5,200 (13.9%) De jure sole nationwide official language //Alemannic, or rarely Alemmanish case 'de_li': case 'de-LI': $lang_name = 'LIECHTENSTEIN_GERMAN'; $country_name = 'LIECHTENSTEIN'; break; case 'gsw': $lang_name = 'Alemannic_German'; $country_name = 'SWITZERLAND'; break; //mostly spoken on Lifou Island, Loyalty Islands, New Caledonia. case 'dhv': $lang_name = 'DREHU'; $country_name = 'NEW_CALEDONIA'; break; case 'pdc': //Pennsilfaanisch-Deitsche $lang_name = 'PENNSYLVANIA_DUTCH'; $country_name = 'PENNSYLVANIA'; break; case 'dk': $lang_name = 'DANISH'; $country_name = 'DENMARK'; break; //acf – Saint Lucian / Dominican Creole French case 'acf': $lang_name = 'DOMINICAN_CREOLE_FRENCH'; //ROSEAU $country_name = 'DOMINICA'; break; case 'en_dm': case 'en-DM': $lang_name = 'DOMINICA_ENGLISH'; $country_name = 'DOMINICA'; break; case 'do': case 'en_do': case 'en-DO': $lang_name = 'SPANISH'; //Santo Domingo $country_name = 'DOMINICAN_REPUBLIC'; break; case 'dj': case 'aa-DJ': case 'aa_dj': $lang_name = 'DJIBOUTI'; //Yibuti, Afar $country_name = 'REPUBLIC_OF_DJIBOUTI'; //République de Djibouti break; case 'dv': $lang_name = 'DIVEHI'; //Maldivian $country_name = 'MALDIVIA'; break; //Berbera Taghelmustă (limba oamenilor albaștri), zisă și Tuaregă, este vorbită în Sahara occidentală. //Berbera Tamazigtă este vorbită în masivul Atlas din Maroc, la sud de orașul Meknes. //Berbera Zenatică zisă și Rifană, este vorbită în masivul Rif din Maroc, în nord-estul țării. //Berbera Șenuană zisă și Telică, este vorbită în masivul Tell din Algeria, în nordul țării. //Berbera Cabilică este vorbită în jurul masivelor Mitigea și Ores din Algeria, în nordul țării. //Berbera Șauiană este vorbită în jurul orașului Batna din Algeria. //Berbera Tahelhită, zisă și Șlănuană (în limba franceză Chleuh) este vorbită în jurul masivului Tubkal din Maroc, în sud-vestul țării. //Berbera Tamașekă, zisă și Sahariană, este vorbită în Sahara de nord, în Algeria, Libia și Egipt. //Berber: Tacawit (@ city Batna from Chaoui, Algery), Shawiya (Shauian) case 'shy': $lang_name = 'SHAWIYA_BERBER'; $country_name = 'ALGERIA'; break; case 'dz': $lang_name = 'DZONGKHA'; $country_name = 'ALGERIA'; //http://www.el-mouradia.dz/ break; case 'ec': $country_name = 'ECUADOR'; $lang_name = 'ECUADOR'; break; case 'eg': $country_name = 'EGYPT'; $lang_name = 'EGYPT'; break; case 'eh': $lang_name = 'WESTERN_SAHARA'; $country_name = 'WESTERN_SAHARA'; break; case 'ee': //Kɔsiɖagbe (Sunday) //Dzoɖagbe (Monday) //Braɖagbe, Blaɖagbe (Tuesday) //Kuɖagbe (Wednesday) //Yawoɖagbe (Thursday) //Fiɖagbe (Friday) //Memliɖagbe (Saturday) $lang_name = 'EWE'; //Èʋegbe Native to Ghana, Togo $country_name = 'ESTONIA'; break; //Greek Language: //ell – Modern Greek //grc – Ancient Greek //cpg – Cappadocian Greek //gmy – Mycenaean Greek //pnt – Pontic //tsd – Tsakonian //yej – Yevanic case 'el': $lang_name = 'GREEK'; $country_name = 'GREECE'; break; case 'cpg': $lang_name = 'CAPPADOCIAN_GREEK'; $country_name = 'GREECE'; break; case 'gmy': $lang_name = 'MYCENAEAN_GREEK'; $country_name = 'GREECE'; break; case 'pnt': $lang_name = 'PONTIC'; $country_name = 'GREECE'; break; case 'tsd': $lang_name = 'TSAKONIAN'; $country_name = 'GREECE'; break; //Albanian: Janina or Janinë, Aromanian: Ianina, Enina, Turkish: Yanya; case 'yej': $lang_name = 'YEVANIC'; $country_name = 'GREECE'; break; case 'en_uk': case 'en-UK': case 'uk': $lang_name = 'BRITISH_ENGLISH'; //used in United Kingdom $country_name = 'GREAT_BRITAIN'; break; case 'en_fj': case 'en-FJ': $lang_name = 'FIJIAN_ENGLISH'; $country_name = 'FIJI'; break; case 'GibE': case 'en_gb': case 'en-GB': case 'gb': $lang_name = 'GIBRALTARIAN _ENGLISH'; //used in Gibraltar $country_name = 'GIBRALTAR'; break; case 'en_us': case 'en-US': $lang_name = 'AMERICAN_ENGLISH'; $country_name = 'UNITED_STATES_OF_AMERICA'; break; case 'en_ie': case 'en-IE': case 'USEng': $lang_name = 'HIBERNO_ENGLISH'; //Irish English $country_name = 'IRELAND'; break; case 'en_il': case 'en-IL': case 'ILEng': case 'heblish': case 'engbrew': $lang_name = 'ISRAELY_ENGLISH'; $country_name = 'ISRAEL'; break; case 'en_ca': case 'en-CA': case 'CanE': $lang_name = 'CANADIAN_ENGLISH'; $country_name = 'CANADA'; break; case 'en_ck': $lang_name = 'COOK_ISLANDS_ENGLISH'; $country_name = 'COOK_ISLANDS'; //CK Cook Islands break; case 'en_in': case 'en-IN': $lang_name = 'INDIAN_ENGLISH'; $country_name = 'REPUBLIC_OF_INDIA'; break; case 'en_ai': case 'en-AI': $lang_name = 'ANGUILLAN_ENGLISH'; $country_name = 'ANGUILLA'; break; case 'en_au': case 'en-AU': case 'AuE': $lang_name = 'AUSTRALIAN_ENGLISH'; $country_name = 'AUSTRALIA'; break; case 'en_nz': case 'en-NZ': case 'NZE': $lang_name = 'NEW_ZEALAND_ENGLISH'; $country_name = 'NEW_ZEALAND'; break; //New England English case 'en_ne': $lang_name = 'NEW_ENGLAND_ENGLISH'; $country_name = 'NEW_ENGLAND'; break; // case 'en_bm': $lang_name = 'BERMUDIAN ENGLISH.'; $country_name = 'BERMUDA'; break; case 'en_nu': $lang_name = 'NIUEAN_ENGLISH'; //Niuean (official) 46% (a Polynesian language closely related to Tongan and Samoan) $country_name = 'NIUE'; // Niuean: Niuē break; case 'en_ms': $lang_name = 'MONTSERRAT_ENGLISH'; $country_name = 'MONTSERRAT'; break; case 'en_pn': $lang_name = 'PITCAIRN_ISLAND_ENGLISH'; $country_name = 'PITCAIRN_ISLAND'; break; case 'en_sh': $lang_name = 'ST_HELENA_ENGLISH'; $country_name = 'ST_HELENA'; break; case 'en_tc': $lang_name = 'TURKS_&_CAICOS_IS_ENGLISH'; $country_name = 'TURKS_&_CAICOS_IS'; break; case 'en_vg': $lang_name = 'VIRGIN_ISLANDS_ENGLISH'; $country_name = 'VIRGIN_ISLANDS_(BRIT)'; break; case 'eo': $lang_name = 'ESPERANTO'; //created in the late 19th century by L. L. Zamenhof, a Polish-Jewish ophthalmologist. In 1887 $country_name = 'EUROPE'; break; case 'er': $lang_name = 'ERITREA'; $country_name = 'ERITREA'; break; //See: // http://www.webapps-online.com/online-tools/languages-and-locales // https://www.ibm.com/support/knowledgecenter/ko/SSS28S_3.0.0/com.ibm.help.forms.doc/locale_spec/i_xfdl_r_locale_quick_reference.html case 'es': //Spanish Main $lang_name = 'SPANISH'; $country_name = 'SPAIN'; break; case 'es_MX': case 'es_mx': //Spanish (Mexico) (es-MX) $lang_name = 'SPANISH_MEXICO'; $country_name = 'MEXICO'; break; case 'es_US': case 'es_us': $lang_name = 'SPANISH_UNITED_STATES'; $country_name = 'UNITED_STATES'; break; case 'es_419': //Spanish Latin America and the Caribbean $lang_name = 'SPANISH_CARIBBEAN'; $country_name = 'CARIBBE'; break; case 'es_ar': // Spanish Argentina $lang_name = 'SPANISH_ARGENTINIAN'; $country_name = 'ARGENTINA'; break; case 'es_BO': case 'es_bo': $lang_name = 'SPANISH_BOLIVIAN'; $country_name = 'BOLIVIA'; break; case 'es_BR': case 'es_br': $lang_name = 'SPANISH_BRAZILIAN'; $country_name = 'BRAZIL'; break; case 'es_cl': // Spanish Chile $lang_name = 'SPANISH_CHILEAN'; $country_name = 'CHILE'; break; case 'es_CO': case 'es_co': case 'es-419': case 'es_419': // Spanish (Colombia) (es-CO) $lang_name = 'SPANISH_COLOMBIAN'; $country_name = 'COLOMBIA'; break; // Variety of es-419 Spanish Latin America and the Caribbean // Spanish language as spoken in // the Caribbean islands of Cuba, // Puerto Rico, and the Dominican Republic // as well as in Panama, Venezuela, // and the Caribbean coast of Colombia. case 'es-CU': case 'es-cu': case 'es_cu': // Spanish (Cuba) (es-CU) $lang_name = 'CUBAN_SPANISH'; $country_name = 'CUBA'; break; case 'es_CR': case 'es_cr': $lang_name = 'SPANISH_COSTA_RICA'; $country_name = 'COSTA_RICA'; break; case 'es_DO': case 'es_do': //Spanish (Dominican Republic) (es-DO) $lang_name = 'SPANISH_DOMINICAN_REPUBLIC'; $country_name = 'DOMINICAN_REPUBLIC'; break; case 'es_ec': // Spanish (Ecuador) (es-EC) $lang_name = 'SPANISH'; $country_name = 'SPAIN'; break; case 'es_es': case 'es_ES': // Spanish Spain $lang_name = 'SPANISH'; $country_name = 'SPAIN'; break; case 'es_ES_tradnl': case 'es_es_tradnl': $lang_name = 'SPANISH_NL'; $country_name = 'NL'; break; case 'es_EU': case 'es_eu': $lang_name = 'SPANISH_EUROPE'; $country_name = 'EUROPE'; break; case 'es_gt': case 'es_GT': // Spanish (Guatemala) (es-GT) $lang_name = 'SPANISH'; $country_name = 'SPAIN'; break; case 'es_HN': case 'es_hn': //Spanish (Honduras) (es-HN) $lang_name = 'SPANISH'; $country_name = 'SPAIN'; break; case 'es_la': case 'es_LA': // Spanish Lao $lang_name = 'SPANISH'; $country_name = 'SPAIN'; break; case 'es_NI': case 'es_ni': // Spanish (Nicaragua) (es-NI) $lang_name = 'SPANISH_NICARAGUAN'; $country_name = 'NICARAGUA'; break; case 'es_PA': case 'es_pa': //Spanish (Panama) (es-PA) $lang_name = 'SPANISH_PANAMIAN'; $country_name = 'PANAMA'; break; case 'es_pe': case 'es_PE': //Spanish (Peru) (es-PE) $lang_name = 'SPANISH_PERU'; $country_name = 'PERU'; break; case 'es_PR': case 'es_pr': //Spanish (Puerto Rico) (es-PR) $lang_name = 'SPANISH_PUERTO_RICO'; $country_name = 'PUERTO_RICO'; break; case 'es_PY': case 'es_py': //Spanish (Paraguay) (es-PY) $lang_name = 'SPANISH_PARAGUAY'; $country_name = 'PARAGUAY'; break; case 'es_SV': case 'es_sv': //Spanish (El Salvador) (es-SV) $lang_name = 'SPANISH_EL_SALVADOR'; $country_name = 'EL_SALVADOR'; break; case 'es-US': case 'es-us': // Spanish (United States) (es-US) $lang_name = 'SPANISH_UNITED_STATES'; $country_name = 'UNITED_STATES'; break; //This dialect is often spoken with an intonation resembling that of the Neapolitan language of Southern Italy, but there are exceptions. case 'es_AR': case 'es_ar': //Spanish (Argentina) (es-AR) $lang_name = 'RIOPLATENSE_SPANISH_ARGENTINA'; $country_name = 'ARGENTINA'; break; case 'es_UY': case 'es_uy': //Spanish (Uruguay) (es-UY) $lang_name = 'SPANISH_URUGUAY'; $country_name = 'URUGUAY'; break; case 'es_ve': case 'es_VE': // Spanish (Venezuela) (es-VE) $lang_name = 'SPANISH_VENEZUELA'; $country_name = 'BOLIVARIAN_REPUBLIC_OF_VENEZUELA'; break; case 'es_xl': case 'es_XL': // Spanish Latin America $lang_name = 'SPANISH_LATIN_AMERICA'; $country_name = 'LATIN_AMERICA'; break; case 'et': $lang_name = 'ESTONIAN'; $country_name = 'ESTONIA'; break; case 'eu': $lang_name = 'BASQUE'; $country_name = ''; break; case 'fa': $lang_name = 'PERSIAN'; $country_name = ''; break; //for Fulah (also spelled Fula) the ISO 639-1 code is ff. //fub – Adamawa Fulfulde //fui – Bagirmi Fulfulde //fue – Borgu Fulfulde //fuq – Central-Eastern Niger Fulfulde //ffm – Maasina Fulfulde //fuv – Nigerian Fulfulde //fuc – Pulaar //fuf – Pular //fuh – Western Niger Fulfulde case 'fub': $lang_name = 'ADAMAWA_FULFULDE'; $country_name = ''; break; case 'fui': $lang_name = 'BAGIRMI_FULFULDE'; $country_name = ''; break; case 'fue': $lang_name = 'BORGU_FULFULDE'; $country_name = ''; break; case 'fuq': $lang_name = 'CENTRAL-EASTERN_NIGER_FULFULDE'; $country_name = ''; break; case 'ffm': $lang_name = 'MAASINA_FULFULDE'; $country_name = ''; break; case 'fuv': $lang_name = 'NIGERIAN_FULFULDE'; $country_name = ''; break; case 'fuc': $lang_name = 'PULAAR'; $country_name = 'SENEGAMBIA_CONFEDERATION'; //sn //gm break; case 'fuf': $lang_name = 'PULAR'; $country_name = ''; break; case 'fuh': $lang_name = 'WESTERN_NIGER_FULFULDE'; $country_name = ''; break; case 'ff': $lang_name = 'FULAH'; $country_name = ''; break; case 'fi': case 'fin': $lang_name = 'FINNISH'; $country_name = 'FINLAND'; break; case 'fkv': $lang_name = 'KVEN'; $country_name = 'NORWAY'; break; case 'fit': $lang_name = 'KVEN'; $country_name = 'SWEDEN'; break; case 'fj': $lang_name = 'FIJIAN'; $country_name = 'FIJI'; break; case 'fk': $lang_name = 'FALKLANDIAN'; $country_name = 'FALKLAND_ISLANDS'; break; case 'fm': $lang_name = 'MICRONESIA'; $country_name = 'MICRONESIA'; break; case 'fo': $lang_name = 'FAROESE'; $country_name = 'FAROE_ISLANDS'; break; //Metropolitan French (French: France Métropolitaine or la Métropole) case 'fr': case 'fr_me': $lang_name = 'FRENCH'; $country_name = 'FRANCE'; break; //Acadian French case 'fr_ac': $lang_name = 'ACADIAN_FRENCH'; $country_name = 'ACADIA'; break; case 'fr_dm': case 'fr-DM': $lang_name = 'DOMINICA_FRENCH'; $country_name = 'DOMINICA'; break; //al-dîzāyīr case 'fr_dz': $lang_name = 'ALGERIAN_FRENCH'; $country_name = 'ALGERIA'; break; //Aostan French (French: français valdôtain) //Seventy: septante[a] [sɛp.tɑ̃t] //Eighty: huitante[b] [ɥi.tɑ̃t] //Ninety: nonante[c] [nɔ.nɑ̃t] case 'fr_ao': $lang_name = 'AOSTAN_FRENCH'; $country_name = 'ITALY'; break; //Belgian French case 'fr_bl': $lang_name = 'BELGIAN_FRENCH'; $country_name = 'BELGIUM'; break; //Cambodian French - French Indochina case 'fr_cb': $lang_name = 'CAMBODIAN_FRENCH'; $country_name = 'CAMBODIA'; break; //Cajun French - Le Français Cajun - New Orleans case 'fr_cj': $lang_name = 'CAJUN_FRENCH'; $country_name = 'UNITED_STATES'; break; //Canadian French (French: Français Canadien) //Official language in Canada, New Brunswick, Northwest Territories, Nunavut, Quebec, Yukon, //Official language in United States, Maine (de facto), New Hampshire case 'fr_ca': case 'fr-CA': $lang_name = 'CANADIAN_FRENCH'; $country_name = 'CANADA'; break; //Guianese French case 'gcr': case 'fr_gu': $lang_name = 'GUIANESE_FRENCH'; $country_name = 'FRENCH_GUIANA'; break; //Guianese English case 'gyn': case 'en_gy': $lang_name = 'GUYANESE_CREOLE'; $country_name = 'ENGLISH_GUIANA'; break; //Haitian French case 'fr-HT': case 'fr_ht': $lang_name = 'HAITIAN_FRENCH'; $country_name = 'HAITI'; //UNITED_STATES break; //Haitian English case 'en-HT': case 'en_ht': $lang_name = 'HAITIAN_CREOLE'; $country_name = 'HAITI'; //UNITED_STATES break; //Indian French case 'fr_id': $lang_name = 'INDIAN_FRENCH'; $country_name = 'INDIA'; break; case 'en_id': $lang_name = 'INDIAN_ENGLISH'; $country_name = 'INDIA'; break; //Jersey Legal French - Anglo-Norman French case 'xno': case 'fr_je': $lang_name = 'JERSEY_LEGAL_FRENCH'; $country_name = 'UNITED_STATES'; break; case 'fr_kh': $lang_name = 'CAMBODIAN_FRENCH'; $country_name = 'CAMBODIA'; break; //Lao French case 'fr_la': $lang_name = 'LAO_FRENCH'; $country_name = 'LAOS'; break; //Louisiana French (French: Français de la Louisiane, Louisiana Creole: Françé la Lwizyàn) case 'frc': case 'fr_lu': $lang_name = 'LOUISIANIAN_FRENCH'; $country_name = 'LOUISIANA'; break; //Louisiana Creole case 'lou': $lang_name = 'LOUISIANA_CREOLE'; $country_name = 'LOUISIANA'; break; //Meridional French (French: Français Méridional, also referred to as Francitan) case 'fr_mr': $lang_name = 'MERIDIONAL_FRENCH'; $country_name = 'OCCITANIA'; break; //Missouri French case 'fr_mi': $lang_name = 'MISSOURI_FRENCH'; $country_name = 'MISSOURI‎'; break; //New Caledonian French vs New Caledonian Pidgin French case 'fr_nc': $lang_name = 'NEW_CALEDONIAN_FRENCH'; $country_name = 'NEW_CALEDONIA'; break; //Newfoundland French (French: Français Terre-Neuvien), case 'fr_nf': $lang_name = 'NEWFOUNDLAND_FRENCH'; $country_name = 'CANADA'; break; //New England French case 'fr_ne': $lang_name = 'NEW_ENGLAND_FRENCH'; $country_name = 'NEW_ENGLAND'; break; //Quebec French (French: français québécois; also known as Québécois French or simply Québécois) case 'fr_qb': $lang_name = 'QUEBEC_FRENCH'; $country_name = 'CANADA'; break; //Swiss French case 'fr_sw': $lang_name = 'SWISS_FRENCH'; $country_name = 'SWITZERLAND'; break; //French Southern and Antarctic Lands case 'fr_tf': case 'tf': $lang_name = 'FRENCH_SOUTHERN_TERRITORIES'; // $country_name = 'SOUTHERN_TERRITORIES'; //Terres australes françaises break; //Vietnamese French case 'fr_vt': $lang_name = 'VIETNAMESE_FRENCH'; $country_name = 'VIETNAM'; break; //West Indian French case 'fr_if': $lang_name = 'WEST_INDIAN_FRENCH'; $country_name = 'INDIA'; break; case 'fr_wf': $country_name = 'TERRITORY_OF_THE_WALLIS_AND_FUTUNA_ISLANDS'; $lang_name = 'WALLISIAN_FRENCH'; break; case 'fy': $lang_name = 'WESTERN_FRISIAN'; $country_name = 'FRYSK'; break; case 'ga': $lang_name = 'IRISH'; $country_name = 'GABON'; break; case 'GenAm': $lang_name = 'General American'; $country_name = 'UNITED_STATES'; break; //gcf – Guadeloupean Creole case 'gcf': $lang_name = 'GUADELOUPEAN_CREOLE_FRENCH'; $country_name = 'GUADELOUPE'; break; case 'gd': $lang_name = 'SCOTTISH'; $country_name = 'GRENADA'; break; case 'ge': $lang_name = 'GEORGIAN'; $country_name = 'GEORGIA'; break; case 'gi': $lang_name = 'LLANITO'; //Llanito or Yanito $country_name = 'GIBRALTAR'; break; case 'gg': $lang_name = 'GUERNESIAIS'; //English, Guernésiais, Sercquiais, Auregnais $country_name = 'GUERNSEY'; break; case 'gh': $lang_name = 'Ghana'; $country_name = 'GHANA'; break; case 'ell': $lang_name = 'MODERN_GREEK'; $country_name = 'GREECE'; break; case 'gr': case 'el_gr': case 'el-gr': case 'gre': $lang_name = 'MODERN_GREEK'; $country_name = 'GREECE'; break; case 'grc': $lang_name = 'ANCIENT_GREEK'; $country_name = 'GREECE'; break; //Galician is spoken by some 2.4 million people, mainly in Galicia, //an autonomous community located in northwestern Spain. case 'gl': $lang_name = 'GALICIAN'; //Galicia $country_name = 'GREENLAND'; break; case 'gm': $lang_name = 'Gambia'; $country_name = 'GAMBIA'; break; //grn is the ISO 639-3 language code for Guarani. Its ISO 639-1 code is gn. // nhd – Chiripá // gui – Eastern Bolivian Guaraní // gun – Mbyá Guaraní // gug – Paraguayan Guaraní // gnw – Western Bolivian Guaraní case 'gn': $lang_name = 'GUARANI'; $country_name = 'GUINEA'; break; //Nhandéva is also known as Chiripá. //The Spanish spelling, Ñandeva, is used in the Paraguayan Chaco // to refer to the local variety of Eastern Bolivian, a subdialect of Avá. case 'nhd': $lang_name = 'Chiripa'; $country_name = 'PARAGUAY'; break; case 'gui': $lang_name = 'EASTERN_BOLIVIAN_GUARANI'; $country_name = 'BOLIVIA'; break; case 'gun': $lang_name = 'MBYA_GUARANI'; $country_name = 'PARAGUAY'; break; case 'gug': $lang_name = 'PARAGUAYAN_GUARANI'; $country_name = 'PARAGUAY'; break; case 'gnw': $lang_name = 'WESTERN_BOLIVIAN_GUARANI'; $country_name = 'BOLIVIA'; break; case 'gs': $lang_name = 'ENGLISH'; $country_name = 'SOUTH_GEORGIA_AND_THE_SOUTH_SANDWICH_ISLANDS'; break; case 'gt': $lang_name = 'Guatemala'; $country_name = 'GUATEMALA'; break; case 'gq': $lang_name = 'Equatorial Guinea'; $country_name = 'EQUATORIAL_GUINEA'; break; case 'gu': $lang_name = 'GUJARATI'; $country_name = 'GUAM'; break; case 'gv': $lang_name = 'manx'; $country_name = ''; break; case 'gw': $lang_name = 'Guinea Bissau'; $country_name = 'GUINEA_BISSAU'; break; case 'gy': $lang_name = 'Guyana'; $country_name = 'GUYANA'; break; case 'ha': $country_name = ''; $lang_name = 'HAUSA'; break; //heb – Modern Hebrew //hbo – Classical Hebrew (liturgical) //smp – Samaritan Hebrew (liturgical) //obm – Moabite (extinct) //xdm – Edomite (extinct) case 'he': case 'heb': $country_name = 'ISRAEL'; $lang_name = 'HEBREW'; break; case 'hbo': $country_name = 'ISRAEL'; $lang_name = 'CLASSICAL_HEBREW'; break; case 'sam': $country_name = 'SAMARIA'; $lang_name = 'SAMARITAN_ARAMEIC'; break; case 'smp': $country_name = 'SAMARIA'; $lang_name = 'SAMARITAN_HEBREW'; break; case 'obm': $country_name = 'MOAB'; $lang_name = 'MOABITE'; break; case 'xdm': $country_name = 'EDOMITE'; $lang_name = 'EDOM'; break; case 'hi': $lang_name = 'hindi'; $country_name = ''; break; case 'ho': $lang_name = 'hiri_motu'; $country_name = ''; break; case 'hk': $lang_name = 'Hong Kong'; $country_name = 'HONG_KONG'; break; case 'hn': $country_name = 'Honduras'; $lang_name = 'HONDURAS'; break; case 'hr': $lang_name = 'croatian'; $country_name = 'CROATIA'; break; case 'ht': $lang_name = 'haitian'; $country_name = 'HAITI'; break; case 'ho': $lang_name = 'hiri_motu'; $country_name = ''; break; case 'hu': $lang_name = 'hungarian'; $country_name = 'HUNGARY'; break; case 'hy': case 'hy-am': $lang_name = 'ARMENIAN'; $country_name = ''; break; case 'hy-AT': case 'hy_at': $lang_name = 'ARMENIAN-ARTSAKH'; $country_name = 'REPUBLIC_OF_ARTSAKH'; break; case 'hz': $lang_name = 'HERERO'; $country_name = ''; break; case 'ia': $lang_name = 'INTERLINGUA'; $country_name = ''; break; case 'ic': $lang_name = ''; $country_name = 'CANARY_ISLANDS'; break; case 'id': $lang_name = 'INDONESIAN'; $country_name = 'INDONESIA'; break; case 'ie': $lang_name = 'interlingue'; $country_name = 'IRELAND'; break; case 'ig': $lang_name = 'igbo'; $country_name = ''; break; case 'ii': $lang_name = 'sichuan_yi'; $country_name = ''; break; case 'ik': $lang_name = 'inupiaq'; $country_name = ''; break; //Mostly spoken on Ouvéa Island or Uvea Island of the Loyalty Islands, New Caledonia. case 'iai': $lang_name = 'IAAI'; $country_name = 'NEW_CALEDONIA'; break; case 'il': $lang_name = 'ibrit'; $country_name = 'ISRAEL'; break; case 'im': $lang_name = 'Isle of Man'; $country_name = 'ISLE_OF_MAN'; break; case 'in': $lang_name = 'India'; $country_name = 'INDIA'; break; case 'ir': $lang_name = 'Iran'; $country_name = 'IRAN'; break; case 'is': $lang_name = 'Iceland'; $country_name = 'ICELAND'; break; case 'it': $lang_name = 'ITALIAN'; $country_name = 'ITALY'; break; case 'iq': $lang_name = 'Iraq'; $country_name = 'IRAQ'; break; case 'je': $lang_name = 'jerriais'; //Jèrriais $country_name = 'JERSEY'; //Bailiwick of Jersey break; case 'jm': $lang_name = 'Jamaica'; $country_name = 'JAMAICA'; break; case 'jo': $lang_name = 'Jordan'; $country_name = 'JORDAN'; break; case 'jp': $lang_name = 'japanese'; $country_name = 'JAPAN'; break; case 'jv': $lang_name = 'javanese'; $country_name = ''; break; case 'kh': $lang_name = 'KH'; $country_name = 'CAMBODIA'; break; case 'ke': $lang_name = 'SWAHILI'; $country_name = 'KENYA'; break; case 'ki': $lang_name = 'Kiribati'; $country_name = 'KIRIBATI'; break; //Bantu languages //zdj – Ngazidja Comorian case 'zdj': $lang_name = 'Ngazidja Comorian'; $country_name = 'COMOROS'; break; //wni – Ndzwani Comorian (Anjouani) dialect case 'wni': $lang_name = 'Ndzwani Comorian'; $country_name = 'COMOROS'; break; //swb – Maore Comorian dialect case 'swb': $lang_name = 'Maore Comorian'; $country_name = 'COMOROS'; break; //wlc – Mwali Comorian dialect case 'wlc': $lang_name = 'Mwali Comorian'; $country_name = 'COMOROS'; break; case 'km': $lang_name = 'KHMER'; $country_name = 'COMOROS'; break; case 'kn': $lang_name = 'kannada'; $country_name = 'ST_KITTS-NEVIS'; break; case 'ko': case 'kp': $lang_name = 'korean'; // kor – Modern Korean // jje – Jeju // okm – Middle Korean // oko – Old Korean // oko – Proto Korean // okm Middle Korean // oko Old Korean $country_name = 'Korea North'; break; case 'kr': $lang_name = 'korean'; $country_name = 'KOREA_SOUTH'; break; case 'kn': $lang_name = 'St Kitts-Nevis'; $country_name = 'ST_KITTS-NEVIS'; break; case 'ks': $lang_name = 'kashmiri'; //Kashmir $country_name = 'KOREA_SOUTH'; break; case 'ky': $lang_name = 'Cayman Islands'; $country_name = 'CAYMAN_ISLANDS'; break; case 'kz': $lang_name = 'Kazakhstan'; $country_name = 'KAZAKHSTAN'; break; case 'kw': //endonim: Kernewek $lang_name = 'Cornish'; $country_name = 'KUWAIT'; break; case 'kg': $lang_name = 'Kyrgyzstan'; $country_name = 'KYRGYZSTAN'; break; case 'la': $lang_name = 'Laos'; $country_name = 'LAOS'; break; case 'lk': $lang_name = 'Sri Lanka'; $country_name = 'SRI_LANKA'; break; case 'lv': $lang_name = 'Latvia'; $country_name = 'LATVIA'; break; case 'lb': $lang_name = 'LUXEMBOURGISH'; $country_name = 'LEBANON'; break; case 'lc': $lang_name = 'St Lucia'; $country_name = 'ST_LUCIA'; break; case 'ls': $lang_name = 'Lesotho'; $country_name = 'LESOTHO'; break; case 'lo': $lang_name = 'LAO'; $country_name = 'LAOS'; break; case 'lr': $lang_name = 'Liberia'; $country_name = 'LIBERIA'; break; case 'ly': $lang_name = 'Libya'; $country_name = 'Libya'; break; case 'li': $lang_name = 'LIMBURGISH'; $country_name = 'LIECHTENSTEIN'; break; case 'lt': $country_name = 'Lithuania'; $lang_name = 'LITHUANIA'; break; case 'lu': $lang_name = 'LUXEMBOURGISH'; $country_name = 'LUXEMBOURG'; break; case 'ma': $lang_name = 'Morocco'; $country_name = 'MOROCCO'; break; case 'mc': $country_name = 'MONACO'; $lang_name = 'Monaco'; break; case 'md': $country_name = 'MOLDOVA'; $lang_name = 'romanian'; break; case 'me': $lang_name = 'MONTENEGRIN'; //Serbo-Croatian, Cyrillic, Latin $country_name = 'MONTENEGRO'; //Црна Гора break; case 'mf': $lang_name = 'FRENCH'; // $country_name = 'SAINT_MARTIN_(FRENCH_PART)'; break; case 'mg': $lang_name = 'Madagascar'; $country_name = 'MADAGASCAR'; break; case 'mh': $lang_name = 'Marshall Islands'; $country_name = 'MARSHALL_ISLANDS'; break; case 'mi': $lang_name = 'MAORI'; $country_name = 'Maori'; break; //Mi'kmaq hieroglyphic writing was a writing system and memory aid used by the Mi'kmaq, //a First Nations people of the east coast of Canada, Mostly spoken in Nova Scotia and Newfoundland. case 'mic': $lang_name = 'MIKMAQ'; $country_name = 'CANADA'; break; case 'mk': $lang_name = 'Macedonia'; $country_name = 'MACEDONIA'; break; case 'mr': $lang_name = 'Mauritania'; $country_name = 'Mauritania'; break; case 'mu': $lang_name = 'Mauritius'; $country_name = 'MAURITIUS'; break; case 'mo': $lang_name = 'Macau'; $country_name = 'MACAU'; break; case 'mn': $lang_name = 'Mongolia'; $country_name = 'MONGOLIA'; break; case 'ms': $lang_name = 'Montserrat'; $country_name = 'MONTSERRAT'; break; case 'mz': $lang_name = 'Mozambique'; $country_name = 'MOZAMBIQUE'; break; case 'mm': $lang_name = 'Myanmar'; $country_name = 'MYANMAR'; break; case 'mp': $lang_name = 'chamorro'; //Carolinian $country_name = 'NORTHERN_MARIANA_ISLANDS'; break; case 'mw': $country_name = 'Malawi'; $lang_name = 'MALAWI'; break; case 'my': $lang_name = 'Myanmar'; $country_name = 'MALAYSIA'; break; case 'mv': $lang_name = 'Maldives'; $country_name = 'MALDIVES'; break; case 'ml': $lang_name = 'Mali'; $country_name = 'MALI'; break; case 'mt': $lang_name = 'Malta'; $country_name = 'MALTA'; break; case 'mx': $lang_name = 'Mexico'; $country_name = 'MEXICO'; break; case 'mq': $lang_name = 'antillean-creole'; // Antillean Creole (Créole Martiniquais) $country_name = 'MARTINIQUE'; break; case 'na': $lang_name = 'Nambia'; $country_name = 'NAMBIA'; break; case 'ni': $lang_name = 'Nicaragua'; $country_name = 'NICARAGUA'; break; //Barber: Targuí, tuareg case 'ne': $lang_name = 'Niger'; $country_name = 'NIGER'; break; //Mostly spoken on Maré Island of the Loyalty Islands, New Caledonia. case 'nen': $lang_name = 'NENGONE'; $country_name = 'NEW_CALEDONIA'; break; case 'new': $lang_name = 'NEW_LANGUAGE'; $country_name = 'NEW_COUNTRY'; break; case 'nc': $lang_name = 'paicî'; //French, Nengone, Paicî, Ajië, Drehu $country_name = 'NEW_CALEDONIA'; break; case 'nk': $lang_name = 'Korea North'; $country_name = 'KOREA_NORTH'; break; case 'ng': $lang_name = 'Nigeria'; $country_name = 'NIGERIA'; break; case 'nf': $lang_name = 'Norfolk Island'; $country_name = 'NORFOLK_ISLAND'; break; case 'nl': $lang_name = 'DUTCH'; //Netherlands, Flemish. $country_name = 'NETHERLANDS'; break; case 'no': $lang_name = 'Norway'; $country_name = 'NORWAY'; break; case 'np': $lang_name = 'Nepal'; $country_name = 'NEPAL'; break; case 'nr': $lang_name = 'Nauru'; $country_name = 'NAURU'; break; case 'niu': $lang_name = 'NIUEAN'; //Niuean (official) 46% (a Polynesian language closely related to Tongan and Samoan) $country_name = 'NIUE'; // Niuean: Niuē break; case 'nu': $lang_name = 'NU'; //Niuean (official) 46% (a Polynesian language closely related to Tongan and Samoan) $country_name = 'NIUE'; // Niuean: Niuē break; case 'nz': $lang_name = 'New Zealand'; $country_name = 'NEW_ZEALAND'; break; case 'ny': $lang_name = 'Chewa'; $country_name = 'Nyanja'; break; //langue d'oc case 'oc': $lang_name = 'OCCITAN'; $country_name = 'OCCITANIA'; break; case 'oj': $lang_name = 'ojibwa'; $country_name = ''; break; case 'om': $lang_name = 'Oman'; $country_name = 'OMAN'; break; case 'or': $lang_name = 'oriya'; $country_name = ''; break; case 'os': $lang_name = 'ossetian'; $country_name = ''; break; case 'pa': $country_name = 'Panama'; $lang_name = 'PANAMA'; break; case 'pe': $country_name = 'Peru'; $lang_name = 'PERU'; break; case 'ph': $lang_name = 'Philippines'; $country_name = 'PHILIPPINES'; break; case 'pf': $country_name = 'French Polynesia'; $lang_name = 'tahitian'; //Polynésie française break; case 'pg': $country_name = 'PAPUA_NEW_GUINEA'; $lang_name = 'Papua New Guinea'; break; case 'pi': $lang_name = 'pali'; $country_name = ''; break; case 'pl': $lang_name = 'Poland'; $country_name = 'POLAND'; break; case 'pn': $lang_name = 'Pitcairn Island'; $country_name = 'PITCAIRN_ISLAND'; break; case 'pr': $lang_name = 'Puerto Rico'; $country_name = 'PUERTO_RICO'; break; case 'pt': case 'pt_pt': $lang_name = 'PORTUGUESE'; $country_name = 'PORTUGAL'; break; case 'pt_br': $lang_name = 'PORTUGUESE_BRASIL'; $country_name = 'BRAZIL'; //pt break; case 'pk': $lang_name = 'Pakistan'; $country_name = 'PAKISTAN'; break; case 'pw': $country_name = 'Palau Island'; $lang_name = 'PALAU_ISLAND'; break; case 'ps': $country_name = 'Palestine'; $lang_name = 'PALESTINE'; break; case 'py': $country_name = 'PARAGUAY'; $lang_name = 'PARAGUAY'; break; case 'qa': $lang_name = 'Qatar'; $country_name = 'QATAR'; break; // rmn – Balkan Romani // rml – Baltic Romani // rmc – Carpathian Romani // rmf – Kalo Finnish Romani // rmo – Sinte Romani // rmy – Vlax Romani // rmw – Welsh Romani case 'ri': case 'rom': $country_name = 'EASTEN_EUROPE'; $lang_name = 'ROMANI'; break; case 'ro': $country_name = 'ROMANIA'; $lang_name = 'ROMANIAN'; break; case 'ro_md': case 'ro_MD': $country_name = 'ROMANIA'; $lang_name = 'ROMANIAN_MOLDAVIA'; break; case 'ro_ro': case 'ro_RO': $country_name = 'ROMANIA'; $lang_name = 'ROMANIAN_ROMANIA'; break; case 'rn': $lang_name = 'kirundi'; $country_name = ''; break; case 'rm': $country_name = ''; $lang_name = 'romansh'; //Switzerland break; case 'rs': $country_name = 'REPUBLIC_OF_SERBIA'; //Република Србија //Republika Srbija $lang_name = 'serbian'; //Serbia, Србија / Srbija break; case 'ru': case 'ru_ru': case 'ru_RU': $country_name = 'RUSSIA'; $lang_name = 'RUSSIAN'; break; case 'rw': $country_name = 'RWANDA'; $lang_name = 'Rwanda'; break; case 'sa': $lang_name = 'arabic'; $country_name = 'SAUDI_ARABIA'; break; case 'sb': $lang_name = 'Solomon Islands'; $country_name = 'SOLOMON_ISLANDS'; break; case 'sc': $lang_name = 'seychellois-creole'; $country_name = 'SEYCHELLES'; break; case 'sco': $lang_name = 'SCOTISH'; $country_name = 'Scotland'; break; //scf – San Miguel Creole French (Panama) case 'scf': $lang_name = 'SAN_MIGUEL_CREOLE_FRENCH'; $country_name = 'SAN_MIGUEL'; break; case 'sd': $lang_name = 'Sudan'; $country_name = 'SUDAN'; break; case 'si': $lang_name = 'SLOVENIAN'; $country_name = 'SLOVENIA'; break; case 'sh': $lang_name = 'SH'; $country_name = 'ST_HELENA'; break; case 'sk': $country_name = 'SLOVAKIA'; $lang_name = 'Slovakia'; break; case 'sg': $country_name = 'SINGAPORE'; $lang_name = 'Singapore'; break; case 'sl': $country_name = 'SIERRA_LEONE'; $lang_name = 'Sierra Leone'; break; case 'sm': $lang_name = 'San Marino'; $country_name = 'SAN_MARINO'; break; case 'smi': $lang_name = 'Sami'; $country_name = 'Norway'; //Native to Finland, Norway, Russia, and Sweden break; case 'sn': $lang_name = 'Senegal'; $country_name = 'SENEGAL'; break; case 'so': $lang_name = 'Somalia'; $country_name = 'SOMALIA'; break; case 'sq': $lang_name = 'ALBANIAN'; $country_name = 'Albania'; break; case 'sr': $lang_name = 'Suriname'; $country_name = 'SURINAME'; break; case 'ss': $lang_name = ''; //Bari [Karo or Kutuk ('mother tongue', Beri)], Dinka, Luo, Murle, Nuer, Zande $country_name = 'REPUBLIC_OF_SOUTH_SUDAN'; break; case 'sse': $lang_name = 'STANDARD_SCOTTISH_ENGLISH'; $country_name = 'Scotland'; break; case 'st': $lang_name = 'Sao Tome & Principe'; $country_name = 'SAO_TOME_&_PRINCIPE'; break; case 'sv': $lang_name = 'El Salvador'; $country_name = 'EL_SALVADOR'; break; case 'sx': $lang_name = 'dutch'; $country_name = 'SINT_MAARTEN_(DUTCH_PART)'; break; case 'sz': $lang_name = 'Swaziland'; $country_name = 'SWAZILAND'; break; case 'se': case 'sv-SE': case 'sv-se': //Swedish (Sweden) (sv-SE) $lang_name = 'Sweden'; $country_name = 'SWEDEN'; break; case 'sy': $lang_name = 'SYRIAC'; //arabic syrian $country_name = 'SYRIA'; break; //ISO 639-2 swa //ISO 639-3 swa – inclusive code //Individual codes: //swc – Congo Swahili //swh – Coastal Swahili //ymk – Makwe //wmw – Mwani //Person Mswahili //People Waswahili //Language Kiswahili case 'sw': $lang_name = 'SWAHILI'; $country_name = 'KENYA'; break; case 'swa': $lang_name = 'SWAHILI'; $country_name = 'AFRICAN_GREAT_LAKES'; break; //swa – inclusive code // //Individual codes: //swc – Congo Swahili case 'swc': $lang_name = 'CONGO_SWAHILI'; $country_name = 'CONGO'; break; //swh – Coastal Swahili case 'swh': $lang_name = 'COASTAL_SWAHILI'; $country_name = 'AFRIKA_EAST_COAST'; break; //ymk – Makwe case 'ymk': $lang_name = 'MAKWE'; $country_name = 'CABO_DELGADO_PROVINCE_OF_MOZAMBIQUE'; break; //wmw – Mwani case 'wmw': $lang_name = 'MWANI'; $country_name = 'COAST_OF_CABO_DELGADO_PROVINCE_OF_MOZAMBIQUE'; break; case 'tc': $lang_name = 'Turks & Caicos Is'; $country_name = 'TURKS_&_CAICOS_IS'; break; case 'td': $lang_name = 'Chad'; $country_name = 'CHAD'; break; case 'tf': $lang_name = 'french '; // $country_name = 'FRENCH_SOUTHERN_TERRITORIES'; //Terres australes françaises break; case 'tj': $lang_name = 'Tajikistan'; $country_name = 'TAJIKISTAN'; break; case 'tg': $lang_name = 'Togo'; $country_name = 'TOGO'; break; case 'th': $country_name = 'Thailand'; $lang_name = 'THAILAND'; break; case 'tk': //260 speakers of Tokelauan, of whom 2,100 live in New Zealand, //1,400 in Tokelau, //and 17 in Swains Island $lang_name = 'Tokelauan'; // /toʊkəˈlaʊən/ Tokelauans or Polynesians $country_name = 'TOKELAUAU'; //Dependent territory of New Zealand break; case 'tl': $country_name = 'East Timor'; $lang_name = 'East Timor'; break; case 'to': $country_name = 'Tonga'; $lang_name = 'TONGA'; break; case 'tt': $country_name = 'Trinidad & Tobago'; $lang_name = 'TRINIDAD_&_TOBAGO'; break; case 'tn': $lang_name = 'Tunisia'; $country_name = 'TUNISIA'; break; case 'tm': $lang_name = 'Turkmenistan'; $country_name = 'TURKMENISTAN'; break; case 'tr': $lang_name = 'Turkey'; $country_name = 'TURKEY'; break; case 'tv': $lang_name = 'Tuvalu'; $country_name = 'TUVALU'; break; case 'tw': $lang_name = 'TAIWANESE_HOKKIEN'; //Taibei Hokkien $country_name = 'TAIWAN'; break; case 'tz': $country_name = 'TANZANIA'; $lang_name = 'Tanzania'; break; case 'ug': $lang_name = 'Uganda'; $country_name = 'UGANDA'; break; case 'ua': $lang_name = 'Ukraine'; $country_name = 'UKRAINE'; break; case 'us': $lang_name = 'en-us'; $country_name = 'UNITED_STATES_OF_AMERICA'; break; case 'uz': $lang_name = 'uzbek'; //Uyghur Perso-Arabic alphabet $country_name = 'UZBEKISTAN'; break; case 'uy': $lang_name = 'Uruguay'; $country_name = 'URUGUAY'; break; case 'va': case 'lat': $country_name = 'VATICAN_CITY'; //Holy See $lang_name = 'LATIN'; break; case 'vc': $country_name = 'ST_VINCENT_&_GRENADINES'; // $lang_name = 'vincentian-creole'; break; case 've': $lang_name = 'Venezuela'; $country_name = 'VENEZUELA'; break; case 'vi': $lang_name = 'Virgin Islands (USA)'; $country_name = 'VIRGIN_ISLANDS_(USA)'; break; case 'fr_vn': $lang_name = 'FRENCH_VIETNAM'; $country_name = 'VIETNAM'; break; case 'vn': $lang_name = 'Vietnam'; $country_name = 'VIETNAM'; break; case 'vg': $lang_name = 'Virgin Islands (Brit)'; $country_name = 'VIRGIN_ISLANDS_(BRIT)'; break; case 'vu': $lang_name = 'Vanuatu'; $country_name = 'VANUATU'; break; case 'wls': $lang_name = 'WALLISIAN'; $country_name = 'WALES'; break; case 'wf': $country_name = 'TERRITORY_OF_THE_WALLIS_AND_FUTUNA_ISLANDS'; $lang_name = 'WF'; //Wallisian, or ʻUvean //Futunan - Austronesian, Malayo-Polynesian break; case 'ws': $country_name = 'SAMOA'; $lang_name = 'Samoa'; break; case 'ye': $lang_name = 'Yemen'; $country_name = 'YEMEN'; break; case 'yt': $lang_name = 'Mayotte'; //Shimaore: $country_name = 'DEPARTMENT_OF_MAYOTTE'; //Département de Mayotte break; case 'za': $lang_name = 'zhuang'; $country_name = 'SOUTH_AFRICA'; break; case 'zm': $lang_name = 'zambian'; $country_name = 'ZAMBIA'; break; case 'zw': $lang_name = 'Zimbabwe'; $country_name = 'ZIMBABWE'; break; case 'zu': $lang_name = 'zulu'; $country_name = 'ZULU'; break; default: $lang_name = $file_dir; $country_name = $file_dir; break; } $return = ($lang_country == 'country') ? $country_name : $lang_name; $return = ($langs_countries == true) ? $lang_name[$country_name] : $return; return $return ; } /** * @param string $var The key to look for * @return mixed The data stored at the key */ public function __get($var) { if (isset($this->$var)) { return $this->$var; } if ($var == 'size') { $this->size = new Size(SHOW_DIR_SIZE ? $this->dir_size() : false); return $this->size; } throw new ExceptionDisplay('Variable ' . Url::html_output($var) . ' not set in DirItem class.'); } } ?> classes/DirectoryList.php0000755000000000000000000001351614576073143012735 0ustar * @version 1.0.1 (June 30, 2004) * @package AutoIndex */ class DirectoryList implements Iterator { /** * @var string The directory this object represents */ protected $dir_name; /** * @var array The list of filesname in this directory (strings) */ protected $contents; /** * @var int The size of the $contents array */ private $list_count; //begin implementation of Iterator /** * @var int $i is used to keep track of the current pointer inside the array when implementing Iterator */ private $i; /** * @return string The element $i currently points to in the array */ #[\ReturnTypeWillChange] public function current() { if ($this -> i < count($this -> contents)) { return $this -> contents[$this -> i]; } return false; } /** * Increments the internal array pointer, then returns the value * at that new position. * * @return string The current position of the pointer in the array */ #[\ReturnTypeWillChange] public function next() { $this -> i++; return $this -> current(); } /** * Sets the internal array pointer to 0 */ #[\ReturnTypeWillChange] public function rewind() { $this -> i = 0; } /** * @return bool True if $i is a valid array index */ #[\ReturnTypeWillChange] public function valid() { return ($this -> i < count($this -> contents)); } /** * @return int Returns $i, the key of the array */ #[\ReturnTypeWillChange] public function key() { return $this -> i; } //end implementation of Iterator /** * @return int The total size in bytes of the folder (recursive) */ public function size_recursive() { $total_size = 0; foreach ($this as $current) { $t = $this -> dir_name . $current; if (@is_dir($t)) { if ($current != '..') { $temp = new DirectoryList($t); $total_size += $temp -> size_recursive(); } } else { $total_size += @filesize($t); } } return $total_size; } /** * @return int The total number of files in this directory (recursive) */ public function num_files() { $count = 0; foreach ($this as $current) { $t = $this -> dir_name . $current; if (@is_dir($t)) { if ($current != '..') { $temp = new DirectoryList($t); $count += $temp -> num_files(); } } else { $count++; } } return $count; } /** * @param string $string The string to search for * @param array $array The array to search * @return bool True if $string matches any elements in $array */ public static function match_in_array($string, &$array) { $string = Item::get_basename($string); static $replace = array( '\*' => '[^\/]*', '\+' => '[^\/]+', '\?' => '[^\/]?'); foreach ($array as $m) { if (preg_match('/^' . strtr(preg_quote(Item::get_basename($m), '/'), $replace) . '$/i', $string)) { return true; } } return false; } /** * @param string $t The file or folder name * @param bool $is_file * @return bool True if $t is listed as a hidden file */ public static function is_hidden($t, $is_file = true) { $t = Item::get_basename($t); if ($t == '.' || $t == '') { return true; } global $you; if ($you -> level >= ADMIN) //allow admins to view hidden files { return false; } global $hidden_files, $show_only_these_files; if ($is_file && count($show_only_these_files)) { return (!self::match_in_array($t, $show_only_these_files)); } return self::match_in_array($t, $hidden_files); } /** * @param string $var The key to look for * @return mixed The data stored at the key */ public function __get($var) { if (isset($this -> $var)) { return $this -> $var; } throw new ExceptionDisplay('Variable ' . Url::html_output($var) . ' not set in DirectoryList class.'); } /** * @param string $path */ public function __construct($path) { $path = Item::make_sure_slash($path); if (!@is_dir($path)) { throw new ExceptionDisplay('Directory ' . Url::html_output($path) . ' does not exist.'); } $temp_list = @scandir($path); if ($temp_list === false) { throw new ExceptionDisplay('Error reading from directory ' . Url::html_output($path) . '.'); } $this -> dir_name = $path; $this -> contents = array(); foreach ($temp_list as $t) { if (!self::is_hidden($t, !@is_dir($path . $t))) { $this -> contents[] = $t; } } $this -> list_count = count($this -> contents); $this -> i = 0; } } ?>classes/DirectoryList.php30000755000000000000000000001330711500513450012776 0ustar * @version 1.0.1 (June 30, 2004) * @package AutoIndex */ class DirectoryList implements Iterator { /** * @var string The directory this object represents */ protected $dir_name; /** * @var array The list of filesname in this directory (strings) */ protected $contents; /** * @var int The size of the $contents array */ private $list_count; //begin implementation of Iterator /** * @var int $i is used to keep track of the current pointer inside the array when implementing Iterator */ private $i; /** * @return string The element $i currently points to in the array */ public function current() { if ($this -> i < count($this -> contents)) { return $this -> contents[$this -> i]; } return false; } /** * Increments the internal array pointer, then returns the value * at that new position. * * @return string The current position of the pointer in the array */ public function next() { $this -> i++; return $this -> current(); } /** * Sets the internal array pointer to 0 */ public function rewind() { $this -> i = 0; } /** * @return bool True if $i is a valid array index */ public function valid() { return ($this -> i < count($this -> contents)); } /** * @return int Returns $i, the key of the array */ public function key() { return $this -> i; } //end implementation of Iterator /** * @return int The total size in bytes of the folder (recursive) */ public function size_recursive() { $total_size = 0; foreach ($this as $current) { $t = $this -> dir_name . $current; if (@is_dir($t)) { if ($current != '..') { $temp = new DirectoryList($t); $total_size += $temp -> size_recursive(); } } else { $total_size += @filesize($t); } } return $total_size; } /** * @return int The total number of files in this directory (recursive) */ public function num_files() { $count = 0; foreach ($this as $current) { $t = $this -> dir_name . $current; if (@is_dir($t)) { if ($current != '..') { $temp = new DirectoryList($t); $count += $temp -> num_files(); } } else { $count++; } } return $count; } /** * @param string $string The string to search for * @param array $array The array to search * @return bool True if $string matches any elements in $array */ public static function match_in_array($string, &$array) { $string = Item::get_basename($string); static $replace = array( '\*' => '[^\/]*', '\+' => '[^\/]+', '\?' => '[^\/]?'); foreach ($array as $m) { if (preg_match('/^' . strtr(preg_quote(Item::get_basename($m), '/'), $replace) . '$/i', $string)) { return true; } } return false; } /** * @param string $t The file or folder name * @param bool $is_file * @return bool True if $t is listed as a hidden file */ public static function is_hidden($t, $is_file = true) { $t = Item::get_basename($t); if ($t == '.' || $t == '') { return true; } global $you; if ($you -> level >= ADMIN) //allow admins to view hidden files { return false; } global $hidden_files, $show_only_these_files; if ($is_file && count($show_only_these_files)) { return (!self::match_in_array($t, $show_only_these_files)); } return self::match_in_array($t, $hidden_files); } /** * @param string $var The key to look for * @return mixed The data stored at the key */ public function __get($var) { if (isset($this -> $var)) { return $this -> $var; } throw new ExceptionDisplay('Variable ' . Url::html_output($var) . ' not set in DirectoryList class.'); } /** * @param string $path */ public function __construct($path) { $path = Item::make_sure_slash($path); if (!@is_dir($path)) { throw new ExceptionDisplay('Directory ' . Url::html_output($path) . ' does not exist.'); } $temp_list = @scandir($path); if ($temp_list === false) { throw new ExceptionDisplay('Error reading from directory ' . Url::html_output($path) . '.'); } $this -> dir_name = $path; $this -> contents = array(); foreach ($temp_list as $t) { if (!self::is_hidden($t, !@is_dir($path . $t))) { $this -> contents[] = $t; } } $this -> list_count = count($this -> contents); $this -> i = 0; } } ?>classes/DirectoryListDetailed.php0000755000000000000000000001552414576307353014375 0ustar * @version 1.1.0 (January 01, 2006) * @package AutoIndex */ class DirectoryListDetailed extends DirectoryList { /** * @var string The HTML text that makes up the path navigation links */ protected $path_nav; /** * @var int Total number of files in this directory */ protected $total_files; /** * @var int Total number of folders in this directory */ protected $total_folders; /** * @var int Total number of folders in this directory (including parent) */ protected $raw_total_folders; /** * @var int Total number of downloads of files in this directory */ protected $total_downloads; /** * @var Size Total size of this directory (recursive) */ protected $total_size; /** * @return string The HTML text that makes up the path navigation */ private function set_path_nav() { global $config, $subdir, $request; $exploded = explode('/', $subdir); $c = count($exploded) - 1; $temp = '' . Url::html_output(substr(str_replace('/', ' / ', $config->__get('base_dir')), 0, -2)) . '/ '; for ($i = 0; $i < $c; $i++) { $temp .= '' . Url::html_output($exploded[$i]) . ' / '; } return $temp; } /** * Returns -1 if $a < $b or 1 if $a > $b * * @param Item $a * @param Item $b * @return int */ private static function callback_sort(Item $a, Item $b) { if ($a->__get('is_parent_dir')) { return -1; } if ($b->__get('is_parent_dir')) { return 1; } $sort = strtolower($_SESSION['sort']); if ($sort === 'size') { $val = (($a->__get('size')->__get('bytes') < $b->__get('size')->__get('bytes')) ? -1 : 1); } else { if (!$a->is_set($sort)) { $_SESSION['sort'] = 'filename'; //so the "continue" link will work throw new ExceptionDisplay('Invalid sort mode.'); } if (is_string($a->__get($sort))) { $val = strnatcasecmp($a->__get($sort), $b->__get($sort)); } else { $val = (($a->__get($sort) < $b->__get($sort)) ? -1 : 1); } } return ((strtolower($_SESSION['sort_mode']) === 'd') ? -$val : $val); } /** * @return int The total number of files and folders (including the parent folder) */ public function total_items() { return $this->raw_total_folders + $this->total_files; } /** * @param string $path The directory to read the files from * @param int $page The number of files to skip (used for pagination) */ public function __construct($path, $page = 1) { $path = Item::make_sure_slash($path); parent::__construct($path); $subtract_parent = false; $this->total_downloads = $total_size = 0; $dirs = $files = array(); foreach ($this as $t) { if (@is_dir($path . $t)) { $temp = new DirItem($path, $t); if ($temp->__get('is_parent_dir')) { $dirs[] = $temp; $subtract_parent = true; } else if ($temp->__get('filename') !== false) { $dirs[] = $temp; if ($temp->__get('size')->__get('bytes') !== false) { $total_size += $temp->__get('size')->__get('bytes'); } } } else if (@is_file($path . $t)) { $temp = new FileItem($path, $t); if ($temp->__get('filename') !== false) { $files[] = $temp; $this->total_downloads += $temp->__get('downloads'); $total_size += $temp->__get('size')->__get('bytes'); } } } $version_compare = explode(".", phpversion(), 3); if ($version_compare[0] == '' || $version_compare[1] == '') { $phpversion = '5.4'; } else { $phpversion = $version_compare[0] . '.' . $version_compare[1]; } if (version_compare($phpversion, "5.5", ">")) { //die("you're on ".$phpversion." or bellow".phpversion().' &'.print_R($version_compare, true)); usort($dirs, array($this, 'callback_sort')); usort($files, array($this, 'callback_sort')); } else { //die("you're on ".$phpversion." or above: ".phpversion().' &'.print_R($version_compare, true)); usort($dirs, array($this, 'callback_sort')); usort($files, array($this, 'callback_sort')); } $this->contents = array_merge($dirs, $files); $this->total_size = new Size($total_size); $this->total_files = count($files); $this->raw_total_folders = $this->total_folders = count($dirs); if ($subtract_parent) { $this->total_folders--; } $this->path_nav = $this->set_path_nav(); //Paginate the files if (ENTRIES_PER_PAGE) { if ($page < 1) { throw new ExceptionDisplay('Invalid page number.'); } global $config; $num_per_page = $config->__get('entries_per_page'); if (($page - 1) * $num_per_page >= $this->total_items()) { throw new ExceptionDisplay('Invalid page number.'); } $this->contents = array_slice($this->contents, ($page - 1) * $num_per_page, $num_per_page); } } /** * @return string The HTML text of the directory list, using the template system */ public function __toString() { $head = new TemplateInfo(TABLE_HEADER, $this); $main = new TemplateFiles(EACH_FILE, $this); $foot = new TemplateInfo(TABLE_FOOTER, $this); return $head->__toString() . $main->__toString() . $foot->__toString(); } } ?> classes/Display.php0000755000000000000000000000515614530557667011553 0ustar * @version 1.0.2 (July 22, 2004) * @package AutoIndex */ class Display { /** * @var string HTML text to output */ private $contents; /** * @return string The HTML text of the list of function calls * @see debug_backtrace() */ public static function get_trace() { $list = '

Debug trace:'; foreach (debug_backtrace() as $arr) { $line = (isset($arr['line']) ? $arr['line'] : 'unknown'); $file = (isset($arr['file']) ? Item::get_basename($arr['file']) : 'unknown'); $type = (isset($arr['type']) ? $arr['type'] : 'Error'); $class = (isset($arr['class']) ? $arr['class'] : 'Display'); $function = (isset($arr['function']) ? $arr['function'] : 'unknown'); $list .= '\n
'.$file.' line '.$line.' '."($class$type$function)".''; } return $list . '

'; } /** * @param string $contents Sets the HTML contents */ public function __construct(&$contents) { $this->contents = $contents; } /** * @return string The HTML output, using the template system */ public function __toString() { $header = new TemplateIndexer(GLOBAL_HEADER); $footer = new TemplateIndexer(GLOBAL_FOOTER); $output = $header->__toString() . $this->contents; if (DEBUG) { $output .= self::get_trace(); } return $output . $footer->__toString(); } } ?> classes/ExceptionDisplay.php0000755000000000000000000000423314530557667013425 0ustar * @version 1.0.0 (August 01, 2004) * @package AutoIndex * @see Display */ class ExceptionDisplay extends ExceptionFatal { protected $request; protected $language; /** * @return string The HTML text to display */ public function __toString() { global $request, $words; $this->language = $words; $this->request = is_object($request) ? $request : new RequestVars('', false); $str = '
' . $this->message . '

' . (isset($this->language) ? $this->language->__get('continue') : 'Continue') . '.

'; $temp = new Display($str); return $temp->__toString(); } } ?> classes/FileItem.php0000755000000000000000000003363214542741422011627 0ustar * @version 1.0.1 (July 10, 2004) * @package AutoIndex */ class FileItem extends Item { /** * @param string $fn The filename * @return string Everything after the list dot in the filename, not including the dot */ public static function ext($fn, $ext = true) { $fn = Item::get_basename($fn); switch($ext) { case false: return (strpos($fn, '.') ? substr($fn, 0, strrpos($fn, '.')) : $fn); break; default: return (strpos($fn, '.') ? strtolower(substr(strrchr($fn, '.'), 1)) : ''); break; } } /** * @return string Returns the name of the filename * @see FileItem::ext() */ public function file_name() { return self::ext($this->filename, false); } /** * @return string Returns the extension of the filename * @see FileItem::ext() */ public function file_ext() { return self::ext($this->filename); } /** * @param string $parent_dir * @param string $filename */ public function __construct($parent_dir, $filename) { parent::__construct($parent_dir, $filename); if (!is_file($this->parent_dir . $filename)) { throw new ExceptionDisplay('File ' . Url::html_output($this->parent_dir . $filename) . ' does not exist.'); } global $config, $words, $downloads, $request; $this->filename = $filename; $this->size = new Size(filesize($this->parent_dir . $filename)); if (ICON_PATH) { $file_icon = new Icon($filename); $this->icon = $file_icon->__toString(); } $this->downloads = (DOWNLOAD_COUNT && $downloads->is_set($parent_dir . $filename) ? (int)($downloads->__get($parent_dir . $filename)) : 0); $this->link = Url::html_output($request->server('PHP_SELF')) . '?dir=' . Url::translate_uri(substr($this->parent_dir, strlen($config->__get('base_dir')))) . '&file=' . Url::translate_uri($filename); if (THUMBNAIL_HEIGHT && in_array(self::ext($filename), array('png', 'jpg', 'jpeg', 'jfif', 'gif', 'bmp'))) { $this->thumb_link = ' ' . $words->__get('thumbnail of') . ' ' . $filename . ''; $this->thumb_link .= ' ' . $words->__get('view') . ' ' . $words->__get('file') . ''; } if (THUMBNAIL_HEIGHT && in_array(self::ext($filename), array('svg', 'SVG'))) { $svgcontent = false; $svgcontent = file_get_contents(Url::translate_uri($this->parent_dir . $filename)); $width = $height = '32'; // $contentsvg = explode(' $content = explode('=', $contentsvg[1]); //[0] => xmlns [1] => "http://www.w3.org/2000/svg" width [2] => "32" height [3] => "32" viewBox [4] => "0 0 32 32"> if(preg_match('/]*width=\"(.*)\"\/>/isU', ' '400') ? str_replace($width, $width/1.1, $svgcontent) : $svgcontent; $svgcontent = ($width < '24') ? str_replace($width, $width*1.5*2, $svgcontent) : $svgcontent; $svgcontent = ('edit.svg' === basename($filename)) ? str_replace($width, '200', $svgcontent) : $svgcontent; if(preg_match_all('/]*height=\"(.*)\"\/>/isU', ' '400') ? str_replace($height, $height/1.1, $svgcontent) : $svgcontent; $svgcontent = ($width < '24') ? str_replace($height, $height*1.5*2, $svgcontent) : $svgcontent; $svgcontent = ('' === basename($filename)) ? str_replace($height, '200', $svgcontent) : $svgcontent; if(preg_match_all('/]*viewBox=\"(.*)\"\/>/isU', 'thumb_link = ''.$svgcontent.''; } if (THUMBNAIL_HEIGHT && in_array(self::ext($filename), array('thm', 'thm'))) { $this->thumb_link = ' ' . $words->__get('thumbnail of') . ' ' . $filename . ''; $this->thumb_link .= ' ' . $words->__get('view') . ' ' . $words->__get('file') . ''; } if (THUMBNAIL_HEIGHT && in_array(self::ext($filename), array('avi', 'divx', 'xvid', 'mkv', 'asf', 'mov', 'wmv', '3gp', 'mp3', 'mp4', 'mpv', 'ogg', 'ogv','mpg', 'mpeg', 'flv', 'FLV', 'flvjs'))) { $mime = new MimeType($filename); $finfo = finfo_open(FILEINFO_MIME_TYPE); //Display correct headers for media file $mimetype = finfo_file($finfo, $this->parent_dir . $filename); $file_size = function_exists('getvideosize') ? getvideosize($this->parent_dir . $filename) : array(); $file_mime = function_exists('getvideosize') ? $file_size['mime'] : $mime->__toString(); $this->thumb_link = ''; if (function_exists('imagecreatefromavi') && in_array(self::ext($filename), array('avi', 'divx', 'xvid'))) { $this->thumb_link .= ' '; $this->thumb_link .= '
' . $words->__get('thumbnail of') . ' ' . $filename . ''; } elseif (in_array(self::ext($filename), array('avi', 'divx', 'xvid', 'mkv', 'asf', 'mov', 'wmv', '3gp', 'mp4', 'mpv', 'ogv', 'mpg', 'mpeg'))) { $video_href = Url::html_output($request->server('PHP_SELF')) . '?thm='. Url::translate_uri($this->parent_dir . $filename); $thumbnail = Url::html_output($request->server('PHP_SELF')) . '?thumbnail='. Url::translate_uri($this->parent_dir . $filename); $this->thumb_link .= ' '; // if (in_array(self::ext($filename), array('avi', 'divx', 'mp4', 'mpg'))) { $this->thumb_link .=' '; //} $this->thumb_link .= '
' . $words->__get('thumbnail of') . ' ' . $filename . ''; $this->thumb_link .= ' ' . $words->__get('view') . ' ' . $words->__get('file') . ''; } elseif (in_array(self::ext($filename), array('flv', 'FLV', 'flvjs'))) { $video_href = Url::html_output($request->server('PHP_SELF')) . '?thm='. Url::translate_uri($this->parent_dir . $filename); $thumbnail = Url::html_output($request->server('PHP_SELF')) . '?thumbnail='. Url::translate_uri($this->parent_dir . $filename); $this->thumb_link .= ''; $this->thumb_link .=''; $this->thumb_link .= ' ' . $words->__get('view') . ' ' . $words->__get('file') . ''; } elseif (in_array(self::ext($filename), array('MP3', 'mp3', 'ogg'))) { // $this->thumb_link .= ' '; // } else { $this->thumb_link .= ' '; $this->thumb_link .= ' ' . $words->__get('view') . ' ' . $words->__get('file') . ''; } } /* if (THUMBNAIL_HEIGHT && in_array(self::ext($filename), array('svg', 'xml'))) { $icon_svg = ICON_PATH ? Url::translate_uri($config->__get('icon_path') . 'svg.png') : Url::translate_uri($this->parent_dir . $filename); $heightwidth = in_array(self::ext($filename), array('svg', 'xml')) ? ' height="' . '150' . '" width="' . '150' . '" ' : ' '; $this->thumb_link .= ' ' . $words->__get('thumbnail of') . ' ' . $filename . ''; } */ $size = $this->size->__get('bytes'); if (MD5_SHOW && $size > 0 && $size / 1048576 <= $config->__get('md5_show')) { $this->md5_link = '[' . $words->__get('calculate md5sum') . ']'; } } /** * @param string $var The key to look for * @return mixed The data stored at the key */ public function __get($var = '') { if (isset($this->$var)) { return $this->$var; } throw new ExceptionDisplay('Variable ' . Url::html_output($var) . ' not set in FileItem class.'); } } ?> classes/FileItem6.php0000755000000000000000000001525414524756313011722 0ustar * @version 1.0.1 (July 10, 2004) * @package AutoIndex */ class FileItem extends Item { /** * @param string $fn The filename * @return string Everything after the list dot in the filename, not including the dot */ public static function ext($fn) { $fn = Item::get_basename($fn); return (strpos($fn, '.') ? strtolower(substr(strrchr($fn, '.'), 1)) : ''); } /** * @return string Returns the extension of the filename * @see FileItem::ext() */ public function file_ext() { return self::ext($this -> filename); } /** * @param string $parent_dir * @param string $filename */ public function __construct($parent_dir, $filename) { parent::__construct($parent_dir, $filename); if (!is_file($this -> parent_dir . $filename)) { throw new ExceptionDisplay('File ' . Url::html_output($this -> parent_dir . $filename) . ' does not exist.'); } global $config, $words, $downloads; $this -> filename = $filename; $this -> size = new Size(filesize($this -> parent_dir . $filename)); if (ICON_PATH) { $file_icon = new Icon($filename); $this -> icon = $file_icon -> __toString(); } $this -> downloads = (DOWNLOAD_COUNT && $downloads -> is_set($parent_dir . $filename) ? (int)($downloads -> __get($parent_dir . $filename)) : 0); $this -> link = Url::html_output($_SERVER['PHP_SELF']) . '?dir=' . Url::translate_uri(substr($this -> parent_dir, strlen($config -> __get('base_dir')))) . '&file=' . Url::translate_uri($filename); if (THUMBNAIL_HEIGHT && in_array(self::ext($filename), array('png', 'jpg', 'jpeg', 'jfif', 'gif', 'bmp'))) { $this -> thumb_link = ' ' . $words -> __get('thumbnail of') . ' ' . $filename . ''; $this -> thumb_link .= ' ' . $words -> __get('view') . ' ' . $words -> __get('file') . ''; } if (THUMBNAIL_HEIGHT && in_array(self::ext($filename), array('avi', 'thm', 'mkv', 'asf', 'mov', 'wmv', '3gp'))) { $mime = new MimeType($filename); $finfo = finfo_open(FILEINFO_MIME_TYPE); //Display correct headers for media file $mimetype = finfo_file($finfo, $this -> parent_dir . $filename); $file_size = function_exists('getvideosize') ? getvideosize($this -> parent_dir . $filename) : array(); $file_mime = function_exists('getvideosize') ? $file_size['mime'] : $mime -> __toString(); $this -> thumb_link = ' '; if (function_exists('imagecreatefromavi') && in_array(self::ext($filename), array('avi', 'wmv', '3gp'))) { $this -> thumb_link .= '
' . $words -> __get('thumbnail of') . ' ' . $filename . ''; } else { $this -> thumb_link = ' '; } } if (THUMBNAIL_HEIGHT && in_array(self::ext($filename), array('svg', 'xml'))) { $icon_svg = ICON_PATH ? Url::translate_uri($config -> __get('icon_path') . 'svg.png') : Url::translate_uri($this -> parent_dir . $filename); $heightwidth = in_array(self::ext($filename), array('svg', 'xml')) ? ' height="' . '150' . '" width="' . '150' . '" ' : ' '; $this -> thumb_link = ' ' . $words -> __get('thumbnail of') . ' ' . $filename . ''; //. ' ' . $words -> __get('thumbnail of') . ' ' . $filename . ''; } $size = $this -> size -> __get('bytes'); if (MD5_SHOW && $size > 0 && $size / 1048576 <= $config -> __get('md5_show')) { $this -> md5_link = '[' . $words -> __get('calculate md5sum') . ']'; } } /** * @param string $var The key to look for * @return mixed The data stored at the key */ public function __get($var = '') { if (isset($this -> $var)) { return $this -> $var; } throw new ExceptionDisplay('Variable ' . Url::html_output($var) . ' not set in FileItem class.'); } } ?>classes/Ftp.php0000755000000000000000000000765511500513450010655 0ustar * @version 1.0.0 (February 16, 2005) * @package AutoIndex */ class Ftp extends DirectoryList { /** * @var resource The FTP connection handle */ private $handle; /** * @var array Array of bools, for each entry */ private $is_directory; /** * Returns if the $i'th entry is a directory or not. * * @param int $i The file/folder entry to check * @return bool True if directory, false if file */ public function is_directory($i) { return $this -> is_directory[$i]; } /** * Reads the contents of the directory $path from the FTP server. * * @param string $path */ private function update_list($path) { $path = Item::make_sure_slash($path); $is_dir = $this -> contents = array(); $this -> dir_name = $path; $raw_list = @ftp_rawlist($this -> handle, $path); if ($raw_list === false) { throw new ExceptionDisplay('Unable to read directory contents of FTP server.'); } foreach ($raw_list as $file) { if ($file == '') { continue; } $name = strrchr($file, ' '); if ($name === false) { continue; } $this -> is_directory[] = (strtolower($file{0}) === 'd'); $this -> contents[] = $path . substr($name, 1); } $this -> list_count = count($this -> contents); $this -> i = 0; } /** * @param string $local * @param string $remote */ public function get_file($local, $remote) { if (!@ftp_get($this -> handle, $local, $remote, FTP_BINARY)) { throw new ExceptionDisplay('Unable to transfer file from FTP server.'); } } /** * @param string $local * @param string $remote */ public function put_file($local, $remote) { if (!@ftp_put($this -> handle, $remote, $local, FTP_BINARY)) { throw new ExceptionDisplay('Unable to transfer file to FTP server.'); } } /** * @param string $host * @param int $port * @param bool $passive * @param string $directory Directory to view * @param string $username To login with * @param string $password To login with */ public function __construct($host, $port, $passive, $directory, $username, $password) { $this -> handle = @ftp_connect(trim($host), (int)$port); if ($this -> handle === false) { throw new ExceptionDisplay('Could not connect to FTP server.'); } if (!@ftp_login($this -> handle, $username, $password)) { throw new ExceptionDisplay('Incorrect login for FTP server.'); } if ($passive && !@ftp_pasv($this -> handle, true)) { throw new ExceptionDisplay('Could not set passive mode for FTP server.'); } $this -> update_list($directory); } /** * Closes the open FTP connection when the object is destroyed. */ public function __destruct() { ftp_close($this -> handle); } } ?>classes/Htaccess.php0000755000000000000000000003016614530557667011702 0ustar * - * - * - AddDescription * - IndexIgnore * - Include * - Order * - Deny from * - Allow from * - AuthUserFile * - AuthName * - Require user * * These password formats are supported for .htpasswd file: * - MD5 * - SHA-1 * - Crypt * - Apache's Custom MD5 Crypt * * @author Justin Hagstrom * @version 1.0.1 (January 6, 2007) * @package AutoIndex */ class Htaccess { /** * @var string "AuthName" setting */ private $auth_name; /** * @var string "AuthUserFile" setting */ private $auth_user_file; /** * @var array "Require user" setting */ private $auth_required_users; /** * @var string "Order" setting */ private $order; /** * @var array "Allow from" setting */ private $allow_list; /** * @var array "Deny from" setting */ private $deny_list; /** * Converts hexadecimal to binary. * * @param string $hex * @return string */ private static function hex2bin($hex) { $bin = ''; $ln = strlen($hex); for($i = 0; $i < $ln; $i += 2) { $bin .= chr(hexdec($hex[$i] . $hex[$i + 1])); } return $bin; } /** * Return the number of count from the value using base conversion. * * @param int $value * @param int $count * @return int */ private static function to64($value, $count) { static $root = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; $result = ''; while(--$count) { $result .= $root[$value & 0x3f]; $value >>= 6; } return $result; } /** * Implementation of Apache's Custom MD5 Crypt. * * @param string $plain The plaintext password * @param string $salt The salt * @return string The hashed password */ private static function md5_crypt($plain, $salt) { $length = strlen($plain); $context = $plain . '$apr1$' . $salt; $binary = self::hex2bin(md5($plain . $salt . $plain)); for ($i = $length; $i > 0; $i -= 16) { $context .= substr($binary, 0, min(16, $i)); } for ( $i = $length; $i > 0; $i >>= 1) { $context .= ($i & 1) ? chr(0) : $plain[0]; } $binary = self::hex2bin(md5($context)); for ($i = 0; $i < 1000; $i++) { $new = ($i & 1) ? $plain : substr($binary, 0, 16); if ($i % 3) { $new .= $salt; } if ($i % 7) { $new .= $plain; } $new .= (($i & 1) ? substr($binary, 0, 16) : $plain); $binary = self::hex2bin(md5($new)); } $p = array(); for ($i = 0; $i < 5; $i++) { $k = $i + 6; $j = $i + 12; if ($j == 16) { $j = 5; } $p[] = self::to64( (ord($binary[$i]) << 16) | (ord($binary[$k]) << 8) | (ord($binary[$j])), 5 ); } return '$apr1$' . $salt . '$' . implode($p) . self::to64(ord($binary[11]), 3); } /** * Tests if $test matches $target. * * @param string $test * @param string $target * @return bool True if $test matches $target */ private static function matches($test, $target) { static $replace = array( '\*' => '.*', '\+' => '.+', '\?' => '.?'); return (bool)preg_match('/^' . strtr(preg_quote($test, '/'), $replace) . '$/i', $target); } /** * Checks if AuthName and AuthUserFile are set, and then prompts for a * username and password. */ private function check_auth() { global $request; if ($this->auth_user_file == '') { return; } if ($this->auth_name == '') { $this->auth_name = '"Directory access restricted by AutoIndex"'; } $validated = false; if ($request->server('PHP_AUTH_USER') && $request->server('PHP_AUTH_PW')) { $file = @file($this->auth_user_file); if ($file === false) { $_GET['dir'] = ''; throw new ExceptionDisplay('Cannot open .htpasswd file
' . htmlentities($this->auth_user_file) . ''); } if ($this->auth_required_users === array() || DirectoryList::match_in_array($request->server('PHP_AUTH_USER'), $this->auth_required_users)) { foreach ($file as $account) { $parts = explode(':', trim($account)); if (count($parts) < 2 || $request->server('PHP_AUTH_USER') != $parts[0]) { continue; } if (isset($parts[2])) //MD5 hash format with realm { $parts[1] = $parts[2]; } switch (strlen($parts[1])) { case 13: //Crypt hash format { $validated = (crypt($request->server('PHP_AUTH_PW'), substr($parts[1], 0, 2)) == $parts[1]); break 2; } case 32: //MD5 hash format { $validated = (md5($request->server('PHP_AUTH_PW')) == $parts[1]); break 2; } case 37: //Apache's MD5 Crypt hash format { $salt = explode('$', $parts[1]); $validated = (self::md5_crypt($request->server('PHP_AUTH_PW'), $salt[2]) == $parts[1]); break 2; } case 40: //SHA-1 hash format { $validated = (sha1($request->server('PHP_AUTH_PW')) == $parts[1]); break 2; } } } } sleep(1); } if (!$validated) { header('WWW-Authenticate: Basic realm=' . $this->auth_name); header('HTTP/1.0 401 Authorization Required'); $_GET['dir'] = ''; throw new ExceptionDisplay('A username and password are required to access this directory.'); } } /** * Checks if the user's IP or hostname is either allowed or denied. */ private function check_deny() { global $ip, $host, $words; if ($this->order === 'allow, deny') { if (!DirectoryList::match_in_array($host, $this->allow_list) && !DirectoryList::match_in_array($ip, $this->allow_list)) { $_GET['dir'] = ''; throw new ExceptionDisplay($words->__get('the administrator has blocked your ip address or hostname') . '.'); } } else if (DirectoryList::match_in_array($ip, $this->deny_list) || DirectoryList::match_in_array($host, $this->deny_list)) { $_GET['dir'] = ''; throw new ExceptionDisplay($words->__get('the administrator has blocked your ip address or hostname') . '.'); } } /** * @param string $file The .htaccess file (name and path) to parse */ private function parse($file) { $data = @file($file); if ($data === false) { return; } $conditional_defined = $conditional_directory = ''; $other_conditional = false; foreach ($data as $line) { $line = trim($line); if ($line == '') { continue; } if ($line[0] == '<') { if (preg_match('#^#i', $line)) { $conditional_directory = ''; } else if (preg_match('#^<\s*directory\s+\"?(.+?)\"?\s*>#i', $line, $matches)) { $conditional_directory = $matches[1]; } else if (preg_match('#^#i', $line)) { //ignore tags continue; } else if (preg_match('#^#i', $line)) { $conditional_defined = ''; } else if (preg_match('#^<\s*ifdefine\s+(.+?)\s*>#i', $line, $matches)) { $conditional_defined = $matches[1]; } else if (isset($line[1])) { $other_conditional = ($line[1] != '/'); } continue; } global $dir; if ($other_conditional || $conditional_directory != '' && !self::matches($conditional_directory, $dir)) //deal with or an unknown < > tag { continue; } if ($conditional_defined != '') //deal with { $conditional_defined = strtoupper($conditional_defined); if ($conditional_defined[0] === '!') { $conditional_defined = substr($conditional_defined, 1); if (defined($conditional_defined) && constant($conditional_defined)) { continue; } } else if (!defined($conditional_defined) || !constant($conditional_defined)) { continue; } } $parts = preg_split('#\s#', $line, -1, PREG_SPLIT_NO_EMPTY); switch (strtolower($parts[0])) { case 'indexignore': { global $hidden_files; for ($i = 1; $i < count($parts); $i++) { $hidden_files[] = $parts[$i]; } break; } case 'include': { if (isset($parts[1]) && @is_file($parts[1]) && @is_readable($parts[1])) { self::parse($parts[1]); } break; } case 'allow': { if (isset($parts[1]) && strtolower($parts[1]) === 'from') { for ($i = 2; $i < count($parts); $i++) { foreach (explode(',', $parts[$i]) as $ip) { if (strtolower($ip) === 'all') { $this->allow_list = array('*'); } else { $this->allow_list[] = $ip; } } } } break; } case 'deny': { if (isset($parts[1]) && strtolower($parts[1]) === 'from') { for ($i = 2; $i < count($parts); $i++) { foreach (explode(',', $parts[$i]) as $ip) { if (strtolower($ip) === 'all') { $this->deny_list = array('*'); } else { $this->deny_list[] = $ip; } } } } break; } case 'adddescription': { global $descriptions; if (!isset($descriptions)) { $descriptions = new ConfigData(false); } for ($i = 1; isset($parts[$i], $parts[$i+1]); $i += 2) { $descriptions->set($parts[$i], $parts[$i+1]); } break; } case 'authuserfile': { if (isset($parts[1])) { $this->auth_user_file = str_replace('"', '', implode(' ', array_slice($parts, 1))); } break; } case 'authname': { if (isset($parts[1])) { $this->auth_name = implode(' ', array_slice($parts, 1)); } break; } case 'order': { if (isset($parts[1]) && (strtolower($parts[1]) === 'allow,deny' || strtolower($parts[1]) === 'mutual-failure')) { $this->order = 'allow,deny'; } } case 'require': { if (isset($parts[1]) && strtolower($parts[1]) === 'user') { for ($i = 2; $i < count($parts); $i++) { $this->auth_required_users[] = $parts[$i]; } } break; } } } } /** * @param string $dir The deepest folder to parse for .htaccess files * @param string $filename The name of the files to look for */ public function __construct($dir, $filename = '.htaccess') { $this->auth_name = $this->auth_user_file = ''; $this->auth_required_users = $this->allow_list = $this->deny_list = array(); $this->order = 'deny, allow'; if (DirItem::get_parent_dir($dir) != '') //recurse into parent directories { new Htaccess(DirItem::get_parent_dir($dir)); } $dir = Item::make_sure_slash($dir); $file = $dir . $filename; if (@is_file($file) && @is_readable($file)) { $this->parse($dir . $filename); $this->check_deny(); $this->check_auth(); } } } ?> classes/Icon.php0000755000000000000000000001547714524237611011030 0ustar * @version 1.0.2 (August 07, 2004) * @package AutoIndex */ class Icon { /** * @var string Filename of the image file */ private $icon_name; /** * Given a file extension, this will come up with the filename of the * icon to represent the filetype. *ş * @param string $ext The file extension to find the icon for * @return string The appropriate icon depending on the extension */ private static function find_icon($ext, $name) { if (($ext == '') || ($ext == 'md')) { switch($name) { case 'README': case 'ReadMe': return 'readme'; break; case 'CODE_OF_CONDUCT': return 'conduct'; break; case 'LICENSE': return 'license'; break; case 'SECURITY': return 'security'; break; default: return 'generic'; } } static $icon_types = array( 'binary' => array('patch', 'bin', 'dmg', 'dms', 'exe', 'msi', 'msp', 'pyd', 'scr', 'so'), 'binhex' => array('hqx'), 'conduct' => array('cnd'), 'readme' => array('wri', 'md'), 'license' => array('tql'), 'security' => array('sec', 'cer', 'der', 'crt', 'spc', 'p7b', 'p12', 'pfx'), 'key' => array('key', 'pem', 'pub', 'fin'), 'cd' => array('bwi', 'bws', 'bwt', 'ccd', 'cdi', 'cue', 'img', 'iso', 'mdf', 'mds', 'nrg', 'nri', 'sub', 'vcd'), 'command' => array('bat', 'cmd', 'com', 'lnk', 'pif'), 'comp' => array('cfg', 'conf', 'inf', 'ini', 'log', 'nfo', 'sys'), 'registry' => array('reg', 'hiv'), 'compressed' => array('7z', 'a', 'ace', 'ain', 'alz', 'amg', 'arc', 'ari', 'arj', 'bh', 'bz', 'bz2', 'cab', 'deb', 'dz', 'gz', 'io', 'ish', 'lha', 'lzh', 'lzs', 'lzw', 'lzx', 'msx', 'pak', 'rar', 'rpm', 'sar', 'sea', 'sit', 'taz', 'tbz', 'tbz2', 'tgz', 'tz', 'tzb', 'uc2', 'xxe', 'yz', 'z', 'zip', 'zoo'), 'dll' => array('386', 'db', 'dll', 'ocx', 'sdb', 'vxd', 'drv'), 'doc' => array('abw', 'ans', 'chm', 'cwk', 'dif', 'doc', 'dot', 'mcw', 'msw', 'pdb', 'psw', 'rtf', 'rtx', 'sdw', 'stw', 'sxw', 'vor', 'wk4', 'wkb', 'wpd', 'wps', 'wpw', 'wsd'), 'image' => array('adc', 'art', 'bmp', 'cgm', 'dib', 'gif', 'ico', 'ief', 'jfif', 'jif', 'jp2', 'jpc', 'jpe', 'jpeg', 'jpg', 'jpx', 'mng', 'pcx', 'png', 'psd', 'psp', 'swc', 'sxd', 'svg', 'tga', 'tif', 'tiff', 'wmf', 'wpg', 'xcf', 'xif', 'yuv'), 'bible' => array('bbl', 'bblx', 'ot', 'nt', 'toc'), 'java' => array('class', 'jar', 'jav', 'java', 'jtk'), 'js' => array('ebs', 'js', 'jse', 'vbe', 'vbs', 'wsc', 'wsf', 'wsh'), 'key' => array('aex', 'asc', 'gpg', 'key', 'pgp', 'ppk'), 'mov' => array('amc', 'dv', 'm4v', 'mac', 'mov', 'pct', 'pic', 'pict', 'pnt', 'pntg', 'qpx', 'qt', 'qti', 'qtif', 'qtl', 'qtp', 'qts', 'qtx'), 'movie' => array('asf', 'asx', 'avi', 'div', 'divx', 'dvi', 'm1v', 'm2v', 'mkv', 'movie', 'mp2v', 'mpa', 'mpe', 'mpeg', 'mpg', 'mp4v', 'mp4', 'mpg4', 'mps', 'mpv', 'mpv2', 'ogm', 'ram', 'rmvb', 'rnx', 'rp', 'rv', 'vivo', 'vob', 'wmv', 'xvid'), 'fnt' => array('fnt', 'bdf'), 'fon' => array('fon'), 'ttf' => array('ttf'), 'otf' => array('otf'), 'sfd' => array('sfd'), 'afm' => array('afm'), 'eot' => array('eot'), 'woff' => array('woff'), 'woff2' => array('woff2'), 'pdf' => array('edn', 'fdf', 'pdf', 'pdp', 'pdx'), 'php' => array('inc', 'php', 'php3', 'php4', 'php5', 'php7', 'php8', 'php9', 'phps', 'phtml'), 'ppt' => array('emf', 'pot', 'ppa', 'pps', 'ppt', 'sda', 'sdd', 'shw', 'sti', 'sxi'), 'ps' => array('ai', 'eps', 'ps'), 'sound' => array('aac', 'ac3', 'aif', 'aifc', 'aiff', 'ape', 'apl', 'au', 'ay', 'bonk', 'cda', 'cdda', 'cpc', 'fla', 'flac', 'gbs', 'gym', 'hes', 'iff', 'it', 'itz', 'kar', 'kss', 'la', 'lpac', 'lqt', 'm4a', 'm4p', 'mdz', 'mid', 'midi', 'mka', 'mo3', 'mod', 'mp+', 'mp1', 'mp2', 'mp3', 'mp4', 'mpc', 'mpga', 'mpm', 'mpp', 'nsf', 'oda', 'ofr', 'ogg', 'pac', 'pce', 'pcm', 'psf', 'psf2', 'ra', 'rm', 'rmi', 'rmjb', 'rmm', 'sb', 'shn', 'sid', 'snd', 'spc', 'spx', 'svx', 'tfm', 'tfmx', 'voc', 'vox', 'vqf', 'wav', 'wave', 'wma', 'wv', 'wvx', 'xa', 'xm', 'xmz'), 'tar' => array('gtar', 'tar'), 'csharp' => array('csproj', 'cs'), 'prog' => array('asm', 'c', 'cc', 'cp', 'cpp', 'cxx', 'diff', 'h', 'hpp', 'hxx', 'md5', 'patch', 'py', 'sfv', 'sh'), 'play' => array('m3u', 'pls'), 'text' => array('md5', 'txt'), 'uu' => array('uu', 'uud', 'uue'), 'web' => array('asa', 'asp', 'aspx', 'cfm', 'cgi', 'css', 'dhtml', 'dtd', 'grxml', 'htc', 'htm', 'html', 'htt', 'htx', 'jsp', 'mathml', 'mht', 'mhtml', 'perl', 'pl', 'plg', 'rss', 'shtm', 'shtml', 'stm', 'swf', 'tpl', 'wbxml', 'xht', 'xhtml', 'xml', 'xsl', 'xslt', 'xul'), 'xls' => array('csv', 'dbf', 'prn', 'pxl', 'sdc', 'slk', 'stc', 'sxc', 'xla', 'xlb', 'xlc', 'xld', 'xlr', 'xls', 'xlt', 'xlw')); foreach ($icon_types as $png_name => $exts) { if (in_array($ext, $exts)) { return $png_name; } } switch($name) { case 'README': case 'ReadMe': return 'readme'; break; case 'CODE_OF_CONDUCT': return 'conduct'; break; case 'LICENSE': return 'license'; break; case 'SECURITY': return 'security'; break; default: return 'unknown'; } } /** * @param string $filename The filename to find the icon for */ public function __construct($filename) { $this->icon_name = self::find_icon(FileItem::ext($filename), FileItem::ext($filename, false)); } /** * @return string The full path to the icon file */ public function __toString() { global $config; return $config->__get('icon_path') . $this->icon_name . '.png'; } } ?> classes/Image.php0000755000000000000000000003154514524237611011154 0ustar * @version 1.0.0 (May 22, 2004) * @package AutoIndex */ class Image { /** * @var string Name of the image file */ private $filename; /** * @var int The height of the thumbnail to create (width is automatically determined) */ private $height; /** * Massage the SVG image data for converters which don't understand some path data syntax. * * This is necessary for rsvg and ImageMagick when compiled with rsvg support. * Upstream bug is https://bugzilla.gnome.org/show_bug.cgi?id=620923, fixed 2014-11-10, so * this will be needed for a while. (T76852) * * @param string $svg SVG image data * @return string Massaged SVG image data */ protected function massageSvgPathdata($svg) { // load XML into simplexml $xml = simplexml_load_file($svg); // if the XML is valid if ( $xml instanceof SimpleXMLElement ) { $dom = new DOMDocument( '1.0', 'utf-8' ); $dom->preserveWhiteSpace = false; $dom->formatOutput = true; // use it as a source $dom->loadXML( $xml->asXML() ); foreach ($dom->getElementsByTagName('path') as $node) { $pathData = $node->getAttribute('d'); // Make sure there is at least one space between numbers, and that leading zero is not omitted. // rsvg has issues with syntax like "M-1-2" and "M.445.483" and especially "M-.445-.483". $pathData = preg_replace('/(-?)(\d*\.\d+|\d+)/', ' ${1}0$2 ', $pathData); // Strip unnecessary leading zeroes for prettiness, not strictly necessary $pathData = preg_replace('/([ -])0(\d)/', '$1$2', $pathData); $node->setAttribute('d', $pathData); } return $dom->saveXML(); } } /** * Convert passed image data, which is assumed to be SVG, to PNG. * * @param string $file SVG image data * @return string|bool PNG image data, or false on failure */ protected function imagecreatefromsvg($file) { /** * This code should be factored out to a separate method on SvgHandler, or perhaps a separate * class, with a separate set of configuration settings. * * This is a distinct use case from regular SVG rasterization: * * We can skip many sanity and security checks (as the images come from a trusted source, * rather than from the user). * * We need to provide extra options to some converters to achieve acceptable quality for very * small images, which might cause performance issues in the general case. * * We want to directly pass image data to the converter, rather than a file path. * * See https://phabricator.wikimedia.org/T76473#801446 for examples of what happens with the * default settings. * * For now, we special-case rsvg (used in WMF production) and do a messy workaround for other * converters. */ $src = file_get_contents($file); $svg = $this->massageSvgPathdata($file); // Sometimes this might be 'rsvg-secure'. Long as it's rsvg. if ( strpos( CACHE_STORAGE_DIR, 'rsvg' ) === 0 ) { $command = 'rsvg-convert'; if ( CACHE_STORAGE_DIR ) { $command = Shell::escape(CACHE_STORAGE_DIR) . $command; } $process = proc_open( $command, [ 0 => [ 'pipe', 'r' ], 1 => [ 'pipe', 'w' ] ], $pipes ); if ( is_resource( $process ) ) { fwrite( $pipes[0], $svg ); fclose( $pipes[0] ); $png = stream_get_contents( $pipes[1] ); fclose( $pipes[1] ); proc_close( $process ); return $png ?: false; } return false; } else { // Write input to and read output from a temporary file $tempFilenameSvg = CACHE_STORAGE_DIR . 'ResourceLoaderImage.svg'; $tempFilenamePng = CACHE_STORAGE_DIR . 'ResourceLoaderImage.png'; @copy($file, $tempFilenameSvg); @file_put_contents( $tempFilenameSvg, $src ); $typeString = "image/png"; $command = 'cd ~' . CACHE_STORAGE_DIR . ' && java -jar batik-rasterizer.jar ' . $tempFilenameSvg . ' -m ' .$typeString; //$command = "java -jar ". CACHE_STORAGE_DIR . "batik-rasterizer.jar -m " . $typeString ." -d ". $tempFilenamePng . " -q " . THUMBNAIL_HEIGHT . " " . $tempFilenameSvg . " 2>&1"; $process = proc_open( $command, [ 0 => [ 'pipe', 'r' ], 1 => [ 'pipe', 'w' ] ], $pipes ); if ( is_resource( $process ) ) { proc_close( $process ); } else { $output = shell_exec($command); echo "Command: $command
"; echo "Output: $output"; } //$svgReader = new SVGReader($file); //$metadata = $svgReader->getMetadata(); //if ( !isset( $metadata['width'] ) || !isset( $metadata['height'] ) ) //{ $metadata['width'] = $metadata['height'] = THUMBNAIL_HEIGHT; //} //loop to color each state as needed, something like $idColorArray = array( "AL" => "339966", "AK" => "0099FF", "WI" => "FF4B00", "WY" => "A3609B" ); foreach($idColorArray as $state => $color) { //Where $color is a RRGGBB hex value $svg = preg_replace('/id="'.$state.'" style="fill: #([0-9a-f]{6})/', 'id="'.$state.'" style="fill: #'.$color, $svg ); } $im = @ImageCreateFromPNG($svg); //$im->readImageBlob($svg); // png settings //$im->setImageFormat(function_exists('imagecreatefrompng') ? 'png24' : 'jpeg'); //$im->resizeImage($metadata['width'], $metadata['height'], (function_exists('imagecreatefrompng') ? imagick::FILTER_LANCZOS : ''), 1); // Optional, if you need to resize // jpeg //$im->adaptiveResizeImage($metadata['width'], $metadata['height']); //Optional, if you need to resize //$im->writeImage($tempFilenamePng); // (or .jpg) //unlink( $tempFilenameSvg ); //$png = null; //if ( $res === true ) //{ // $png = file_get_contents( $tempFilenamePng ); // unlink( $tempFilenamePng ); //} //return $png ?: false; } die($svg); } /** * Outputs the jpeg image along with the correct headers so the * browser will display it. The script is then exited. */ public function __toString() { $thumbnail_height = $this->height; $file = $this->filename; $file_icon = new Icon($file); $this->icon = $file_icon->__toString(); if (!@is_file($file)) { header('HTTP/1.0 404 Not Found'); throw new ExceptionDisplay('Image file not found: ' . Url::html_output($file) . ''); } switch (FileItem::ext($file)) { case 'gif': { $src = @imagecreatefromgif($file); break; } /* case 'thm': { $src = @exif_thumbnail($file, THUMBNAIL_HEIGHT, THUMBNAIL_HEIGHT, 'image/jpg'); break; } */ case 'jpeg': case 'jpg': case 'jpe': case 'jfif' : { $src = @imagecreatefromjpeg($file); break; } case 'svg' : { $src = $this->imagecreatefromsvg($file); break; } case 'png': { $src = @imagecreatefrompng($file); break; } case 'bmp' : { $src = imagecreatefrombmp($file); break; } case 'xbm' : { $src= imagecreatefromxbm($file); break; } case 'xpm' : { $src = imagecreatefromxpm($file); break; } case 'wmv' : { ini_set('memory_limit', '512M'); $src = function_exists('imagecreatefromwmv') ? imagecreatefromwmv($file) : imagecreatefromjpeg(str_replace('wmv', 'jpg', $file)); break; } case 'avi': case 'divx': case 'xvid': { ini_set('memory_limit', '512M'); $src = function_exists($function) ? imagecreatefromavi($file) : imagecreatefromjpeg(str_replace(FileItem::ext($file), 'jpg', $file)); break; } case 'mp4': case 'mpg': case 'mp3': case 'ogv': case 'flv': { ini_set('memory_limit', '512M'); $function = 'imagecreatefrom'.FileItem::ext($file); $src = function_exists($function) ? 'imagecreatefrom'.$$function.($file) : imagecreatefromjpeg(str_replace(FileItem::ext($file), 'jpg', $file)); break; } case '3gp': { ini_set('memory_limit', '512M'); $src = function_exists('imagecreatefrom3gp') ? imagecreatefrom3gp($file) : imagecreatefromjpeg(str_replace('3gp', 'jpg', $file)); break; } case 'php': { $src = str_replace('php', 'png', $file); //JN (GPL) $file_header = 'Content-type: image/png'; srand ((float) microtime() * 10000000); $quote = rand(1, 6); switch($quote) { case "1": $rand_quote = "MXP-CMS Team, mxp.sf.net"; break; case "2": $rand_quote = "in between milestones edition ;)"; break; case "3": $rand_quote = "MX-Publisher, Fully Modular Portal & CMS for phpBB"; break; case "4": $rand_quote = "Portal & CMS Site Creation Tool"; break; case "5": $rand_quote = "...pafileDB, FAP, MX-Publisher, Translator"; break; case "6": $rand_quote = "...Calendar, Links & News...modules"; break; } $pic_title = $rand_quote; $pic_title_reg = preg_replace("/[^A-Za-z0-9]/", "_", $pic_title); $current_release = "3.0.0"; $im = @ImageCreateFromPNG($src); $pic_size = @getimagesize($src); $pic_width = $pic_size[0]; $pic_height = $pic_size[1]; $dimension_font = 1; $dimension_filesize = filesize($src); $dimension_string = intval($pic_width) . 'x' . intval($pic_height) . '(' . intval($dimension_filesize / 1024) . 'KB)'; $blue = ImageColorAllocate($im, 6, 108, 159); $dimension_height = imagefontheight($dimension_font); $dimension_width = imagefontwidth($dimension_font) * strlen($current_release); $dimension_x = ($thumbnail_width - $dimension_width) / 2; $dimension_y = $thumbnail_height + ((16 - $dimension_height) / 2); //ImageString($im, 2, $dimension_x, $dimension_y, $current_release, $blue); @ImageString($im, 2, 125, 2, $current_release, $blue); @ImageString($im, 2, 20, 17, $rand_quote, $blue); @Header($file_header); Header("Expires: Mon, 1, 1999 05:00:00 GMT"); Header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); Header("Cache-Control: no-store, no-cache, must-revalidate"); Header("Cache-Control: post-check=0, pre-check=0", false); Header("Pragma: no-cache"); @ImagePNG($im); exit; break; } default: { $function = 'imagecreatefrom'.FileItem::ext($file); $src = function_exists($function) ? 'imagecreatefrom'.$$function.($file) : imagecreatefromjpeg(str_replace(FileItem::ext($file), 'jpg', $file)); break; } } if ($src === false) { throw new ExceptionDisplay('Unsupported image type.'); } header('Content-Type: image/jpeg'); header('Cache-Control: public, max-age=3600, must-revalidate'); header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 3600) . ' GMT'); $src_height = imagesy($src); if ($src_height <= $thumbnail_height) { imagejpeg($src, '', 95); } else { $src_width = imagesx($src); $thumb_width = $thumbnail_height * ($src_width / $src_height); $thumb = imagecreatetruecolor($thumb_width, $thumbnail_height); imagecopyresampled($thumb, $src, 0, 0, 0, 0, $thumb_width, $thumbnail_height, $src_width, $src_height); imagejpeg($thumb); imagedestroy($thumb); } imagedestroy($src); die(); } /** * @param string $file The image file */ public function __construct($file) { if (!THUMBNAIL_HEIGHT) { throw new ExceptionDisplay('Image thumbnailing is turned off.'); } global $config; $this -> height = (int)$config ->__get('thumbnail_height'); $this -> filename = $file; //$this -> tn_path = $config -> __get('thumbnail_path'); //$this -> tn_quality = $config -> __get('thumbnail_quality'); } } ?> classes/Item.php0000755000000000000000000021100214576073424011023 0ustar * @version 1.0.1 (July 03, 2004) * @package AutoIndex * @see DirItem, FileItem */ abstract class Item { /** * @var string */ protected $filename; /** * @var Size */ protected $size; /** * @var int Last modified time */ protected $m_time; protected $last_write_time; /** * @var int Last accessed time */ protected $a_time; /** * @var int */ protected $downloads; /** * @var string */ protected $description; /** * @var string The HTML text of the link to the type icon */ protected $icon; /** * @var string The HTML text of the "[New]" icon */ protected $new_icon; /** * @var string The HTML text of the link to this file or folder */ protected $link; /** * @var string The HTML text of the link to the thumbnail picture */ protected $thumb_link; /** * @var string The HTML text of the link to find the md5sum */ protected $md5_link; /** * @var string The name and path of the parent directory */ protected $parent_dir; /** * @var bool True if this is a link to '../' */ protected $is_parent_dir; /** * @param int $timestamp Time in UNIX timestamp format * @return string Formatted version of $timestamp */ private static function format_date($timestamp) { if ($timestamp === false) { return ' '; } return date(DATE_FORMAT, $timestamp); } /** * @return string Date modified (m_time) formatted as a string * @see Item::format_date() */ public function format_m_time() { return self::format_date($this -> m_time); } /** * @return string Date last accessed (a_time) formatted as a string * @see Item::format_date() */ public function format_a_time() { return self::format_date($this -> a_time); } /** * Returns everything after the slash, or the original string if there is * no slash. A slash at the last character of the string is ignored. * * @param string $fn The file or folder name * @return string The basename of $fn * @see basename() */ public static function get_basename($fn) { return basename(str_replace('\\', '/', $fn)); } /** * @param string $path The directory name * @return string If there is no slash at the end of $path, one will be added */ public static function make_sure_slash($path) { $path = str_replace('\\', '/', $path); if (!preg_match('#/$#', $path)) { $path .= '/'; } return $path; } /** * @param string $parent_dir * @param string $filename */ public function __construct($parent_dir, $filename) { $parent_dir = self::make_sure_slash($parent_dir); $full_name = $parent_dir . $filename; $this->is_parent_dir = false; $this->m_time = filemtime($full_name); $this->a_time = fileatime($full_name); //$this->creation_time = date('y-m-d h:i:s', filectime($full_name)); $this->last_write_time = date('h:i:s', filemtime($full_name)); $this->icon = $this->new_icon = $this->md5_link = $this->thumb_link = ''; global $descriptions, $words; $description = ((DESCRIPTION_FILE && $descriptions->is_set($full_name)) ? $descriptions->__get($full_name) : strtoupper(substr($filename, 0, strrpos($filename, '.')))); $extend_description = (($words->is_set('CHAP') && $words->is_set(strtoupper(substr($description, 0, strrpos($description, '_'))))) ? $words->__get(strtoupper(substr($description, 0, strrpos($description, '_')))) . ' ' . $words -> __get('CHAP') . ' ' . substr(strrchr($description, '_'), 1) : $description); $extend_description = ($words->is_set($extend_description) ? $words->__get($extend_description) : $extend_description); $this->description = ($words->is_set($description) ? $words->__get($description) : $extend_description); $this->parent_dir = $parent_dir; if (DAYS_NEW) { global $config; $days_new = $config->__get('days_new'); $age = (time() - $this->m_time) / 86400; $age_r = round($age, 1); $s = (($age_r == 1) ? '' : 's'); $this->description = ($age_r <= 1) ? $this->description . ' @ ' . $this->last_write_time : $this->description; $this->new_icon = (($days_new > 0 && $age <= $days_new) ? (ICON_PATH ? ' ' . ' : ' [New]') : ''); } } /** * function decode_lang from mx_traslator phpBB3 Extension * * $mx_user_lang = decode_country_name($lang['USER_LANG'], 'country'); * * @param unknown_type $file_dir * @param unknown_type $lang_country = 'country' or 'language' * @param array $langs_countries * @return unknown */ private function decode_country_name($file_dir, $lang_country = 'country', $langs_countries = false) { /* known languages */ switch ($file_dir) { case 'aa': $lang_name = 'AFAR'; $country_name = 'AFAR'; //Ethiopia break; case 'aae': $lang_name = 'AFRICAN-AMERICAN_ENGLISH'; $country_name = 'UNITED_STATES'; break; case 'ab': $lang_name = 'ABKHAZIAN'; $country_name = 'ABKHAZIA'; break; case 'ad': $lang_name = 'ANGOLA'; $country_name = 'ANGOLA'; break; case 'ae': $lang_name = 'AVESTAN'; $country_name = 'UNITED_ARAB_EMIRATES'; //Persia break; case 'af': $country_name = 'AFGHANISTAN'; // langs: pashto and dari $lang_name = 'AFRIKAANS'; // speakers: 6,855,082 - 13,4% break; case 'ag': $lang_name = 'ENGLISH-CREOLE'; $country_name = 'ANTIGUA_&_BARBUDA'; break; case 'ai': $lang_name = 'Anguilla'; $country_name = 'ANGUILLA'; break; case 'aj': case 'rup': $lang_name = 'AROMANIAN'; $country_name = 'BALCANS'; //$country_name = 'Aromaya'; break; case 'ak': $lang_name = 'AKAN'; $country_name = ''; break; case 'al': $lang_name = 'ALBANIAN'; $country_name = 'ALBANIA'; break; case 'am': $lang_name = 'AMHARIC'; //$lang_name = 'armenian'; $country_name = 'ARMENIA'; break; case 'an': $lang_name = 'ARAGONESE'; // //$country_name = 'Andorra'; $country_name = 'NETHERLAND_ANTILLES'; break; case 'ao': $lang_name = 'ANGOLIAN'; $country_name = 'ANGOLA'; break; case 'ap': $lang_name = 'ANGIKA'; $country_name = 'ANGA'; //India break; case 'ar': $lang_name = 'ARABIC'; $country_name = 'ARGENTINA'; break; case 'arq': $lang_name = 'ALGERIAN_ARABIC'; //known as Darja or Dziria in Algeria $country_name = 'ALGERIA'; break; case 'arc': $country_name = 'ASHURIA'; $lang_name = 'ARAMEIC'; break; case 'ary': $lang_name = 'MOROCCAN_ARABIC'; //known as Moroccan Arabic or Moroccan Darija or Algerian Saharan Arabic $country_name = 'MOROCCO'; break; //jrb – Judeo-Arabic //yhd – Judeo-Iraqi Arabic //aju – Judeo-Moroccan Arabic //yud – Judeo-Tripolitanian Arabic //ajt – Judeo-Tunisian Arabic //jye – Judeo-Yemeni Arabic case 'jrb': $lang_name = 'JUDEO-ARABIC'; $country_name = 'JUDEA'; break; case 'kab': $lang_name = 'KABYLE'; //known as Kabyle (Tamazight) $country_name = 'ALGERIA'; break; case 'aq': $lang_name = ''; $country_name = 'ANTARCTICA'; break; case 'as': $lang_name = 'ASSAMESE'; $country_name = 'AMERICAN_SAMOA'; break; case 'at': $lang_name = 'GERMAN'; $country_name = 'AUSTRIA'; break; case 'av': $lang_name = 'AVARIC'; $country_name = ''; break; case 'av-da': case 'av_da': case 'av_DA': $lang_name = 'AVARIAN_KHANATE'; $country_name = 'Daghestanian'; break; case 'ay': $lang_name = 'AYMARA'; $country_name = ''; break; case 'aw': $lang_name = 'ARUBA'; $country_name = 'ARUBA'; break; case 'au': $lang_name = 'en-au'; // $country_name = 'AUSTRALIA'; break; case 'az': $lang_name = 'AZERBAIJANI'; $country_name = 'AZERBAIJAN'; break; case 'ax': $lang_name = 'FINNISH'; $country_name = 'ALAND_ISLANDS'; //The Aland Islands or Aland (Swedish: Aland, IPA: ['o?land]; Finnish: Ahvenanmaa) is an archipelago province at the entrance to the Gulf of Bothnia in the Baltic Sea belonging to Finland. break; case 'ba': $lang_name = 'BASHKIR'; //Baskortostán (Rusia) $country_name = 'BOSNIA_&_HERZEGOVINA'; //Bosnian, Croatian, Serbian break; //Bavarian (also known as Bavarian Austrian or Austro-Bavarian; Boarisch ['b??r??] or Bairisch; //German: Bairisch ['ba????] (About this soundlisten); Hungarian: bajor. case 'bar': $lang_name = 'BAVARIAN'; $country_name = 'BAVARIA'; //Germany break; case 'bb': $lang_name = 'Barbados'; $country_name = 'BARBADOS'; break; case 'bd': $lang_name = 'Bangladesh'; $country_name = 'BANGLADESH'; break; case 'be': $lang_name = 'BELARUSIAN'; $country_name = 'BELGIUM'; break; case 'bf': $lang_name = 'Burkina Faso'; $country_name = 'BURKINA_FASO'; break; case 'bg': $lang_name = 'BULGARIAN'; $country_name = 'BULGARIA'; break; case 'bh': $lang_name = 'BHOJPURI'; // Bihar (India) $country_name = 'BAHRAIN'; // Mamlakat al-Ba?rayn (arabic) break; case 'bi': $lang_name = 'BISLAMA'; $country_name = 'BURUNDI'; break; case 'bj': $lang_name = 'BENIN'; $country_name = 'BENIN'; break; case 'bl': $lang_name = 'BONAIRE'; $country_name = 'BONAIRE'; break; case 'bm': $lang_name = 'BAMBARA'; $country_name = 'Bermuda'; break; case 'bn': $country_name = 'BRUNEI'; $lang_name = 'BENGALI'; break; case 'bo': $lang_name = 'TIBETAN'; $country_name = 'BOLIVIA'; break; case 'br': $lang_name = 'BRETON'; $country_name = 'BRAZIL'; //pt break; case 'bs': $lang_name = 'BOSNIAN'; $country_name = 'BAHAMAS'; break; case 'bt': $lang_name = 'Bhutan'; $country_name = 'Bhutan'; break; case 'bw': $lang_name = 'Botswana'; $country_name = 'BOTSWANA'; break; case 'bz': $lang_name = 'BELIZE'; $country_name = 'BELIZE'; break; case 'by': $lang_name = 'BELARUSIAN'; $country_name = 'Belarus'; break; case 'en-CM': case 'en_cm': $lang_name = 'CAMEROONIAN_PIDGIN_ENGLISH'; $country_name = 'Cameroon'; break; case 'wes': $lang_name = 'CAMEROONIAN'; //Kamtok $country_name = 'CAMEROON'; //Wes Cos break; case 'cm': $lang_name = 'CAMEROON'; $country_name = 'CAMEROON'; break; case 'ca': $lang_name = 'CATALAN'; $country_name = 'CANADA'; break; case 'cc': $lang_name = 'COA_A_COCOS'; //COA A Cocos dialect of Betawi Malay [ente (you) and ane (me)] and AU-English $country_name = 'COCOS_ISLANDS'; //CC Cocos (Keeling) Islands break; case 'cd': $lang_name = 'Congo Democratic Republic'; $country_name = 'CONGO_DEMOCRATIC_REPUBLIC'; break; //??????? ???? case 'ce': $lang_name = 'CHECHEN'; $country_name = 'Chechenya'; break; case 'cf': $lang_name = 'Central African Republic'; $country_name = 'CENTRAL_AFRICAN_REPUBLIC'; break; case 'cg': $lang_name = 'CONGO'; $country_name = 'CONGO'; break; case 'ch': $lang_name = 'CHAMORRO'; //Finu' Chamoru $country_name = 'SWITZERLAND'; break; case 'ci': $lang_name = 'Cote D-Ivoire'; $country_name = 'COTE_D-IVOIRE'; break; case 'ck': $lang_name = ''; $country_name = 'COOK_ISLANDS'; //CK Cook Islands break; case 'cl': $lang_name = 'Chile'; $country_name = 'CHILE'; break; case 'cn': //Chinese Macrolanguage case 'zh': //639-1: zh case 'chi': //639-2/B: chi case 'zho': //639-2/T and 639-3: zho $lang_name = 'CHINESE'; $country_name = 'CHINA'; break; //Chinese Individual Languages // ?? // Fujian Province, Republic of China case 'cn-fj': // ??? case 'cdo': //Chinese Min Dong $lang_name = 'CHINESE_DONG'; $country_name = 'CHINA'; break; //1. Bingzhou spoken in central Shanxi (the ancient Bing Province), including Taiyuan. //2. Lüliang spoken in western Shanxi (including Lüliang) and northern Shaanxi. //3. Shangdang spoken in the area of Changzhi (ancient Shangdang) in southeastern Shanxi. //4. Wutai spoken in parts of northern Shanxi (including Wutai County) and central Inner Mongolia. //5. Da–Bao spoken in parts of northern Shanxi and central Inner Mongolia, including Baotou. //6. Zhang-Hu spoken in Zhangjiakou in northwestern Hebei and parts of central Inner Mongolia, including Hohhot. //7. Han-Xin spoken in southeastern Shanxi, southern Hebei (including Handan) and northern Henan (including Xinxiang). //8. Zhi-Yan spoken in Zhidan County and Yanchuan County in northern Shaanxi. // ?? / ?? case 'cjy': //Chinese Jinyu ? $lang_name = 'CHINA_JINYU'; $country_name = 'CHINA'; break; // Cantonese is spoken in Hong Kong // ?? case 'cmn': //Chinese Mandarin ??? (Pu tong hua) literally translates into “common tongue.” $lang_name = 'CHINESE_MANDARIN'; $country_name = 'CHINA'; break; // Mandarin is spoken in Mainland China and Taiwan // ?? / ?? //semantic shift has occurred in Min or the rest of Chinese: //*tia?B ? "wok". The Min form preserves the original meaning "cooking pot". //*dzh?nA "rice field". scholars identify the Min word with chéng ? (MC zying) "raised path between fields", but Norman argues that it is cognate with céng ? (MC dzong) "additional layer or floor". //*tšhioC ? "house". the Min word is cognate with shu ? (MC syuH) "to guard". //*tshyiC ? "mouth". In Min this form has displaced the common Chinese term kou ?. It is believed to be cognate with hui ? (MC xjwojH) "beak, bill, snout; to pant". //Austroasiatic origin for some Min words: //*-d??A "shaman" compared with Vietnamese ð?ng (/?o?2/) "to shamanize, to communicate with spirits" and Mon do? "to dance (as if) under demonic possession". //*ki?nB ? "son" appears to be related to Vietnamese con (/k?n/) and Mon kon "child". // Southern Min: // Datian Min; // Hokkien ?; Hokkien-Taiwanese ????? - Philippine Hokkien ???. // Teochew; // Zhenan Min; // Zhongshan Min, etc. //Pu-Xian Min (Hinghwa); Putian dialect: Xianyou dialect. //Northern Min: Jian'ou dialect; Jianyang dialect; Chong'an dialect; Songxi dialect; Zhenghe dialect; //Shao-Jiang Min: Shaowu dialect, Jiangle dialect, Guangze dialect, Shunchang dialect; //http://www.shanxigov.cn/ //Central Min: Sanming dialect; Shaxian dialect; Yong'an dialect, //Leizhou Min : Leizhou Min. //Abbreviation //Simplified Chinese: ? //Traditional Chinese: ? //Literal meaning: Min [River] //?? case 'cpx': //Chinese Pu-Xian Min, Sing-iú-ua / ???, (Xianyou dialect) http://www.putian.gov.cn/ $lang_name = 'CHINESE_PU-XIAN'; $country_name = 'CHINA'; break; // ?? case 'czh': //Chinese HuiZhou ?? http://www.huizhou.gov.cn/ | Song dynasty $lang_name = 'CHINESE_HUIZHOU'; $country_name = 'CHINA'; break; // ?? case 'czo': //Chinese Min Zhong ??? | ??? http://zx.cq.gov.cn/ | Zhong-Xian | Zhong ?? $lang_name = 'CHINESE_ZHONG'; $country_name = 'CHINA'; break; // ??? SanMing: http://www.sm.gov.cn/ | Sha River (??) case 'dng': //Ding Chinese $lang_name = 'DING_CHINESE'; $country_name = 'CHINA'; break; // ?? case 'gan': //Gan Chinese $lang_name = 'GAN_CHINESE'; $country_name = 'CHINA'; break; // ??? case 'hak': //Chinese Hakka $lang_name = 'CHINESE_HAKKA'; $country_name = 'CHINA'; break; case 'hsn': //Xiang Chinese ??/?? $lang_name = 'XIANG_CHINESE'; $country_name = 'CHINA'; break; // ?? case 'lzh': //Literary Chinese $lang_name = 'LITERARY_CHINESE'; $country_name = 'CHINA'; break; // ??? case 'mnp': //Min Bei Chinese $lang_name = 'MIN_BEI_CHINESE'; $country_name = 'CHINA'; break; // ??? case 'nan': //Min Nan Chinese $lang_name = 'MIN_NAN_CHINESE'; $country_name = 'CHINA'; break; // ?? case 'wuu': //Wu Chinese $lang_name = 'WU_CHINESE'; $country_name = 'CHINA'; break; // ?? case 'yue': //Yue or Cartonese Chinese $lang_name = 'YUE_CHINESE'; $country_name = 'CHINA'; break; case 'co': $lang_name = 'CORSICAN'; // Corsica $country_name = 'COLUMBIA'; break; //Eeyou Istchee ?? case 'cr': $lang_name = 'CREE'; $country_name = 'COSTA_RICA'; break; case 'cs': $lang_name = 'CZECH'; $country_name = 'CZECH_REPUBLIC'; break; case 'cu': $lang_name = 'SLAVONIC'; $country_name = 'CUBA'; //langs: break; case 'cv': $country_name = 'CAPE_VERDE'; $lang_name = 'CHUVASH'; break; case 'cx': $lang_name = ''; // Malaysian Chinese origin and European Australians $country_name = 'CHRISTMAS_ISLAND'; break; case 'cy': $lang_name = 'CYPRUS'; $country_name = 'CYPRUS'; break; case 'cz': $lang_name = 'CZECH'; $country_name = 'CZECH_REPUBLIC'; break; case 'cw': $lang_name = 'PAPIAMENTU'; // Papiamentu (Portuguese-based Creole), Dutch, English $country_name = 'CURAÇAO'; // Ilha da Curaçao (Island of Healing) break; case 'da': $lang_name = 'DANISH'; $country_name = 'DENMARK'; break; //Geman (Deutsch) /* deu – German gmh – Middle High German goh – Old High German gct – Colonia Tovar German bar – Bavarian cim – Cimbrian geh – Hutterite German ksh – Kölsch nds – Low German sli – Lower Silesian ltz – Luxembourgish vmf – Mainfränkisch mhn – Mocheno pfl – Palatinate German pdc – Pennsylvania German pdt – Plautdietsch swg – Swabian German gsw – Swiss German uln – Unserdeutsch sxu – Upper Saxon wae – Walser German wep – Westphalian hrx – Riograndenser Hunsrückisch yec – Yenish */ //Germany 84,900,000 75,101,421 (91.8%) 5,600,000 (6.9%) De facto sole nationwide official language case 'de': case 'de-DE': case 'de_de': case 'deu': $lang_name = 'GERMAN'; $country_name = 'GERMANY'; break; //Belgium 11,420,163 73,000 (0.6%) 2,472,746 (22%) De jure official language in the German speaking community case 'de_be': case 'de-BE': $lang_name = 'BELGIUM_GERMAN'; $country_name = 'BELGIUM'; break; //Austria 8,838,171 8,040,960 (93%) 516,000 (6%) De jure sole nationwide official language case 'de_at': case 'de-AT': $lang_name = 'AUSTRIAN_GERMAN'; $country_name = 'AUSTRIA'; break; // Switzerland 8,508,904 5,329,393 (64.6%) 395,000 (5%) Co-official language at federal level; de jure sole official language in 17, co-official in 4 cantons (out of 26) case 'de_sw': case 'de-SW': $lang_name = 'SWISS_GERMAN'; $country_name = 'SWITZERLAND'; break; //Luxembourg 602,000 11,000 (2%) 380,000 (67.5%) De jure nationwide co-official language case 'de_lu': case 'de-LU': case 'ltz': $lang_name = 'LUXEMBOURG_GERMAN'; $country_name = 'LUXEMBOURG'; break; //Liechtenstein 37,370 32,075 (85.8%) 5,200 (13.9%) De jure sole nationwide official language //Alemannic, or rarely Alemmanish case 'de_li': case 'de-LI': $lang_name = 'LIECHTENSTEIN_GERMAN'; $country_name = 'LIECHTENSTEIN'; break; case 'gsw': $lang_name = 'Alemannic_German'; $country_name = 'SWITZERLAND'; break; //mostly spoken on Lifou Island, Loyalty Islands, New Caledonia. case 'dhv': $lang_name = 'DREHU'; $country_name = 'NEW_CALEDONIA'; break; case 'pdc': //Pennsilfaanisch-Deitsche $lang_name = 'PENNSYLVANIA_DUTCH'; $country_name = 'PENNSYLVANIA'; break; case 'dk': $lang_name = 'DANISH'; $country_name = 'DENMARK'; break; //acf – Saint Lucian / Dominican Creole French case 'acf': $lang_name = 'DOMINICAN_CREOLE_FRENCH'; //ROSEAU $country_name = 'DOMINICA'; break; case 'en_dm': case 'en-DM': $lang_name = 'DOMINICA_ENGLISH'; $country_name = 'DOMINICA'; break; case 'do': case 'en_do': case 'en-DO': $lang_name = 'SPANISH'; //Santo Domingo $country_name = 'DOMINICAN_REPUBLIC'; break; case 'dj': case 'aa-DJ': case 'aa_dj': $lang_name = 'DJIBOUTI'; //Yibuti, Afar $country_name = 'REPUBLIC_OF_DJIBOUTI'; //République de Djibouti break; case 'dv': $lang_name = 'DIVEHI'; //Maldivian $country_name = 'MALDIVIA'; break; //Berbera Taghelmustã (limba oamenilor alba?tri), zisã ?i Tuaregã, este vorbitã în Sahara occidentalã. //Berbera Tamazigtã este vorbitã în masivul Atlas din Maroc, la sud de ora?ul Meknes. //Berbera Zenaticã zisã ?i Rifanã, este vorbitã în masivul Rif din Maroc, în nord-estul ?ãrii. //Berbera ?enuanã zisã ?i Telicã, este vorbitã în masivul Tell din Algeria, în nordul ?ãrii. //Berbera Cabilicã este vorbitã în jurul masivelor Mitigea ?i Ores din Algeria, în nordul ?ãrii. //Berbera ?auianã este vorbitã în jurul ora?ului Batna din Algeria. //Berbera Tahelhitã, zisã ?i ?lãnuanã (în limba francezã Chleuh) este vorbitã în jurul masivului Tubkal din Maroc, în sud-vestul ?ãrii. //Berbera Tama?ekã, zisã ?i Saharianã, este vorbitã în Sahara de nord, în Algeria, Libia ?i Egipt. //Berber: Tacawit (@ city Batna from Chaoui, Algery), Shawiya (Shauian) case 'shy': $lang_name = 'SHAWIYA_BERBER'; $country_name = 'ALGERIA'; break; case 'dz': $lang_name = 'DZONGKHA'; $country_name = 'ALGERIA'; //http://www.el-mouradia.dz/ break; case 'ec': $country_name = 'ECUADOR'; $lang_name = 'ECUADOR'; break; case 'eg': $country_name = 'EGYPT'; $lang_name = 'EGYPT'; break; case 'eh': $lang_name = 'WESTERN_SAHARA'; $country_name = 'WESTERN_SAHARA'; break; case 'ee': //K?si?agbe (Sunday) //Dzo?agbe (Monday) //Bra?agbe, Bla?agbe (Tuesday) //Ku?agbe (Wednesday) //Yawo?agbe (Thursday) //Fi?agbe (Friday) //Memli?agbe (Saturday) $lang_name = 'EWE'; //E?egbe Native to Ghana, Togo $country_name = 'ESTONIA'; break; //Greek Language: //ell – Modern Greek //grc – Ancient Greek //cpg – Cappadocian Greek //gmy – Mycenaean Greek //pnt – Pontic //tsd – Tsakonian //yej – Yevanic case 'el': $lang_name = 'GREEK'; $country_name = 'GREECE'; break; case 'cpg': $lang_name = 'CAPPADOCIAN_GREEK'; $country_name = 'GREECE'; break; case 'gmy': $lang_name = 'MYCENAEAN_GREEK'; $country_name = 'GREECE'; break; case 'pnt': $lang_name = 'PONTIC'; $country_name = 'GREECE'; break; case 'tsd': $lang_name = 'TSAKONIAN'; $country_name = 'GREECE'; break; //Albanian: Janina or Janinë, Aromanian: Ianina, Enina, Turkish: Yanya; case 'yej': $lang_name = 'YEVANIC'; $country_name = 'GREECE'; break; case 'en_uk': case 'en-UK': case 'uk': $lang_name = 'BRITISH_ENGLISH'; //used in United Kingdom $country_name = 'GREAT_BRITAIN'; break; case 'en_fj': case 'en-FJ': $lang_name = 'FIJIAN_ENGLISH'; $country_name = 'FIJI'; break; case 'GibE': case 'en_gb': case 'en-GB': case 'gb': $lang_name = 'GIBRALTARIAN _ENGLISH'; //used in Gibraltar $country_name = 'GIBRALTAR'; break; case 'en_us': case 'en-US': $lang_name = 'AMERICAN_ENGLISH'; $country_name = 'UNITED_STATES_OF_AMERICA'; break; case 'en_ie': case 'en-IE': case 'USEng': $lang_name = 'HIBERNO_ENGLISH'; //Irish English $country_name = 'IRELAND'; break; case 'en_il': case 'en-IL': case 'ILEng': case 'heblish': case 'engbrew': $lang_name = 'ISRAELY_ENGLISH'; $country_name = 'ISRAEL'; break; case 'en_ca': case 'en-CA': case 'CanE': $lang_name = 'CANADIAN_ENGLISH'; $country_name = 'CANADA'; break; case 'en_ck': $lang_name = 'COOK_ISLANDS_ENGLISH'; $country_name = 'COOK_ISLANDS'; //CK Cook Islands break; case 'en_in': case 'en-IN': $lang_name = 'INDIAN_ENGLISH'; $country_name = 'REPUBLIC_OF_INDIA'; break; case 'en_ai': case 'en-AI': $lang_name = 'ANGUILLAN_ENGLISH'; $country_name = 'ANGUILLA'; break; case 'en_au': case 'en-AU': case 'AuE': $lang_name = 'AUSTRALIAN_ENGLISH'; $country_name = 'AUSTRALIA'; break; case 'en_nz': case 'en-NZ': case 'NZE': $lang_name = 'NEW_ZEALAND_ENGLISH'; $country_name = 'NEW_ZEALAND'; break; //New England English case 'en_ne': $lang_name = 'NEW_ENGLAND_ENGLISH'; $country_name = 'NEW_ENGLAND'; break; // case 'en_bm': $lang_name = 'BERMUDIAN ENGLISH.'; $country_name = 'BERMUDA'; break; case 'en_nu': $lang_name = 'NIUEAN_ENGLISH'; //Niuean (official) 46% (a Polynesian language closely related to Tongan and Samoan) $country_name = 'NIUE'; // Niuean: Niue break; case 'en_ms': $lang_name = 'MONTSERRAT_ENGLISH'; $country_name = 'MONTSERRAT'; break; case 'en_pn': $lang_name = 'PITCAIRN_ISLAND_ENGLISH'; $country_name = 'PITCAIRN_ISLAND'; break; case 'en_sh': $lang_name = 'ST_HELENA_ENGLISH'; $country_name = 'ST_HELENA'; break; case 'en_tc': $lang_name = 'TURKS_&_CAICOS_IS_ENGLISH'; $country_name = 'TURKS_&_CAICOS_IS'; break; case 'en_vg': $lang_name = 'VIRGIN_ISLANDS_ENGLISH'; $country_name = 'VIRGIN_ISLANDS_(BRIT)'; break; case 'eo': $lang_name = 'ESPERANTO'; //created in the late 19th century by L. L. Zamenhof, a Polish-Jewish ophthalmologist. In 1887 $country_name = 'EUROPE'; break; case 'er': $lang_name = 'ERITREA'; $country_name = 'ERITREA'; break; //See: // http://www.webapps-online.com/online-tools/languages-and-locales // https://www.ibm.com/support/knowledgecenter/ko/SSS28S_3.0.0/com.ibm.help.forms.doc/locale_spec/i_xfdl_r_locale_quick_reference.html case 'es': //Spanish Main $lang_name = 'SPANISH'; $country_name = 'SPAIN'; break; case 'es_MX': case 'es_mx': //Spanish (Mexico) (es-MX) $lang_name = 'SPANISH_MEXICO'; $country_name = 'MEXICO'; break; case 'es_US': case 'es_us': $lang_name = 'SPANISH_UNITED_STATES'; $country_name = 'UNITED_STATES'; break; case 'es_419': //Spanish Latin America and the Caribbean $lang_name = 'SPANISH_CARIBBEAN'; $country_name = 'CARIBBE'; break; case 'es_ar': // Spanish Argentina $lang_name = 'SPANISH_ARGENTINIAN'; $country_name = 'ARGENTINA'; break; case 'es_BO': case 'es_bo': $lang_name = 'SPANISH_BOLIVIAN'; $country_name = 'BOLIVIA'; break; case 'es_BR': case 'es_br': $lang_name = 'SPANISH_BRAZILIAN'; $country_name = 'BRAZIL'; break; case 'es_cl': // Spanish Chile $lang_name = 'SPANISH_CHILEAN'; $country_name = 'CHILE'; break; case 'es_CO': case 'es_co': case 'es-419': case 'es_419': // Spanish (Colombia) (es-CO) $lang_name = 'SPANISH_COLOMBIAN'; $country_name = 'COLOMBIA'; break; // Variety of es-419 Spanish Latin America and the Caribbean // Spanish language as spoken in // the Caribbean islands of Cuba, // Puerto Rico, and the Dominican Republic // as well as in Panama, Venezuela, // and the Caribbean coast of Colombia. case 'es-CU': case 'es-cu': case 'es_cu': // Spanish (Cuba) (es-CU) $lang_name = 'CUBAN_SPANISH'; $country_name = 'CUBA'; break; case 'es_CR': case 'es_cr': $lang_name = 'SPANISH_COSTA_RICA'; $country_name = 'COSTA_RICA'; break; case 'es_DO': case 'es_do': //Spanish (Dominican Republic) (es-DO) $lang_name = 'SPANISH_DOMINICAN_REPUBLIC'; $country_name = 'DOMINICAN_REPUBLIC'; break; case 'es_ec': // Spanish (Ecuador) (es-EC) $lang_name = 'SPANISH'; $country_name = 'SPAIN'; break; case 'es_es': case 'es_ES': // Spanish Spain $lang_name = 'SPANISH'; $country_name = 'SPAIN'; break; case 'es_ES_tradnl': case 'es_es_tradnl': $lang_name = 'SPANISH_NL'; $country_name = 'NL'; break; case 'es_EU': case 'es_eu': $lang_name = 'SPANISH_EUROPE'; $country_name = 'EUROPE'; break; case 'es_gt': case 'es_GT': // Spanish (Guatemala) (es-GT) $lang_name = 'SPANISH'; $country_name = 'SPAIN'; break; case 'es_HN': case 'es_hn': //Spanish (Honduras) (es-HN) $lang_name = 'SPANISH'; $country_name = 'SPAIN'; break; case 'es_la': case 'es_LA': // Spanish Lao $lang_name = 'SPANISH'; $country_name = 'SPAIN'; break; case 'es_NI': case 'es_ni': // Spanish (Nicaragua) (es-NI) $lang_name = 'SPANISH_NICARAGUAN'; $country_name = 'NICARAGUA'; break; case 'es_PA': case 'es_pa': //Spanish (Panama) (es-PA) $lang_name = 'SPANISH_PANAMIAN'; $country_name = 'PANAMA'; break; case 'es_pe': case 'es_PE': //Spanish (Peru) (es-PE) $lang_name = 'SPANISH_PERU'; $country_name = 'PERU'; break; case 'es_PR': case 'es_pr': //Spanish (Puerto Rico) (es-PR) $lang_name = 'SPANISH_PUERTO_RICO'; $country_name = 'PUERTO_RICO'; break; case 'es_PY': case 'es_py': //Spanish (Paraguay) (es-PY) $lang_name = 'SPANISH_PARAGUAY'; $country_name = 'PARAGUAY'; break; case 'es_SV': case 'es_sv': //Spanish (El Salvador) (es-SV) $lang_name = 'SPANISH_EL_SALVADOR'; $country_name = 'EL_SALVADOR'; break; case 'es-US': case 'es-us': // Spanish (United States) (es-US) $lang_name = 'SPANISH_UNITED_STATES'; $country_name = 'UNITED_STATES'; break; //This dialect is often spoken with an intonation resembling that of the Neapolitan language of Southern Italy, but there are exceptions. case 'es_AR': case 'es_ar': //Spanish (Argentina) (es-AR) $lang_name = 'RIOPLATENSE_SPANISH_ARGENTINA'; $country_name = 'ARGENTINA'; break; case 'es_UY': case 'es_uy': //Spanish (Uruguay) (es-UY) $lang_name = 'SPANISH_URUGUAY'; $country_name = 'URUGUAY'; break; case 'es_ve': case 'es_VE': // Spanish (Venezuela) (es-VE) $lang_name = 'SPANISH_VENEZUELA'; $country_name = 'BOLIVARIAN_REPUBLIC_OF_VENEZUELA'; break; case 'es_xl': case 'es_XL': // Spanish Latin America $lang_name = 'SPANISH_LATIN_AMERICA'; $country_name = 'LATIN_AMERICA'; break; case 'et': $lang_name = 'ESTONIAN'; $country_name = 'ESTONIA'; break; case 'eu': $lang_name = 'BASQUE'; $country_name = ''; break; case 'fa': $lang_name = 'PERSIAN'; $country_name = ''; break; //for Fulah (also spelled Fula) the ISO 639-1 code is ff. //fub – Adamawa Fulfulde //fui – Bagirmi Fulfulde //fue – Borgu Fulfulde //fuq – Central-Eastern Niger Fulfulde //ffm – Maasina Fulfulde //fuv – Nigerian Fulfulde //fuc – Pulaar //fuf – Pular //fuh – Western Niger Fulfulde case 'fub': $lang_name = 'ADAMAWA_FULFULDE'; $country_name = ''; break; case 'fui': $lang_name = 'BAGIRMI_FULFULDE'; $country_name = ''; break; case 'fue': $lang_name = 'BORGU_FULFULDE'; $country_name = ''; break; case 'fuq': $lang_name = 'CENTRAL-EASTERN_NIGER_FULFULDE'; $country_name = ''; break; case 'ffm': $lang_name = 'MAASINA_FULFULDE'; $country_name = ''; break; case 'fuv': $lang_name = 'NIGERIAN_FULFULDE'; $country_name = ''; break; case 'fuc': $lang_name = 'PULAAR'; $country_name = 'SENEGAMBIA_CONFEDERATION'; //sn //gm break; case 'fuf': $lang_name = 'PULAR'; $country_name = ''; break; case 'fuh': $lang_name = 'WESTERN_NIGER_FULFULDE'; $country_name = ''; break; case 'ff': $lang_name = 'FULAH'; $country_name = ''; break; case 'fi': case 'fin': $lang_name = 'FINNISH'; $country_name = 'FINLAND'; break; case 'fkv': $lang_name = 'KVEN'; $country_name = 'NORWAY'; break; case 'fit': $lang_name = 'KVEN'; $country_name = 'SWEDEN'; break; case 'fj': $lang_name = 'FIJIAN'; $country_name = 'FIJI'; break; case 'fk': $lang_name = 'FALKLANDIAN'; $country_name = 'FALKLAND_ISLANDS'; break; case 'fm': $lang_name = 'MICRONESIA'; $country_name = 'MICRONESIA'; break; case 'fo': $lang_name = 'FAROESE'; $country_name = 'FAROE_ISLANDS'; break; //Metropolitan French (French: France Métropolitaine or la Métropole) case 'fr': case 'fr_me': $lang_name = 'FRENCH'; $country_name = 'FRANCE'; break; //Acadian French case 'fr_ac': $lang_name = 'ACADIAN_FRENCH'; $country_name = 'ACADIA'; break; case 'fr_dm': case 'fr-DM': $lang_name = 'DOMINICA_FRENCH'; $country_name = 'DOMINICA'; break; //al-dîzayir case 'fr_dz': $lang_name = 'ALGERIAN_FRENCH'; $country_name = 'ALGERIA'; break; //Aostan French (French: français valdôtain) //Seventy: septante[a] [s?p.t?~t] //Eighty: huitante[b] [?i.t?~t] //Ninety: nonante[c] [n?.n?~t] case 'fr_ao': $lang_name = 'AOSTAN_FRENCH'; $country_name = 'ITALY'; break; //Belgian French case 'fr_bl': $lang_name = 'BELGIAN_FRENCH'; $country_name = 'BELGIUM'; break; //Cambodian French - French Indochina case 'fr_cb': $lang_name = 'CAMBODIAN_FRENCH'; $country_name = 'CAMBODIA'; break; //Cajun French - Le Français Cajun - New Orleans case 'fr_cj': $lang_name = 'CAJUN_FRENCH'; $country_name = 'UNITED_STATES'; break; //Canadian French (French: Français Canadien) //Official language in Canada, New Brunswick, Northwest Territories, Nunavut, Quebec, Yukon, //Official language in United States, Maine (de facto), New Hampshire case 'fr_ca': case 'fr-CA': $lang_name = 'CANADIAN_FRENCH'; $country_name = 'CANADA'; break; //Guianese French case 'gcr': case 'fr_gu': $lang_name = 'GUIANESE_FRENCH'; $country_name = 'FRENCH_GUIANA'; break; //Guianese English case 'gyn': case 'en_gy': $lang_name = 'GUYANESE_CREOLE'; $country_name = 'ENGLISH_GUIANA'; break; //Haitian French case 'fr-HT': case 'fr_ht': $lang_name = 'HAITIAN_FRENCH'; $country_name = 'HAITI'; //UNITED_STATES break; //Haitian English case 'en-HT': case 'en_ht': $lang_name = 'HAITIAN_CREOLE'; $country_name = 'HAITI'; //UNITED_STATES break; //Indian French case 'fr_id': $lang_name = 'INDIAN_FRENCH'; $country_name = 'INDIA'; break; case 'en_id': $lang_name = 'INDIAN_ENGLISH'; $country_name = 'INDIA'; break; //Jersey Legal French - Anglo-Norman French case 'xno': case 'fr_je': $lang_name = 'JERSEY_LEGAL_FRENCH'; $country_name = 'UNITED_STATES'; break; case 'fr_kh': $lang_name = 'CAMBODIAN_FRENCH'; $country_name = 'CAMBODIA'; break; //Lao French case 'fr_la': $lang_name = 'LAO_FRENCH'; $country_name = 'LAOS'; break; //Louisiana French (French: Français de la Louisiane, Louisiana Creole: Françé la Lwizyan) case 'frc': case 'fr_lu': $lang_name = 'LOUISIANIAN_FRENCH'; $country_name = 'LOUISIANA'; break; //Louisiana Creole case 'lou': $lang_name = 'LOUISIANA_CREOLE'; $country_name = 'LOUISIANA'; break; //Meridional French (French: Français Méridional, also referred to as Francitan) case 'fr_mr': $lang_name = 'MERIDIONAL_FRENCH'; $country_name = 'OCCITANIA'; break; //Missouri French case 'fr_mi': $lang_name = 'MISSOURI_FRENCH'; $country_name = 'MISSOURI?'; break; //New Caledonian French vs New Caledonian Pidgin French case 'fr_nc': $lang_name = 'NEW_CALEDONIAN_FRENCH'; $country_name = 'NEW_CALEDONIA'; break; //Newfoundland French (French: Français Terre-Neuvien), case 'fr_nf': $lang_name = 'NEWFOUNDLAND_FRENCH'; $country_name = 'CANADA'; break; //New England French case 'fr_ne': $lang_name = 'NEW_ENGLAND_FRENCH'; $country_name = 'NEW_ENGLAND'; break; //Quebec French (French: français québécois; also known as Québécois French or simply Québécois) case 'fr_qb': $lang_name = 'QUEBEC_FRENCH'; $country_name = 'CANADA'; break; //Swiss French case 'fr_sw': $lang_name = 'SWISS_FRENCH'; $country_name = 'SWITZERLAND'; break; //French Southern and Antarctic Lands case 'fr_tf': case 'tf': $lang_name = 'FRENCH_SOUTHERN_TERRITORIES'; // $country_name = 'SOUTHERN_TERRITORIES'; //Terres australes françaises break; //Vietnamese French case 'fr_vt': $lang_name = 'VIETNAMESE_FRENCH'; $country_name = 'VIETNAM'; break; //West Indian French case 'fr_if': $lang_name = 'WEST_INDIAN_FRENCH'; $country_name = 'INDIA'; break; case 'fr_wf': $country_name = 'TERRITORY_OF_THE_WALLIS_AND_FUTUNA_ISLANDS'; $lang_name = 'WALLISIAN_FRENCH'; break; case 'fy': $lang_name = 'WESTERN_FRISIAN'; $country_name = 'FRYSK'; break; case 'ga': $lang_name = 'IRISH'; $country_name = 'GABON'; break; case 'GenAm': $lang_name = 'General American'; $country_name = 'UNITED_STATES'; break; //gcf – Guadeloupean Creole case 'gcf': $lang_name = 'GUADELOUPEAN_CREOLE_FRENCH'; $country_name = 'GUADELOUPE'; break; case 'gd': $lang_name = 'SCOTTISH'; $country_name = 'GRENADA'; break; case 'ge': $lang_name = 'GEORGIAN'; $country_name = 'GEORGIA'; break; case 'gi': $lang_name = 'LLANITO'; //Llanito or Yanito $country_name = 'GIBRALTAR'; break; case 'gg': $lang_name = 'GUERNESIAIS'; //English, Guernésiais, Sercquiais, Auregnais $country_name = 'GUERNSEY'; break; case 'gh': $lang_name = 'Ghana'; $country_name = 'GHANA'; break; case 'ell': $lang_name = 'MODERN_GREEK'; $country_name = 'GREECE'; break; case 'gr': case 'el_gr': case 'el-gr': case 'gre': $lang_name = 'MODERN_GREEK'; $country_name = 'GREECE'; break; case 'grc': $lang_name = 'ANCIENT_GREEK'; $country_name = 'GREECE'; break; //Galician is spoken by some 2.4 million people, mainly in Galicia, //an autonomous community located in northwestern Spain. case 'gl': $lang_name = 'GALICIAN'; //Galicia $country_name = 'GREENLAND'; break; case 'gm': $lang_name = 'Gambia'; $country_name = 'GAMBIA'; break; //grn is the ISO 639-3 language code for Guarani. Its ISO 639-1 code is gn. // nhd – Chiripá // gui – Eastern Bolivian Guaraní // gun – Mbyá Guaraní // gug – Paraguayan Guaraní // gnw – Western Bolivian Guaraní case 'gn': $lang_name = 'GUARANI'; $country_name = 'GUINEA'; break; //Nhandéva is also known as Chiripá. //The Spanish spelling, Nandeva, is used in the Paraguayan Chaco // to refer to the local variety of Eastern Bolivian, a subdialect of Avá. case 'nhd': $lang_name = 'Chiripa'; $country_name = 'PARAGUAY'; break; case 'gui': $lang_name = 'EASTERN_BOLIVIAN_GUARANI'; $country_name = 'BOLIVIA'; break; case 'gun': $lang_name = 'MBYA_GUARANI'; $country_name = 'PARAGUAY'; break; case 'gug': $lang_name = 'PARAGUAYAN_GUARANI'; $country_name = 'PARAGUAY'; break; case 'gnw': $lang_name = 'WESTERN_BOLIVIAN_GUARANI'; $country_name = 'BOLIVIA'; break; case 'gs': $lang_name = 'ENGLISH'; $country_name = 'SOUTH_GEORGIA_AND_THE_SOUTH_SANDWICH_ISLANDS'; break; case 'gt': $lang_name = 'Guatemala'; $country_name = 'GUATEMALA'; break; case 'gq': $lang_name = 'Equatorial Guinea'; $country_name = 'EQUATORIAL_GUINEA'; break; case 'gu': $lang_name = 'GUJARATI'; $country_name = 'GUAM'; break; case 'gv': $lang_name = 'manx'; $country_name = ''; break; case 'gw': $lang_name = 'Guinea Bissau'; $country_name = 'GUINEA_BISSAU'; break; case 'gy': $lang_name = 'Guyana'; $country_name = 'GUYANA'; break; case 'ha': $country_name = ''; $lang_name = 'HAUSA'; break; //heb – Modern Hebrew //hbo – Classical Hebrew (liturgical) //smp – Samaritan Hebrew (liturgical) //obm – Moabite (extinct) //xdm – Edomite (extinct) case 'he': case 'heb': $country_name = 'ISRAEL'; $lang_name = 'HEBREW'; break; case 'hbo': $country_name = 'ISRAEL'; $lang_name = 'CLASSICAL_HEBREW'; break; case 'sam': $country_name = 'SAMARIA'; $lang_name = 'SAMARITAN_ARAMEIC'; break; case 'smp': $country_name = 'SAMARIA'; $lang_name = 'SAMARITAN_HEBREW'; break; case 'obm': $country_name = 'MOAB'; $lang_name = 'MOABITE'; break; case 'xdm': $country_name = 'EDOMITE'; $lang_name = 'EDOM'; break; case 'hi': $lang_name = 'hindi'; $country_name = ''; break; case 'ho': $lang_name = 'hiri_motu'; $country_name = ''; break; case 'hk': $lang_name = 'Hong Kong'; $country_name = 'HONG_KONG'; break; case 'hn': $country_name = 'Honduras'; $lang_name = 'HONDURAS'; break; case 'hr': $lang_name = 'croatian'; $country_name = 'CROATIA'; break; case 'ht': $lang_name = 'haitian'; $country_name = 'HAITI'; break; case 'ho': $lang_name = 'hiri_motu'; $country_name = ''; break; case 'hu': $lang_name = 'hungarian'; $country_name = 'HUNGARY'; break; case 'hy': case 'hy-am': $lang_name = 'ARMENIAN'; $country_name = ''; break; case 'hy-AT': case 'hy_at': $lang_name = 'ARMENIAN-ARTSAKH'; $country_name = 'REPUBLIC_OF_ARTSAKH'; break; case 'hz': $lang_name = 'HERERO'; $country_name = ''; break; case 'ia': $lang_name = 'INTERLINGUA'; $country_name = ''; break; case 'ic': $lang_name = ''; $country_name = 'CANARY_ISLANDS'; break; case 'id': $lang_name = 'INDONESIAN'; $country_name = 'INDONESIA'; break; case 'ie': $lang_name = 'interlingue'; $country_name = 'IRELAND'; break; case 'ig': $lang_name = 'igbo'; $country_name = ''; break; case 'ii': $lang_name = 'sichuan_yi'; $country_name = ''; break; case 'ik': $lang_name = 'inupiaq'; $country_name = ''; break; //Mostly spoken on Ouvéa Island or Uvea Island of the Loyalty Islands, New Caledonia. case 'iai': $lang_name = 'IAAI'; $country_name = 'NEW_CALEDONIA'; break; case 'il': $lang_name = 'ibrit'; $country_name = 'ISRAEL'; break; case 'im': $lang_name = 'Isle of Man'; $country_name = 'ISLE_OF_MAN'; break; case 'in': $lang_name = 'India'; $country_name = 'INDIA'; break; case 'ir': $lang_name = 'Iran'; $country_name = 'IRAN'; break; case 'is': $lang_name = 'Iceland'; $country_name = 'ICELAND'; break; case 'it': $lang_name = 'ITALIAN'; $country_name = 'ITALY'; break; case 'iq': $lang_name = 'Iraq'; $country_name = 'IRAQ'; break; case 'je': $lang_name = 'jerriais'; //Jerriais $country_name = 'JERSEY'; //Bailiwick of Jersey break; case 'jm': $lang_name = 'Jamaica'; $country_name = 'JAMAICA'; break; case 'jo': $lang_name = 'Jordan'; $country_name = 'JORDAN'; break; case 'jp': $lang_name = 'japanese'; $country_name = 'JAPAN'; break; case 'jv': $lang_name = 'javanese'; $country_name = ''; break; case 'kh': $lang_name = 'KH'; $country_name = 'CAMBODIA'; break; case 'ke': $lang_name = 'SWAHILI'; $country_name = 'KENYA'; break; case 'ki': $lang_name = 'Kiribati'; $country_name = 'KIRIBATI'; break; //Bantu languages //zdj – Ngazidja Comorian case 'zdj': $lang_name = 'Ngazidja Comorian'; $country_name = 'COMOROS'; break; //wni – Ndzwani Comorian (Anjouani) dialect case 'wni': $lang_name = 'Ndzwani Comorian'; $country_name = 'COMOROS'; break; //swb – Maore Comorian dialect case 'swb': $lang_name = 'Maore Comorian'; $country_name = 'COMOROS'; break; //wlc – Mwali Comorian dialect case 'wlc': $lang_name = 'Mwali Comorian'; $country_name = 'COMOROS'; break; case 'km': $lang_name = 'KHMER'; $country_name = 'COMOROS'; break; case 'kn': $lang_name = 'kannada'; $country_name = 'ST_KITTS-NEVIS'; break; case 'ko': case 'kp': $lang_name = 'korean'; // kor – Modern Korean // jje – Jeju // okm – Middle Korean // oko – Old Korean // oko – Proto Korean // okm Middle Korean // oko Old Korean $country_name = 'Korea North'; break; case 'kr': $lang_name = 'korean'; $country_name = 'KOREA_SOUTH'; break; case 'kn': $lang_name = 'St Kitts-Nevis'; $country_name = 'ST_KITTS-NEVIS'; break; case 'ks': $lang_name = 'kashmiri'; //Kashmir $country_name = 'KOREA_SOUTH'; break; case 'ky': $lang_name = 'Cayman Islands'; $country_name = 'CAYMAN_ISLANDS'; break; case 'kz': $lang_name = 'Kazakhstan'; $country_name = 'KAZAKHSTAN'; break; case 'kw': //endonim: Kernewek $lang_name = 'Cornish'; $country_name = 'KUWAIT'; break; case 'kg': $lang_name = 'Kyrgyzstan'; $country_name = 'KYRGYZSTAN'; break; case 'la': $lang_name = 'Laos'; $country_name = 'LAOS'; break; case 'lk': $lang_name = 'Sri Lanka'; $country_name = 'SRI_LANKA'; break; case 'lv': $lang_name = 'Latvia'; $country_name = 'LATVIA'; break; case 'lb': $lang_name = 'LUXEMBOURGISH'; $country_name = 'LEBANON'; break; case 'lc': $lang_name = 'St Lucia'; $country_name = 'ST_LUCIA'; break; case 'ls': $lang_name = 'Lesotho'; $country_name = 'LESOTHO'; break; case 'lo': $lang_name = 'LAO'; $country_name = 'LAOS'; break; case 'lr': $lang_name = 'Liberia'; $country_name = 'LIBERIA'; break; case 'ly': $lang_name = 'Libya'; $country_name = 'Libya'; break; case 'li': $lang_name = 'LIMBURGISH'; $country_name = 'LIECHTENSTEIN'; break; case 'lt': $country_name = 'Lithuania'; $lang_name = 'LITHUANIA'; break; case 'lu': $lang_name = 'LUXEMBOURGISH'; $country_name = 'LUXEMBOURG'; break; case 'ma': $lang_name = 'Morocco'; $country_name = 'MOROCCO'; break; case 'mc': $country_name = 'MONACO'; $lang_name = 'Monaco'; break; case 'md': $country_name = 'MOLDOVA'; $lang_name = 'romanian'; break; case 'me': $lang_name = 'MONTENEGRIN'; //Serbo-Croatian, Cyrillic, Latin $country_name = 'MONTENEGRO'; //???? ???? break; case 'mf': $lang_name = 'FRENCH'; // $country_name = 'SAINT_MARTIN_(FRENCH_PART)'; break; case 'mg': $lang_name = 'Madagascar'; $country_name = 'MADAGASCAR'; break; case 'mh': $lang_name = 'Marshall Islands'; $country_name = 'MARSHALL_ISLANDS'; break; case 'mi': $lang_name = 'MAORI'; $country_name = 'Maori'; break; //Mi'kmaq hieroglyphic writing was a writing system and memory aid used by the Mi'kmaq, //a First Nations people of the east coast of Canada, Mostly spoken in Nova Scotia and Newfoundland. case 'mic': $lang_name = 'MIKMAQ'; $country_name = 'CANADA'; break; case 'mk': $lang_name = 'Macedonia'; $country_name = 'MACEDONIA'; break; case 'mr': $lang_name = 'Mauritania'; $country_name = 'Mauritania'; break; case 'mu': $lang_name = 'Mauritius'; $country_name = 'MAURITIUS'; break; case 'mo': $lang_name = 'Macau'; $country_name = 'MACAU'; break; case 'mn': $lang_name = 'Mongolia'; $country_name = 'MONGOLIA'; break; case 'ms': $lang_name = 'Montserrat'; $country_name = 'MONTSERRAT'; break; case 'mz': $lang_name = 'Mozambique'; $country_name = 'MOZAMBIQUE'; break; case 'mm': $lang_name = 'Myanmar'; $country_name = 'MYANMAR'; break; case 'mp': $lang_name = 'chamorro'; //Carolinian $country_name = 'NORTHERN_MARIANA_ISLANDS'; break; case 'mw': $country_name = 'Malawi'; $lang_name = 'MALAWI'; break; case 'my': $lang_name = 'Myanmar'; $country_name = 'MALAYSIA'; break; case 'mv': $lang_name = 'Maldives'; $country_name = 'MALDIVES'; break; case 'ml': $lang_name = 'Mali'; $country_name = 'MALI'; break; case 'mt': $lang_name = 'Malta'; $country_name = 'MALTA'; break; case 'mx': $lang_name = 'Mexico'; $country_name = 'MEXICO'; break; case 'mq': $lang_name = 'antillean-creole'; // Antillean Creole (Créole Martiniquais) $country_name = 'MARTINIQUE'; break; case 'na': $lang_name = 'Nambia'; $country_name = 'NAMBIA'; break; case 'ni': $lang_name = 'Nicaragua'; $country_name = 'NICARAGUA'; break; //Barber: Targuí, tuareg case 'ne': $lang_name = 'Niger'; $country_name = 'NIGER'; break; //Mostly spoken on Maré Island of the Loyalty Islands, New Caledonia. case 'nen': $lang_name = 'NENGONE'; $country_name = 'NEW_CALEDONIA'; break; case 'new': $lang_name = 'NEW_LANGUAGE'; $country_name = 'NEW_COUNTRY'; break; case 'nc': $lang_name = 'paicî'; //French, Nengone, Paicî, Ajië, Drehu $country_name = 'NEW_CALEDONIA'; break; case 'nk': $lang_name = 'Korea North'; $country_name = 'KOREA_NORTH'; break; case 'ng': $lang_name = 'Nigeria'; $country_name = 'NIGERIA'; break; case 'nf': $lang_name = 'Norfolk Island'; $country_name = 'NORFOLK_ISLAND'; break; case 'nl': $lang_name = 'DUTCH'; //Netherlands, Flemish. $country_name = 'NETHERLANDS'; break; case 'no': $lang_name = 'Norway'; $country_name = 'NORWAY'; break; case 'np': $lang_name = 'Nepal'; $country_name = 'NEPAL'; break; case 'nr': $lang_name = 'Nauru'; $country_name = 'NAURU'; break; case 'niu': $lang_name = 'NIUEAN'; //Niuean (official) 46% (a Polynesian language closely related to Tongan and Samoan) $country_name = 'NIUE'; // Niuean: Niue break; case 'nu': $lang_name = 'NU'; //Niuean (official) 46% (a Polynesian language closely related to Tongan and Samoan) $country_name = 'NIUE'; // Niuean: Niue break; case 'nz': $lang_name = 'New Zealand'; $country_name = 'NEW_ZEALAND'; break; case 'ny': $lang_name = 'Chewa'; $country_name = 'Nyanja'; break; //langue d'oc case 'oc': $lang_name = 'OCCITAN'; $country_name = 'OCCITANIA'; break; case 'oj': $lang_name = 'ojibwa'; $country_name = ''; break; case 'om': $lang_name = 'Oman'; $country_name = 'OMAN'; break; case 'or': $lang_name = 'oriya'; $country_name = ''; break; case 'os': $lang_name = 'ossetian'; $country_name = ''; break; case 'pa': $country_name = 'Panama'; $lang_name = 'PANAMA'; break; case 'pe': $country_name = 'Peru'; $lang_name = 'PERU'; break; case 'ph': $lang_name = 'Philippines'; $country_name = 'PHILIPPINES'; break; case 'pf': $country_name = 'French Polynesia'; $lang_name = 'tahitian'; //Polynésie française break; case 'pg': $country_name = 'PAPUA_NEW_GUINEA'; $lang_name = 'Papua New Guinea'; break; case 'pi': $lang_name = 'pali'; $country_name = ''; break; case 'pl': $lang_name = 'Poland'; $country_name = 'POLAND'; break; case 'pn': $lang_name = 'Pitcairn Island'; $country_name = 'PITCAIRN_ISLAND'; break; case 'pr': $lang_name = 'Puerto Rico'; $country_name = 'PUERTO_RICO'; break; case 'pt': case 'pt_pt': $lang_name = 'PORTUGUESE'; $country_name = 'PORTUGAL'; break; case 'pt_br': $lang_name = 'PORTUGUESE_BRASIL'; $country_name = 'BRAZIL'; //pt break; case 'pk': $lang_name = 'Pakistan'; $country_name = 'PAKISTAN'; break; case 'pw': $country_name = 'Palau Island'; $lang_name = 'PALAU_ISLAND'; break; case 'ps': $country_name = 'Palestine'; $lang_name = 'PALESTINE'; break; case 'py': $country_name = 'PARAGUAY'; $lang_name = 'PARAGUAY'; break; case 'qa': $lang_name = 'Qatar'; $country_name = 'QATAR'; break; // rmn – Balkan Romani // rml – Baltic Romani // rmc – Carpathian Romani // rmf – Kalo Finnish Romani // rmo – Sinte Romani // rmy – Vlax Romani // rmw – Welsh Romani case 'ri': case 'rom': $country_name = 'EASTEN_EUROPE'; $lang_name = 'ROMANI'; break; case 'ro': $country_name = 'ROMANIA'; $lang_name = 'ROMANIAN'; break; case 'ro_md': case 'ro_MD': $country_name = 'ROMANIA'; $lang_name = 'ROMANIAN_MOLDAVIA'; break; case 'ro_ro': case 'ro_RO': $country_name = 'ROMANIA'; $lang_name = 'ROMANIAN_ROMANIA'; break; case 'rn': $lang_name = 'kirundi'; $country_name = ''; break; case 'rm': $country_name = ''; $lang_name = 'romansh'; //Switzerland break; case 'rs': $country_name = 'REPUBLIC_OF_SERBIA'; //????????? ?????? //Republika Srbija $lang_name = 'serbian'; //Serbia, ?????? / Srbija break; case 'ru': case 'ru_ru': case 'ru_RU': $country_name = 'RUSSIA'; $lang_name = 'RUSSIAN'; break; case 'rw': $country_name = 'RWANDA'; $lang_name = 'Rwanda'; break; case 'sa': $lang_name = 'arabic'; $country_name = 'SAUDI_ARABIA'; break; case 'sb': $lang_name = 'Solomon Islands'; $country_name = 'SOLOMON_ISLANDS'; break; case 'sc': $lang_name = 'seychellois-creole'; $country_name = 'SEYCHELLES'; break; case 'sco': $lang_name = 'SCOTISH'; $country_name = 'Scotland'; break; //scf – San Miguel Creole French (Panama) case 'scf': $lang_name = 'SAN_MIGUEL_CREOLE_FRENCH'; $country_name = 'SAN_MIGUEL'; break; case 'sd': $lang_name = 'Sudan'; $country_name = 'SUDAN'; break; case 'si': $lang_name = 'SLOVENIAN'; $country_name = 'SLOVENIA'; break; case 'sh': $lang_name = 'SH'; $country_name = 'ST_HELENA'; break; case 'sk': $country_name = 'SLOVAKIA'; $lang_name = 'Slovakia'; break; case 'sg': $country_name = 'SINGAPORE'; $lang_name = 'Singapore'; break; case 'sl': $country_name = 'SIERRA_LEONE'; $lang_name = 'Sierra Leone'; break; case 'sm': $lang_name = 'San Marino'; $country_name = 'SAN_MARINO'; break; case 'smi': $lang_name = 'Sami'; $country_name = 'Norway'; //Native to Finland, Norway, Russia, and Sweden break; case 'sn': $lang_name = 'Senegal'; $country_name = 'SENEGAL'; break; case 'so': $lang_name = 'Somalia'; $country_name = 'SOMALIA'; break; case 'sq': $lang_name = 'ALBANIAN'; $country_name = 'Albania'; break; case 'sr': $lang_name = 'Suriname'; $country_name = 'SURINAME'; break; case 'ss': $lang_name = ''; //Bari [Karo or Kutuk ('mother tongue', Beri)], Dinka, Luo, Murle, Nuer, Zande $country_name = 'REPUBLIC_OF_SOUTH_SUDAN'; break; case 'sse': $lang_name = 'STANDARD_SCOTTISH_ENGLISH'; $country_name = 'Scotland'; break; case 'st': $lang_name = 'Sao Tome & Principe'; $country_name = 'SAO_TOME_&_PRINCIPE'; break; case 'sv': $lang_name = 'El Salvador'; $country_name = 'EL_SALVADOR'; break; case 'sx': $lang_name = 'dutch'; $country_name = 'SINT_MAARTEN_(DUTCH_PART)'; break; case 'sz': $lang_name = 'Swaziland'; $country_name = 'SWAZILAND'; break; case 'se': case 'sv-SE': case 'sv-se': //Swedish (Sweden) (sv-SE) $lang_name = 'Sweden'; $country_name = 'SWEDEN'; break; case 'sy': $lang_name = 'SYRIAC'; //arabic syrian $country_name = 'SYRIA'; break; //ISO 639-2 swa //ISO 639-3 swa – inclusive code //Individual codes: //swc – Congo Swahili //swh – Coastal Swahili //ymk – Makwe //wmw – Mwani //Person Mswahili //People Waswahili //Language Kiswahili case 'sw': $lang_name = 'SWAHILI'; $country_name = 'KENYA'; break; case 'swa': $lang_name = 'SWAHILI'; $country_name = 'AFRICAN_GREAT_LAKES'; break; //swa – inclusive code // //Individual codes: //swc – Congo Swahili case 'swc': $lang_name = 'CONGO_SWAHILI'; $country_name = 'CONGO'; break; //swh – Coastal Swahili case 'swh': $lang_name = 'COASTAL_SWAHILI'; $country_name = 'AFRIKA_EAST_COAST'; break; //ymk – Makwe case 'ymk': $lang_name = 'MAKWE'; $country_name = 'CABO_DELGADO_PROVINCE_OF_MOZAMBIQUE'; break; //wmw – Mwani case 'wmw': $lang_name = 'MWANI'; $country_name = 'COAST_OF_CABO_DELGADO_PROVINCE_OF_MOZAMBIQUE'; break; case 'tc': $lang_name = 'Turks & Caicos Is'; $country_name = 'TURKS_&_CAICOS_IS'; break; case 'td': $lang_name = 'Chad'; $country_name = 'CHAD'; break; case 'tf': $lang_name = 'french '; // $country_name = 'FRENCH_SOUTHERN_TERRITORIES'; //Terres australes françaises break; case 'tj': $lang_name = 'Tajikistan'; $country_name = 'TAJIKISTAN'; break; case 'tg': $lang_name = 'Togo'; $country_name = 'TOGO'; break; case 'th': $country_name = 'Thailand'; $lang_name = 'THAILAND'; break; case 'tk': //260 speakers of Tokelauan, of whom 2,100 live in New Zealand, //1,400 in Tokelau, //and 17 in Swains Island $lang_name = 'Tokelauan'; // /to?k?'la??n/ Tokelauans or Polynesians $country_name = 'TOKELAUAU'; //Dependent territory of New Zealand break; case 'tl': $country_name = 'East Timor'; $lang_name = 'East Timor'; break; case 'to': $country_name = 'Tonga'; $lang_name = 'TONGA'; break; case 'tt': $country_name = 'Trinidad & Tobago'; $lang_name = 'TRINIDAD_&_TOBAGO'; break; case 'tn': $lang_name = 'Tunisia'; $country_name = 'TUNISIA'; break; case 'tm': $lang_name = 'Turkmenistan'; $country_name = 'TURKMENISTAN'; break; case 'tr': $lang_name = 'Turkey'; $country_name = 'TURKEY'; break; case 'tv': $lang_name = 'Tuvalu'; $country_name = 'TUVALU'; break; case 'tw': $lang_name = 'TAIWANESE_HOKKIEN'; //Taibei Hokkien $country_name = 'TAIWAN'; break; case 'tz': $country_name = 'TANZANIA'; $lang_name = 'Tanzania'; break; case 'ug': $lang_name = 'Uganda'; $country_name = 'UGANDA'; break; case 'ua': $lang_name = 'Ukraine'; $country_name = 'UKRAINE'; break; case 'us': $lang_name = 'en-us'; $country_name = 'UNITED_STATES_OF_AMERICA'; break; case 'uz': $lang_name = 'uzbek'; //Uyghur Perso-Arabic alphabet $country_name = 'UZBEKISTAN'; break; case 'uy': $lang_name = 'Uruguay'; $country_name = 'URUGUAY'; break; case 'va': $country_name = 'VATICAN_CITY'; //Holy See $lang_name = 'latin'; break; case 'vc': $country_name = 'ST_VINCENT_&_GRENADINES'; // $lang_name = 'vincentian-creole'; break; case 've': $lang_name = 'Venezuela'; $country_name = 'VENEZUELA'; break; case 'vi': $lang_name = 'Virgin Islands (USA)'; $country_name = 'VIRGIN_ISLANDS_(USA)'; break; case 'fr_vn': $lang_name = 'FRENCH_VIETNAM'; $country_name = 'VIETNAM'; break; case 'vn': $lang_name = 'Vietnam'; $country_name = 'VIETNAM'; break; case 'vg': $lang_name = 'Virgin Islands (Brit)'; $country_name = 'VIRGIN_ISLANDS_(BRIT)'; break; case 'vu': $lang_name = 'Vanuatu'; $country_name = 'VANUATU'; break; case 'wls': $lang_name = 'WALLISIAN'; $country_name = 'WALES'; break; case 'wf': $country_name = 'TERRITORY_OF_THE_WALLIS_AND_FUTUNA_ISLANDS'; $lang_name = 'WF'; //Wallisian, or ‘Uvean //Futunan - Austronesian, Malayo-Polynesian break; case 'ws': $country_name = 'SAMOA'; $lang_name = 'Samoa'; break; case 'ye': $lang_name = 'Yemen'; $country_name = 'YEMEN'; break; case 'yt': $lang_name = 'Mayotte'; //Shimaore: $country_name = 'DEPARTMENT_OF_MAYOTTE'; //Département de Mayotte break; case 'za': $lang_name = 'zhuang'; $country_name = 'SOUTH_AFRICA'; break; case 'zm': $lang_name = 'zambian'; $country_name = 'ZAMBIA'; break; case 'zw': $lang_name = 'Zimbabwe'; $country_name = 'ZIMBABWE'; break; case 'zu': $lang_name = 'zulu'; $country_name = 'ZULU'; break; default: $lang_name = $file_dir; $country_name = $file_dir; break; } $return = ($lang_country == 'country') ? $country_name : $lang_name; $return = ($langs_countries == true) ? $lang_name[$country_name] : $return; return $return ; } /** * @param string $var The key to look for * @return bool True if $var is set */ public function is_set($var) { return isset($this -> $var); } /** * @return string The file or folder name */ public function __toString() { return $this -> filename; } /** * @return string The file extension of the file or folder name */ abstract public function file_ext(); } ?> classes/Item.php30000755000000000000000000021075214520115122011076 0ustar * @version 1.0.1 (July 03, 2004) * @package AutoIndex * @see DirItem, FileItem */ abstract class Item { /** * @var string */ protected $filename; /** * @var Size */ protected $size; /** * @var int Last modified time */ protected $m_time; /** * @var int Last accessed time */ protected $a_time; /** * @var int */ protected $downloads; /** * @var string */ protected $description; /** * @var string The HTML text of the link to the type icon */ protected $icon; /** * @var string The HTML text of the "[New]" icon */ protected $new_icon; /** * @var string The HTML text of the link to this file or folder */ protected $link; /** * @var string The HTML text of the link to the thumbnail picture */ protected $thumb_link; /** * @var string The HTML text of the link to find the md5sum */ protected $md5_link; /** * @var string The name and path of the parent directory */ protected $parent_dir; /** * @var bool True if this is a link to '../' */ protected $is_parent_dir; /** * @param int $timestamp Time in UNIX timestamp format * @return string Formatted version of $timestamp */ private static function format_date($timestamp) { if ($timestamp === false) { return ' '; } return date(DATE_FORMAT, $timestamp); } /** * @return string Date modified (m_time) formatted as a string * @see Item::format_date() */ public function format_m_time() { return self::format_date($this -> m_time); } /** * @return string Date last accessed (a_time) formatted as a string * @see Item::format_date() */ public function format_a_time() { return self::format_date($this -> a_time); } /** * Returns everything after the slash, or the original string if there is * no slash. A slash at the last character of the string is ignored. * * @param string $fn The file or folder name * @return string The basename of $fn * @see basename() */ public static function get_basename($fn) { return basename(str_replace('\\', '/', $fn)); } /** * @param string $path The directory name * @return string If there is no slash at the end of $path, one will be added */ public static function make_sure_slash($path) { $path = str_replace('\\', '/', $path); if (!preg_match('#/$#', $path)) { $path .= '/'; } return $path; } /** * @param string $parent_dir * @param string $filename */ public function __construct($parent_dir, $filename) { $parent_dir = self::make_sure_slash($parent_dir); $full_name = $parent_dir . $filename; $this->is_parent_dir = false; $this->m_time = filemtime($full_name); $this->a_time = fileatime($full_name); //$this->creation_time = date('y-m-d h:i:s', filectime($full_name)); $this->last_write_time = date('h:i:s', filemtime($full_name)); $this->icon = $this->new_icon = $this->md5_link = $this->thumb_link = ''; global $descriptions, $words; $description = ((DESCRIPTION_FILE && $descriptions->is_set($full_name)) ? $descriptions->__get($full_name) : strtoupper(substr($filename, 0, strrpos($filename, '.')))); $extend_description = (($words->is_set('CHAP') && $words->is_set(strtoupper(substr($description, 0, strrpos($description, '_'))))) ? $words->__get(strtoupper(substr($description, 0, strrpos($description, '_')))) . ' ' . $words -> __get('CHAP') . ' ' . substr(strrchr($description, '_'), 1) : $description); $extend_description = ($words->is_set($extend_description) ? $words->__get($extend_description) : $extend_description); $this->description = ($words->is_set($description) ? $words->__get($description) : $extend_description); $this->parent_dir = $parent_dir; if (DAYS_NEW) { global $config; $days_new = $config->__get('days_new'); $age = (time() - $this->m_time) / 86400; $age_r = round($age, 1); $s = (($age_r == 1) ? '' : 's'); $this->description = ($age_r <= 1) ? $this->description . ' @ ' . $this->last_write_time : $this->description; $this->new_icon = (($days_new > 0 && $age <= $days_new) ? (ICON_PATH ? ' ' . ' : ' [New]') : ''); } } /** * function decode_lang from mx_traslator phpBB3 Extension * * $mx_user_lang = decode_country_name($lang['USER_LANG'], 'country'); * * @param unknown_type $file_dir * @param unknown_type $lang_country = 'country' or 'language' * @param array $langs_countries * @return unknown */ private function decode_country_name($file_dir, $lang_country = 'country', $langs_countries = false) { /* known languages */ switch ($file_dir) { case 'aa': $lang_name = 'AFAR'; $country_name = 'AFAR'; //Ethiopia break; case 'aae': $lang_name = 'AFRICAN-AMERICAN_ENGLISH'; $country_name = 'UNITED_STATES'; break; case 'ab': $lang_name = 'ABKHAZIAN'; $country_name = 'ABKHAZIA'; break; case 'ad': $lang_name = 'ANGOLA'; $country_name = 'ANGOLA'; break; case 'ae': $lang_name = 'AVESTAN'; $country_name = 'UNITED_ARAB_EMIRATES'; //Persia break; case 'af': $country_name = 'AFGHANISTAN'; // langs: pashto and dari $lang_name = 'AFRIKAANS'; // speakers: 6,855,082 - 13,4% break; case 'ag': $lang_name = 'ENGLISH-CREOLE'; $country_name = 'ANTIGUA_&_BARBUDA'; break; case 'ai': $lang_name = 'Anguilla'; $country_name = 'ANGUILLA'; break; case 'aj': case 'rup': $lang_name = 'AROMANIAN'; $country_name = 'BALCANS'; //$country_name = 'Aromaya'; break; case 'ak': $lang_name = 'AKAN'; $country_name = ''; break; case 'al': $lang_name = 'ALBANIAN'; $country_name = 'ALBANIA'; break; case 'am': $lang_name = 'AMHARIC'; //$lang_name = 'armenian'; $country_name = 'ARMENIA'; break; case 'an': $lang_name = 'ARAGONESE'; // //$country_name = 'Andorra'; $country_name = 'NETHERLAND_ANTILLES'; break; case 'ao': $lang_name = 'ANGOLIAN'; $country_name = 'ANGOLA'; break; case 'ap': $lang_name = 'ANGIKA'; $country_name = 'ANGA'; //India break; case 'ar': $lang_name = 'ARABIC'; $country_name = 'ARGENTINA'; break; case 'arq': $lang_name = 'ALGERIAN_ARABIC'; //known as Darja or Dziria in Algeria $country_name = 'ALGERIA'; break; case 'arc': $country_name = 'ASHURIA'; $lang_name = 'ARAMEIC'; break; case 'ary': $lang_name = 'MOROCCAN_ARABIC'; //known as Moroccan Arabic or Moroccan Darija or Algerian Saharan Arabic $country_name = 'MOROCCO'; break; //jrb – Judeo-Arabic //yhd – Judeo-Iraqi Arabic //aju – Judeo-Moroccan Arabic //yud – Judeo-Tripolitanian Arabic //ajt – Judeo-Tunisian Arabic //jye – Judeo-Yemeni Arabic case 'jrb': $lang_name = 'JUDEO-ARABIC'; $country_name = 'JUDEA'; break; case 'kab': $lang_name = 'KABYLE'; //known as Kabyle (Tamazight) $country_name = 'ALGERIA'; break; case 'aq': $lang_name = ''; $country_name = 'ANTARCTICA'; break; case 'as': $lang_name = 'ASSAMESE'; $country_name = 'AMERICAN_SAMOA'; break; case 'at': $lang_name = 'GERMAN'; $country_name = 'AUSTRIA'; break; case 'av': $lang_name = 'AVARIC'; $country_name = ''; break; case 'av-da': case 'av_da': case 'av_DA': $lang_name = 'AVARIAN_KHANATE'; $country_name = 'Daghestanian'; break; case 'ay': $lang_name = 'AYMARA'; $country_name = ''; break; case 'aw': $lang_name = 'ARUBA'; $country_name = 'ARUBA'; break; case 'au': $lang_name = 'en-au'; // $country_name = 'AUSTRALIA'; break; case 'az': $lang_name = 'AZERBAIJANI'; $country_name = 'AZERBAIJAN'; break; case 'ax': $lang_name = 'FINNISH'; $country_name = 'ALAND_ISLANDS'; //The Aland Islands or Aland (Swedish: Aland, IPA: ['o?land]; Finnish: Ahvenanmaa) is an archipelago province at the entrance to the Gulf of Bothnia in the Baltic Sea belonging to Finland. break; case 'ba': $lang_name = 'BASHKIR'; //Baskortostán (Rusia) $country_name = 'BOSNIA_&_HERZEGOVINA'; //Bosnian, Croatian, Serbian break; //Bavarian (also known as Bavarian Austrian or Austro-Bavarian; Boarisch ['b??r??] or Bairisch; //German: Bairisch ['ba????] (About this soundlisten); Hungarian: bajor. case 'bar': $lang_name = 'BAVARIAN'; $country_name = 'BAVARIA'; //Germany break; case 'bb': $lang_name = 'Barbados'; $country_name = 'BARBADOS'; break; case 'bd': $lang_name = 'Bangladesh'; $country_name = 'BANGLADESH'; break; case 'be': $lang_name = 'BELARUSIAN'; $country_name = 'BELGIUM'; break; case 'bf': $lang_name = 'Burkina Faso'; $country_name = 'BURKINA_FASO'; break; case 'bg': $lang_name = 'BULGARIAN'; $country_name = 'BULGARIA'; break; case 'bh': $lang_name = 'BHOJPURI'; // Bihar (India) $country_name = 'BAHRAIN'; // Mamlakat al-Ba?rayn (arabic) break; case 'bi': $lang_name = 'BISLAMA'; $country_name = 'BURUNDI'; break; case 'bj': $lang_name = 'BENIN'; $country_name = 'BENIN'; break; case 'bl': $lang_name = 'BONAIRE'; $country_name = 'BONAIRE'; break; case 'bm': $lang_name = 'BAMBARA'; $country_name = 'Bermuda'; break; case 'bn': $country_name = 'BRUNEI'; $lang_name = 'BENGALI'; break; case 'bo': $lang_name = 'TIBETAN'; $country_name = 'BOLIVIA'; break; case 'br': $lang_name = 'BRETON'; $country_name = 'BRAZIL'; //pt break; case 'bs': $lang_name = 'BOSNIAN'; $country_name = 'BAHAMAS'; break; case 'bt': $lang_name = 'Bhutan'; $country_name = 'Bhutan'; break; case 'bw': $lang_name = 'Botswana'; $country_name = 'BOTSWANA'; break; case 'bz': $lang_name = 'BELIZE'; $country_name = 'BELIZE'; break; case 'by': $lang_name = 'BELARUSIAN'; $country_name = 'Belarus'; break; case 'en-CM': case 'en_cm': $lang_name = 'CAMEROONIAN_PIDGIN_ENGLISH'; $country_name = 'Cameroon'; break; case 'wes': $lang_name = 'CAMEROONIAN'; //Kamtok $country_name = 'CAMEROON'; //Wes Cos break; case 'cm': $lang_name = 'CAMEROON'; $country_name = 'CAMEROON'; break; case 'ca': $lang_name = 'CATALAN'; $country_name = 'CANADA'; break; case 'cc': $lang_name = 'COA_A_COCOS'; //COA A Cocos dialect of Betawi Malay [ente (you) and ane (me)] and AU-English $country_name = 'COCOS_ISLANDS'; //CC Cocos (Keeling) Islands break; case 'cd': $lang_name = 'Congo Democratic Republic'; $country_name = 'CONGO_DEMOCRATIC_REPUBLIC'; break; //??????? ???? case 'ce': $lang_name = 'CHECHEN'; $country_name = 'Chechenya'; break; case 'cf': $lang_name = 'Central African Republic'; $country_name = 'CENTRAL_AFRICAN_REPUBLIC'; break; case 'cg': $lang_name = 'CONGO'; $country_name = 'CONGO'; break; case 'ch': $lang_name = 'CHAMORRO'; //Finu' Chamoru $country_name = 'SWITZERLAND'; break; case 'ci': $lang_name = 'Cote D-Ivoire'; $country_name = 'COTE_D-IVOIRE'; break; case 'ck': $lang_name = ''; $country_name = 'COOK_ISLANDS'; //CK Cook Islands break; case 'cl': $lang_name = 'Chile'; $country_name = 'CHILE'; break; case 'cn': //Chinese Macrolanguage case 'zh': //639-1: zh case 'chi': //639-2/B: chi case 'zho': //639-2/T and 639-3: zho $lang_name = 'CHINESE'; $country_name = 'CHINA'; break; //Chinese Individual Languages // ?? // Fujian Province, Republic of China case 'cn-fj': // ??? case 'cdo': //Chinese Min Dong $lang_name = 'CHINESE_DONG'; $country_name = 'CHINA'; break; //1. Bingzhou spoken in central Shanxi (the ancient Bing Province), including Taiyuan. //2. Lüliang spoken in western Shanxi (including Lüliang) and northern Shaanxi. //3. Shangdang spoken in the area of Changzhi (ancient Shangdang) in southeastern Shanxi. //4. Wutai spoken in parts of northern Shanxi (including Wutai County) and central Inner Mongolia. //5. Da–Bao spoken in parts of northern Shanxi and central Inner Mongolia, including Baotou. //6. Zhang-Hu spoken in Zhangjiakou in northwestern Hebei and parts of central Inner Mongolia, including Hohhot. //7. Han-Xin spoken in southeastern Shanxi, southern Hebei (including Handan) and northern Henan (including Xinxiang). //8. Zhi-Yan spoken in Zhidan County and Yanchuan County in northern Shaanxi. // ?? / ?? case 'cjy': //Chinese Jinyu ? $lang_name = 'CHINA_JINYU'; $country_name = 'CHINA'; break; // Cantonese is spoken in Hong Kong // ?? case 'cmn': //Chinese Mandarin ??? (Pu tong hua) literally translates into “common tongue.” $lang_name = 'CHINESE_MANDARIN'; $country_name = 'CHINA'; break; // Mandarin is spoken in Mainland China and Taiwan // ?? / ?? //semantic shift has occurred in Min or the rest of Chinese: //*tia?B ? "wok". The Min form preserves the original meaning "cooking pot". //*dzh?nA "rice field". scholars identify the Min word with chéng ? (MC zying) "raised path between fields", but Norman argues that it is cognate with céng ? (MC dzong) "additional layer or floor". //*tšhioC ? "house". the Min word is cognate with shu ? (MC syuH) "to guard". //*tshyiC ? "mouth". In Min this form has displaced the common Chinese term kou ?. It is believed to be cognate with hui ? (MC xjwojH) "beak, bill, snout; to pant". //Austroasiatic origin for some Min words: //*-d??A "shaman" compared with Vietnamese ð?ng (/?o?2/) "to shamanize, to communicate with spirits" and Mon do? "to dance (as if) under demonic possession". //*ki?nB ? "son" appears to be related to Vietnamese con (/k?n/) and Mon kon "child". // Southern Min: // Datian Min; // Hokkien ?; Hokkien-Taiwanese ????? - Philippine Hokkien ???. // Teochew; // Zhenan Min; // Zhongshan Min, etc. //Pu-Xian Min (Hinghwa); Putian dialect: Xianyou dialect. //Northern Min: Jian'ou dialect; Jianyang dialect; Chong'an dialect; Songxi dialect; Zhenghe dialect; //Shao-Jiang Min: Shaowu dialect, Jiangle dialect, Guangze dialect, Shunchang dialect; //http://www.shanxigov.cn/ //Central Min: Sanming dialect; Shaxian dialect; Yong'an dialect, //Leizhou Min : Leizhou Min. //Abbreviation //Simplified Chinese: ? //Traditional Chinese: ? //Literal meaning: Min [River] //?? case 'cpx': //Chinese Pu-Xian Min, Sing-iú-ua / ???, (Xianyou dialect) http://www.putian.gov.cn/ $lang_name = 'CHINESE_PU-XIAN'; $country_name = 'CHINA'; break; // ?? case 'czh': //Chinese HuiZhou ?? http://www.huizhou.gov.cn/ | Song dynasty $lang_name = 'CHINESE_HUIZHOU'; $country_name = 'CHINA'; break; // ?? case 'czo': //Chinese Min Zhong ??? | ??? http://zx.cq.gov.cn/ | Zhong-Xian | Zhong ?? $lang_name = 'CHINESE_ZHONG'; $country_name = 'CHINA'; break; // ??? SanMing: http://www.sm.gov.cn/ | Sha River (??) case 'dng': //Ding Chinese $lang_name = 'DING_CHINESE'; $country_name = 'CHINA'; break; // ?? case 'gan': //Gan Chinese $lang_name = 'GAN_CHINESE'; $country_name = 'CHINA'; break; // ??? case 'hak': //Chinese Hakka $lang_name = 'CHINESE_HAKKA'; $country_name = 'CHINA'; break; case 'hsn': //Xiang Chinese ??/?? $lang_name = 'XIANG_CHINESE'; $country_name = 'CHINA'; break; // ?? case 'lzh': //Literary Chinese $lang_name = 'LITERARY_CHINESE'; $country_name = 'CHINA'; break; // ??? case 'mnp': //Min Bei Chinese $lang_name = 'MIN_BEI_CHINESE'; $country_name = 'CHINA'; break; // ??? case 'nan': //Min Nan Chinese $lang_name = 'MIN_NAN_CHINESE'; $country_name = 'CHINA'; break; // ?? case 'wuu': //Wu Chinese $lang_name = 'WU_CHINESE'; $country_name = 'CHINA'; break; // ?? case 'yue': //Yue or Cartonese Chinese $lang_name = 'YUE_CHINESE'; $country_name = 'CHINA'; break; case 'co': $lang_name = 'CORSICAN'; // Corsica $country_name = 'COLUMBIA'; break; //Eeyou Istchee ?? case 'cr': $lang_name = 'CREE'; $country_name = 'COSTA_RICA'; break; case 'cs': $lang_name = 'CZECH'; $country_name = 'CZECH_REPUBLIC'; break; case 'cu': $lang_name = 'SLAVONIC'; $country_name = 'CUBA'; //langs: break; case 'cv': $country_name = 'CAPE_VERDE'; $lang_name = 'CHUVASH'; break; case 'cx': $lang_name = ''; // Malaysian Chinese origin and European Australians $country_name = 'CHRISTMAS_ISLAND'; break; case 'cy': $lang_name = 'CYPRUS'; $country_name = 'CYPRUS'; break; case 'cz': $lang_name = 'CZECH'; $country_name = 'CZECH_REPUBLIC'; break; case 'cw': $lang_name = 'PAPIAMENTU'; // Papiamentu (Portuguese-based Creole), Dutch, English $country_name = 'CURAÇAO'; // Ilha da Curaçao (Island of Healing) break; case 'da': $lang_name = 'DANISH'; $country_name = 'DENMARK'; break; //Geman (Deutsch) /* deu – German gmh – Middle High German goh – Old High German gct – Colonia Tovar German bar – Bavarian cim – Cimbrian geh – Hutterite German ksh – Kölsch nds – Low German sli – Lower Silesian ltz – Luxembourgish vmf – Mainfränkisch mhn – Mocheno pfl – Palatinate German pdc – Pennsylvania German pdt – Plautdietsch swg – Swabian German gsw – Swiss German uln – Unserdeutsch sxu – Upper Saxon wae – Walser German wep – Westphalian hrx – Riograndenser Hunsrückisch yec – Yenish */ //Germany 84,900,000 75,101,421 (91.8%) 5,600,000 (6.9%) De facto sole nationwide official language case 'de': case 'de-DE': case 'de_de': case 'deu': $lang_name = 'GERMAN'; $country_name = 'GERMANY'; break; //Belgium 11,420,163 73,000 (0.6%) 2,472,746 (22%) De jure official language in the German speaking community case 'de_be': case 'de-BE': $lang_name = 'BELGIUM_GERMAN'; $country_name = 'BELGIUM'; break; //Austria 8,838,171 8,040,960 (93%) 516,000 (6%) De jure sole nationwide official language case 'de_at': case 'de-AT': $lang_name = 'AUSTRIAN_GERMAN'; $country_name = 'AUSTRIA'; break; // Switzerland 8,508,904 5,329,393 (64.6%) 395,000 (5%) Co-official language at federal level; de jure sole official language in 17, co-official in 4 cantons (out of 26) case 'de_sw': case 'de-SW': $lang_name = 'SWISS_GERMAN'; $country_name = 'SWITZERLAND'; break; //Luxembourg 602,000 11,000 (2%) 380,000 (67.5%) De jure nationwide co-official language case 'de_lu': case 'de-LU': case 'ltz': $lang_name = 'LUXEMBOURG_GERMAN'; $country_name = 'LUXEMBOURG'; break; //Liechtenstein 37,370 32,075 (85.8%) 5,200 (13.9%) De jure sole nationwide official language //Alemannic, or rarely Alemmanish case 'de_li': case 'de-LI': $lang_name = 'LIECHTENSTEIN_GERMAN'; $country_name = 'LIECHTENSTEIN'; break; case 'gsw': $lang_name = 'Alemannic_German'; $country_name = 'SWITZERLAND'; break; //mostly spoken on Lifou Island, Loyalty Islands, New Caledonia. case 'dhv': $lang_name = 'DREHU'; $country_name = 'NEW_CALEDONIA'; break; case 'pdc': //Pennsilfaanisch-Deitsche $lang_name = 'PENNSYLVANIA_DUTCH'; $country_name = 'PENNSYLVANIA'; break; case 'dk': $lang_name = 'DANISH'; $country_name = 'DENMARK'; break; //acf – Saint Lucian / Dominican Creole French case 'acf': $lang_name = 'DOMINICAN_CREOLE_FRENCH'; //ROSEAU $country_name = 'DOMINICA'; break; case 'en_dm': case 'en-DM': $lang_name = 'DOMINICA_ENGLISH'; $country_name = 'DOMINICA'; break; case 'do': case 'en_do': case 'en-DO': $lang_name = 'SPANISH'; //Santo Domingo $country_name = 'DOMINICAN_REPUBLIC'; break; case 'dj': case 'aa-DJ': case 'aa_dj': $lang_name = 'DJIBOUTI'; //Yibuti, Afar $country_name = 'REPUBLIC_OF_DJIBOUTI'; //République de Djibouti break; case 'dv': $lang_name = 'DIVEHI'; //Maldivian $country_name = 'MALDIVIA'; break; //Berbera Taghelmustã (limba oamenilor alba?tri), zisã ?i Tuaregã, este vorbitã în Sahara occidentalã. //Berbera Tamazigtã este vorbitã în masivul Atlas din Maroc, la sud de ora?ul Meknes. //Berbera Zenaticã zisã ?i Rifanã, este vorbitã în masivul Rif din Maroc, în nord-estul ?ãrii. //Berbera ?enuanã zisã ?i Telicã, este vorbitã în masivul Tell din Algeria, în nordul ?ãrii. //Berbera Cabilicã este vorbitã în jurul masivelor Mitigea ?i Ores din Algeria, în nordul ?ãrii. //Berbera ?auianã este vorbitã în jurul ora?ului Batna din Algeria. //Berbera Tahelhitã, zisã ?i ?lãnuanã (în limba francezã Chleuh) este vorbitã în jurul masivului Tubkal din Maroc, în sud-vestul ?ãrii. //Berbera Tama?ekã, zisã ?i Saharianã, este vorbitã în Sahara de nord, în Algeria, Libia ?i Egipt. //Berber: Tacawit (@ city Batna from Chaoui, Algery), Shawiya (Shauian) case 'shy': $lang_name = 'SHAWIYA_BERBER'; $country_name = 'ALGERIA'; break; case 'dz': $lang_name = 'DZONGKHA'; $country_name = 'ALGERIA'; //http://www.el-mouradia.dz/ break; case 'ec': $country_name = 'ECUADOR'; $lang_name = 'ECUADOR'; break; case 'eg': $country_name = 'EGYPT'; $lang_name = 'EGYPT'; break; case 'eh': $lang_name = 'WESTERN_SAHARA'; $country_name = 'WESTERN_SAHARA'; break; case 'ee': //K?si?agbe (Sunday) //Dzo?agbe (Monday) //Bra?agbe, Bla?agbe (Tuesday) //Ku?agbe (Wednesday) //Yawo?agbe (Thursday) //Fi?agbe (Friday) //Memli?agbe (Saturday) $lang_name = 'EWE'; //E?egbe Native to Ghana, Togo $country_name = 'ESTONIA'; break; //Greek Language: //ell – Modern Greek //grc – Ancient Greek //cpg – Cappadocian Greek //gmy – Mycenaean Greek //pnt – Pontic //tsd – Tsakonian //yej – Yevanic case 'el': $lang_name = 'GREEK'; $country_name = 'GREECE'; break; case 'cpg': $lang_name = 'CAPPADOCIAN_GREEK'; $country_name = 'GREECE'; break; case 'gmy': $lang_name = 'MYCENAEAN_GREEK'; $country_name = 'GREECE'; break; case 'pnt': $lang_name = 'PONTIC'; $country_name = 'GREECE'; break; case 'tsd': $lang_name = 'TSAKONIAN'; $country_name = 'GREECE'; break; //Albanian: Janina or Janinë, Aromanian: Ianina, Enina, Turkish: Yanya; case 'yej': $lang_name = 'YEVANIC'; $country_name = 'GREECE'; break; case 'en_uk': case 'en-UK': case 'uk': $lang_name = 'BRITISH_ENGLISH'; //used in United Kingdom $country_name = 'GREAT_BRITAIN'; break; case 'en_fj': case 'en-FJ': $lang_name = 'FIJIAN_ENGLISH'; $country_name = 'FIJI'; break; case 'GibE': case 'en_gb': case 'en-GB': case 'gb': $lang_name = 'GIBRALTARIAN _ENGLISH'; //used in Gibraltar $country_name = 'GIBRALTAR'; break; case 'en_us': case 'en-US': $lang_name = 'AMERICAN_ENGLISH'; $country_name = 'UNITED_STATES_OF_AMERICA'; break; case 'en_ie': case 'en-IE': case 'USEng': $lang_name = 'HIBERNO_ENGLISH'; //Irish English $country_name = 'IRELAND'; break; case 'en_il': case 'en-IL': case 'ILEng': case 'heblish': case 'engbrew': $lang_name = 'ISRAELY_ENGLISH'; $country_name = 'ISRAEL'; break; case 'en_ca': case 'en-CA': case 'CanE': $lang_name = 'CANADIAN_ENGLISH'; $country_name = 'CANADA'; break; case 'en_ck': $lang_name = 'COOK_ISLANDS_ENGLISH'; $country_name = 'COOK_ISLANDS'; //CK Cook Islands break; case 'en_in': case 'en-IN': $lang_name = 'INDIAN_ENGLISH'; $country_name = 'REPUBLIC_OF_INDIA'; break; case 'en_ai': case 'en-AI': $lang_name = 'ANGUILLAN_ENGLISH'; $country_name = 'ANGUILLA'; break; case 'en_au': case 'en-AU': case 'AuE': $lang_name = 'AUSTRALIAN_ENGLISH'; $country_name = 'AUSTRALIA'; break; case 'en_nz': case 'en-NZ': case 'NZE': $lang_name = 'NEW_ZEALAND_ENGLISH'; $country_name = 'NEW_ZEALAND'; break; //New England English case 'en_ne': $lang_name = 'NEW_ENGLAND_ENGLISH'; $country_name = 'NEW_ENGLAND'; break; // case 'en_bm': $lang_name = 'BERMUDIAN ENGLISH.'; $country_name = 'BERMUDA'; break; case 'en_nu': $lang_name = 'NIUEAN_ENGLISH'; //Niuean (official) 46% (a Polynesian language closely related to Tongan and Samoan) $country_name = 'NIUE'; // Niuean: Niue break; case 'en_ms': $lang_name = 'MONTSERRAT_ENGLISH'; $country_name = 'MONTSERRAT'; break; case 'en_pn': $lang_name = 'PITCAIRN_ISLAND_ENGLISH'; $country_name = 'PITCAIRN_ISLAND'; break; case 'en_sh': $lang_name = 'ST_HELENA_ENGLISH'; $country_name = 'ST_HELENA'; break; case 'en_tc': $lang_name = 'TURKS_&_CAICOS_IS_ENGLISH'; $country_name = 'TURKS_&_CAICOS_IS'; break; case 'en_vg': $lang_name = 'VIRGIN_ISLANDS_ENGLISH'; $country_name = 'VIRGIN_ISLANDS_(BRIT)'; break; case 'eo': $lang_name = 'ESPERANTO'; //created in the late 19th century by L. L. Zamenhof, a Polish-Jewish ophthalmologist. In 1887 $country_name = 'EUROPE'; break; case 'er': $lang_name = 'ERITREA'; $country_name = 'ERITREA'; break; //See: // http://www.webapps-online.com/online-tools/languages-and-locales // https://www.ibm.com/support/knowledgecenter/ko/SSS28S_3.0.0/com.ibm.help.forms.doc/locale_spec/i_xfdl_r_locale_quick_reference.html case 'es': //Spanish Main $lang_name = 'SPANISH'; $country_name = 'SPAIN'; break; case 'es_MX': case 'es_mx': //Spanish (Mexico) (es-MX) $lang_name = 'SPANISH_MEXICO'; $country_name = 'MEXICO'; break; case 'es_US': case 'es_us': $lang_name = 'SPANISH_UNITED_STATES'; $country_name = 'UNITED_STATES'; break; case 'es_419': //Spanish Latin America and the Caribbean $lang_name = 'SPANISH_CARIBBEAN'; $country_name = 'CARIBBE'; break; case 'es_ar': // Spanish Argentina $lang_name = 'SPANISH_ARGENTINIAN'; $country_name = 'ARGENTINA'; break; case 'es_BO': case 'es_bo': $lang_name = 'SPANISH_BOLIVIAN'; $country_name = 'BOLIVIA'; break; case 'es_BR': case 'es_br': $lang_name = 'SPANISH_BRAZILIAN'; $country_name = 'BRAZIL'; break; case 'es_cl': // Spanish Chile $lang_name = 'SPANISH_CHILEAN'; $country_name = 'CHILE'; break; case 'es_CO': case 'es_co': case 'es-419': case 'es_419': // Spanish (Colombia) (es-CO) $lang_name = 'SPANISH_COLOMBIAN'; $country_name = 'COLOMBIA'; break; // Variety of es-419 Spanish Latin America and the Caribbean // Spanish language as spoken in // the Caribbean islands of Cuba, // Puerto Rico, and the Dominican Republic // as well as in Panama, Venezuela, // and the Caribbean coast of Colombia. case 'es-CU': case 'es-cu': case 'es_cu': // Spanish (Cuba) (es-CU) $lang_name = 'CUBAN_SPANISH'; $country_name = 'CUBA'; break; case 'es_CR': case 'es_cr': $lang_name = 'SPANISH_COSTA_RICA'; $country_name = 'COSTA_RICA'; break; case 'es_DO': case 'es_do': //Spanish (Dominican Republic) (es-DO) $lang_name = 'SPANISH_DOMINICAN_REPUBLIC'; $country_name = 'DOMINICAN_REPUBLIC'; break; case 'es_ec': // Spanish (Ecuador) (es-EC) $lang_name = 'SPANISH'; $country_name = 'SPAIN'; break; case 'es_es': case 'es_ES': // Spanish Spain $lang_name = 'SPANISH'; $country_name = 'SPAIN'; break; case 'es_ES_tradnl': case 'es_es_tradnl': $lang_name = 'SPANISH_NL'; $country_name = 'NL'; break; case 'es_EU': case 'es_eu': $lang_name = 'SPANISH_EUROPE'; $country_name = 'EUROPE'; break; case 'es_gt': case 'es_GT': // Spanish (Guatemala) (es-GT) $lang_name = 'SPANISH'; $country_name = 'SPAIN'; break; case 'es_HN': case 'es_hn': //Spanish (Honduras) (es-HN) $lang_name = 'SPANISH'; $country_name = 'SPAIN'; break; case 'es_la': case 'es_LA': // Spanish Lao $lang_name = 'SPANISH'; $country_name = 'SPAIN'; break; case 'es_NI': case 'es_ni': // Spanish (Nicaragua) (es-NI) $lang_name = 'SPANISH_NICARAGUAN'; $country_name = 'NICARAGUA'; break; case 'es_PA': case 'es_pa': //Spanish (Panama) (es-PA) $lang_name = 'SPANISH_PANAMIAN'; $country_name = 'PANAMA'; break; case 'es_pe': case 'es_PE': //Spanish (Peru) (es-PE) $lang_name = 'SPANISH_PERU'; $country_name = 'PERU'; break; case 'es_PR': case 'es_pr': //Spanish (Puerto Rico) (es-PR) $lang_name = 'SPANISH_PUERTO_RICO'; $country_name = 'PUERTO_RICO'; break; case 'es_PY': case 'es_py': //Spanish (Paraguay) (es-PY) $lang_name = 'SPANISH_PARAGUAY'; $country_name = 'PARAGUAY'; break; case 'es_SV': case 'es_sv': //Spanish (El Salvador) (es-SV) $lang_name = 'SPANISH_EL_SALVADOR'; $country_name = 'EL_SALVADOR'; break; case 'es-US': case 'es-us': // Spanish (United States) (es-US) $lang_name = 'SPANISH_UNITED_STATES'; $country_name = 'UNITED_STATES'; break; //This dialect is often spoken with an intonation resembling that of the Neapolitan language of Southern Italy, but there are exceptions. case 'es_AR': case 'es_ar': //Spanish (Argentina) (es-AR) $lang_name = 'RIOPLATENSE_SPANISH_ARGENTINA'; $country_name = 'ARGENTINA'; break; case 'es_UY': case 'es_uy': //Spanish (Uruguay) (es-UY) $lang_name = 'SPANISH_URUGUAY'; $country_name = 'URUGUAY'; break; case 'es_ve': case 'es_VE': // Spanish (Venezuela) (es-VE) $lang_name = 'SPANISH_VENEZUELA'; $country_name = 'BOLIVARIAN_REPUBLIC_OF_VENEZUELA'; break; case 'es_xl': case 'es_XL': // Spanish Latin America $lang_name = 'SPANISH_LATIN_AMERICA'; $country_name = 'LATIN_AMERICA'; break; case 'et': $lang_name = 'ESTONIAN'; $country_name = 'ESTONIA'; break; case 'eu': $lang_name = 'BASQUE'; $country_name = ''; break; case 'fa': $lang_name = 'PERSIAN'; $country_name = ''; break; //for Fulah (also spelled Fula) the ISO 639-1 code is ff. //fub – Adamawa Fulfulde //fui – Bagirmi Fulfulde //fue – Borgu Fulfulde //fuq – Central-Eastern Niger Fulfulde //ffm – Maasina Fulfulde //fuv – Nigerian Fulfulde //fuc – Pulaar //fuf – Pular //fuh – Western Niger Fulfulde case 'fub': $lang_name = 'ADAMAWA_FULFULDE'; $country_name = ''; break; case 'fui': $lang_name = 'BAGIRMI_FULFULDE'; $country_name = ''; break; case 'fue': $lang_name = 'BORGU_FULFULDE'; $country_name = ''; break; case 'fuq': $lang_name = 'CENTRAL-EASTERN_NIGER_FULFULDE'; $country_name = ''; break; case 'ffm': $lang_name = 'MAASINA_FULFULDE'; $country_name = ''; break; case 'fuv': $lang_name = 'NIGERIAN_FULFULDE'; $country_name = ''; break; case 'fuc': $lang_name = 'PULAAR'; $country_name = 'SENEGAMBIA_CONFEDERATION'; //sn //gm break; case 'fuf': $lang_name = 'PULAR'; $country_name = ''; break; case 'fuh': $lang_name = 'WESTERN_NIGER_FULFULDE'; $country_name = ''; break; case 'ff': $lang_name = 'FULAH'; $country_name = ''; break; case 'fi': case 'fin': $lang_name = 'FINNISH'; $country_name = 'FINLAND'; break; case 'fkv': $lang_name = 'KVEN'; $country_name = 'NORWAY'; break; case 'fit': $lang_name = 'KVEN'; $country_name = 'SWEDEN'; break; case 'fj': $lang_name = 'FIJIAN'; $country_name = 'FIJI'; break; case 'fk': $lang_name = 'FALKLANDIAN'; $country_name = 'FALKLAND_ISLANDS'; break; case 'fm': $lang_name = 'MICRONESIA'; $country_name = 'MICRONESIA'; break; case 'fo': $lang_name = 'FAROESE'; $country_name = 'FAROE_ISLANDS'; break; //Metropolitan French (French: France Métropolitaine or la Métropole) case 'fr': case 'fr_me': $lang_name = 'FRENCH'; $country_name = 'FRANCE'; break; //Acadian French case 'fr_ac': $lang_name = 'ACADIAN_FRENCH'; $country_name = 'ACADIA'; break; case 'fr_dm': case 'fr-DM': $lang_name = 'DOMINICA_FRENCH'; $country_name = 'DOMINICA'; break; //al-dîzayir case 'fr_dz': $lang_name = 'ALGERIAN_FRENCH'; $country_name = 'ALGERIA'; break; //Aostan French (French: français valdôtain) //Seventy: septante[a] [s?p.t?~t] //Eighty: huitante[b] [?i.t?~t] //Ninety: nonante[c] [n?.n?~t] case 'fr_ao': $lang_name = 'AOSTAN_FRENCH'; $country_name = 'ITALY'; break; //Belgian French case 'fr_bl': $lang_name = 'BELGIAN_FRENCH'; $country_name = 'BELGIUM'; break; //Cambodian French - French Indochina case 'fr_cb': $lang_name = 'CAMBODIAN_FRENCH'; $country_name = 'CAMBODIA'; break; //Cajun French - Le Français Cajun - New Orleans case 'fr_cj': $lang_name = 'CAJUN_FRENCH'; $country_name = 'UNITED_STATES'; break; //Canadian French (French: Français Canadien) //Official language in Canada, New Brunswick, Northwest Territories, Nunavut, Quebec, Yukon, //Official language in United States, Maine (de facto), New Hampshire case 'fr_ca': case 'fr-CA': $lang_name = 'CANADIAN_FRENCH'; $country_name = 'CANADA'; break; //Guianese French case 'gcr': case 'fr_gu': $lang_name = 'GUIANESE_FRENCH'; $country_name = 'FRENCH_GUIANA'; break; //Guianese English case 'gyn': case 'en_gy': $lang_name = 'GUYANESE_CREOLE'; $country_name = 'ENGLISH_GUIANA'; break; //Haitian French case 'fr-HT': case 'fr_ht': $lang_name = 'HAITIAN_FRENCH'; $country_name = 'HAITI'; //UNITED_STATES break; //Haitian English case 'en-HT': case 'en_ht': $lang_name = 'HAITIAN_CREOLE'; $country_name = 'HAITI'; //UNITED_STATES break; //Indian French case 'fr_id': $lang_name = 'INDIAN_FRENCH'; $country_name = 'INDIA'; break; case 'en_id': $lang_name = 'INDIAN_ENGLISH'; $country_name = 'INDIA'; break; //Jersey Legal French - Anglo-Norman French case 'xno': case 'fr_je': $lang_name = 'JERSEY_LEGAL_FRENCH'; $country_name = 'UNITED_STATES'; break; case 'fr_kh': $lang_name = 'CAMBODIAN_FRENCH'; $country_name = 'CAMBODIA'; break; //Lao French case 'fr_la': $lang_name = 'LAO_FRENCH'; $country_name = 'LAOS'; break; //Louisiana French (French: Français de la Louisiane, Louisiana Creole: Françé la Lwizyan) case 'frc': case 'fr_lu': $lang_name = 'LOUISIANIAN_FRENCH'; $country_name = 'LOUISIANA'; break; //Louisiana Creole case 'lou': $lang_name = 'LOUISIANA_CREOLE'; $country_name = 'LOUISIANA'; break; //Meridional French (French: Français Méridional, also referred to as Francitan) case 'fr_mr': $lang_name = 'MERIDIONAL_FRENCH'; $country_name = 'OCCITANIA'; break; //Missouri French case 'fr_mi': $lang_name = 'MISSOURI_FRENCH'; $country_name = 'MISSOURI?'; break; //New Caledonian French vs New Caledonian Pidgin French case 'fr_nc': $lang_name = 'NEW_CALEDONIAN_FRENCH'; $country_name = 'NEW_CALEDONIA'; break; //Newfoundland French (French: Français Terre-Neuvien), case 'fr_nf': $lang_name = 'NEWFOUNDLAND_FRENCH'; $country_name = 'CANADA'; break; //New England French case 'fr_ne': $lang_name = 'NEW_ENGLAND_FRENCH'; $country_name = 'NEW_ENGLAND'; break; //Quebec French (French: français québécois; also known as Québécois French or simply Québécois) case 'fr_qb': $lang_name = 'QUEBEC_FRENCH'; $country_name = 'CANADA'; break; //Swiss French case 'fr_sw': $lang_name = 'SWISS_FRENCH'; $country_name = 'SWITZERLAND'; break; //French Southern and Antarctic Lands case 'fr_tf': case 'tf': $lang_name = 'FRENCH_SOUTHERN_TERRITORIES'; // $country_name = 'SOUTHERN_TERRITORIES'; //Terres australes françaises break; //Vietnamese French case 'fr_vt': $lang_name = 'VIETNAMESE_FRENCH'; $country_name = 'VIETNAM'; break; //West Indian French case 'fr_if': $lang_name = 'WEST_INDIAN_FRENCH'; $country_name = 'INDIA'; break; case 'fr_wf': $country_name = 'TERRITORY_OF_THE_WALLIS_AND_FUTUNA_ISLANDS'; $lang_name = 'WALLISIAN_FRENCH'; break; case 'fy': $lang_name = 'WESTERN_FRISIAN'; $country_name = 'FRYSK'; break; case 'ga': $lang_name = 'IRISH'; $country_name = 'GABON'; break; case 'GenAm': $lang_name = 'General American'; $country_name = 'UNITED_STATES'; break; //gcf – Guadeloupean Creole case 'gcf': $lang_name = 'GUADELOUPEAN_CREOLE_FRENCH'; $country_name = 'GUADELOUPE'; break; case 'gd': $lang_name = 'SCOTTISH'; $country_name = 'GRENADA'; break; case 'ge': $lang_name = 'GEORGIAN'; $country_name = 'GEORGIA'; break; case 'gi': $lang_name = 'LLANITO'; //Llanito or Yanito $country_name = 'GIBRALTAR'; break; case 'gg': $lang_name = 'GUERNESIAIS'; //English, Guernésiais, Sercquiais, Auregnais $country_name = 'GUERNSEY'; break; case 'gh': $lang_name = 'Ghana'; $country_name = 'GHANA'; break; case 'ell': $lang_name = 'MODERN_GREEK'; $country_name = 'GREECE'; break; case 'gr': case 'el_gr': case 'el-gr': case 'gre': $lang_name = 'MODERN_GREEK'; $country_name = 'GREECE'; break; case 'grc': $lang_name = 'ANCIENT_GREEK'; $country_name = 'GREECE'; break; //Galician is spoken by some 2.4 million people, mainly in Galicia, //an autonomous community located in northwestern Spain. case 'gl': $lang_name = 'GALICIAN'; //Galicia $country_name = 'GREENLAND'; break; case 'gm': $lang_name = 'Gambia'; $country_name = 'GAMBIA'; break; //grn is the ISO 639-3 language code for Guarani. Its ISO 639-1 code is gn. // nhd – Chiripá // gui – Eastern Bolivian Guaraní // gun – Mbyá Guaraní // gug – Paraguayan Guaraní // gnw – Western Bolivian Guaraní case 'gn': $lang_name = 'GUARANI'; $country_name = 'GUINEA'; break; //Nhandéva is also known as Chiripá. //The Spanish spelling, Nandeva, is used in the Paraguayan Chaco // to refer to the local variety of Eastern Bolivian, a subdialect of Avá. case 'nhd': $lang_name = 'Chiripa'; $country_name = 'PARAGUAY'; break; case 'gui': $lang_name = 'EASTERN_BOLIVIAN_GUARANI'; $country_name = 'BOLIVIA'; break; case 'gun': $lang_name = 'MBYA_GUARANI'; $country_name = 'PARAGUAY'; break; case 'gug': $lang_name = 'PARAGUAYAN_GUARANI'; $country_name = 'PARAGUAY'; break; case 'gnw': $lang_name = 'WESTERN_BOLIVIAN_GUARANI'; $country_name = 'BOLIVIA'; break; case 'gs': $lang_name = 'ENGLISH'; $country_name = 'SOUTH_GEORGIA_AND_THE_SOUTH_SANDWICH_ISLANDS'; break; case 'gt': $lang_name = 'Guatemala'; $country_name = 'GUATEMALA'; break; case 'gq': $lang_name = 'Equatorial Guinea'; $country_name = 'EQUATORIAL_GUINEA'; break; case 'gu': $lang_name = 'GUJARATI'; $country_name = 'GUAM'; break; case 'gv': $lang_name = 'manx'; $country_name = ''; break; case 'gw': $lang_name = 'Guinea Bissau'; $country_name = 'GUINEA_BISSAU'; break; case 'gy': $lang_name = 'Guyana'; $country_name = 'GUYANA'; break; case 'ha': $country_name = ''; $lang_name = 'HAUSA'; break; //heb – Modern Hebrew //hbo – Classical Hebrew (liturgical) //smp – Samaritan Hebrew (liturgical) //obm – Moabite (extinct) //xdm – Edomite (extinct) case 'he': case 'heb': $country_name = 'ISRAEL'; $lang_name = 'HEBREW'; break; case 'hbo': $country_name = 'ISRAEL'; $lang_name = 'CLASSICAL_HEBREW'; break; case 'sam': $country_name = 'SAMARIA'; $lang_name = 'SAMARITAN_ARAMEIC'; break; case 'smp': $country_name = 'SAMARIA'; $lang_name = 'SAMARITAN_HEBREW'; break; case 'obm': $country_name = 'MOAB'; $lang_name = 'MOABITE'; break; case 'xdm': $country_name = 'EDOMITE'; $lang_name = 'EDOM'; break; case 'hi': $lang_name = 'hindi'; $country_name = ''; break; case 'ho': $lang_name = 'hiri_motu'; $country_name = ''; break; case 'hk': $lang_name = 'Hong Kong'; $country_name = 'HONG_KONG'; break; case 'hn': $country_name = 'Honduras'; $lang_name = 'HONDURAS'; break; case 'hr': $lang_name = 'croatian'; $country_name = 'CROATIA'; break; case 'ht': $lang_name = 'haitian'; $country_name = 'HAITI'; break; case 'ho': $lang_name = 'hiri_motu'; $country_name = ''; break; case 'hu': $lang_name = 'hungarian'; $country_name = 'HUNGARY'; break; case 'hy': case 'hy-am': $lang_name = 'ARMENIAN'; $country_name = ''; break; case 'hy-AT': case 'hy_at': $lang_name = 'ARMENIAN-ARTSAKH'; $country_name = 'REPUBLIC_OF_ARTSAKH'; break; case 'hz': $lang_name = 'HERERO'; $country_name = ''; break; case 'ia': $lang_name = 'INTERLINGUA'; $country_name = ''; break; case 'ic': $lang_name = ''; $country_name = 'CANARY_ISLANDS'; break; case 'id': $lang_name = 'INDONESIAN'; $country_name = 'INDONESIA'; break; case 'ie': $lang_name = 'interlingue'; $country_name = 'IRELAND'; break; case 'ig': $lang_name = 'igbo'; $country_name = ''; break; case 'ii': $lang_name = 'sichuan_yi'; $country_name = ''; break; case 'ik': $lang_name = 'inupiaq'; $country_name = ''; break; //Mostly spoken on Ouvéa Island or Uvea Island of the Loyalty Islands, New Caledonia. case 'iai': $lang_name = 'IAAI'; $country_name = 'NEW_CALEDONIA'; break; case 'il': $lang_name = 'ibrit'; $country_name = 'ISRAEL'; break; case 'im': $lang_name = 'Isle of Man'; $country_name = 'ISLE_OF_MAN'; break; case 'in': $lang_name = 'India'; $country_name = 'INDIA'; break; case 'ir': $lang_name = 'Iran'; $country_name = 'IRAN'; break; case 'is': $lang_name = 'Iceland'; $country_name = 'ICELAND'; break; case 'it': $lang_name = 'ITALIAN'; $country_name = 'ITALY'; break; case 'iq': $lang_name = 'Iraq'; $country_name = 'IRAQ'; break; case 'je': $lang_name = 'jerriais'; //Jerriais $country_name = 'JERSEY'; //Bailiwick of Jersey break; case 'jm': $lang_name = 'Jamaica'; $country_name = 'JAMAICA'; break; case 'jo': $lang_name = 'Jordan'; $country_name = 'JORDAN'; break; case 'jp': $lang_name = 'japanese'; $country_name = 'JAPAN'; break; case 'jv': $lang_name = 'javanese'; $country_name = ''; break; case 'kh': $lang_name = 'KH'; $country_name = 'CAMBODIA'; break; case 'ke': $lang_name = 'SWAHILI'; $country_name = 'KENYA'; break; case 'ki': $lang_name = 'Kiribati'; $country_name = 'KIRIBATI'; break; //Bantu languages //zdj – Ngazidja Comorian case 'zdj': $lang_name = 'Ngazidja Comorian'; $country_name = 'COMOROS'; break; //wni – Ndzwani Comorian (Anjouani) dialect case 'wni': $lang_name = 'Ndzwani Comorian'; $country_name = 'COMOROS'; break; //swb – Maore Comorian dialect case 'swb': $lang_name = 'Maore Comorian'; $country_name = 'COMOROS'; break; //wlc – Mwali Comorian dialect case 'wlc': $lang_name = 'Mwali Comorian'; $country_name = 'COMOROS'; break; case 'km': $lang_name = 'KHMER'; $country_name = 'COMOROS'; break; case 'kn': $lang_name = 'kannada'; $country_name = 'ST_KITTS-NEVIS'; break; case 'ko': case 'kp': $lang_name = 'korean'; // kor – Modern Korean // jje – Jeju // okm – Middle Korean // oko – Old Korean // oko – Proto Korean // okm Middle Korean // oko Old Korean $country_name = 'Korea North'; break; case 'kr': $lang_name = 'korean'; $country_name = 'KOREA_SOUTH'; break; case 'kn': $lang_name = 'St Kitts-Nevis'; $country_name = 'ST_KITTS-NEVIS'; break; case 'ks': $lang_name = 'kashmiri'; //Kashmir $country_name = 'KOREA_SOUTH'; break; case 'ky': $lang_name = 'Cayman Islands'; $country_name = 'CAYMAN_ISLANDS'; break; case 'kz': $lang_name = 'Kazakhstan'; $country_name = 'KAZAKHSTAN'; break; case 'kw': //endonim: Kernewek $lang_name = 'Cornish'; $country_name = 'KUWAIT'; break; case 'kg': $lang_name = 'Kyrgyzstan'; $country_name = 'KYRGYZSTAN'; break; case 'la': $lang_name = 'Laos'; $country_name = 'LAOS'; break; case 'lk': $lang_name = 'Sri Lanka'; $country_name = 'SRI_LANKA'; break; case 'lv': $lang_name = 'Latvia'; $country_name = 'LATVIA'; break; case 'lb': $lang_name = 'LUXEMBOURGISH'; $country_name = 'LEBANON'; break; case 'lc': $lang_name = 'St Lucia'; $country_name = 'ST_LUCIA'; break; case 'ls': $lang_name = 'Lesotho'; $country_name = 'LESOTHO'; break; case 'lo': $lang_name = 'LAO'; $country_name = 'LAOS'; break; case 'lr': $lang_name = 'Liberia'; $country_name = 'LIBERIA'; break; case 'ly': $lang_name = 'Libya'; $country_name = 'Libya'; break; case 'li': $lang_name = 'LIMBURGISH'; $country_name = 'LIECHTENSTEIN'; break; case 'lt': $country_name = 'Lithuania'; $lang_name = 'LITHUANIA'; break; case 'lu': $lang_name = 'LUXEMBOURGISH'; $country_name = 'LUXEMBOURG'; break; case 'ma': $lang_name = 'Morocco'; $country_name = 'MOROCCO'; break; case 'mc': $country_name = 'MONACO'; $lang_name = 'Monaco'; break; case 'md': $country_name = 'MOLDOVA'; $lang_name = 'romanian'; break; case 'me': $lang_name = 'MONTENEGRIN'; //Serbo-Croatian, Cyrillic, Latin $country_name = 'MONTENEGRO'; //???? ???? break; case 'mf': $lang_name = 'FRENCH'; // $country_name = 'SAINT_MARTIN_(FRENCH_PART)'; break; case 'mg': $lang_name = 'Madagascar'; $country_name = 'MADAGASCAR'; break; case 'mh': $lang_name = 'Marshall Islands'; $country_name = 'MARSHALL_ISLANDS'; break; case 'mi': $lang_name = 'MAORI'; $country_name = 'Maori'; break; //Mi'kmaq hieroglyphic writing was a writing system and memory aid used by the Mi'kmaq, //a First Nations people of the east coast of Canada, Mostly spoken in Nova Scotia and Newfoundland. case 'mic': $lang_name = 'MIKMAQ'; $country_name = 'CANADA'; break; case 'mk': $lang_name = 'Macedonia'; $country_name = 'MACEDONIA'; break; case 'mr': $lang_name = 'Mauritania'; $country_name = 'Mauritania'; break; case 'mu': $lang_name = 'Mauritius'; $country_name = 'MAURITIUS'; break; case 'mo': $lang_name = 'Macau'; $country_name = 'MACAU'; break; case 'mn': $lang_name = 'Mongolia'; $country_name = 'MONGOLIA'; break; case 'ms': $lang_name = 'Montserrat'; $country_name = 'MONTSERRAT'; break; case 'mz': $lang_name = 'Mozambique'; $country_name = 'MOZAMBIQUE'; break; case 'mm': $lang_name = 'Myanmar'; $country_name = 'MYANMAR'; break; case 'mp': $lang_name = 'chamorro'; //Carolinian $country_name = 'NORTHERN_MARIANA_ISLANDS'; break; case 'mw': $country_name = 'Malawi'; $lang_name = 'MALAWI'; break; case 'my': $lang_name = 'Myanmar'; $country_name = 'MALAYSIA'; break; case 'mv': $lang_name = 'Maldives'; $country_name = 'MALDIVES'; break; case 'ml': $lang_name = 'Mali'; $country_name = 'MALI'; break; case 'mt': $lang_name = 'Malta'; $country_name = 'MALTA'; break; case 'mx': $lang_name = 'Mexico'; $country_name = 'MEXICO'; break; case 'mq': $lang_name = 'antillean-creole'; // Antillean Creole (Créole Martiniquais) $country_name = 'MARTINIQUE'; break; case 'na': $lang_name = 'Nambia'; $country_name = 'NAMBIA'; break; case 'ni': $lang_name = 'Nicaragua'; $country_name = 'NICARAGUA'; break; //Barber: Targuí, tuareg case 'ne': $lang_name = 'Niger'; $country_name = 'NIGER'; break; //Mostly spoken on Maré Island of the Loyalty Islands, New Caledonia. case 'nen': $lang_name = 'NENGONE'; $country_name = 'NEW_CALEDONIA'; break; case 'new': $lang_name = 'NEW_LANGUAGE'; $country_name = 'NEW_COUNTRY'; break; case 'nc': $lang_name = 'paicî'; //French, Nengone, Paicî, Ajië, Drehu $country_name = 'NEW_CALEDONIA'; break; case 'nk': $lang_name = 'Korea North'; $country_name = 'KOREA_NORTH'; break; case 'ng': $lang_name = 'Nigeria'; $country_name = 'NIGERIA'; break; case 'nf': $lang_name = 'Norfolk Island'; $country_name = 'NORFOLK_ISLAND'; break; case 'nl': $lang_name = 'DUTCH'; //Netherlands, Flemish. $country_name = 'NETHERLANDS'; break; case 'no': $lang_name = 'Norway'; $country_name = 'NORWAY'; break; case 'np': $lang_name = 'Nepal'; $country_name = 'NEPAL'; break; case 'nr': $lang_name = 'Nauru'; $country_name = 'NAURU'; break; case 'niu': $lang_name = 'NIUEAN'; //Niuean (official) 46% (a Polynesian language closely related to Tongan and Samoan) $country_name = 'NIUE'; // Niuean: Niue break; case 'nu': $lang_name = 'NU'; //Niuean (official) 46% (a Polynesian language closely related to Tongan and Samoan) $country_name = 'NIUE'; // Niuean: Niue break; case 'nz': $lang_name = 'New Zealand'; $country_name = 'NEW_ZEALAND'; break; case 'ny': $lang_name = 'Chewa'; $country_name = 'Nyanja'; break; //langue d'oc case 'oc': $lang_name = 'OCCITAN'; $country_name = 'OCCITANIA'; break; case 'oj': $lang_name = 'ojibwa'; $country_name = ''; break; case 'om': $lang_name = 'Oman'; $country_name = 'OMAN'; break; case 'or': $lang_name = 'oriya'; $country_name = ''; break; case 'os': $lang_name = 'ossetian'; $country_name = ''; break; case 'pa': $country_name = 'Panama'; $lang_name = 'PANAMA'; break; case 'pe': $country_name = 'Peru'; $lang_name = 'PERU'; break; case 'ph': $lang_name = 'Philippines'; $country_name = 'PHILIPPINES'; break; case 'pf': $country_name = 'French Polynesia'; $lang_name = 'tahitian'; //Polynésie française break; case 'pg': $country_name = 'PAPUA_NEW_GUINEA'; $lang_name = 'Papua New Guinea'; break; case 'pi': $lang_name = 'pali'; $country_name = ''; break; case 'pl': $lang_name = 'Poland'; $country_name = 'POLAND'; break; case 'pn': $lang_name = 'Pitcairn Island'; $country_name = 'PITCAIRN_ISLAND'; break; case 'pr': $lang_name = 'Puerto Rico'; $country_name = 'PUERTO_RICO'; break; case 'pt': case 'pt_pt': $lang_name = 'PORTUGUESE'; $country_name = 'PORTUGAL'; break; case 'pt_br': $lang_name = 'PORTUGUESE_BRASIL'; $country_name = 'BRAZIL'; //pt break; case 'pk': $lang_name = 'Pakistan'; $country_name = 'PAKISTAN'; break; case 'pw': $country_name = 'Palau Island'; $lang_name = 'PALAU_ISLAND'; break; case 'ps': $country_name = 'Palestine'; $lang_name = 'PALESTINE'; break; case 'py': $country_name = 'PARAGUAY'; $lang_name = 'PARAGUAY'; break; case 'qa': $lang_name = 'Qatar'; $country_name = 'QATAR'; break; // rmn – Balkan Romani // rml – Baltic Romani // rmc – Carpathian Romani // rmf – Kalo Finnish Romani // rmo – Sinte Romani // rmy – Vlax Romani // rmw – Welsh Romani case 'ri': case 'rom': $country_name = 'EASTEN_EUROPE'; $lang_name = 'ROMANI'; break; case 'ro': $country_name = 'ROMANIA'; $lang_name = 'ROMANIAN'; break; case 'ro_md': case 'ro_MD': $country_name = 'ROMANIA'; $lang_name = 'ROMANIAN_MOLDAVIA'; break; case 'ro_ro': case 'ro_RO': $country_name = 'ROMANIA'; $lang_name = 'ROMANIAN_ROMANIA'; break; case 'rn': $lang_name = 'kirundi'; $country_name = ''; break; case 'rm': $country_name = ''; $lang_name = 'romansh'; //Switzerland break; case 'rs': $country_name = 'REPUBLIC_OF_SERBIA'; //????????? ?????? //Republika Srbija $lang_name = 'serbian'; //Serbia, ?????? / Srbija break; case 'ru': case 'ru_ru': case 'ru_RU': $country_name = 'RUSSIA'; $lang_name = 'RUSSIAN'; break; case 'rw': $country_name = 'RWANDA'; $lang_name = 'Rwanda'; break; case 'sa': $lang_name = 'arabic'; $country_name = 'SAUDI_ARABIA'; break; case 'sb': $lang_name = 'Solomon Islands'; $country_name = 'SOLOMON_ISLANDS'; break; case 'sc': $lang_name = 'seychellois-creole'; $country_name = 'SEYCHELLES'; break; case 'sco': $lang_name = 'SCOTISH'; $country_name = 'Scotland'; break; //scf – San Miguel Creole French (Panama) case 'scf': $lang_name = 'SAN_MIGUEL_CREOLE_FRENCH'; $country_name = 'SAN_MIGUEL'; break; case 'sd': $lang_name = 'Sudan'; $country_name = 'SUDAN'; break; case 'si': $lang_name = 'SLOVENIAN'; $country_name = 'SLOVENIA'; break; case 'sh': $lang_name = 'SH'; $country_name = 'ST_HELENA'; break; case 'sk': $country_name = 'SLOVAKIA'; $lang_name = 'Slovakia'; break; case 'sg': $country_name = 'SINGAPORE'; $lang_name = 'Singapore'; break; case 'sl': $country_name = 'SIERRA_LEONE'; $lang_name = 'Sierra Leone'; break; case 'sm': $lang_name = 'San Marino'; $country_name = 'SAN_MARINO'; break; case 'smi': $lang_name = 'Sami'; $country_name = 'Norway'; //Native to Finland, Norway, Russia, and Sweden break; case 'sn': $lang_name = 'Senegal'; $country_name = 'SENEGAL'; break; case 'so': $lang_name = 'Somalia'; $country_name = 'SOMALIA'; break; case 'sq': $lang_name = 'ALBANIAN'; $country_name = 'Albania'; break; case 'sr': $lang_name = 'Suriname'; $country_name = 'SURINAME'; break; case 'ss': $lang_name = ''; //Bari [Karo or Kutuk ('mother tongue', Beri)], Dinka, Luo, Murle, Nuer, Zande $country_name = 'REPUBLIC_OF_SOUTH_SUDAN'; break; case 'sse': $lang_name = 'STANDARD_SCOTTISH_ENGLISH'; $country_name = 'Scotland'; break; case 'st': $lang_name = 'Sao Tome & Principe'; $country_name = 'SAO_TOME_&_PRINCIPE'; break; case 'sv': $lang_name = 'El Salvador'; $country_name = 'EL_SALVADOR'; break; case 'sx': $lang_name = 'dutch'; $country_name = 'SINT_MAARTEN_(DUTCH_PART)'; break; case 'sz': $lang_name = 'Swaziland'; $country_name = 'SWAZILAND'; break; case 'se': case 'sv-SE': case 'sv-se': //Swedish (Sweden) (sv-SE) $lang_name = 'Sweden'; $country_name = 'SWEDEN'; break; case 'sy': $lang_name = 'SYRIAC'; //arabic syrian $country_name = 'SYRIA'; break; //ISO 639-2 swa //ISO 639-3 swa – inclusive code //Individual codes: //swc – Congo Swahili //swh – Coastal Swahili //ymk – Makwe //wmw – Mwani //Person Mswahili //People Waswahili //Language Kiswahili case 'sw': $lang_name = 'SWAHILI'; $country_name = 'KENYA'; break; case 'swa': $lang_name = 'SWAHILI'; $country_name = 'AFRICAN_GREAT_LAKES'; break; //swa – inclusive code // //Individual codes: //swc – Congo Swahili case 'swc': $lang_name = 'CONGO_SWAHILI'; $country_name = 'CONGO'; break; //swh – Coastal Swahili case 'swh': $lang_name = 'COASTAL_SWAHILI'; $country_name = 'AFRIKA_EAST_COAST'; break; //ymk – Makwe case 'ymk': $lang_name = 'MAKWE'; $country_name = 'CABO_DELGADO_PROVINCE_OF_MOZAMBIQUE'; break; //wmw – Mwani case 'wmw': $lang_name = 'MWANI'; $country_name = 'COAST_OF_CABO_DELGADO_PROVINCE_OF_MOZAMBIQUE'; break; case 'tc': $lang_name = 'Turks & Caicos Is'; $country_name = 'TURKS_&_CAICOS_IS'; break; case 'td': $lang_name = 'Chad'; $country_name = 'CHAD'; break; case 'tf': $lang_name = 'french '; // $country_name = 'FRENCH_SOUTHERN_TERRITORIES'; //Terres australes françaises break; case 'tj': $lang_name = 'Tajikistan'; $country_name = 'TAJIKISTAN'; break; case 'tg': $lang_name = 'Togo'; $country_name = 'TOGO'; break; case 'th': $country_name = 'Thailand'; $lang_name = 'THAILAND'; break; case 'tk': //260 speakers of Tokelauan, of whom 2,100 live in New Zealand, //1,400 in Tokelau, //and 17 in Swains Island $lang_name = 'Tokelauan'; // /to?k?'la??n/ Tokelauans or Polynesians $country_name = 'TOKELAUAU'; //Dependent territory of New Zealand break; case 'tl': $country_name = 'East Timor'; $lang_name = 'East Timor'; break; case 'to': $country_name = 'Tonga'; $lang_name = 'TONGA'; break; case 'tt': $country_name = 'Trinidad & Tobago'; $lang_name = 'TRINIDAD_&_TOBAGO'; break; case 'tn': $lang_name = 'Tunisia'; $country_name = 'TUNISIA'; break; case 'tm': $lang_name = 'Turkmenistan'; $country_name = 'TURKMENISTAN'; break; case 'tr': $lang_name = 'Turkey'; $country_name = 'TURKEY'; break; case 'tv': $lang_name = 'Tuvalu'; $country_name = 'TUVALU'; break; case 'tw': $lang_name = 'TAIWANESE_HOKKIEN'; //Taibei Hokkien $country_name = 'TAIWAN'; break; case 'tz': $country_name = 'TANZANIA'; $lang_name = 'Tanzania'; break; case 'ug': $lang_name = 'Uganda'; $country_name = 'UGANDA'; break; case 'ua': $lang_name = 'Ukraine'; $country_name = 'UKRAINE'; break; case 'us': $lang_name = 'en-us'; $country_name = 'UNITED_STATES_OF_AMERICA'; break; case 'uz': $lang_name = 'uzbek'; //Uyghur Perso-Arabic alphabet $country_name = 'UZBEKISTAN'; break; case 'uy': $lang_name = 'Uruguay'; $country_name = 'URUGUAY'; break; case 'va': $country_name = 'VATICAN_CITY'; //Holy See $lang_name = 'latin'; break; case 'vc': $country_name = 'ST_VINCENT_&_GRENADINES'; // $lang_name = 'vincentian-creole'; break; case 've': $lang_name = 'Venezuela'; $country_name = 'VENEZUELA'; break; case 'vi': $lang_name = 'Virgin Islands (USA)'; $country_name = 'VIRGIN_ISLANDS_(USA)'; break; case 'fr_vn': $lang_name = 'FRENCH_VIETNAM'; $country_name = 'VIETNAM'; break; case 'vn': $lang_name = 'Vietnam'; $country_name = 'VIETNAM'; break; case 'vg': $lang_name = 'Virgin Islands (Brit)'; $country_name = 'VIRGIN_ISLANDS_(BRIT)'; break; case 'vu': $lang_name = 'Vanuatu'; $country_name = 'VANUATU'; break; case 'wls': $lang_name = 'WALLISIAN'; $country_name = 'WALES'; break; case 'wf': $country_name = 'TERRITORY_OF_THE_WALLIS_AND_FUTUNA_ISLANDS'; $lang_name = 'WF'; //Wallisian, or ‘Uvean //Futunan - Austronesian, Malayo-Polynesian break; case 'ws': $country_name = 'SAMOA'; $lang_name = 'Samoa'; break; case 'ye': $lang_name = 'Yemen'; $country_name = 'YEMEN'; break; case 'yt': $lang_name = 'Mayotte'; //Shimaore: $country_name = 'DEPARTMENT_OF_MAYOTTE'; //Département de Mayotte break; case 'za': $lang_name = 'zhuang'; $country_name = 'SOUTH_AFRICA'; break; case 'zm': $lang_name = 'zambian'; $country_name = 'ZAMBIA'; break; case 'zw': $lang_name = 'Zimbabwe'; $country_name = 'ZIMBABWE'; break; case 'zu': $lang_name = 'zulu'; $country_name = 'ZULU'; break; default: $lang_name = $file_dir; $country_name = $file_dir; break; } $return = ($lang_country == 'country') ? $country_name : $lang_name; $return = ($langs_countries == true) ? $lang_name[$country_name] : $return; return $return ; } /** * @param string $var The key to look for * @return bool True if $var is set */ public function is_set($var) { return isset($this -> $var); } /** * @return string The file or folder name */ public function __toString() { return $this -> filename; } /** * @return string The file extension of the file or folder name */ abstract public function file_ext(); } ?> classes/Language.php0000755000000000000000000001264214530557667011667 0ustar * @version 1.0.0 (January 01, 2006) * @package AutoIndex */ class Language { /** * @var ConfigData Contains the translation data from the language file */ private $translation_data; private $lang_file; /** * Returns a list of all files in $path that match the filename format * of language files. * * There are two valid formats for the filename of a language file. The * standard way is the language code then the .txt extension. You can * also use the language code followed by an underscore then the * country code. The second format would be used for dialects of * languages. For example pt.txt would be Portuguese, and pt_BR.txt * would be Brazilian Portuguese. The filenames are case insensitive. * * @param string $path The directory to read from * @return array The list of valid language files (based on filename) */ public static function get_all_langs($path) { if (($hndl = @opendir($path)) === false) { return false; } $list = array(); while (($file = readdir($hndl)) !== false) { if (@is_file($path . $file) && preg_match('/^[a-z]{2}(_[a-z]{2})?' . preg_quote(LANGUAGE_FILE_EXT, '/') . '$/i', $file)) { $list[] = $file; } } closedir($hndl); for ($i = 0; $i < count($list); $i++) { //remove the file extention from each language code $list[$i] = substr($list[$i], 0, -strlen(LANGUAGE_FILE_EXT)); } return $list; } /** * @return string The code for the language to load * * First tries to use the default of the user's browser, and then tries * the default in the config file. */ private function get_current_lang() { global $request; //try to detect the default language of the user's browser if (null !== $request->server('HTTP_ACCEPT_LANGUAGE')) //e.g. "en-us,en;q=0.5" //if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) //e.g. "en-us,en;q=0.5" { $available_langs = self::get_all_langs(PATH_TO_LANGUAGES); $accept_lang_ary = explode(',', $request->server('HTTP_ACCEPT_LANGUAGE')); if ($available_langs !== false) { $pref = array(); //user's preferred languages foreach ($accept_lang_ary as $lang) { $lang_array = explode(';q=', trim($lang)); $q = (isset($lang_array[1]) ? trim($lang_array[1]) : 1); //preference value $pref[trim($lang_array[0])] = (float) $q; } arsort($pref); //find the first match that is available: foreach ($pref as $lang => $q) { //replace line string to language file downscroll $lang = isset($_GET['lang']) ? str_replace('-', '_', $_GET['lang']) : str_replace('-', '_', $lang); if (file_exists(@realpath(PATH_TO_LANGUAGES . $lang . LANGUAGE_FILE_EXT))) { return $lang; } elseif (in_array($lang, $available_langs)) { return $lang; } } } } //the browser has no preferences set, so use the config's default global $config; return $config->__get('language'); } /** * Creates a new language object. First tries to use the default of * the user's browser, and then tries the default in the config file. */ public function __construct() { $this->lang_file = PATH_TO_LANGUAGES . $this->get_current_lang() . LANGUAGE_FILE_EXT; if (!@is_readable($this->lang_file)) { throw new ExceptionFatal('Cannot read from language file: ' . Url::html_output($lang_file) . ''); } //load the file as a tab-separated object $this->translation_data = new ConfigData($this->lang_file); } /** * @param string $name The word to look for * @return bool True if $name is set in the translation file */ public function is_set($name) { return $this->translation_data->is_set($name); } /** * @param string $var The key to look for (the keyword) * @return string The value $name points to (its translation) */ public function __get($var) { if ($this->translation_data->is_set($var)) { return $this->translation_data->__get($var); } print('Variable ' . Url::html_output($var) . ' not set in Language file'. $this->lang_file . '.'); throw new ExceptionDisplay('Variable ' . Url::html_output($var) . ' not set in Language file'. $this->lang_file . '.'); } } ?> classes/Logging.php0000755000000000000000000001004114530557667011521 0ustar * @version 1.0.1 (July 21, 2004) * @package AutoIndex */ class Logging { /** * @var string Filename of the log to write to */ private $filename; /** * @param string $filename The name of the log file */ public function __construct($filename) { $this->filename = $filename; } /** * Writes data to the log file. * * @param string $extra Any additional data to add in the last column of the entry */ public function add_entry($extra = '') { if (LOG_FILE) { $h = @fopen($this->filename, 'ab'); if ($h === false) { throw new ExceptionDisplay('Could not open log file for writing.' . ' Make sure PHP has write permission to this file.'); } global $dir, $ip, $host, $request; $referrer = (!$request->server('HTTP_REFERER') ? $request->server('HTTP_REFERER') : 'N/A'); fwrite($h, date(DATE_FORMAT) . "\t" . date('H:i:s') . "\t$ip\t$host\t$referrer\t$dir\t$extra\n"); fclose($h); } } /** * @param int $max_num_to_display */ public function display($max_num_to_display) { if (!@is_file($this->filename)) { throw new ExceptionDisplay('There are no entries in the log file.'); } $file_array = @file($this->filename); if ($file_array === false) { throw new ExceptionDisplay('Could not open log file for reading.'); } $count_log = count($file_array); $num = (($max_num_to_display == 0) ? $count_log : min($max_num_to_display, $count_log)); $out = "

Viewing $num (of $count_log) entries.

\n" . ' ' . '' . ' ' . ' ' . ' '; for ($i = 0; $i < $num; $i++) { $class = (($i % 2) ? 'dark_row' : 'light_row'); $out .= ''; $parts = explode("\t", rtrim($file_array[$count_log-$i-1], "\r\n"), 7); if (count($parts) !== 7) { throw new ExceptionDisplay('Incorrect format for log file on line ' . ($i + 1)); } for ($j = 0; $j < 7; $j++) { $cell = Url::html_output($parts[$j]); if ($j === 4 && $cell != 'N/A') { $cell = "$cell"; } $out .= '' : "$cell"); } $out .= "\n"; } global $words, $request; $out .= '
# DateTimeIP address HostnameReferrer DirectoryFile downloaded or other info
' . ($i + 1) . '' . (($cell == '') ? ' 

' . $words->__get('continue') . '.

'; echo new Display($out); die(); } } ?> classes/MimeType.php0000755000000000000000000001777614524237611011675 0ustar * @version 1.0.1 (February 09, 2005) * @package AutoIndex */ class MimeType { /** * @var string The filename's MIME-type */ private $mime; /** * @var string The default MIME-type to return */ private $default_type; /** * Given a file extension, this will come up with the file's appropriate * MIME-type. * * @param string $ext The file extension to find the MIME-type for * @return string The appropriate MIME-type depending on the extension */ private function find_mime_type($ext) { static $mime_types = array( 'application/andrew-inset' => array('ez'), 'application/mac-binhex40' => array('hqx'), 'application/mac-compactpro' => array('cpt'), 'application/mathml+xml' => array('mathml'), 'application/msword' => array('doc'), 'application/msoffice' => array('docx'), 'application/octet-stream' => array('bin', 'dms', 'dmg', 'ocx', 'sys', 'drv', 'so'), 'application/windows-executable' => array('exe'), 'application/windows-dll' => array('dll', 'vxd'), 'application/system-class' => array('class'), 'application/archive-lzh' => array('lha', 'lzh'), 'application/oda' => array('oda'), 'application/ogg' => array('ogg'), 'application/pdf' => array('pdf'), 'application/postscript' => array('ai', 'eps', 'ps'), 'application/rdf+xml' => array('rdf'), 'application/smil' => array('smi', 'smil'), 'application/srgs' => array('gram'), 'application/srgs+xml' => array('grxml'), 'application/vnd.mif' => array('mif'), 'application/vnd.mozilla.xul+xml' => array('xul'), 'application/vnd.ms-excel' => array('xls'), 'application/vnd.ms-powerpoint' => array('ppt'), 'application/vnd.wap.wbxml' => array('wbxml'), 'application/vnd.wap.wmlc' => array('wmlc'), 'application/vnd.wap.wmlscriptc' => array('wmlsc'), 'application/voicexml+xml' => array('vxml'), 'application/x-bcpio' => array('bcpio'), 'application/x-cdlink' => array('vcd'), 'application/x-chess-pgn' => array('pgn'), 'application/x-cpio' => array('cpio'), 'application/x-csh' => array('csh'), 'application/x-director' => array('dcr', 'dir', 'dxr'), 'application/x-dvi' => array('dvi'), 'application/x-futuresplash' => array('spl'), 'application/x-gtar' => array('gtar'), 'application/x-hdf' => array('hdf'), 'application/x-javascript' => array('js'), 'application/x-koan' => array('skp', 'skd', 'skt', 'skm'), 'application/x-latex' => array('latex'), 'application/x-netcdf' => array('nc', 'cdf'), 'application/x-sh' => array('sh'), 'application/x-shar' => array('shar'), 'application/x-shockwave-flash' => array('swf'), 'application/x-stuffit' => array('sit'), 'application/x-sv4cpio' => array('sv4cpio'), 'application/x-sv4crc' => array('sv4crc'), 'application/x-tar' => array('tar'), 'application/x-tcl' => array('tcl'), 'application/x-tex' => array('tex'), 'application/x-texinfo' => array('texinfo', 'texi'), 'application/x-troff' => array('t', 'tr', 'roff'), 'application/x-troff-man' => array('man'), 'text/documentation' => array('md'), 'application/x-troff-me' => array('me'), 'application/x-troff-ms' => array('ms'), 'application/x-ustar' => array('ustar'), 'application/x-wais-source' => array('src'), 'application/xhtml+xml' => array('xhtml', 'xht'), 'application/xslt+xml' => array('xslt'), 'application/xml' => array('xml', 'xsl'), 'application/xml-dtd' => array('dtd'), 'application/zip' => array('zip'), 'audio/basic' => array('au', 'snd'), 'audio/midi' => array('mid', 'midi', 'kar'), 'audio/mpeg' => array('mpga', 'mp2', 'mp3'), 'audio/x-aiff' => array('aif', 'aiff', 'aifc'), 'audio/x-mpegurl' => array('m3u'), 'audio/x-pn-realaudio' => array('ram', 'ra'), 'application/vnd.rn-realmedia' => array('rm'), 'audio/x-wav' => array('wav'), 'chemical/x-pdb' => array('pdb'), 'chemical/x-xyz' => array('xyz'), 'image/bmp' => array('bmp'), 'image/cgm' => array('cgm'), 'image/gif' => array('gif'), 'image/ief' => array('ief'), 'image/jpeg' => array('jpeg', 'jpg', 'jpe'), 'image/png' => array('png'), 'image/svg+xml' => array('svg'), 'font/fnt' => array('fnt', 'bdf'), 'font/fon' => array('fon'), 'font/ttf' => array('ttf'), 'font/otf' => array('otf'), 'font/sfd' => array('sfd'), 'font/afm' => array('afm'), 'font/eot' => array('eot'), 'font/woff' => array('woff'), 'font/woff2' => array('woff2'), 'image/tiff' => array('tiff', 'tif'), 'image/vnd.djvu' => array('djvu', 'djv'), 'image/vnd.wap.wbmp' => array('wbmp'), 'image/x-cmu-raster' => array('ras'), 'image/x-icon' => array('ico'), 'image/x-portable-anymap' => array('pnm'), 'image/x-portable-bitmap' => array('pbm'), 'image/x-portable-graymap' => array('pgm'), 'image/x-portable-pixmap' => array('ppm'), 'image/x-rgb' => array('rgb'), 'image/x-xbitmap' => array('xbm'), 'image/x-xpixmap' => array('xpm'), 'image/x-xwindowdump' => array('xwd'), 'model/iges' => array('igs', 'iges'), 'model/mesh' => array('msh', 'mesh', 'silo'), 'model/vrml' => array('wrl', 'vrml'), 'text/calendar' => array('ics', 'ifb'), 'text/css' => array('css'), 'text/html' => array('html', 'htm'), 'text/plain' => array('asc', 'txt'), 'text/richtext' => array('rtx'), 'text/rtf' => array('rtf'), 'text/sgml' => array('sgml', 'sgm'), 'text/tab-separated-values' => array('tsv'), 'text/vnd.wap.wml' => array('wml'), 'text/vnd.wap.wmlscript' => array('wmls'), 'text/x-setext' => array('etx'), 'video/mpeg' => array('mpg', 'mpeg', 'mpe'), 'video/quicktime' => array('qt', 'mov'), //QuickTime 'video/vnd.mpegurl' => array('mxu', 'm4u'), 'video/x-msvideo' => array('avi', 'mkv', 'xvid'), //A/V Interleave 'video/x-flv' => array('flv'), //Flash Video 'video/mp4' => array('mp4'), //MPEG-4 'application/x-mpegURL' => array('mpu'), //iPhone Index 'video/MP2T' => array('mp2t'), //iPhone Segment 'video/3gpp' => array('3gpp'), //3GP Mobile 'video/x-ms-wmv' => array('wmv'), //Windows Media 'video/x-sgi-movie' => array('sgi'), 'x-conference/x-cooltalk' => array('ice') ); foreach ($mime_types as $mime_type => $exts) { if (in_array($ext, $exts)) { return $mime_type; } } return $this->default_type; } /** * @param string $filename The filename to find the MIME-type for * @param string $default_type The default MIME-type to return */ public function __construct($filename, $default_type = 'text/plain') { $this->default_type = $default_type; $this->mime = $this->find_mime_type(FileItem::ext($filename)); } /** * @return string */ public function __toString() { return $this->mime; } } ?> classes/MobileDeviceDetect.php0000755000000000000000000006377014576072531013624 0ustar cache = $cache; $this->request = $request; $this->language = $words; if(empty($ua)) { $this->_user_agent = $request->server('HTTP_USER_AGENT'); } else { $this->_user_agent = $ua; } //$this->_user_agent = (!empty($_SERVER['HTTP_USER_AGENT'])) ? htmlspecialchars((string) $_SERVER['HTTP_USER_AGENT']) : ''; } /** * @package Mobile Device Detect class * @author FlorinCB aka orynider * @copyright (c) 2015 Sniper_E - http://www.sniper-e.com * @copyright (c) 2015 dmzx - http://www.dmzx-web.net * @copyright (c) 2015 martin - http://www.martins-phpbb.com * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 */ public function mobile_device_detect($iphone = true, $ipod = true, $ipad = true, $android = true, $opera = true, $blackberry = true, $palm = true, $windows = true, $lg = true) { $mobile_browser = false; switch (true) { case (preg_match('/x86_64|WOW64|Win64|Iceweasel/i', $this->_user_agent)); $status = $this->language->__get('DESKTOP'); $mobile_browser = true; break; case (preg_match('/Bot|CFNetwork|libwww|Java|Jigsaw|SpreadTrum|httpget/i', $this->_user_agent)); $mobile_browser = false; break; case (preg_match('/ipad/i',$this->_user_agent)); $status = $this->language->__get('IPAD'); $mobile_browser = $ipad; break; case (preg_match('/ipod/i',$this->_user_agent)); $status = $this->language->__get('IPOD'); $mobile_browser = $ipod; break; case (preg_match('/iphone/i', $this->_user_agent)); $status = $this->language->__get('IPHONE'); $mobile_browser = $iphone; break; case (preg_match('/android/i', $this->_user_agent)); if (preg_match('/SM-G870A/i', $this->_user_agent)) { $status = $this->language->__get('SGS5A'); } else if (preg_match('/SM-G900A|SM-G900F|SM-G900H|SM-G900M|SM-G900P|SM-G900R4|SM-G900T|SM-G900V|SM-G900W8|SM-G800F/i', $this->_user_agent)) { $status = $this->language->__get('SGS5'); } else if (preg_match('/SM-G920F/i', $this->_user_agent)) { $status = $this->language->__get('SGS6'); } else if (preg_match('/SGH-I497/i', $this->_user_agent)) { $status = $this->language->__get('SG2T'); } else if (preg_match('/GT-P5210|SM-T110|SM-T310/i', $this->_user_agent)) { $status = $this->language->__get('SGT3'); } else if (preg_match('/SM-T210/i', $this->_user_agent)) { $status = $this->language->__get('SGT3W'); } else if (preg_match('/SM-T335|SM-T530/i', $this->_user_agent)) { $status = $this->language->__get('SGT4'); } else if (preg_match('/SM-T520/i', $this->_user_agent)) { $status = $this->language->__get('SGTP'); } else if (preg_match('/SGH-I537/i', $this->_user_agent)) { $status = $this->language->__get('SGS4A'); } else if (preg_match('/GT-I9505|GT-I9500|SPH-L720T/i', $this->_user_agent)) { $status = $this->language->__get('SGS4'); } else if (preg_match('/GT-I9100P/i', $this->_user_agent)) { $status = $this->language->__get('SGS2'); } else if (preg_match('/SM-N9005|SM-P600/i', $this->_user_agent)) { $status = $this->language->__get('SGN3'); } else if (preg_match('/SM-N7505/i', $this->_user_agent)) { $status = $this->language->__get('SGN3N'); } else if (preg_match('/SM-N910C|SM-N910F/i', $this->_user_agent)) { $status = $this->language->__get('SGN4'); } else if (preg_match('/SM-N920P/i', $this->_user_agent)) { $status = $this->language->__get('SGN5'); } else if (preg_match('/SM-G357FZ/i', $this->_user_agent)) { $status = $this->language->__get('SGA4'); } else if (preg_match('/SM-G925P/i', $this->_user_agent)) { $status = $this->language->__get('SGS6E'); } else if (preg_match('/SM-G935F/i', $this->_user_agent)) { $status = $this->language->__get('SGS7E'); } else if (preg_match('/SM-G950F|SM-G955F/i', $this->_user_agent)) { $status = $this->language->__get('SGS8'); } else if (preg_match('/GT-S7582/i', $this->_user_agent)) { $status = $this->language->__get('SGSD2'); } else if (preg_match('/GT-I9100P/i', $this->_user_agent)) { $status = $this->language->__get('SGS2'); } else if (preg_match('/HONORPLK-L01/i',$user_agent)) { $status = $this->language->__get('HPL01'); } else if (preg_match('/EVA-L09/i', $this->_user_agent)) { $status = $this->language->__get('HPL09'); } else if (preg_match('/VNS-L23/i', $this->_user_agent)) { $status = $this->language->__get('HPL23'); } else if (preg_match('/IMM76B/i', $this->_user_agent)) { $status = $this->language->__get('SGN'); } else if (preg_match('/TF101/i', $this->_user_agent)) { $status = $this->language->__get('ATT'); } else if (preg_match('/Archos 40b/i', $this->_user_agent)) { $status = $this->language->__get('A4TS'); } else if (preg_match('/A0001/i', $this->_user_agent)) { $status = $this->language->__get('OPO'); } else if (preg_match('/Orange Nura/i', $this->_user_agent)) { $status = $this->language->__get('ORN'); } else if (preg_match('/XT1030/i', $this->_user_agent)) { $status = $this->language->__get('MDM'); } else if (preg_match('/TIANYU-KTOUCH/i', $this->_user_agent)) { $status = $this->language->__get('TKT'); } else if (preg_match('/D2005|D2105/i',$user_agent)) { $status = $this->language->__get('SXED'); } else if (preg_match('/C2005|D2303/i', $this->_user_agent)) { $status = $this->language->__get('SXM2'); } else if (preg_match('/C6906/i', $this->_user_agent)) { $status = $this->language->__get('SXZ1'); } else if (preg_match('/D5803/i', $this->_user_agent)) { $status = $this->language->__get('SXZ3'); } else if (preg_match('/P710/i', $this->_user_agent)) { $status = $this->language->__get('LGOL7IT'); } else if (preg_match('/LG-H850/i', $this->_user_agent)) { $status = $this->language->__get('LGH850'); } else if (preg_match('/LG-V500/i', $this->_user_agent)) { $status = $this->language->__get('LGV500'); } else if (preg_match('/lg/i', $this->_user_agent)) { $status = $this->language->__get('LG'); } else if (preg_match('/ASUS_T00J/i', $this->_user_agent)) { $status = $this->language->__get('ATOOJ'); } else if (preg_match('/Aquaris E5/i', $this->_user_agent)) { $status = $this->language->__get('AE5HD'); } else if (preg_match('/HTC Desire|626s/i', $this->_user_agent)) { $status = $this->language->__get('HTCD'); } else if (preg_match('/Nexus One/i', $this->_user_agent)) { $status = $this->language->__get('N1'); } else if (preg_match('/Nexus 4|LRX22C|LVY48F|LMY47V/i', $this->_user_agent)) { $status = $this->language->__get('N4'); } else if (preg_match('/Nexus 5|LMY48S/i', $this->_user_agent)) { $status = $this->language->__get('N5'); } else if (preg_match('/Nexus 7|KTU84P/i', $this->_user_agent)) { $status = $this->language->__get('N7'); } else if (preg_match('/Nexus 9|LMY47X/i',$user_agent)) { $status = $this->language->__get('N9'); } else if (preg_match('/Lenovo_K50_T5/i', $this->_user_agent)) { $status = $this->language->__get('LK50T5'); } else { $status = $this->language->__get('ANDROID'); } $mobile_browser = $android; break; case (preg_match('/opera mini/i', $this->_user_agent)); $status = $this->language->__get('MOBILE_DEVICE'); $mobile_browser = $opera; break; case (preg_match('/blackberry/i', $this->_user_agent)); if (preg_match('/BlackBerry9900|BlackBerry9930|BlackBerry9790|BlackBerry9780|BlackBerry9700|BlackBerry9650|BlackBerry9000|/i',$user_agent)) { $status = 'BlackBerry Bold'; } else if (preg_match('/BlackBerry9380|BlackBerry9370|BlackBerry9360|BlackBerry9350|BlackBerry9330|BlackBerry9320|BlackBerry9300|BlackBerry9220|BlackBerry8980|BlackBerry8900|BlackBerry8530|BlackBerry8520|BlackBerry8330|BlackBerry8320|BlackBerry8310|BlackBerry8300/i',$user_agent)) { $status = $this->language->__get('BBCURVE'); } else if (preg_match('/BlackBerry9860|BlackBerry9850|BlackBerry9810|BlackBerry9800/i', $this->_user_agent)) { $status = $this->language->__get('BBTORCH'); } else if (preg_match('/BlackBerry9900/i', $this->_user_agent)) { $status = $this->language->__get('BBTOUCH'); } else if (preg_match('/BlackBerry9105/i', $this->_user_agent)) { $status = $this->language->__get('BBPEARL'); } else if (preg_match('/BlackBerry8220/i', $this->_user_agent)) { $status = $this->language->__get('BBPEARLF'); } else if (preg_match('/BlackBerry Storm|BlackBerry Storm2/i', $this->_user_agent)) { $status = $this->language->__get('BBSTORM'); } else if (preg_match('/BlackBerry Passport/i', $this->_user_agent)) { $status = $this->language->__get('BBPP'); } else if (preg_match('/BlackBerry Porsche/i',$user_agent)) { $status = $this->language->__get('BBP'); } else if (preg_match('/BlackBerry PlayBook/i', $this->_user_agent)) { $status = $this->language->__get('BBPB'); } else { $status = $this->language->__get('BLACKBERRY'); } $mobile_browser = $blackberry; break; case (preg_match('/(pre\/|palm os|palm|hiptop|avantgo|plucker|xiino|blazer|elaine)/i', $this->_user_agent)); $status = $this->language->__get('PALM'); $mobile_browser = $palm; break; case (preg_match('/(iris|3g_t|windows ce|windows Phone|opera mobi|windows ce; smartphone;|windows ce; iemobile)/i', $this->_user_agent)); if (preg_match('/Lumia 640 XL/i', $this->_user_agent)) { $status = $this->language->__get('L640XL'); } else { $status = $this->language->__get('WSP'); } $mobile_browser = $windows; break; case (preg_match('/lge vx10000/i', $this->_user_agent)); $status = $this->language->__get('VOYAGER'); $mobile_browser = $windows; break; case (preg_match('/(mini 9.5|vx1000|lge |m800|e860|u940|ux840|compal|wireless| mobi|ahong|lg380|lgku|lgu900|lg210|lg47|lg920|lg840|lg370|sam-r|mg50|s55|g83|t66|vx400|mk99|d615|d763|el370|sl900|mp500|samu3|samu4|vx10|xda_|samu5|samu6|samu7|samu9|a615|b832|m881|s920|n210|s700|c-810|_h797|mob-x|sk16d|848b|mowser|s580|r800|471x|v120|rim8|c500foma:|160x|x160|480x|x640|t503|w839|i250|sprint|w398samr810|m5252|c7100|mt126|x225|s5330|s820|htil-g1|fly v71|s302|-x113|novarra|k610i|-three|8325rc|8352rc|sanyo|vx54|c888|nx250|n120|mtk |c5588|s710|t880|c5005|i;458x|p404i|s210|c5100|teleca|s940|c500|s590|foma|samsu|vx8|vx9|a1000|_mms|myx|a700|gu1100|bc831|e300|ems100|me701|me702m-three|sd588|s800|8325rc|ac831|mw200|brew |d88|htc\/|htc_touch|355x|m50|km100|d736|p-9521|telco|sl74|ktouch|m4u\/|me702|8325rc|kddi|phone|lg |sonyericsson|samsung|240x|x320|vx10|nokia|sony cmd|motorola|up.browser|up.link|mmp|symbian|smartphone|midp|wap|vodafone|o2|pocket|kindle|mobile|psp|treo)/i', $this->_user_agent)); $status = $this->language->__get('MOBILE_DEVICE'); $mobile_browser = true; break; case (isset($post['HTTP_X_WAP_PROFILE']) || isset($post['HTTP_PROFILE'])); $status = $this->language->__get('MOBILE_DEVICE'); $mobile_browser = true; break; case (in_array(strtolower(substr($this->_user_agent, 0, 4)), array('1207'=>'1207','3gso'=>'3gso','4thp'=>'4thp','501i'=>'501i','502i'=>'502i','503i'=>'503i','504i'=>'504i','505i'=>'505i','506i'=>'506i','6310'=>'6310','6590'=>'6590','770s'=>'770s','802s'=>'802s','a wa'=>'a wa','acer'=>'acer','acs-'=>'acs-','airn'=>'airn','alav'=>'alav','asus'=>'asus','attw'=>'attw','au-m'=>'au-m','aur '=>'aur ','aus '=>'aus ','abac'=>'abac','acoo'=>'acoo','aiko'=>'aiko','alco'=>'alco','alca'=>'alca','amoi'=>'amoi','anex'=>'anex','anny'=>'anny','anyw'=>'anyw','aptu'=>'aptu','arch'=>'arch','argo'=>'argo','bell'=>'bell','bird'=>'bird','bw-n'=>'bw-n','bw-u'=>'bw-u','beck'=>'beck','benq'=>'benq','bilb'=>'bilb','blac'=>'blac','c55/'=>'c55/','cdm-'=>'cdm-','chtm'=>'chtm','capi'=>'capi','cond'=>'cond','craw'=>'craw','dall'=>'dall','dbte'=>'dbte','dc-s'=>'dc-s','dica'=>'dica','ds-d'=>'ds-d','ds12'=>'ds12','dait'=>'dait','devi'=>'devi','dmob'=>'dmob','doco'=>'doco','dopo'=>'dopo','el49'=>'el49','erk0'=>'erk0','esl8'=>'esl8','ez40'=>'ez40','ez60'=>'ez60','ez70'=>'ez70','ezos'=>'ezos','ezze'=>'ezze','elai'=>'elai','emul'=>'emul','eric'=>'eric','ezwa'=>'ezwa','fake'=>'fake','fly-'=>'fly-','fly_'=>'fly_','g-mo'=>'g-mo','g1 u'=>'g1 u','g560'=>'g560','gf-5'=>'gf-5','grun'=>'grun','gene'=>'gene','go.w'=>'go.w','good'=>'good','grad'=>'grad','hcit'=>'hcit','hd-m'=>'hd-m','hd-p'=>'hd-p','hd-t'=>'hd-t','hei-'=>'hei-','hp i'=>'hp i','hpip'=>'hpip','hs-c'=>'hs-c','htc '=>'htc ','htc-'=>'htc-','htca'=>'htca','htcg'=>'htcg','htcp'=>'htcp','htcs'=>'htcs','htct'=>'htct','htc_'=>'htc_','haie'=>'haie','hita'=>'hita','huaw'=>'huaw','hutc'=>'hutc','i-20'=>'i-20','i-go'=>'i-go','i-ma'=>'i-ma','i230'=>'i230','iac'=>'iac','iac-'=>'iac-','iac/'=>'iac/','ig01'=>'ig01','im1k'=>'im1k','inno'=>'inno','iris'=>'iris','jata'=>'jata','java'=>'java','kddi'=>'kddi','kgt'=>'kgt','kgt/'=>'kgt/','kpt '=>'kpt ','kwc-'=>'kwc-','klon'=>'klon','lexi'=>'lexi','lg g'=>'lg g','lg-a'=>'lg-a','lg-b'=>'lg-b','lg-c'=>'lg-c','lg-d'=>'lg-d','lg-f'=>'lg-f','lg-g'=>'lg-g','lg-k'=>'lg-k','lg-l'=>'lg-l','lg-m'=>'lg-m','lg-o'=>'lg-o','lg-p'=>'lg-p','lg-s'=>'lg-s','lg-t'=>'lg-t','lg-u'=>'lg-u','lg-w'=>'lg-w','lg/k'=>'lg/k','lg/l'=>'lg/l','lg/u'=>'lg/u','lg50'=>'lg50','lg54'=>'lg54','lge-'=>'lge-','lge/'=>'lge/','lynx'=>'lynx','leno'=>'leno','m1-w'=>'m1-w','m3ga'=>'m3ga','m50/'=>'m50/','maui'=>'maui','mc01'=>'mc01','mc21'=>'mc21','mcca'=>'mcca','medi'=>'medi','meri'=>'meri','mio8'=>'mio8','mioa'=>'mioa','mo01'=>'mo01','mo02'=>'mo02','mode'=>'mode','modo'=>'modo','mot '=>'mot ','mot-'=>'mot-','mt50'=>'mt50','mtp1'=>'mtp1','mtv '=>'mtv ','mate'=>'mate','maxo'=>'maxo','merc'=>'merc','mits'=>'mits','mobi'=>'mobi','motv'=>'motv','mozz'=>'mozz','n100'=>'n100','n101'=>'n101','n102'=>'n102','n202'=>'n202','n203'=>'n203','n300'=>'n300','n302'=>'n302','n500'=>'n500','n502'=>'n502','n505'=>'n505','n700'=>'n700','n701'=>'n701','n710'=>'n710','nec-'=>'nec-','nem-'=>'nem-','newg'=>'newg','neon'=>'neon','netf'=>'netf','noki'=>'noki','nzph'=>'nzph','o2 x'=>'o2 x','o2-x'=>'o2-x','opwv'=>'opwv','owg1'=>'owg1','opti'=>'opti','oran'=>'oran','p800'=>'p800','pand'=>'pand','pg-1'=>'pg-1','pg-2'=>'pg-2','pg-3'=>'pg-3','pg-6'=>'pg-6','pg-8'=>'pg-8','pg-c'=>'pg-c','pg13'=>'pg13','phil'=>'phil','pn-2'=>'pn-2','pt-g'=>'pt-g','palm'=>'palm','pana'=>'pana','pire'=>'pire','pock'=>'pock','pose'=>'pose','psio'=>'psio','qa-a'=>'qa-a','qc-2'=>'qc-2','qc-3'=>'qc-3','qc-5'=>'qc-5','qc-7'=>'qc-7','qc07'=>'qc07','qc12'=>'qc12','qc21'=>'qc21','qc32'=>'qc32','qc60'=>'qc60','qci-'=>'qci-','qwap'=>'qwap','qtek'=>'qtek','r380'=>'r380','r600'=>'r600','raks'=>'raks','rim9'=>'rim9','rove'=>'rove','s55/'=>'s55/','sage'=>'sage','sams'=>'sams','sc01'=>'sc01','sch-'=>'sch-','scp-'=>'scp-','sdk/'=>'sdk/','se47'=>'se47','sec-'=>'sec-','sec0'=>'sec0','sec1'=>'sec1','semc'=>'semc','sgh-'=>'sgh-','shar'=>'shar','sie-'=>'sie-','sk-0'=>'sk-0','sl45'=>'sl45','slid'=>'slid','smb3'=>'smb3','smt5'=>'smt5','sp01'=>'sp01','sph-'=>'sph-','spv '=>'spv ','spv-'=>'spv-','sy01'=>'sy01','samm'=>'samm','sany'=>'sany','sava'=>'sava','scoo'=>'scoo','send'=>'send','siem'=>'siem','smar'=>'smar','smit'=>'smit','soft'=>'soft','sony'=>'sony','t-mo'=>'t-mo','t218'=>'t218','t250'=>'t250','t600'=>'t600','t610'=>'t610','t618'=>'t618','tcl-'=>'tcl-','tdg-'=>'tdg-','telm'=>'telm','tim-'=>'tim-','ts70'=>'ts70','tsm-'=>'tsm-','tsm3'=>'tsm3','tsm5'=>'tsm5','tx-9'=>'tx-9','tagt'=>'tagt','talk'=>'talk','teli'=>'teli','topl'=>'topl','hiba'=>'hiba','up.b'=>'up.b','upg1'=>'upg1','utst'=>'utst','v400'=>'v400','v750'=>'v750','veri'=>'veri','vk-v'=>'vk-v','vk40'=>'vk40','vk50'=>'vk50','vk52'=>'vk52','vk53'=>'vk53','vm40'=>'vm40','vx98'=>'vx98','virg'=>'virg','vite'=>'vite','voda'=>'voda','vulc'=>'vulc','w3c '=>'w3c ','w3c-'=>'w3c-','wapj'=>'wapj','wapp'=>'wapp','wapu'=>'wapu','wapm'=>'wapm','wig '=>'wig ','wapi'=>'wapi','wapr'=>'wapr','wapv'=>'wapv','wapy'=>'wapy','wapa'=>'wapa','waps'=>'waps','wapt'=>'wapt','winc'=>'winc','winw'=>'winw','wonu'=>'wonu','x700'=>'x700','xda2'=>'xda2','xdag'=>'xdag','yas-'=>'yas-','your'=>'your','zte-'=>'zte-','zeto'=>'zeto','acs-'=>'acs-','alav'=>'alav','alca'=>'alca','amoi'=>'amoi','aste'=>'aste','audi'=>'audi','avan'=>'avan','benq'=>'benq','bird'=>'bird','blac'=>'blac','blaz'=>'blaz','brew'=>'brew','brvw'=>'brvw','bumb'=>'bumb','ccwa'=>'ccwa','cell'=>'cell','cldc'=>'cldc','cmd-'=>'cmd-','dang'=>'dang','doco'=>'doco','eml2'=>'eml2','eric'=>'eric','fetc'=>'fetc','hipt'=>'hipt','http'=>'http','ibro'=>'ibro','idea'=>'idea','ikom'=>'ikom','inno'=>'inno','ipaq'=>'ipaq','jbro'=>'jbro','jemu'=>'jemu','java'=>'java','jigs'=>'jigs','kddi'=>'kddi','keji'=>'keji','kyoc'=>'kyoc','kyok'=>'kyok','leno'=>'leno','lg-c'=>'lg-c','lg-d'=>'lg-d','lg-g'=>'lg-g','lge-'=>'lge-','libw'=>'libw','m-cr'=>'m-cr','maui'=>'maui','maxo'=>'maxo','midp'=>'midp','mits'=>'mits','mmef'=>'mmef','mobi'=>'mobi','mot-'=>'mot-','moto'=>'moto','mwbp'=>'mwbp','mywa'=>'mywa','nec-'=>'nec-','newt'=>'newt','nok6'=>'nok6','noki'=>'noki','o2im'=>'o2im','opwv'=>'opwv','palm'=>'palm','pana'=>'pana','pant'=>'pant','pdxg'=>'pdxg','phil'=>'phil','play'=>'play','pluc'=>'pluc','port'=>'port','prox'=>'prox','qtek'=>'qtek','qwap'=>'qwap','rozo'=>'rozo','sage'=>'sage','sama'=>'sama','sams'=>'sams','sany'=>'sany','sch-'=>'sch-','sec-'=>'sec-','send'=>'send','seri'=>'seri','sgh-'=>'sgh-','shar'=>'shar','sie-'=>'sie-','siem'=>'siem','smal'=>'smal','smar'=>'smar','sony'=>'sony','sph-'=>'sph-','symb'=>'symb','t-mo'=>'t-mo','teli'=>'teli','tim-'=>'tim-','tosh'=>'tosh','treo'=>'treo','tsm-'=>'tsm-','upg1'=>'upg1','upsi'=>'upsi','vk-v'=>'vk-v','voda'=>'voda','vx52'=>'vx52','vx53'=>'vx53','vx60'=>'vx60','vx61'=>'vx61','vx70'=>'vx70','vx80'=>'vx80','vx81'=>'vx81','vx83'=>'vx83','vx85'=>'vx85','wap-'=>'wap-','wapa'=>'wapa','wapi'=>'wapi','wapp'=>'wapp','wapr'=>'wapr','webc'=>'webc','whit'=>'whit','winw'=>'winw','wmlb'=>'wmlb','xda-'=>'xda-',))); $status = $this->language->__get('MOBILE_DEVICE'); $mobile_browser = true; break; default; $status = $this->language->__get('DESKTOP'); $mobile_browser = false; break; } //@header('Cache-Control: no-transform'); //@header('Vary: User-Agent'); if ($status == '') { return $mobile_browser; } elseif ($mobile_browser == '') { return $status; } else { return array($mobile_browser, $status); } } private $_basic_browser = array ( 'Trident\/7.0' => 'Internet Explorer 11', 'Beamrise' => 'Beamrise', 'Opera' => 'Opera', 'OPR' => 'Opera', 'Shiira' => 'Shiira', 'Chimera' => 'Chimera', 'Phoenix' => 'Phoenix', 'Firebird' => 'Firebird', 'Camino' => 'Camino', 'Netscape' => 'Netscape', 'OmniWeb' => 'OmniWeb', 'Konqueror' => 'Konqueror', 'icab' => 'iCab', 'Lynx' => 'Lynx', 'Links' => 'Links', 'hotjava' => 'HotJava', 'amaya' => 'Amaya', 'IBrowse' => 'IBrowse', 'iTunes' => 'iTunes', 'Silk' => 'Silk', 'Dillo' => 'Dillo', 'Maxthon' => 'Maxthon', 'Arora' => 'Arora', 'Galeon' => 'Galeon', 'Iceape' => 'Iceape', 'Iceweasel' => 'Iceweasel', 'Midori' => 'Midori', 'QupZilla' => 'QupZilla', 'Namoroka' => 'Namoroka', 'NetSurf' => 'NetSurf', 'BOLT' => 'BOLT', 'EudoraWeb' => 'EudoraWeb', 'shadowfox' => 'ShadowFox', 'Swiftfox' => 'Swiftfox', 'Uzbl' => 'Uzbl', 'UCBrowser' => 'UCBrowser', 'Kindle' => 'Kindle', 'wOSBrowser' => 'wOSBrowser', 'Epiphany' => 'Epiphany', 'SeaMonkey' => 'SeaMonkey', 'Avant Browser' => 'Avant Browser', 'Firefox' => 'Firefox', 'Chrome' => 'Google Chrome', 'MSIE' => 'Internet Explorer', 'Internet Explorer' => 'Internet Explorer', 'Safari' => 'Safari', 'Mozilla' => 'Mozilla' ); private $_basic_platform = array( 'windows' => 'Windows', 'iPad' => 'iPad', 'iPod' => 'iPod', 'iPhone' => 'iPhone', 'mac' => 'Apple', 'android' => 'Android', 'linux' => 'Linux', 'Nokia' => 'Nokia', 'BlackBerry' => 'BlackBerry', 'FreeBSD' => 'FreeBSD', 'OpenBSD' => 'OpenBSD', 'NetBSD' => 'NetBSD', 'UNIX' => 'UNIX', 'DragonFly' => 'DragonFlyBSD', 'OpenSolaris' => 'OpenSolaris', 'SunOS' => 'SunOS', 'OS\/2' => 'OS/2', 'BeOS' => 'BeOS', 'win' => 'Windows', 'Dillo' => 'Linux', 'PalmOS' => 'PalmOS', 'RebelMouse' => 'RebelMouse' ); /** * @package Browser & Platform Detect class/functions * @author https://stackoverflow.com/users/1060394/jay * @ https://stackoverflow.com/questions/2257597/reliable-user-browser-detection-with-php */ function detect() { $this->detectBrowser(); $this->detectPlatform(); return $this; } /** * @package Browser & Platform Detect class/functions * @author https://stackoverflow.com/users/1060394/jay * @ https://stackoverflow.com/questions/2257597/reliable-user-browser-detection-with-php */ function detectBrowser() { foreach($this->_basic_browser as $pattern => $name) { if( preg_match("/".$pattern."/i",$this->_user_agent, $match)) { $this->_name = $name; // finally get the correct version number $known = array('Version', $pattern, 'other'); $pattern_version = '#(?' . join('|', $known).')[/ ]+(?[0-9.|a-zA-Z.]*)#'; if (!preg_match_all($pattern_version, $this->_user_agent, $matches)) { // we have no matching number just continue } // see how many we have $i = count($matches['browser']); if ($i != 1) { //we will have two since we are not using 'other' argument yet //see if version is before or after the name if (strripos($this->_user_agent,"Version") < strripos($this->_user_agent,$pattern)) { @$this->_version = $matches['version'][0]; } else { @$this->_version = $matches['version'][1]; } } else { $this->_version = $matches['version'][0]; } break; } } } /** * @package Browser & Platform Detect class/functions * @author https://stackoverflow.com/users/1060394/jay * @ https://stackoverflow.com/questions/2257597/reliable-user-browser-detection-with-php */ function detectPlatform() { foreach($this->_basic_platform as $key => $platform) { if (stripos($this->_user_agent, $key) !== false) { $this->_platform = $platform; break; } } } /** * @package Browser & Platform Detect class/functions * @author https://stackoverflow.com/users/1060394/jay * @ https://stackoverflow.com/questions/2257597/reliable-user-browser-detection-with-php */ function getBrowser() { if(!empty($this->_name)) { return $this->_name; } } function getVersion() { return $this->_version; } function getPlatform() { if(!empty($this->_platform)) { return $this->_platform; } } function getUserAgent() { return $this->_user_agent; } function getInfo() { // see how many we have, i.e. Array ( [0] => 1 [1] => 'Desktop) if (is_array($this->mobile_device_detect())) { //we will have two since we are not using 'other' argument yet $mobile = $this->mobile_device_detect(); //see if version is before or after the name if (empty($mobile[1])) { $mobile_device = $mobile[0]; } else { $mobile_device = $mobile[1]; } } else { $mobile_device = $this->mobile_device_detect(); } return "Browsing with: {$this->getBrowser()}" . " - {$this->getVersion()}" . //"Browser User Agent String: {$this->getUserAgent()}
\n" . " :: from OS: {$this->getPlatform()}" . "-{$mobile_device}, on a server with PHP ". PHP_VERSION ." & OS ". PHP_OS; } } //end of class ?> classes/RequestVars.php0000755000000000000000000010767314530557667012441 0ustar post('mode', TYPE_NO_TAGS, ''); * - $page_id = $mx_request_vars->get('page', TYPE_INT, 1); * This class IS instatiated in common.php ;-) * * @access public * @author Markus Petrux, John Olson, FlorinCB * @package Core */ class RequestVars { /**#@+ * Constant identifying the super global with the same name. */ const _POST = 0; const _GET = 1; const _REQUEST = 2; const _COOKIE = 3; const _SERVER = 4; const _FILES = 5; const POST = 0; const GET = 1; const REQUEST = 2; const COOKIE = 3; const SERVER = 4; const FILES = 5; /**#@-*/ // // Implementation Conventions: // Properties and methods prefixed with underscore are intented to be private. ;-) // /** * @var array The names of super global variables that this class should protect if super globals are disabled. */ protected $super_globals = array( self::POST => '_POST', self::GET => '_GET', self::REQUEST => '_REQUEST', self::COOKIE => '_COOKIE', self::SERVER => '_SERVER', self::FILES => '_FILES', ); /** * @vars arrays Stores count() of $GLOBALS arrays. */ var $post_array = 0; var $get_array = 0; var $request_array = 0; var $cookie_array = 0; var $server_array = 0; var $files_arrays = 0; /** * @var array Stores original contents of $_REQUEST array. */ protected $original_request = null; /** * @var */ protected $super_globals_disabled = false; /** * @var array An associative array that has the value of super global constants as keys and holds their data as values. */ protected $input; /** * @var \phpbb\request\type_cast_helper_interface An instance of a type cast helper providing convenience methods for type conversions. * borrowed from github.comb */ protected $type_cast_helper; // ------------------------------ // Properties // /* ------------------------------ * Constructor * Initialises the request class, that means it stores all input data in {@link $input input} * and then calls {@link deactivated_super_global deactivated_super_global} */ public function __construct($disable_super_globals = false) { foreach ($this->super_globals as $const => $super_global) { $this->input[$const] = isset($GLOBALS[$super_global]) ? $GLOBALS[$super_global] : array(); } // simulate request_order = GP $this->original_request = $this->input[self::REQUEST]; $this->input[self::REQUEST] = $this->input[self::POST] + $this->input[self::GET]; $this->post_array = isset($GLOBALS['_POST']) ? count($GLOBALS['_POST']) : 0; $this->get_array = isset($GLOBALS['_GET']) ? count($GLOBALS['_GET']) : 0; $this->request_array = isset($GLOBALS['_REQUEST']) ? count($GLOBALS['_REQUEST']) : 0; $this->cookie_array = isset($GLOBALS['_COOKIE']) ? count($GLOBALS['_COOKIE']) : 0; $this->server_array = isset($GLOBALS['_SERVER']) ? count($GLOBALS['_SERVER']) : 0; $this->files_arrays = isset($GLOBALS['_FILES']) ? count($GLOBALS['_FILES']) : 0; if ($disable_super_globals) { $this->disable_super_globals(); } } /** * Getter for $super_globals_disabled * * @return bool Whether super globals are disabled or not. * borrowed from github.comb */ public function super_globals_disabled() { return $this->super_globals_disabled; } /** * Disables access of super globals specified in $super_globals. * This is achieved by overwriting the super globals with instances of {@link \autoindex\request\deactivated_super_global \autoindex\request\deactivated_super_global} * borrowed from github.comb */ public function disable_super_globals() { if (!$this->super_globals_disabled) { foreach ($this->super_globals as $const => $super_global) { unset($GLOBALS[$super_global]); $GLOBALS[$super_global] = new deactivated_super_global($this, $super_global, $const); } $this->super_globals_disabled = true; } } /** * Enables access of super globals specified in $super_globals if they were disabled by {@link disable_super_globals disable_super_globals}. * This is achieved by making the super globals point to the data stored within this class in {@link $input input}. * borrowed from github.comb */ public function enable_super_globals() { if ($this->super_globals_disabled) { foreach ($this->super_globals as $const => $super_global) { $GLOBALS[$super_global] = $this->input[$const]; } $GLOBALS['_REQUEST'] = $this->original_request; $this->super_globals_disabled = false; } } // ------------------------------ // Public Methods // /** * This function allows overwriting or setting a value in one of the super global arrays. * * Changes which are performed on the super globals directly will not have any effect on the results of * other methods this class provides. Using this function should be avoided if possible! It will * consume twice the the amount of memory of the value * * @param string $var_name The name of the variable that shall be overwritten * @param mixed $value The value which the variable shall contain. * If this is null the variable will be unset. * @param mx_request_vars::POST|GET|REQUEST|COOKIE $super_global * Specifies which super global shall be changed */ public function overwrite($var_name, $value, $super_global = self::REQUEST) { if (!isset($this->super_globals[$super_global])) { return; } $this->type_cast_helper->add_magic_quotes($value); // setting to null means unsetting if ($value === null) { unset($this->input[$super_global][$var_name]); if (!$this->super_globals_disabled()) { unset($GLOBALS[$this->super_globals[$super_global]][$var_name]); } } else { $this->input[$super_global][$var_name] = $value; if (!$this->super_globals_disabled()) { $GLOBALS[$this->super_globals[$super_global]][$var_name] = $value; } } } // ------------------------------ // Private Methods // /** * Function: _read(). * * Get the value of the specified request var (post or get) and force the result to be * of specified type. It might also transform the result (stripslashes, htmlspecialchars) for security * purposes. It all depends on the $type argument. * If the specified request var does not exist, then the default ($dflt) value is returned. * Note the $type argument behaves as a bit array where more than one option can be specified by OR'ing * the passed argument. This is tipical practice in languages like C, but it can also be done with PHP. * * @access private * @param unknown_type $var * @param unknown_type $type * @param unknown_type $dflt * @return unknown */ public function _read($var, $type = TYPE_ANY, $dflt = '', $not_null = false) { if( ($type & (TYPE_POST_VARS|TYPE_GET_VARS)) == 0 ) { $type |= (TYPE_POST_VARS|TYPE_GET_VARS); } if( ($type & TYPE_POST_VARS) && isset($_POST[$var]) || ($type & TYPE_GET_VARS) && isset($_GET[$var]) ) { $val = ( ($type & TYPE_POST_VARS) && isset($_POST[$var]) ? $_POST[$var] : $_GET[$var] ); if( !($type & TYPE_NO_STRIP) ) { if( is_array($val) ) { foreach( $val as $k => $v ) { $val[$k] = trim(stripslashes($v)); } } else { $val = trim(stripslashes($val)); } } } else { $val = $dflt; } if( $type & TYPE_INT ) // integer { return $not_null && empty($val) ? $dflt : intval($val); } if( $type & TYPE_FLOAT ) // float { return $not_null && empty($val) ? $dflt : floatval($val); } if( $type & TYPE_NO_TAGS ) // ie username { if( is_array($val) ) { foreach( $val as $k => $v ) { $val[$k] = htmlspecialchars(strip_tags(ltrim(rtrim($v, " \t\n\r\0\x0B\\")))); } } else { $val = htmlspecialchars(strip_tags(ltrim(rtrim($val, " \t\n\r\0\x0B\\")))); } } elseif( $type & TYPE_NO_HTML ) // no slashes nor html { if( is_array($val) ) { foreach( $val as $k => $v ) { $val[$k] = htmlspecialchars(ltrim(rtrim($v, " \t\n\r\0\x0B\\"))); } } else { $val = htmlspecialchars(ltrim(rtrim($val, " \t\n\r\0\x0B\\"))); } } if( $type & TYPE_SQL_QUOTED ) { if( is_array($val) ) { foreach( $val as $k => $v ) { $val[$k] = str_replace(($type & TYPE_NO_STRIP ? "\'" : "'"), "''", $v); } } else { $val = str_replace(($type & TYPE_NO_STRIP ? "\'" : "'"), "''", $val); } } return $not_null && empty($val) ? $dflt : $val; } // ------------------------------ // Public Methods // /** * Central type safe input handling function. * All variables in GET or POST requests should be retrieved through this function to maximise security. * * @param string|array $var_name The form variable's name from which data shall be retrieved. * If the value is an array this may be an array of indizes which will give * direct access to a value at any depth. E.g. if the value of "var" is array(1 => "a") * then specifying array("var", 1) as the name will return "a". * @param mixed $default A default value that is returned if the variable was not set. * This function will always return a value of the same type as the default. * @param bool $multibyte If $default is a string this parameter has to be true if the variable may contain any UTF-8 characters * Default is false, causing all bytes outside the ASCII range (0-127) to be replaced with question marks * @param mx_request_vars::POST|GET|REQUEST|COOKIE $super_global * Specifies which super global should be used * * @return mixed The value of $_REQUEST[$var_name] run through {@link set_var set_var} to ensure that the type is the * the same as that of $default. If the variable is not set $default is returned. */ public function variable($var_name, $default, $multibyte = false, $super_global = self::REQUEST) { return $this->_variable($var_name, $default, $multibyte, $super_global, true); } /** * Get a variable, but without trimming strings. * Same functionality as variable(), except does not run trim() on strings. * This method should be used when handling passwords. * * @param string|array $var_name The form variable's name from which data shall be retrieved. * If the value is an array this may be an array of indizes which will give * direct access to a value at any depth. E.g. if the value of "var" is array(1 => "a") * then specifying array("var", 1) as the name will return "a". * @param mixed $default A default value that is returned if the variable was not set. * This function will always return a value of the same type as the default. * @param bool $multibyte If $default is a string this parameter has to be true if the variable may contain any UTF-8 characters * Default is false, causing all bytes outside the ASCII range (0-127) to be replaced with question marks * @param mx_request_vars::POST|GET|REQUEST|COOKIE $super_global * Specifies which super global should be used * * @return mixed The value of $_REQUEST[$var_name] run through {@link set_var set_var} to ensure that the type is the * the same as that of $default. If the variable is not set $default is returned. */ public function untrimmed_variable($var_name, $default, $multibyte = false, $super_global = self::REQUEST) { return $this->_variable($var_name, $default, $multibyte, $super_global, false); } /** * */ public function raw_variable($var_name, $default, $super_global = self::REQUEST) { $path = false; // deep direct access to multi dimensional arrays if (is_array($var_name)) { $path = $var_name; // make sure at least the variable name is specified if (empty($path)) { return (is_array($default)) ? array() : $default; } // the variable name is the first element on the path $var_name = array_shift($path); } if (!isset($this->input[$super_global][$var_name])) { return (is_array($default)) ? array() : $default; } $var = $this->input[$super_global][$var_name]; if ($path) { // walk through the array structure and find the element we are looking for foreach ($path as $key) { if (is_array($var) && isset($var[$key])) { $var = $var[$key]; } else { return (is_array($default)) ? array() : $default; } } } return $var; } /** * Shortcut method to retrieve SERVER variables. * * Also fall back to getenv(), some CGI setups may need it (probably not, but * whatever). * * @param string|array $var_name See \request\request_interface::variable * @param mixed $Default See \request\request_interface::variable * * @return mixed The server variable value. */ public function server($var_name, $default = '') { $multibyte = true; if ($this->is_set($var_name, self::SERVER)) { return $this->variable($var_name, $default, $multibyte, self::SERVER); } else { $var = getenv($var_name); $this->recursive_set_var($var, $default, $multibyte); return $var; } } /** * Shortcut method to retrieve the value of client HTTP headers. * * @param string|array $header_name The name of the header to retrieve. * @param mixed $default See \request\request_interface::variable * * @return mixed The header value. */ public function header($header_name, $default = '') { $var_name = 'HTTP_' . str_replace('-', '_', strtoupper($header_name)); return $this->server($var_name, $default); } /** * Shortcut method to retrieve $_FILES variables * * @param string $form_name The name of the file input form element * * @return array The uploaded file's information or an empty array if the * variable does not exist in _FILES. */ public function file($form_name) { return $this->variable($form_name, array('name' => 'none'), true, self::FILES); } /** * Request POST variable. * * _read() wrappers to retrieve POST, GET or any REQUEST (both) variable. * * @access public * @param string $var * @param integer $type * @param string $dflt * @return string */ public function post($var, $type = TYPE_ANY, $dflt = '', $not_null = false) { if (!$this->super_globals_disabled()) { return $this->_read($var, ($type | TYPE_POST_VARS), $dflt, $not_null); } else { $super_global = self::POST; $multibyte = false; //UTF-8 ? $default = $dflt; return $this->_variable($var_name, $default, $multibyte, $super_global, true); } } /** ** / public function post($var_name, $default, $multibyte = false, $super_global = self::POST) { return $this->_variable($var_name, $default, $multibyte, $super_global, true); } /** **/ /** * Request GET variable. * * _read() wrappers to retrieve POST, GET or any REQUEST (both) variable. * * @access public * @param string $var * @param integer $type * @param string $dflt * @return string */ public function get($var, $type = TYPE_ANY, $dflt = '', $not_null = false) { if (!$this->super_globals_disabled()) { return $this->_read($var, ($type | TYPE_GET_VARS), $dflt, $not_null); } else { $super_global = self::GET; $multibyte = false; //UTF-8 ? $default = $dflt; return $this->_variable($var_name, $default, $multibyte, $super_global, true); } } /** ** / public function get($var_name, $default, $multibyte = false, $super_global = self::GET) { return $this->_variable($var_name, $default, $multibyte, $super_global, true); } /** **/ /** * Request GET or POST variable. * * _read() wrappers to retrieve POST, GET or any REQUEST (both) variable. * * @access public * @param string $var * @param integer $type * @param string $dflt * @return string */ public function request($var, $type = TYPE_ANY, $dflt = '', $not_null = false) { if (!$this->super_globals_disabled()) { return $this->_read($var, ($type | TYPE_POST_VARS | TYPE_GET_VARS), $dflt, $not_null); } else { $super_global = self::REQUEST; $multibyte = false; //UTF-8 ? $default = $dflt; return $this->_variable($var_name, $default, $multibyte, $super_global, true); } } /** * Is POST var? * * Boolean method to check for existence of POST variable. * * @access public * @param string $var * @return boolean */ public function is_post($var) { // Note: _x and _y are used by (at least IE) to return the mouse position at onclick of INPUT TYPE="img" elements. return ($this->is_set_post($var) || $this->is_set_post($var.'_x') && $this->is_set_post($var.'_y')) ? 1 : 0; } /** * Is GET var? * * Boolean method to check for existence of GET variable. * * @access public * @param string $var * @return boolean */ public function is_get($var) { //return isset($_GET[$var]) ? 1 : 0 ; return $this->is_set($var, self::GET); } /** * Is REQUEST (either GET or POST) var? * * Boolean method to check for existence of any REQUEST (both) variable. * * @access public * @param string $var * @return boolean */ public function is_request($var) { return ($this->is_get($var) || $this->is_post($var)) ? 1 : 0; //return $this->is_set($var, self::REQUEST); } /** * Is POST var empty? * * Boolean method to check if POST variable is empty * as it might be set but still be empty. * * @access public * @param string $var * @return boolean */ public function is_empty_post($var) { //return (empty($_POST[$var]) && ( empty($_POST[$var.'_x']) || empty($_POST[$var.'_y']))) ? 1 : 0 ; return ($this->is_empty($var, self::POST) && ($this->is_empty($var.'_x', self::POST) || $this->is_empty($var.'_y', self::POST))) ? 1 : 0; } /** * Is POST var not empty? * * Boolean method to check if POST variable is empty * as it might be set but still be empty. * * @access public * @param string $var * @return boolean */ public function is_not_empty_post($var) { //return (!empty($_POST[$var]) && ( !empty($_POST[$var.'_x']) || !empty($_POST[$var.'_y']))) ? 1 : 0 ; return ($this->is_not_empty($var, self::POST) && ($this->is_not_empty($var.'_x', self::POST) || $this->is_not_empty($var.'_y', self::POST))) ? 1 : 0; } /** * Is GET var empty? * * Boolean method to check if GET variable is empty * as it might be set but still be empty * * @access public * @param string $var * @return boolean */ public function is_empty_get($var) { //return empty($_GET[$var]) ? 1 : 0; return $this->is_empty($var, self::GET); } /** * Is GET var not empty? * * Boolean method to check if GET variable is empty * as it might be set but still be empty * * @access public * @param string $var * @return boolean */ public function is_not_empty_get($var) { //return !empty($_GET[$var]) ? 1 : 0; return $this->is_not_empty($var, self::GET); } /** * Is REQUEST empty (GET and POST) var? * * Boolean method to check if REQUEST (both) variable is empty. * * @access public * @param string $var * @return boolean */ public function is_empty_request($var) { return ($this->is_empty_get($var) && $this->is_empty_post($var)) ? 1 : 0; } /** * Is REQUEST not empty (GET and POST) var? * * Boolean method to check if REQUEST (both) variable is empty. * * @access public * @param string $var * @return boolean */ public function is_not_empty_request($var) { return ($this->is_not_empty_get($var) && $this->is_not_empty_post($var)) ? 1 : 0; } /** * Checks whether a certain variable was sent via POST. * To make sure that a request was sent using POST you should call this function * on at least one variable. * * @param string $name The name of the form variable which should have a * _p suffix to indicate the check in the code that creates the form too. * * @return bool True if the variable was set in a POST request, false otherwise. */ public function is_set_post($var) { if (is_array($var)) { return $this->is_array_set($var, self::POST); } else { return $this->is_set($var, self::POST); } } /** * Checks whether a certain variable was not sent via POST. * To make sure that a request was not sent using POST you should call this function * on at least one variable. * * @param string $name The name of the form variable which should have a * _p suffix to indicate the check in the code that creates the form too. * * @return bool True if the variable was not set in a POST request, false otherwise. */ public function is_not_set_post($name) { return $this->is_not_set($name, self::POST); } /** * Checks whether a certain variable was sent via GET. * To make sure that a request was sent using GET you should call this function * on at least one variable. * * @param string $name The name of the form variable which should have a * _p suffix to indicate the check in the code that creates the form too. * * @return bool True if the variable was set in a GET request, false otherwise. */ public function is_set_get($var) { if (is_array($var)) { return $this->is_array_set($var, self::GET); } else { return $this->is_set($var, self::GET); } } /** * Checks whether a certain variable was not sent via GET. * To make sure that a request was not sent using GET you should call this function * on at least one variable. * * @param string $name The name of the form variable which should have a * _p suffix to indicate the check in the code that creates the form too. * * @return bool True if the variable was not set in a GET request, false otherwise. */ public function is_not_set_get($name) { return $this->is_not_set($name, self::GET); } /* * * */ public function post_array() { return ($this->post_array > 0) ? $this->post_array : 0; } /* * * */ public function get_array() { return ($this->get_array > 0) ? $this->get_array : 0; } /* * * */ public function request_array() { return ($this->request_array > 0) ? $this->request_array : 0; } /* * * */ public function cookie_array() { return ($this->cookie_array > 0) ? $this->cookie_array : 0; } /* * * */ public function server_array() { return ($this->server_array > 0) ? $this->server_array : 0; } /* * * */ public function files_array() { return ($this->files_array > 0) ? $this->files_array : 0; } /** * Checks whether a certain variable is empty in one of the super global * arrays. * * @param string $var Name of the variable * @param mx_request_vars::POST|GET|REQUEST|COOKIE $super_global * Specifies the super global which shall be checked * * @return bool True if the variable was sent as input */ public function is_empty($var, $super_global = self::REQUEST) { return empty($this->input[$super_global][$var]); } /** * Checks whether a certain variable is not empty in one of the super global * arrays. * * @param string $var Name of the variable * @param mx_request_vars::POST|GET|REQUEST|COOKIE $super_global * Specifies the super global which shall be checked * * @return bool True if the variable was sent as input */ public function is_not_empty($var, $super_global = self::REQUEST) { return !empty($this->input[$super_global][$var]); } /** * Checks whether a certain variable is set in one of the super global * arrays. * * @param string $var Name of the variable * @param mx_request_vars::POST|GET|REQUEST|COOKIE $super_global * Specifies the super global which shall be checked * * @return bool True if the variable was sent as input */ public function is_set($var, $super_global = self::REQUEST) { return isset($this->input[$super_global][$var]); } /** * Checks whether a certain array of variables are set in one of the super global * arrays. * * @param string $var1 Name of the variable * @param string $var2 Name of the variable * @param mx_request_vars::POST|GET|REQUEST|COOKIE $super_global * Specifies the super global which shall be checked * * @return bool True if the variable was sent as input */ public function is_array_set($arr, $super_global = self::REQUEST) { $n = count($arr); $lim = 4; for ($i = 0; $i < $n; $i++) { foreach($arr as $var) { $arr[$i] = isset($this->input[$super_global][$var][$i]) ? $this->input[$super_global][$var][$i] : $var; } if ($i < 3) { return isset($this->input[$super_global][$var][0], $this->input[$super_global][$var][2]); } elseif ($i < 4) { return isset($this->input[$super_global][$var][0], $this->input[$super_global][$var][2], $this->input[$super_global][$var][3]); } elseif ($i < 5) { return isset($this->input[$super_global][$var][0], $this->input[$super_global][$var][2], $this->input[$super_global][$var][3], $this->input[$super_global][$var][4]); } elseif ($lim < $n) { print('Warning: Request vars class only accepts a number of arguments in an array: ' . $lim . ', but now are: ' . $n . ' arguments.'); } } } /** * Checks whether a certain variable is not set in one of the super global * arrays. * * @param string $var Name of the variable * @param mx_request_vars::POST|GET|REQUEST|COOKIE $super_global * Specifies the super global which shall be checked * * @return bool True if the variable was sent as input */ public function is_not_set($var, $super_global = self::REQUEST) { return !isset($this->input[$super_global][$var]); } /** * Checks whether the current request is an AJAX request (XMLHttpRequest) * * @return bool True if the current request is an ajax request */ public function is_ajax() { return $this->header('X-Requested-With') == 'XMLHttpRequest'; } /** * Checks if the current request is happening over HTTPS. * * @return bool True if the request is secure. */ public function is_secure() { $https = $this->server('HTTPS'); $https = $this->server('HTTP_X_FORWARDED_PROTO') === 'https' ? 'on' : $https; return !empty($https) && $https !== 'off'; } /** * Returns all variable names for a given super global * * @param mx_request_vars::POST|GET|REQUEST|COOKIE $super_global * The super global from which names shall be taken * * @return array All variable names that are set for the super global. * Pay attention when using these, they are unsanitised! */ public function variable_names($super_global = self::REQUEST) { if (!isset($this->input[$super_global])) { return array(); } return array_keys($this->input[$super_global]); } /** * Helper function used by variable() and untrimmed_variable(). * * @param string|array $var_name The form variable's name from which data shall be retrieved. * If the value is an array this may be an array of indizes which will give * direct access to a value at any depth. E.g. if the value of "var" is array(1 => "a") * then specifying array("var", 1) as the name will return "a". * @param mixed $default A default value that is returned if the variable was not set. * This function will always return a value of the same type as the default. * @param bool $multibyte If $default is a string this parameter has to be true if the variable may contain any UTF-8 characters * Default is false, causing all bytes outside the ASCII range (0-127) to be replaced with question marks * @param mx_request_vars::POST|GET|REQUEST|COOKIE $super_global * Specifies which super global should be used * @param bool $trim Indicates whether trim() should be applied to string values. * * @return mixed The value of $_REQUEST[$var_name] run through {@link set_var set_var} to ensure that the type is the * the same as that of $default. If the variable is not set $default is returned. */ protected function _variable($var_name, $default, $multibyte = false, $super_global = self::REQUEST, $trim = true) { $var = $this->raw_variable($var_name, $default, $super_global); // Return prematurely if raw variable is empty array or the same as // the default. Using strict comparison to ensure that one can't // prevent proper type checking on any input variable if ($var === array() || $var === $default) { return $var; } $this->recursive_set_var($var, $default, $multibyte, $trim); return $var; } /** * */ public function get_super_global($super_global = self::REQUEST) { return $this->input[$super_global]; } /** * */ public function escape($var, $multibyte) { if (is_array($var)) { $result = array(); foreach ($var as $key => $value) { $this->set_var($key, $key, gettype($key), $multibyte); $result[$key] = $this->escape($value, $multibyte); } $var = $result; } else { $this->set_var($var, $var, 'string', $multibyte); } return $var; } /** * Check GET POST vars exists */ function check_http_var_exists($var_name, $empty_var = false) { if ($empty_var) { if (isset($_GET[$var_name]) || isset($_POST[$var_name])) { return true; } else { return false; } } else { if (!empty($_GET[$var_name]) || !empty($_POST[$var_name])) { return true; } else { return false; } } return false; } /** * Check variable value against default array */ function check_var_value($var, $var_array, $var_default = false) { if (!is_array($var_array) || empty($var_array)) { return $var; } $var_default = (($var_default === false) ? $var_array[0] : $var_default); $var = in_array($var, $var_array) ? $var : $var_default; return $var; } /** * Set variable $result to a particular type. * * @param mixed &$result The variable to fill * @param mixed $var The contents to fill with * @param mixed $type The variable type. Will be used with {@link settype()} * @param bool $multibyte Indicates whether string values may contain UTF-8 characters. * Default is false, causing all bytes outside the ASCII range (0-127) to be replaced with question marks. * @param bool $trim Indicates whether trim() should be applied to string values. * Default is true. */ public function set_var(&$result, $var, $type, $multibyte = false, $trim = true) { settype($var, $type); $result = $var; if ($type == 'string') { $result = str_replace(array("\r\n", "\r", "\0"), array("\n", "\n", ''), $result); if ($trim) { $result = trim($result); } $result = htmlspecialchars($result, ENT_COMPAT, 'UTF-8'); if ($multibyte) { if (is_array($result)) { foreach ($result as $key => $string) { if (is_array($string)) { foreach ($string as $_key => $_string) { $result = $result[$key][$_string]; } } else { $result = $strings[$key]; } } } } if (!empty($result)) { // Make sure multibyte characters are wellformed if ($multibyte) { if (!preg_match('/^./u', $result)) { $result = ''; } } else { // no multibyte, allow only ASCII (0-127) $result = preg_replace('/[\x80-\xFF]/', '?', $result); } } } } /** * Recursively sets a variable to a given type using {@link set_var set_var} * * @param string $var The value which shall be sanitised (passed by reference). * @param mixed $default Specifies the type $var shall have. * If it is an array and $var is not one, then an empty array is returned. * Otherwise var is cast to the same type, and if $default is an array all * keys and values are cast recursively using this function too. * @param bool $multibyte Indicates whether string keys and values may contain UTF-8 characters. * Default is false, causing all bytes outside the ASCII range (0-127) to * be replaced with question marks. * @param bool $trim Indicates whether trim() should be applied to string values. * Default is true. */ public function recursive_set_var(&$var, $default, $multibyte, $trim = true) { if (is_array($var) !== is_array($default)) { $var = (is_array($default)) ? array() : $default; return; } if (!is_array($default)) { $type = gettype($default); $this->set_var($var, $var, $type, $multibyte, $trim); } else { // make sure there is at least one key/value pair to use get the // types from if (empty($default)) { $var = array(); return; } list($default_key, $default_value) = each($default); $key_type = gettype($default_key); $_var = $var; $var = array(); foreach ($_var as $k => $v) { $this->set_var($k, $k, $key_type, $multibyte); $this->recursive_set_var($v, $default_value, $multibyte, $trim); $var[$k] = $v; } } } } // class RequestVars ?> classes/Search.php0000755000000000000000000001312314525007432011324 0ustar * @version 1.0.3 (July 06, 2005) * @package AutoIndex */ class Search extends DirectoryListDetailed { /** * @var array List of matched filenames */ private $matches; /** * @return string The HTML text that makes up the search box */ public static function search_box() { global $words, $subdir, $request; $search = ($request->is_set_get('search') ? Url::html_output($request->get('search')) : ''); $mode = ($request->is_set_get('search_mode') ? self::clean_mode($request->is_set_get('search_mode')) : 'f'); $modes = array('files' => 'f', 'folders' => 'd', 'both' => 'fd'); $out = '
' . '

' . '

'; return $out; } /** * @param string $filename * @param string $string * @return bool True if string matches filename */ private static function match(&$filename, &$string) { if (preg_match_all('/(?<=")[^"]+(?=")|[^ "]+/', $string, $matches)) { foreach ($matches[0] as $w) { if (stripos($filename, $w) !== false) { return true; } } } return false; } /** * Merges $obj into $this. * * @param Search $obj */ private function merge(Search $obj) { $this->total_folders += $obj->__get('total_folders'); $this->total_files += $obj->__get('total_files'); $this->total_downloads += $obj->__get('total_downloads'); $this->total_size->add_size($obj->__get('total_size')); $this->matches = array_merge($this->matches, $obj->__get('contents')); } /** * Returns a string with all characters except 'd' and 'f' stripped. * Either 'd' 'f' 'df' will be returned, defaults to 'f' * * @param string $mode * @return string */ private static function clean_mode($mode) { $str = ''; if (stripos($mode, 'f') !== false) { $str .= 'f'; } if (stripos($mode, 'd') !== false) { $str .= 'd'; } else if ($str == '') { $str = 'f'; } return $str; } /** * @param string $query String to search for * @param string $dir The folder to search (recursive) * @param string $mode Should be f (files), d (directories), or fd (both) */ public function __construct($query, $dir, $mode) { if (strlen($query) < 2 || strlen($query) > 20) { throw new ExceptionDisplay('Search query is either too long or too short.'); } $mode = self::clean_mode($mode); $dir = Item::make_sure_slash($dir); DirectoryList::__construct($dir); $this->matches = array(); $this->total_size = new Size(0); $this->total_downloads = $this->total_folders = $this->total_files = 0; foreach ($this as $item) { if ($item == '..') { continue; } if (@is_dir($dir . $item)) { if (stripos($mode, 'd') !== false && self::match($item, $query)) { $temp = new DirItem($dir, $item); $this->matches[] = $temp; if ($temp->__get('size')->__get('bytes') !== false) { $this->total_size->add_size($temp->__get('size')); } $this->total_folders++; } $sub_search = new Search($query, $dir . $item, $mode); $this->merge($sub_search); } else if (stripos($mode, 'f') !== false && self::match($item, $query)) { $temp = new FileItem($dir, $item); $this->matches[] = $temp; $this->total_size->add_size($temp->__get('size')); $this->total_downloads += $temp->__get('downloads'); $this->total_files++; } } global $words, $config, $subdir, $request; $link = ' ' . Url::html_output($dir) . ' '; $this->path_nav = $words->__get('search results for') . $link . $words->__get('and its subdirectories'); $this->contents = $this->matches; unset($this->matches); } } ?>classes/Size.php0000755000000000000000000000510513770256216011041 0ustar * @version 1.0.1 (July 15, 2004) * @package AutoIndex */ class Size { /** * @var int Size in bytes */ private $bytes; /** * @return string Returns $bytes formatted as a string */ public function formatted() { $size = $this -> bytes; if ($size === true) //used for the parent directory { return ' '; } if ($size === false) //used for regular directories (if SHOW_DIR_SIZE is false) { return '[dir]'; } static $u = array(' B', 'KB', 'MB', 'GB'); for ($i = 0; $size >= 1024 && $i < 4; $i++) { $size /= 1024; } return number_format($size, 1) . ' ' . $u[$i]; } /** * Adds the size of $s into $this * * @param Size $s */ public function add_size(Size $s) { $temp = $s -> __get('bytes'); if (is_int($temp)) { $this -> bytes += $temp; } } /** * True if parent directory, * False if directory, * Integer for an actual size. * * @param mixed $bytes */ public function __construct($bytes) { $this -> bytes = ((is_bool($bytes)) ? $bytes : max((int)$bytes, 0)); } /** * @param string $var The key to look for * @return string The value $name points to */ public function __get($var) { if (isset($this -> $var)) { return $this -> $var; } throw new ExceptionDisplay('Variable ' . Url::html_output($var) . ' not set in Size class.'); } } ?>classes/Stats.php0000755000000000000000000003331114530557667011236 0ustar * @version 1.0.1 (July 12, 2004) * @package AutoIndex */ class Stats { /** * @var array Stores number of downloads per file extension */ private $extensions; /** * @var array Hits per day */ private $dates; /** * @var array Unique hits per day */ private $unique_hits; /** * @var array Keys are the country codes and values are the number of visits */ private $countries; /** * @var int Total views of the base_dir */ private $total_hits; /** * @var int The number of days that there is a log entry for */ private $num_days; /** * @var int Average hits per day ($total_hits / $num_days) */ private $avg; /** * Returns $num formatted with a color (green for positive numbers, red * for negative numbers, and black for 0). * * @param int $num * @return string */ private static function get_change_color($num) { if ($num > 0) { return '+'; } if ($num < 0) { return ''; } return ''; } /** * If $array[$num] is set, it will be incremented by 1, otherwise it will * be set to 1. * * @param int $num * @param array $array */ private static function add_num_to_array($num, &$array) { isset($array[$num]) ? $array[$num]++ : $array[$num] = 1; } /** * Reads the log file, and sets the member variables after doing * calculations. */ public function __construct() { $extensions = $dates = $unique_hits = $countries = array(); $total_hits = 0; global $config; $log_file = $config -> __get('log_file'); $base_dir = $config -> __get('base_dir'); $h = @fopen($log_file, 'rb'); if ($h === false) { throw new ExceptionDisplay("Cannot open log file: $log_file"); } while (!feof($h)) { $entries = explode("\t", rtrim(fgets($h, 1024), "\r\n")); if (count($entries) === 7) { //find the number of unique visits if ($entries[5] == $base_dir) { $total_hits++; if (!in_array($entries[3], $unique_hits)) { $unique_hits[] = Url::html_output($entries[3]); } //find country codes by hostnames $cc = FileItem::ext($entries[3]); if (preg_match('/^[a-z]+$/i', $cc)) { self::add_num_to_array($cc, $countries); } //find the dates of the visits self::add_num_to_array($entries[0], $dates); } //find file extensions $ext = FileItem::ext($entries[6]); if (preg_match('/^[\w-]+$/', $ext)) { self::add_num_to_array($ext, $extensions); } } } fclose($h); $this -> num_days = count($dates); $this -> avg = round($total_hits / $this -> num_days); $this -> extensions = $extensions; $this -> dates = $dates; $this -> unique_hits = $unique_hits; $this -> countries = $countries; $this -> total_hits = $total_hits; } /** * Uses the display class to output results. */ public function display() { static $country_codes = array( 'af' => 'Afghanistan', 'al' => 'Albania', 'dz' => 'Algeria', 'as' => 'American Samoa', 'ad' => 'Andorra', 'ao' => 'Angola', 'ai' => 'Anguilla', 'aq' => 'Antarctica', 'ag' => 'Antigua and Barbuda', 'ar' => 'Argentina', 'am' => 'Armenia', 'aw' => 'Aruba', 'au' => 'Australia', 'at' => 'Austria', 'ax' => 'Ålang Islands', 'az' => 'Azerbaidjan', 'bs' => 'Bahamas', 'bh' => 'Bahrain', 'bd' => 'Banglades', 'bb' => 'Barbados', 'by' => 'Belarus', 'be' => 'Belgium', 'bz' => 'Belize', 'bj' => 'Benin', 'bm' => 'Bermuda', 'bo' => 'Bolivia', 'ba' => 'Bosnia-Herzegovina', 'bw' => 'Botswana', 'bv' => 'Bouvet Island', 'br' => 'Brazil', 'io' => 'British Indian O. Terr.', 'bn' => 'Brunei Darussalam', 'bg' => 'Bulgaria', 'bf' => 'Burkina Faso', 'bi' => 'Burundi', 'bt' => 'Buthan', 'kh' => 'Cambodia', 'cm' => 'Cameroon', 'ca' => 'Canada', 'cv' => 'Cape Verde', 'ky' => 'Cayman Islands', 'cf' => 'Central African Rep.', 'td' => 'Chad', 'cl' => 'Chile', 'cn' => 'China', 'cx' => 'Christmas Island', 'cc' => 'Cocos (Keeling) Isl.', 'co' => 'Colombia', 'km' => 'Comoros', 'cg' => 'Congo', 'ck' => 'Cook Islands', 'cr' => 'Costa Rica', 'hr' => 'Croatia', 'cu' => 'Cuba', 'cy' => 'Cyprus', 'cz' => 'Czech Republic', 'cs' => 'Czechoslovakia', 'dk' => 'Denmark', 'dj' => 'Djibouti', 'dm' => 'Dominica', 'do' => 'Dominican Republic', 'tp' => 'East Timor', 'ec' => 'Ecuador', 'eg' => 'Egypt', 'sv' => 'El Salvador', 'gq' => 'Equatorial Guinea', 'ee' => 'Estonia', 'et' => 'Ethiopia', 'fk' => 'Falkland Isl. (UK)', 'fo' => 'Faroe Islands', 'fj' => 'Fiji', 'fi' => 'Finland', 'fr' => 'France', 'fx' => 'France (European Terr.)', 'tf' => 'French Southern Terr.', 'ga' => 'Gabon', 'gm' => 'Gambia', 'ge' => 'Georgia', 'de' => 'Germany', 'gh' => 'Ghana', 'gi' => 'Gibraltar', 'gb' => 'Great Britain (UK)', 'gr' => 'Greece', 'gl' => 'Greenland', 'gd' => 'Grenada', 'gp' => 'Guadeloupe (Fr)', 'gu' => 'Guam (US)', 'gt' => 'Guatemala', 'gn' => 'Guinea', 'gw' => 'Guinea Bissau', 'gy' => 'Guyana', 'gf' => 'Guyana (Fr)', 'ht' => 'Haiti', 'hm' => 'Heard & McDonald Isl.', 'hn' => 'Honduras', 'hk' => 'Hong Kong', 'hu' => 'Hungary', 'is' => 'Iceland', 'in' => 'India', 'id' => 'Indonesia', 'ir' => 'Iran', 'iq' => 'Iraq', 'ie' => 'Ireland', 'il' => 'Israel', 'it' => 'Italy', 'ci' => 'Ivory Coast', 'jm' => 'Jamaica', 'jp' => 'Japan', 'jo' => 'Jordan', 'kz' => 'Kazachstan', 'ke' => 'Kenya', 'kg' => 'Kirgistan', 'ki' => 'Kiribati', 'kp' => 'North Korea', 'kr' => 'South Korea', 'kw' => 'Kuwait', 'la' => 'Laos', 'lv' => 'Latvia', 'lb' => 'Lebanon', 'ls' => 'Lesotho', 'lr' => 'Liberia', 'ly' => 'Libya', 'li' => 'Liechtenstein', 'lt' => 'Lithuania', 'lu' => 'Luxembourg', 'mo' => 'Macau', 'mg' => 'Madagascar', 'mw' => 'Malawi', 'my' => 'Malaysia', 'mv' => 'Maldives', 'ml' => 'Mali', 'mt' => 'Malta', 'mh' => 'Marshall Islands', 'mk' => 'Macedonia', 'mq' => 'Martinique (Fr.)', 'mr' => 'Mauritania', 'mu' => 'Mauritius', 'mx' => 'Mexico', 'fm' => 'Micronesia', 'md' => 'Moldavia', 'mc' => 'Monaco', 'mn' => 'Mongolia', 'ms' => 'Montserrat', 'ma' => 'Morocco', 'mz' => 'Mozambique', 'mm' => 'Myanmar', 'na' => 'Namibia', 'nr' => 'Nauru', 'np' => 'Nepal', 'an' => 'Netherland Antilles', 'nl' => 'Netherlands', 'nt' => 'Neutral Zone', 'nc' => 'New Caledonia (Fr.)', 'nz' => 'New Zealand', 'ni' => 'Nicaragua', 'ne' => 'Niger', 'ng' => 'Nigeria', 'nu' => 'Niue', 'nf' => 'Norfolk Island', 'mp' => 'Northern Mariana Isl.', 'no' => 'Norway', 'om' => 'Oman', 'pk' => 'Pakistan', 'pw' => 'Palau', 'pa' => 'Panama', 'pg' => 'Papua New Guinea', 'py' => 'Paraguay', 'pe' => 'Peru', 'ph' => 'Philippines', 'pn' => 'Pitcairn', 'pl' => 'Poland', 'pf' => 'Polynesia (Fr.)', 'pt' => 'Portugal', 'pr' => 'Puerto Rico (US)', 'qa' => 'Qatar', 're' => 'Réunion (Fr.)', 'ro' => 'Romania', 'ru' => 'Russian Federation', 'rw' => 'Rwanda', 'lc' => 'Saint Lucia', 'ws' => 'Samoa', 'sm' => 'San Marino', 'sa' => 'Saudi Arabia', 'sn' => 'Senegal', 'sc' => 'Seychelles', 'sl' => 'Sierra Leone', 'sg' => 'Singapore', 'sk' => 'Slovak Republic', 'si' => 'Slovenia', 'sb' => 'Solomon Islands', 'so' => 'Somalia', 'za' => 'South Africa', 'su' => 'Soviet Union', 'es' => 'Spain', 'lk' => 'Sri Lanka', 'sh' => 'St. Helena', 'pm' => 'St. Pierre & Miquelon', 'st' => 'St. Tome and Principe', 'kn' => 'St. Kitts Nevis Anguilla', 'vc' => 'St. Vincent & Grenadines', 'sd' => 'Sudan', 'sr' => 'Suriname', 'sj' => 'Svalbard & Jan Mayen Isl.', 'sz' => 'Swaziland', 'se' => 'Sweden', 'ch' => 'Switzerland', 'sy' => 'Syria', 'tj' => 'Tadjikistan', 'tw' => 'Taiwan', 'tz' => 'Tanzania', 'th' => 'Thailand', 'tg' => 'Togo', 'tk' => 'Tokelau', 'to' => 'Tonga', 'tt' => 'Trinidad & Tobago', 'tn' => 'Tunisia', 'tr' => 'Turkey', 'tm' => 'Turkmenistan', 'tc' => 'Turks & Caicos Islands', 'tv' => 'Tuvalu', 'ug' => 'Uganda', 'ua' => 'Ukraine', 'ae' => 'United Arab Emirates', 'uk' => 'United Kingdom', 'us' => 'United States', 'uy' => 'Uruguay', 'um' => 'US Minor outlying Isl.', 'uz' => 'Uzbekistan', 'vu' => 'Vanuatu', 'va' => 'Vatican City State', 've' => 'Venezuela', 'vn' => 'Vietnam', 'vg' => 'Virgin Islands (British)', 'vi' => 'Virgin Islands (US)', 'wf' => 'Wallis & Futuna Islands', 'wlk' => 'Wales', 'eh' => 'Western Sahara', 'ye' => 'Yemen', 'yu' => 'Yugoslavia', 'zr' => 'Zaire', 'zm' => 'Zambia', 'zw' => 'Zimbabwe', 'mil' => 'United States Military', 'gov' => 'United States Government', 'com' => 'Commercial', 'net' => 'Network', 'org' => 'Non-Profit Organization', 'edu' => 'Educational', 'int' => 'International', 'aero' => 'Air Transport Industry', 'biz' => 'Businesses', 'coop' => 'Non-profit cooperatives', 'arpa' => 'Arpanet', 'info' => 'Info', 'name' => 'Name', 'nato' => 'Nato', 'museum' => 'Museum', 'pro' => 'Pro' ); $str = '' . "
  TotalDaily
Hits {$this -> total_hits}{$this -> avg}" . '
Unique Hits ' . count($this -> unique_hits) . '' . round(count($this -> unique_hits) / $this -> num_days) . '

Percent Unique: ' . number_format(count($this -> unique_hits) / $this -> total_hits * 100, 1) . '

'; arsort($this -> extensions); arsort($this -> countries); $date_nums = array_values($this -> dates); $str .= ''; $i = 0; foreach ($this -> dates as $day => $num) { $diff = $num - $this -> avg; $change = (($i > 0) ? ($num - $date_nums[$i-1]) : 0); $change_color = self::get_change_color($change); $diff_color = self::get_change_color($diff); $class = (($i++ % 2) ? 'dark_row' : 'light_row'); $str .= ""; } $str .= '
Date Hits That DayChange From Previous Day Difference From Average (' . $this -> avg . ')
$day $num $change_color$change $diff_color$diff

'; $i = 0; foreach ($this -> extensions as $ext => $num) { $class = (($i++ % 2) ? 'dark_row' : 'light_row'); $str .= ""; } $str .= '
Downloads based on file extensions TotalDaily
$ext $num" . number_format($num / $this -> num_days, 1) . "

'; $i = 0; foreach ($this -> countries as $c => $num) { $c_code = (isset($country_codes[strtolower($c)]) ? ' (' . $country_codes[strtolower($c)] . ')' : ''); $class = (($i++ % 2) ? 'dark_row' : 'light_row'); $str .= "\n"; } $str .= '
Hostname ISP extension TotalDaily
$c{$c_code}$num" . number_format($num / $this -> num_days, 1) . "

Continue.

'; echo new Display($str); die(); } } ?>classes/Stream.php0000755000000000000000000001331013770231136011351 0ustar * @version 2.0.4 (Jan 27, 2007) * @package AutoIndex */ class Stream { /** * @var string Name of the image file */ private $filename; /** * @var int The height of the thumbnail to create (width is automatically determined) */ private $height; /** * @param string $fn The filename * @return string Everything after the list dot in the filename, not including the dot */ public static function ext($fn) { $fn = Item::get_basename($fn); return (strpos($fn, '.') ? strtolower(substr(strrchr($fn, '.'), 1)) : ''); } /** * @return string Returns the extension of the filename * @see FileItem::ext() */ public function file_ext() { return self::ext($this -> filename); } /** * Outputs the video stream along with the correct headers so the * browser will display it. The script is then exited. */ public function __toString() { $thumbnail_height = $this -> height; $filepath = $this -> filename; if (!@is_file($filepath)) { header('HTTP/1.0 404 Not Found'); throw new ExceptionDisplay('Video file not found: ' . Url::html_output($filepath) . ''); } $file = Item::get_basename($filepath); // ------------------------------------ // Check the request // ------------------------------------ // ------------------------------------ // Check the permissions // ------------------------------------ // ------------------------------------ // Check hotlink // ------------------------------------ /* +---------------------------------------------------------- | Main work here... +---------------------------------------------------------- */ $ip = '127.0.0.0'; //localhost $port = '80'; $mount = "/"; // Used for alternate path to "Streaming URL" -- leave as "/" for the default setup. $wmpmode = ($protocol_type == 'icyx:') ? 'icyx://' : 'http://'; // AAC VS MPEG $mimetype = ($protocol_type == 'icyx:') ? 'audio/aacp' : 'audio/x-mpeg'; // AAC VS MPEG //Other $artist = "Video Steam -via- AutoIndex"; $title = "Video Steam !"; $album = "Live"; // Make socket connection $errno = "errno"; $errstr = "errstr"; //$station_url = str_replace("/listen.pls", "", htmlspecialchars(trim($thissong['station_url']))); $size = filesize($filepath); static $u = array('B', 'K', 'M', 'G'); for ($i = 0; $size >= 1024 && $i < 4; $i++) { $size /= 1024; } $filesize = number_format($size, 1) . ' ' . $u[$i]; // Establish response headers //header("HTTP/1.0 200 OK"); //Get media file content type $finfo = finfo_open(FILEINFO_MIME_TYPE); //Display correct headers for media file $mimetype = finfo_file($finfo, $filepath); header("Content-Type: $mimetype, application/octet-stream"); header("Content-Transfer-Encoding: binary"); // Content-Length is required for Internet Explorer: // - Set to a rediculous number // = I think the limit is somewhere around 420 MB // ini_set('memory_limit', '512M'); // Create send headers //echo "here".finfo_file($finfo, $filepath); finfo_close($finfo); header('Content-length: ' . filesize($filepath)); //header("Content-Disposition: attachment; filename=$title")."\n"; header('Content-Disposition: inline; filename="'.$file.'"'); //header('X-Sendfile: ' . $filepath); header('Cache-Control: public, max-age=3600, must-revalidate'); header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 3600) . ' GMT'); readfile($filepath); //die(); } /** * @param string $file The video file */ public function __construct($file) { if (!THUMBNAIL_HEIGHT) { throw new ExceptionDisplay('Video streaming is turned off.'); } global $config; $this -> height = (int)$config -> __get('thumbnail_height'); $this -> filename = $file; } } // +------------------------------------------------------+ // | Powered by Mx Music Center 2.0.1 (c) 2007 OryNider| // +------------------------------------------------------+ ?>classes/Tar.php0000755000000000000000000000757411500513450010652 0ustar * @version 1.0.1 (July 03, 2004) * @package AutoIndex */ class Tar { /** * @var int Length of directory path to cut off from start */ private $base_dir_length; /** * @var string Added in the filepath inside the tar archive */ private $prepend_path; /** * @param string $data * @return int The checksum of $data */ private static function checksum(&$data) { $unsigned_chksum = 0; for ($i = 0; $i < 512; $i++) { $unsigned_chksum += ord($data{$i}); } for ($i = 148; $i < 156; $i++) { $unsigned_chksum -= ord($data{$i}); } return $unsigned_chksum + 256; } /** * @param string $name The file or folder name * @param int $size The size of the file (0 for directories) * @param bool $is_dir True if folder, false if file */ private function create_header($name, $size = 0, $is_dir = true) { $header = str_pad($this -> prepend_path . substr($name, $this -> base_dir_length), 100, "\0") //filename . str_pad('755', 7, '0', STR_PAD_LEFT) . "\0" //permissions . '0000000' . "\0" //uid . '0000000' . "\0" //gid . str_pad(decoct($size), 11, '0', STR_PAD_LEFT) . "\0" //size . str_pad(decoct(filemtime($name)), 11, '0', STR_PAD_LEFT) . "\0" //time . ' ' //checksum (8 spaces) . ($is_dir ? '5' : '0') //typeflag . str_repeat("\0", 100) //linkname . 'ustar ' //magic /* * version (1) + username (32) + groupname (32) + devmajor (8) + * devminor (8) + prefix (155) + end (12) = 248 */ . str_repeat("\0", 248); $checksum = str_pad(decoct(self::checksum($header)), 6, '0', STR_PAD_LEFT) . "\0 "; return substr_replace($header, $checksum, 148, strlen($checksum)); } /** * @param DirectoryList $filenames List of files to add to the archive * @param string $prepend_path Added in the filepath inside the tar archive * @param int $base_dir_length Length of directory path to cut off from start */ public function __construct(DirectoryList $filenames, $prepend_path = '', $base_dir_length = 0) { $this -> base_dir_length = (int)$base_dir_length; $this -> prepend_path = Item::make_sure_slash($prepend_path); foreach ($filenames as $base) { $name = $filenames -> __get('dir_name') . $base; if (@is_dir($name)) { if ($base != '.' && $base != '..') { echo $this -> create_header($name); $list = new DirectoryList($name); new Tar($list, $this -> prepend_path, $this -> base_dir_length); } } else if (@is_file($name) && @is_readable($name) && ($size = @filesize($name))) { echo $this -> create_header($name, $size, false); Url::force_download($name, false); echo str_repeat("\0", (ceil($size / 512) * 512) - $size); } } } } ?>classes/Template.php0000755000000000000000000001374714542354250011710 0ustar * @version 1.0.3 (February 02, 2005) * @package AutoIndex */ class Template { /** * @var string The final output */ protected $out; /** * @param array $m The array given by preg_replace_callback() * @return string Looks up $m[1] in word list and returns match */ private static function callback_words($m) { global $words; return $words->__get(strtolower($m[1])); } /** * @param array $m The array given by preg_replace_callback() * @return string The parsed template of filename $m[1] */ private static function callback_include($m) { $temp = new Template($m[1]); return $temp->__toString(); } /** * Returns a list of all files in $path that match the filename format * of themes files. * * There are two valid formats for the filename of a template folder.. * * @param string $path The directory to read from * @return array The list of valid theme names (based on directory name) */ public static function get_all_styles($path = PATH_TO_TEMPLATES) { if (($hndl = @opendir($path)) === false) { echo 'Did try to open dir: ' . $path; return false; } $themes_array = $installable_themes = array(); $style_id = 0; while (($sub_dir = readdir($hndl)) !== false) { // get the sub-template path if( !is_file(@realpath($path . $sub_dir)) && !is_link(@realpath($path . $sub_dir)) && $sub_dir != "." && $sub_dir != ".." && $sub_dir != "CVS" ) { if(@file_exists(realpath($path . $sub_dir . "/$sub_dir.css")) || @file_exists(realpath($path . $sub_dir . "/default.css")) ) { $themes[] = array('template' => $path . $sub_dir . '/', 'template_name' => $sub_dir, 'style_id' => $style_id++); } } } closedir($hndl); return $themes; } /** * @param array $m The array given by preg_replace_callback() * @return string The setting for the config value $m[1] */ private static function callback_config($m) { global $config; return $config->__get(strtolower($m[1])); } /** * Parses the text in $filename and sets the result to $out. We cannot * use ExceptionDisplay here if there is an error, since it uses the * template system. * * Steps to parse the template: * - remove comments * - replace {info} variables * - replace {words} strings * - replace {config} variables * - include other files when we see the {include} statement * * @param string $filename The name of the file to parse */ public function __construct($filename) { global $config, $request, $dir, $subdir, $words, $mobile_device_detect; $style = $request->is_set('style') ? $request->variable('style', '') : 0; $themes = $this->get_all_styles($config->__get('template_path')); $template_path = $request->is_set('style') ? $themes[$style]['template'] : $config->__get('template'); $full_filename = $template_path . $filename; if (!is_file($full_filename)) { throw new ExceptionFatal('Template file ' . Url::html_output($full_filename) . ' cannot be found.'); } //read raw file contents $contents = file_get_contents($full_filename); if ($contents === false) { throw new ExceptionFatal('Template file ' . Url::html_output($full_filename) . ' could not be opened for reading.'); } //remove comments $contents = preg_replace('#/\*.*?\*/#s', '', $contents); //replace info variables and word strings from language file $tr = array( '{info:dir}' => (isset($dir) ? Url::html_output($dir) : ''), '{info:subdir}' => (isset($subdir) ? Url::html_output($subdir) : ''), '{info:version}' => VERSION, '{info:page_time}' => round((microtime(true) - START_TIME) * 1000, 1), '{info:statinfo}' => $mobile_device_detect->detect()->getInfo(), '{info:message}' => $words->__get('cookie consent msg'), '{info:dismiss}' => $words->__get('cookie consent OK'), '{info:link}' => $words->__get('cookie consent info'), '{info:href}' => $words->__get('privacy') ); $contents = preg_replace_callback('/\{\s*words?\s*:\s*(.+)\s*\}/Ui', array('self', 'callback_words'), strtr($contents, $tr)); //replace {config} variables $contents = preg_replace_callback('/\{\s*config\s*:\s*(.+)\s*\}/Ui', array('self', 'callback_config'), $contents); //parse includes $this -> out = preg_replace_callback('/\{\s*include\s*:\s*(.+)\s*\}/Ui', array('self', 'callback_include'), $contents); } /** * @return string The HTML text of the parsed template */ public function __toString() { return $this->out; } } ?> classes/TemplateFiles.php0000755000000000000000000001667014530557667012707 0ustar * @version 1.0.1 (July 09, 2004) * @package AutoIndex */ class TemplateFiles extends TemplateInfo { /** * @var Item The file or folder we're currently processing */ private $temp_item; /** * @var bool Is the current user an admin */ private $is_admin; /** * @var bool Is the current user a moderator */ private $is_mod; /** * @var int The number of the file we're currently processing */ private $i; /** * @var int The total number of files to process */ private $length; /** * @param array $m The array given by preg_replace_callback() * @return string Property is gotten from temp_item */ private function callback_file($m) { global $words, $subdir, $request; switch (strtolower($m[1])) { case 'tr_class': { return (($this->i % 2) ? 'dark_row' : 'light_row'); } case 'filename': { return Url::html_output($this->temp_item->__get('filename')); } case 'file_ext': { return $this->temp_item->file_ext(); } case 'size': { return $this->temp_item->__get('size')->formatted(); } case 'bytes': { return $this->temp_item->__get('size')->__get('bytes'); } case 'date': case 'time': case 'm_time': { return $this->temp_item->format_m_time(); } case 'a_time': { return $this->temp_item->format_a_time(); } case 'thumbnail': { return $this->temp_item->__get('thumb_link'); } case 'num_subfiles': { return (($this->temp_item instanceof DirItem && !$this->temp_item->__get('is_parent_dir')) ? $this->temp_item->num_subfiles() : ''); } case 'delete_link': { return (($this->is_admin && !$this->temp_item->__get('is_parent_dir')) ? ' [' . $words->__get('delete') . ']' : ''); } case 'rename_link': { return (($this->is_admin && !$this->temp_item->__get('is_parent_dir')) ? ' [' . $words->__get('rename') . ']' : ''); } case 'edit_description_link': { $slash = (($this->temp_item instanceof DirItem) ? '/' : ''); return (($this->is_mod && DESCRIPTION_FILE && !$this->temp_item->__get('is_parent_dir')) ? ' [' . $words->__get('edit description') . ']' : ''); } case 'ftp_upload_link': { if (!$this->is_mod || !$this->temp_item instanceof FileItem || !isset($_SESSION['ftp'])) { return ''; } return ' [' . $words->__get('upload to ftp') . ']'; } default: { return $this->temp_item->__get($m[1]); } } } /** * Either the HTML text is returned, or an empty string is returned, * depending on if the if-statement passed. * * @param array $m The array given by preg_replace_callback() * @return string The result to insert into the HTML */ private function callback_type($m) { switch (strtolower($m[1])) { case 'is_file': //file { return (($this->temp_item instanceof FileItem) ? $m[2] : ''); } case 'is_dir': //folder or link to parent directory { return (($this->temp_item instanceof DirItem) ? $m[2] : ''); } case 'is_real_dir': //folder { return (($this->temp_item instanceof DirItem && !$this->temp_item->__get('is_parent_dir')) ? $m[2] : ''); } case 'is_parent_dir': //link to parent directory { return (($this->temp_item instanceof DirItem && $this->temp_item->__get('is_parent_dir')) ? $m[2] : ''); } default: { throw new ExceptionDisplay('Invalid file:if statement in ' . Url::html_output(EACH_FILE) . ''); } } } /** * Either the HTML text is returned or an empty string is returned, * depending on if temp_item is the ith file parsed. * * @param array $m The array given by preg_replace_callback() * @return string The result to insert into the HTML output */ private function callback_do_every($m) { $num = $this->i + 1; return (($num % (int)$m[1] === 0 && $this->length !== $num) ? $m[2] : ''); } /** * Parses info for each file in the directory. Order of elements to * replace is: * - file:if * - do_every * - file * * @param string $filename The name of the file to parse * @param DirectoryListDetailed $list */ public function __construct($filename, DirectoryListDetailed $list) { parent::__construct($filename, $list); global $you; $this->is_admin = ($you->level >= ADMIN); $this->is_mod = ($you->level >= MODERATOR); $final_file_line = ''; $this->length = (int)$list->__get('list_count'); foreach ($list as $i => $item) { $this->i = (int)$i; $this->temp_item = $item; $temp_line = preg_replace_callback('/\{\s*file\s*:\s*if\s*:\s*(\w+)\s*\}(.*)\{\s*end\s*if\s*\}/Uis', array($this, 'callback_type'), $this->out); $temp_line = preg_replace_callback('/\{\s*do_every\s*:\s*(\d+)\s*\}(.*)\{\s*end\s*do_every\s*\}/Uis', array($this, 'callback_do_every'), $temp_line); $final_file_line .= preg_replace_callback('/\{\s*file\s*:\s*(\w+)\s*\}/Ui', array($this, 'callback_file'), $temp_line); } $this->out = $final_file_line; } } ?> classes/TemplateIndexer.php0000755000000000000000000001431714576214764013235 0ustar * @version 1.0.3 (February 02, 2005) * @package AutoIndex */ class TemplateIndexer { /** * @var string The final output */ protected $out; /** * @param array $m The array given by preg_replace_callback() * @return string Looks up $m[1] in word list and returns match */ private static function callback_words($m) { global $words; return $words->__get(strtolower($m[1])); } /** * @param array $m The array given by preg_replace_callback() * @return string The parsed template of filename $m[1] */ private static function callback_include($m) { $temp = new TemplateIndexer($m[1]); return $temp->__toString(); } /** * @param array $m The array given by preg_replace_callback() * @return string The setting for the config value $m[1] */ private static function callback_config($m) { global $config; return $config->__get(strtolower($m[1])); } /** * Returns a list of all files in $path that match the filename format * of themes files. * * There are two valid formats for the filename of a template folder.. * * @param string $path The directory to read from * @return array The list of valid theme names (based on directory name) */ public static function get_all_styles($path = PATH_TO_TEMPLATES) { if (($hndl = @opendir($path)) === false) { echo 'Did try to open dir: ' . $path; return false; } $themes_array = $installable_themes = array(); $style_id = 0; while (($sub_dir = readdir($hndl)) !== false) { // get the sub-template path if( !is_file(@realpath($path . $sub_dir)) && !is_link(@realpath($path . $sub_dir)) && $sub_dir != "." && $sub_dir != ".." && $sub_dir != "CVS" ) { if(@file_exists(realpath($path . $sub_dir . "/$sub_dir.css")) || @file_exists(realpath($path . $sub_dir . "/default.css")) ) { $themes[] = array('template' => $path . $sub_dir . '/', 'template_name' => $sub_dir, 'style_id' => $style_id++); } } } closedir($hndl); return $themes; } /** * Parses the text in $filename and sets the result to $out. We cannot * use ExceptionDisplay here if there is an error, since it uses the * template system. * * Steps to parse the template: * - remove comments * - replace {info} variables * - replace {words} strings * - replace {config} variables * - include other files when we see the {include} statement * * @param string $filename The name of the file to parse */ public function __construct($filename) { global $config, $request, $dir, $subdir, $words, $mobile_device_detect; $style = $request->is_set('style') ? $request->variable('style', '') : 0; $themes = $this->get_all_styles($config->__get('template_path')); /* Style ids are impare default [style_id] => 0 pubOry [style_id] => 1 simple_image_gallery [style_id] => 2 SwiftBlue [style_id] => 3 SwiftBlueBeitDina [style_id] => 4 */ $template_path = $request->is_set('style') ? $themes[$style]['template'] : $config->__get('template'); $full_filename = $template_path . $filename; if (!is_file($full_filename)) { throw new ExceptionFatal('Template file ' . Url::html_output($full_filename) . ' cannot be found.'); } //read raw file contents $contents = file_get_contents($full_filename); if ($contents === false) { throw new ExceptionFatal('Template file ' . Url::html_output($full_filename) . ' could not be opened for reading.'); } //remove comments $contents = preg_replace('#/\*.*?\*/#s', '', $contents); //replace info variables and word strings from language file $tr = array( '{info:dir}' => (isset($dir) ? Url::html_output($dir) : ''), '{info:subdir}' => (isset($subdir) ? Url::html_output($subdir) : ''), '{info:version}' => VERSION, '{info:page_time}' => round((microtime(true) - START_TIME) * 1000, 1), '{info:statinfo}' => $mobile_device_detect->detect()->getInfo(), '{info:message}' => $words->__get('cookie consent msg'), '{info:dismiss}' => $words->__get('cookie consent OK'), '{info:link}' => $words->__get('cookie consent info'), '{info:href}' => $words->__get('privacy') ); $contents = preg_replace_callback('/\{\s*words?\s*:\s*(.+)\s*\}/Ui', array($this, 'callback_words'), strtr($contents, $tr)); //replace {config} variables $contents = preg_replace_callback('/\{\s*config\s*:\s*(.+)\s*\}/Ui', array($this, 'callback_config'), $contents); //parse includes $this->out = preg_replace_callback('/\{\s*include\s*:\s*(.+)\s*\}/Ui', array($this, 'callback_include'), $contents); } /** * @return string The HTML text of the parsed template */ public function __toString() { return $this->out; } } ?>classes/TemplateIndexer.php30000755000000000000000000001433014532334220013271 0ustar * @version 1.0.3 (February 02, 2005) * @package AutoIndex */ class TemplateIndexer { /** * @var string The final output */ protected $out; /** * @param array $m The array given by preg_replace_callback() * @return string Looks up $m[1] in word list and returns match */ private static function callback_words($m) { global $words; return $words->__get(strtolower($m[1])); } /** * @param array $m The array given by preg_replace_callback() * @return string The parsed template of filename $m[1] */ private static function callback_include($m) { $temp = new TemplateIndexer($m[1]); return $temp->__toString(); } /** * @param array $m The array given by preg_replace_callback() * @return string The setting for the config value $m[1] */ private static function callback_config($m) { global $config; return $config->__get(strtolower($m[1])); } /** * Returns a list of all files in $path that match the filename format * of themes files. * * There are two valid formats for the filename of a template folder.. * * @param string $path The directory to read from * @return array The list of valid theme names (based on directory name) */ public static function get_all_styles($path = PATH_TO_TEMPLATES) { if (($hndl = @opendir($path)) === false) { echo 'Did try to open dir: ' . $path; return false; } $themes_array = $installable_themes = array(); $style_id = 0; while (($sub_dir = readdir($hndl)) !== false) { // get the sub-template path if( !is_file(@realpath($path . $sub_dir)) && !is_link(@realpath($path . $sub_dir)) && $sub_dir != "." && $sub_dir != ".." && $sub_dir != "CVS" ) { if(@file_exists(realpath($path . $sub_dir . "/$sub_dir.css")) || @file_exists(realpath($path . $sub_dir . "/default.css")) ) { $themes[] = array('template' => $path . $sub_dir . '/', 'template_name' => $sub_dir, 'style_id' => $style_id++); } } } closedir($hndl); return $themes; } /** * Parses the text in $filename and sets the result to $out. We cannot * use ExceptionDisplay here if there is an error, since it uses the * template system. * * Steps to parse the template: * - remove comments * - replace {info} variables * - replace {words} strings * - replace {config} variables * - include other files when we see the {include} statement * * @param string $filename The name of the file to parse */ public function __construct($filename) { global $config, $request, $dir, $subdir, $words, $mobile_device_detect; $style = $request->is_set('style') ? $request->variable('style', '') : 0; $themes = $this->get_all_styles($config->__get('template_path')); /* Style ids are impare default [style_id] => 0 pubOry [style_id] => 1 simple_image_gallery [style_id] => 2 SwiftBlue [style_id] => 3 SwiftBlueBeitDina [style_id] => 4 */ $template_path = $request->is_set('style') ? $themes[$style]['template'] : $config->__get('template'); $full_filename = $template_path . $filename; if (!is_file($full_filename)) { throw new ExceptionFatal('Template file ' . Url::html_output($full_filename) . ' cannot be found.'); } //read raw file contents $contents = file_get_contents($full_filename); if ($contents === false) { throw new ExceptionFatal('Template file ' . Url::html_output($full_filename) . ' could not be opened for reading.'); } //remove comments $contents = preg_replace('#/\*.*?\*/#s', '', $contents); //replace info variables and word strings from language file $tr = array( '{info:dir}' => (isset($dir) ? Url::html_output($dir) : ''), '{info:subdir}' => (isset($subdir) ? Url::html_output($subdir) : ''), '{info:version}' => VERSION, '{info:page_time}' => round((microtime(true) - START_TIME) * 1000, 1), '{info:statinfo}' => $mobile_device_detect->detect()->getInfo(), '{info:message}' => $words->__get('cookie consent msg'), '{info:dismiss}' => $words->__get('cookie consent OK'), '{info:link}' => $words->__get('cookie consent info'), '{info:href}' => $words->__get('privacy') ); $contents = preg_replace_callback('/\{\s*words?\s*:\s*(.+)\s*\}/Ui', array('self', 'callback_words'), strtr($contents, $tr)); //replace {config} variables $contents = preg_replace_callback('/\{\s*config\s*:\s*(.+)\s*\}/Ui', array('self', 'callback_config'), $contents); //parse includes $this->out = preg_replace_callback('/\{\s*include\s*:\s*(.+)\s*\}/Ui', array('self', 'callback_include'), $contents); } /** * @return string The HTML text of the parsed template */ public function __toString() { return $this->out; } } ?> classes/TemplateInfo.php0000755000000000000000000001331514576214512012516 0ustar * @version 1.1.0 (January 01, 2006) * @package AutoIndex */ class TemplateInfo extends TemplateIndexer { /** * @var DirectoryListDetailed */ private $dir_list; protected $config; protected $request; /** * @param array $m The array given by preg_replace_callback() * @return string Link to change the sort mode */ private static function callback_sort($m) { global $subdir, $request; $m = Url::html_output(strtolower($m[1])); $temp = Url::html_output($request->server('PHP_SELF')) . '?dir=' . $subdir . '&sort=' . $m . '&sort_mode=' . (($_SESSION['sort'] == $m && $_SESSION['sort_mode'] == 'a') ? 'd' : 'a'); if ($request->is_set_get(array('search', 'search_mode')) && $request->is_not_empty_get('search') && $request->is_not_empty_get('search_mode')) { $temp .= '&search=' . Url::html_output($request->get('search')) . '&search_mode=' . Url::html_output($request->get('search_mode')); } return $temp; } /** * @param array $m The array given by preg_replace_callback() * @return string Property is gotten from dir_list */ private function callback_info($m) { switch (strtolower($m[1])) { case 'archive_link': { global $config, $request; return Url::html_output($request->server('PHP_SELF')) . '?archive=true&dir=' . substr($this->dir_list->__get('dir_name'), strlen($config->__get('base_dir'))); } case 'total_size': { return $this->dir_list->__get('total_size')->formatted(); } case 'search_box': { return Search::search_box(); } case 'login_box': { global $you; return $you->login_box(); } case 'current_page_number': { if (!ENTRIES_PER_PAGE) { return 1; } global $page; return $page; } case 'last_page_number': { if (!ENTRIES_PER_PAGE) { return 1; } global $max_page; return $max_page; } case 'previous_page_link': { if (!ENTRIES_PER_PAGE) { return ''; } global $config, $page; if ($page <= 1) { return '<<'; } return '<<'; } case 'next_page_link': { if (!ENTRIES_PER_PAGE) { return ''; } global $config, $page, $max_page, $request; if ($page >= $max_page) { return '>>'; } return '>>'; } default: { return $this->dir_list->__get($m[1]); } } } /** * Either the HTML text is returned, or an empty string is returned, * depending on if the if-statement passed. * * @param array $m The array given by preg_replace_callback() * @return string The result to insert into the HTML */ private static function callback_if($m) { $var = strtoupper($m[1]); if (!defined($var)) { throw new ExceptionDisplay('$' . Url::html_output($m[1]) . ' is not a valid variable (check if-statement in template file).'); } return (constant($var) ? $m[2] : ''); } /** * @param string $filename The name of the file to parse * @param DirectoryListDetailed $dir_list */ public function __construct($filename, DirectoryListDetailed $dir_list) { parent::__construct($filename); $this->dir_list = $dir_list; //parse if-statements $last_text = ''; $regex = '/\{\s*if\s*:\s*(\w+)\s*\}(.*)\{\s*end\s*if\s*:\s*\1\s*\}/Uis'; //match {if:foo} ... {end if:foo} while ($last_text != ($this->out = preg_replace_callback($regex, array($this, 'callback_if'), $this->out))) { $last_text = $this->out; } $this->out = $last_text; //parse sort modes $this->out = preg_replace_callback('/\{\s*sort\s*:\s*(\w+)\s*\}/Ui', array($this, 'callback_sort'), $this->out); //replace {info} variables $this->out = preg_replace_callback('/\{\s*info\s*:\s*(\w+)\s*\}/Ui', array($this, 'callback_info'), $this->out); } } ?>classes/Upload.php0000755000000000000000000001160314530557667011364 0ustar * @version 1.0.1 (June 30, 2004) * @package AutoIndex */ class Upload { /** * Uploads all files in the $_FILES array, then echos the results. */ public function do_upload() { $uploaded_files = $errors = ''; global $request, $words, $log, $dir; foreach ($_FILES as $file_upload) { $filename = Item::get_basename($file_upload['name']); if ($filename == '') { continue; } if (DirectoryList::is_hidden($filename)) { $errors .= "
  • $filename [" . $words->__get('filename is listed as a hidden file') . ']
  • '; continue; } $filename = Url::clean_input($filename); $fullpathname = realpath($dir) . '/' . $filename; if (@file_exists($fullpathname)) { $errors .= "
  • $filename [" . $words->__get('file already exists') . ']
  • '; } else if (@move_uploaded_file($file_upload['tmp_name'], $fullpathname)) { @chmod($fullpathname, 0644); $uploaded_files .= "
  • $filename
  • "; $log -> add_entry("Uploaded file: $filename"); } else { $errors .= "
  • $filename
  • "; } } if ($errors == '') { $errors = '
    [' . $words->__get('none') . ']'; } if ($uploaded_files == '') { $uploaded_files = '
    [' . $words->__get('none') . ']'; } $str = '
    ' . '' . $words->__get('uploaded files') . ": $uploaded_files

    " . $words->__get('failed files') . ": $errors" . '

    ' . $words->__get('continue') . '.

    '; echo new Display($str); die(); } /** * @param User $current_user Makes sure the user has permission to upload files */ public function __construct(User $current_user) { if ($current_user->level < LEVEL_TO_UPLOAD) { throw new ExceptionDisplay('Your user account does not have permission to upload files.'); } } /** * @return string The HTML that makes up the upload form */ public function __toString() { global $request, $words, $subdir; if ($request->is_set_get('num_uploads') && (int)$request->get('num_uploads') > 0) { $str = '

    '; $num = min((int)$request->get('num_uploads'), 100); for ($i = 0; $i < $num; $i++) { $str .= "\n\t" . $words->__get('file') . ' '. ($i + 1) . ' :
    '; } $str .= '

    '; $str = '
    ' . $str . '

    ' . $words->__get('continue') . '.

    '; echo new Display($str); die(); } return '

    ' . $words->__get('upload') . ' ' . $words->__get('files to this folder') . '

    '; } } ?> classes/Url.php0000755000000000000000000001273414516224316010672 0ustar * @version 1.0.4 (November 9, 2007) * @package AutoIndex */ class Url { /** * @var string */ private $url; /** * Rawurlencodes $uri, but not slashes. * * @param string $uri * @return string */ public static function translate_uri($uri) { $uri = rawurlencode(str_replace('\\', '/', $uri)); return str_replace(rawurlencode('/'), '/', $uri); } /** * Returns the string with correct HTML entities so it can be displayed. * * @param string $str * @return string */ public static function html_output($str) { return htmlentities($str, ENT_QUOTES, 'UTF-8'); } /** * Checks input for hidden files/folders, and deals with ".." * * @param string $d The URL to check * @return string Safe version of $d */ private static function eval_dir($d) { $d = str_replace('\\', '/', $d); if ($d == '' || $d == '/') { return ''; } $dirs = explode('/', $d); for ($i = 0; $i < count($dirs); $i++) { if (DirectoryList::is_hidden($dirs[$i], false)) { array_splice($dirs, $i, 1); $i--; } else if (preg_match('/^\.\./', $dirs[$i])) //if it starts with two dots { array_splice($dirs, $i-1, 2); $i = -1; } } $new_dir = implode('/', $dirs); if ($new_dir == '' || $new_dir == '/') { return ''; } if ($d[0] == '/' && $new_dir[0] != '/') { $new_dir = '/' . $new_dir; } if (preg_match('#/$#', $d) && !preg_match('#/$#', $new_dir)) { $new_dir .= '/'; } else if (DirectoryList::is_hidden(Item::get_basename($new_dir))) { return DirItem::get_parent_dir($new_dir); //it's a file, so make sure the file itself is not hidden } return $new_dir; } /** * @param string $url The URL path to check and clean * @return string Resolves $url's special chars and runs eval_dir on it */ public static function clean_input($url) { $url = rawurldecode( $url ); $newURL = ''; for ( $i = 0; $i < strlen( $url ); $i++ ) //loop to remove all null chars { if ( ord($url[$i]) != 0 ) { $newURL .= $url[$i]; } } return self::eval_dir( $newURL ); } /** * Sends the browser a header to redirect it to this URL. */ public function redirect() { $site = $this -> url; header("Location: $site"); die(simple_display('Redirection header could not be sent.
    ' . "Continue here: $site")); } /** * @param string $file_dl * @param bool $headers */ public static function force_download($file_dl, $headers = true) { if (!@is_file($file_dl)) { header('HTTP/1.0 404 Not Found'); throw new ExceptionDisplay('The file ' . self::html_output($file_dl) . ' could not be found on this server.'); } if (!($fn = fopen($file_dl, 'rb'))) { throw new ExceptionDisplay('

    Error 401: permission denied

    you cannot access ' . Url::html_output($file_dl) . ' on this server.'); } if ($headers) { $outname = Item::get_basename($file_dl); $size = filesize($file_dl); if ($size !== false) { header('Content-Length: ' . $size); } $mime = new MimeType($outname); header('Content-Type: ' . $mime -> __toString() . '; name="' . $outname . '"'); header('Content-Disposition: attachment; filename="' . $outname . '"'); } global $speed; while (true) { $temp = fread($fn, (int)($speed * 1024)); if ($temp === '') { break; } echo $temp; flush(); if (BANDWIDTH_LIMIT) { sleep(1); } } fclose($fn); } /** * Downloads the URL on the user's browser, using either the redirect() * or force_download() functions. */ public function download() { if (FORCE_DOWNLOAD) { @set_time_limit(0); self::force_download(self::clean_input($this -> url)); die(); } $this -> redirect(); } /** * @param string $text_url The URL to create an object from * @param bool $special_chars If true, translate_uri will be run on the url */ public function __construct($text_url, $special_chars = false) { if ($special_chars) { $text_url = self::translate_uri($text_url); } $this -> url = $text_url; } /** * @return string Returns the URL as a string */ public function __toString() { return $this -> url; } } ?> classes/User.php0000755000000000000000000001213614571144660011046 0ustar * @version 1.0.1 (July 21, 2004) * @package AutoIndex */ class User { /** * @var string Username */ public $username; /** * @var string The password, stored as a sha-1 hash of the actual password */ public $sha1_pass; /** * @var int The user's level (use the GUEST USER ADMIN constants) */ public $level; /** * @var string The user's home directory, or an empty string to use the default base_dir */ public $home_dir; /** * @param User $user The user to compare to $this * @return bool True if this user is equal to $user, based on username and password */ public function equals(User $user) { return ((strcasecmp($this->username, $user->username) === 0) && (strcasecmp($this->sha1_pass, $user->sha1_pass) === 0)); } /** * Since this is not an instance of UserLoggedIn, we know he is not * logged in. */ public function logout() { global $request, $config; $autoindex_u = $request->server('PHP_SELF'); $autoindex_u = empty($autoindex_u) ? $config->__get('base_dir') : $request->server('PHP_SELF'); $autoindex_a = str_replace(array('&logout=true', '&logout=true'), array('', ''), $autoindex_u); if ($request->is_not_set('action')) { $home = new Url(Url::html_output($autoindex_a), true); //header("Location: $autoindex_a"); $home->redirect(); } die(simple_display('You are not logged in. Redirection header could not be sent.
    ' . "Continue here: Main Index")); } /** * Here we display a login box rather than account options, since this is * not an instance of UserLoggedIn. * * @return string The HTML text of the login box */ public function login_box() { $str = ''; if (USE_LOGIN_SYSTEM) { global $words, $subdir, $request; $str .= '
    ' . $words->__get('username') . ': ' . '
    ' . $words->__get('password') . ':
    ' . '

    '; } if (LEVEL_TO_UPLOAD === GUEST) { global $you; $upload_panel = new Upload($you); $str .= $upload_panel->__toString(); } return $str; } /** * @param string $username Username * @param string $sha1_pass Password as a sha-1 hash * @param int $level User's level (use the GUEST, USER, MODERATOR, ADMIN constants) * @param string $home_dir The home directory of the user, or blank for the default */ public function __construct($username = '', $sha1_pass = '', $level = GUEST, $home_dir = '') { $level = (int)$level; if ($level < BANNED || $level > ADMIN) { throw new ExceptionDisplay('Error in user accounts file: Invalid user level (for username "' . Url::html_output($username) . '").'); } if ($sha1_pass != '' && strlen($sha1_pass) !== 40) { throw new ExceptionDisplay('Error in user accounts file: Invalid password hash (for username "' . Url::html_output($username) . '").'); } $this->sha1_pass = $sha1_pass; $this->username = $username; $this->level = $level; $this->home_dir = $home_dir; } /** * @return string This string format is how it is stored in the user_list file */ public function __toString() { return $this->username . "\t" . $this->sha1_pass . "\t" . $this->level . "\t" . $this->home_dir . "\n"; } } ?> classes/UserLoggedIn.php0000755000000000000000000000716614576207207012470 0ustar * @version 1.0.1 (July 02, 2004) * @package AutoIndex */ class UserLoggedIn extends User { /** * Since the user is already logged in, the account options will be * displayed rather than a login box. * * @return string The HTML text that makes up the account options box */ public function login_box() { global $config, $words, $request, $you, $subdir; $PHP_SELF = $request->server('PHP_SELF'); $autoindex_u = empty($PHP_SELF) ? $config->__get('base_dir') : $PHP_SELF; $autoindex_a = str_replace(array('&logout=true', '&logout=true'), array('', ''), $autoindex_u); $txt = '

    ' . $words->__get('logout') . ' [ ' . Url::html_output($this->username) . ' ]

    '; if ($you->level >= MODERATOR) //show admin options if they are a moderator or higher { $admin_panel = new Admin($you); $txt = $admin_panel->__toString() . $txt; } if ($you->level >= LEVEL_TO_UPLOAD) //show upload options if they are a logged in user or higher { $upload_panel = new Upload($you); $txt .= $upload_panel->__toString(); } return $txt; } /** * Logs out the user by destroying the session data and refreshing the * page. */ public function logout() { global $request, $subdir; $this->level = GUEST; $this->sha1_pass = $this->username = ''; session_unset(); session_destroy(); $home = new Url(Url::html_output($request->server('PHP_SELF', '')), true); $home->redirect(); } /** * Validates username and password using the accounts stored in the * user_list file. * * @param string $username The username to login * @param string $sha1_pass The sha-1 hash of the password */ public function __construct($username, $sha1_pass) { parent::__construct($username, $sha1_pass); $accounts = new Accounts(); if (!($accounts->is_valid_user($this))) { global $log; $log->add_entry("Invalid login (Username: $username)"); session_unset(); sleep(1); throw new ExceptionDisplay('Invalid username or password.'); } $this->level = $accounts->get_level($username); if ($this->level <= BANNED) { throw new ExceptionDisplay('Your account has been disabled by the site admin.'); } $this->username = $accounts->get_stored_case($username); $this->home_dir = $accounts->get_home_dir($username); } } ?>