Hi Thomas,
this is download.php , as for information this download.php is called by main.php by using function header('Location: http://www.xxx.com/download.php')
this is the code for download.php
<?php
session_start();
//redirect to home page for unAuthorized Access
if (($HTTP_SESSION_VARS["UserID"] == '') && ($HTTP_SESSION_VARS["Password"] == '')) {
header('Location: http://www.xxx.com/');
echo "You are not an Authorized user";
exit;
} else {
$Var1 = $HTTP_SESSION_VARS["UserID"];
$Var2 = $HTTP_SESSION_VARS["Password"];
//session_unset();
//session_destroy();
$ImageFileName = generateUserID_VerImage($Var1, $Var2);
$HTTP_SESSION_VARS["ImageFileName"] = $ImageFileName;
//initialize Session Variable instead of using session_unset() and session_destroy() which is
//currently still having problem
$HTTP_SESSION_VARS["UserID"] = '';
$HTTP_SESSION_VARS["Password"] = '';
}
//session_unset();
//session_destroy();
function generateUserID_VerImage($UserID, $Password){
session_start();
$font = 5;
$imagex = 250;
$imagey = 150;
$im = @imagecreatetruecolor($imagex, $imagey) or die("cannot initialize new GD image stream");
$text_color = imagecolorallocate($im, 115, 0, 95);
$tile_color = imagecolorallocate($im, 102, 102, 102);
$back_color = imagecolorallocate($im, 127, 145, 84);
$cir_color1 = imagecolorallocate($im, 163, 163, 163);
$cir_color2 = imagecolorallocate($im, 102, 102, 102);
$cir_color3 = imagecolorallocate($im, 61, 61, 61);
$fontwidth = imagefontwidth($font);
$fontwidth += 3; //add some spacing between
//below give us our new background color
imagefilledrectangle($im, 0, 0, $imagex-1, $imagey-1, $back_color);
//below loops draw the tiles
for($i = -1; $i < $imagex; $i += 8) //-1 so first line isnt always on top row
imageline($im, $i, 0, $i, $imagey, $tile_color);
for($j = -1; $j < $imagey; $j += 8) //-1 so first line isnt always on left column pixel
imageline($im, 0, $j, $imagex, $j, $tile_color);
srand((double) microtime() * 1000000); //i said random baby !
//below is circle algorithm, if you want different shapes/filled in, change below
//below is the loop to make number of circle created
for($i = 0; $i < 6; $i++)
{
imageellipse($im, rand(10, $imagex - 1 - 10), rand(10, $imagey - 1 - 10), $imagex / 4, $imagex / 4, $cir_color1);
imageellipse($im, rand(10, $imagex - 1 - 10), rand(10, $imagey - 1 - 10), $imagex / 4, $imagex / 4, $cir_color2);
imageellipse($im, rand(10, $imagex - 1 - 10), rand(10, $imagey - 1 - 10), $imagex / 4, $imagex / 4, $cir_color3);
//imagelinethick($im, rand(10, $imagex - 1 - 10), rand(10, $imagey - 1 - 10), rand(12, $imagex - 1 - 12), rand(10, $imagey - 1 - 10), $cir_color1);
}
//below is actual drawing text.
//imagestring($im, $font, 15 + $fontwidth * 0 + rand(0, 2), 15 + rand(-3, 3), $HTTP_SESSION_VARS["UserID"], $text_color);
for($i = 0; $i < 10; $i++)
{
$jmax = rand(0, 3);
for($j = 0; $j < $jmax; $j++)
rand();
//imagestring($im, $font, 15 + $fontwidth * $i + rand(0, 2), 15 + rand(-3, 3), chr(rand(65,90)), $text_color);
imagestring($im, $font, 45 + $fontwidth * $i + rand(0, 2), 45 + rand(-3, 3), $UserID[$i], $text_color);
imagestring($im, $font, 85 + $fontwidth * $i + rand(0, 2), 75 + rand(-3, 3), $Password[$i], $text_color);
}
//Create Unique File name , can use tempnam() function also
$str = uniqid('',FALSE);
while(strlen($str) < 19)
{
$str = rand(0,3) . $str;
}
$str = base_convert($str, 10, 36);
$str = str_pad($str, 12 ,'0' ,STR_PAD_LEFT);
$str = strtoupper($str);
$a1 = substr($str,4,8);
$xfile[0] = $a1;
$xfile[1] = "png";
$yfile = implode(".", $xfile);
$zfile[0] = "/home/xxx888/public_html/img";
$zfile[1] = $yfile;
$destfile = implode("/", $zfile);
$sourcefile = "/home/xxx888/public_html/img/template.png";
$sourcefileX = "template.png";
$destfileX = $yfile;
if (!copy($sourcefileX, $destfileX)) {
// echo "failed to copy $file...<br />\n";
}
$HTTP_SESSION_VARS["ImageFileName"] = $destfile;
//Generate Imagefile , this is the part which caused error in NETSCAPE
Header("Content-type: image/png", false);
Imagepng($im,$destfileX,80);
Imagedestroy($im);
return $destfileX;
}
?>
<html>
<head>
<title>Download page</title>
<meta http-equiv="content-type"
content="text/html; charset=ISO-8859-1">
</head>
<body>
Click <a href="/template.jpg">here</a> to download<br>
Click <a href="/download/cPanel%205%20User%20Guide%201.01.pdf">here</a> to download
picture
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<?php
echo $HTTP_SESSION_VARS["ImageFileName"];
print "<img src='".$ImageFileName."' alt='".$szAltText."'>";
unlink($ImageFileName);
// if ($PHPSESSID != '')
// {
// echo $PHPSESSID;
// }
// if ($ImgAS400 != '')
// {
// echo $Img;
// print "<img src='".$Img."' alt='".$szAltText."'>";
// }
?>
</body>
</html>
thanks a lot in advance. hope you could help me with this.