stormx Posted December 4, 2008 Share Posted December 4, 2008 Hello, I can't seem to get my script working, here is the code below: $myarr = explode('<td>TrafficShare left:</td><td align=right style=\"padding-right:20px;\"><b>([0-9\.]+) GB</b>',$xxx); if (isset($myarr[1])) { $mybw = explode ("<td></td><b>",$myarr[1]); $tbw = round(($mybw[0] / 1000),1); if ($tbw>=50) { return "bandwidth"; //exit; } return $tbw; //exit; It just isn't exploding properly, please help Quote Link to comment https://forums.phpfreaks.com/topic/135576-explode-help/ Share on other sites More sharing options...
premiso Posted December 4, 2008 Share Posted December 4, 2008 You are using regex in the explode function, when explode does not understand regex. Try preg_match if you want to use regex. Quote Link to comment https://forums.phpfreaks.com/topic/135576-explode-help/#findComment-706291 Share on other sites More sharing options...
stormx Posted December 4, 2008 Author Share Posted December 4, 2008 Could I get some help with preg_match(), I have no clue how to use it on my script Quote Link to comment https://forums.phpfreaks.com/topic/135576-explode-help/#findComment-706300 Share on other sites More sharing options...
stormx Posted December 4, 2008 Author Share Posted December 4, 2008 I tried $myarr = explode('<td>TrafficShare left:</td><td align=right style=\"padding-right:20px;\"><b>([0-9\.]+) GB</b>',$xxx); //$mirrors = get_value_from_code('5 days Traffic:</td><td align=right style="padding-right:20px;"><b>',"$domain",$mirrorlink); if (isset($myarr[1])) { $mybw = preg_match("<td></td><b></b>",$myarr[1]); But no success Quote Link to comment https://forums.phpfreaks.com/topic/135576-explode-help/#findComment-706304 Share on other sites More sharing options...
.josh Posted December 5, 2008 Share Posted December 5, 2008 Would help if you gave an example string along with an example of what you're wanting to happen. Quote Link to comment https://forums.phpfreaks.com/topic/135576-explode-help/#findComment-706359 Share on other sites More sharing options...
stormx Posted December 5, 2008 Author Share Posted December 5, 2008 This is my whole code: <?php function get_value_from_code( $before, $after, $code) { $match = '#'.$before.'(.+?)'.$after.'#'; if( preg_match( $match, $code, $match)) { return $match[1]; } return false; } /** * @author Jamezzz * @copyright 2008 */ include "../db.php"; $conn=mysql_connect(mysql_host, mysql_user, mysql_password) or die(mysql_error()); mysql_select_db(mysql_db) or die("SQL Died"); function get_bw($cook) { $curl = curl_init(); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($curl, CURLOPT_HEADER, 1); //curl_setopt($curl, CURLOPT_POST, false); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_COOKIE, "user=$cook"); curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)"); curl_setopt($curl, CURLOPT_FOLLOWLOCATION, false); curl_setopt($curl, CURLOPT_URL, "https://ssl.rapidshare.com/cgi-bin/premiumzone.cgi"); $xxx = curl_exec($curl); $check1 = explode('if (1) {',$xxx); if (isset($check1[1])) { return "expired"; //die("expired"); //die($check1[1]); } $check2 = explode("Account has been found, but the password is incorrect",$xxx); if(isset($check2[1])){ return "incorrect"; //exit; } $check3 = explode("Fraud Detected",$xxx); if(isset($check3[1])){ return "incorrect"; //exit; } //die("expired"); $myarr = explode('<td>TrafficShare left:</td><td align=right style=\"padding-right:20px;\"><b>([0-9\.]+) GB</b>',$xxx); //$mirrors = get_value_from_code('5 days Traffic:</td><td align=right style="padding-right:20px;"><b>',"$domain",$mirrorlink); if (isset($myarr[1])) { $mybw = preg_match("<td></td><b></b>",$myarr[1]); $tbw = round(($mybw[0] / 1000),1); if ($tbw>=50) { return "bandwidth"; //exit; } return $tbw; //exit; } else { //$this->disable($cook,'true'); return "unknown"; //exit; } } $today = date('dmy'); $bandw = 0; $source = mysql_query("SELECT * FROM band WHERE disabled != 'expired' and disabled !='bandwidth' and disabled != 'incorrect'") or die(mysql_error()); $premnum = 0; $totalbw = 0; while($row = mysql_fetch_array( $source )) { $premnum++; $cook = $row['prem']; $premid = $row['id']; $type = $row['type']; $result=get_bw($cook); echo $cook; echo " "; echo $result; /*$result = $bandwidth; if($result == "expired" || $result == "bandwidth" || $result == "unknown" || $result=="incorrect") { $status = } else { $result= ""; $status = 1; }*/ mysql_query("update status set bandwidth='$result', type='$type' where AccountID='$premid'"); $query="Update band set disabled = '$result' WHERE prem='$cook'"; mysql_query($query) or die (mysql_error()); echo "<br />"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/135576-explode-help/#findComment-706430 Share on other sites More sharing options...
.josh Posted December 5, 2008 Share Posted December 5, 2008 Don't need your code. Need a 'before' and 'after' example of the string you want to regex. Quote Link to comment https://forums.phpfreaks.com/topic/135576-explode-help/#findComment-706450 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.