EOT; // process path here - is set if mod_rewrite is in use if (!empty($_REQUEST["path"])) { // the followling line calculates the path in the album and excludes any subdirectories if // Plogger is installed in one $path = join("/",array_diff(explode("/",$_SERVER["REQUEST_URI"]),explode("/",$_SERVER["PHP_SELF"]))); $resolved_path = resolve_path($path); if (is_array($resolved_path)) { $_GET["level"] = $resolved_path["level"]; $_GET["id"] = $resolved_path["id"]; // get page number from url, if present $parts = parse_url($_SERVER["REQUEST_URI"]); if (isset($parts["query"])) { parse_str($parts["query"],$query_parts); if (!empty($query_parts["page"])) $_GET["page"] = $query_parts["page"]; }; $path = $parts["path"]; }; }; if ($_GET["level"] == "slideshow") $inHead .= generate_slideshow_js($_GET["id"], "album"); /* else if ($level == "slideshow") $inHead .= generate_slideshow_js($id, "album"); */ // Set sorting session variables if they are passed if (isset($_GET['sortby'])) $_SESSION['plogger_sortby'] = $_GET['sortby']; if (isset($_GET['sortdir'])) $_SESSION['plogger_sortdir'] = $_GET['sortdir']; // This file contains the main gallery function the_gallery(); // this function is placed in the HTML document directly. // The function does not take any arguments, it reads directly from // the HTTP_GET_VARS array. // The three GET parameters that it accepts are // $level = "collection", "album", or "picture" // $id = id number of collection, album, or picture // $n = starting element (for pagination) go from n to n + max_thumbs (in global config) function the_gallery_head() { global $inHead; echo $inHead; } function the_gallery(){ $start = microtime(); global $TABLE_PREFIX; global $config; $output = ''; $level = isset($_GET["level"]) ? $_GET["level"] : ''; $allowed_levels = array('collection','album','picture','slideshow','search'); if (!in_array($level,$allowed_levels)) { $level = 'collections'; }; $id = isset($_GET["id"]) ? intval($_GET["id"]) : 0; $_REQUEST["id"] = $id; $_REQUEST["level"] = $level; $page = isset($_GET["page"]) ? intval($_GET["page"]) : 1; $num = 0; // this is needed to get pagination work $total_items = 0; // Output highest level container division $output .= '
'.generate_header().''.generate_jump_menu().generate_search_box().'
'; if ($level != "picture"){ $output .= '
'; } $output .= '
'; if ($level == "picture"){ // first lets load the thumbnail of the picture at the correct size $sql = "SELECT *, UNIX_TIMESTAMP(`date_submitted`) AS `unix_date_submitted`, UNIX_TIMESTAMP(`EXIF_date_taken`) AS `unix_exif_date_taken` FROM `".$TABLE_PREFIX."pictures` WHERE id = $id"; $result = run_query($sql); $row = mysql_fetch_assoc($result); // generate a list of all image id-s so proper prev/next links can be created. This should be a // fast query, even for big albums. $image_list = array(); $sql = "SELECT id FROM `".$TABLE_PREFIX."pictures` WHERE parent_album = ".$row["parent_album"]; // determine sort ordering switch ($_SESSION["plogger_sortby"]){ case 'number_of_comments': $sql .= " ORDER BY `num_comments`"; break; case 'caption': $sql .= " ORDER BY `caption` "; break; case 'date_taken': $sql .= " ORDER BY `EXIF_date_taken` "; break; case 'filename': $sql .= " ORDER BY `path` "; break; case 'date': default: $sql .= " ORDER BY `date_submitted` "; break; } switch ($_SESSION["plogger_sortdir"]){ case 'ASC': $sql .= " ASC"; break; case 'DESC': case 'default': $sql .= " DESC"; break; } $result = run_query($sql); while ($image = mysql_fetch_assoc($result)) { $image_list[] = $image["id"]; }; $current_picture = array_search($id,$image_list); $prev_link = $next_link = ""; if ($current_picture > 0) { $prev_link = '« vorige'; }; if ($current_picture < sizeof($image_list)-1) { $next_link = 'volgende »'; }; $date_taken = !empty($row["unix_exif_date_taken"]) ? $row["unix_exif_date_taken"] : $row["unix_date_submitted"]; $output .= '

'.date($config["date_format"],$date_taken).'

