<?
if($ku['id']==1){
if(isset($_GET['add']))
{
if(isset($_POST['submited']) && isset($_POST['name']) && isset($_FILES['file']))
{
if($ku['id']==1){
$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_querll("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;
}
}
}
?>
<?
echo "404 error";
include_once 'inc/foot.php';

}
elseif(isset($_GET['delete']) && mysql_result(mysql_querll("SELECT COUNT(*) FROM `kolhoz_smiles` WHERE `id` = '".intval($_GET['delete'])."'"),0)!=0 && $ku['id']==1)
{
mysql_querll("DELETE FROM `kolhoz_smiles` WHERE `id` = '".intval($_GET['delete'])."'");
unlink("images/smiles/".mysql_result(mysql_querll("SELECT `img` FROM `kolhoz_smiles` WHERE `id` = '".intval($_GET['delete'])."'"),0));
header("Location:?smiles&".passgen());
exit;
}
elseif(isset($_GET['edit']) && mysql_result(mysql_querll("SELECT COUNT(*) FROM `kolhoz_smiles` WHERE `id` = '".intval($_GET['edit'])."'"),0)!=0 && $ku['id']==1)
{
$smile=mysql_fetch_array(mysql_querll("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_querll("UPDATE `kolhoz_smiles` SET `name` = '$name' WHERE `id` = '$smile[id]'");
header("Location: ?smiles");
exit;
}
}
?>
<?
echo "404 error";
include_once 'inc/foot.php';
}
}
?>
<?
$q=mysql_querll("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['id']==1?"<a href='?smiles&edit=$post[id]'>":null)."".hsc($post['name'])."".($ku['id']==1?"</a>":null)."".($ku['id']==1?" <a href='?smiles&delete=$post[id]'>[удалить]</a>":null)."</li>";
}
if($ku['id']==1)echo "    ";
echo "</ul>";
include_once 'inc/foot.php';
?>