last 25 comments

Started by rickandmary, July 20, 2012, 01:00:58 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

ZajferX

#3
sorry for double posting but i just wanted to say that i am trying to convert the code to 09 and the first thing i did was to add PHP to the start <? and then i am rewriting all the print to $HTMLOUT .. hopefully i will manage to convert the whole file :D

now it is fully functioning


<?php
require_once "include/bittorrent.php";
require_once 
"include/user_functions.php";
require_once 
"include/html_functions.php";
require_once 
"include/bbcode_functions.php";
dbconn();
loggedinorreturn();
$lang array_mergeload_language('global'), load_language('tags') );
echo 
stdhead("Comments");
echo 
begin_main_frame();
echo 
begin_frame("Comments");
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Begin Page
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
$limit 25;

if ((isset(
$_GET["amount"])) && ($_GET["amount"])) { if (intval($_GET["amount"]) != $_GET["amount"]) { stderr("Error""Amount wasn't an integer."); } $limit$_GET["amount"]; if ($limit>999$limit 1000; if ($limit<10$limit 10; }

echo 
"<p align=\"left\">Showing " $limit " latest comments.</p>\n";

$subres mysql_query("SELECT comments.id, torrent, text, user, comments.added , editedby, editedat, avatar, warned, username, title, class FROM comments LEFT JOIN users ON comments.user = users.id ORDER BY comments.id DESC limit 0," $limit) or sqlerr(__FILE____LINE__);
while (
$subrow mysql_fetch_array($subres)) $allrows[] = $subrow;

// function
function my_function($rows) {

foreach ($rows as $row) {
$subres mysql_query("SELECT name from torrents where id=" $row["torrent"]) or sqlerr(__FILE____LINE__);
$subrow mysql_fetch_array($subres);

echo "<br /><a href=\"details.php?id=" $row["torrent"] . "\">" $subrow["name"] . "</a><br />\n" .
"<p class=sub>#" $row["id"] . " by ";

if (isset($row["username"])) {
echo "<a name=comm{$row["id"]}href=userdetails.php?id={$row["user"]}><b>" htmlspecialchars($row["username"]) . "</b></a>" . ($row["warned"] == "yes" "<img src=" "pic/warned.gif alt=\"Warned\">" "");
}
else { echo "<a name=\"comm" $row["id"] . "\"><i>(orphaned)</i></a>\n"; }

echo " at {$row['added']} GMT- [<a href=comment.php?action=edit&cid=$row[id]>Edit</a>]- [<a href=deletecomment.php?id=$row[id]>Delete</a>]</p>\n";

//$avatar = ($CURUSER["avatars"] == "yes" ? htmlspecialchars($row["avatar"]) : "");
/*if (!$avatar) {*/ $avatar "pic/forumicons/default_avatar.gif"//}

echo begin_table(true);
echo "<tr valign=top>\n";
//echo "<td align=center width=150 style='padding: 0px'><img width=150 src=$avatar></td>\n";
echo "<td class=text>" format_comment($row["text"]) . "</td>\n";
echo "</tr>\n";
echo end_table();
}
    
}

my_function($allrows);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// End Page
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
echo  end_frame();
echo  
end_main_frame();
echo 
stdfoot();
?>



please note that it uses the lang-file from tags due to i have not yet created the correct comments lang file .. but will do it soon and share it with you but other than that the code should work for everyone .. feel free to edit it so that it is 100% correct and feel free to add it to your source :D



Quote from: ZajferX on May 03, 2014, 11:02:20 AM
how to convert this mod to 09 ? please help

ZajferX

how to convert this mod to 09 ? please help

rickandmary

save and upload to root folder.

comments.php
<?
require "include/bittorrent.php";
dbconn();
loggedinorreturn();
if (get_user_class() < UC_MODERATOR)
stderr("Error", "permission denied.");

stdhead();

$limit = 25;

if ($_GET["amount"]) {

if (intval($_GET["amount"]) != $_GET["amount"]) {
stderr("Error", "Amount wasn't an integer.");
}

$limit= 0 + $_GET["amount"];

if ($limit>999)
$limit = 1000;

if ($limit<10)
$limit = 10;
}

print("<p align=\"left\">Showing " . $limit . " latest comments.</p>\n");

$subres = mysql_query("SELECT comments.id, torrent, text, user, comments.added , editedby, editedat, avatar, warned, ".
"username, title, class FROM comments LEFT JOIN users ON comments.user = users.id " .
" ORDER BY comments.id DESC limit 0," . $limit) or sqlerr(__FILE__, __LINE__);
$allrows = array();
while ($subrow = mysql_fetch_array($subres))
$allrows[] = $subrow;

commenttable_new($allrows);
stdfoot();


function commenttable_new($rows) {

global $CURUSER, $HTTP_SERVER_VARS;
begin_main_frame();
begin_frame();
$count = 0;
foreach ($rows as $row)
{
$subres = mysql_query("SELECT name from torrents where id=" . $row["torrent"]) or sqlerr(__FILE__, __LINE__);
$subrow = mysql_fetch_array($subres);
print("<br /><a href=\"details.php?id=" . $row["torrent"] . "\">" . $subrow["name"] . "</a><br />\n");
print("<p class=sub>#" . $row["id"] . " by ");
if (isset($row["username"])) {
print("<a name=comm". $row["id"] . " href=userdetails.php?id=" . $row["user"] . "><b>" . htmlspecialchars($row["username"]) . "</b></a>" . ($row["warned"] == "yes" ? "<img src=" . "pic/warned.gif alt=\"Warned\">" : ""));
}
else {
print("<a name=\"comm" . $row["id"] . "\"><i>(orphaned)</i></a>\n");
}
print(" at " . $row["added"] . " GMT" .
"- [<a href=comment.php?action=edit&cid=$row[id]>Edit</a>]" .
"- [<a href=deletecomment.php?id=$row[id]>Delete</a>]</p>\n");
$avatar = ($CURUSER["avatars"] == "yes" ? htmlspecialchars($row["avatar"]) : "");
if (!$avatar) {
$avatar = "pic/default_avatar.gif";
}

begin_table(true);
print("<tr valign=top>\n");
print("<td align=center width=150 style='padding: 0px'><img width=150 src=$avatar></td>\n");
print("<td class=text>" . format_comment($row["text"]) . "</td>\n");
print("</tr>\n");
end_table();
}
end_frame();
end_main_frame();
}

?>


add to staff php where you want it to go

<td class=embedded><form method=get action=comments.php><input type=submit value="Last Comments" style='height: 20px; width: 100px'></form></td>

All credit to the author