Файл: vk/admin/likes.php
Строк: 105
<?php
if($_GET['action'] == "delete" && isset($_GET['id'])){
$q = $db->mysql_qw("SELECT * FROM likes WHERE id = ?;",$_GET['id']);
if(mysql_num_rows($q)>0){
if(isset($_POST['delete'])){
$db->mysql_qw("DELETE FROM likes WHERE id = ?;",$_GET['id']);
echo "
<div class='alert alert-success'>
<b>Функция: Лайки успешно удалена!</b>
</div>
";
}else{
echo "
<center>
<b>Вы действительно хотите удалитьЛайки?</b>
<form method='post'>
<input type='hidden' name='delete' value='1'>
<input type='submit' class='btn btn-info' value='Удалить'>
<input type='button' class='btn btn-danger' value='Отменить' onClick='window.location.href="?page=likes&gpage=".$_GET['gpage']."";'>
</form>
</center>
";
}
}else{
echo "
<div class='alert alert-error'>
<b>Функция:Лайк с данным ID не найдена!</b>
</div>
";
}
exit();
}
if($_GET['action'] == "edit" && isset($_GET['id'])){
if(isset($_POST['name'])){
foreach($_POST as $key=>$val){
if($key == "created"){
$val = strtotime($val);
}
$string .= ",".$key."='".$val."'";
}
$string = substr($string, 1);
mysql_query("UPDATE likes SET ".$string." WHERE id = ".$_GET['id'].";");
echo "
<div class='alert alert-success'>
<b>Лайк отредактирован!</b>
</div>
";
}
$q = $db->mysql_qw("SELECT * FROM likes WHERE id = ?;",$_GET['id']);
if(mysql_num_rows($q)>0){
while($val = mysql_fetch_assoc($q)){
if($val['active'] == 1){
$status = "
<select name='active' class='tselect'>
<option value='0'>Остановлено</option>
<option value='1' selected>Запущено</option>
</select>
";
}else{
$status = "
<select name='active'>
<option value='0' selected>Остановлено</option>
<option value='1'>Запущено</option>
</select>
";
}
$date = date("H:i d.m.Y",$val['created']);
echo "
<form method='post'>
<table class='admint'>
<tr>
<td>Название</td>
<td><input type='text' name='name' value='".$val['name']."'></td>
</tr>
<tr>
<td>Владелец</td>
<td><input type='text' name='owner' value='".$val['owner']."'></td>
</tr>
<tr>
<td>Ссылка</td>
<td><input type='text' name='link' value='".$val['link']."'></td>
</tr>
<tr>
<td>Нужно Рассказать</td>
<td><input type='text' name='likes' value='".$val['likes']."'></td>
</tr>
<tr>
<td>Рассказало</td>
<td><input type='text' name='joined' value='".$val['joined']."'></td>
</tr>
<tr>
<td>Создан</td>
<td><input type='text' name='created' value='".$date."'></td>
</tr>
<tr>
<td>Статус</td>
<td>".$status."</td>
</tr>
</table>
<br>
<input type='submit' class='btn btn-info' value='Сохранить'> <input type='button' class='btn btn-danger' value='Отменить' onClick='window.location.href="?page=likes&gpage=".$_GET['gpage']."";'>
</form>
";
}
}else{
echo "
<div class='alert alert-error'>
<b>Запись с данным ID не найдена!</b>
</div>
";
}
}else{
$q = $db->mysql_qw("SELECT * FROM likes;");
$on_page = 10;
$pages = ceil(mysql_num_rows($q) / $on_page);
if($pages == 0){
echo "<center><h3>Не создано ни одной записи</h3></center>";
}else{
if(!isset($_GET['gpage'])){
$page_now = 1;
}else{
$page_now = $_GET['gpage'];
}
echo "Выберите страницу: ";
for($c=1;$c<=$pages;$c++){
if($c == $page_now){
echo "<b>".$c."</b>";
}else{
echo "<a href='#'>".$c."</a>";
}
}
$sd = $page_now * $on_page - $on_page;
echo "
<table class='admint'>
<tr>
<td>Название</td>
<td>Владелец</td>
<td>Ссылка</td>
<td>Нужно Лайков</td>
<td>Лайкнули</td>
<td>Создан</td>
<td>Статус</td>
<td></td>
</tr>
";
$q = $db->mysql_qw("SELECT * FROM likes LIMIT ?,?",$sd, $on_page);
while($val = mysql_fetch_assoc($q)){
$date = date("H:i d.m.Y",$val['created']);
if($val['active'] == 1){
$status = "Активно";
}else{
$status = "Остановлено";
}
echo "
<tr>
<td>".$val['name']."</td>
<td>".$val['owner']."</td>
<td>".$val['link']."</td>
<td>".$val['likes']."</td>
<td>".$val['joined']."</td>
<td>".$date."</td>
<td>".$status."</td>
<td>
<a href='?page=likes&gpage=".$page_now."&id=".$val['id']."&action=edit'><img src='http://cdn2.iconfinder.com/data/icons/diagona/icon/16/018.png' class='editt'></a>
<a href='?page=likes&gpage=".$page_now."&id=".$val['id']."&action=delete'><img src='http://cdn2.iconfinder.com/data/icons/diagona/icon/16/101.png' class='deletet'></a>
</td>
</tr>
";
}
echo "</table>";
}
}
?>