View file Spiderwap.in File Hosting/rait.php

File size: 2.76Kb
<?php
require 'sys/config.php';
$id = isset($_GET['id'])?fil($_GET['id'],'int'):'';
if($sql->result('SELECT COUNT(*) FROM `files` WHERE `id`="'.$id.'"')==0)
{
$smarty->assign('title','Error');
$smarty->assign('back','/index.php');
$smarty->assign('error','This file does not exist');
$smarty->display('header.tpl');
$smarty->display('error.tpl');
$smarty->display('footer.tpl');
}

$_GET['who'] = str_replace(array('add','min'),array('+','-'),$_GET['who']);
if(!in_array($_GET['who'],array('-','+')))
{
$smarty->assign('title','Error');
$smarty->assign('back','/file-'.$id);
$smarty->assign('error','Ошибка');
$smarty->display('header.tpl');
$smarty->display('error.tpl');
$smarty->display('footer.tpl');
}

if(isset($user)){

$alls = $sql->query('SELECT `raitis` FROM `files` WHERE `id`="'.$id.'"')->fetch_assoc();
$all = split(',',$alls['raitis']);
if(in_array($user['id'],$all))
{
$smarty->assign('title','Ошибка');
$smarty->assign('back','/file-'.$id);
$smarty->assign('error','You already voted for this file');
$smarty->display('header.tpl');
$smarty->display('error.tpl');
$smarty->display('footer.tpl');
} else {
if($sql->query('UPDATE `files` SET `raitis`="'.$alls['raitis'].','.$user['id'].'", `rait`=`rait`'.$_GET['who'].'1 WHERE `id`="'.$id.'"'))
{
$smarty->assign('title','Готово');
$smarty->assign('back','/file-'.$id);
$smarty->assign('nz','to file');
$smarty->assign('ok','Rate File successfully changed');
$smarty->display('header.tpl');
$smarty->display('ok.tpl');
$smarty->display('footer.tpl');
} else {
$smarty->assign('title','Error');
$smarty->assign('back','/file-'.$id);
$smarty->assign('error','Contact the administrator');
$smarty->display('header.tpl');
$smarty->display('error.tpl');
$smarty->display('footer.tpl');
}
}
}  else {

$alls = !empty($_COOKIE['pmixr'])?$_COOKIE['pmixr']:'';
$all = split(',',$alls);
if(in_array($id,$all))
{
$smarty->assign('title','Error');
$smarty->assign('back','/file-'.$id);
$smarty->assign('error','You already voted for this file');
$smarty->display('header.tpl');
$smarty->display('error.tpl');
$smarty->display('footer.tpl');
} else {
if($sql->query('UPDATE `files` SET `rait`=`rait`'.$_GET['who'].'1 WHERE `id`="'.$id.'"'))
{
setcookie('pmixr',$alls.','.$id);
$smarty->assign('title','Finish');
$smarty->assign('back','/file-'.$id);
$smarty->assign('nz','К файлу');
$smarty->assign('ok','Rate File successfully changed');
$smarty->display('header.tpl');
$smarty->display('ok.tpl');
$smarty->display('footer.tpl');
} else {
$smarty->assign('title','Error');
$smarty->assign('back','/file-'.$id);
$smarty->assign('error','Contact the administrator');
$smarty->display('header.tpl');
$smarty->display('error.tpl');
$smarty->display('footer.tpl');
}
}
}