Login
Username: Password:
Remember me

[Sign Up] / [Recover Password]

Theme / Language

Popular
New Torrents
new name
Size: 18.40 MB
Most active
new name
S: 74 L: 3
New Posters
Back to torrent after edit/delete commen
Controls ·  Search New posts · Mark unread

You are in: Forum / Forum / v2.08 / v2.08 Mods Completed

Unknown User
2013-02-05 05:55:23
After you have edited or deleted a comment from a torrent or from News you are redirected back.

These actions are are registered into Log.

Replace entire code at comments.php with this one:



<?php

require_once("backend/functions.php");

require_once("backend/bbcode.php");

dbconn();



$id = (int)$_GET["id"];

$type = $_GET["type"];

$edit = (int)$_GET["edit"];

$delete = (int)$_GET["delete"];



if ($edit == 1 || $delete == 1 || $_GET["takecomment"] == 'yes') loggedinonly();



if (!isset($id) || !$id || ($type != "torrent" && $type != "news"))

   show_error_msg("ERROR", T_("ERROR"), 1);



if ($edit=='1'){

   $row = mysql_fetch_assoc(SQL_Query_exec("SELECT user FROM comments WHERE id=$id"));



   if (($type == "torrent" && $CURUSER["edit_torrents"] == "no" || $type == "news" && $CURUSER["edit_news"] == "no") && $CURUSER['id'] != $row['user'])  

       show_error_msg("ERROR","You cant do this!",1);



       $save = (int)$_GET["save"];



       if($save){

           $text = sqlesc($_POST['text']);

         

           if ($type == "torrent") {

               $res = SQL_Query_exec("SELECT torrent FROM comments WHERE id=$id");

               $row = mysql_fetch_assoc($res);

               $idback = $row["torrent"];

               $query="UPDATE comments SET text=$text WHERE id=$id";

               $result=SQL_Query_exec($query);

               write_log("<a href=account-details.php?id=".$CURUSER['id']."><b>".$CURUSER['username']."</a></b> has edited comment ID: <b>$id</b> from torrent: [<a href=torrents-details.php?id=$idback><b>$idback</b></a>]");

               autolink("torrents-details.php?id=$idback", "Comment was edited successfully.");

           }

         

           if ($type == "news") {

               $res = SQL_Query_exec("SELECT news FROM comments WHERE id=$id");

               $row = mysql_fetch_assoc($res);

               $idback = $row["news"];

               $query="UPDATE comments SET text=$text WHERE id=$id";

               $result=SQL_Query_exec($query);

               write_log("<a href=account-details.php?id=".$CURUSER['id']."><b>".$CURUSER['username']."</a></b> has edited comment ID: <b>$id</b> from News ID: [<a href=comments.php?type=news&id=$idback><b>$idback</b></a>]");

               autolink("comments.php?type=news&id=$idback", "Comment was edited successfully.");

           }

       }



       stdhead("Edit Comment");



       $res = SQL_Query_exec("SELECT * FROM comments WHERE id=$id");

       $arr = mysql_fetch_array($res);



       begin_frame("Edit Comment");

       print("<center><b>Edit comment </b><p>n");

       print("<form method="post" name="comment" action="comments.php?type=$type&amp;edit=1&save=1&amp;id=$id">n");

       print textbbcode("comment","text", htmlspecialchars($arr["text"]));

       print("<p><input type="submit"  value="Submit Changes" /></p></form></center>n");

       end_frame();

       stdfoot();

       die();

}



if ($delete=='1'){

   if ($CURUSER["delete_news"] == "no" && $type == "news" || $CURUSER["delete_torrents"] == "no" && $type == "torrent")

       show_error_msg("ERROR","You cant do this!",1);



   if ($type == "torrent") {

       $res = SQL_Query_exec("SELECT torrent FROM comments WHERE id=$id");

       $row = mysql_fetch_assoc($res);

       if ($row["torrent"] > 0) {

           SQL_Query_exec("UPDATE torrents SET comments = comments - 1 WHERE id = $row[torrent]");

       }

       $idback = $row["torrent"];

       SQL_Query_exec("DELETE FROM comments WHERE id = $id");

       write_log("<a href=account-details.php?id=".$CURUSER['id']."><b>".$CURUSER['username']."</a></b> has deleted comment ID: <b>$id</b> from torrent: [<a href=torrents-details.php?id=$idback><b>$idback</b></a>]");

       autolink("torrents-details.php?id=$idback", "Comment was deleted successfully.");

   }

 

   if ($type == "news") {

       $res = SQL_Query_exec("SELECT news FROM comments WHERE id=$id");

       $row = mysql_fetch_assoc($res);

       $idback = $row["news"];

       SQL_Query_exec("DELETE FROM comments WHERE id = $id");

       write_log("<a href=account-details.php?id=".$CURUSER['id']."><b>".$CURUSER['username']."</a></b> has deleted comment ID: <b>$id</b> from News ID: [<a href=comments.php?type=news&id=$idback><b>$idback</b></a>]");

       autolink("comments.php?type=news&id=$idback", "Comment was deleted successfully.");

   }

}



