0

PHP4で記述された古い画像キャプチャジェネレーターがあり、PHP5に変換する必要があります。動作を開始するために何を変更する必要があるかについての提案はありますか?私が得ている主なエラーは、「リソースは画像として解釈されますが、MIMEタイプtext / htmlで転送されました」と表示されます。これは、header('Content-type:image / jpeg');

<?php
extract($HTTP_GET_VARS);
extract($HTTP_POST_VARS);

session_start(); 

$alphanum  = "ABGKLMNPRSTUXZ"; 
$rand = substr(str_shuffle($alphanum), 0, 5); 
$image = imagecreatetruecolor(65,25);
$background = imagecolorallocate($image, 255, 255, 255);
$border = imagecolorallocate($image, 128, 128, 128);
$colors[] = imagecolorallocate($image, 128, 64, 192);
$colors[] = imagecolorallocate($image, 192, 64, 128);
$colors[] = imagecolorallocate($image, 108, 192, 64);

imagefilledrectangle($image, 1, 1, 65 - 2, 25 - 2, $background);
imagerectangle($image, 0, 0, 65 - 1, 25 - 1, $border);

for ($i = 0; $i < 5; $i++){
    $x1 = rand(0, 65 - 5);
    $y1 = rand(0, 25 - 5);
    $x2 = $x1 - 4 + rand(2, 8);
    $y2 = $y1 - 4 + rand(2, 8);
    imageline($image, $x1, $y1, $x2, $y2,$colors[rand(0, count($colors) - 1)]);
}

$textColor = imagecolorallocate ($image, 30, 30, 30); 

imagestring ($image, 8, rand(8,10), rand(1,8),  $rand, $textColor); 

$_SESSION['image_random_value'] = md5($rand); 

header("Expires: Mon, 26 Jul 1998 06:00:00 GMT");  
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");  
header("Cache-Control: no-store, no-cache, must-revalidate");  
header("Cache-Control: post-check=0, pre-check=0", false);  
header("Pragma: no-cache");
header('Content-type: image/jpeg');

imagejpeg($image); 
imagedestroy($image); 
?>

この画像は、役に立ったらここのページに読み込まれます。



    
    function textCounter(field, countfield, maxlimit) {
    if (field.value.length > maxlimit)
    field.value = field.value.substring(0, maxlimit);
    else
    countfield.value = maxlimit - field.value.length;
    }
    function form_visible(){
    var el = document.getElementById('sf');
    if(el.style.display == 'inline'){
    el.style.display = 'none';
    }else{
    el.style.display = 'inline';
    }
    }
    var shows = 0;
    var lc;
    var i;
    var image;
    var ny;
    function show(star_img,rnid) 
    {
    if (shows){
    if(rnid==lc){
    return;
    }
    }

    for (i=1; i");
    for (var i=1; i");
    }
    document.write("Please Select");
    }
    
     $value) {
    ${$key} = $value;
    } 
    foreach($_POST AS $key => $value) {
    ${$key} = $value;
    } 

    $db=mysql_connect($db_host,$database_user,$database_pass) or die("MySQL Error: Unable to connect to database please check that you have provided the correct 
  • Database Login username
  • Database Login Password"); mysql_select_db($db_name,$db)or die("MySQL Error: Unable to select database please check that you have provided the correct
  • Database name"); echo "


    "; $day =date("D d"); $month =date("M"); $year =date("Y"); $dt="$year-$month-$day"; $ent=mysql_query("SELECT * FROM ez_ccomment_opt"); $rowi=@mysql_fetch_array($ent); if($do=="do_sign" && $id=="$mid"){ if ($comment !="" && $email !="" && $name !="" && $rating!=""){ if(md5($_POST['security']) == $_SESSION['image_random_value']){ $comment = str_replace ("",">", $comment); $name = str_replace ("",">", $name); $email = str_replace ("",">", $email); $website = str_replace ("", $comment); $comment = str_replace ("

    ", "
    ", $comment); $name = stripslashes ($name); $comment = stripslashes ($comment); $lis="0"; if($rowi[filter]=="y"){ $user=file("badwords.txt"); for($x=0;$xPlease enter valid security image."; } }else{ $w="1"; echo "Please fill in the required fields.";} } ob_start(); echo ""; echo "Rating*"; ?> showform(1); "; echo "Comments* Name* Email* (Will not be shown) Security Image*make sure to type security image in ALL CAPITAL characters!
    * = Required


    "; echo ""; ob_end_flush(); if($w=="1"){ ?> var el = document.getElementById('sf'); el.style.display = 'inline'; "; $list = ("SELECT * FROM ez_ccomment WHERE status='confirmed' AND ccid='$id' ORDER BY op DESC"); $row_num1= @mysql_num_rows(mysql_query($list)); $list_per_page=$rowi['limit_pp']; if($row_num1>0){ echo "Comments"; }else{ echo "No ratings yet. Be the first to add a rating!"; } if($start==""){ $start=1; } if($start==""||$start==1){ $sfrom=0; }else{ $sfrom=(($start-1)*$list_per_page); } $end=$list_per_page; $gr=0; $list.= (" LIMIT $sfrom,$end"); $blist=(mysql_query($list)); while($row=@mysql_fetch_array($blist)){ if(substr_count($row[email],"@")==1){ $name="$row[name]"; }else{ $name="$row[name]"; } $messag=$row[message]; $messag=wordwrap($messag, 55, "\n", 1); $row[rating]=round($row[rating],2); if ($row[rating] == 5) { $star = "images/5star.gif" ; $pk="5 - Excellent!"; } if ($row[rating]>=1 && $row[rating]=2 && $row[rating]=3 && $row[rating]= 4 && $row[rating]= 5) { $star = "images/5star.gif" ; $pk="5 - Excellent!"; } if ($row[rating] $messag$row[name], $row[date]"; $gr+=1; } $list_per_page=$rowi['limit_pp']; echo ""; if($start==""){ $start=1; } if($start==""||$start==1){ $sfrom=0; }else{ $sfrom=(($start-1)*$list_per_page); } $end=$list_per_page; if ($row_num1>$list_per_page){ $no_of_page=$row_num1/$list_per_page; $no_page=explode(".",$no_of_page); if($no_page[1]>0){ $no_of_page+=1; } echo ""; echo ""; if($start > 1){ $s=$start-1; echo "Previous"; } echo ""; $last=round($no_of_page,0); for($i=1;$i$i "; }else{ echo " $i "; } }else{ if($i>$start+3){ if($once==""){ echo " ....... $last"; } $once="yes"; }elseif($i0){ echo "1 ....... "; } $tonce="yes"; }else{ if($i!=$start){ echo " $i "; }else{ echo " $i "; } } } } echo ""; if($start Next"; }elseif($start>=$i){ $next = ""; } echo "$next"; } echo ""; ?>
  • 4

    1 に答える 1

    1

    そのコードでは、$_GETの場合は$HTTP_GET_VARSを、$_POSTの場合は$HTTP_POST_VARSを変更するだけです。

    extract($_GET);
    extract($_POST);
    

    私はそれを試しました、そしてそれは働きます。

    于 2012-10-05T19:19:36.957 に答える