Need help adding variable to script

Discussion in 'PHP' started by Loryman, Dec 10, 2008.

  1. #1
    I'm new to PHP but I bought a script a while ago (a myspace adder website script) and since myspace has changed around quite a lot lately, theres now 3 or 4 different layout codes, which is a really big pain when it comes to my script trying to fetch something from any of them.
    I was just wondering if anyone could help me insert a variable, so I can enter the 3/4 different styles of code, allowing it to fetch the info I need from them all without any problems?

    The code is below:
    <?php
    session_start();
    if(isset($_POST['submit']))
    {
    include 'config.php';
    mysql_connect("$host", "$username", "$password")or die("cannot connect");
    mysql_select_db("$db_name")or die("cannot select DB");
    $ip   = $_SERVER['REMOTE_ADDR'];
    
    $fid = $_POST['fid'];
    
    
    
    
    if($fid == 6221){
    ?>
    
    <script language="javascript"><!--
    alert("The ID you entered has been banned!")
    location.replace("index.php")
    //-->
    </script>
    
    
    <?PHP }
    
    
    else {
    $pass = $_POST['password'];
    $sql="SELECT * FROM xtrm_users WHERE fid='$fid'";
    $result=mysql_query($sql);
    $check=mysql_fetch_array($result);
      if($check[fid]==$fid) {
                  	 if($check[password]=='XtRmWeB') {
    mysql_query("UPDATE xtrm_users SET ip = '$ip', last_login=CURRENT_TIMESTAMP WHERE fid = '$fid'");
    	 	 $_SESSION["fid"] = $fid;
    		 header("location:home.php"); }
                           else {
                              if($pass==$check[password]) {
    mysql_query("UPDATE xtrm_users SET ip = '$ip', last_login=CURRENT_TIMESTAMP WHERE fid = '$fid'");
    				 	 $_SESSION["fid"] = $fid;
    					 header("location:home.php"); }
    			   else { ?>
                           
    
    <script language="javascript"><!--
    alert("Invalid Password!")
    location.replace("index.php")
    //-->
    </script> <?PHP }
    
    
     					}
    }
    else {
    define ("profile_url","http://profile.myspace.com/index.cfm?fuseaction=user.viewprofile&friendID=" );
    $full_file_path = profile_url.$fid;
    $handle = fopen($full_file_path,"r");
    	if (!$handle){
        	echo "<p>Sorry Myspace Is Slow Try Again.\n";
        	$arr = 0; }
    	else {
    	$timeout = 300;
    	ini_set('max_execution_time','120');
    	set_time_limit(120);
    	ini_set('default_socket_timeout','120');
    	while($contents = fread($handle,'1024'))
    	{ $hold .= $contents; }
    	preg_match("/<a.*?href=\"http:\/\/viewmorepics.myspace.com\/index\.cfm\?fuseaction=user.*?<img.*?[^\>]*src=\"([^\">]+)/is",$hold,$match);
    $pic_url = $match[1];
    preg_match("/<span class=\"nametext\">(.*)<br \/>/",$hold,$match);
    $name = $match[1];
    		if(empty($pic_url))
    		{
    		preg_match("/<a.*?href=\"http:\/\/viewmorepics.myspace.com\/index\.cfm\?fuseaction=user.*?<img.*?[^\>]*src=\"([^\">]+)/is",$hold,$match);
    
    		$pic_url = $match[1];
    		}
    		if(empty($name))
    		{
    		preg_match("/<span class=\"nametext\">(.*)<\/span>/",$hold,$match);
    		$name = $match[1];
    		}
    		
    		fclose($handle);
    		ini_restore('max_execution_time');
    		ini_restore('default_socket_timeout');
    		if(empty($pic_url))
    		{ ?>
    <script language="javascript"><!--
    alert("Invalid ID!")
    location.replace("index.php")
    //-->
    </script>
    <?PHP
    		
    		}
    else
    {
    $oldip = $_POST['new'];
    $sql = "SELECT * FROM xtrm_users WHERE fid = '$oldip'";
    $res = mysql_query($sql);
    echo mysql_error();
    $check = mysql_fetch_array($res);
       $newip = $check['ip']; 
     if($newip!=$ip) {
    mysql_query("UPDATE xtrm_users SET points = points+50 WHERE fid = '$oldip'");
    mysql_query("UPDATE xtrm_users SET refs = refs+1 WHERE fid = '$oldip'");
    mysql_query("UPDATE xtrm_users SET total_points = total_points+50 WHERE fid = '$oldip'");
    }
    else {
    //add a feature here in the future.. mrnightowl
    }
    
    
    $pic = $pic_url;
    mysql_query("INSERT INTO xtrm_users SET 
    				pic='$pic_url',
    				name='$name', 
    				ip='$ip', 
    				fid='$fid'");
     $_SESSION["fid"] = $fid;
    header("location:home.php");
     }
    }
    }
    }
    }
    ?>
    
    PHP:
    The thing that I need to change is the part below, the rest works fine.
    preg_match("/<a.*?href=\"http:\/\/viewmorepics.myspace.com\/index\.cfm\?fuseaction=user.*?<img.*?[^\>]*src=\"([^\">]+)/is",$hold,$match);
    PHP:

    Also, if you could also help me with another thing, if the information it fetches is "http://x.myspacecdn.com/modules/common/static/img/clear.gif", ignore it and keep trying until it finds something else. Sometimes the code I have fetches that instead of the correct info.

    Let me know if you can help out at all, thanks a lot!
     
    Loryman, Dec 10, 2008 IP
  2. Loryman

    Loryman Peon

    Messages:
    10
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Still need help with this script.
    I'll give $10 for a quick fix, anyone?

    PM me if interested.
    Thanks.
     
    Loryman, Dec 11, 2008 IP