PageRenderTime 54ms CodeModel.GetById 26ms RepoModel.GetById 1ms app.codeStats 0ms

/Tours.php

https://github.com/Elieser/choosing-guides
PHP | 358 lines | 310 code | 42 blank | 6 comment | 57 complexity | 240e9eebce02f4f24bcd0c38356721c6 MD5 | raw file
  1. <?php require_once('Connections/ChoosingGuidesConnection.php'); ?>
  2. <?php
  3. if (!function_exists("GetSQLValueString")) {
  4. function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
  5. {
  6. if (PHP_VERSION < 6) {
  7. $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  8. }
  9. $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
  10. switch ($theType) {
  11. case "text":
  12. $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  13. break;
  14. case "long":
  15. case "int":
  16. $theValue = ($theValue != "") ? intval($theValue) : "NULL";
  17. break;
  18. case "double":
  19. $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
  20. break;
  21. case "date":
  22. $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  23. break;
  24. case "defined":
  25. $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
  26. break;
  27. }
  28. return $theValue;
  29. }
  30. }
  31. $currentPage = $_SERVER["PHP_SELF"];
  32. $maxRows_Tours = 10;
  33. $pageNum_Tours = 0;
  34. if (isset($_GET['pageNum_Tours'])) {
  35. $pageNum_Tours = $_GET['pageNum_Tours'];
  36. }
  37. $startRow_Tours = $pageNum_Tours * $maxRows_Tours;
  38. $maxRows_Tours = 10;
  39. $pageNum_Tours = 0;
  40. if (isset($_GET['pageNum_Tours'])) {
  41. $pageNum_Tours = $_GET['pageNum_Tours'];
  42. }
  43. $startRow_Tours = $pageNum_Tours * $maxRows_Tours;
  44. $WebLanguage_Tours = "-1";
  45. if (isset($_POST['weblanguage'])) {
  46. $WebLanguage_Tours = $_POST['weblanguage'];
  47. }
  48. else
  49. {
  50. if (isset($_SESSION['MM_WebLanguageId'])){
  51. $WebLanguage_Tours = $_SESSION['MM_WebLanguageId'];
  52. }
  53. }
  54. $country_Tours = "";
  55. if (isset($_POST['country']) && $_POST['country']!='0') {
  56. $country_Tours = 'AND tblTours.CountryId='.$_POST['country'];
  57. }
  58. else
  59. {
  60. if (isset($_SESSION['MM_CountryId']) && $_SESSION['MM_CountryId']!='0'){
  61. $country_Tours = ' AND tblTours.CountryId='.$_SESSION['MM_CountryId'];
  62. }
  63. }
  64. $state_Tours = "";
  65. if (isset($_POST['state']) && $_POST['state']!='0') {
  66. $state_Tours = ' AND tblTours.StateId='.$_POST['state'];
  67. }
  68. else
  69. {
  70. if (isset($_SESSION['MM_StateId']) && $_SESSION['MM_StateId']!='0'){
  71. $state_Tours = ' AND tblTours.StateId='.$_SESSION['MM_StateId'];
  72. }
  73. }
  74. $location_Tours = "";
  75. if (isset($_POST['location']) && $_POST['location']!='0') {
  76. $location_Tours = ' AND tblTours.LocationId='.$_POST['location'];
  77. }
  78. else
  79. {
  80. if (isset($_SESSION['MM_LocationId']) && $_SESSION['MM_LocationId']!='0'){
  81. $location_Tours = ' AND tblTours.LocationId='.$_SESSION['MM_LocationId'];
  82. }
  83. }
  84. $word_Tours = "";
  85. if (isset($_POST['wordfilter'])) {
  86. $word_Tours = $_POST['wordfilter'];
  87. }
  88. $sorted_Tours = "Rand()";
  89. $SortId=0;
  90. if (isset($_POST['queryorder'])){
  91. $SortId=$_POST['queryorder'];
  92. }
  93. else
  94. {
  95. if (isset($_SESSION['MM_SortId'])) {
  96. $SortId=$_SESSION['MM_SortId'];
  97. }
  98. }
  99. switch ($SortId){
  100. case 0: $sorted_Tours = "Rand()";
  101. break;
  102. case 1: $sorted_Tours = "ClickCounter DESC";
  103. break;
  104. case 2: $sorted_Tours = "TourPrice";
  105. break;
  106. case 3: $sorted_Tours = "(select count(*) from tbltourcomments where TourId=tbltour.TourId) DESC";
  107. break;
  108. case 4: $sorted_Tours = "(select round(avg(Points),2) from tbltourcomments where TourId=tbltour.TourId) DESC";
  109. break;
  110. }
  111. mysql_select_db($database_ChoosingGuidesConnection, $ChoosingGuidesConnection);
  112. $query_Tours = sprintf("SELECT tblTours.TourId, tblToursdet.WebLanguageId, tblTours.CountryId, tblTours.StateId, tblTours.LocationId, tblTours.TourPrice, tblTours.TourPicture, tblTours.TourPictureName, tblToursdet.TourName, CONVERT(tblToursdet.TourDesc, char(290)) AS TourDesc FROM tblTours LEFT OUTER JOIN tblToursdet ON tblTours.TourId = tblToursdet.TourId WHERE WebLanguageId = %s %s %s %s AND (tblToursdet.TourName like %s or tblToursdet.TourDesc like %s) GROUP BY tblTours.TourId ORDER BY %s", GetSQLValueString($WebLanguage_Tours, "int"),$country_Tours,$state_Tours,$location_Tours,GetSQLValueString("%" . $word_Tours . "%", "text"),GetSQLValueString("%" . $word_Tours . "%", "text"),$sorted_Tours);
  113. $query_limit_Tours = sprintf("%s LIMIT %d, %d", $query_Tours, $startRow_Tours, $maxRows_Tours);
  114. $Tours = mysql_query($query_limit_Tours, $ChoosingGuidesConnection) or die(mysql_error());
  115. $row_Tours = mysql_fetch_assoc($Tours);
  116. if (isset($_GET['totalRows_Tours'])) {
  117. $totalRows_Tours = $_GET['totalRows_Tours'];
  118. } else {
  119. $all_Tours = mysql_query($query_Tours);
  120. $totalRows_Tours = mysql_num_rows($all_Tours);
  121. }
  122. $totalPages_Tours = ceil($totalRows_Tours/$maxRows_Tours)-1;
  123. $queryString_Tours = "";
  124. if (!empty($_SERVER['QUERY_STRING'])) {
  125. $params = explode("&", $_SERVER['QUERY_STRING']);
  126. $newParams = array();
  127. foreach ($params as $param) {
  128. if (stristr($param, "pageNum_Tours") == false &&
  129. stristr($param, "totalRows_Tours") == false) {
  130. array_push($newParams, $param);
  131. }
  132. }
  133. if (count($newParams) != 0) {
  134. $queryString_Tours = "&" . htmlentities(implode("&", $newParams));
  135. }
  136. }
  137. $queryString_Tours = sprintf("&totalRows_Tours=%d%s", $totalRows_Tours, $queryString_Tours);
  138. ?>
  139. <script type="text/javascript">
  140. function MM_goToURL() { //v3.0
  141. var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  142. for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
  143. }
  144. </script>
  145. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  146. <html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="Templates/GlobalTemplate.dwt.php" codeOutsideHTMLIsLocked="false" -->
  147. <head><link rel="Shortcut Icon" href="images/cg.ico" type="image/x-icon" />
  148. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  149. <!-- InstanceBeginEditable name="doctitle" -->
  150. <title>Choosing Guides</title>
  151. <!-- InstanceEndEditable -->
  152. <link href="CSS/twoColLiqLtHdr.css" rel="stylesheet" type="text/css" />
  153. <link href="SpryAssets/SpryMenuBarHorizontal.css" rel="stylesheet" type="text/css" />
  154. <link href="Spry-UI-1.7/css/SpryImageSlideShow.css" rel="stylesheet" type="text/css" />
  155. <!--[if lte IE 7]>
  156. <style>
  157. .content { margin-right: -1px; } /* this 1px negative margin can be placed on any of the columns in this layout with the same corrective effect. */
  158. ul.nav a { zoom: 1; } /* the zoom property gives IE the hasLayout trigger it needs to correct extra whiltespace between the links */
  159. </style>
  160. <![endif]-->
  161. <!-- InstanceBeginEditable name="head" -->
  162. <!-- InstanceEndEditable -->
  163. <script src="SpryAssets/SpryMenuBar.js" type="text/javascript"></script>
  164. <script src="Spry-UI-1.7/includes/SpryDOMUtils.js" type="text/javascript"></script>
  165. <script src="Spry-UI-1.7/includes/SpryDOMEffects.js" type="text/javascript"></script>
  166. <script src="Spry-UI-1.7/includes/SpryWidget.js" type="text/javascript"></script>
  167. <script src="Spry-UI-1.7/includes/SpryPanelSet.js" type="text/javascript"></script>
  168. <script src="Spry-UI-1.7/includes/SpryFadingPanels.js" type="text/javascript"></script>
  169. <script src="Spry-UI-1.7/includes/SpryImageLoader.js" type="text/javascript"></script>
  170. <script src="Spry-UI-1.7/includes/SpryImageSlideShow.js" type="text/javascript"></script>
  171. <script src="Spry-UI-1.7/includes/plugins/ImageSlideShow/SpryPanAndZoomPlugin.js" type="text/javascript"></script>
  172. <style type="text/css">
  173. /* BeginOAWidget_Instance_2141542: #ImageSlideShow */
  174. #ImageSlideShow.ImageSlideShow {
  175. width: 250px;
  176. height: 98px;
  177. border: solid 1px #000000;
  178. }
  179. #ImageSlideShow .ISSClip {
  180. background-color: #000000;
  181. }
  182. /* EndOAWidget_Instance_2141542 */
  183. </style>
  184. <script type="text/xml">
  185. <!--
  186. <oa:widgets>
  187. <oa:widget wid="2141542" binding="#ImageSlideShow" />
  188. </oa:widgets>
  189. -->
  190. </script>
  191. </head>
  192. <body bgcolor="#D2D2FF">
  193. <div class="container">
  194. <div class="header">
  195. <div class="logo">
  196. <a href="Index.php"><img src="images/LogoChoosingGuides.gif" alt="Insert Logo Here" name="Insert_logo" width="300" height="100" class="logo" id="Insert_logo" style="background-color: #8090AB; display:block;" /></a>
  197. <!-- end .header -->
  198. </div>
  199. <ul id="ImageSlideShow">
  200. <li><img src="images/camp-nou.jpg" alt="" width="250" height="98" /></li>
  201. <li><img src="images/diagonal.jpg" alt="" width="250" height="96" /></li>
  202. <li><img src="images/gardens-royal-palace-pedralbes.jpg" alt="" width="250" height="96" /></li>
  203. <li><img src="images/pedralbes-monastery.jpg" alt="" width="250" height="96" /></li>
  204. <li><img src="images/pla&ccedil;a-catalunya.jpg" alt="" width="250" height="96" /></li>
  205. </ul>
  206. <div class="weblanguage">
  207. <?php
  208. include ("Includes/SelectLanguage.php");
  209. ?>
  210. <script type="text/javascript">
  211. // BeginOAWidget_Instance_2141542: #ImageSlideShow
  212. var ImageSlideShow = new Spry.Widget.ImageSlideShow("#ImageSlideShow", {
  213. widgetID: "ImageSlideShow",
  214. injectionType: "replace",
  215. autoPlay: true,
  216. displayInterval: 4000,
  217. transitionDuration: 2000,
  218. componentOrder: ["view"],
  219. plugIns: [ ]
  220. });
  221. // EndOAWidget_Instance_2141542
  222. </script>
  223. </div>
  224. </div>
  225. <div class="menu">
  226. <ul id="MenuBar1" class="MenuBarHorizontal">
  227. <li><a href="#">Guides</a></li>
  228. <li><a href="#">Travel Agencies</a></li>
  229. <li><a href="Tours.php">Tours</a></li>
  230. <li><a href="Places.php">Interesting Places</a></li>
  231. </ul>
  232. </div>
  233. <div class="content"><!-- InstanceBeginEditable name="Body" -->
  234. <?php
  235. include ("Includes/filter.php");
  236. ?>
  237. <table border="0" align="right">
  238. <tr>
  239. <td align="left"><?php if (mysql_num_rows($Tours)!=0){?>
  240. Found <?php echo $totalRows_Tours?> Results<?php }?></td>
  241. <td width="200">
  242. <td width="72">&nbsp;</td>
  243. <td width="0"></td>
  244. <td width="0"></td>
  245. <td><?php if ($pageNum_Tours > 0) { // Show if not first page ?>
  246. <a href="<?php printf("%s?pageNum_Tours=%d%s", $currentPage, 0, $queryString_Tours); ?>"><img src="images/First.gif" /></a>
  247. <?php } else {?><img src="images/First_disable.gif" /> <?php } // Show if not first page ?></td>
  248. <td><?php if ($pageNum_Tours > 0) { // Show if not first page ?>
  249. <a href="<?php printf("%s?pageNum_Tours=%d%s", $currentPage, max(0, $pageNum_Tours - 1), $queryString_Tours); ?>"><img src="images/Previous.gif" /></a>
  250. <?php } else {?><img src="images/Previous_disable.gif" /> <?php } // Show if not first page ?></td>
  251. <td><?php echo $pageNum_Tours+1 ?> of <?php echo $totalPages_Tours+1 ?></td>
  252. <td><?php if ($pageNum_Tours < $totalPages_Tours) { // Show if not last page ?>
  253. <a href="<?php printf("%s?pageNum_Tours=%d%s", $currentPage, min($totalPages_Tours, $pageNum_Tours + 1), $queryString_Tours); ?>"><img src="images/Next.gif" /></a>
  254. <?php } else {?><img src="images/Next_disable.gif" /> <?php }// Show if not last page ?></td>
  255. <td><?php if ($pageNum_Tours < $totalPages_Tours) { // Show if not last page ?>
  256. <a href="<?php printf("%s?pageNum_Tours=%d%s", $currentPage, $totalPages_Tours, $queryString_Tours); ?>"><img src="images/Last.gif" /></a>
  257. <?php } else {?><img src="images/Last_disable.gif" /> <?php }// Show if not last page ?></td>
  258. </tr>
  259. </table>
  260. <?php
  261. if (mysql_num_rows($Tours)==0)
  262. {
  263. echo "No Results were found ...";
  264. }
  265. else
  266. {
  267. do { ?>
  268. <div class="placesList"> <div class="placeImage"> <a href="ToursDetails.php?tour=<?php echo $row_Tours['TourId']; ?>"><img src="<?php echo $row_Tours['TourPicture']; ?>" width="196" height="156" alt="<?php echo $row_Tours['TourPictureName']; ?>" /></a> </div>
  269. <div class="PlaceDesc">
  270. <div class="EditDelete">
  271. Price: <?php echo $row_Tours['TourPrice']; ?>
  272. </div>
  273. <h4><a href="ToursDetails.php?tour=<?php echo $row_Tours['TourId']; ?>"><?php echo $row_Tours['TourName']; ?></a></h4>
  274. <p class="placeDesc"><?php echo $row_Tours['TourDesc']; ?> ...</p>
  275. </div>
  276. </div>
  277. <?php } while ($row_Tours = mysql_fetch_assoc($Tours)); ?>
  278. <p>
  279. <table border="0" align="right">
  280. <tr>
  281. <td>&nbsp;</td>
  282. <td></td>
  283. <td></td>
  284. <td><?php if ($pageNum_Tours > 0) { // Show if not first page ?>
  285. <a href="<?php printf("%s?pageNum_Tours=%d%s", $currentPage, 0, $queryString_Tours); ?>"><img src="images/First.gif" /></a>
  286. <?php } else {?><img src="images/First_disable.gif" /> <?php } // Show if not first page ?></td>
  287. <td><?php if ($pageNum_Tours > 0) { // Show if not first page ?>
  288. <a href="<?php printf("%s?pageNum_Tours=%d%s", $currentPage, max(0, $pageNum_Tours - 1), $queryString_Tours); ?>"><img src="images/Previous.gif" /></a>
  289. <?php } else {?><img src="images/Previous_disable.gif" /> <?php } // Show if not first page ?></td>
  290. <td><?php echo $pageNum_Tours+1 ?> of <?php echo $totalPages_Tours+1 ?></td>
  291. <td><?php if ($pageNum_Tours < $totalPages_Tours) { // Show if not last page ?>
  292. <a href="<?php printf("%s?pageNum_Tours=%d%s", $currentPage, min($totalPages_Tours, $pageNum_Tours + 1), $queryString_Tours); ?>"><img src="images/Next.gif" /></a>
  293. <?php } else {?><img src="images/Next_disable.gif" /> <?php }// Show if not last page ?></td>
  294. <td><?php if ($pageNum_Tours < $totalPages_Tours) { // Show if not last page ?>
  295. <a href="<?php printf("%s?pageNum_Tours=%d%s", $currentPage, $totalPages_Tours, $queryString_Tours); ?>"><img src="images/Last.gif" /></a>
  296. <?php } else {?><img src="images/Last_disable.gif" /> <?php }// Show if not last page ?></td>
  297. </tr>
  298. </table>
  299. </p>
  300. <!-- InstanceEndEditable --><!-- end .content --></div>
  301. <div class="sidebar1">
  302. <p>Barra Lateral aaa</p>
  303. </div>
  304. <div class="footer">
  305. <p>&nbsp;</p>
  306. <!-- end .footer --></div>
  307. <!-- end .container --></div>
  308. <script type="text/javascript">
  309. var MenuBar1 = new Spry.Widget.MenuBar("MenuBar1", {imgDown:"SpryAssets/SpryMenuBarDownHover.gif", imgRight:"SpryAssets/SpryMenuBarRightHover.gif"});
  310. </script>
  311. </body>
  312. <!-- InstanceEnd --></html>
  313. <?php
  314. }
  315. mysql_free_result($Tours);
  316. ?>