diff options
author | Paul Arthur <paul.arthur@flowerysong.com> | 2013-01-26 03:00:32 -0500 |
---|---|---|
committer | Paul Arthur <paul.arthur@flowerysong.com> | 2013-01-26 03:38:46 -0500 |
commit | ef4d3660605efc7f1328d4533b0f4bfb6c1107e2 (patch) | |
tree | e4377fb129a899e65aaaf421f8c97098aecaedd5 /lib/general.lib.php | |
parent | 8a750c3e875d590d351c3042570a134fcdf03e5d (diff) | |
download | ampache-ef4d3660605efc7f1328d4533b0f4bfb6c1107e2.tar.gz ampache-ef4d3660605efc7f1328d4533b0f4bfb6c1107e2.tar.bz2 ampache-ef4d3660605efc7f1328d4533b0f4bfb6c1107e2.zip |
Cosmetics: death to tabs
The refactoring I've been doing has reminded me of my strong preference
for spaces, and I feel inclined to impose my will on the tree.
Diffstat (limited to 'lib/general.lib.php')
-rw-r--r-- | lib/general.lib.php | 262 |
1 files changed, 131 insertions, 131 deletions
diff --git a/lib/general.lib.php b/lib/general.lib.php index 6833b8bf..9ba241b2 100644 --- a/lib/general.lib.php +++ b/lib/general.lib.php @@ -1,5 +1,5 @@ <?php -/* vim:set tabstop=8 softtabstop=8 shiftwidth=8 noexpandtab: */ +/* vim:set softtabstop=4 shiftwidth=4 expandtab: */ /** * * LICENSE: GNU General Public License, version 2 (GPLv2) @@ -27,12 +27,12 @@ */ function set_memory_limit($new_limit) { - $current_limit = unUI::format_bytes(ini_get('memory_limit')); - $new_limit = unUI::format_bytes($new_limit); + $current_limit = unUI::format_bytes(ini_get('memory_limit')); + $new_limit = unUI::format_bytes($new_limit); - if ($current_limit < $new_limit) { - ini_set (memory_limit, $new_limit); - } + if ($current_limit < $new_limit) { + ini_set (memory_limit, $new_limit); + } } // set_memory_limit @@ -42,24 +42,24 @@ function set_memory_limit($new_limit) { */ function generate_password($length) { - $vowels = 'aAeEuUyY12345'; - $consonants = 'bBdDgGhHjJmMnNpPqQrRsStTvVwWxXzZ6789'; - $password = ''; + $vowels = 'aAeEuUyY12345'; + $consonants = 'bBdDgGhHjJmMnNpPqQrRsStTvVwWxXzZ6789'; + $password = ''; - $alt = time() % 2; + $alt = time() % 2; - for ($i = 0; $i < $length; $i++) { - if ($alt == 1) { - $password .= $consonants[(rand(0,strlen($consonants)-1))]; - $alt = 0; - } - else { - $password .= $vowels[(rand(0,strlen($vowels)-1))]; - $alt = 1; - } - } + for ($i = 0; $i < $length; $i++) { + if ($alt == 1) { + $password .= $consonants[(rand(0,strlen($consonants)-1))]; + $alt = 0; + } + else { + $password .= $vowels[(rand(0,strlen($vowels)-1))]; + $alt = 1; + } + } - return $password; + return $password; } // generate_password @@ -69,16 +69,16 @@ function generate_password($length) { */ function scrub_in($input) { - if (!is_array($input)) { - return stripslashes(htmlspecialchars(strip_tags($input))); - } - else { - $results = array(); - foreach($input as $item) { - $results[] = scrub_in($item); - } - return $results; - } + if (!is_array($input)) { + return stripslashes(htmlspecialchars(strip_tags($input))); + } + else { + $results = array(); + foreach($input as $item) { + $results[] = scrub_in($item); + } + return $results; + } } // scrub_in /** @@ -88,7 +88,7 @@ function scrub_in($input) { */ function scrub_out($string) { - return htmlentities($string, ENT_QUOTES, Config::get('site_charset')); + return htmlentities($string, ENT_QUOTES, Config::get('site_charset')); } // scrub_out @@ -98,7 +98,7 @@ function scrub_out($string) { */ function unhtmlentities($string) { - return html_entity_decode($string, ENT_QUOTES, Config::get('site_charset')); + return html_entity_decode($string, ENT_QUOTES, Config::get('site_charset')); } //unhtmlentities @@ -109,11 +109,11 @@ function unhtmlentities($string) { */ function scrub_arg($arg) { - if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { - return '"' . str_replace(array('"', '%'), array('', ''), $arg) . '"'; - } else { - return "'" . str_replace("'", "'\\''", $arg) . "'"; - } + if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { + return '"' . str_replace(array('"', '%'), array('', ''), $arg) . '"'; + } else { + return "'" . str_replace("'", "'\\''", $arg) . "'"; + } } /** @@ -123,11 +123,11 @@ function scrub_arg($arg) */ function make_bool($string) { - if (strcasecmp($string,'false') == 0) { - return false; - } + if (strcasecmp($string,'false') == 0) { + return false; + } - return (bool)$string; + return (bool)$string; } // make_bool @@ -137,7 +137,7 @@ function make_bool($string) { */ function invert_bool($value) { - return make_bool($value) ? false : true; + return make_bool($value) ? false : true; } // invert_bool @@ -150,81 +150,81 @@ function invert_bool($value) { */ function get_languages() { - /* Open the locale directory */ - $handle = @opendir(Config::get('prefix') . '/locale'); - - if (!is_resource($handle)) { - debug_event('language','Error unable to open locale directory','1'); - } - - $results = array(); - - /* Prepend English */ - $results['en_US'] = 'English (US)'; - - while ($file = readdir($handle)) { - - $full_file = Config::get('prefix') . '/locale/' . $file; - - /* Check to see if it's a directory */ - if (is_dir($full_file) AND substr($file,0,1) != '.' AND $file != 'base') { - - switch($file) { - case 'af_ZA'; $name = 'Afrikaans'; break; /* Afrikaans */ - case 'ca_ES'; $name = 'Català'; break; /* Catalan */ - case 'cs_CZ'; $name = 'Česky'; break; /* Czech */ - case 'da_DK'; $name = 'Dansk'; break; /* Danish */ - case 'de_DE'; $name = 'Deutsch'; break; /* German */ - case 'en_US'; $name = 'English (US)'; break; /* English */ - case 'en_GB'; $name = 'English (UK)'; break; /* English */ - case 'es_ES'; $name = 'Español'; break; /* Spanish */ - case 'es_MX'; $name = 'Español (MX)'; break; /* Spanish */ - case 'es_AR'; $name = 'Español (AR)'; break; /* Spanish */ - case 'et_EE'; $name = 'Eesti'; break; /* Estonian */ - case 'eu_ES'; $name = 'Euskara'; break; /* Basque */ - case 'fr_FR'; $name = 'Français'; break; /* French */ - case 'ga_IE'; $name = 'Gaeilge'; break; /* Irish */ - case 'el_GR'; $name = 'Greek'; break; /* Greek */ - case 'is_IS'; $name = 'Icelandic'; break; /* Icelandic */ - case 'it_IT'; $name = 'Italiano'; break; /* Italian */ - case 'lv_LV'; $name = 'Latviešu'; break; /* Latvian */ - case 'lt_LT'; $name = 'Lietuvių'; break; /* Lithuanian */ - case 'hu_HU'; $name = 'Magyar'; break; /* Hungarian */ - case 'nl_NL'; $name = 'Nederlands'; break; /* Dutch */ - case 'no_NO'; $name = 'Norsk bokmål'; break; /* Norwegian */ - case 'pl_PL'; $name = 'Polski'; break; /* Polish */ - case 'pt_BR'; $name = 'Português Brasileiro'; break; /* Portuguese */ - case 'pt_PT'; $name = 'Português'; break; /* Portuguese */ - case 'ro_RO'; $name = 'Română'; break; /* Romanian */ - case 'sk_SK'; $name = 'Slovenčina'; break; /* Slovak */ - case 'sl_SI'; $name = 'Slovenščina'; break; /* Slovenian */ - case 'sr_CS'; $name = 'Srpski'; break; /* Serbian */ - case 'fi_FI'; $name = 'Suomi'; break; /* Finnish */ - case 'sv_SE'; $name = 'Svenska'; break; /* Swedish */ - case 'uk_UA'; $name = 'Українська'; break; /* Ukrainian */ - case 'vi_VN'; $name = 'Tiếng Việt'; break; /* Vietnamese */ - case 'tr_TR'; $name = 'Türkçe'; break; /* Turkish */ - case 'bg_BG'; $name = 'Български'; break; /* Bulgarian */ - case 'ru_RU'; $name = 'Русский'; break; /* Russian */ - case 'zh_CN'; $name = '简体中文'; break; /* Chinese */ - case 'zn_TW'; $name = '繁體中文'; break; /* Chinese */ - case 'ko_KR'; $name = '한국말'; break; /* Korean */ - case 'ja_JP'; $name = '日本語'; break; /* Japanese */ - case 'nb_NO'; $name = 'Norsk'; break; /* Norwegian */ - /* These languages are right to left. */ - case 'ar_SA'; $name = 'العربية'; break; /* Arabic */ - case 'he_IL'; $name = 'עברית'; break; /* Hebrew */ - case 'fa_IR'; $name = 'فارسي'; break; /* Farsi */ - default: $name = T_('Unknown'); break; - } // end switch - - - $results[$file] = $name; - } - - } // end while - - return $results; + /* Open the locale directory */ + $handle = @opendir(Config::get('prefix') . '/locale'); + + if (!is_resource($handle)) { + debug_event('language','Error unable to open locale directory','1'); + } + + $results = array(); + + /* Prepend English */ + $results['en_US'] = 'English (US)'; + + while ($file = readdir($handle)) { + + $full_file = Config::get('prefix') . '/locale/' . $file; + + /* Check to see if it's a directory */ + if (is_dir($full_file) AND substr($file,0,1) != '.' AND $file != 'base') { + + switch($file) { + case 'af_ZA'; $name = 'Afrikaans'; break; /* Afrikaans */ + case 'ca_ES'; $name = 'Català'; break; /* Catalan */ + case 'cs_CZ'; $name = 'Česky'; break; /* Czech */ + case 'da_DK'; $name = 'Dansk'; break; /* Danish */ + case 'de_DE'; $name = 'Deutsch'; break; /* German */ + case 'en_US'; $name = 'English (US)'; break; /* English */ + case 'en_GB'; $name = 'English (UK)'; break; /* English */ + case 'es_ES'; $name = 'Español'; break; /* Spanish */ + case 'es_MX'; $name = 'Español (MX)'; break; /* Spanish */ + case 'es_AR'; $name = 'Español (AR)'; break; /* Spanish */ + case 'et_EE'; $name = 'Eesti'; break; /* Estonian */ + case 'eu_ES'; $name = 'Euskara'; break; /* Basque */ + case 'fr_FR'; $name = 'Français'; break; /* French */ + case 'ga_IE'; $name = 'Gaeilge'; break; /* Irish */ + case 'el_GR'; $name = 'Greek'; break; /* Greek */ + case 'is_IS'; $name = 'Icelandic'; break; /* Icelandic */ + case 'it_IT'; $name = 'Italiano'; break; /* Italian */ + case 'lv_LV'; $name = 'Latviešu'; break; /* Latvian */ + case 'lt_LT'; $name = 'Lietuvių'; break; /* Lithuanian */ + case 'hu_HU'; $name = 'Magyar'; break; /* Hungarian */ + case 'nl_NL'; $name = 'Nederlands'; break; /* Dutch */ + case 'no_NO'; $name = 'Norsk bokmål'; break; /* Norwegian */ + case 'pl_PL'; $name = 'Polski'; break; /* Polish */ + case 'pt_BR'; $name = 'Português Brasileiro'; break; /* Portuguese */ + case 'pt_PT'; $name = 'Português'; break; /* Portuguese */ + case 'ro_RO'; $name = 'Română'; break; /* Romanian */ + case 'sk_SK'; $name = 'Slovenčina'; break; /* Slovak */ + case 'sl_SI'; $name = 'Slovenščina'; break; /* Slovenian */ + case 'sr_CS'; $name = 'Srpski'; break; /* Serbian */ + case 'fi_FI'; $name = 'Suomi'; break; /* Finnish */ + case 'sv_SE'; $name = 'Svenska'; break; /* Swedish */ + case 'uk_UA'; $name = 'Українська'; break; /* Ukrainian */ + case 'vi_VN'; $name = 'Tiếng Việt'; break; /* Vietnamese */ + case 'tr_TR'; $name = 'Türkçe'; break; /* Turkish */ + case 'bg_BG'; $name = 'Български'; break; /* Bulgarian */ + case 'ru_RU'; $name = 'Русский'; break; /* Russian */ + case 'zh_CN'; $name = '简体中文'; break; /* Chinese */ + case 'zn_TW'; $name = '繁體中文'; break; /* Chinese */ + case 'ko_KR'; $name = '한국말'; break; /* Korean */ + case 'ja_JP'; $name = '日本語'; break; /* Japanese */ + case 'nb_NO'; $name = 'Norsk'; break; /* Norwegian */ + /* These languages are right to left. */ + case 'ar_SA'; $name = 'العربية'; break; /* Arabic */ + case 'he_IL'; $name = 'עברית'; break; /* Hebrew */ + case 'fa_IR'; $name = 'فارسي'; break; /* Farsi */ + default: $name = T_('Unknown'); break; + } // end switch + + + $results[$file] = $name; + } + + } // end while + + return $results; } // get_languages @@ -233,7 +233,7 @@ function get_languages() { * This checks whether to be a rtl language. */ function is_rtl($locale) { - return in_array($locale, array("he_IL", "fa_IR", "ar_SA")); + return in_array($locale, array("he_IL", "fa_IR", "ar_SA")); } /** @@ -244,20 +244,20 @@ function is_rtl($locale) { */ function translate_pattern_code($code) { - $code_array = array('%A'=>'album', - '%a'=>'artist', - '%c'=>'comment', - '%g'=>'genre', - '%T'=>'track', - '%t'=>'title', - '%y'=>'year', - '%o'=>'zz_other'); + $code_array = array('%A'=>'album', + '%a'=>'artist', + '%c'=>'comment', + '%g'=>'genre', + '%T'=>'track', + '%t'=>'title', + '%y'=>'year', + '%o'=>'zz_other'); - if (isset($code_array[$code])) { - return $code_array[$code]; - } + if (isset($code_array[$code])) { + return $code_array[$code]; + } - return false; + return false; } // translate_pattern_code |