Jump to content

works on local , no response on remote


arash

Recommended Posts

i wrote code bellow , it works on local [tested by easy php] , but there is just no respone on remote  , like : http://yahooavatarload.sourceforge.net/?yid=darkeliden

 

code :

<?php

if (isset($_GET['yid'])) {
$id=$_GET['yid'];
$fn="http://img.msg.yahoo.com/avatar.php?yids=$id&format=png&width=120&height=120";
$handle = fopen("$fn", "r");
$contents = stream_get_contents($handle);
$fp = fopen('avats/'.$id.'.png', 'w');
fwrite($fp, $contents);
fclose($fp);


// load the image from the file specified:
$img="avats\\".$id.".png";
$im = imagecreatefrompng("$img");
// if there's an error, stop processing the page:
if(!$im)
{
die("");
}

// define some colours to use with the image
$yellow = imagecolorallocate($im, 255, 255, 0);
$black = imagecolorallocate($im, 0, 0, 0);

// get the width and the height of the image
$width = imagesx($im);
$height = imagesy($im);

// draw a black rectangle across the bottom, say, 20 pixels of the image:
imagefilledrectangle($im, 0, ($height-15) , $width, $height, $black);

// now we want to write in the centre of the rectangle:
$font = 3; // store the int ID of the system font we're using in $font
$text = "Y A L - NG"; // store the text we're going to write in $text
// calculate the left position of the text:
$leftTextPos = ( $width - imagefontwidth($font)*strlen($text) )/2;
// finally, write the string:
imagestring($im, $font, $leftTextPos, $height-13, $text, $yellow);

// output the image
// tell the browser what we're sending it
Header('Content-type: image/png');
// output the image as a png
imagepng($im);

// tidy up
imagedestroy($im);



}else{
echo "NO ID ENTERED";
}
?>

Link to comment
Share on other sites

Instead do a file_put_contents() and wrap it to check and see if it returns false like so:

<?php
if(file_put_contents('avats/'.$id.'.png',$contents)===FALSE ) {
  echo 'You are encountering a problem writing to the disk on this server!';
  exit;
}

This will be a definitive answer if it is a write issue, if not then let me know and we will do some more trouble shooting.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.