?
Path : /home/admin/domains/happytokorea.com/public_html_bk/new/ |
Current File : /home/admin/domains/happytokorea.com/public_html_bk/new/programs.php |
<?php define('TITLE','Usys Tours : Our Tours'); $root = $_SERVER['DOCUMENT_ROOT']; //db connect include($root."/db/db_connect.php"); ?> <?php /*##################### Page Setting. #####################*/ //page number. if(isset($_GET['page'])) { $page = trim($_GET['page']); if(!preg_match("/\b^[0-9]+\b/",$page)) { $page = 1; } } else { $page = 1; } //page type (zone , country , state , programs). if(isset($_GET['type'])){ $page_type = strtolower(stripslashes(strip_tags(trim($_GET['type'])))); } else { $page_type = "zone"; } if($page_type == "programs") { $thumb = 12; } else { $thumb = 18; } $offset = ($page-1)*$thumb; //the reference from user click. if(isset($_GET['fr'])){ if(preg_match("/^[a-z]/",$fr)) { $fr = strtolower(stripslashes(strip_tags(trim($_GET['fr'])))); $header = "<h2>ทัวร์ ".ucwords($fr)."</h2>"; } else $fr = stripslashes(strip_tags(trim($_GET['fr']))); $header = "<h2>ทัวร์ $fr</h2>"; } ?> <?php include($root."/includes/header.php");?> <div id="wrapper"><div id="mid"> <img src="/images/programs_h.png" alt="" align="right" style="margin:0 -7px 20px 0;" /><br class="clear" /> <?php include($root."/includes/side_bar.php");?> <div id="content" style="margin-top:-1px;"> <?php /*######################### Start retrieve infomation from db. #########################*/ switch($page_type){ case "country" : $r = @mysql_query("SELECT country_id FROM country JOIN zone WHERE country.zone_id = zone.zone_id AND zone.name = '$fr'"); $rows_count = @mysql_num_rows($r); $r = @mysql_query("SELECT country.* FROM country JOIN zone WHERE country.zone_id = zone.zone_id AND zone.name = '$fr' ORDER BY country.country_id ASC LIMIT $offset,$thumb"); break; case "state" : $r = @mysql_query("SELECT state_id FROM state JOIN country WHERE state.country_id = country.country_id AND country.name = '$fr'"); $rows_count = @mysql_num_rows($r); $r = @mysql_query("SELECT state.* FROM state JOIN country WHERE state.country_id = country.country_id AND country.name = '$fr' ORDER BY state.state_id ASC LIMIT $offset,$thumb"); break; case "programs" : $r = @mysql_query("SELECT program_id FROM programs JOIN $ref WHERE programs.{$ref}_id = {$ref}.{$ref}_id AND {$ref}.name = '$fr'"); $rows_count = @mysql_num_rows($r); $r = @mysql_query("SELECT programs.* FROM programs JOIN $ref WHERE programs.{$ref}_id = {$ref}.{$ref}_id AND {$ref}.name = '$fr' ORDER BY hot_tag DESC, new_tag DESC, date DESC LIMIT $offset,$thumb"); break; default : //default to "zone" $r = @mysql_query("SELECT zone_id FROM zone"); $rows_count = @mysql_num_rows($r); $header = "<h2>Zone</h2>"; $r = @mysql_query("SELECT * FROM zone ORDER BY zone_id ASC LIMIT $offset,$thumb"); } /*####################### Start content for html #######################*/ $i = 0; $max_page = ceil($rows_count/$thumb); /*--------------------------------------------- Page for Zone ---------------------------------------------*/ if($page_type == 'zone') { echo $header; while($row = @mysql_fetch_array($r,MYSQL_ASSOC)) { $image_path = "/images/tours/{$row['name']}/{$row['image_name']}"; if($i < $thumb) { $r2 = @mysql_query("SELECT country_id,program_id FROM programs WHERE zone_id = {$row['zone_id']}"); $row2 = @mysql_fetch_assoc($r2); if(!$row2['country_id'] && $row2['program_id']) {?> <div class="tour_link"> <a href="<?php echo $_SERVER['PHP_SELF']."?type=programs&ref=$page_type&fr={$row['name']}";?>"> <div class="image"><?php if($row['image_name'] != "") echo"<img src='$image_path' alt='' />";?></div> </a> <div class="name"><?php echo "<h3>{$row['name']}</h3>";?></div> </div> <?php } else {?> <div class="tour_link"> <a href="<?php echo $_SERVER['PHP_SELF']."?type=country&fr={$row['name']}";?>"> <div class="image"><?php if($row['image_name'] != "") echo"<img src='$image_path' alt='' />";?></div> </a> <div class="name"><?php echo "<h3>{$row['name']}</h3>";?></div> </div> <?php } $i++; } } if($rows_count == 0) echo "<div style='margin-top:50px;'><h2>Coming Soon</h2></div>"; } /*--------------------------------------------- End Page for Zone ---------------------------------------------*/ /*--------------------------------------------- Page for Country. ---------------------------------------------*/ if($page_type == 'country') { echo $header; while($row = @mysql_fetch_assoc($r)) { $image_path = "/images/tours/$fr/{$row['name']}/{$row['image_name']}"; if($i < $thumb) { $r2 = @mysql_query("SELECT state_id,program_id FROM programs WHERE country_id = {$row['country_id']}"); $row2 = @mysql_fetch_assoc($r2); if(!$row2['state_id'] && $row2['program_id']) {?> <div class="tour_link"> <a href="<?php echo $_SERVER['PHP_SELF']."?type=programs&ref=$page_type&fr={$row['name']}";?>"> <div class="image"><?php if($row['image_name'] != "") echo"<img src='$image_path' alt='' />";?></div> </a> <div class="name"><?php echo "<h3>{$row['name']}</h3>";?></div> </div> <?php } else {?> <div class="tour_link"> <a href="<?php echo $_SERVER['PHP_SELF']."?type=state&fr={$row['name']}";?>"> <div class="image"><?php if($row['image_name'] != "") echo"<img src='$image_path' alt='' />";?></div> </a> <div class="name"><?php echo "<h3>{$row['name']}</h3>";?></div> </div> <?php } $i++; } } if($rows_count == 0) echo "<div style='margin-top:50px;'><h2>Coming Soon</h2></div>"; } /*--------------------------------------------- End Page for Country. ---------------------------------------------*/ /*--------------------------------------------- Page for State. ---------------------------------------------*/ if($page_type == 'state') { echo $header; while($row = @mysql_fetch_assoc($r)) { $r_z = @mysql_query("SELECT zone.name FROM zone JOIN country WHERE country.country_id = {$row['country_id']} AND ". "country.zone_id = zone.zone_id"); $zone = mysql_fetch_assoc($r_z); $image_path = "/images/tours/{$zone['name']}/$fr/{$row['name']}/{$row['image_name']}"; if($i < $thumb) {?> <div class="tour_link"> <a href="<?php echo $_SERVER['PHP_SELF']."?type=programs&ref=$page_type&fr={$row['name']}";?>"> <div class="image"><?php if($row['image_name'] != "") echo"<img src='$image_path' alt='' />";?></div> </a> <div class="name"><?php echo "<h3>{$row['name']}</h3>";?></div> </div> <?php $i++; } } if($rows_count == 0) echo "<div style='margin-top:50px;'><h2>Coming Soon</h2></div>"; } /*--------------------------------------------- End Page for State. ---------------------------------------------*/ /*--------------------------------------------- Page for Programs. ---------------------------------------------*/ if($page_type == 'programs') { echo $header."<br class='clear' />"; while($row = @mysql_fetch_assoc($r)) { if($i < $thumb) { if($ref == 'state') { $z = @mysql_query("SELECT zone.name FROM zone JOIN programs WHERE zone.zone_id = programs.zone_id AND program_id = {$row['program_id']}"); $zone = @mysql_fetch_assoc($z); $c = @mysql_query("SELECT country.name FROM country JOIN programs WHERE country.country_id = programs.country_id AND program_id = {$row['program_id']}"); $country = @mysql_fetch_assoc($c); $image_path = "/images/tours/{$zone['name']}/{$country['name']}/$fr/{$row['image_name']}"; } else if($ref == 'country') { $z = @mysql_query("SELECT zone.name FROM zone JOIN programs WHERE zone.zone_id = programs.zone_id AND program_id = {$row['program_id']}"); $zone = @mysql_fetch_assoc($z); $image_path = "/images/tours/{$zone['name']}/$fr/{$row['image_name']}"; } else { $image_path = "/images/tours/$fr/{$row['image_name']}"; } if(isset($ref)) {?> <div class="trip"> <?php if($row['new_tag'] != 0){ echo "<div class='new_tag'><img src='/images/new_tag.png' alt='' width='73' heigth='73' /></div>"; }?> <div class="image"> <?php if($row['image_name'] != "")echo"<img src='$image_path' alt='' />";?> <div class="download_tag"><a href="/pdf/download.php?fn=<?php if($row['pdf_name'] != ""){echo $row['pdf_name'];} else echo "#\" title='coming soon'";?>"> <img src="/images/slide_download_btn.png" alt="" /></a></div> </div> <div class="info"> <div class="title"><h4 class="font20"><?php echo stripslashes(nl2br(trim($row['title'])));?></h4></div> <div class="des"><?php echo $row['air_line']."<br />".$row['schedule'];?> </div> <div class="tag"><h3 class="font21">ราคา <?php echo $row['price'];?></h3></div> </div> </div><!--end trip--> <?php } $i++; } } if($rows_count == 0) echo "<div style='margin-top:50px;'><h2>Coming Soon</h2></div>"; } /*--------------------------------------------- End Page for Programs. ---------------------------------------------*/ @mysql_free_result($r); mysql_close($dbc); include($root."/tpl/page_nav.php"); ?> <div class="clear"></div> <div id="page_nav"><?php page_nav($page,$max_page);?></div> </div><!--End content--> <div class="clear"></div> </div></div><!--End mid--> <?php include($root."/includes/footer.php");?>