array ("value" => 1, "display_en" => 'Before 9:00', 'Before 9:00', "start" => "2017-09-16 06:00:00", "end" => "2017-09-16 08:59:59"), "2" => array ("value" => 2, "display_en" => '09:00-12:00', '09:00-12:00', "start" => "2017-09-16 09:00:00", "end" => "2017-09-16 11:59:59"), "3" => array ("value" => 3, "display_en" => '12:00-14:00', '12:00-14:00', "start" => "2017-09-16 12:00:00", "end" => "2017-09-16 13:59:59"), ); //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 == "undefined" ) { $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 (taketime >= '" . $timeranges[$timerange_select]['start'] . "' and taketime <= '" . $timeranges[$timerange_select]['end'] ."')"; */ //$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); } ?> FOUR TRAILS MINI 迷你四徑 - 照片庫 Photo Gallery
' . i18n_field($timerange,display) . ''; } echo 'CLEAR'; */ foreach ($timeranges as $timerange) { if (in_array($timerange['value'], $timerange_select)) {$active = "active";} else {$active = "";} echo ''; } ?>
中文 English
= $photomax ) { ?>