| Server IP : 210.245.233.93 / Your IP : 216.73.216.226 Web Server : Apache/2.2.15 (CentOS) System : Linux webserver2.onesolution.com.hk 2.6.32-754.35.1.el6.x86_64 #1 SMP Sat Nov 7 12:42:14 UTC 2020 x86_64 User : apache ( 48) PHP Version : 5.3.3 Disable Function : exec, shell_exec, system, passthru, popen, proc_open, pcntl_exec MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/hkosl.com/m.musiccircle/webadmin/plupload/ |
Upload File : |
<?php
include '../config.php';
// Check if the user is logged in
if ((!isSet($_SESSION['loginname'])) || ($loggin <> '1')) {
header("Location: ../login.php");
exit;
}
//delete file
if($_POST["clean_temp"] == 1){
//delete temp file in plupload/uploads which over 1 week
//$time_ago = 1 * 24 * 60 * 60;
/*$files = glob('uploads/*');
foreach($files as $file) {
$file_modifiy_time = filemtime($file);
if($file_modifiy_time < (time() - $time_ago)){
unlink($file);
}
}*/
$sql = "select * from temp_file where deleted = ? and createdate <= ?";
$parameters = array("0", date("Y-m-d H:i:s", strtotime("-1 week")));
if (!($sth = $dbh->prepare($sql))) {
throw new Exception('[' . $sth->errorCode() . ']: ' . print_r($sth->errorInfo()));
exit;
}
if (!$sth->execute($parameters)) {
throw new Exception('[' . $sth->errorCode() . ']: ' . print_r($sth->errorInfo()));
exit;
}
while($file_info = $sth->fetch(PDO::FETCH_ASSOC)){
if (!unlink("uploads/".$file_info{"file_name"})){
} else {
$sql2 = "update temp_file set deleted = ? where file_id = ?";
$parameters2 = array("1", $file_info{"file_id"});
if (!($sth2 = $dbh->prepare($sql2))) {
throw new Exception('[' . $sth2->errorCode() . ']: ' . print_r($sth2->errorInfo()));
exit;
}
if (!$sth2->execute($parameters2)) {
throw new Exception('[' . $sth2->errorCode() . ']: ' . print_r($sth2->errorInfo()));
exit;
}
}
}
echo ("success");
}else{
$file_id = $_POST["file_id"];
$sql = "select * from temp_file where file_id = ?";
$parameters = array($file_id);
if (!($sth = $dbh->prepare($sql))) {
throw new Exception('[' . $sth->errorCode() . ']: ' . print_r($sth->errorInfo()));
exit;
}
if (!$sth->execute($parameters)) {
throw new Exception('[' . $sth->errorCode() . ']: ' . print_r($sth->errorInfo()));
exit;
}
$file_info = $sth->fetch(PDO::FETCH_ASSOC);
if (!unlink("uploads/".$file_info{"file_name"})){
echo ("fail");
} else {
echo ("success");
}
}
?>