w'; // prevent loading without a page $use_header = '1'; $path_var = "Home > Search "; $connectdb = '1'; // get config file include('config.php'); // set up random icon picking range($start,$stop); $rand_set = range(1,50); shuffle($rand_set); shuffle($rand_set); $max_icons_available = 104; // init the counter $rand_cntr = 1; // how many items to display? // total is max_across * max_down $max_across = 3; $max_down = 5; $max_items = ($max_across * $max_down); // get incoming vars $stxt = $_GET['stxt']; $act = $_GET['act']; ////////////////////////////// // clean data $act = substr($act, 0,4); $stxt = substr($stxt, 0,12); $stxt = preg_replace ('|`|', '', $stxt); $act = preg_replace('|`|', '', $act); $stxt = htmlentities ($stxt, ENT_QUOTES); $act = htmlentities ($act, ENT_QUOTES); //print "ACT: $act, STXT: $stxt
"; // failsafe - no search if no text if($stxt == "" && $act == "srch"){$act = ""; $user_msg = "No text to search on! ";} // failsafe - no search if no text if(strlen($stxt) < 2 && $act == "srch"){$act = ""; $user_msg = "Please search for at least 2 characters.";} ////////////////////////////// // print the page... $title_text = "Search For Games"; if($stxt){$title_text = "Searching for: $stxt";} // set title $titlebar_text = "Search For Games"; $intro_text = ""; include('/var/www/jokesnfun.com/web/header.php'); include('/var/www/jokesnfun.com/web/games/topmenu.php'); print <<$title_text $intro_text $user_msg EOM; $cellcounter++; $itemcounter++; if($cellcounter == $max_across){ print "\n"; $cellcounter = 0; if($itemcounter != $max_items){ print "\n"; } } } //end while if($cellcounter == '1'){print "";} if($cellcounter == '2'){print "";} print "

Enter a term to search on:

 


EOM; // are we searching? if($act == "srch"){ print <<
EOM; $query = "SELECT * FROM game_list WHERE display_name LIKE '%$stxt%' AND enabled = '1' LIMIT 100"; //print "Q: $query
"; $result = mysqli_query($dbcon, $query ,$db); while ($myrow = mysqli_fetch_array($result)){ $game_id = $myrow['game_id']; $display_name = $myrow['display_name']; $rating = $myrow['rating']; $times_played = $myrow['times_played']; $image_name = $myrow['image_name']; $ratimg = round($rating) . "stars"; $display_name = reg_replace('|-|', ' ', $display_name); // correct for missing icons if($image_name == "stand_in.jpg"){ $image_name = image_picker(); } print <<
$display_name

Played $times_played times
  
 


\n"; } print << EOM; function image_picker(){ // selects an icon for games without an image global $image_name, $rand_set, $max_icons_available, $start, $stop, $rand_cntr; $rand_image = $rand_set[$rand_cntr]; $rand_cntr++; // check to make sure we didn't run out of numbers // if so, refresh the rand_set array if($rand_cntr){ // create a new array range($start,$stop); // fill it $rand_set = range(1,$max_icons_available); // 50 icons available // randomize it shuffle($rand_set); shuffle($rand_set); // reset the counter $rand_cntr = 1; } $image_name = "stand_in$rand_image.jpg"; return $image_name; } // get footer include('/var/www/jokesnfun.com/web/footer.php'); ?>