Location: PHPKode > projects > H-tracker > mysimpaty.php
<?
//
//  H-Tracker v0.2
//    http://h-tracker.org
//    Based on TorrentTrader (http://www.torrenttrader.org)
//
//

require "backend/functions.php";

dbconn(false);

loggedinonly();

if (!isset($_GET["id"]))
       $userid = $CURUSER["id"];
elseif (get_user_class() < 5 && $_GET["id"] != $CURUSER["id"])
        show_error_msg("Error", "Access Denied.");
elseif (get_user_class() >= 5 || $_GET["id"] == $CURUSER["id"])
        $userid = (int) $_GET["id"];

if (!is_valid_id($userid))
        show_error_msg("Error", "Invalid ID.");

stdhead("My respects");
        $count_res = mysql_query("SELECT COUNT(*) FROM simpaty WHERE touserid = $userid");
		$count_row = mysql_fetch_array($count_res);
		$count = $count_row[0];

if (!$count) {
show_error_msg("Warning!", "You dont have respects");
} else {
        unset ($admin);
        if (get_user_class()>=7) {
                $admin = true;
        }
begin_frame("My simpaty");
?>
<table border="1" cellspacing="0" cellpadding="3" align="center" width="98%">
<tr>
<td width=10 class=ttable_head >#</td>
<td width=20 class=ttable_head >Type</td>
<td class=ttable_head >From who</td>
<td class=ttable_head >For which</td>
<td class=ttable_head >Reason</td>
<td class=ttable_head  align=center width="10%">Date</td>
<?
if ($admin)
	print("<td class=ttable_head width=8>Delete</td>");
?>
</tr>
<?
        list($pagertop, $pagerbottom, $limit) = pager(30, $count, "mysimpaty.php?", array(lastpagedefault => 0));
        $res = mysql_query("SELECT * FROM simpaty WHERE touserid = $userid ORDER BY respect_time DESC $limit");
        while ($arr = mysql_fetch_assoc($res)) {
                $respect_id = $arr["id"];
                $touserid = $arr["touserid"];
                $respect_type = ($arr["bad"]==1?"bad":"good");
                $i++;
                if (substr($arr["type"],0,7) == 'torrent') {
                        $from_what = '<a href="torrents-details.php?id=' . substr($arr["type"],7,strlen($arr["type"])) . '&hit=1">' . "Torrent" . '</a>';
                }
                elseif (substr($arr["type"],0,7) == 'comment') {
                        preg_match("/comment[a-z]{0,3}([0-9]*)_id([0-9]*)/", $arr["type"], $matches);
                        $comment_id = $matches[1];
                        $id = $matches[2];
                        if (substr($arr["type"],0,10)=="commentreq") $filename = "requests.php";
                        elseif (substr($arr["type"],0,10)=="commentoff") $filename = "offers.php";
                        else $filename = "details.php";
                        $from_what = '<a href="' . $filename . '?id=' . $id . '&page=' . $page . '&viewcomm=' . $comment_id . '#comm' . $comment_id . '">' . "Commentary" . '</a>';
                }
                elseif (substr($arr["type"],0,7) == 'request')
                        $from_what = '<a href="requests.php?id=' . substr($arr["type"],7,strlen($arr["type"])) . '">' . "Demand" . '</a>';
                elseif (substr($arr["type"],0,5) == 'offer')
                        $from_what = '<a href="offers.php?id=' . substr($arr["type"],5,strlen($arr["type"])) . '">' . "Proposal" . '</a>';
                /*$tracker_template->assign_block_vars('simpaty_section.switch_count.simpaty_row', array(
                        'TOUSERID' => $touserid,
                        'RESPECT_ID' => $respect_id,
                        'RESPECT_TYPE' => $respect_type,
                        'NUMBER' => $i + (30 * (int)$_GET["page"]),
                        'TYPE' => $arr["good"]==1?'<img src="images/thum_good.gif" alt="' . "Respect" . '" title="' . "Respect" . '">':'<img src="images/thum_bad.gif" alt="' . "Anti-respect" . '" title="' . "Anti-respect" . '">',
                        'FROM_USERID' => $arr["fromuserid"],
                        'FROM_USERNAME' => $arr["fromusername"],
                        'FROM_WHAT' => $from_what,
                        'DESCRIPTION' => $arr["description"],
                        'DATE' => str_replace("\" \"", "<br />", display_date_time(strtotime($arr["respect_time"]), $CURUSER["tzoffset"])))
                );*/
                $number = $i + (30 * (int)$_GET["page"]);
                $type = $arr["good"]==1?'<img src="images/thum_good.gif" alt="' . "Respect" . '" title="' . "Respect" . '">':'<img src="images/thum_bad.gif" alt="' . "Anti-respect" . '" title="' . "Anti-respect" . '">';
                $fromuserid = $arr["fromuserid"];
                $fromusername = $arr["fromusername"];
                $description = $arr["description"];
                $respect_time = $arr["respect_time"];
?>
<tr>
<td><?=$number;?></td>
<td><?=$type;?></td>
<td><a href="account-details.php?id=<?=$fromuserid;?>"><?=$fromusername;?></a></td>
<td><?=$from_what;?></td>
<td><?=$description;?></td>
<td align="center"><?=$respect_time;?></td>
<?
if ($admin)
	print('<td><a href="simpaty.php?action=delete&amp;respect_id='.$respect_id.'&amp;touserid='.$touserid.'&amp;respect_type='.$respect_type.'&amp;returnto='.urlencode($_SERVER["REQUEST_URI"]).'"><img src="images/delete.gif" border="0" /></a></td>');
?>
</tr>
<?
        }
}
?>
</table>
<?

print($pagerbottom);
end_frame();
stdfoot();

?>
Return current item: H-tracker