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

loggedinorreturn();

stdhead("Requests Page");

if (get_user_class() < 3)
{
 print("<h1>Ñúæàëÿâàì</h2><p>Òðÿáâà äà ñòå Power User èëè ïî-ãîðåí êëàñ ïîòðåáèòåë, çà äà âèäèòå çàÿâêèòå! Çà ïîâå÷å èíôîðìàöèÿ âèæòå <a href=faq.php><b>FAQ</b></a></p>");
 die();
}

print("<h1>Äîáàâÿíå íà çàÿâêà</h1><p>Çà äà âèäèòå âñè÷êè çàÿâêè, íàòèñíåòå <a href=viewrequests.php>òóê</a></p>\n");

/*

$res = mysql_query("SELECT users.username, requests.id, requests.userid, requests.request, requests.added, categories.name as cat FROM requests inner join categories on requests.cat = categories.id inner join users on requests.userid = users.id order by requests.id desc LIMIT 10") or sqlerr();
$num = mysql_num_rows($res);

print("<table border=1 width=800 cellspacing=0 cellpadding=5>\n");
print("<tr><td class=colhead align=left width=400>Requested</td><td class=colhead align=center width=100>Category</td><td class=colhead align=center>Added</td><td class=colhead align=center width=100>Requested By</td></tr>\n");
for ($i = 0; $i < $num; ++$i)
{
 $arr = mysql_fetch_assoc($res);
 {

     $addedby = "<td style='padding: 0px' align=center><b><a href=userdetails.php?id=$arr[userid]>$arr[username]</a></b></td>";
 }
 
 print("<tr><td align=left><a href=reqdetails.php?id=$arr[id]><b>$arr[request]</b></a></td><td align=left>$arr[cat]</td>" .
 "<td align=center>$arr[added]</td>".
   "$addedby</tr>\n");
}
print("<tr><td align=center colspan=4><form method=\"get\" action=viewrequests.php><input type=\"submit\" value=\"Show All\" style='height: 22px' /></form></td></tr>\n");
print("</table>\n");

*/

print("<br>\n");

$where = "WHERE userid = " . $CURUSER["id"] . "";
$res2 = mysql_query("SELECT * FROM requests $where") or sqlerr();
$num2 = mysql_num_rows($res2);

/*print("<table border=1 width=800 cellspacing=0 cellpadding=5>\n");
print("<tr><td class=colhead align=left width=400>Your Added Requests</td><td class=colhead align=center>Category</td><td class=colhead align=center>Added</td></tr>\n");
for ($i = 0; $i < $num; ++$i)
{
 $arr = mysql_fetch_assoc($res2);
 
 print("<tr><td align=left><b>$arr[request]</b></td><td align=left>$arr[cat]</td>" .
 "<td align=center>$arr[added]</td>".
   "</tr>\n");
}
print("</table>");

print("<br>\n"); 
*/
?>



<table border=1 width=800 cellspacing=0 cellpadding=5>
<tr><td class=colhead align=left>Ïîòúðñè çà òîðåíòà ïðåäè äà äàâàø çàÿâêà</td></tr>
<tr><td align=left><form method="get" action=browse.php>
<input type="text" name="search" size="40" value="<?= htmlspecialchars($searchstr) ?>" />
âúâ
<select name="cat">
<option value="0">(Âñè÷êè âèäîâå)</option>
<?


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

$deadchkbox = "<input type=\"checkbox\" name=\"incldead\" value=\"1\"";
if ($_GET["incldead"])
   $deadchkbox .= " checked=\"checked\"";
$deadchkbox .= " /> âêëþ÷èòåëíî è íåðàáîòåùèòå\n";

?>
<?= $catdropdown ?>
</select>
<?= $deadchkbox ?>
<input type="submit" value="Òúðñè!" style='height: 18px' />
</form>
</td></tr></table>

<? print("<br>\n");

print("<form method=post action=takerequest.php><a name=add id=add></a>\n");
print("<table border=1 width=800 cellspacing=0 cellpadding=5>\n");
print("<tr><td align=center><b>Çàãëàâèå: </b><input type=text size=40 name=requesttitle>");
?>

<select name="category">
  <option value="0">(Èçáåðè êàòåãîðèÿ)</option>
  <option value="1">Appz/PC ISO</option>
  <option value="4">Movies/DVD-R</option>
  <option value="5">Music</option>
  <option value="6">TV</option>
  <option value="7">Games/PC ISO</option>
  <option value="9">XXX</option>
  <option value="12">Games/PC Rips</option>
  <option value="17">Movies/SVCD</option>
  <option value="19">Music Videos</option>
  <option value="20">Movies/XviD</option>
  <option value="21">Games/PS2</option>
  <option value="22">Appz/misc</option>
<?

$res2 = mysql_query("SELECT id, name FROM categories where name like order by name");
$num = mysql_num_rows($res2);
$catdropdown2 = "";
for ($i = 0; $i < $num; ++$i)
   {
 $cats2 = mysql_fetch_assoc($res2);  
     $catdropdown2 .= "<option value=\"" . $cats2["id"] . "\"";
     $catdropdown2 .= ">" . htmlspecialchars($cats2["name"]) . "</option>\n";
   }

?>
<?= $catdropdown2 ?>
</select>

<? print("<br>\n");

print("<tr><td align=center>Äîïúëíèòåëíà èíôîðìàöèÿ (íå å çàäúëæèòåëíà)
<br><textarea name=descr rows=5 cols=100></textarea>\n");
print("<tr><td align=center><input type=submit value=Äîáàâè! style='height: 22px'>\n");
print("</form>\n");
print("</table>\n");

$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>Äà</b></font></a>"; 
else
$filled = "<a href=reqdetails.php?id=$arr[id]><font color=red><b>Íå</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=Èçòðèé></p>");
print("</form>");

echo $pagerbottom;

stdfoot();
die;

?>
Return current item: Trunk.net