添加html标记后,PHP代码无法正常工作

时间:2016-01-19 11:25:27

标签: php html

所以我制作了用于签名的PHP代码,现在问题不在于,当我在代码的开头添加<html></html>标签时,它不会显示我所拥有的任何内容用PHP完成。因此,当我在PHP前面放置html标签或腾出空间时,页面中没有任何内容,但是当我删除它们时,一切正常。我不是PHP专家所以..

    <?php

    include_once("functions.php");

    $sign = !isset($_GET['s']) ? 1 : $_GET['s'];

    $uname = !isset($_GET["name"]) ? "None" : $_GET['name'];

    // Connection & Website Settings

    $ftpad = "";

    $ftpuser = "";

    $ftppass = "";

    $comm = "SAMP";

    $weburl = "www.incoming.com";

    $usersdir = "/scriptfiles/Users";

    //

    $ftpcon = ftp_connect($ftpad,4112) or die("Error|I can't connect to the database: $ftpad, contact web master");

    $login = ftp_login($ftpcon,$ftpuser,$ftppass);

    $uname = "";

        $name = $_GET['name'];

        ftp_pasv($ftpcon,true);

        $fhandle = fopen("tempsign_".hash('sha256',"$name").".tmp","w+");

        ftp_fget($ftpcon,$fhandle,"$usersdir/$name.ini",FTP_ASCII);

        $str = parse_ini_file2("tempsign_".hash('sha256',"$ime").".tmp");

        fclose($fhandle);

        $skin = $str['Skin'];

    $rImg = ImageCreateFromPNG("./signs/1.png");

if (file_exists("./signs/skins/$skin.jpg")) 

{

    $skinImg = ImageCreateFromjpeg("./signs/skins/$skin.jpg");

} 

else 