stdhead(T_("COMMENTS"));



//take comment add

if ($_GET["takecomment"] == 'yes'){

   $body = $_POST['body'];

 

   if (!$body)

       show_error_msg(T_("ERROR"), T_("YOU_DID_NOT_ENTER_ANYTHING"), 1);



   if ($type =="torrent"){

       SQL_Query_exec("UPDATE torrents SET comments = comments + 1 WHERE id = $id");

   }



   SQL_Query_exec("INSERT INTO comments (user, ".$type.", added, text) VALUES (".$CURUSER["id"].", ".$id.", '" .get_date_time(). "', " . sqlesc($body).")");

 

   if (mysql_affected_rows() == 1)

           show_error_msg(T_("COMPLETED"), "Your Comment was added successfully.", 0);

       else

           show_error_msg(T_("ERROR"), T_("UNABLE_TO_ADD_COMMENT"), 0);

}//end insert comment



//NEWS

if ($type =="news"){

   $res = SQL_Query_exec("SELECT * FROM news WHERE id = $id");

   $row = mysql_fetch_array($res);



   if (!$row){

       show_error_msg(T_("ERROR"), "News id invalid", 0);

       stdfoot();

   }



   begin_frame(T_("NEWS"));

   echo htmlspecialchars($row['title']) . "<br /><br />".format_comment($row['body'])."<br />";

   end_frame();

}



//TORRENT

if ($type =="torrent"){

   $res = SQL_Query_exec("SELECT id, name FROM torrents WHERE id = $id");

   $row = mysql_fetch_array($res);



   if (!$row){

       show_error_msg(T_("ERROR"), "News id invalid", 0);

       stdfoot();

   }

   echo "<center><b>Comments for:</b> <a href='torrents-details.php?id=".$row['id']."'>".htmlspecialchars($row['name'])."</a></center><br />";

}



if($CURUSER["commentbanned"]=="yes")

   show_error_msg("Access Denied","You was banned to use comments!",0);

else {

   begin_frame(T_("COMMENTS"));



   $subres = SQL_Query_exec("SELECT COUNT(*) FROM comments WHERE $type = $id");

   $subrow = mysql_fetch_array($subres);

   $commcount = $subrow[0];



   if ($commcount) {

       list($pagertop, $pagerbottom, $limit) = pager(25, $commcount, "comments.php?id=$id&amp;type=$type&amp;");

       $commquery = "SELECT comments.id, text, user, comments.added, avatar, signature, username, title, class, uploaded, downloaded, privacy, donated FROM comments LEFT JOIN users ON comments.user = users.id WHERE $type = $id ORDER BY comments.added DESC $limit";

       $commres = SQL_Query_exec($commquery);

   }else{

       unset($commres);

   }



   if ($commcount) {

       print($pagertop);

       commenttable($commres, $type);

       print($pagerbottom);

   }else {

       print("<br /><b>" .T_("NOCOMMENTS"). "</b><br />n");

   }



   echo "<center>";

   echo "<form name="comment" method="post" action="comments.php?type=$type&amp;id=$id&amp;takecomment=yes">";

   echo textbbcode("comment","body")."<br />";

   echo "<input type="submit"  value="Add Comment" />";

   echo "</form></center>";



   end_frame();

}

stdfoot();

?>

Unknown User
2013-02-05 06:50:16
personnaly i use autolink instead show_error_msg
Unknown User
2013-03-01 17:35:45
[size=18px]I forgot about comments from News, I updated the first post with all that is necessary[/size] :)
2013-03-22 06:47:08
Thanks!
2013-04-01 16:14:56
Thanks You / Merci BigMax1 :)
Unknown User
2013-04-15 15:19:56
Thanks You BigMax1   :)
Users online

No users online

Search



Statistics

    Torrents

  • Tracking: 3
  • Todays torrents: 0
  • Seeders: 0
  • Leechers: 0
  • Peers: 0
  • Downloaded: 89.96 GB
  • Uploaded: 9.86 GB

  • Members

  • We have: 838
  • New today: 0
  • Guest today: 9

  • Online

  • Total online: 9
  • Members: 0
  • Guests online: 9
  • Comments: 3
  • Messages: 1,728