"English (US)" ) + $results; return $results; } // get_languages /** * is_rtl * This checks whether to be a rtl language. */ function is_rtl($locale) { return in_array($locale, array("he_IL", "fa_IR", "ar_SA")); } /** * translate_pattern_code * This just contains a keyed array which it checks against to give you the * 'tag' name that said pattern code corrasponds to. It returns false if nothing * is found. */ 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'); if (isset($code_array[$code])) { return $code_array[$code]; } return false; } // translate_pattern_code /** * generate_config * * This takes an array of results and re-generates the config file * this is used by the installer and by the admin/system page */ function generate_config($current) { // Start building the new config file $distfile = AmpConfig::get('prefix') . '/config/ampache.cfg.php.dist'; $handle = fopen($distfile,'r'); $dist = fread($handle,filesize($distfile)); fclose($handle); $data = explode("\n",$dist); $final = ""; foreach ($data as $line) { if (preg_match("/^;?([\w\d]+)\s+=\s+[\"]{1}(.*?)[\"]{1}$/",$line,$matches) || preg_match("/^;?([\w\d]+)\s+=\s+[\']{1}(.*?)[\']{1}$/", $line, $matches) || preg_match("/^;?([\w\d]+)\s+=\s+[\'\"]{0}(.*)[\'\"]{0}$/",$line,$matches)) { $key = $matches[1]; $value = $matches[2]; // Put in the current value if ($key == 'config_version') { $line = $key . ' = ' . escape_ini($value); } elseif (isset($current[$key])) { $line = $key . ' = "' . escape_ini($current[$key]) . '"'; unset($current[$key]); } } $final .= $line . "\n"; } return $final; } /** * write_config * * Write new configuration into the current configuration file by keeping old values. */ function write_config($current_file_path) { $new_data = generate_config(parse_ini_file($current_file_path)); // Start writing into the current config file $handle = fopen($current_file_path, 'w+'); fwrite($handle, $new_data, strlen($new_data)); fclose($handle); } /** * escape_ini * * Escape a value used for inserting into an ini file. * Won't quote ', like addslashes does. */ function escape_ini($str) { return str_replace('"', '\"', $str); } // Declare apache_request_headers and getallheaders if it don't exists (PHP <= 5.3 + FastCGI) if (!function_exists('apache_request_headers')) { function apache_request_headers() { $headers = array(); foreach ($_SERVER as $name => $value) { if (substr($name, 0, 5) == 'HTTP_') { $name = str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5))))); $headers[$name] = $value; } else if ($name == "CONTENT_TYPE") { $headers["Content-Type"] = $value; } else if ($name == "CONTENT_LENGTH") { $headers["Content-Length"] = $value; } } return $headers; } function getallheaders() { return apache_request_headers(); } } function get_current_path() { if (strlen($_SERVER['PHP_SELF'])) { $root = $_SERVER['PHP_SELF']; } else { $root = $_SERVER['REQUEST_URI']; } return $root; } function get_web_path() { $root = get_current_path(); //$root = rtrim(dirname($root),"/\\"); $root = preg_replace('#(.*)/(\w+\.php)$#', '$1', $root); return $root; }