{

    $skinImg = ImageCreateFromjpeg("./signs/skins/0.jpg");

}  

    $cor_black = imagecolorallocate($rImg,0,0,0);

    $cor_blue = imagecolorallocate($rImg,0,0,255);

    $cor_lblue = imagecolorallocate($rImg,30,144,255);

    $cor_green = imagecolorallocate($rImg,69,139,116);

    $cor_red = imagecolorallocate($rImg,220,20,65);

    $cor_wh = imagecolorallocate($rImg,255,255,255);

        $cor_n = imagecolorallocate($rImg,246,74,14);

    if(ftp_size($ftpcon,"$usersdir/$name.ini") == -1 || $ime == "None")
    {
        ?>
        <tr>

    <center><td align="center" valign="top"><img src="logo.png" width="400" height="155" alt="logo" /></td></center>

  </tr>
  <style type="text/css">

body{

    background-color:#000;

    background-image:url(backg.png);

}
.

</style>
        <?php

     echo "<center><br/><br/><br/><br/><font color='#FF3333'>Error | That signature doesn't exist! Possible reasons:<br/><br/></font></center>";

echo "<center><font color='#0FB9FC'>1. You didn't enter your username in field for that<br/></font></center>";

echo "<center><font color='#0FB9FC'>2. You entered wrong username(Example Your_Name)<br/></font></center>";

echo "<center><font color='#0FB9FC'>3. Username that you entered isn't in our databse<br/></font></center>";

return 1;





    }

    else

    {

        ftp_pasv($ftpcon,true);

        $fhandle = fopen("tempsign_".hash('sha256',"$name").".tmp","w+");

        ftp_fget($ftpcon,$fhandle,"$usersdir/$name.ini",FTP_ASCII);

        $str = parse_ini_file2("tempsign_".hash('sha256',"$name").".tmp");

        fclose($fhandle);

        imagettftext($rImg,12,0,11,39,$cor_n,"font.TTF",urldecode($name));

        imagettftext($rImg,12,0,11,79,$cor_n,"font.TTF",urldecode($str['Level']));

                imagettftext($rImg,12,0,173,120,$cor_n,"font.TTF",urldecode($str['Points']));

                imagettftext($rImg,12,0,173,80,$cor_n,"font.TTF",urldecode($str['Hours']));

                imagecopymerge($rImg, $skinImg, 308,6,0,0,80,100,100);

    }



                          if($str['Sex'] == 0) { imagettftext($rImg,12,0,10,122,$cor_n,"font.TTF","Male"); }

                          else if($str['Sex'] == 1) { imagettftext($rImg,12,0,10,122,$cor_n,"font.TTF","Female"); }


              if($str['GM'] > 0)
              {
              imagettftext($rImg, 13,0,5,161,$cor_green,"font.TTF","GameSupport");}
              if($str['Admin'] > 0)
              {
              imagettftext($rImg, 13,0,5,161,$cor_red,"font.TTF","Admin");}

              if($str['Leader'] > 0)

                {

                  if($str['Leader'] == 1) { imagettftext($rImg,13,0,171,40,$cor_n,"font.TTF","LSPD"); }

                          else if($str['Leader'] == 2) { imagettftext($rImg,13,0,171,40,$cor_n,"font.TTF","FBI"); }

                          else if($str['Leader'] == 3) { imagettftext($rImg,13,0,171,40,$cor_n,"font.TTF","CNN"); }

                          else if($str['Leader'] == 4) { imagettftext($rImg,13,0,171,40,$cor_n,"font.TTF","La Cocaina"); }

                          else if($str['Leader'] == 5) { imagettftext($rImg,13,0,171,40,$cor_n,"font.TTF","La Cosa Nostra"); }

                          else if($str['Leader'] == 6) { imagettftext($rImg,13,0,171,40,$cor_n,"font.TTF","Terror Squad Crew"); }

                          else if($str['Leader'] == 7) { imagettftext($rImg,13,0,171,40,$cor_n,"font.TTF","GSF"); }

                          else if($str['Leader'] == 8) { imagettftext($rImg,13,0,171,40,$cor_n,"font.TTF","Yakuza"); }

                          else if($str['Leader'] == 9) { imagettftext($rImg,13,0,171,40,$cor_n,"font.TTF","Russian Mafia"); }

                          else if($str['Leader'] == 10) { imagettftext($rImg,13,0,171,40,$cor_n,"font.TTF","Underground Racers"); }

                          else if($str['Leader'] == 11) { imagettftext($rImg,13,0,171,40,$cor_n,"font.TTF","Hitman Agency"); }

                }

                else if($str['Member'] > 0)

                {

                  if($str['Member'] == 1) { imagettftext($rImg,13,0,171,40,$cor_wh,"font.TTF","LSPD"); }

                          else if($str['Member'] == 2) { imagettftext($rImg,13,0,171,40,$cor_n,"font.TTF","FBI"); }

                          else if($str['Member'] == 3) { imagettftext($rImg,13,0,171,40,$cor_n,"font.TTF","CNN"); }

                          else if($str['Member'] == 4) { imagettftext($rImg,13,0,171,40,$cor_n,"font.TTF","La Cocaine"); }

                          else if($str['Member'] == 5) { imagettftext($rImg,13,0,171,40,$cor_n,"font.TTF","La Cosa Nostra"); }

                          else if($str['Member'] == 6) { imagettftext($rImg,13,0,171,40,$cor_n,"font.TTF","Terror Squad Crew"); }

                          else if($str['Member'] == 7) { imagettftext($rImg,13,0,171,40,$cor_n,"font.TTF","GSF"); }

                          else if($str['Member'] == 8) { imagettftext($rImg,13,0,171,40,$cor_n,"font.TTF","Yakuza"); }

                          else if($str['Member'] == 9) { imagettftext($rImg,13,0,171,40,$cor_n,"font.TTF","Russian Mafia"); }

                          else if($str['Member'] == 10) { imagettftext($rImg,13,0,171,40,$cor_n,"font.TTF","Underground Racers"); }

                          else if($str['Member'] == 11) { imagettftext($rImg,13,0,171,40,$cor_n,"font.TTF","Hitman Agency"); }

                }

                else

                {

                  imagettftext($rImg,13,0,171,40,$cor_n,"font.TTF","Civil");

                }

    ftp_close($ftpcon);

    unset($str);

    unset($ftpad);

    unset($ftpuser);

    unset($ftppass);

    unset($ftpcon);

    unset($login);

    header('Content-type: image/png');

    imagepng($rImg);

        imagepng($skinImg);



