From e3734f063ed58356f9653a81f6dea86aa55931f4 Mon Sep 17 00:00:00 2001 From: Karl 'vollmerk' Vollmer Date: Sat, 17 Jun 2006 16:32:04 +0000 Subject: moved init.php improved vainfo a bit, removed checkboxes from search page --- lib/init.php | 286 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ lib/search.php | 21 ++++- 2 files changed, 302 insertions(+), 5 deletions(-) create mode 100644 lib/init.php (limited to 'lib') diff --git a/lib/init.php b/lib/init.php new file mode 100644 index 00000000..8a97f5c9 --- /dev/null +++ b/lib/init.php @@ -0,0 +1,286 @@ + 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); +?> diff --git a/lib/search.php b/lib/search.php index 5ab121ba..203168a9 100644 --- a/lib/search.php +++ b/lib/search.php @@ -33,12 +33,20 @@ function run_search($data) { /* Create an array of the object we need to search on */ - foreach ($data['search_object'] as $type) { - /* generate the full name of the textbox */ - $fullname = $type . "_string"; - $search[$type] = sql_escape($data[$fullname]); + foreach ($data as $key=>$value) { + /* Get the first two chars to check + * and see if it's s_ + */ + $prefix = substr($key,0,2); + $value = trim($value); + + if ($prefix == 's_' AND strlen($value)) { + $true_name = substr($key,2,strlen($key)); + $search[$true_name] = sql_escape($value); + } + } // end foreach - + /* Figure out if they want a AND based search or a OR based search */ switch($_REQUEST['operator']) { case 'or': @@ -156,6 +164,9 @@ function search_song($data,$operator,$method,$limit) { case 'filename': $where_sql .= " song.file $value_string $operator"; break; + case 'comment': + $where_sql .= " song.comment $value_string $operator"; + break; case 'played': /* This is a 0/1 value so bool it */ $value = make_bool($value); -- cgit