Project Detail

Modification of php code in order to fits our demand!  

Modification of php code in order to fits our demand! is project number 326659
posted at Freelancer.com. Click here to post your own project.

 

| More Free Trial For New Buyers
 

Status:

Selected Providers: COGWebTech

Budget: $30-250

Created: 10/23/2008 at 13:49 EDT

Bid Count: 6

Average Bid:
$ 154

12/22/2008 at 13:49 EST

Project Creator: girolimoni
Employer Rating: (No Feedback Yet)

Bid On This Project
 

Description

I need someone to modify the following code in order that it can grab 2 different html pages:

?php
/*
$Id: sp_tracking.php, v1.0 01/16/2008 osC forum - id chris23

Provides courier tracking for Swiss Post

This script will be called via ajax from account_history_info.php and admin/orders.php

osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com

Copyright (c) 2003 osCommerce

Released under the GNU General Public License

*/

// prevent direct calls to this page

if (!isset($_GET['tracking_id'])) {
die('Direct call to script. Exiting.');
}

require("includes/application_top.php");
require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_TRACKING_MODULE);


$tracking_number = $_GET['tracking_id'];

$sp_get_receiver_url = TRACKING_GET_URL_SP;

$params = "&DCSext.wt_shortcut=swisspost-tracking";

$agent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; InfoPath.1; .NET CLR 2.0.50727)"; // dummy UA

$url = $sp_get_receiver_url . $tracking_number . $params;


//echo $url; die();
/*
no redirects for ie so grab data and clean
*/

$ch = curl_init();
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$grab_data = curl_exec($ch);
if ($error = curl_errno($ch)) {
if ($error == 7) {
die(TRACKING_CURL_SERVER_ERROR);
}
if ($error == 6) {
die(TRACKING_CURL_NO_ACTIVE_INTERNET);
}
}
curl_close($ch);

// tidy extraneous whitespace - use on all grabs

$grab_data = str_replace("n", "", $grab_data);
$grab_data = str_replace("r", "", $grab_data);
$grab_data = str_replace("t", "", $grab_data);
$grab_data = str_replace(" ", "", $grab_data);
$pat[0] = "/^s+/";
$pat[1] = "/s{2,}/";
$pat[2] = "/s+$/";
$rep[0] = "";
$rep[1] = " ";
$rep[2] = "";

$grab_data = preg_replace($pat, $rep, $grab_data);

// set html start and end grab

$StartGrab = '<!--bean:write name="parcelEvent" property="product"/-->';
$EndGrab = '<!-- FINE Packet post-->';

// Grab delivery status information
$text = eregi("$StartGrab(.*)$EndGrab", $grab_data, $content);

// start custom tidying
// strip tags - keep tracking table

$content = strip_tags($content[1], '<table><tr><th></th><td></td></tr></table>');

// remove all html attributes

function strip_attributes($msg, $tag, $attr) {
$lengthfirst = 0;
while (strstr(substr($msg, $lengthfirst), "<$tag ") != "") {
$imgstart = $lengthfirst + strpos(substr($msg, $lengthfirst), "<$tag ");
$partafterwith = substr($msg, $imgstart);
$img = substr($partafterwith, 0, strpos($partafterwith, ">")+1);
$img = str_replace(" =", "=", $msg);
$out = "<$tag";

for($i = 0; $i <= (count($attr) - 1 );
$i++) {
$long_val = strpos($img, " ", strpos($img, $attr[$i]."=")) - (strpos($img, $attr[$i]."=") + strlen($attr[$i]) + 1) ;
$val = substr($img, strpos($img, $attr[$i]."=") + strlen($attr[$i]) + 1, $long_val);
if (strlen($val) > 0) $attr[$i] = " ".$attr[$i]."=".$val;
else $attr[$i] = "";
$out .= $attr[$i];
}

$out .= ">";
$partafter = substr($partafterwith, strpos($partafterwith, ">")+1);
$msg = substr($msg, 0, $imgstart).$out.$partafter;
$lengthfirst = $imgstart+3;
}
return $msg;
}

$content = strip_attributes($content, "tr", array());
$content = strip_attributes($content, "td", array());

$content = preg_replace("/writeBgColor(d{1});/","", $content);

// fix table font size

$content = str_replace("<table border="0" cellpadding="0" cellspacing="0" width="496">","<table border="0" cellpadding="0" cellspacing="0" width="100%" style="font-size: 11px; padding: 5px 0 5px 0;">",$content);

echo $content;

// the following function may be needed if remote server returns utf encoding (parent osC page is iso-8859) - prevents ? characters appearing
// uncomment if returned text contains ? in a little diamond.
echo mb_convert_encoding($output,"UTF-8","ISO-8859-1");
?>



Messages Posted:2 View project clarification board Post message on project clarification board

Bid On This Project
 

If you are the project creator or one of the bidders Log In for more options

 

45

0 days

10-09-2008 14:41 EDT

get it done within next 3 hours... Thanks

help

 

200

6 days

10-23-2008 17:10 EDT

Lets start. Thank you.

help

 

30

0 days

10-24-2008 00:12 EDT

quick work. ready to start right now.

help

 

250

5 days

11-20-2008 02:52 EST

We have similar projects here, the team with over 7 years working experiences. please kindly check PMB for details, thank you.

help

 

250

5 days

10-11-2008 03:43 EDT

See PMB. Thank you.

help

 

150

3 days

12-22-2008 10:45 EST

Hi, Please check PMB for other detail and lets start doing this project. Regards

help


    Bid on this Project