Guest User

Untitled

a guest
Jul 23rd, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.96 KB | None | 0 0
  1. <?php
  2. require_once("conn.php");
  3. require_once("includes.php");
  4.  
  5. if(!isset($_GET['page']))
  6. {
  7. $page = 1;
  8. }
  9. else
  10. {
  11. $page = $_GET['page'];
  12. }
  13.  
  14. $max_results = 10;
  15. $from = (($page * $max_results) - $max_results);
  16. $query = array();
  17.  
  18. if(!empty($_GET[c]))
  19. {
  20. $query[] = "cars_listings.CategoryID = '$_GET[c]' ";
  21. }
  22.  
  23.  
  24. if(!empty($_GET[AgentID]))
  25. {
  26. $query[] = "cars_listings.AgentID = '$_GET[AgentID]' ";
  27. }
  28.  
  29.  
  30. if(!empty($_GET[VehicleModel]))
  31. {
  32. $query[] = "cars_listings.VehicleModel = '$_GET[VehicleModel]' ";
  33. }
  34.  
  35. if(!empty($_GET[VehicleMake]))
  36. {
  37. $query[] = "cars_listings.VehicleMake = '$_GET[VehicleMake]' " ;
  38. }
  39.  
  40. if(!empty($_GET[search_gorivo]))
  41. {
  42. $query[] = "cars_listings.gorivo = '$_GET[search_gorivo]' ";
  43. }
  44.  
  45.  
  46. if(!empty($_GET[km1]))
  47. {
  48. $query[] = "cars_listings.mileage >= '$_GET[km1]' ";
  49. }
  50.  
  51.  
  52. if(!empty($_GET[km2]))
  53. {
  54. $query[] = "cars_listings.mileage <= '$_GET[km2]' ";
  55. }
  56.  
  57.  
  58. if(!empty($_GET[snag1]))
  59. {
  60. $query[] = "cars_listings.snaga >= '$_GET[snag1]' ";
  61. }
  62.  
  63.  
  64. if(!empty($_GET[snag2]))
  65. {
  66. $query[] = "cars_listings.snaga <= '$_GET[snag2]' ";
  67. }
  68.  
  69. if(!empty($_GET[kub1]))
  70. {
  71. $query[] = "cars_listings.kubikaza >= '$_GET[kub1]' ";
  72. }
  73.  
  74. if(!empty($_GET[kub2]))
  75. {
  76. $query[] = "cars_listings.kubikaza <= '$_GET[kub2]' ";
  77. }
  78.  
  79. if(!empty($_GET[search_stanjevozila]))
  80. {
  81. $query[] = "cars_listings.stanjevozila = '$_GET[search_stanjevozila]' ";
  82. }
  83.  
  84. if(!empty($_GET[search_mjenjac]))
  85. {
  86. $query[] = "cars_listings.mjenjac = '$_GET[search_mjenjac]' ";
  87. }
  88.  
  89. if(!empty($_GET[search_karoserija]))
  90. {
  91. $query[] = "cars_listings.karoserija = '$_GET[search_karoserija]' ";
  92. }
  93.  
  94. if(!empty($_GET[search_pogon]))
  95. {
  96. $query[] = "cars_listings.pogon = '$_GET[search_pogon]' ";
  97. }
  98.  
  99. if(!empty($_GET[search_kozna_sjedala]))
  100. {
  101. $query[] = "cars_listings.kozna_sjedala = '$_GET[search_kozna_sjedala]' ";
  102. }
  103.  
  104. if(!empty($_GET[search_klima_manualna]))
  105. {
  106. $query[] = "cars_listings.klima_manualna = '$_GET[search_klima_manualna]' ";
  107. }
  108.  
  109. if(!empty($_GET[search_klima_auto]))
  110. {
  111. $query[] = "cars_listings.klima_auto = '$_GET[search_klima_auto]' ";
  112. }
  113.  
  114. if(!empty($_GET[search_abss]))
  115. {
  116. $query[] = "cars_listings.abss = '$_GET[search_abss]' ";
  117. }
  118.  
  119. if(!empty($_GET[search_asr]))
  120. {
  121. $query[] = "cars_listings.asr = '$_GET[search_asr]' ";
  122. }
  123.  
  124. if(!empty($_GET[search_esp]))
  125. {
  126. $query[] = "cars_listings.esp = '$_GET[search_esp]' ";
  127. }
  128.  
  129. if(!empty($_GET[search_alu_felge]))
  130. {
  131. $query[] = "cars_listings.alu_felge = '$_GET[search_alu_felge]' ";
  132. }
  133.  
  134. if(!empty($_GET[search_zracni_jastuk]))
  135. {
  136. $query[] = "cars_listings.zracni_jastuk = '$_GET[search_zracni_jastuk]' ";
  137. }
  138.  
  139. if(!empty($_GET[search_alarm]))
  140. {
  141. $query[] = "cars_listings.alarm = '$_GET[search_alarm]' ";
  142. }
  143.  
  144. if(!empty($_GET[search_siber]))
  145. {
  146. $query[] = "cars_listings.siber = '$_GET[search_siber]' ";
  147. }
  148.  
  149. if(!empty($_GET[search_tempomat]))
  150. {
  151. $query[] = "cars_listings.tempomat = '$_GET[search_tempomat]' ";
  152. }
  153.  
  154. if(!empty($_GET[search_el_podizaci]))
  155. {
  156. $query[] = "cars_listings.el_podizaci = '$_GET[search_el_podizaci]' ";
  157. }
  158.  
  159. if(!empty($_GET[search_cent_zakljuc]))
  160. {
  161. $query[] = "cars_listings.cent_zakljuc = '$_GET[search_cent_zakljuc]' ";
  162. }
  163.  
  164. if(!empty($_GET[search_auto_radio]))
  165. {
  166. $query[] = "cars_listings.auto_radio = '$_GET[search_auto_radio]' ";
  167. }
  168.  
  169. if(!empty($_GET[search_servo]))
  170. {
  171. $query[] = "cars_listings.servo = '$_GET[search_servo]' ";
  172. }
  173.  
  174. if(!empty($_GET[VehicleColor]))
  175. {
  176. $query[] = "cars_listings.VehicleColor = '$_GET[VehicleColor]' ";
  177. }
  178.  
  179. if(!empty($_GET[search_country]))
  180. {
  181. $query[] = "cars_agents.country = '$_GET[search_country]' ";
  182. }
  183.  
  184. if(!empty($_GET[search_city]))
  185. {
  186. $query[] = "cars_agents.city = '$_GET[search_city]' ";
  187. }
  188.  
  189. if(!empty($_GET[min]))
  190. {
  191. $query[] = "cars_listings.price >= '$_GET[min]' ";
  192. }
  193.  
  194. if(!empty($_GET[max]))
  195. {
  196. $query[] = "cars_listings.price <= '$_GET[max]' ";
  197. }
  198.  
  199. if(!empty($_GET[eur1]))
  200. {
  201. $query[] = "cars_listings.Euro >= '$_GET[eur1]' ";
  202. }
  203.  
  204. if(!empty($_GET[eur2]))
  205. {
  206. $query[] = "cars_listings.Euro <= '$_GET[eur2]' ";
  207. }
  208.  
  209. if(!empty($_GET[year1]))
  210. {
  211. $query[] = "cars_listings.VehicleYear >= '$_GET[year1]' ";
  212. }
  213.  
  214. if(!empty($_GET[year2]))
  215. {
  216. $query[] = "cars_listings.VehicleYear <= '$_GET[year2]' ";
  217. }
  218.  
  219. if(!empty($_GET[before]))
  220. {
  221. $MyDate = strtotime("-$_GET[before]");
  222. $query[] = "cars_listings.DateAdded >= '$MyDate' ";
  223. }
  224.  
  225. if(!empty($query))
  226. {
  227. $MyQuery = implode(" and ", $query);
  228. $MyQuery = " and ".$MyQuery;
  229. }
  230.  
  231.  
  232. ////////////////////////////////////////////////////////////
  233. ////////// order by
  234. ////////////////////////////////////////////////////////////
  235.  
  236. $order = array();
  237.  
  238. if(!empty($_GET[orderby]))
  239. {
  240. $MyOrder = explode("|", $_GET[orderby]);
  241.  
  242. while(list(,$ov) = each($MyOrder))
  243. {
  244. if($ov == "DateAdded")
  245. {
  246. $order[] = " cars_listings.DateAdded desc ";
  247. }
  248.  
  249. if($ov == "Price")
  250. {
  251. $order[] = " cars_listings.Price asc ";
  252. }
  253.  
  254. if($ov == "address")
  255. {
  256. $order[] = " cars_agents.address asc ";
  257. }
  258.  
  259. }
  260. }
  261. else
  262. {
  263. if(!empty($_GET[p]))
  264. {
  265. $order[] = " cars_listings.Price asc ";
  266. }
  267.  
  268. if(!empty($_GET[r]))
  269. {
  270. $order[] = " cars_listings.mileage asc ";
  271. }
  272.  
  273. if(!empty($_GET[vehicle]))
  274. {
  275. $order[] = " cars_vehicle.VehicleName ";
  276. }
  277.  
  278. }
  279.  
  280.  
  281. if(count($order) > '0')
  282. {
  283. $MyOrder = implode(", ", $order);
  284.  
  285. }
  286.  
  287. if(empty($MyOrder))
  288. {
  289. $MyOrder = " order by cars_agents.PriorityLevel desc, cars_listings.DateAdded desc";
  290. }
  291. else
  292. {
  293. $MyOrder = " order by cars_agents.PriorityLevel desc, $MyOrder, cars_listings.DateAdded desc";
  294. }
  295.  
  296.  
  297. if(!empty($_GET[Start]))
  298. {
  299. $Start = $_GET[Start];
  300. }
  301. else
  302. {
  303. $Start = '0';
  304. }
  305.  
  306. $ByPage = '10';
  307. if($aset[Sitefee]=="1")
  308. {
  309. $q1 = "select * from cars_listings, cars_agents, cars_vehicle where cars_listings.AgentID = cars_agents.AgentID and cars_agents.AccountStatus = 'active' and cars_listings.VehicleMake = cars_vehicle.VehicleID $MyQuery $MyOrder limit $from, $max_results ";
  310. $total_results = mysql_num_rows(mysql_query("select * from cars_listings, cars_agents, cars_vehicle where cars_listings.AgentID = cars_agents.AgentID and cars_agents.AccountStatus = 'active' and cars_listings.VehicleMake = cars_vehicle.VehicleID $MyQuery $MyOrder"));
  311. //echo $total_results;
  312. $total_pages = ceil($total_results / $max_results);
  313.  
  314. }
  315. else
  316. {
  317. $q1 = "select * from cars_listings, cars_agents, cars_priority, cars_vehicle where cars_listings.AgentID = cars_agents.AgentID and cars_agents.PriorityLevel = cars_priority.PriorityLevel and cars_agents.AccountStatus = 'active' and cars_listings.VehicleMake = cars_vehicle.VehicleID $MyQuery $MyOrder limit $from, $max_results ";
  318. $total_results = mysql_num_rows(mysql_query("select * from cars_listings, cars_agents, cars_priority, cars_vehicle where cars_listings.AgentID = cars_agents.AgentID and cars_agents.PriorityLevel = cars_priority.PriorityLevel and cars_agents.AccountStatus = 'active' and cars_listings.VehicleMake = cars_vehicle.VehicleID $MyQuery"));
  319.  
  320. $total_pages = ceil($total_results / $max_results);
  321. }
  322. $qnav = "select * from cars_listings, cars_agents where cars_listings.AgentID = cars_agents.AgentID $MyQuery";
  323.  
  324. $r1 = mysql_query($q1) or die(mysql_error());
  325. $lrows = mysql_num_rows($r1);
  326.  
  327. if($lrows > '0')
  328. {
  329. $ListingTable .= "<table align=center width=599px height=23 bgcolor=#EAEAEA class=border_za_detalj_4_1>\n";
  330. $ListingTable .= "<tr>\n<td width=100<strong>Rezultati pretrage</strong></td>\n\t";
  331.  
  332. $ListingTable .= "<td width=200 align=center><a href=\"trazi?c=$_GET[c]&vehicle=1 \">vozilo</a></td>\n\t";
  333.  
  334. $ListingTable .= "<td width=125 align=center><a href=\"trazi?c=$_GET[c]&r=1 \">kilometraža</a></td>\n\t";
  335.  
  336. $ListingTable .= "<td align=center width=100><a href=\"trazi?c=$_GET[c]
  337.  
  338. &min=$_GET[min]&max=$_GET[max]&p=1 \">cijena</a></td>\n";
  339.  
  340. $ListingTable .= "</tr>\n</table>\n\n";
  341.  
  342. $ListingTable .= "<table align=center width=599px height=23 bgcolor=#FFFFFF border=0 cellspacing=0 cellpadding=0 class=border_za_detalj_5>\n";
  343.  
  344. while($a1 = mysql_fetch_array($r1))
  345. {
  346. $ListingTable .= "<tr onMouseOver=\"this.style.background='#F7F7F7'; this.style.cursor='pointer'\" onMouseOut=\"this.style.background='#FFFFFF'\" onClick=\"window.open('oglas?id=$a1[ListingID]', '_top')\">\n\t";
  347. $ListingTable .= "<td height=60>";
  348.  
  349. $ListingTable .= "<table align=center width=\"100%\" border=0 cellspacing=0 cellpadding=0>\n";
  350.  
  351. $ListingTable .= "<caption align=center>";
  352. if($aset[Sitefee]=="0")
  353. {
  354. if($a1[PriorityLevel] > '1')
  355. {
  356. $ListingTable .= "<span class=RedLink>$a1[PriorityName] listing</span></caption>\n";
  357. }
  358. }
  359. $ListingTable .= "<tr>\n\t<td width=75>";
  360.  
  361. if(!empty($a1[image]))
  362. {
  363. $images = explode("|", $a1[image]);
  364. $MyImage = $images[0];
  365.  
  366. $ListingTable .= "<div style=padding:8px><img src=\"cars_images/$MyImage\" width=75 height=60></div>";
  367. }
  368. else
  369. {
  370. $ListingTable .= "<div style=padding:8px><img src=\"no_image.gif\"></div>";
  371. }
  372.  
  373. $ListingTable .= "</td><strong>\n\t";
  374.  
  375. $MyMiles = number_format($a1[mileage], 0, "", ".");
  376.  
  377. $ListingTable .= "</strong><td width=225 valign=top align=center><b><div style=padding:8px>$a1[VehicleName] $a1[VehicleModel]</b><br>Županija: $a1[country]</div></td>\n\t";
  378. $ListingTable .= "<td width=100 valign=top align=left><div style=padding:8px>$MyMiles km<br>Godina: $a1[VehicleYear]</div></td>\n\t";
  379.  
  380. $MyPrice = number_format($a1[Price], 2, ",", ".");
  381.  
  382. $ListingTable .= "<td align=center width=100 valign=top><div style=padding:8px><b>$MyPrice $aset[Currencya]</b><br>Oglas dodan: </div></td>\n";
  383.  
  384. $ListingTable .= "</tr>\n";
  385.  
  386. $ShortDesc = substr($a1[DetailedDesc], 0, 200);
  387.  
  388. $ListingTable .= "<tr>\n\t<td colspan=4><div style=padding:8px>$ShortDesc</div></td>\n</tr>\n";
  389.  
  390. $ListingTable .= "</table>\n\n</td>\n</tr><tr>\n\t<td height=23 class=border_za_detalj_4><div align=right><img src=brrrmmmm.com/brrmmm.png /></div></td>\n</tr>\n\n";
  391.  
  392. }
  393.  
  394. $ListingTable .= "</table><br />
  395. <div align=center>
  396. <a href=javascript:history.go(-1);> <strong>natrag</strong></a> | <a href=#><strong>vrh stranice</strong></a>
  397. </div>";
  398.  
  399. $rnav = mysql_query($qnav) or die(mysql_error());
  400. $rows = mysql_num_rows($rnav);
  401.  
  402. if($rows > $ByPage)
  403. {
  404. $ListingTable .= "<br><table align=center width=599px>";
  405. $ListingTable .= "<td align=center> | ";
  406.  
  407. $pages = ceil($rows/$ByPage);
  408.  
  409. for($i = 0; $i <= ($pages); $i++)
  410. {
  411. $PageStart = $ByPage*$i;
  412.  
  413. $i2 = $i + 1;
  414.  
  415. if($PageStart == $Start)
  416. {
  417. $links[] = "$i2\n\t ";
  418. }
  419. elseif($PageStart < $rows)
  420. {
  421. $links[] = "<a href=\"trazi?Start=$PageStart&c=$_GET[c]&page=$i2\">$i2</a>\n\t ";
  422. }
  423. }
  424.  
  425. $links2 = implode(" | ", $links);
  426.  
  427. $ListingTable .= $links2;
  428.  
  429. $ListingTable .= "|</td>";
  430.  
  431. $ListingTable .= "</table><br>\n";
  432.  
  433. }
  434. }
  435. else
  436. {
  437. $ListingTable = "<br><br><center>Nema rezultata! <a href=javascript:history.go(-1);> << natrag</a></center>";
  438. }
  439.  
  440. require_once("templates/HeaderTemplate.php");
  441. require_once("templates/SearchTemplate.php");
  442. require_once("templates/FooterTemplate.php");
  443.  
  444. ?>
Add Comment
Please, Sign In to add comment