ציטוט:
נכתב במקור על ידי drowkid
|
תודה...אההההם יש לי עם זה בעיה

עשיתי בדיקה והכל ותראה איזה "יופי"
http://myrand.net/new/img.php?id=1
הנה הקובץ IMG:
PHP קוד:
<?
if(isset($_GET['id'])) {
if(is_numeric($_GET['id'])) {
include 'func.php';
include 'db.php';
$id = $_GET['id'];
$id = intval($id);
$select = mysql_query("SELECT * FROM `banners` WHERE `mid`='$id' ORDER BY rand()") or die(mysql_error());
$count = mysql_num_rows($select);
if($count != 0) {
$select = mysql_fetch_assoc($select);
$url = $select['url'];
if(url_exists($url)) {
$fParts = explode(".", $url);
$ext = $fParts[count($fParts)-1];
if($ext == "gif") {
$image = imagecreatefromgif ($url);
} elseif($ext == "jpg") {
$image = imagecreatefromjpeg ($url);
} elseif($ext == "jpeg") {
$image = imagecreatefromjpeg ($url);
} elseif($ext == "png") {
$image = imagecreatefrompng ($url);
}
$back_color = imageColorAllocate($image, 255, 255, 255);
$draw_color = imagecolorallocate($image, 255, 255, 255);
imagerectangle($image, 0, 0, imagesx($image) - 0,
imagesy($image) - 0, $draw_color);
if($ext == "gif") {
header('Content-Type: image/gif');
imagegif($image);
} elseif($ext == "jpg") {
header('Content-Type: image/jpeg');
imagejpeg($image);
} elseif($ext == "jpeg") {
header('Content-Type: image/jpeg');
imagejpeg($image);
} elseif($ext == "png") {
header('Content-Type: image/png');
imagepng($image);
}
imageDestroy($image);
} else {
nopic();
}
} else {
nopic();
}
} else {
nopic();
}
} else {
nopic();
}
function nopic() {
$url = 'http://myrand.net/nopic.gif';
$image = imagecreatefromgif ($url);
$back_color = imageColorAllocate($image, 255, 255, 255);
$draw_color = imagecolorallocate($image, 255, 255, 255);
imagerectangle($image, 0, 0, imagesx($image) - 0,
imagesy($image) - 0, $draw_color);
header('Content-Type: image/gif');
imagegif($image);
imageDestroy($image);
}
?>
הקובץ FUNC:
PHP קוד:
<?php
function url_exists($url) {
$a_url = parse_url($url);
if (!isset($a_url['port'])) $a_url['port'] = 80;
$errno = 0;
$errstr = '';
$timeout = 30;
if(isset($a_url['host']) && $a_url['host']!=gethostbyname($a_url['host'])) {
$fid = fsockopen($a_url['host'], $a_url['port'], $errno, $errstr, $timeout);
if (!$fid) return false;
$page = isset($a_url['path']) ?$a_url['path']:'';
$page .= isset($a_url['query'])?'?'.$a_url['query']:'';
fputs($fid, 'HEAD '.$page.' HTTP/1.0'."\r\n".'Host: '.$a_url['host']."\r\n\r\n");
$head = fread($fid, 4096);
fclose($fid);
return preg_match('#^HTTP/.*\s+[200|302]+\s#i', $head);
} else {
return false;
}
}
?>