Файл: modules/padmin/add_link.php
Строк: 134
<?php
/**********************************
* @package: PerfCMS *
* @year: 2012 *
* @author: Artas *
* @link: http://perfcms.ru *
**********************************/
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/ads/add?act=error');
}
exit;
}
$title = $lang->word('add_link');
require_once(SYS.'/view/header.php');
$tpl->div('title', $lang->word('add_link'));
if(isset($_GET['act']) && $_GET['act'] == 'error') {
$tpl->div('error', 'Unsupported input data');
}
echo '<div class="menu">
<form action="/padmin/ads/add?act=add" method="post">
'. $lang->word('link_url') .':<br/>
<input type="text" name="link_url" /><br/>
'. $lang->word('link_name') .':<br/>
<input type="text" name="link_name" /><br/>
'. $lang->word('link_image') .':<br/>
<input type="text" name="link_image" /><br/>
'. $lang->word('link_type') .':<br/>
<select name="link_type">
<option value="1">'. $lang->word('header_link') .'</option>
<option value="2">'. $lang->word('footer_link') .'</option>
<option value="3">'. $lang->word('banner_link') .'</option>
</select><br/>
'. $lang->word('link_redirect') .': <input type="checkbox" name="link_redirect" /><br/>
<input type="submit" value="'. $lang->word('add_link') .'" />
</form>
</div>';
$tpl->div('block', img('ads.png') .'<a href="/padmin/ads/">'. $lang->word('padmin_ads') .'</a><br/>'. img('admin.png') .'<a href="/padmin/">'. $lang->word('padmin') .'</a><br/>'. HICO .'<a href="/">'. $lang->word('home') .'</a>');
require_once(SYS.'/view/footer.php');
?>