'; $output .= (trim($row["caption"]) != '') ? stripslashes($row["caption"]) : ''; $output .= '

'; $thumburl = generate_thumb($row['path'], $row['id'], 'large'); // generate XHTML with thumbnail and link to picture view. $img_link = $config["baseurl"] . $row["path"]; // generate XHTML with thumbnail and link to picture view. $imgtag = ''.$row['; if (!$_SESSION["plogger_details"]){ $detail_url = 'Show details'; } else{ $detail_url = 'Hide details'; } $output .= '
'.$prev_link.' '.$next_link.'
'; $output .= ' '; $output .= '
'.$detail_url.'
'; $output .= generate_exif_table($row["id"]); // display comments for selected picture $output .= display_comments($row["id"]); $output .= '
'; } else{ // so basicly, this whole block gets to run only if I'm not showing a picture $output .= '
'; if ($level == "slideshow") { $output .= '
'; $output .= generate_slideshow_interface(); $output .= '
'; $num_items = 1; } elseif ($level == "search"){ $output .= ''; $terms = $_REQUEST["searchterms"]; $terms = explode(" ",$terms); $query = "SELECT `caption`,`path`,p.`id`,c.`comment` FROM `".$TABLE_PREFIX."pictures` p LEFT JOIN `".$TABLE_PREFIX."commentaren` c ON p.`id` = c.`parent_id` "; if ((count($terms) != 1) || ($terms[0] != '')){ $query .= " WHERE ( "; foreach ($terms as $term) { $query .= " `path` LIKE '%".mysql_escape_string($term)."%' OR `comment` LIKE '%".mysql_escape_string($term)."%' OR `caption` LIKE '%".mysql_escape_string($term)."%' OR "; } $query = substr($query, 0, strlen($query) - 3) .") "; } else{ // no search terms? no results either $query .= " WHERE 1 = 0"; } $query .= " GROUP BY p.`id`ORDER BY `date_submitted` DESC"; $result = run_query($query); if (mysql_num_rows($result) > 0){ $output .= '
    '; $counter = 0; $from = ($page - 1) * $config["thumb_num"]; mysql_data_seek($result, $from); $i = $page; // Loop through each album in the set. while(($row = mysql_fetch_assoc($result)) && ($i++ < ($page + $config["thumb_num"]))){ // display thumbnails within album $thumbpath = generate_thumb($row['path'], $row['id'], 'small'); // generate XHTML with thumbnail and link to picture view. $imgtag = ''.htmlspecialchars($row['; // Tables are a necessary evil for getting the interface done... $comment_query = "SELECT COUNT(*) AS `num_comments` FROM `".$TABLE_PREFIX."comments` WHERE `parent_id`='".$row["id"]."'"; $comment_result = run_query($comment_query); $num_comments = mysql_result($comment_result, 0, 'num_comments'); $output .= '
  • '.$imgtag.'
    '; if ($config["allow_dl"]) $output .= ''; $filename = basename($row["path"]); if (strlen($filename) > $config["truncate"] && $config["truncate"] != 0) $filename = substr($filename, 0, $config["truncate"])."..."; $output .= $filename.'
    '; if ($config["allow_comments"]) { $output.= '
    ('.$num_comments.' bijschrift'; if ($num_comments != 1) $output .= 'en'; $output .= ')
    '; } $output.='
  • '; $counter++; } $output .= '
