Просмотр файла apanel/ads.php

Размер файла: 6.17Kb
<?php
/*\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\//
// Sitchi CMS - Mobile Content Management System //
// The author:  Nikoloz Sitchinava [sitchi]      //
// Link:        http://sitchicms.num.ge          //
// Skype:       SitchiCMS                        //
// License:     LICENSE.txt (see attached file)  //
// Version:     VERSION.txt (see attached file)  //
//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
define('_SITCHICMS', 1);
$root_path='../';
require $root_path.'includes/db_connect.php';
require $root_path.'includes/start.php';
require $root_path.'includes/header.php';
require $root_path.'includes/functions.php';
require $root_path.'includes/head.php'; // თავი
$lng_a = load_lng('admin');
if($user['level']<10)
header("Location: /");
if (!isset($_GET['act']))$_GET['act']='';
$act=htmlspecialchars(trim($_GET['act']));
switch ($act) 
{
/* რეკლამის ჩვენება */
default:
head(''.$lng['1_54'].' | '.$lng_a['1_29'].'');
echo'<div class="hdr"><b>'.$lng_a['1_29'].'</b></div>';
err();
echo'<div class="egmenu">' .
'<a href="ads.php?act=view_ads&amp;selection=1">'.$lng_a['1_30'].'</a><br/>' .
'<a href="ads.php?act=view_ads&amp;selection=2">'.$lng_a['1_31'].'</a><br/>' .
'</div>';
echo'<a href="/apanel/">'.$lng['1_54'].'</a>';
break;
/* რეკლამების სია */
case 'view_ads':
if (isset($_GET['selection']) && is_numeric($_GET['selection']) && strlen($_GET['selection'])>0 && strlen($_GET['selection'])<2)
{
$selection=intval(abs($_GET['selection']));
}else{
header("Location: index.php?".SID);
}
head(''.$lng['1_54'].' | '.$lng_a['1_33'].'');
echo'<div class="hdr"><b>'.$lng_a['1_29'].'</b></div>';
err();
$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `ads` WHERE `selection` = '$selection'"),0);
$k_page=k_page($k_post,$set['p_count']);
$page=page($k_page);
$start=$set['p_count']*$page-$set['p_count'];
$q=mysql_query("SELECT * FROM `ads` WHERE `selection` = '$selection' ORDER BY `lasttime` DESC LIMIT $start, $set[p_count]");
if($k_post==0)
{
echo'<div class="errmenu">';
echo''.$lng_a['1_32'].'.';
echo'</div>';
}
while ($post = mysql_fetch_assoc($q))
{
echo'<div class="menu">';
if ($post['img']==NULL)
{
echo $post['name'].'<br/>'; 
}else{
echo'<a href="'.$post['img'].'">['.$lng_a['1_39'].']</a><br/>';
}
if ($post['lasttime']>$time) 
{
echo'('.$lng_a['1_55'].' '.timef($post['lasttime']).')';
}else{
echo'('.$lng_a['1_41'].')';
}
echo'<a href="ads.php?act=delete_ads&amp;id_ads='.$post['id'].'">[X]</a><br/>';
echo''.$lng_a['1_37'].': '.$post['link'].'<br/>';
if ($post['img']!=NULL)
echo''.$lng_a['1_39'].': '.$post['img'].'<br/>';
echo'</div>';
}
if (isset($user) && $user['level']>=10){
echo'<a href="ads.php?act=create_ads&amp;selection='.$selection.'">'.$lng_a['1_34'].'</a>';}
echo'<br/><a href="ads.php">'.$lng_a['1_33'].'</a><br/>';
echo'<a href="/apanel/">'.$lng['1_54'].'</a><br/>';
break;
/***********************
** რეკლამის დამატება **
***********************/
case 'create_ads':
if (isset($_GET['selection']) && is_numeric($_GET['selection']) && strlen($_GET['selection'])>0 && strlen($_GET['selection'])<2)
{
$selection=intval(abs($_GET['selection']));
}else{
header("Location: index.php?".SID);
}
if (isset($_POST['name']) && isset($_POST['link']) && isset($_POST['img']) && isset($_POST['ch']) && isset($_POST['mn']))
{
$ch=intval($_POST['ch']);
$mn=intval($_POST['mn']);
$lasttime=$time+$ch*$mn*60*60*24;
$link=stripcslashes(htmlspecialchars($_POST['link']));
$link_color=stripcslashes(htmlspecialchars($_POST['color']));
$font_style=stripcslashes(htmlspecialchars($_POST['font_style']));
$font_weight=stripcslashes(htmlspecialchars($_POST['font_weight']));
$name=stripcslashes(htmlspecialchars($_POST['name']));
$img=stripcslashes(htmlspecialchars($_POST['img']));
mysql_query("INSERT INTO `ads` (`lasttime`, `name`, `img`, `link`, `selection`, `link_color`, `font_style`, `font_weight`) VALUES ('$lasttime', '$name', '$img', '$link', '$selection', '$link_color', '$font_style', '$font_weight')");
header("Location: ads.php?act=view_ads&selection=$selection&".SID);
}
head(''.$lng['1_54'].' | '.$lng_a['1_36'].''); 
echo'<div class="hdr"><b>'.$lng_a['1_29'].'</b></div>';
echo'<form action="ads.php?act=create_ads&amp;selection='.$selection.'" method="post"><div class="menu">' .
''.$lng_a['1_35'].'(max 32):<br/><input type="text" name="name" maxlength="32" value="" /><br/>' .
''.$lng_a['1_37'].'(http://'.$lng['1_9'].')(max 64):<br/><input type="text" name="link" value="" maxlength="64" /><br/>' .
''.$lng_a['1_38'].'(red | #ffffff)(max 12):<br/><input type="text" name="color" maxlength="12" value="" /><br/>' .
'Font-style*(italic | normal)(max 7):<br/><input type="text" name="font_style" maxlength="7" value="" /><br/>' .
'Font-weight**(100 | bolder)(max 7):<br/><input type="text" name="font_weight" maxlength="7" value="" /><br/>' .
''.$lng_a['1_39'].':(img http://'.$lng['1_9'].')(max 64)<br/><input type="text" name="img" maxlength="64" value="" /><br/>' .
''.$lng_a['1_40'].':<br/>' .
'<input type="text" name="ch" size="3" value="1" />' .
'<select name="mn">' .
'<option value="1">'.$lng['1_5'].'</option>' .
'<option value="7" selected="selected">'.$lng['1_6'].'</option>' .
'<option value="31">'.$lng['1_7'].'</option>' .
'</select><br/>' .
'<input value="'.$lng['1_8'].'" type="submit" />' .
'</div></form>';
echo'<a href="/apanel/">'.$lng['1_54'].'</a><br/>';
echo'<a href="ads.php">'.$lng_a['1_33'].'</a>';
break;
/*********************
** რეკლამის წაშლა **
*********************/
case 'delete_ads':
if (isset($_GET['id_ads']) && is_numeric($_GET['id_ads']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `ads` WHERE `id` = '".intval($_GET['id_ads'])."' LIMIT 1",$dblink), 0)==1)
{
$id_ads=intval(abs($_GET['id_ads']));
$ads = mysql_fetch_assoc(mysql_query("SELECT * FROM `ads` WHERE `id` = '".$id_ads."' LIMIT 1"));
}else{
header("Location: index.php?".SID);
}
if (isset($user) && $user['level']>=6)
{
mysql_query("DELETE FROM `ads` WHERE `id` = '$ads[id]'");
header("Location: ads.php?&".SID);
}
break;
}
require $root_path.'includes/end.php'; // დასასრული
?>