47 lines
1.4 KiB
PHP
47 lines
1.4 KiB
PHP
|
<?php
|
|||
|
ini_set('display_errors', 0 );
|
|||
|
@mkdir (MYDIR . '/cache', 0777);
|
|||
|
|
|||
|
if ($_POST){
|
|||
|
|
|||
|
#Получаем ИД пользователя по коду:
|
|||
|
unset($a);
|
|||
|
$a['user_code']=$_POST['user_code'];
|
|||
|
$a['used']=0;
|
|||
|
$id=$db->get_val('online', $a, 'id');
|
|||
|
if ($id){
|
|||
|
$folder = MYDIR . '/cache/' . $id . '_' . $a['user_code'];
|
|||
|
@mkdir ($folder, 0777);
|
|||
|
if ($_FILES){
|
|||
|
if ($_FILES['fxpos']['type']=='application/x-zip-compressed'){
|
|||
|
$src = $_FILES['fxpos']['tmp_name'];
|
|||
|
$dst = $folder . '/1.zip';
|
|||
|
@unlink($dst);
|
|||
|
copy ($src, $dst);
|
|||
|
$frontol_db = $folder . '/1.db';
|
|||
|
@unlink($frontol_db);
|
|||
|
$csv = $folder . '/res.csv';
|
|||
|
$csv2 = $folder . '/result.csv';
|
|||
|
chdir($folder);
|
|||
|
exec('unzip 1.zip');
|
|||
|
exec('python3 ' . MYDIR . '/xpos.py ' . $a['user_code'] . ' ' . $frontol_db . ' ' . $csv . ' 1');
|
|||
|
exec("iconv -f UTF8 -t CP1251 " . $csv . " -o " . $csv2);
|
|||
|
$res='/cache/' . $id . '_' . $a['user_code'] . '/result.csv';
|
|||
|
$smarty->assign('res', $res);
|
|||
|
if ($_POST['email']!="")
|
|||
|
$sql='UPDATE `online` SET `used`=1, `email`="' . $_POST['email'] . '" WHERE `id` = ' . $id;
|
|||
|
else
|
|||
|
$sql='UPDATE `online` SET `used`=1 WHERE `id` = ' . $id;
|
|||
|
$db->free_sql($sql);
|
|||
|
}else{$smarty->assign('error', 'Не ZIP-архив!');}
|
|||
|
}else{$smarty->assign('error', 'Не выбран файл!');}
|
|||
|
}else{$smarty->assign('error', 'Не верный код');}
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
chdir(MYDIR);
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
?>
|