Need PHP help

Discussion in 'PHP' started by tyankee, Jan 12, 2011.

  1. #1
    I need help fixing a problem with http://www.trainmyspace.com. The images to the users are no longer showing up because, i think, myspace has changed the location of the images and this script pulls images from a myspace location. I can point you to the file where i think the problem is but i dont' know enough about the preg_match command to fix it.. I appreciate any help i can get.. Here is the code where i think the problem is:

    function GetProfileImage($profile, $id)
    {
    if(file_exists($file_name))
    return;
    $file_name = "cache/images/$id.png";
    if(file_exists($file_name))
    {
    $modif = filemtime($file_name);
    $use_http = (time() - $modif > 3600 * 24);
    }
    else
    $use_http = true;
    if($use_http)
    {
    preg_match('/<a\s+[^>]*id\s*=\s*".*?_hlDefaultImage"[^>]*>\s*<img[^>]*src\s*=\s*"([^"]+)"[^>]*>/i', $profile, $preg_result);
    if(count($preg_result) == 0)
    preg_match('/<a\s+[^>]*href\s*=\s*".*?fuseaction=user\.viewAlbums.*?"[^>]*>\s*<img[^>]*src\s*=\s*"([^"]+)"[^>]*>/i', $profile, $preg_result);
    $preg_result[1] = trim($preg_result[1]);
    if($preg_result[1] == '')
    {
    preg_match('/<a\s+[^>]*id\s*=\s*"ctl00_Main_ctl00_UserBasicInformation1_hlDefaultImage"[^>]*>\s*<img\s+src\s*=\s*"([^"]+)"\s*style\s*=\s*"\s*border-width\s*:\s*0\s*px\s*;\s*"\s*\/>\s*<\/a>/im', $profile, $preg_result);
    $preg_result[1] = trim($preg_result[1]);
    if($preg_result[1] == '') $url = "http://x.myspace.com/images/no_pic.gif";
    else $url = $preg_result[1];
    }

    else
    $url = $preg_result[1];
    $image_data = GetData($url);
    $image = imagecreatefromstring($image_data);
    $image_w = imagesx($image);
    $image_h = imagesy($image);
    $coef_x = 100 / $image_w;
    $coef_y = 100 / $image_h;
    $coef_real = min($coef_x, $coef_y);
    if($coef_real > 1)
    $coef_real = 1;
    $sample_w = $image_w * $coef_real;
    $sample_h = $image_h * $coef_real;
    $sample_image = imagecreatetruecolor($sample_w, $sample_h);
    imagecopyresampled($sample_image, $image, 0, 0, 0, 0, $sample_w, $sample_h, $image_w, $image_h);
    imagepng($sample_image, $file_name);
    imagedestroy($image);
    imagedestroy($sample_image);
    }
    return $file_name;
    }
     
    tyankee, Jan 12, 2011 IP
  2. tyankee

    tyankee Well-Known Member

    Messages:
    1,023
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    150
    #2
    I would also like this script copied and modified to become a facebook friend train - as a separate project.
     
    tyankee, Jan 12, 2011 IP