'; } else{ $output .= '
Ern zijn geen afbeeldingen die aan je zoekopdracht voldoen.
'; } $num_items = mysql_num_rows($result); } elseif ($level == "album") { // Album level display mode (display all pictures within album) $output .= ''; $count_sql = "SELECT COUNT(*) AS num_items FROM `".$TABLE_PREFIX."pictures` WHERE parent_album = '$id'"; $result = mysql_query($count_sql); $num_items = mysql_result($result, 'num_items'); $num = $num_items; $sql = "SELECT `".$TABLE_PREFIX."pictures`.`id`,`path`,`caption`, COUNT(`comment`) AS `num_comments` FROM `".$TABLE_PREFIX."pictures` LEFT JOIN `".$TABLE_PREFIX."comments` ON `".$TABLE_PREFIX."pictures`.`id`=`".$TABLE_PREFIX."comments`.`parent_id` WHERE `".$TABLE_PREFIX."pictures`.`parent_album` = ".$id." GROUP BY `".$TABLE_PREFIX."pictures`.`id`"; // query database and retreive all pictures withing selected album switch ($_SESSION["plogger_sortby"]){ case 'number_of_comments': $sql .= " ORDER BY `num_comments`"; break; case 'caption': $sql .= " ORDER BY `caption` "; break; case 'date_taken': $sql .= " ORDER BY `EXIF_date_taken` "; break; case 'filename': $sql .= " ORDER BY `path` "; break; case 'date': default: $sql .= " ORDER BY `date_submitted` "; break; } switch ($_SESSION["plogger_sortdir"]){ case 'ASC': $sql .= " ASC"; break; case 'DESC': case 'default': $sql .= " DESC"; break; } $from = ($page - 1) * $config["thumb_num"]; $sql .= ",`".$TABLE_PREFIX."pictures`.`id` DESC "; $sql .= " LIMIT ".$from.",".$config["thumb_num"]; $result = run_query($sql); if (mysql_num_rows($result) > 0){ $output .= '
    '; $counter = 0; // Loop through each album in the set. while($row = mysql_fetch_assoc($result)) { // display thumbnails within album $thumbpath = generate_thumb($row['path'], $row['id'], 'small'); // generate XHTML with thumbnail and link to picture view. $imgtag = ''.htmlspecialchars($row['; $num_comments = $row['num_comments']; $output .= '
  • ' . $imgtag . "
    "; if ($config["allow_dl"]) $output .= ''; $filename = basename($row["path"]); if (strlen($filename) > $config["truncate"] && $config["truncate"] != 0) $filename = substr($filename, 0, $config["truncate"])."..."; $output .= $filename.'
    '; if ($config["allow_comments"]) { $output.= '
    ('.$num_comments.' bijschrift'; if ($num_comments != 1) $output .= 'en'; $output .= ')
    '; } $output.='
  • '; $counter++; } $output .= '
'; } else{ $output .= '
Er staan nog geen afbeeldingen in deze collectie.
'; } } else if ($level == "collection") { $sql = "SELECT COUNT(DISTINCT `parent_album`) AS `num_items` FROM `".$TABLE_PREFIX."pictures` WHERE `parent_collection` = '" . $id . "'"; $result = run_query($sql); $num_items = mysql_result($result, 'num_items'); $num = $num_items; // create a list of all non-empty albums. Could be done with subqueries, but // MySQL 4.0 does not support those // -1 is just for the case there are no albums at all. Shouldn't happen if user // follows links, but let's deal with it anyway $image_count = array(-1 => -1); // 1. create a list of all albums with at least one photo $sql = "SELECT parent_album,COUNT(*) AS imagecount FROM `".$TABLE_PREFIX."pictures` GROUP BY parent_album"; $result = run_query($sql); while($row = mysql_fetch_assoc($result)) { $image_count[$row["parent_album"]] = $row["imagecount"]; }; $output .= ''; $imlist = join(",",array_keys($image_count)); $from = ($page - 1) * $config["thumb_num"]; $sql = "SELECT * FROM `".$TABLE_PREFIX."albums` WHERE `parent_id` = '$id' AND id IN ($imlist) ORDER BY `name` DESC LIMIT ".$from.",".$config["thumb_num"]; $result = run_query($sql); $output .= ''; if (mysql_num_rows($result) > 0){ $output .= '
    '; $counter = 0; while ($row = mysql_fetch_array($result)){ // Display a thumbnail of the first picture in the album if ($row["thumbnail_id"]) { $thumb_query = "SELECT * FROM `".$TABLE_PREFIX."pictures` WHERE id='".$row["thumbnail_id"] . "'"; } else { $thumb_query = "SELECT * FROM `".$TABLE_PREFIX."pictures` WHERE `parent_album`='".$row["id"]."' ORDER BY `date_submitted` DESC LIMIT 1"; }; $thumb_result = run_query($thumb_query); $thumb_row = mysql_fetch_assoc($thumb_result); if (mysql_num_rows($thumb_result) > 0){ $thumbpath = generate_thumb($thumb_row['path'], $thumb_row['id'], 'small'); $numquery = "SELECT COUNT(*) AS `num_pictures` FROM `".$TABLE_PREFIX."pictures` WHERE `parent_album`='".$row["id"]."'"; $numresult = run_query($numquery); $num_pictures = mysql_result($numresult, 'num_pictures'); $output .= '
  • '; // generate XHTML with thumbnail and link to picture view. $imgtag = ''.htmlspecialchars($row['; $output .= $imgtag; $output .= '
    '; if ($config["allow_dl"]) $output .= ''; $output.= $row["name"].'
    ('.$num_pictures.' picture'; if ($num_pictures != 1) $output .= 's'; $output .= ')
  • '; $counter++; } } $output .= '
