zhq
Members-
Posts
17 -
Joined
-
Last visited
Never
Profile Information
-
Gender
Not Telling
zhq's Achievements
Member (2/5)
0
Reputation
-
Hi, forward.php and download_main.php are attached here. Thanks. zhq [attachment deleted by admin]
-
Hi, Thanks for your help. I have Adobe Reader 7.0.7 installed on my PC. I don't know how the file type is altered. Please kindly advise me what I should do next. Thansk a lot. zhq
-
Hi All, when I intend to open a .pdf file in a pop-up window, a blank pop-up window appears and also a 'File download - security warning' window comes out showing: 'unknow file type', save or cancel. I have the hearder - 'Content-Type: application/pdf' in my php code and it works previously. The web server is Xitami and OS is Windows XP. Any help is greatly appreciated. Thanks, zhq
-
Hi, I got the following error message. I don't know what cause this problem. Please help. Thanks a lot in advance. zhq *** Warning: file_get_contents(http://localhost/uploadfiles/Process.pdf) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request in c:\inetpub\wwwroot\vlsi\forward.php on line 18 Warning: fopen(http://zhenghq/uploadfiles/Process.pdf) [function.fopen]: failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request in c:\inetpub\wwwroot\forward.php on line 66 Warning: fread(): supplied argument is not a valid stream resource in c:\inetpub\wwwroot\forward.php on line 26 Warning: fclose(): supplied argument is not a valid stream resource in c:\inetpub\wwwroot\forward.php on line 68 *** the code is here: *** <?php include("download_header.php"); header("Cache-control: no-cache"); $filedir = "http://" . $HTTP_SERVER_VARS['HTTP_HOST'] . "/"; $tempdir = $filedir . "temp/"; $filedir = $filedir . "uploadfiles/"; $redirect = "http://" . $HTTP_SERVER_VARS['HTTP_HOST'] . "/"; $redirect = $redirect . "download_main.php"; function RemoteFileSize($remote_file) { echo "<pre>"; var_dump($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; echo"<pre>"; var_dump($filename); $filedir=$filedir.$filename; echo"<pre>"; var_dump($filedir); $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"); }
-
Hi All, I got the following error message. Can anyone tell me what the message means? Thanks a lot. zhq **** File 'c:\mysql\share\charsets\?.conf' not found (Errcode: 2) Character set '#33' is not a compiled character set and is not specified in the 'c:\mysql\share\charsets\Index' file ****
-
Hi, I got a ' Parse error: parse error, unexpected T_ELSEIF in c:\inetpub\wwwroot\vlsi\forward.php on line 8' message after I changed the first few lines in order to ensure that dirname($HTTP_SERVER_VARS['PHP_SELF']) is not equal to "/" and "\". ***<?php include("download_header.php"); header("Cache-control: no-cache"); $fd = "http://" . $HTTP_SERVER_VARS['HTTP_HOST']; if (dirname($HTTP_SERVER_VARS['PHP_SELF']) == "/") {elseif (dirname($HTTP_SERVER_VARS['PHP_SELF']) != "\") {$filedir = $fd . dirname($HTTP_SERVER_VARS['PHP_SELF']) . "/" ;} else { $sub_filedir = dirname($HTTP_SERVER_VARS['PHP_SELF']); $sub_filedir = str_replace('\','', $sub_filedir); $filedir = $fd . $sub_filedir . "/"; } } $tempdir = $filedir . "temp/"; $filedir = $filedir . "uploadfiles/"; $redirect = $filedir . "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"); }
-
HI, What does message - unexpected T_CONSTANT_ENCAPSED_STRING means? thanks zhq
-
Hi, I found that it is because of **dirname($HTTP_SERVER_VARS['PHP_SELF']) ** which returns a '/' or '\' in new php version. Can any code replace the slash with an empty string. regards zhq
-
In IE address field, something like http://localhost//faqdisplay.php?page=59&type=2. The script is working fine under Xitami Web server. The faqdisplay.php script is below. ***** <?php include("formheader.inc"); ?> <td valign="top" height="100%" width="986" style="border-right:none; border-right-width:medium; border-top-style:none; border-top-width:medium; border-bottom-style:none; border-bottom-width:medium; border-left:solid medium #FF6600" bgcolor="#FFFFFF" width="791"><!--mstheme--><font face="Arial, Arial, Helvetica"> <?php $filedir = "http://" . $HTTP_SERVER_VARS['HTTP_HOST']; if (dirname($HTTP_SERVER_VARS['PHP_SELF']) != "/") $filedir = $filedir . dirname($HTTP_SERVER_VARS['PHP_SELF']) . "/"; $filedir = $filedir . "faq/"; if (isset($_GET['type']) && isset($_GET['page'])){ $type=$_GET['type']; $page=$_GET['page']; if($type==1) echo " <font size=\"4\">FAQ: Unix Workstation Related</font><br><br>"; else if($type==2) echo " <font size=\"4\">FAQ: EDA tools</font><br><br>"; else if($type==3) echo " <font size=\"4\">FAQ: Design Kits</font><br><br>"; else if($type==4) echo " <font size=\"4\">FAQ: Others</font><br><br>"; 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 * from faq WHERE faq_no=\"$page\""; $result = mysql_query($sql); if ($result) { if (mysql_num_rows($result) == 0) { echo "No FAQ available.<br>"; exit(); } else { $count = mysql_num_rows($result); while ($count > 0) { $index = 1; $row_array = mysql_fetch_row($result); //$row_array[2]= strip_tags($row_array[2]); //$row_array[2] = StripSlashes($row_array[2]); $row_array[2] = ereg_replace("\n","<br>  ", $row_array[2]); $row_array[1] = ereg_replace("\n","<br>  ", $row_array[1]); echo "<font color=brown><b>Question:</b></font> (ID: ".$row_array[0].")<font color=blue>  ".$row_array[1] ."</font><br><br>"; print "<font color=brown>Answer:</font><br><font color=blue>  ".$row_array[2] . "</font><br><br>"; if ($row_array[3] != "No file attached"){ echo "File ".$index.": <br><font color=blue>  ". $row_array[6]. " </font><a href=$filedir".$row_array[3]. ">(View it)</a><br><br>"; $index++; } if ($row_array[4] != "No file attached"){ echo "File ".$index.": <br><font color=blue>  ". $row_array[7]. " </font><a href=$filedir".$row_array[4]. ">(View it)</a><br><br>"; $index++; } if ($row_array[5] != "No file attached"){ echo "File ".$index.": <br><font color=blue>  ". $row_array[8]. " </font><a href=$filedir".$row_array[5]. ">(View it)</a><br><br>"; } echo "<hr>"; $count = $count - 1; } } } } ?> <!--mstheme--></font></td> </tr> <?php include("formfooter.inc"); ?> **** regards zhq
-
Hi all, I am using iis 6.0, php 4.4.1 and mysql 4.1.18. I have the problem - the url becomes like http://localhost//... once the page is connected to mysql database. Can anyone tell what the reason could be? Any help will be much appreciated. zhq
-
Hi, I am using Windows XP and derver IIS V5.1. It is working on same OS but server Xitami. regards zhq
-
Hi, I got the following warning when running php code. Warning: session_start(): open(C:\PHP\sessiondata\sess_ea64eb1750d43a0f2c91c74343fd7b25, O_RDWR) failed: Permission denied (13) in c:\inetpub\wwwroot\vlsi\download_action.php on line 95 Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at c:\inetpub\wwwroot\vlsi\download_action.php:95) in c:\inetpub\wwwroot\vlsi\download_action.php on line 95 Warning: Cannot modify header information - headers already sent by (output started at c:\inetpub\wwwroot\vlsi\download_action.php:95) in c:\inetpub\wwwroot\vlsi\download_action.php on line 103 Warning: Unknown(): open(C:\PHP\sessiondata\sess_ea64eb1750d43a0f2c91c74343fd7b25, O_RDWR) failed: Permission denied (13) in Unknown on line 0 Warning: Unknown(): Failed to write session data (files). Please verify that the current setting of session.save_path is correct (C:\PHP\sessiondata) in Unknown on line 0 Any help is much appreciated. zhq
-
Hi, With 'cache-control:no-cache', the downloading is disabled for users using IE but it doesn't work for users using netscape. A ftp pop-up window comes out once user clicking on a file for opening. Is there any way to disable netscape to download the file with using PHP script? Any help is much appreciated. zhq
-
Dear All, My website is using MySql database and php. I intend to block users from downloading and saving pdf file while viewing it online. From the php forum, I know that saving file could be disabled if javascript is used to construct the page. Anyone has such javascript? Any help is much appreciated. zhq
-
block downloading files to local temp directory while viewing files online
zhq replied to zhq's topic in PHP Coding Help
Dear All, Sorry I am not quite clear about this becasue I am new to all the topic. Using "header('Cache-Control: no-cache')", the downloading to the temp directory can be blockbed. For blocking user to use the 'save as' function to save a PDF file, the java script has to be used. Am I right? Instead of using Java script, can PHP script work for this? I need a clear drection so that I know how to start my work. Thanks. zhq