Jump to content


Photo

php scripts not woking on IIS6


  • Please log in to reply
1 reply to this topic

#1 zhq

zhq
  • Members
  • PipPip
  • Member
  • 17 posts

Posted 15 December 2005 - 02:11 AM

Dear All,

The php scripts got errors when running on IIS 6.0 web server and windows server 2003. The error massages and the php codes are shown below. Please help me if you know the answer. Thanks a lot in advance.

zhqnus

####
error messages
***
Warning: file_get_contents(): php_network_getaddresses: gethostbyname failed in C:\Inetpub\wwwroot\vlsi\forward.php on line 21

Warning: file_get_contents(http://vlsi-test.ece.nus.edu.sg\/uploadfiles/CMOS_C35_noise_para_ENG-189_rev1.pdf): failed to open stream: No error in C:\Inetpub\wwwroot\vlsi\forward.php on line 21

Warning: Cannot modify header information - headers already sent by (output started at C:\Inetpub\wwwroot\vlsi\forward.php:21) in C:\Inetpub\wwwroot\vlsi\forward.php on line 62

Warning: Cannot modify header information - headers already sent by (output started at C:\Inetpub\wwwroot\vlsi\forward.php:21) in C:\Inetpub\wwwroot\vlsi\forward.php on line 63

Warning: Cannot modify header information - headers already sent by (output started at C:\Inetpub\wwwroot\vlsi\forward.php:21) in C:\Inetpub\wwwroot\vlsi\forward.php on line 64

Warning: fopen(): php_network_getaddresses: gethostbyname failed in C:\Inetpub\wwwroot\vlsi\forward.php on line 66

Warning: fopen(http://vlsi-test.ece.nus.edu.sg\/uploadfiles/CMOS_C35_noise_para_ENG-189_rev1.pdf): failed to open stream: No error in C:\Inetpub\wwwroot\vlsi\forward.php on line 66

Warning: fread(): supplied argument is not a valid stream resource in C:\Inetpub\wwwroot\vlsi\forward.php on line 29

Warning: fclose(): supplied argument is not a valid stream resource in C:\Inetpub\wwwroot\vlsi\forward.php on line 68
####


####
forward.php
***
<?php
include("download_header.php");
header("Cache-control: private");


$filedir = "http://" . $HTTP_SERVER_VARS['HTTP_HOST'];
if (dirname($HTTP_SERVER_VARS['PHP_SELF']) != "/")
$filedir = $filedir . dirname($HTTP_SERVER_VARS['PHP_SELF']) . "/";

$tempdir = $filedir . "temp/";
$filedir = $filedir . "uploadfiles/";


$redirect = "http://" . $HTTP_SERVER_VARS['HTTP_HOST'];
if (dirname($HTTP_SERVER_VARS['PHP_SELF']) != "/")
$redirect = $redirect . dirname($HTTP_SERVER_VARS['PHP_SELF']) . "/";
$redirect = $redirect . "download_main.php";

function RemoteFileSize($remote_file)
{
$file = file_get_contents($remote_file);

return strlen($file);
}

function Longfread($handle, $size){
$contents = "";
do {
$data = fread($handle, $size);
if (strlen($data) == 0) {
break;
}
$contents .= $data;
} while(true);
return $contents;
}



if (isset($_GET['page'])){
$page=$_GET['page'];

mysql_connect("localhost","root","") or die ("Unable to connect to MySQL server.");
$db = mysql_select_db("nus") or die ("Unable to select requested database.");
$sql = "SELECT f_name from file WHERE f_ID=\"$page\"";
$result = mysql_query($sql);

if($result){
if (mysql_num_rows($result) == 0){
echo "This file may not exist in database. Please enter your administrator name correctly.
<a href=$redirect>BACK</a>.<br>";
exit();
} else{
$row_array = mysql_fetch_row($result);
$filename = $row_array[0];
//$filename ="logout.pdf";
//$tempdir=$tempdir.$filename;
$filedir=$filedir.$filename;

$filesize=RemoteFileSize($filedir);

header("Content-Type: application/pdf");
header("Content-Length: ".$filesize);
header("Content-Disposition: inline; filename=$filename");

$fp = fopen($filedir, 'rb');
$pdf_buffer = Longfread($fp, 8192);
fclose ($fp);
print $pdf_buffer;
exit();

//header("Location: $filedir");
//exit();

}
}

}else{
header("Location: $redirect");
}
#####

zhqnus


#2 turbosport

turbosport
  • Members
  • Pip
  • Newbie
  • 9 posts

Posted 14 January 2006 - 02:22 AM

You didnt say if the script was working but displaying errors ?

If it works turn off WARNINGS

Ig it dosnt some thoughts:

is your allow_url_fopen set to true ?

[a href=\"http://vlsi-test.ece.nus.edu.sg\/uploadfiles/CMOS_C35_noise_para_ENG-189_rev1.pdf\" target=\"_blank\"]http://vlsi-test.ece.nus.edu.sg\/uplo...NG-189_rev1.pdf[/a]

theres a \/ after the domain part not sure how the call will treat this.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users