PageRenderTime 44ms CodeModel.GetById 13ms RepoModel.GetById 1ms app.codeStats 0ms

/how-it-works/tracking.php

https://bitbucket.org/bfarleigh/transdirect
PHP | 379 lines | 308 code | 58 blank | 13 comment | 19 complexity | aacb6118b0d76630cfa5b09119d632c4 MD5 | raw file
  1. <?php
  2. set_time_limit(0);
  3. ini_set('memory_limit', '160000000M');
  4. require_once('simple_html_dom.php');
  5. function getCokies($url,$postFields){
  6. $ch = curl_init($url);
  7. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  8. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  9. curl_setopt($ch, CURLOPT_HEADER, 1);
  10. curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields);
  11. preg_match('/^Set-Cookie: (.*?);/m', curl_exec($ch), $m);
  12. return $m[1];
  13. }
  14. ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  15. <html xmlns="http://www.w3.org/1999/xhtml">
  16. <head>
  17. <title>Courier Australia, Interstate Couriers, Courier Service Australia, Sydney, Melbourne, Brisbane, Courier Delivery, Australian Courier Company, Perth, Adelaide, Hobart, Darwin, Canberra - Parcel Courier Service - Door to Door Anywhere in Australia!</title>
  18. <meta name="keywords" content="Post, send , transport, freight, courier, package, parcel, ebay, shipping" />
  19. <meta name="description" content="Transdirect door to door freight for everybody." />
  20. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  21. <meta http-equiv="Content-Language" content="en-au" />
  22. <meta name="robots" content="index, follow " />
  23. <link rel="stylesheet" href="/css/screen.css" type="text/css" media="screen" />
  24. <link rel="stylesheet" href="/css/print.css" type="text/css" media="print" />
  25. <link rel="stylesheet" href="/css/sIFR-screen.css" type="text/css" media="screen" />
  26. <link rel="stylesheet" href="/css/sIFR-print.css" type="text/css" media="print" />
  27. <link rel="Shortcut Icon" href="/favicon.ico" type="image/x-icon" />
  28. <script type="text/javascript" src="/inc/js/swfobject.js"></script>
  29. <script type="text/javascript" src="/inc/js/sifr.js"></script>
  30. <script type="text/javascript" src="/inc/js/mootools.v1.11.js"></script>
  31. <script type="text/javascript" src="/inc/js/std-scripts.js"></script>
  32. <!--[if lt IE 7]><script language="javascript" type="text/javascript" src="/inc/js/sleight.js"></script><![endif]-->
  33. <script type="text/javascript">
  34. var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
  35. document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
  36. </script>
  37. <script type="text/javascript">
  38. var pageTracker = _gat._getTracker("UA-5698511-1");
  39. pageTracker._trackPageview();
  40. </script>
  41. <style type="text/css">
  42. <!--
  43. .style3 {font-size: 14px}
  44. .style6 {font-size: 16px; color: #000099; }
  45. .style8 {font-size: 14px; color: #FF9933; }
  46. .style9 {font-size: 16px; color: #000000; }
  47. .detailsTable
  48. {
  49. width: 500px;
  50. }
  51. .detailsTable td
  52. {
  53. vertical-align: top;
  54. }
  55. .detailsTable tr
  56. {
  57. }
  58. .headerTable
  59. {
  60. margin: 0px;
  61. padding: 0px;
  62. width: 100%;
  63. }
  64. .podImage
  65. {
  66. width: 500px;
  67. }
  68. table
  69. {
  70. font-size: 11px;
  71. }
  72. th
  73. {
  74. background-color: #4F4F4F;
  75. font-size: 12px;
  76. font-weight: bold;
  77. text-align: center;
  78. }
  79. -->
  80. </style>
  81. <!-- search engine tracking script V.1.0 -->
  82. <script type="text/javascript">//<![CDATA[
  83. var ns_data,ns_hp,ns_tz,ns_rf,ns_sr,ns_img,ns_pageName;
  84. ns_pageName= this.location;
  85. document.cookie='__support_check=1';ns_hp='http';
  86. ns_rf=document.referrer;ns_sr=window.location.search;
  87. ns_tz=new Date();if(location.href.substr(0,6).toLowerCase() == 'http:')
  88. ns_hp='http';ns_data='&an='+escape(navigator.appName)+
  89. '&sr='+escape(ns_sr)+'&ck='+document.cookie.length+
  90. '&rf='+escape(ns_rf)+'&sl='+escape(navigator.systemLanguage)+
  91. '&av='+escape(navigator.appVersion)+'&l='+escape(navigator.language)+
  92. '&pf='+escape(navigator.platform)+'&pg='+escape(ns_pageName);
  93. ns_data=ns_data+'&cd='+screen.colorDepth+'&rs='+escape(screen.width+ ' x '+screen.height)+
  94. '&tz='+ns_tz.getTimezoneOffset()+'&je='+ navigator.javaEnabled();
  95. ns_img=new Image();ns_img.src=ns_hp+'://tracker.statgauge.com/statistics.aspx'+
  96. '?v=1&s=213&acct=225183'+ns_data+'&tks='+ns_tz.getTime(); //]]>
  97. </script>
  98. <!-- End search engine tracking script -->
  99. </head>
  100. <body>
  101. <div id="header-outer">
  102. <div id="header">
  103. <h1><a href="/" title=""><span>Post / send / transport / freight / courier your package or parcel from A to B - Ebay specialists!</span></a></h1>
  104. <a class="airlink" href="/accountquery/" onclick="_gaq.push(['_trackEvent', 'Account Query', 'Button Click', '/accountquery/']);"></a>
  105. </div>
  106. <div id="top-nav-span">
  107. <div id="top-nav-wrap">
  108. <ul id="top-nav">
  109. <li id="home"><a href="/" title=""><span>Home</span></a></li>
  110. <li id="how-it-works"><a class = "current" href="/how-it-works/" title=""><span>How It Works?</span></a></li>
  111. <li id="why-transdirect"><a href="/why-transdirect-couriers/" title=""><span>Why Transdirect Couriers?</span></a></li>
  112. <li id="insurance"><a href="/parcel-insurance/" title=""><span>Parcel Insurance</span></a></li>
  113. <li id="contact"><a href="/contact/" title=""><span>Contact Us</span></a></li>
  114. </ul>
  115. </div>
  116. </div>
  117. </div>
  118. <div id="subpage-outer" class="quote">
  119. <div id="content">
  120. <div id="left">
  121. <div class="padFix">
  122. <a name="top"></a>
  123. <?
  124. require_once('../calc/config.inc.php');
  125. //echo '<pre>';print_r($_GET);exit;
  126. if(!mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASS))
  127. die('Could not connect to the database.');
  128. if(!mysql_select_db(MYSQL_DB))
  129. die('Could not select the database.');
  130. //$connote = $_GET['connote']; //'AOE148656';
  131. /********************* T O L L **************************/
  132. //Check if this is a Toll cannote.
  133. if(strpos($_GET['connote'],"846827")===false){
  134. $connoteInTable = 'XXXXXXX';
  135. }
  136. else{
  137. $connoteInTable = substr(trim($_GET['connote']),6);
  138. }
  139. $ck_toll_query = mysql_query("SELECT `id`,`connote` FROM `bookings_toll` WHERE `id`='".mysql_real_escape_string(trim($_GET['connote']))."' OR `connote`='".mysql_real_escape_string($connoteInTable)."' LIMIT 1");
  140. if(mysql_num_rows($ck_toll_query)){
  141. $tollOrderDetails = mysql_fetch_row($ck_toll_query);
  142. $connote = $tollOrderDetails[1];
  143. if(stristr($connote, '846827') === false) $connote = '846827'.$connote; // check for 846827 at front, add it if not there
  144. if($connote){
  145. $url ='https://online.toll.com.au/trackandtrace/traceConsignments.do';
  146. $postFields = 'consignments='.trim($connote);
  147. $sessionId = (getCokies($url,$postFields, $ckfile));
  148. // $urlTocall = "https://online.toll.com.au/trackandtrace/consignmentDetails.do;".$sessionId."?consignment=".trim($connote)."&recordCreatedBy=FIMS&groupId=";
  149. // $html = str_get_html(file_get_contents($urlTocall));
  150. $opts = array('http' => array('header'=> 'Cookie: '.$sessionId."\r\n"));
  151. $context = stream_context_create($opts);
  152. $urlTocall = "https://online.toll.com.au/trackandtrace/consignmentDetails.do?consignment=".trim($connote)."&recordCreatedBy=FIMS&groupId=";
  153. $html = str_get_html(file_get_contents($urlTocall,false,$context));
  154. foreach($html->find('div[class=errors]',0)->find('font') as $e){
  155. $error = $e->innertext;
  156. }
  157. if($error){
  158. echo '<h2>Consignment Information: '.$connote.'</h2>';
  159. echo '<h3>Consignment not found. </h3>';
  160. }else{
  161. echo '<h2>Consignment Information: '.$connote.'</h2>';
  162. echo '<table class="detailsTable" cellspacing="5" cellpadding="10" id="dimensionsTable">';
  163. ?>
  164. <tr>
  165. <th>Date</th>
  166. <th>Location</th>
  167. <th>Items</th>
  168. <th>Tracking Event</th>
  169. <th>Destination</th>
  170. </tr>
  171. <?php
  172. foreach($html->find('td[colspan=2] > table[width=100%]',3)->find('tr') as $tr){
  173. echo '<tr>';
  174. $cnt=0;
  175. foreach($tr->find('td') as $td){
  176. if($cnt==0){ $cnt++; continue;}
  177. echo '<td>';
  178. echo trim($td->plaintext);
  179. echo '</td>';
  180. }
  181. echo '</tr>';
  182. }
  183. echo '</table>';
  184. }
  185. $html->clear();
  186. unset($html);
  187. ?>
  188. <a href="/onlinequery/?consignment=<?=$connote?>"><button style="padding:5px;margin-top:10px;">OPEN AN ONLINE QUERY - CLICK HERE</button></a>
  189. <?
  190. }
  191. }
  192. /********************* T O L L **************************/
  193. else{
  194. $inTabCN = substr(trim($_GET['connote']),3);
  195. // check in Allied table it its with ID and get cannote number.
  196. $ck_allied_id = mysql_query("SELECT `connote`,`receiver_id` FROM `bookings` WHERE `id`='".mysql_real_escape_string(trim($_GET['connote']))."' OR `connote`='".mysql_real_escape_string($inTabCN)."' LIMIT 1");
  197. if(mysql_num_rows($ck_allied_id)){
  198. $resAllied = mysql_fetch_row($ck_allied_id);
  199. $connote = $resAllied[0];
  200. $despc_q = mysql_query("SELECT `postcode` FROM `addresses` WHERE `id`='".mysql_real_escape_string($resAllied[1])."' LIMIT 1");
  201. if(mysql_num_rows($despc_q)){
  202. $despc_res = mysql_fetch_row($despc_q);
  203. $destpc = $despc_res[0];
  204. }
  205. if(stristr($connote, 'aoe') === false) $connote = 'aoe'.$connote; // check for aoe at front, add it if not there
  206. $connote = strtoupper($connote);
  207. if(stristr($connote, '-0')) { // they put the -00x on the end, trim it...
  208. $trimpos = strpos($connote, '-0');
  209. $connote = substr($connote, 0, $trimpos);
  210. }
  211. $destpc = str_pad($destpc, 4, "0", STR_PAD_LEFT); // added on 2/11/2013
  212. $data = file_get_contents('http://neptune.alliedexpress.com.au/iTrack/search.do?sig=0C5E96954FB23091E0E4A795C8063C67&ono=&tno='.$connote.'&dpc='.$destpc.'&searchType=con');
  213. $startpos = strpos($data, '<!-- Start Page Content -->');
  214. $endpos = strpos($data, '<!-- End Page Content -->');
  215. $data = substr($data, $startpos, ($endpos - $startpos));
  216. $data = str_replace('h1', 'h2', $data);
  217. $data = str_replace('cellspacing="1"', 'cellspacing="5"', $data);
  218. $data = str_replace('cellpadding="3"', 'cellpadding="10"', $data);
  219. $data = str_replace('caption', 'h3', $data);
  220. $data = str_replace("src='/iTrack/", "src='http://neptune.alliedexpress.com.au/iTrack/", $data);
  221. $data = str_replace('<td class="column1">Weight</td>', '<td class="column1">Charged Weight</td>', $data);
  222. // Remove all the job info from the top, especially the damn scheduled delivery date.....
  223. if(stristr($data, '<fieldset id="jobDetails">')) { // exists
  224. // Work out where the scheduled delivery info starts and ends...
  225. $delivery_startpos = strpos($data, '<fieldset id="jobDetails">');
  226. $delivery_endpos = (strpos($data, '</fieldset>', $delivery_startpos) + 11); // the +11 is so the fieldset is removed too
  227. // Chop out the scheduled delivery date, as it is bullsh
  228. $result = substr($data, 0, $delivery_startpos);
  229. $result.= substr($data, $delivery_endpos);
  230. } else { // nope delivery date does not exist, leave alone
  231. $result = $data;
  232. }
  233. // chop out bazza's error message if it exists
  234. if(stristr($result, 'Urgent Notice'))
  235. {
  236. $bazza_startpos = strpos($result, '<fieldset id="jobDetails" style="color:#000000; background-color:#FFFFFF; font-size: 14px; ">');
  237. $bazza_endpos = (strpos($result, '</fieldset>', $bazza_startpos) + 11); // the +11 is so the fieldset is removed too
  238. $newresult = substr($result, 0, $bazza_startpos);
  239. $newresult.= substr($result, $bazza_endpos);
  240. } else {
  241. $newresult = $result;
  242. }// enough of bazza's crapola
  243. // spit it out...
  244. echo $newresult;
  245. ?>
  246. <p>&nbsp;</p>
  247. <h3>Legend</h3>
  248. <table>
  249. <tr><td width="100px"><b><u>SCAN DATE</u></b></td><td>The date and time of current location, and status.</td></tr>
  250. <tr><td colspan="2">&nbsp;</td></tr>
  251. <tr><td><b><u>LOCATION</u></b></td><td>&nbsp;</td></tr>
  252. <tr><td>MEL</td><td>The item is currently in Melbourne</td></tr>
  253. <tr><td>SYD</td><td>The item is currently in Sydney</td></tr>
  254. <tr><td>etc</td><td>etc</td></tr>
  255. <tr><td colspan="2">&nbsp;</td></tr>
  256. <tr><td><b><u>STATUS</u></b></td><td>&nbsp;</td></tr>
  257. <tr><td>AMIN</td><td>The item scanned into the depot in the morning</td></tr>
  258. <tr><td>PMIN</td><td>The item scanned into the depot in the afternoon</td></tr>
  259. <tr><td>123OUT</td><td>The item is currently being delivered by driver 123</td></tr>
  260. <tr><td>DEL</td><td>The item has been delivered</td></tr>
  261. <tr><td>PODIN</td><td>The Proof of delivery is now available</td></tr>
  262. <tr><td>MEL</td><td>The item is on the way to Melbourne</td></tr>
  263. <tr><td>SYD</td><td>The item is on the way to Sydney</td></tr>
  264. <tr><td>ADL</td><td>The item is on the way to Adelaide</td></tr>
  265. <tr><td>PER</td><td>The item is on the way to Perth</td></tr>
  266. <tr><td>ROADIN</td><td>Main linehaul truck has arrived in depot</td></tr>
  267. <tr><td>CL</td><td>Delivery was attempted, and a card was left</td></tr>
  268. <tr><td>etc</td><td>etc</td></tr>
  269. </table>
  270. <?php
  271. }
  272. else{
  273. echo '<h2>Consignment Information: '.$_GET['connote'].'</h2>';
  274. echo '<h3>Consignment not found. </h3>';
  275. }
  276. ?>
  277. <a href="/onlinequery/?consignment=<?=$connote?>"><button style="padding:5px;margin-top:10px;">OPEN AN ONLINE QUERY - CLICK HERE</button></a>
  278. <?
  279. } ?>
  280. <div class="float-fix"></div>
  281. </div>
  282. </div>
  283. <div id="right">
  284. <div class="padFix">
  285. <h2 style="color:FF6D0C;">Translinks</h2>
  286. <ul>
  287. <li><a href="/faq" title="">Frequently Asked Questions</a></li>
  288. <li><a href="./#top" title="">How it Works</a></li>
  289. <? // <li><a href="./#compare" title="">Compare our Rates</a></li> ?>
  290. <li><a href="./#requirements" title="">Packing &amp; Sending Requirements</a></li>
  291. <li><a href="./#measuring" title="">Measuring Info</a></li>
  292. <li><a href="./#tracking" title="">Tracking Info</a></li>
  293. <li><a href="./#times" title="">Transit Times</a></li>
  294. <li><a href="./#regular" title="">Regular Sender?</a></li>
  295. </ul>
  296. </div>
  297. </div>
  298. <div class="float-fix"></div>
  299. </div>
  300. </div>
  301. <div id="footer-outer">
  302. <div id="footer">
  303. <div class="left">
  304. <p><strong>TransDirect</strong> - Post, send, transport, freight or courier your package or parcel from A to B - Ebay specialists!<br />
  305. <script type="text/javascript">generateEmailLink('info', 'transdirect.com.au');</script><br />
  306. ph. 1300 668 229</p>
  307. </div>
  308. <div class="right">
  309. <p><a href="/contact" title="">CONTACT</a> | <a href="/terms/" title="">TERMS &amp; CONDITIONS</a></p>
  310. <p>&copy; 2008 TransDirect - <a href="/resources">Resources</a> <br>
  311. <a href="http://courier-brisbane.transdirect.com.au/">Brisbane</a> - <a href="http://courier-adelaide.transdirect.com.au/">Adelaide</a> -
  312. <a href="http://courier-canberra.transdirect.com.au/">Canberra</a> - <a href="http://courier-darwin.transdirect.com.au/">Darwin</a> -
  313. <a href="http://courier-hobart.transdirect.com.au/">Hobart</a> - <a href="http://courier-melbourne.transdirect.com.au/">Melbourne</a> -
  314. <a href="http://courier-perth.transdirect.com.au/">Perth</a> - <a href="http://courier-sydney.transdirect.com.au/">Sydney</a>
  315. </p>
  316. </div>
  317. <div class="float-fix"></div>
  318. </div>
  319. </div>
  320. </body>
  321. </html>