Правка
This commit is contained in:
@ -1161,26 +1161,7 @@ if ($code!=$_POST['code']) return new AuthError('invalid code');
|
|||||||
if ($fn==8)//Получить отчёт как Excel.xls файл (почти тоже самое что и функция 4)
|
if ($fn==8)//Получить отчёт как Excel.xls файл (почти тоже самое что и функция 4)
|
||||||
{
|
{
|
||||||
$dir='./temp/';
|
$dir='./temp/';
|
||||||
|
// отправка файла в отдельном файле download.php для совместимости с java версией
|
||||||
if(isset($_REQUEST['file'])) {
|
|
||||||
$file = $_REQUEST['file'];
|
|
||||||
$myFile = $dir.$file;
|
|
||||||
if(file_exists($myFile))
|
|
||||||
{
|
|
||||||
header("Content-type: application/octet-stream");
|
|
||||||
header('Content-Disposition: attachment; filename="'.$file.'"');
|
|
||||||
header('Content-Length: '.filesize($myFile));
|
|
||||||
readfile($myFile);
|
|
||||||
exit();
|
|
||||||
}else
|
|
||||||
{
|
|
||||||
header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found", true, 404);
|
|
||||||
echo 'File "'.$file.'" not found!';
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
session_write_close(); //Разблокируем сессионный файл так как запросы могут быть достаточно долгими
|
session_write_close(); //Разблокируем сессионный файл так как запросы могут быть достаточно долгими
|
||||||
|
|
||||||
//Выбираем информацию о текущем пользователе
|
//Выбираем информацию о текущем пользователе
|
||||||
@ -1190,7 +1171,7 @@ if ($code!=$_POST['code']) return new AuthError('invalid code');
|
|||||||
$stmt->bindValue(':user_id', $_SESSION['USER_ID'], PDO::PARAM_INT);
|
$stmt->bindValue(':user_id', $_SESSION['USER_ID'], PDO::PARAM_INT);
|
||||||
$res=$stmt->execute();
|
$res=$stmt->execute();
|
||||||
if($res && $stmt->rowCount()>0)
|
if($res && $stmt->rowCount()>0)
|
||||||
{ $result = $stmt->fetch(PDO::FETCH_NUM);
|
{ $result = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
$name='<i>'.$result['name'].'</i><br>';
|
$name='<i>'.$result['name'].'</i><br>';
|
||||||
}
|
}
|
||||||
$res=null; //Чтоб сработал сборщик мусора, а то вываливается ошибка: "Cannot execute queries while other unbuffered queries are active".
|
$res=null; //Чтоб сработал сборщик мусора, а то вываливается ошибка: "Cannot execute queries while other unbuffered queries are active".
|
||||||
@ -1305,7 +1286,8 @@ if ($code!=$_POST['code']) return new AuthError('invalid code');
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Сохраняем результсет в файл в виде HTML с расширением XLS
|
//Сохраняем результсет в файл в виде HTML с расширением XLS
|
||||||
$file='file_'.rand(0,1000).'.xls';
|
$num=rand(0,1000);
|
||||||
|
$file='file_'.$num.'.xls';
|
||||||
$myFile = $dir.$file;
|
$myFile = $dir.$file;
|
||||||
|
|
||||||
$fh = fopen($myFile, 'w');
|
$fh = fopen($myFile, 'w');
|
||||||
@ -1365,7 +1347,7 @@ if ($code!=$_POST['code']) return new AuthError('invalid code');
|
|||||||
fclose($fh);
|
fclose($fh);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($ext=="pdf")
|
/*if($ext=="pdf")
|
||||||
{
|
{
|
||||||
//Если в виде PDF
|
//Если в виде PDF
|
||||||
$mpdf = new mPDF('utf-8', 'A4', '8', '', 10, 10, 7, 7, 10, 10); // задаем формат, отступы и.т.д.
|
$mpdf = new mPDF('utf-8', 'A4', '8', '', 10, 10, 7, 7, 10, 10); // задаем формат, отступы и.т.д.
|
||||||
@ -1373,18 +1355,16 @@ if ($code!=$_POST['code']) return new AuthError('invalid code');
|
|||||||
$mpdf->WriteHTML(file_get_contents($myFile)); // формируем pdf
|
$mpdf->WriteHTML(file_get_contents($myFile)); // формируем pdf
|
||||||
|
|
||||||
$dir='./temp/';
|
$dir='./temp/';
|
||||||
$file='file_'.rand(0,1000).'_'.time().'.pdf';
|
$file='file_'.$num.'.pdf';
|
||||||
$myFile = $dir.$file;
|
$myFile = $dir.$file;
|
||||||
|
|
||||||
$mpdf->Output($myFile, 'F');
|
$mpdf->Output($myFile, 'F');
|
||||||
}
|
}*/
|
||||||
|
//$myFile=getFullPath().'temp/'.$file;
|
||||||
|
|
||||||
$myFile=getFullPath().'temp/'.$file;
|
|
||||||
|
|
||||||
//отправляем ссылку на файл
|
//отправляем ссылку на файл TODO переделать в JSON
|
||||||
header('Content-type: text/xml');
|
header('Content-type: text/xml');
|
||||||
echo '<?xml version="1.0" encoding="utf-8"?><metadata fn="8"><file><![CDATA['.$file.']]></file></metadata>';
|
echo '<?xml version="1.0" encoding="utf-8"?><metadata fn="8"><file><![CDATA['.$num.']]></file></metadata>';
|
||||||
|
|
||||||
//deleteTempFiles($dir);
|
//deleteTempFiles($dir);
|
||||||
}else
|
}else
|
||||||
|
|||||||
Reference in New Issue
Block a user