?>
</style>

1 个答案:

答案 0 :(得分:0)

请检查以下代码:

<?php

//Error reporting section
ini_set('display_errors', 1); 
ini_set('display_startup_errors', 1); 
error_reporting(E_ALL);


include_once("functions.php");

$sign = !isset($_GET['s']) ? 1 : $_GET['s'];

$uname = !isset($_GET["name"]) ? "None" : $_GET['name'];

// Connection & Website Settings

$ftpad = "";

$ftpuser = "";

$ftppass = "";

$comm = "SAMP";

$weburl = "www.incoming.com";

$usersdir = "/scriptfiles/Users";

$ftpcon = ftp_connect($ftpad,4112) or die("Error|I can't connect to the database: $ftpad, contact web master");

$login = ftp_login($ftpcon,$ftpuser,$ftppass);

$uname = "";

$name = $_GET['name'];

ftp_pasv($ftpcon,true);

$fhandle = fopen("tempsign_".hash('sha256',"$name").".tmp","w+");

ftp_fget($ftpcon,$fhandle,"$usersdir/$name.ini",FTP_ASCII);

$str = parse_ini_file2("tempsign_".hash('sha256',"$ime").".tmp");

fclose($fhandle);

$skin = $str['Skin'];

$rImg = ImageCreateFromPNG("./signs/1.png");

if (file_exists("./signs/skins/$skin.jpg")) 
{
    $skinImg = ImageCreateFromjpeg("./signs/skins/$skin.jpg");
} 
else 

{
    $skinImg = ImageCreateFromjpeg("./signs/skins/0.jpg");
}  

$cor_black = imagecolorallocate($rImg,0,0,0);

$cor_blue = imagecolorallocate($rImg,0,0,255);

$cor_lblue = imagecolorallocate($rImg,30,144,255);

$cor_green = imagecolorallocate($rImg,69,139,116);

$cor_red = imagecolorallocate($rImg,220,20,65);

$cor_wh = imagecolorallocate($rImg,255,255,255);

$cor_n = imagecolorallocate($rImg,246,74,14);

if(ftp_size($ftpcon,"$usersdir/$name.ini") == -1 || $ime == "None")
{
  ?><tr>
        <center><td align="center" valign="top"><img src="logo.png" width="400" height="155" alt="logo" /></td></center>
    </tr>
    <style type="text/css">

        body{

            background-color:#000;

            background-image:url(backg.png);

        }
    </style><?php

 echo "<center><br/><br/><br/><br/><font color='#FF3333'>Error | That signature doesn't exist! Possible reasons:<br/><br/></font></center>";

    echo "<center><font color='#0FB9FC'>1. You didn't enter your username in field for that<br/></font></center>";

    echo "<center><font color='#0FB9FC'>2. You entered wrong username(Example Your_Name)<br/></font></center>";

    echo "<center><font color='#0FB9FC'>3. Username that you entered isn't in our databse<br/></font></center>";

    return 1;

}
else
{

  ftp_pasv($ftpcon,true);

  $fhandle = fopen("tempsign_".hash('sha256',"$name").".tmp","w+");

  ftp_fget($ftpcon,$fhandle,"$usersdir/$name.ini",FTP_ASCII);

  $str = parse_ini_file2("tempsign_".hash('sha256',"$name").".tmp");

  fclose($fhandle);

  imagettftext($rImg,12,0,11,39,$cor_n,"font.TTF",urldecode($name));

  imagettftext($rImg,12,0,11,79,$cor_n,"font.TTF",urldecode($str['Level']));

  imagettftext($rImg,12,0,173,120,$cor_n,"font.TTF",urldecode($str['Points']));

  imagettftext($rImg,12,0,173,80,$cor_n,"font.TTF",urldecode($str['Hours']));

  imagecopymerge($rImg, $skinImg, 308,6,0,0,80,100,100);

}



