forked from pouetnet/pouet-www-v2.0
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtoplist.php
130 lines (114 loc) · 3.06 KB
/
toplist.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<?
require_once("bootstrap.inc.php");
class PouetBoxTopList extends PouetBox {
function PouetBoxTopList() {
parent::__construct();
$this->uniqueID = "pouetbox_toplist";
$this->formifier = new Formifier();
$row = SQLLib::selectRow("DESC prods type");
preg_match_all("/'([^']+)'/",$row->Type,$m);
$this->types = array();
$this->types[""] = "- none - ";
foreach($m[1] as $v) $this->types[$v] = $v;
}
function LoadFromDB()
{
global $PLATFORMS;
$plat = array();
$plat[""] = "- none -";
foreach($PLATFORMS as $k=>$v) $plat[$k] = $v["name"];
uasort($plat,"strcasecmp");
$this->fields = array(
"type"=>array(
"name"=>"type",
"type"=>"select",
//"multiple"=>true,
"assoc"=>true,
"fields"=>$this->types,
"info"=>" ",
//"required"=>true,
),
"platform"=>array(
"name"=>"platform",
"type"=>"select",
//"multiple"=>true,
"assoc"=>true,
"fields"=>$plat,
"info"=>" ",
//"required"=>true,
),
"days"=>array(
"name"=>"days to go back",
"type"=>"number",
"value"=>0,
"info"=>"0 means alltime",
),
"limit"=>array(
"name"=>"number of prods",
"type"=>"number",
"value"=>10,
"max"=>50,
),
);
if ($_GET)
{
foreach($_GET as $k=>$v)
if ($this->fields[$k])
$this->fields[$k]["value"] = $v;
}
$s = new BM_Query("prods");
if ($_GET["days"])
{
$s->AddOrder("(prods.views/((NOW()-prods.quand)/100000)+prods.views)*prods.voteavg*prods.voteup DESC");
$s->AddWhere(sprintf_esc("prods.quand > DATE_SUB(NOW(),INTERVAL %d DAY)",$_GET["days"]));
}
else
{
$s->AddOrder("prods.rank");
$s->AddWhere("prods.rank > 0");
}
if ($_GET["type"])
{
$s->AddWhere(sprintf_esc("FIND_IN_SET('%s',prods.type)>0",$_GET["type"]));
}
if ($_GET["platform"])
{
$s->AddJoin("","prods_platforms",sprintf_esc("prods_platforms.prod = prods.id AND prods_platforms.platform=%d",$_GET["platform"]));
}
$limit = (int)($_GET["limit"] ? $_GET["limit"] : 10);
$limit = min($limit,50);
$limit = max($limit,10);
$s->SetLimit($limit);
$this->prods = $s->perform();
}
function RenderTitle()
{
echo "<div class='selector'>";
echo "<form action='toplist.php' method='get'>\n";
$this->formifier->RenderForm( $this->fields );
echo " <input type='submit' value='Submit'/>\n";
echo "</form>\n";
echo "</div>";
}
function RenderBody()
{
echo "<ul class='boxlist'>\n";
$n = 1;
foreach($this->prods as $p)
{
printf(" <li>%d. %s</li>\n",$n++,$p->RenderSingleRowShort());
}
echo "</ul>\n";
}
};
$TITLE = "top of the trumpets";
require_once("include_pouet/header.php");
require("include_pouet/menu.inc.php");
echo "<div id='content'>\n";
$box = new PouetBoxTopList();
$box->Load();
$box->Render();
echo "</div>\n";
require("include_pouet/menu.inc.php");
require_once("include_pouet/footer.php");
?>