Файл: modules/padmin/add_link.php
Строк: 145
<?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
*/
if($user['level'] < 6 || !isset($user)) { header('Location: /'); exit;}
$locate = 'in_padmin';
if(isset($_GET['act']) && $_GET['act'] == 'add') {
$link_url = input($_POST['link_url']);
$link_name = input($_POST['link_name']);
$link_image = input($_POST['link_image']);
$link_type = abs(intval($_POST['link_type']));
if(isset($_POST['link_redirect'])) {
$link_redirect = 1;
}
else
{
$link_redirect = 2;
}
if($link_type == 1 && !empty($link_url) && !empty($link_name)) {
$db->query("INSERT INTO `ads` SET `link` = '$link_url', `name` = '$link_name', `type` = '1', `redirect` = '$link_redirect'");
header('location: /padmin/ads/?type=header');
// print_r($db->errorInfo());
} elseif($link_type == 2 && !empty($link_url) && !empty($link_name)) {
$db->query("INSERT INTO `ads` SET `link` = '$link_url', `name` = '$link_name', `type` = '2', `redirect` = '$link_redirect'");
header('location: /padmin/ads/?type=footer');
// print_r($db->errorInfo());
} elseif($link_type == 3 && !empty($link_url) && !empty($link_name) && !empty($link_image)) {
$db->query("INSERT INTO `ads` SET `link` = '$link_url', `name` = '$link_name', `image` = '$link_image', `type` = '3', `redirect` = '$link_redirect'");
header('location: /padmin/ads/?type=banner');
// print_r($db->errorInfo());
} else {
header('location: /padmin/add_link?act=error');
}
exit;
}
$title = _t('add_link');
include_header($title);
$tpl->div('title', _t('add_link'));
if(isset($_GET['act']) && $_GET['act'] == 'error') {
$tpl->div('error', 'Unsupported input data');
}
echo '<div class="menu">
<form action="/padmin/add_link?act=add" method="post">
'. _t('link_url') .':<br/>
<input type="text" name="link_url" value="http://" /><br/>
'. _t('link_name') .':<br/>
<input type="text" name="link_name" /><br/>
'. _t('link_image') .':<br/>
<input type="text" name="link_image" /><br/>
'. _t('link_type') .':<br/>
<select name="link_type">
<option value="1">'. _t('header_link') .'</option>
<option value="2">'. _t('footer_link') .'</option>
<option value="3">'. _t('banner_link') .'</option>
</select><br/>
'. _t('link_redirect') .': <input type="checkbox" name="link_redirect" /><br/>
<input type="submit" value="'. _t('add_link') .'" />
</form>
</div>';
$tpl->div('block', img('ads.png') .'<a href="/padmin/ads/">'. _t('padmin_ads') .'</a><br/>'. img('admin.png') .'<a href="/padmin/">'. _t('padmin') .'</a><br/>'. HICO .'<a href="/">'. _t('home') .'</a>');
include_footer();
?>