'; } } // collections mode (show all albums within a collection) else { // Show all of the collections // How many non-empty collections are there? $sql = "SELECT COUNT(DISTINCT `parent_collection`) AS `num_items` FROM `".$TABLE_PREFIX."pictures`"; $result = run_query($sql); $num_items = mysql_result($result, 'num_items'); $num = $num_items; // create a list of all non-empty collections. Could be done with subqueries, but // MySQL 4.0 does not support those // -1 is just for the case there are no collections at all $image_count = array(-1 => -1); // 1. create a list of all albums with at least one photo $sql = "SELECT parent_collection,COUNT(*) AS imagecount FROM `".$TABLE_PREFIX."pictures` GROUP BY parent_collection"; $result = run_query($sql); while($row = mysql_fetch_assoc($result)) { $image_count[$row["parent_collection"]] = $row["imagecount"]; }; $output .= ''; $imlist = join(",",array_keys($image_count)); // I need to determine correct arguments for LIMIT from the given page number $from = ($page - 1) * $config["thumb_num"]; $sql = "SELECT * FROM `".$TABLE_PREFIX."collections` WHERE id IN ($imlist) LIMIT ".$from.",".$config["thumb_num"]; $result = run_query($sql); if (mysql_num_rows($result) > 0){ $output .= '
    '; $counter = 0; while ($row = mysql_fetch_array($result)){ $numquery = "SELECT COUNT(*) AS `num_albums` FROM `".$TABLE_PREFIX."albums` WHERE `parent_id`='".$row["id"]."'"; $numresult = run_query($numquery); $num_albums = mysql_result($numresult, 'num_albums'); if ($row["thumbnail_id"]) { $thumb_query = "SELECT * FROM `".$TABLE_PREFIX."pictures` WHERE id='".$row["thumbnail_id"]."'"; } else { $thumb_query = "SELECT * FROM `".$TABLE_PREFIX."pictures` WHERE `parent_collection`='".$row["id"]."' LIMIT 1"; }; $thumb_result = run_query($thumb_query); if (mysql_num_rows($thumb_result) > 0){ $thumb_row = mysql_fetch_assoc($thumb_result); $output .= '
  • '; $thumbpath = generate_thumb($thumb_row['path'], $thumb_row['id'], 'small'); // generate XHTML with thumbnail and link to picture view. $imgtag = ''.htmlspecialchars($row['; $output .= $imgtag; $output .= '
    '; if ($config["allow_dl"]) $output .= ''; $output .= $row["name"].'
    ('.$num_albums.' album'; if ($num_albums != 1) $output .= 's'; $output .= ')
  • '; $counter++; } } $output .= '
