Файл: modules/downloads/attach_screen.php
Строк: 403
<?php
/**
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) 2013, Taras Chornyi, Sergiy Mazurenko, Ivan Kotliar
* @link http://perf-engine.net
* @package PerfEngine
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
$locate = 'in_downloads';
$file_id = abs(intval($_GET['id']));
if(!isset($_GET['id']) && $db->query("SELECT * FROM `downloads_files` WHERE `id` = '$file_id'")->rowCount() == 0 || !User::logged())
{
redirect('/downloads/');
}
if($db->query("SELECT user_id FROM `downloads_files` WHERE `id` = '$file_id'")->fetchColumn() != User::Id() && User::level() < 5)
{
redirect('/downloads/');
}
$filei = $db->query("SELECT * FROM `downloads_files` WHERE `id` = '". $file_id ."'")->fetch();
if(isset($_GET['act']) && $_GET['act'] == 'save')
{
import_lib('jimage.class');
if ($_FILES['screen_1']['tmp_name'])
{
if(file_exists(ROOT.'/files/downloads_screens/screen_1_'.$filei['server_name'].'.png')) unlink(ROOT.'/files/downloads_screens/screen_1_'.$filei['server_name'].'.png');
$file_info = pathinfo($_FILES['screen_1']['name']);
$file_info['extension'] = strtolower($file_info['extension']);
move_uploaded_file($_FILES['screen_1']['tmp_name'], ROOT.'/tmp/'.$file_info['filename'].'.'.$file_info['extension']);
$handle = new jimage();
$handle->thumb(ROOT.'/tmp/'.$file_info['filename'].'.'.$file_info['extension'], ROOT. '/files/downloads_screens/screen_1_'.$filei['server_name'].'.png', 128, 160);
unlink(ROOT.'/tmp/'.$file_info['filename'].'.'.$file_info['extension']);
}
if ($_FILES['screen_2']['tmp_name'])
{
if(file_exists(ROOT.'/files/downloads_screens/screen_2_'.$filei['server_name'].'.png')) unlink(ROOT.'/files/downloads_screens/screen_2_'.$filei['server_name'].'.png');
$file_info = pathinfo($_FILES['screen_2']['name']);
$file_info['extension'] = strtolower($file_info['extension']);
move_uploaded_file($_FILES['screen_2']['tmp_name'], ROOT.'/tmp/'.$file_info['filename'].'.'.$file_info['extension']);
$handle = new jimage();
$handle->thumb(ROOT.'/tmp/'.$file_info['filename'].'.'.$file_info['extension'], ROOT. '/files/downloads_screens/screen_2_'.$filei['server_name'].'.png', 128, 160);
unlink(ROOT.'/tmp/'.$file_info['filename'].'.'.$file_info['extension']);
}
if ($_FILES['screen_3']['tmp_name'])
{
if(file_exists(ROOT.'/files/downloads_screens/screen_3_'.$filei['server_name'].'.png')) unlink(ROOT.'/files/downloads_screens/screen_3_'.$filei['server_name'].'.png');
$file_info = pathinfo($_FILES['screen_3']['name']);
$file_info['extension'] = strtolower($file_info['extension']);
move_uploaded_file($_FILES['screen_3']['tmp_name'], ROOT.'/tmp/'.$file_info['filename'].'.'.$file_info['extension']);
$handle = new jimage();
$handle->thumb(ROOT.'/tmp/'.$file_info['filename'].'.'.$file_info['extension'], ROOT. '/files/downloads_screens/screen_3_'.$filei['server_name'].'.png', 128, 160);
unlink(ROOT.'/tmp/'.$file_info['filename'].'.'.$file_info['extension']);
}
if ($_FILES['screen_4']['tmp_name'])
{
if(file_exists(ROOT.'/files/downloads_screens/screen_4_'.$filei['server_name'].'.png')) unlink(ROOT.'/files/downloads_screens/screen_4_'.$filei['server_name'].'.png');
$file_info = pathinfo($_FILES['screen_4']['name']);
$file_info['extension'] = strtolower($file_info['extension']);
move_uploaded_file($_FILES['screen_4']['tmp_name'], ROOT.'/tmp/'.$file_info['filename'].'.'.$file_info['extension']);
$handle = new jimage();
$handle->thumb(ROOT.'/tmp/'.$file_info['filename'].'.'.$file_info['extension'], ROOT. '/files/downloads_screens/screen_4_'.$filei['server_name'].'.png', 128, 160);
unlink(ROOT.'/tmp/'.$file_info['filename'].'.'.$file_info['extension']);
}
if ($_FILES['screen_5']['tmp_name'])
{
if(file_exists(ROOT.'/files/downloads_screens/screen_5_'.$filei['server_name'].'.png')) unlink(ROOT.'/files/downloads_screens/screen_5_'.$filei['server_name'].'.png');
$file_info = pathinfo($_FILES['screen_5']['name']);
$file_info['extension'] = strtolower($file_info['extension']);
move_uploaded_file($_FILES['screen_5']['tmp_name'], ROOT.'/tmp/'.$file_info['filename'].'.'.$file_info['extension']);
$handle = new jimage();
$handle->thumb(ROOT.'/tmp/'.$file_info['filename'].'.'.$file_info['extension'], ROOT. '/files/downloads_screens/screen_5_'.$filei['server_name'].'.png', 128, 160);
unlink(ROOT.'/tmp/'.$file_info['filename'].'.'.$file_info['extension']);
}
}
if(isset($_GET['delete']) && $_GET['delete'] >= 1 && $_GET['delete'] <=5) {
unlink(ROOT.'/files/downloads_screens/screen_'.abs(intval($_GET['delete'])).'_'.$filei['server_name'].'.png');
header('location: /downloads/attach_screen/'.$file_id);
exit;
}
$title = _t('dl_attach_screenshot').' | '._t('downloads');
include_header($title);
$tpl->div('title', _t('dl_attach_screenshot'));
echo '<div class="post">
<form action="/downloads/attach_screen/'.$file_id.'?act=save" method="post" enctype="multipart/form-data">
'.(file_exists(ROOT.'/files/downloads_screens/screen_1_'.$filei['server_name'].'.png') ?
'<img src="/files/downloads_screens/screen_1_'.$filei['server_name'].'.png" weight="150" width="100" alt="Screen" /><br/>
<a href="/downloads/attach_screen/'.$file_id.'?delete=1">'._t('delete').'</a><br/>
' : NULL).'
'._t('dl_choose_screenshot').':<br/>
<input type="file" name="screen_1" /><br/>
'.(file_exists(ROOT.'/files/downloads_screens/screen_2_'.$filei['server_name'].'.png') ?
'<img src="/files/downloads_screens/screen_2_'.$filei['server_name'].'.png" weight="150" width="100" alt="Screen" /><br/>
<a href="/downloads/attach_screen/'.$file_id.'?delete=2">'._t('delete').'</a><br/>' : NULL).'
'._t('dl_choose_screenshot').':<br/>
<input type="file" name="screen_2" /><br/>
'.(file_exists(ROOT.'/files/downloads_screens/screen_3_'.$filei['server_name'].'.png') ?
'<img src="/files/downloads_screens/screen_3_'.$filei['server_name'].'.png" weight="150" width="100" alt="Screen" /><br/>
<a href="/downloads/attach_screen/'.$file_id.'?delete=3">'._t('delete').'</a><br/>' : NULL).'
'._t('dl_choose_screenshot').':<br/>
<input type="file" name="screen_3" /><br/>
'.(file_exists(ROOT.'/files/downloads_screens/screen_4_'.$filei['server_name'].'.png') ?
'<img src="/files/downloads_screens/screen_4_'.$filei['server_name'].'.png" weight="150" width="100" alt="Screen" /><br/>
<a href="/downloads/attach_screen/'.$file_id.'?delete=4">'._t('delete').'</a><br/>' : NULL).'
'._t('dl_choose_screenshot').':<br/>
<input type="file" name="screen_4" /><br/>
'.(file_exists(ROOT.'/files/downloads_screens/screen_5_'.$filei['server_name'].'.png') ?
'<img src="/files/downloads_screens/screen_5_'.$filei['server_name'].'.png" weight="150" width="100" alt="Screen" /><br/>
<a href="/downloads/attach_screen/'.$file_id.'?delete=5">'._t('delete').'</a><br/>' : NULL).'
'._t('dl_choose_screenshot').':<br/>
<input type="file" name="screen_5" /><br/>
<input type="submit" value="'. _t('save') .'" />
</form>
</div>';
$tpl->div('block', img('nav.png') . ' <a href="/downloads/file/'.$file_id.'">'. _t('back') .'</a><br/>'
. img('download.png') . ' <a href="/downloads/">'. _t('downloads') .'</a><br/>'
. HICO .' <a href="/">'. _t('home') .'</a>');
include_footer();
?>