Files
nexusphp/public/bookmark.php

32 lines
1.3 KiB
PHP
Raw Normal View History

2020-12-26 01:42:23 +08:00
<?php
2021-01-13 19:32:26 +08:00
require "../include/bittorrent.php";
2020-12-26 01:42:23 +08:00
dbconn();
//Send some headers to keep the user's browser from caching the response.
2022-03-26 16:09:39 +08:00
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT" );
header("Last-Modified: " . gmdate( "D, d M Y H:i:s" ) . "GMT" );
header("Cache-Control: no-cache, must-revalidate" );
2020-12-26 01:42:23 +08:00
header("Pragma: no-cache" );
header("Content-Type: text/xml; charset=utf-8");
2021-01-06 02:19:03 +08:00
$torrentid = intval($_GET['torrentid'] ?? 0);
2020-12-26 01:42:23 +08:00
if(isset($CURUSER))
{
2022-03-26 16:09:39 +08:00
$searchRep = new \App\Repositories\SearchRepository();
2021-03-25 18:30:23 +08:00
$res_bookmark = sql_query("SELECT * FROM bookmarks WHERE torrentid=" . sqlesc($torrentid) . " AND userid=" . sqlesc($CURUSER['id']));
2020-12-26 01:42:23 +08:00
if (mysql_num_rows($res_bookmark) == 1){
2022-03-26 16:09:39 +08:00
$bookmarkResult = mysql_fetch_assoc($res_bookmark);
$searchRep->deleteBookmark($bookmarkResult['id']);
2020-12-26 01:42:23 +08:00
sql_query("DELETE FROM bookmarks WHERE torrentid=" . sqlesc($torrentid) . " AND userid=" . sqlesc($CURUSER['id'])) or sqlerr(__FILE__,__LINE__);
$Cache->delete_value('user_'.$CURUSER['id'].'_bookmark_array');
echo "deleted";
2022-03-26 16:09:39 +08:00
} else {
2020-12-26 01:42:23 +08:00
sql_query("INSERT INTO bookmarks (torrentid, userid) VALUES (" . sqlesc($torrentid) . "," . sqlesc($CURUSER['id']) . ")") or sqlerr(__FILE__,__LINE__);
$Cache->delete_value('user_'.$CURUSER['id'].'_bookmark_array');
2022-03-26 16:09:39 +08:00
$searchRep->addBookmark(mysql_insert_id());
2020-12-26 01:42:23 +08:00
echo "added";
}
}
else echo "failed";
?>