' ; if (isset($_POST["qstring"])) { // checks if the search string has been posted to the page /*connect to database */ $host = "mysql5.hostexcellence.com"; $user = "ddbstoc_user"; $pass = "00none00"; $database = "ddbstoc_largeimage"; $table = "largeimage"; $link = mysql_connect($host, $user, $pass) or die("could not connect: " . mysql_error()); mysql_select_db($database, $link) or die("could not select ddbstock database: " . mysql_error()); $mysearchterms = $_POST["qstring"]; // retrieve the search string from the POST variable $mysearch = new MysqlSearch; // create a new mysqlsearch object $mysearch->setidentifier("imageid"); // set imageid as the primary key $mysearch->settable($table); // set the table to search in as ddbstock $mysearch->setsearchcolumns("keywords, caption"); // specify which columns to search in $results_array = $mysearch->find($mysearchterms); // perform search $_SESSION['results'] = $results_array; // assign the search results to a session variable $num_results = count($results_array); // get a count of the results search_lt_header(); // output the search box and light table information print "$num_results entries found for $mysearchterms
\n"; if ($num_results == 0) { print "no results found.\n"; } else { if ($num_results > 20) { // checks the number of results, if greater than 20... print "displaying results 1-20
\n"; result_links($results_array, 0); // display the links for the rest of the results imagetable($results_array, 0, 20); // display the image table for the first 20 results $footerflag = true; // flag to display the other pages below the images } else { // less than 20 results print "displaying results 1-$num_results
\n"; imagetable($results_array, 0, $num_results); // display all the results in one table with no links } } } elseif (isset($_SERVER['QUERY_STRING'])) { // verifies that there is a query string $arglist = $_SERVER['QUERY_STRING']; $arg_pairs = explode("&", $arglist); // split the arguments into an array if (is_array($arg_pairs)) { // verifies that the array was made foreach ($arg_pairs as $pair) { // creates a vars array that contains all the variables in the query string list($key, $var) = explode("=", $pair); $vars[$key] = $var; } switch ($vars['state']) { // checks the state variable for which action to take // viewing search results case "search" : if (isset($_SESSION['results'])) { // verifies that the results session variable exists $results_array = $_SESSION['results']; // populates a local variable with the session variable search_lt_header(); // displays the search and lighttable header if (isset($results_array) && isset($vars['start'])) { // if there are search results and a starting point $start = $vars['start']; $end = $start + 20; $start = $start + 1; if ($end > count($results_array)) { // condition so it doesnt claim to be displaying more results than are available print "Displaying results " . $start . "-" . count($results_array) . "
\n"; } else { print "Displaying results " . $start . "-" . $end . "
\n"; } result_links($results_array, $vars['start']); imagetable($results_array, $vars['start']); result_links($results_array, $vars['start']); } } else { // nothing in the results session variable print "please reenter your search query
\n"; } break; // add an image to the lighttable case "add_img" : if (isset($vars['addimageid'])) { // verifies that there is a value for addimageid in the query string $_SESSION['imageids'][$vars['addimageid']] = $vars['addimageid']; // add that imageid to the session array // print "Image {$vars['addimageid']} added to light table
\n"; if($vars['from'] == "cats") { // the image being added is from a category view page search_lt_header(); print "Image {$vars['addimageid']} added to light table
\n"; display_category($vars['cat']); } else { // the image being added is from a search results page /************************BEGIN KLUDGE************************/ if (isset($_SESSION['results'])) { // verifies that the results session variable exists $results_array = $_SESSION['results']; // populates a local variable with the session variable search_lt_header(); // displays the search and lighttable header print "Image {$vars['addimageid']} added to light table
\n"; if (isset($results_array) && isset($vars['start'])) { // if there are search results and a starting point $start = $vars['start']; $end = $start + 20; $start = $start + 1; if ($end > count($results_array)) { // condition so it doesnt claim to be displaying more results than are available print "Displaying results " . $start . "-" . count($results_array) . "
\n"; } else { print "Displaying results " . $start . "-" . $end . "
\n"; } result_links($results_array, $vars['start']); imagetable($results_array, $vars['start']); result_links($results_array, $vars['start']); } } else { // nothing in the results session variable print "please reenter your search query
\n"; } /************************END KLUDGE**************************/ } } else { // there was no value for addimageid search_lt_header(); print "no image to display
\n"; } break; // remove an image from the lighttable case "del_img" : if (isset($vars['delimageid'])) { // verifies that there is a vlue for delimageid in the query string unset($_SESSION['imageids'][$vars['delimageid']]); // removes the imageid from the imageids session array search_lt_header(); // displays the search and lighttable header view_light_table("Image {$vars['delimageid']} removed from light table
\n");// displays the users lighttable } else { // there was no value for dellimageid search_lt_header(); print "no image to delete
\n"; } break; // view lightable case "view_lt" : search_lt_header(); //displays the search and lighttable header view_light_table(""); // displays the users lighttable break; // view category listing case "view_cats": if (isset($vars['letter'])) { // verifies that there is a value for letter search_lt_header(); // displays the search and lighttable header view_categories($vars['letter']); // sends view_categories the first letter of the categories to display } else { // there was no value for letter print "no letter for category\n"; } break; // view specific category case "disp_cats": if (isset($vars['cat'])) { search_lt_header(); display_category($vars['cat']); } else { print "no category to display
"; } break; case "enlarge": if(isset($vars['imageid'])) { search_lt_header(); enlarged_pic($vars['imageid']); } else { print "no imageid to enlarge"; } break; default : search_lt_header(); break; } } } else { // nothing has been posted to the page and there are no query strings in the url, this is the case for the first visit to the page search_lt_header(); view_categories("a"); } ?>