diff options
author | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2006-06-17 16:32:04 +0000 |
---|---|---|
committer | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2006-06-17 16:32:04 +0000 |
commit | e3734f063ed58356f9653a81f6dea86aa55931f4 (patch) | |
tree | 3aace945cfd5d8e988395170ff92ab75c0419819 /modules | |
parent | c6c2320170b488f64f1c67de23a35f4ca4de59de (diff) | |
download | ampache-e3734f063ed58356f9653a81f6dea86aa55931f4.tar.gz ampache-e3734f063ed58356f9653a81f6dea86aa55931f4.tar.bz2 ampache-e3734f063ed58356f9653a81f6dea86aa55931f4.zip |
moved init.php improved vainfo a bit, removed checkboxes from search page
Diffstat (limited to 'modules')
-rwxr-xr-x | modules/id3/vainfo.class.php | 46 | ||||
-rw-r--r-- | modules/init.php | 286 |
2 files changed, 37 insertions, 295 deletions
diff --git a/modules/id3/vainfo.class.php b/modules/id3/vainfo.class.php index d9efe341..23f2703f 100755 --- a/modules/id3/vainfo.class.php +++ b/modules/id3/vainfo.class.php @@ -28,19 +28,18 @@ class vainfo { /* Default Encoding */ - var $encoding = 'UTF-8'; + var $encoding = ''; /* Loaded Variables */ var $filename = ''; var $type = ''; var $tags = array(); - var $info = array(); - /* Internal Information */ var $_raw = array(); var $_getID3 = ''; var $_iconv = false; + var $_file_encoding = ''; var $_file_pattern = ''; var $_dir_pattern = ''; @@ -93,9 +92,15 @@ class vainfo { /* Figure out what type of file we are dealing with */ $this->type = $this->_get_type(); + /* This is very important, figure out th encoding of the + * file + */ + $this->_set_encoding(); + /* Get the general information about this file */ $info = $this->_get_info(); + /* Gets the Tags */ $this->tags = $this->_get_tags(); $this->tags['info'] = $info; @@ -105,6 +110,26 @@ class vainfo { } // get_info /** + * _set_encoding + * This function trys to figure out what the encoding + * is based on the file type and sets the _file_encoding + * var to whatever it finds, the default is UTF-8 if we + * can't find anything + */ + function _set_encoding() { + /* Switch on the file type */ + switch ($this->type) { + case 'mp3': + $this->_file_encoding = $this->_raw['encoding']; + break; + default: + $this->_file_encoding = 'UTF-8'; + break; + } // end switch + + } // _get_encoding + + /** * _get_type * This function takes the raw information and figures out * what type of file we are dealing with for use by the tag @@ -285,14 +310,14 @@ class vainfo { function _parse_id3v1($tags) { $array = array(); - + /* Go through all the tags */ foreach ($tags as $tag=>$data) { /* This is our baseline for naming * so no translation needed */ - $array[$tag] = $this->_clean_tag($data['0']); + $array[$tag] = $this->_clean_tag($data['0'],$this->_file_encoding); } // end foreach @@ -316,7 +341,7 @@ class vainfo { /* This is our baseline for naming so * no translation is needed */ - $array[$tag] = $this->_clean_tag($data['0']); + $array[$tag] = $this->_clean_tag($data['0'],$this->_file_encoding); } // end foreach @@ -379,10 +404,13 @@ class vainfo { * in the file */ function _clean_tag($tag,$encoding='') { + + /* Guess that it's UTF-8 */ + if (!$encoding) { $encoding = 'UTF-8'; } - - if ($this->_iconv) { - $tag = iconv('UTF-8',conf('site_charset'),$tag); + if ($this->_iconv AND strcasecmp($encoding,$this->encoding) != 0) { + $charset = $this->encoding . '//TRANSLIT'; + $tag = iconv($encoding,$charset,$tag); } return $tag; diff --git a/modules/init.php b/modules/init.php deleted file mode 100644 index 96b99a21..00000000 --- a/modules/init.php +++ /dev/null @@ -1,286 +0,0 @@ -<?php -/* - - Copyright (c) 2001 - 2006 Ampache.org - All rights reserved. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -*/ - -/*! - @header INIT file - Take care of our init grunt work so we don't scatter paths - all over the place. - -*/ - -// Set the Error level manualy... I'm to lazy to fix notices -error_reporting(E_ALL ^ E_NOTICE); - -// This makes this file nolonger need customization -// the config file is in the same dir as this (init.php) file. -$ampache_path = dirname(__FILE__); -$prefix = realpath($ampache_path . "/../"); -$configfile = "$prefix/config/ampache.cfg.php"; -require_once($prefix . "/lib/general.lib.php"); - -/*********************STOP EDITING*********************************/ - -/* - Check to see if this is Http or https -*/ -if ($_SERVER['HTTPS'] == 'on') { - $http_type = "https://"; -} -else { - $http_type = "http://"; -} - -/* - See if the Config File Exists if it doesn't - then go ahead and move them over to the install - script -*/ -if (!file_exists($configfile)) { - $path = preg_replace("/(.*)\/(\w+\.php)$/","\${1}", $_SERVER['PHP_SELF']); - $link = $http_type . $_SERVER['HTTP_HOST'] . $path . "/install.php"; - header ("Location: $link"); - exit(); -} - -/* - Try to read the config file, if it fails give them - an explanation -*/ -if (!$results = read_config($configfile,0)) { - $path = preg_replace("/(.*)\/(\w+\.php)$/","\${1}", $_SERVER['PHP_SELF']); - $link = $http_type . $_SERVER['HTTP_HOST'] . $path . "/test.php"; - header ("Location: $link"); - exit(); -} - - -//FIXME: Until we have a config updater force stream as allowed playback method -if (!$results['allow_stream_playback']) { - $results['allow_stream_playback'] = "true"; -} - - -/** This is the version.... fluf nothing more... **/ -$results['version'] = '3.3.2-Beta3 (Build 008)'; - -$results['raw_web_path'] = $results['web_path']; -$results['web_path'] = $http_type . $_SERVER['HTTP_HOST'] . $results['web_path']; -$results['catalog_file_pattern']= 'mp3|mpc|m4p|m4a|mp4|aac|ogg|rm|wma|asf|flac|spx|ra'; -$results['http_port'] = $_SERVER['SERVER_PORT']; -if (!$results['prefix']) { - $results['prefix'] = $prefix; -} -if (!$results['stop_auth']) { - $results['stop_auth'] = $results['prefix'] . "/modules/vauth/gone.fishing"; -} -if (!$results['http_port']) { - $results['http_port'] = '80'; -} -if (!$results['site_charset']) { - $results['site_charset'] = "iso-8859-1"; -} -if (!$results['ellipse_threshold_album']) { - $results['ellipse_threshold_album'] = 27; -} -if (!$results['ellipse_threshold_artist']) { - $results['ellipse_threshold_artist'] = 27; -} -if (!$results['ellipse_threshold_title']) { - $results['ellipse_threshold_title'] = 27; -} -if (!$results['raw_web_path']) { - $results['raw_web_path'] = '/'; -} -if (!$_SERVER['SERVER_NAME']) { - $_SERVER['SERVER_NAME'] = ''; -} - -/* Variables needed for vauth Module */ -$results['cookie_path'] = $results['raw_web_path']; -$results['cookie_domain'] = $_SERVER['SERVER_NAME']; -$results['cookie_life'] = $results['sess_cookielife']; -$results['session_name'] = $results['sess_name']; -$results['cookie_secure'] = '0'; -$results['session_length'] = '9000'; -$results['mysql_password'] = $results['local_pass']; -$results['mysql_username'] = $results['local_username']; -$results['mysql_hostname'] = $results['local_host']; -$results['mysql_db'] = $results['local_db']; - -/* Temp Fixes */ -$results = fix_preferences($results); - -// Setup Static Arrays -conf($results); - -// Vauth Requires -require_once(conf('prefix') . '/modules/vauth/init.php'); - -// Librarys -require_once(conf('prefix') . '/lib/album.lib.php'); -require_once(conf('prefix') . '/lib/artist.lib.php'); -require_once(conf('prefix') . '/lib/song.php'); -require_once(conf('prefix') . '/lib/search.php'); -require_once(conf('prefix') . '/lib/preferences.php'); -require_once(conf('prefix') . '/lib/rss.php'); -require_once(conf('prefix') . '/lib/log.lib.php'); -require_once(conf('prefix') . '/lib/localplay.lib.php'); -require_once(conf('prefix') . '/lib/ui.lib.php'); -require_once(conf('prefix') . '/lib/gettext.php'); -require_once(conf('prefix') . '/lib/batch.lib.php'); -require_once(conf('prefix') . '/lib/themes.php'); -require_once(conf('prefix') . '/lib/stream.lib.php'); -require_once(conf('prefix') . '/lib/playlist.lib.php'); -require_once(conf('prefix') . '/lib/upload.php'); -require_once(conf('prefix') . '/modules/lib.php'); -require_once(conf('prefix') . '/modules/admin.php'); -require_once(conf('prefix') . '/modules/catalog.php'); -require_once(conf('prefix') . "/modules/id3/getid3/getid3.php"); -require_once(conf('prefix') . '/modules/id3/vainfo.class.php'); -require_once(conf('prefix') . '/modules/amazon/Snoopy.class.php'); -require_once(conf('prefix') . '/modules/amazon/AmazonSearchEngine.class.php'); -require_once(conf('prefix') . '/lib/xmlrpc.php'); -require_once(conf('prefix') . '/modules/xmlrpc/xmlrpc.inc'); - -// Modules (These are conditionaly included depending upon config values) -if (conf('ratings')) { - require_once(conf('prefix') . '/lib/class/rating.class.php'); - require_once(conf('prefix') . '/lib/rating.lib.php'); -} - -// Classes -require_once(conf('prefix') . '/lib/class/localplay.class.php'); -require_once(conf('prefix') . '/lib/class/catalog.class.php'); -require_once(conf('prefix') . '/lib/class/stream.class.php'); -require_once(conf('prefix') . '/lib/class/playlist.class.php'); -require_once(conf('prefix') . '/lib/class/song.class.php'); -require_once(conf('prefix') . '/lib/class/view.class.php'); -require_once(conf('prefix') . '/lib/class/update.class.php'); -require_once(conf('prefix') . '/lib/class/user.class.php'); -require_once(conf('prefix') . '/lib/class/album.class.php'); -require_once(conf('prefix') . '/lib/class/artist.class.php'); -require_once(conf('prefix') . '/lib/class/access.class.php'); -require_once(conf('prefix') . '/lib/class/error.class.php'); -require_once(conf('prefix') . '/lib/class/genre.class.php'); -require_once(conf('prefix') . '/lib/class/flag.class.php'); - -/* Set a new Error Handler */ -$old_error_handler = set_error_handler("ampache_error_handler"); - -/* Initilize the Vauth Library */ -vauth_init($results); - -/* Check their PHP Vars to make sure we're cool here */ -if ($results['memory_limit'] < 16) { - $results['memory_limit'] = 16; -} -set_memory_limit($results['memory_limit']); - -if (ini_get('short_open_tag') != "On") { - ini_set (short_open_tag, "On"); -} - -// Check Session GC mojo, increase if need be -$gc_probability = @ini_get('session.gc_probability'); -$gc_divisor = @ini_get('session.gc_divisor'); - -if (!$gc_divisor) { - $gc_divisor = '100'; -} -if (!$gc_probability) { - $gc_probability = '1'; -} - -// Force GC on 1:5 page loads -if (($gc_divisor / $gc_probability) > 5) { - $new_gc_probability = $gc_divisor * .2; - ini_set('session.gc_probability',$new_gc_probability); -} - -/* PHP5 Date problem solved.. ya'll GMT now! */ -putenv("TZ=GMT"); - -/* Seed the random number */ -srand((double) microtime() * 1000003); - -/**** END Set PHP Vars ****/ - -// If we don't want a session -if (!isset($no_session) AND conf('use_auth')) { - if (!vauth_check_session()) { logout(); exit(); } - $user = new User($_SESSION['userdata']['username']); - init_preferences(); - set_theme(); - $user->set_preferences(); - $user->update_last_seen(); -} -elseif (!conf('use_auth')) { - $auth['success'] = 1; - $auth['username'] = '-1'; - $auth['fullname'] = "Ampache User"; - $auth['id'] = -1; - $auth['access'] = "admin"; - $auth['offset_limit'] = 50; - if (!vauth_check_session()) { vauth_session_create($auth); } - $user = new User(-1); - $user->fullname = 'Ampache User'; - $user->offset_limit = $auth['offset_limit']; - $user->username = '-1'; - $user->access = $auth['access']; - $_SESSION['userdata']['username'] = $auth['username']; - $user->set_preferences(); - init_preferences(); - set_theme(); -} -else { - $user = new user(); -} - -// Load gettext mojo -load_gettext(); - -/* Set CHARSET */ -header ("Content-Type: text/html; charset=" . conf('site_charset')); - -/* Clean up a bit */ -unset($array); -unset($results); - -/* Setup the flip class */ -flip_class(array('odd','even')); - -/* Setup the Error Class */ -$error = new Error(); - -/* Set the Theme */ -$theme = get_theme(conf('theme_name')); - -if (! preg_match('/update\.php/', $_SERVER['PHP_SELF'])) { - $update = new Update(); - if ($update->need_update()) { - header("Location: " . conf('web_path') . "/update.php"); - exit(); - } -} - -unset($update); -?> |