PageRenderTime 46ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/cgadmin/PlacesAdmin.php

https://github.com/Elieser/choosing-guides
PHP | 333 lines | 287 code | 40 blank | 6 comment | 53 complexity | 7d994445ae9e6e3c59cc20fbce8361dd 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_Places = 10;
  33. $pageNum_Places = 0;
  34. if (isset($_GET['pageNum_Places'])) {
  35. $pageNum_Places = $_GET['pageNum_Places'];
  36. }
  37. $startRow_Places = $pageNum_Places * $maxRows_Places;
  38. $maxRows_Places = 10;
  39. $pageNum_Places = 0;
  40. if (isset($_GET['pageNum_Places'])) {
  41. $pageNum_Places = $_GET['pageNum_Places'];
  42. }
  43. $startRow_Places = $pageNum_Places * $maxRows_Places;
  44. $WebLanguage_Places = "-1";
  45. if (isset($_POST['weblanguage'])) {
  46. $WebLanguage_Places = $_POST['weblanguage'];
  47. }
  48. else
  49. {
  50. if (isset($_SESSION['MM_WebLanguageId'])){
  51. $WebLanguage_Places = $_SESSION['MM_WebLanguageId'];
  52. }
  53. }
  54. $country_Places = "";
  55. if (isset($_POST['country']) && $_POST['country']!='0') {
  56. $country_Places = 'AND tblplaces.CountryId='.$_POST['country'];
  57. }
  58. else
  59. {
  60. if (isset($_SESSION['MM_CountryId']) && $_SESSION['MM_CountryId']!='0'){
  61. $country_Places = ' AND tblplaces.CountryId='.$_SESSION['MM_CountryId'];
  62. }
  63. }
  64. $state_Places = "";
  65. if (isset($_POST['state']) && $_POST['state']!='0') {
  66. $state_Places = ' AND tblplaces.StateId='.$_POST['state'];
  67. }
  68. else
  69. {
  70. if (isset($_SESSION['MM_StateId']) && $_SESSION['MM_StateId']!='0'){
  71. $state_Places = ' AND tblplaces.StateId='.$_SESSION['MM_StateId'];
  72. }
  73. }
  74. $location_Places = "";
  75. if (isset($_POST['location']) && $_POST['location']!='0') {
  76. $location_Places = ' AND tblplaces.LocationId='.$_POST['location'];
  77. }
  78. else
  79. {
  80. if (isset($_SESSION['MM_LocationId']) && $_SESSION['MM_LocationId']!='0'){
  81. $location_Places = ' AND tblplaces.LocationId='.$_SESSION['MM_LocationId'];
  82. }
  83. }
  84. $word_Places = "";
  85. if (isset($_POST['wordfilter'])) {
  86. $word_Places = $_POST['wordfilter'];
  87. }
  88. $sorted_Places = "PlaceId DESC";
  89. mysql_select_db($database_ChoosingGuidesConnection, $ChoosingGuidesConnection);
  90. $query_Places = sprintf("SELECT tblplaces.PlaceId, tblplacesdet.WebLanguageId, tblplaces.CountryId, tblplaces.StateId, tblplaces.LocationId, tblplacesdet.PlaceName, CONVERT(tblplacesdet.PlaceDesc, char(290)) AS PlaceDesc, tblplacespictures.PictureName, tblplacespictures.PicturePath FROM tblplaces LEFT OUTER JOIN tblplacespictures ON tblplaces.PlaceId = tblplacespictures.PlaceId LEFT OUTER JOIN tblplacesdet ON tblplaces.PlaceId = tblplacesdet.PlaceId WHERE WebLanguageId = %s %s %s %s AND (tblplacesdet.PlaceName like %s or tblplacesdet.PlaceDesc like %s) GROUP BY tblplaces.PlaceId ORDER BY %s", GetSQLValueString($WebLanguage_Places, "int"),$country_Places,$state_Places,$location_Places,GetSQLValueString("%" . $word_Places . "%", "text"),GetSQLValueString("%" . $word_Places . "%", "text"),$sorted_Places);
  91. $query_limit_Places = sprintf("%s LIMIT %d, %d", $query_Places, $startRow_Places, $maxRows_Places);
  92. $Places = mysql_query($query_limit_Places, $ChoosingGuidesConnection) or die(mysql_error());
  93. $row_Places = mysql_fetch_assoc($Places);
  94. if (isset($_GET['totalRows_Places'])) {
  95. $totalRows_Places = $_GET['totalRows_Places'];
  96. } else {
  97. $all_Places = mysql_query($query_Places);
  98. $totalRows_Places = mysql_num_rows($all_Places);
  99. }
  100. $totalPages_Places = ceil($totalRows_Places/$maxRows_Places)-1;
  101. $queryString_Places = "";
  102. if (!empty($_SERVER['QUERY_STRING'])) {
  103. $params = explode("&", $_SERVER['QUERY_STRING']);
  104. $newParams = array();
  105. foreach ($params as $param) {
  106. if (stristr($param, "pageNum_Places") == false &&
  107. stristr($param, "totalRows_Places") == false) {
  108. array_push($newParams, $param);
  109. }
  110. }
  111. if (count($newParams) != 0) {
  112. $queryString_Places = "&" . htmlentities(implode("&", $newParams));
  113. }
  114. }
  115. $queryString_Places = sprintf("&totalRows_Places=%d%s", $totalRows_Places, $queryString_Places);
  116. ?>
  117. <script type="text/javascript">
  118. function MM_goToURL() { //v3.0
  119. var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  120. for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
  121. }
  122. </script>
  123. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  124. <html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="../Templates/AdminTemplate.dwt.php" codeOutsideHTMLIsLocked="false" -->
  125. <head><link rel="Shortcut Icon" href="../images/cg.ico" type="image/x-icon" />
  126. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  127. <!-- InstanceBeginEditable name="doctitle" -->
  128. <title>Choosing Guides Admin</title>
  129. <!-- InstanceEndEditable -->
  130. <link href="../CSS/twoColLiqLtHdr.css" rel="stylesheet" type="text/css" />
  131. <link href="../SpryAssets/SpryMenuBarHorizontal.css" rel="stylesheet" type="text/css" />
  132. <link href="../Spry-UI-1.7/css/SpryImageSlideShow.css" rel="stylesheet" type="text/css" />
  133. <!--[if lte IE 7]>
  134. <style>
  135. .content { margin-right: -1px; } /* this 1px negative margin can be placed on any of the columns in this layout with the same corrective effect. */
  136. ul.nav a { zoom: 1; } /* the zoom property gives IE the hasLayout trigger it needs to correct extra whiltespace between the links */
  137. </style>
  138. <![endif]-->
  139. <!-- InstanceBeginEditable name="head" -->
  140. <!-- InstanceEndEditable -->
  141. <script src="../SpryAssets/SpryMenuBar.js" type="text/javascript"></script>
  142. <script src="../Spry-UI-1.7/includes/SpryDOMUtils.js" type="text/javascript"></script>
  143. <script src="../Spry-UI-1.7/includes/SpryDOMEffects.js" type="text/javascript"></script>
  144. <script src="../Spry-UI-1.7/includes/SpryWidget.js" type="text/javascript"></script>
  145. <script src="../Spry-UI-1.7/includes/SpryPanelSet.js" type="text/javascript"></script>
  146. <script src="../Spry-UI-1.7/includes/SpryFadingPanels.js" type="text/javascript"></script>
  147. <script src="../Spry-UI-1.7/includes/SpryImageLoader.js" type="text/javascript"></script>
  148. <script src="../Spry-UI-1.7/includes/SpryImageSlideShow.js" type="text/javascript"></script>
  149. <script src="../Spry-UI-1.7/includes/plugins/ImageSlideShow/SpryPanAndZoomPlugin.js" type="text/javascript"></script>
  150. <style type="text/css">
  151. /* BeginOAWidget_Instance_2141542: #ImageSlideShow */
  152. #ImageSlideShow.ImageSlideShow {
  153. width: 250px;
  154. height: 98px;
  155. border: solid 1px #000000;
  156. }
  157. #ImageSlideShow .ISSClip {
  158. background-color: #000000;
  159. }
  160. /* EndOAWidget_Instance_2141542 */
  161. </style>
  162. <script type="text/xml">
  163. <!--
  164. <oa:widgets>
  165. <oa:widget wid="2141542" binding="#ImageSlideShow" />
  166. </oa:widgets>
  167. -->
  168. </script>
  169. </head>
  170. <body bgcolor="#D2D2FF">
  171. <div class="container">
  172. <div class="header">
  173. <div class="logo">
  174. <a href="../IndexAdmin.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>
  175. <!-- end .header -->
  176. </div>
  177. <ul id="ImageSlideShow">
  178. <li><img src="../images/camp-nou.jpg" alt="" width="250" height="98" /></li>
  179. <li><img src="../images/diagonal.jpg" alt="" width="250" height="96" /></li>
  180. <li><img src="../images/gardens-royal-palace-pedralbes.jpg" alt="" width="250" height="96" /></li>
  181. <li><img src="../images/pedralbes-monastery.jpg" alt="" width="250" height="96" /></li>
  182. <li><img src="../images/pla&ccedil;a-catalunya.jpg" alt="" width="250" height="96" /></li>
  183. </ul>
  184. <div class="weblanguage">
  185. <?php
  186. include ("../Includes/SelectLanguage.php");
  187. ?>
  188. <script type="text/javascript">
  189. // BeginOAWidget_Instance_2141542: #ImageSlideShow
  190. var ImageSlideShow = new Spry.Widget.ImageSlideShow("#ImageSlideShow", {
  191. widgetID: "ImageSlideShow",
  192. injectionType: "replace",
  193. autoPlay: true,
  194. displayInterval: 4000,
  195. transitionDuration: 2000,
  196. componentOrder: ["view"],
  197. plugIns: [ ]
  198. });
  199. // EndOAWidget_Instance_2141542
  200. </script>
  201. </div>
  202. </div>
  203. <div class="menu">
  204. <ul id="MenuBar1" class="MenuBarHorizontal">
  205. <li><a href="#">Guides Admin</a></li>
  206. <li><a href="#">Travel Agencies Admin</a></li>
  207. <li><a href="ToursAdmin.php">Tours Admin</a></li>
  208. <li><a href="PlacesAdmin.php">Interesting Places Admin</a></li>
  209. </ul>
  210. </div>
  211. <div class="content"><!-- InstanceBeginEditable name="Body" -->
  212. <?php
  213. include ("Includes/filter.php");
  214. ?>
  215. <table border="0" align="right">
  216. <tr>
  217. <td>Found <?php echo $totalRows_Places?> Results</td>
  218. <td width="360">
  219. <td><input name="new" type="button" id="new" onClick="MM_goToURL('parent','PlacesAdminAdd.php');return document.MM_returnValue" value="New Place" /></td>
  220. <td></td>
  221. <td></td>
  222. <td><?php if ($pageNum_Places > 0) { // Show if not first page ?>
  223. <a href="<?php printf("%s?pageNum_Places=%d%s", $currentPage, 0, $queryString_Places); ?>"><img src="../images/First.gif" /></a>
  224. <?php } else {?><img src="../images/First_disable.gif" /> <?php } // Show if not first page ?></td>
  225. <td><?php if ($pageNum_Places > 0) { // Show if not first page ?>
  226. <a href="<?php printf("%s?pageNum_Places=%d%s", $currentPage, max(0, $pageNum_Places - 1), $queryString_Places); ?>"><img src="../images/Previous.gif" /></a>
  227. <?php } else {?><img src="../images/Previous_disable.gif" /> <?php } // Show if not first page ?></td>
  228. <td><?php echo $pageNum_Places+1 ?> of <?php echo $totalPages_Places+1 ?></td>
  229. <td><?php if ($pageNum_Places < $totalPages_Places) { // Show if not last page ?>
  230. <a href="<?php printf("%s?pageNum_Places=%d%s", $currentPage, min($totalPages_Places, $pageNum_Places + 1), $queryString_Places); ?>"><img src="../images/Next.gif" /></a>
  231. <?php } else {?><img src="../images/Next_disable.gif" /> <?php }// Show if not last page ?></td>
  232. <td><?php if ($pageNum_Places < $totalPages_Places) { // Show if not last page ?>
  233. <a href="<?php printf("%s?pageNum_Places=%d%s", $currentPage, $totalPages_Places, $queryString_Places); ?>"><img src="../images/Last.gif" /></a>
  234. <?php } else {?><img src="../images/Last_disable.gif" /> <?php }// Show if not last page ?></td>
  235. </tr>
  236. </table>
  237. <?php
  238. if (mysql_num_rows($Places)==0)
  239. {
  240. echo "No Results were found ...";
  241. }
  242. else
  243. {
  244. do { ?>
  245. <div class="placesList"> <div class="placeImage"> <a href="PlacesAdminDetails.php?place=<?php echo $row_Places['PlaceId']; ?>"><img src="<?php echo "../".$row_Places['PicturePath']; ?>" width="196" height="156" alt="<?php echo $row_Places['PictureName']; ?>" /></a> </div>
  246. <div class="placeDesc">
  247. <div class="EditDelete">
  248. <input name="Delete" type="button" onClick="MM_goToURL('parent','PlacesAdminDel.php?place=<?php echo $row_Places['PlaceId']; ?>');return document.MM_returnValue" value="Delete" />
  249. </div>
  250. <h4><a href="PlacesAdminDetails.php?place=<?php echo $row_Places['PlaceId']; ?>"><?php echo $row_Places['PlaceName']; ?></a></h4>
  251. <p class="placeDesc"><?php echo $row_Places['PlaceDesc']; ?> ...</p>
  252. </div>
  253. </div>
  254. <?php } while ($row_Places = mysql_fetch_assoc($Places)); ?>
  255. <p>
  256. <table border="0" align="right">
  257. <tr>
  258. <td><input name="new" type="button" id="new" onClick="MM_goToURL('parent','PlacesAdminAdd.php');return document.MM_returnValue" value="New Place" /></td>
  259. <td></td>
  260. <td></td>
  261. <td><?php if ($pageNum_Places > 0) { // Show if not first page ?>
  262. <a href="<?php printf("%s?pageNum_Places=%d%s", $currentPage, 0, $queryString_Places); ?>"><img src="../images/First.gif" /></a>
  263. <?php } else {?><img src="../images/First_disable.gif" /> <?php } // Show if not first page ?></td>
  264. <td><?php if ($pageNum_Places > 0) { // Show if not first page ?>
  265. <a href="<?php printf("%s?pageNum_Places=%d%s", $currentPage, max(0, $pageNum_Places - 1), $queryString_Places); ?>"><img src="../images/Previous.gif" /></a>
  266. <?php } else {?><img src="../images/Previous_disable.gif" /> <?php } // Show if not first page ?></td>
  267. <td><?php echo $pageNum_Places+1 ?> of <?php echo $totalPages_Places+1 ?></td>
  268. <td><?php if ($pageNum_Places < $totalPages_Places) { // Show if not last page ?>
  269. <a href="<?php printf("%s?pageNum_Places=%d%s", $currentPage, min($totalPages_Places, $pageNum_Places + 1), $queryString_Places); ?>"><img src="../images/Next.gif" /></a>
  270. <?php } else {?><img src="../images/Next_disable.gif" /> <?php }// Show if not last page ?></td>
  271. <td><?php if ($pageNum_Places < $totalPages_Places) { // Show if not last page ?>
  272. <a href="<?php printf("%s?pageNum_Places=%d%s", $currentPage, $totalPages_Places, $queryString_Places); ?>"><img src="../images/Last.gif" /></a>
  273. <?php } else {?><img src="../images/Last_disable.gif" /> <?php }// Show if not last page ?></td>
  274. </tr>
  275. </table>
  276. </p>
  277. <!-- InstanceEndEditable --><!-- end .content --></div>
  278. <div class="sidebar1">
  279. <p>Barra Lateral aaa</p>
  280. </div>
  281. <div class="footer">
  282. <p>&nbsp;</p>
  283. <!-- end .footer --></div>
  284. <!-- end .container --></div>
  285. <script type="text/javascript">
  286. var MenuBar1 = new Spry.Widget.MenuBar("MenuBar1", {imgDown:"../SpryAssets/SpryMenuBarDownHover.gif", imgRight:"../SpryAssets/SpryMenuBarRightHover.gif"});
  287. </script>
  288. </body>
  289. <!-- InstanceEnd --></html>
  290. <?php
  291. }
  292. mysql_free_result($Places);
  293. ?>