Location: PHPKode > projects > Trunk.net > viewrequests.php
<?php
ob_start("ob_gzhandler");
require_once("include/functions.php");
hit_start();
dbconn();
loggedinorreturn();

stdhead("Requests Page");

begin_main_frame();

print("<h1><center>Ñåêöèÿ ñúñ Çàÿâêè</h1></center>\n");
print("<p><a href=requests.php>Íàïðàâè çàÿâêà</a>&nbsp;&nbsp;<a href=viewrequests.php?requestorid=$CURUSER[id]>Âèæ ìîèòå çàÿâêè</a></p>");
print("<p>Ñîðòèðàé ïî <a href=" . $_SERVER[PHP_SELF] . "?category=" . $_GET[category] . "&filter=" . $_GET[filter] . "&sort=votes>Ãëàñîâå</a>, <a href=". $_SERVER[PHP_SELF] ."?category=" . $_GET[category] . "&filter=" . $_GET[filter] . "&sort=request>Èìå íà çàÿâêàòà</a>, èëè <a href=" . $_SERVER[PHP_SELF] ."?category=" . $_GET[category] . "&filter=" . $_GET[filter] . "&sort=added>Äàòà íà äîáàâÿíå</a></p>");
print("<p><a href=". $_SERVER[PHP_SELF] ."?category=" . $_GET[category] . "&sort=" . $_GET[sort] . "&filter=true>Ñêðèé èçïúëíåíèòå</a></p>");
$categ = $_GET["category"];
$requestorid = $_GET["requestorid"];
$sort = $_GET["sort"];
$search = $_GET["search"];
$filter = $_GET["filter"];

$search = " AND requests.request like '%$search%' ";


if ($sort == "votes")
$sort = " order by hits desc ";
else if ($sort == "request")
$sort = " order by request ";
else
$sort = " order by added desc ";


if ($filter == "true")
$filter = " AND requests.filledby = 0 ";
else
$filter = "";


if ($requestorid <> NULL)
{
if (($categ <> NULL) && ($categ <> 0))
 $categ = "WHERE requests.cat = " . $categ . " AND requests.userid = " . $requestorid;
else
 $categ = "WHERE requests.userid = " . $requestorid;
}

else if ($categ == 0)
$categ = '';
else
$categ = "WHERE requests.cat = " . $categ;

/*
if ($categ == 0)
$categ = 'WHERE requests.cat > 0 ';
else
$categ = "WHERE requests.cat = " . $categ;
*/


$res = mysql_query("SELECT count(requests.id) FROM requests inner join categories on requests.cat = categories.id inner join users on requests.userid = users.id  $categ $filter $search") or die(mysql_error());
$row = mysql_fetch_array($res);
$count = $row[0];


$perpage = 50;

 list($pagertop, $pagerbottom, $limit) = pager($perpage, $count, $_SERVER["PHP_SELF"] ."?" . "category=" . $_GET["category"] . "&sort=" . $_GET["sort"] . "&" );

echo $pagertop;

$res = mysql_query("SELECT users.downloaded, users.uploaded, users.username, requests.filled, requests.filledby, requests.id, requests.userid, requests.request, requests.added, requests.hits, 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();
$num = mysql_num_rows($res);



print("<form method=get action=viewrequests.php>");
?>
<select name="category">
<option value="0">(Ïîêàæè âñè÷êè)</option>
<?

$cats = genrelist();
$catdropdown = "";
foreach ($cats as $cat) {
   $catdropdown .= "<option value=\"" . $cat["id"] . "\"";
   $catdropdown .= ">" . htmlspecialchars($cat["name"]) . "</option>\n";
}

?>
<?= $catdropdown ?>
</select>
<?
print("<input type=submit align=center value=Change style='height: 22px'>\n");
print("</form>\n<p></p>");

print("<form method=get action=viewrequests.php>");
print("<b>Òúðñè çà çàÿâêè: </b><input type=text size=40 name=search>");
print("<input type=submit align=center value=Òúðñè style='height: 22px'>\n");
print("</form><p></p><br />");





print("<form method=post action=takedelreq.php>");
print("<table border=1 width=950 cellspacing=0 cellpadding=5>\n");
print("<tr><td class=colhead align=left>Çàÿâêè</td><td class=colhead align=center>Êàòåãîðèÿ</td><td class=colhead align=center width=150>Äîáàâåíà íà</td><td class=colhead align=center>Äîáàâåíà îò</td><td class=colhead align=center>Èçïúëíåíà</td><td class=colhead align=center>Èçïúëíåíà îò</td><td class=colhead align=center>Ãëàñîâå</td><td class=colhead align=center>Èçòðèé</td></tr>\n");
for ($i = 0; $i < $num; ++$i)
{



 $arr = mysql_fetch_assoc($res);

if ($arr["downloaded"] > 0)
   {
     $ratio = number_format($arr["uploaded"] / $arr["downloaded"], 2);
     $ratio = "<font color=" . get_ratio_color($ratio) . "><b>$ratio</b></font>";
   }
   else if ($arr["uploaded"] > 0)
       $ratio = "Inf.";
   else
       $ratio = "---";


$res2 = mysql_query("SELECT username from users where id=" . $arr[filledby]);
$arr2 = mysql_fetch_assoc($res2);  
if ($arr2[username])
$filledby = $arr2[username];
else
$filledby = " ";       
$addedby = "<td style='padding: 0px' align=center><a href=userdetails.php?id=$arr[userid]><b>$arr[username] ($ratio)</b></a></td>";
$filled = $arr[filled];
if ($filled)
$filled = "<a href=$filled><font color=green><b>Yes</b></font></a>"; 
else
$filled = "<a href=reqdetails.php?id=$arr[id]><font color=red><b>No</b></font></a>";
 print("<tr><td align=left><a href=reqdetails.php?id=$arr[id]><b>$arr[request]</b></a></td>" .
 "<td align=center>$arr[cat]</td><td align=center>$arr[added]</td>$addedby<td>$filled</td><td><a href=userdetails.php?id=$arr[filledby]><b>$arr2[username]</b></a></td><td><a href=votesview.php?requestid=$arr[id]><b>$arr[hits]</b></a></td><td><input type=\"checkbox\" name=\"delreq[]\" value=\"" . $arr[id] . "\" /></td></tr>\n");
}

print("</table>\n");

print("<p><input type=submit value=Delete></p>");
print("</form>");

echo $pagerbottom;

die;

?>
Return current item: Trunk.net