if($str['Sex'] == 0) { imagettftext($rImg,12,0,10,122,$cor_n,"font.TTF","Male"); }
else if($str['Sex'] == 1) { imagettftext($rImg,12,0,10,122,$cor_n,"font.TTF","Female"); }


if($str['GM'] > 0){ imagettftext($rImg, 13,0,5,161,$cor_green,"font.TTF","GameSupport");}
if($str['Admin'] > 0){ imagettftext($rImg, 13,0,5,161,$cor_red,"font.TTF","Admin");}

if($str['Leader'] > 0){

  if($str['Leader'] == 1) { imagettftext($rImg,13,0,171,40,$cor_n,"font.TTF","LSPD"); }

  else if($str['Leader'] == 2) { imagettftext($rImg,13,0,171,40,$cor_n,"font.TTF","FBI"); }

  else if($str['Leader'] == 3) { imagettftext($rImg,13,0,171,40,$cor_n,"font.TTF","CNN"); }

  else if($str['Leader'] == 4) { imagettftext($rImg,13,0,171,40,$cor_n,"font.TTF","La Cocaina"); }

  else if($str['Leader'] == 5) { imagettftext($rImg,13,0,171,40,$cor_n,"font.TTF","La Cosa Nostra"); }

  else if($str['Leader'] == 6) { imagettftext($rImg,13,0,171,40,$cor_n,"font.TTF","Terror Squad Crew"); }

  else if($str['Leader'] == 7) { imagettftext($rImg,13,0,171,40,$cor_n,"font.TTF","GSF"); }

  else if($str['Leader'] == 8) { imagettftext($rImg,13,0,171,40,$cor_n,"font.TTF","Yakuza"); }

  else if($str['Leader'] == 9) { imagettftext($rImg,13,0,171,40,$cor_n,"font.TTF","Russian Mafia"); }

  else if($str['Leader'] == 10) { imagettftext($rImg,13,0,171,40,$cor_n,"font.TTF","Underground Racers"); }

  else if($str['Leader'] == 11) { imagettftext($rImg,13,0,171,40,$cor_n,"font.TTF","Hitman Agency"); }

}
else if($str['Member'] > 0)
{

  if($str['Member'] == 1) { imagettftext($rImg,13,0,171,40,$cor_wh,"font.TTF","LSPD"); }

  else if($str['Member'] == 2) { imagettftext($rImg,13,0,171,40,$cor_n,"font.TTF","FBI"); }

  else if($str['Member'] == 3) { imagettftext($rImg,13,0,171,40,$cor_n,"font.TTF","CNN"); }

  else if($str['Member'] == 4) { imagettftext($rImg,13,0,171,40,$cor_n,"font.TTF","La Cocaine"); }

  else if($str['Member'] == 5) { imagettftext($rImg,13,0,171,40,$cor_n,"font.TTF","La Cosa Nostra"); }

  else if($str['Member'] == 6) { imagettftext($rImg,13,0,171,40,$cor_n,"font.TTF","Terror Squad Crew"); }

  else if($str['Member'] == 7) { imagettftext($rImg,13,0,171,40,$cor_n,"font.TTF","GSF"); }

  else if($str['Member'] == 8) { imagettftext($rImg,13,0,171,40,$cor_n,"font.TTF","Yakuza"); }

  else if($str['Member'] == 9) { imagettftext($rImg,13,0,171,40,$cor_n,"font.TTF","Russian Mafia"); }

  else if($str['Member'] == 10) { imagettftext($rImg,13,0,171,40,$cor_n,"font.TTF","Underground Racers"); }

  else if($str['Member'] == 11) { imagettftext($rImg,13,0,171,40,$cor_n,"font.TTF","Hitman Agency"); }

}
else
{
  imagettftext($rImg,13,0,171,40,$cor_n,"font.TTF","Civil");
}

ftp_close($ftpcon);

unset($str);

unset($ftpad);

unset($ftpuser);

unset($ftppass);

unset($ftpcon);

unset($login);

header('Content-type: image/png');

imagepng($rImg);

imagepng($skinImg);
?>