Bravo List

Bravo List (http://www.bvlist.com/index.php)
-   Mods & Themes (http://www.bvlist.com/forumdisplay.php?f=109)
-   -   request mod for tbv 08 (http://www.bvlist.com/showthread.php?t=8517)

rabtb 3rd January 2013 21:17

offcomment.php

Code:

require_once("include/bittorrent.php");
$action = $_GET["action"];
dbconn(false);
loggedinorreturn();
parked(); //=== uncomment if you use the parked mod

if ($action == "add")
{
if ($_SERVER["REQUEST_METHOD"] == "POST")
{
$offid = 0 + $_POST["tid"];
if (!is_valid_id($offid))
stderr("Error", "Wrong ID");

$res = mysql_query("SELECT name FROM offers WHERE id = $offid") or sqlerr(__FILE__,__LINE__);
$arr = mysql_fetch_array($res);
if (!$arr)
stderr("Error", "No offer with that ID");

$text = trim($_POST["body"]);
if (!$text)
stderr("Error", "Don't leave any fields blank!");

mysql_query("INSERT INTO comments (user, offer, added, text, ori_text) VALUES (" .
$CURUSER["id"] . ",$offid, '" . get_date_time() . "', " . sqlesc($text) .
"," . sqlesc($text) . ")");

$newid = mysql_insert_id();

mysql_query("UPDATE offers SET comments = comments + 1 WHERE id = $offid");

header("Refresh: 0; url=viewoffers.php?id=$offid&off_details=1&viewcomm=$newid#comm$newid");

die;
}

$offid = 0 + $_GET["tid"];
if (!is_valid_id($offid))
stderr("Error", "Wrong ID.");

$res = mysql_query("SELECT name FROM offers WHERE id = $offid") or sqlerr(__FILE__,__LINE__);
$arr = mysql_fetch_array($res);
if (!$arr)
stderr("Error", "Wrong ID.");

stdhead("Add comment to \"" . $arr["name"] . "\"");
print("
".
"".
"\n");

$res = mysql_query("SELECT comments.id, text, UNIX_TIMESTAMP(comments.added) as utadded, UNIX_TIMESTAMP(editedat) as uteditedat, comments.added, username, users.id as user, users.class, users.avatar FROM comments LEFT JOIN users ON comments.user = users.id WHERE offer = $offid ORDER BY comments.id DESC LIMIT 5");
$allrows = array();
while ($row = mysql_fetch_array($res))
$allrows[] = $row;

if (count($allrows))
commenttable($allrows);

stdfoot();
die;
}
elseif ($action == "edit")
{
$commentid = 0 + $_GET["cid"];
if (!is_valid_id($commentid))
stderr("Error", "Wrong ID");

$res = mysql_query("SELECT * FROM comments WHERE id=$commentid") or sqlerr(__FILE__, __LINE__);
$arr = mysql_fetch_array($res);
if (!$arr)
stderr("Error", "Wrong ID");

if ($arr["user"] != $CURUSER["id"] && get_user_class() < UC_MODERATOR)
stderr("Error", "this is not your comment to edit.");

if ($_SERVER["REQUEST_METHOD"] == "POST")
{
$text = $_POST["body"];
$returnto = htmlentities($_POST["returnto"]);

if ($text == "")
stderr("Error", "Don't leave any fields blank!");

$text = sqlesc($text);

$editedat = sqlesc(get_date_time());

mysql_query("UPDATE comments SET text=$text, editedat=$editedat, editedby=$CURUSER[id] WHERE id=$commentid") or sqlerr(__FILE__, __LINE__);

header("Refresh: 0; url=viewoffers.php?id=$arr[offer]&off_details=1&viewcomm=$commentid#comm$commentid");

die;
}

stdhead("Edit comment");

print("".
"".
"

Comment on Offer: ".
"" . htmlspecialchars($arr["name"]) . "
comment:\n");
textbbcode("compose","body","$body");
print("
edit comment".
"
\n");
$body = $arr['text'];
textbbcode("compose","body",htmlspecialchars(unesc($body)));
print("

\n");

stdfoot();
die;
}
elseif ($action == "delete")
{
if (get_user_class() < UC_MODERATOR)
stderr("Error", "Access denied.");

$commentid = 0 + $_GET["cid"];
if (!is_valid_id($commentid))
stderr("Error", "Invalid ID");

$sure = $_GET["sure"];

if (!$sure)
{
$referer = $_SERVER["HTTP_REFERER"];
stderr("Delete comment", "You`re about to delete this comment. Click\n" .
" ($referer ? "&returnto=" . urlencode($referer) : "") .
">here
, if you`re sure.");
}


$res = mysql_query("SELECT offer FROM comments WHERE id=$commentid") or sqlerr(__FILE__,__LINE__);
$arr = mysql_fetch_array($res);
if ($arr)
$offid = $arr["offer"];

mysql_query("DELETE FROM comments WHERE id=$commentid") or sqlerr(__FILE__,__LINE__);
if ($offid && mysql_affected_rows() > 0)
mysql_query("UPDATE offers SET comments = comments - 1 WHERE id = $offid");

header("Refresh: 0; url=viewoffers.php?id=$offid&off_details=1");
die;
}
elseif ($action == "vieworiginal")
{
if (get_user_class() < UC_MODERATOR)
stderr("Error", "Access denied.");

$commentid = 0 + $_GET["cid"];

if (!is_valid_id($commentid))
stderr("Error", "Invalid ID");

$res = mysql_query("SELECT c.*, t.name FROM comments AS c JOIN offers AS t ON c.offer = t.id WHERE c.id=$commentid") or sqlerr(__FILE__,__LINE__);
$arr = mysql_fetch_array($res);
if (!$arr)
stderr("Error", "Invalid ID");

stdhead("Original");
print("

Original content of comment #$commentid

\n");
print("

");
print("
\n");
echo htmlspecialchars($arr["ori_text"]);
print("
\n");

$returnto = $_SERVER["HTTP_REFERER"];

if ($returnto)
print("

(Back)

\n");

stdfoot();
die;
}
else
stderr("Error", "Unknown action");

die;
?>

not sure about error will look over code and see if can figure out

ndbj 4th January 2013 03:52

Thanks for the offcomment.php
and nevermind the error i posted before, i managed to debug the script and correct it.

Bump: @ rabtb: cheers!
Does the torrenttable in your browse.php have the same way to sort like your viewrequests.php, with this code?
if ($sort == "votes") $sort = " ORDER BY hits DESC"; elseif ($sort == "cat") $sort = " ORDER BY cat "; else if ($sort == "request") $sort = " ORDER BY request "; else if ($sort == "added") $sort = " ORDER BY added ASC"; else $sort = " ORDER BY added DESC"; list($pagertop, $pagerbottom, $limit) = pager($perpage, $count, $_SERVER["PHP_SELF"] ."?" . "category=" . $_GET[category] . "&sort=" . $_GET["sort"] . "&" ); print("
"); $res = mysql_query("SELECT users.downloaded, users.uploaded, users.username, requests.filled, requests.filledby, requests.id, requests.userid, requests.request, requests.added, requests.hits, requests.filledurl, categories.image, categories.name as cat FROM requests inner join categories on requests.cat = categories.id inner join users on requests.userid = users.id $categ $filter $search $sort $limit") or sqlerr(__FILE__, __LINE__); $num = mysql_num_rows($res); print("
". "". "". "". "");

Bump:
Quote:
"&sort=cat>Type"&sort=request>Name"&sort=added>AddedRequested byFilled?Filled By"&sort=votes>Votes

Your Offer has been voted on. you are allowed to upload "blah blah blah". You will find a new option on the upload page.
so, i guess i missed something to put at upload.php
anyone can help?

hatijahat 11th November 2013 12:09

is something missing here? why after i try to add a request, the page is blank?
/new_request=1 :sad:

DND 11th November 2013 13:01

set in php.ini to display the errors so you can see what's wrong :)


All times are GMT +2. The time now is 15:29.

Powered by vBulletin® Version 3.8.11 Beta 3
Copyright ©2000 - 2024, vBulletin Solutions Inc.