Файл: KOSMOS/inc/smiles.php
Строк: 134
<?
if(isset($_GET['add']) && $ku['status']==3)
{
if(isset($_POST['submited']) && isset($_POST['name']) && isset($_FILES['file']))
{
$name=$_POST['name'];
$name=str_replace(' ','',$name);
$q=explode(',',$name);
$count=0;
$name=NULL;
foreach($q as $key => $value)
{
if($value!=NULL){$name=($name!=NULL?$name.",":null)."$value";$count++;}
}
$img=$_FILES['file']['name'];
$type=$_FILES['file']['type'];
if ($type!='image/jpeg' && $type!='image/jpg' && $type!='image/gif' && $type!='image/png')err_game('Это не картинка');
elseif($count==0)err_game("Введите хоть одно название.");
else
{
mysql_query("INSERT INTO `kolhoz_smiles` SET `name` = '$name', `img` = '$img'");
$tmp = $_FILES['file']['tmp_name'];
move_uploaded_file($tmp,
"images/smiles/$img");
chmod("images/smiles/$img",0777);
header("Location: ?smiles");
exit;
}
}
?>
<? if($ku['status']==3) ?>
<div class="event">
<h1><a href='?smiles'>Смайлы</a> / Добавить</h1>
</div>
<div class="content">
<ul class="block">
<?
if($ku['status']==3)
echo "<form method='post' enctype='multipart/form-data'>";
echo "Названия (через запитую):<br/>";
echo "<input type='text' name='name'><br/>";
echo "Изображение:<br/>";
echo "<input type='file' name='file'><br/>";
echo "<input type='submit' name='submited' value='Добавить'><br/>";
echo "</form></ul>";
include_once 'inc/foot.php';
}
elseif(isset($_GET['delete']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_smiles` WHERE `id` = '".intval($_GET['delete'])."'"),0)!=0 && $ku['status']==3)
{
mysql_query("DELETE FROM `kolhoz_smiles` WHERE `id` = '".intval($_GET['delete'])."'");
unlink("images/smiles/".mysql_result(mysql_query("SELECT `img` FROM `kolhoz_smiles` WHERE `id` = '".intval($_GET['delete'])."'"),0));
header("Location:?smiles&".passgen());
exit;
}
elseif(isset($_GET['edit']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_smiles` WHERE `id` = '".intval($_GET['edit'])."'"),0)!=0 && $ku['status']==3)
{
$smile=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_smiles` WHERE `id` = '".intval($_GET['edit'])."'"));
if(isset($_POST['submited']) && isset($_POST['name']))
{
$name=$_POST['name'];
$name=str_replace(' ','',$name);
$q=explode(',',$name);
$count=0;
$name=NULL;
foreach($q as $key => $value)
{
if($value!=NULL){$name=($name!=NULL?$name.",":null)."$value";$count++;}
}
if($count==0)err_game("Введите хоть одно название.");
else
{
mysql_query("UPDATE `kolhoz_smiles` SET `name` = '$name' WHERE `id` = '$smile[id]'");
header("Location: ?smiles");
exit;
}
}
?>
<div class="event">
<h1><a href='?smiles'>Смайлы</a> / Редактировать</h1>
</div>
<div class="content">
<ul class="block">
<?
echo "<form method='post'>";
echo "Названия (через запитую):<br/>";
echo "<input type='text' name='name' value='".hsc($smile['name'])."'><br/>";
echo "<input type='submit' name='submited' value='Сохранить'><br/>";
echo "</form></ul>";
include_once 'inc/foot.php';
}
?>
<div class="event">
<h1>Смайлы</h1>
</div>
<div class="content">
<ul class="block">
<?
$q=mysql_query("SELECT * FROM `kolhoz_smiles` ORDER BY `id` ASC");
while($post=mysql_fetch_array($q))
{
$n=explode(',',$post['name']);
$nn=NULL;
foreach($n as $key => $value)
{
$nn=($nn!=NULL?$nn." или ":null)."$value";
}
$post['name']=$nn;
echo "<li><img src='images/smiles/$post[img]' alt='o'> ".($ku['status']==3?"<a href='?smiles&edit=$post[id]'>":null)."".hsc($post['name'])."".($ku['status']==3?"</a>":null)."".($ku['status']==3?" <a href='?smiles&delete=$post[id]'>[удалить]</a>":null)."</li>";
}
if($ku['status']==3)echo "<li>» <a href='?smiles&add'>Добавить смайл</a></li>";
echo "</ul>";
if($ku['status']==3 && $ku['vip']!=0)
{
echo "<div class='event'><h1>ВВкоды</h1></div><div class='content'><ul class='block'>";
echo "<font size='3'>
<img src='/images/icons/present.png'> <span class='pt small minor'>[img]/images/icons/present.png[/img]</br></span>
<font color='red'>Цветной текст</font> <span class='pt small minor'>[color=red]Цветной текст[/color]</br></span>
<i>Прописной текст</i> <span class='pt small minor'>[i]Прописной текст[/i]</br></span>
<s>Зачеркнутый текст</s> <span class='pt small minor'>[s]Зачеркнутый текст[/s]</br></span>
<b>Жирный текст</b> <span class='pt small minor'>[b]Жирный текст[/b]</br></span>
<u>Подчеркнутый текст</u> <span class='pt small minor'>[u]Подчеркнутый текст[/u]</br></span>
<font size='30'>Размер текста 0-30</font> <span class='pt small minor'>[size=30]Размер теста 0-30[/size]</br></span>";
echo "</font></ul>";
}
include_once 'inc/foot.php';
?>