require_once("../appheader.php"); $baseurl = "http://web.sportsystem.hk/utmt201718/gallery/"; //$path = "photos/53960f4d2fbb87e9c50c9df2ed628837/out/"; //$images = glob($path . '*.{jpg,jpeg,png,gif,JPG,JPEG,PNG,GIF}', GLOB_BRACE); //d($images); $photomax = 1500; $timeranges = array( "1" => array ("value" => 1, "display_en" => '30-Dec Morning 6:00-11:59', "display_zh-hant" => '12月30日 上午 6:00-11:59', "start" => "2017-12-30 06:00:00", "end" => "2017-12-30 11:59:59"), "2" => array ("value" => 2, "display_en" => '30-Dec Afternoon 12:00-17:59', "display_zh-hant" => '12月30日 下午 12:00-17:59', "start" => "2017-12-30 12:00:00", "end" => "2017-12-30 17:59:59"), "3" => array ("value" => 3, "display_en" => '30-Dec Night 18:00-23:59', "display_zh-hant" => '12月30日 晚上 18:00-23:59', "start" => "2017-12-30 18:00:00", "end" => "2017-12-30 23:59:59"), "4" => array ("value" => 4, "display_en" => '31-Dec Morning 6:00-11:59', "display_zh-hant" => '12月31日 上午 6:00-11:59', "start" => "2016-12-31 06:00:00", "end" => "2016-12-31 11:59:59"), "5" => array ("value" => 5, "display_en" => '31-Dec Afternoon 12:00-17:59', "display_zh-hant" => '12月31日 下午 12:00-17:59', "start" => "2016-12-31 12:00:00", "end" => "2016-12-31 17:59:59"), "6" => array ("value" => 6, "display_en" => '31-Dec Night 18:00-23:59', "display_zh-hant" => '12月31日 晚上 18:00-23:59', "start" => "2016-12-31 18:00:00", "end" => "2016-12-31 23:59:59"), "7" => array ("value" => 7, "display_en" => '1-Jan Before dawn 00:00-05:59', "display_zh-hant" => '1月1日 凌晨 00:00-05:59', "start" => "2018-01-01 00:00:00", "end" => "2018-01-01 05:59:59"), "EMPTY" => array ("value" => "EMPTY", "display_en" => 'Photo without timestamp', "display_zh-hant" => '沒有時間資料的相片') ); //https://www.facebook.com/sharer/sharer.php?u=http%3A%2F%2Fweb.sportsystem.hk%2Fttnh2016%2Fgallery%2F%23%26gid%3D1%26pid%3D9 $bibno = getpostval('bibno'); if ($bibno != "v" && $bibno != "volunteer" && $bibno != "EMPTY") { $bibno = str_pad($bibno, 4, "0", STR_PAD_LEFT); } if ($bibno == "0000" || $bibno == "" ) { $bibno = ""; } $location_select = $_REQUEST['locationbuttons']; $timerange_select = $_REQUEST['timerangbuttons']; $credit_select = $_REQUEST['creditbuttons']; //d($location_select); $sql = "select count(*) as c from " . $table_prefix . "gallery"; $stmt = $db->prepare($sql); $stmt->execute(); $totalphotos = $stmt->fetch(PDO::FETCH_ASSOC); $sql = "select location, count(*) as c from " . $table_prefix . "gallery group by location order by c desc"; $stmt = $db->prepare($sql); $stmt->execute(); $locations = $stmt->fetchAll(PDO::FETCH_ASSOC); $sql = "select credit, count(*) as c from " . $table_prefix . "gallery group by credit order by c desc"; $stmt = $db->prepare($sql); $stmt->execute(); $credits = $stmt->fetchAll(PDO::FETCH_ASSOC); //d($credits); if ($bibno || $location_select || $timerange_select || $credit_select ) { if ($bibno == "volunteer") { $bibno = "v"; } if (strtolower($bibno) != "EMPTY" && strtolower($bibno) != "all" && strtolower($bibno) != "v" && strtolower($bibno) != "empty" && ctype_alpha(substr($bibno,0,1))) { $bibno = substr($bibno,1); } $sql = 'select distinct gallery.* from ' . $table_prefix . 'gallery gallery left join ' . $table_prefix . 'gallery_tag gallery_tag on gallery.id = gallery_tag.gallery_id where 1=1 '; if (intval($bibno) > 0 ) { $sql .= 'and CAST(gallery_tag.bibno AS UNSIGNED) = ' . $bibno . '' ; } if (strtolower($bibno)== "v") { $sql .= 'and gallery_tag.bibno = "v"' ; } if ($bibno == "EMPTY") { $sql .= 'and (gallery_tag.bibno = "" or gallery_tag.bibno is null)' ; } $l = null; if ($location_select) { foreach ($location_select as $lx) { if (trim($lx) != "EMPTY" && trim($lx) != "") { $l[] = mysql_escape_mimic($lx); } } $sql .= " and ( location in ('" . implode("','",$l) . "')"; foreach ($location_select as $l) { if ($l == "EMPTY") $sql .= " or location is null"; } $sql .= ") "; } $l = array(); if ($credit_select) { foreach ($credit_select as $lx) { if (trim($lx) != "EMPTY" && trim($lx) != "") { $l[] = mysql_escape_mimic($lx); } } $sql .= " and ( credit in ('" . implode("','",$l) . "')"; foreach ($credit_select as $l) { if ($l == "EMPTY") $sql .= " or credit is null"; } $sql .= ") "; } if ($timerange_select) { //$sql .= " and location in ('" . implode("','",$location_select) . "')"; $sql .= " and ( 1=2 "; foreach ($timerange_select as $s) { if ( $timeranges[$s]['start'] ) { $sql .= " or (taketime >= '" . mysql_escape_mimic($timeranges[$s]['start']) . "' and taketime <= '" . mysql_escape_mimic($timeranges[$s]['end']) ."')"; } } foreach ($timerange_select as $l) { if ($l == "EMPTY") $sql .= " or taketime = '0000-00-00 00:00:00' or taketime = '' or taketime is null"; } $sql .= " ) "; } $sql .= " order by taketime limit " . $photomax ; } else { if(intval($_GET['pid'])) { $sql = ' select * from ' . $table_prefix . 'gallery gallery order by case when id=' . intval($_GET['pid']) . ' then -1 else RAND() end asc limit 200'; } else { $sql = 'select * from ' . $table_prefix . 'gallery ORDER BY RAND() limit 200'; } } //$sql = "select * from gallery limit 20"; //d($_GET); //exit(); //echo $sql; $stmt = $db->prepare($sql); $stmt->execute(); $images = $stmt->fetchAll(PDO::FETCH_ASSOC); if(intval($_GET['pid'])) { $sql = ' select * from ' . $table_prefix . 'gallery where id=' . intval($_GET['pid']) ; $stmt = $db->prepare($sql); $stmt->execute(); $odimages = $stmt->fetch(PDO::FETCH_ASSOC); } ?>
if(!$odimages['basename']) { if ($bibno && $images[0]) { //d($images[0]); $ogimage = $baseurl . 'photos/' . $images[0]['path'] . '/' . $images[0]['basename']; $ogimagewidth = $images[0]['width']; $ogimageheight = $images[0]['height']; } else { $ogimage = $baseurl . 'photos/fa33ae17bd-0949707e5b/DSC_4744L.jpg'; $ogimagewidth = 2048; $ogimageheight = 1052; } } else { $ogimage = $baseurl . '/photos/' . $odimages['path'] . '/' . $odimages['basename']; $ogimagewidth = $odimages['width']; $ogimageheight = $odimages['height']; } ?>