'; } } // change the tooltip message to reflect the nature of the RSS aggregate link. if ($level != "") $rss_tooltip = "RSS 2.0 abboneer op deze collectie $level"; else $rss_tooltip = "RSS 2.0 abboneer op alle collecties"; if ($config["use_mod_rewrite"]) { global $path; if (isset($path)) $rss_link .= "http://".$_SERVER["SERVER_NAME"]."/".SmartStripSlashes(substr($path,1))."/feed/"; else $rss_link .= $config['baseurl']."feed/"; } else { $rss_link .= "plog-rss.php?level=$level&id=$id"; }; if ($level == "search") { // append the search terms $separator = $config["use_mod_rewrite"] ? "?" : "&"; $rss_link .= $separator . "searchterms=".urlencode($_GET["searchterms"]); }; if ($level == "search") { $searchterms = urlencode($_GET["searchterms"]); $p_url = $_SERVER["PHP_SELF"]."?level=search&searchterms=$searchterms&id=$id"; } else { if ($level) { $p_url = generate_url($level,$id); if ($config["use_mod_rewrite"]) { $p_url .= "/"; }; } else { $p_url = $config["baseurl"]; }; }; $ss_tag = $ss_cap_tag = $rss_tag = ""; if ($level == "album") { $ss_url = $_SERVER["PHP_SELF"]."?level=slideshow&mode=$level&id=$id"; if ($config["use_mod_rewrite"]) { $ss_url = generate_url($level,$id) . "/slideshow"; }; $ss_tag = "Toon als Diapresentatie"; } if ($level != "slideshow") $rss_tag = 'RSS 							2.0 Feed'; else $ss_cap_tag = ' '; $output .= '
'; $end = microtime(); $t2 = (getmicrotime($end) - getmicrotime($start)); $output .= '
'; } $output .= ' '; echo $output; } function generate_breadcrumb($level, $id){ global $TABLE_PREFIX; switch ($level){ case 'collection': $query = "SELECT * FROM `".$TABLE_PREFIX."collections` WHERE `id`='".$id."'"; $result = run_query($query); $row = mysql_fetch_assoc($result); $breadcrumbs = ' Collections » ' . $row["name"] . ''; if ($level == "slideshow") $breadcrumbs .= ' » Slideshow'; break; case 'slideshow': case 'album': $query = "SELECT * FROM `".$TABLE_PREFIX."albums` WHERE `id`='".$id."'"; $result = run_query($query); $row = mysql_fetch_assoc($result); $album_name = $row["name"]; $album_link = generate_url("album",$row["id"],$row["name"]); $query = "SELECT * FROM `".$TABLE_PREFIX."collections` WHERE `id`='".$row["parent_id"]."'"; $result = run_query($query); $row = mysql_fetch_assoc($result); $collection_link = '' . $row["name"] . ''; if ($level == "slideshow") $breadcrumbs = ' Collections » ' . $collection_link . ' » ' . ''.$album_name.' » ' . ' Slideshow'; else $breadcrumbs = ' Collections » ' . $collection_link . ' » ' . ''.$album_name.''; break; case 'picture': $query = "SELECT * FROM `".$TABLE_PREFIX."pictures` WHERE `id`='".$id."'"; $result = run_query($query); $row = mysql_fetch_assoc($result); $picture_name = basename($row["path"]); $query = "SELECT * FROM `".$TABLE_PREFIX."albums` WHERE `id`='".$row["parent_album"]."'"; $result = run_query($query); $row = mysql_fetch_assoc($result); //$album_link = ''.$row["name"].''; $album_link = '' . $row["name"] . ''; $query = "SELECT * FROM `".$TABLE_PREFIX."collections` WHERE `id`='".$row["parent_id"]."'"; $result = run_query($query); $row = mysql_fetch_assoc($result); //$collection_link = ''.$row["name"].''; $collection_link = '' . $row["name"] . ''; $breadcrumbs = ' Collections » ' . $collection_link . ' » ' . $album_link . ' » ' . ''.$picture_name.''; if ($level == "slideshow") $breadcrumbs .= ' » Slideshow'; break; case 'search': $breadcrumbs = 'U zocht naar: '.htmlspecialchars($_GET["searchterms"]).'.'; break; default: $breadcrumbs = ' Collecties'; } return ''; } function generate_jump_menu() { global $TABLE_PREFIX; global $config; $output = ''; $output .= '
'; $output .= ''; $output .= '
'; return $output; } function generate_exif_table($id, $condensed=0){ global $TABLE_PREFIX; global $config; $query = "SELECT * FROM `".$TABLE_PREFIX."pictures` WHERE `id`='".$id."'"; $result = run_query($query); if (mysql_num_rows($result) > 0){ $row = mysql_fetch_assoc($result); foreach($row as $key => $val) if (trim($row[$key]) == '') $row[$key] = ' '; $table_data = '
Afbeeldingsgrootte: '.$size.' kbytes
Genomen op: '.$row["EXIF_date_taken"].'
Camera model: '.$row["EXIF_camera"].'
Sluitertijd: '.$row["EXIF_shutterspeed"].'
Focus lengte: '.$row["EXIF_focallength"].'
Zoombereik: '.$row["EXIF_aperture"].'
'; } else { $table_data .= '>Afmetingen:'.$width .' x ' .$height.'Afbeeldingsgrootte'.$size.' kbytesGenomen op:'.$row["EXIF_date_taken"].'Camera model:'.$row["EXIF_camera"].'Sluitertijd:'.$row["EXIF_shutterspeed"].'Focus lengte:'.$row["EXIF_focallength"].'Zoombereik:'.$row["EXIF_aperture"].''; } } return $table_data; } function display_comments($id) { global $TABLE_PREFIX; global $config; $output = ""; $error_message = ""; if ($config["allow_comments"] == 1) { // this function takes the photo id and selects all relevent comments // it then displays them with an ordered HTML list. // get comments from table $query = "SELECT *, UNIX_TIMESTAMP(`date`) AS `unix_date` FROM `".$TABLE_PREFIX."comments` WHERE parent_id = '$id'"; $result = run_query($query) or die(mysql_error()); $output .= "

