View file 3020.ru/ajax/delfilekom.php

File size: 1.05Kb
<?php
// Зарещаем не ajax
$fasa = ((isset($_SERVER['HTTP_X_REQUESTED_WITH']) && !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest')) ? 1 : 0; 
if($fasa == 0): exit('Ошибка'); endif;
//
require('../flowap/system.php');
if(empty($user['id'])):
	$d = ['location' => '/','type' => 'error'];
	echo json_encode($d); exit;
endif;
switch ($act) {
	default:
		$ids = $functions->htmlred($_POST['ids']);
		$filer = DB::$dbs->queryFetch('SELECT id,idus,idd,name,time FROM forum_files WHERE id = ? LIMIT 1', [$ids]);
		if(empty($filer['id']) or $filer['idus'] != $user['id'] or $filer['time'] < (time() - 86400)):
			$d = ['location' => '/','type' => 'error'];
			echo json_encode($d); exit;
		endif;
		define('R', $_SERVER['DOCUMENT_ROOT']);
		$dir = R.'/files/kfiles/';
		unlink($dir.$filer['name']);
		DB::$dbs->querySql('DELETE FROM forum_files WHERE id = ? and idus = ?',[$ids,$user['id']]);
		$d = ['zamena' => '', 'type' => 'success'];
		echo json_encode($d); exit;
	break;
}
?>