|
|
|
สอบถามปัญหา Warning: fgets() expects parameter 1 to be resource, string given |
|
|
|
|
|
|
|
Code (PHP)
<?
include "sessionuser.php";
include "functionavp32.php";
if($f!=""){
header("location:../pdf/$u/$y/$m/$f");
}
?>
<HTML>
<HEAD>
<TITLE> ถอดรหัส</TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874" />
</HEAD>
<BODY>
<?
include "../include/connect.php";
$a = $_SESSION["sess_id"];
$sql2 = "select * from user where user_id = $a ";
$result2 = mysqli_query($conn,$sql2);
$data2 = mysqli_fetch_array($result2);
$key = $data2[user_key];
if ($_POST[key] != $key ){
//echo "<center>คุณกรอกรหัสเปิดไฟล์ลับไม่ถูกต้อง <br> กรุณากรอกรหัสผ่านใหม่ครับ<br><br> ";
//echo "<input type='button' value=' ปิด ' onClick='window.close()'> </center>";
exit;
}
?>
</BODY>
</HTML>
<?
//if($_FILES[file][name]!=""){
// copy($_FILES[file][tmp_name],"file/".$_FILES[file][name]);
$sql3 = "select * from send where send_id = '$_GET[user_send_id]'";
$result3 = mysqli_query($conn, $sql3);
$data3 = mysqli_fetch_array($result3);
$user_s = $data3[user_id];
$date_f = $data3[send_date];
$user_key = $data3[send_key];
$key = AVP32($user_key);
$aa=$_GET[name_book];
$year = substr( $date_f , -5,-1);
$month = substr( $date_f , 4,-6);
//$fd = substr($date_f , 4);
$fp=fopen("../pdf/$user_s/$year/$month/$aa","r+");
$i=1;
while($ln=fgets($fp)){
if(preg_match("/filename=/",$ln)){
list($a,$filename)=explode("=",$ln);
$line=$i;
break;
}
$i++;
}
$str=fopen("../pdf/$user_s/$year/$month/$aa","r+");
$i=1;
while($ln=fgets($str)){
if($i>$line){
$x=explode(" ",$ln);
for($j=0;$j<count($x)-1;$j++){
$num = $x[$j]/$key;
$num = $num ^ 100;
$num = chr($num);
$str .= $num;
}
}
//echo "$str<br>";
$i++;
}
//fclose($fp);
// begin set extent file
if(preg_match("/.png/",$filename))
$filename="ex.png";
if(preg_match("/.doc/",$filename))
$filename="ex.doc";
if(preg_match("/.jpg/",$filename))
$filename="ex.jpg";
if(preg_match("/.avi/",$filename))
$filename="ex.avi";
if(preg_match("/.ppt/",$filename))
$filename="ex.ppt";
if(preg_match("/.xls/",$filename))
$filename="ex.xls";
if(preg_match("/.mp3/",$filename))
$filename="ex.mp3";
if(preg_match("/.bmp/",$filename))
$filename="ex.bmp";
if(preg_match("/.php/",$filename))
$filename="ex.php";
if(preg_match("/.html/",$filename))
$filename="ex.html";
if(preg_match("/.pdf/",$filename))
$filename="ex.pdf";
if(preg_match("/.gif/",$filename))
$filename="ex.gif";
// end set exten file
$fp2=fopen("../pdf/$user_s/$year/$month/".$filename,"w+");
fwrite($fp2,$str);
echo "$fp2<br>";
echo "filename=$filename<br>";
//echo "<script>location='decode.php?f=$filename&u=$user_s&y=$year&m=$month';</script>";
//fclose($fp2);
//unlink($filename);
//}
?>
Tag : PHP, MySQL, HTML/CSS, JavaScript, Ajax, jQuery
|
|
|
|
|
|
Date :
2016-05-20 10:33:48 |
By :
settachai |
View :
989 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|