Commentaren:

"; if (mysql_num_rows($result) == 0) { $output .= "

Nog geen commentaar.

"; } else { $output .= "
    "; while($row = mysql_fetch_assoc($result)) { $url = htmlspecialchars($row["url"]); $author = htmlspecialchars($row["author"]); $output .= "
  1. "; $output .= "

    ".htmlspecialchars($row["comment"])."

    "; $output .= "Bijschrift door: "; $output .= (trim($url) != '') ? "$author" : "$author"; $output .= "- gemaakt op ".date($config["date_format"],$row["unix_date"]); $output .= "
  2. "; } $output .= "
"; } $query = "SELECT * FROM `".$TABLE_PREFIX."pictures` WHERE id = '$id'"; $result = run_query($query) or die(mysql_error()); $row = mysql_fetch_assoc($result); if ($row["allow_comments"]) { if (isset($_SESSION['comment_post_error'])) { $error_message = "

" . $_SESSION['comment_post_error'] . "

"; unset($_SESSION['comment_post_error']); }; $output .= '

Geef je bijschrift:

'.$error_message.'

(Verplicht)

(Verplicht, wordt niet getoond)


'; } else $output .= '

Commentaar geven is hiervoor niet toegestaan

'; } return $output; } // generate header produces the Gallery Name, The Jump Menu, and the Breadcrumb trail at the top of the image function generate_header() { global $config; //$output = '

'.stripslashes($config["gallery_name"]).'

'; $output = '

geinstein

'; return $output; } function generate_sortby($level,$id){ $output = ''; if ($level == "album"){ $output .= '
Sorteer op:
'; return $output; } // generates correclt urls depending on whether mod_rewrite is in use or not // level - type of the url to generate // id - used for id=xx urls // name - used for mod_rewrite URL-s, both should be passed as arguments, so this // function doesn't have to query the database // benchmark timing function getmicrotime($t) { list($usec, $sec) = explode(" ",$t); return ((float)$usec + (float)$sec); } function generate_slideshow_interface() { global $config; $large_link = ''; $prev_url = ''; $next_url = ''; $stop_url = ''; $play_url = ''; $output = '
'.$large_link.$prev_url.$stop_url.$play_url.$next_url.'
'; /* $imgtag = ''.$row['; */ $imgtag = ''; $output .= '
'.$imgtag.'

'; // activate slideshow object using javascript block $output .= ''; return $output; } // function for generating the slideshow javascript function generate_slideshow_js($id, $mode) { global $TABLE_PREFIX; global $config; // output the link to the slideshow javascript $output = ''; // get all pictures within album sorted by default sort order if ($mode == "collection") $sql = "SELECT * FROM ".$TABLE_PREFIX."pictures WHERE parent_collection = '".$id."'"; elseif ($mode == "album") $sql = "SELECT * FROM ".$TABLE_PREFIX."pictures WHERE parent_album = '".$id."'"; else $sql = "SELECT * FROM ".$TABLE_PREFIX."pictures"; // determine sort ordering switch ($_SESSION["plogger_sortby"]){ case 'number_of_comments': $sql .= " ORDER BY `num_comments`"; break; case 'caption': $sql .= " ORDER BY `caption` "; break; case 'date_taken': $sql .= " ORDER BY `EXIF_date_taken` "; break; case 'filename': $sql .= " ORDER BY `path` "; break; case 'date': default: $sql .= " ORDER BY `date_submitted` "; break; } switch ($_SESSION["plogger_sortdir"]){ case 'ASC': $sql .= " ASC"; break; case 'DESC': case 'default': $sql .= " DESC"; break; } $result = run_query($sql); $output .= ''; return $output; } ?>