mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-05-14 20:17:35 +08:00
support pg
This commit is contained in:
+6
-4
@@ -22,15 +22,17 @@ $is_rulelang = get_single_value("language","rule_lang","WHERE id = ".sqlesc($lan
|
||||
if (!$is_rulelang){
|
||||
$lang_id = 6; //English
|
||||
}
|
||||
$res = sql_query("SELECT `id`, `link_id`, `question`, `flag` FROM `faq` WHERE `type`='categ' AND `lang_id` = ".sqlesc($lang_id)." ORDER BY `order` ASC");
|
||||
while ($arr = mysql_fetch_array($res)) {
|
||||
//$res = sql_query("SELECT id, link_id, question, flag FROM faq WHERE type='categ' AND lang_id = ".sqlesc($lang_id)." ORDER BY order ASC");
|
||||
$res = \App\Models\Faq::query()->where('type', 'categ')->where('lang_id', $lang_id)->orderBy('order')->get()->toArray();
|
||||
foreach ($res as $arr) {
|
||||
$faq_categ[$arr['link_id']]['title'] = $arr['question'];
|
||||
$faq_categ[$arr['link_id']]['flag'] = $arr['flag'];
|
||||
$faq_categ[$arr['link_id']]['link_id'] = $arr['link_id'];
|
||||
}
|
||||
|
||||
$res = sql_query("SELECT `id`, `link_id`, `question`, `answer`, `flag`, `categ` FROM `faq` WHERE `type`='item' AND `lang_id` = ".sqlesc($lang_id)." ORDER BY `order` ASC");
|
||||
while ($arr = mysql_fetch_array($res)) {
|
||||
//$res = sql_query("SELECT id, link_id, question, answer, flag, categ FROM faq WHERE type='item' AND lang_id = ".sqlesc($lang_id)." ORDER BY order ASC");
|
||||
$res = \App\Models\Faq::query()->where('type', 'item')->where('lang_id', $lang_id)->get()->toArray();
|
||||
foreach ($res as $arr) {
|
||||
$faq_categ[$arr['categ']]['items'][$arr['id']]['question'] = $arr['question'];
|
||||
$faq_categ[$arr['categ']]['items'][$arr['id']]['answer'] = $arr['answer'];
|
||||
$faq_categ[$arr['categ']]['items'][$arr['id']]['flag'] = $arr['flag'];
|
||||
|
||||
+1
-1
@@ -671,7 +671,7 @@ if ($action == "viewtopic")
|
||||
$pagerbottom = "<p align=\"center\">".$pagerstr."<br />".$pager."</p>\n";
|
||||
//------ Get posts
|
||||
|
||||
$res = sql_query("SELECT * FROM posts $where ORDER BY id LIMIT $offset,$perpage") or sqlerr(__FILE__, __LINE__);
|
||||
$res = sql_query("SELECT * FROM posts $where ORDER BY id LIMIT $perpage offset $offset") or sqlerr(__FILE__, __LINE__);
|
||||
|
||||
stdhead($lang_forums['head_view_topic']." \"".$orgsubject."\"");
|
||||
begin_main_frame("",true);
|
||||
|
||||
+1
-1
@@ -91,7 +91,7 @@ end_frame();
|
||||
|
||||
//--------------------- forum moderators section ---------------------------//
|
||||
$ppl = '';
|
||||
$res = sql_query("SELECT forummods.userid AS userid, users.last_access, users.country FROM forummods LEFT JOIN users ON forummods.userid = users.id GROUP BY userid ORDER BY forummods.forumid, forummods.userid") or sqlerr();
|
||||
$res = sql_query("SELECT forummods.userid AS userid, users.last_access, users.country FROM forummods LEFT JOIN users ON forummods.userid = users.id GROUP BY userid,users.last_access, users.country,forummods.forumid, forummods.userid ORDER BY forummods.forumid, forummods.userid") or sqlerr();
|
||||
while ($arr = mysql_fetch_assoc($res))
|
||||
{
|
||||
$countryrow = get_country_row($arr['country']);
|
||||
|
||||
@@ -139,7 +139,7 @@ if ($piecesCount > $maxPieceCount && $idealPiecesCount < $maxPieceCount) {
|
||||
bark('Too many pieces');
|
||||
}
|
||||
$infohash = $dict->getInfoHashV1ForAnnounce();
|
||||
$exists = \App\Models\Torrent::query()->where('info_hash', $infohash)->first(['id']);
|
||||
$exists = \App\Models\Torrent::query()->whereInfoHash($infohash)->first(['id']);
|
||||
if ($exists) {
|
||||
// bark($lang_takeupload['std_torrent_existed']);
|
||||
nexus_redirect(sprintf("details.php?id=%d&existed=1", $exists['id']));
|
||||
|
||||
+14
-7
@@ -484,7 +484,14 @@ $Cache->add_whole_row();
|
||||
|
||||
if ($type == 1)
|
||||
{
|
||||
$mainquery = "SELECT id as userid, username, added, uploaded, downloaded, uploaded / (UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(added)) AS upspeed, downloaded / (UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(added)) AS downspeed FROM users WHERE enabled = 'yes'";
|
||||
if (\Nexus\Database\NexusDB::isMysql()) {
|
||||
$speedStr = "uploaded / (UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(added)) AS upspeed, downloaded / (UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(added)) AS downspeed";
|
||||
} else if (\Nexus\Database\NexusDB::isPgsql()) {
|
||||
$speedStr = "uploaded::numeric / (EXTRACT(EPOCH FROM NOW()) - EXTRACT(EPOCH FROM added)) AS upspeed";
|
||||
} else {
|
||||
throw new \RuntimeException('Not supported database.');
|
||||
}
|
||||
$mainquery = "SELECT id as userid, username, added, uploaded, downloaded, $speedStr FROM users WHERE enabled = 'yes'";
|
||||
|
||||
|
||||
if ($limit == 10 || $subtype == "ul")
|
||||
@@ -581,7 +588,7 @@ elseif ($type == 3)
|
||||
{
|
||||
if ($limit == 10 || $subtype == "us")
|
||||
{
|
||||
$r = sql_query("SELECT name, flagpic, COUNT(users.country) as num FROM countries LEFT JOIN users ON users.country = countries.id GROUP BY name ORDER BY num DESC LIMIT $limit") or sqlerr();
|
||||
$r = sql_query("SELECT name, flagpic, COUNT(users.country) as num FROM countries LEFT JOIN users ON users.country = countries.id GROUP BY name,flagpic ORDER BY num DESC LIMIT $limit") or sqlerr();
|
||||
countriestable($r, $lang_topten['text_top']."$limit ".$lang_topten['text_countries_users']. ($limit == 10 ? " <font class=\"small\"> - [<a class=\"altlink\" href=\"topten.php?type=$type&lim=25&subtype=us\">Top 25</a>]</font>" : ""),$lang_topten['col_users']);
|
||||
}
|
||||
|
||||
@@ -630,13 +637,13 @@ elseif ($type == 5)
|
||||
{
|
||||
if ($limit == 10 || $subtype == "mtop")
|
||||
{
|
||||
$r = sql_query( "SELECT users_topics.userid, users_topics.usertopics, COUNT(posts.id) as userposts FROM (SELECT users.id as userid, COUNT(topics.id) as usertopics from users LEFT JOIN topics ON users.id = topics.userid GROUP BY users.id) as users_topics LEFT JOIN posts ON users_topics.userid = posts.userid GROUP BY users_topics.userid ORDER BY usertopics DESC LIMIT $limit") or sqlerr();
|
||||
$r = sql_query( "SELECT users_topics.userid, users_topics.usertopics, COUNT(posts.id) as userposts FROM (SELECT users.id as userid, COUNT(topics.id) as usertopics from users LEFT JOIN topics ON users.id = topics.userid GROUP BY users.id) as users_topics LEFT JOIN posts ON users_topics.userid = posts.userid GROUP BY users_topics.userid, users_topics.usertopics ORDER BY usertopics DESC LIMIT $limit") or sqlerr();
|
||||
postable($r, $lang_topten['text_top']."$limit ".$lang_topten['text_most_topic'] . ($limit == 10 ? " <font class=\"small\"> - [<a class=\"altlink\" href=\"topten.php?type=$type&lim=100&subtype=mtop\">".$lang_topten['text_one_hundred']."</a>] - [<a class=\"altlink\" href=\"topten.php?type=$type&lim=250&subtype=mtop\">".$lang_topten['text_top_250']."</a>]</font>" : ""));
|
||||
}
|
||||
|
||||
if ($limit == 10 || $subtype == "mpos")
|
||||
{
|
||||
$r = sql_query( "SELECT users_topics.userid, users_topics.usertopics, COUNT(posts.id) as userposts FROM (SELECT users.id as userid, COUNT(topics.id) as usertopics from users LEFT JOIN topics ON users.id = topics.userid GROUP BY users.id) as users_topics LEFT JOIN posts ON users_topics.userid = posts.userid GROUP BY users_topics.userid ORDER BY userposts DESC LIMIT $limit") or sqlerr();
|
||||
$r = sql_query( "SELECT users_topics.userid, users_topics.usertopics, COUNT(posts.id) as userposts FROM (SELECT users.id as userid, COUNT(topics.id) as usertopics from users LEFT JOIN topics ON users.id = topics.userid GROUP BY users.id) as users_topics LEFT JOIN posts ON users_topics.userid = posts.userid GROUP BY users_topics.userid, users_topics.usertopics ORDER BY userposts DESC LIMIT $limit") or sqlerr();
|
||||
postable($r, $lang_topten['text_top']."$limit ".$lang_topten['text_most_post'] . ($limit == 10 ? " <font class=\"small\"> - [<a class=\"altlink\" href=\"topten.php?type=$type&lim=100&subtype=mpos\">".$lang_topten['text_one_hundred']."</a>] - [<a class=\"altlink\" href=\"topten.php?type=$type&lim=250&subtype=mpos\">".$lang_topten['text_top_250']."</a>]</font>" : ""));
|
||||
}
|
||||
|
||||
@@ -704,17 +711,17 @@ if ($enabledonation == 'yes'){
|
||||
|
||||
if ($limit == 10 || $subtype == "mcli")
|
||||
{
|
||||
$r = sql_query( "SELECT agent_allowed_family.family as client_name, COUNT(users.id) as client_num from users RIGHT JOIN agent_allowed_family ON agent_allowed_family.id = users.clientselect GROUP BY clientselect ORDER BY client_num DESC LIMIT $limit") or sqlerr();
|
||||
$r = sql_query( "SELECT agent_allowed_family.family as client_name, COUNT(users.id) as client_num from users RIGHT JOIN agent_allowed_family ON agent_allowed_family.id = users.clientselect GROUP BY clientselect, client_name ORDER BY client_num DESC LIMIT $limit") or sqlerr();
|
||||
clienttable($r, $lang_topten['text_top']."$limit ".$lang_topten['text_most_client'] . ($limit == 10 ? " <font class=\"small\"> - [<a class=\"altlink\" href=\"topten.php?type=$type&lim=100&subtype=mcli\">".$lang_topten['text_one_hundred']."</a>] - [<a class=\"altlink\" href=\"topten.php?type=$type&lim=250&subtype=mcli\">".$lang_topten['text_top_250']."</a>]</font>" : ""));
|
||||
}
|
||||
if ($limit == 10 || $subtype == "ss")
|
||||
{
|
||||
$r = sql_query( "SELECT stylesheets.name as stylesheet_name, COUNT(users.id) as stylesheet_num from users JOIN stylesheets ON stylesheets.id = users.stylesheet GROUP BY stylesheet ORDER BY stylesheet_num DESC LIMIT $limit") or sqlerr();
|
||||
$r = sql_query( "SELECT stylesheets.name as stylesheet_name, COUNT(users.id) as stylesheet_num from users JOIN stylesheets ON stylesheets.id = users.stylesheet GROUP BY stylesheet, stylesheet_name ORDER BY stylesheet_num DESC LIMIT $limit") or sqlerr();
|
||||
stylesheettable($r, $lang_topten['text_top']."$limit ".$lang_topten['text_most_stylesheet'] . ($limit == 10 ? "<font class=\"small\"> - [<a class=\"altlink\" href=\"topten.php?type=$type&lim=25&subtype=ss\">Top 25</a>] - [<a class=\"altlink\" href=\"topten.php?type=$type&lim=50&subtype=ss\">Top 50</a>]</font>" : ""));
|
||||
}
|
||||
if ($limit == 10 || $subtype == "lang")
|
||||
{
|
||||
$r = sql_query( "SELECT language.lang_name as lang_name, COUNT(users.id) as lang_num from users JOIN language ON language.id = users.lang WHERE site_lang=1 GROUP BY lang ORDER BY lang_num DESC LIMIT $limit") or sqlerr();
|
||||
$r = sql_query( "SELECT language.lang_name as lang_name, COUNT(users.id) as lang_num from users JOIN language ON language.id = users.lang WHERE site_lang=1 GROUP BY lang, lang_name ORDER BY lang_num DESC LIMIT $limit") or sqlerr();
|
||||
languagetable($r, $lang_topten['text_top']."$limit ".$lang_topten['text_most_language'] . ($limit == 10 ? "<font class=\"small\"> - [<a class=\"altlink\" href=\"topten.php?type=$type&lim=25&subtype=lang\">Top 25</a>]</font>" : ""));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,12 +40,14 @@ else
|
||||
{
|
||||
$lastseen .= " (" . gettime($lastseen, true, false, true).")";
|
||||
}
|
||||
$res = sql_query("SELECT COUNT(*) FROM comments WHERE user=" . $user['id']) or sqlerr();
|
||||
$arr3 = mysql_fetch_row($res);
|
||||
$torrentcomments = $arr3[0];
|
||||
$res = sql_query("SELECT COUNT(*) FROM posts WHERE userid=" . $user['id']) or sqlerr();
|
||||
$arr3 = mysql_fetch_row($res);
|
||||
$forumposts = $arr3[0];
|
||||
//$res = sql_query("SELECT COUNT(*) FROM comments WHERE user=" . $user['id']) or sqlerr();
|
||||
//$arr3 = mysql_fetch_row($res);
|
||||
//$torrentcomments = $arr3[0];
|
||||
$torrentcomments = \App\Models\Comment::query()->where('user', $user['id'])->count();
|
||||
//$res = sql_query("SELECT COUNT(*) FROM posts WHERE userid=" . $user['id']) or sqlerr();
|
||||
//$arr3 = mysql_fetch_row($res);
|
||||
//$forumposts = $arr3[0];
|
||||
$forumposts = \App\Models\Post::query()->where('userid', $user['id'])->count();
|
||||
|
||||
$arr = get_country_row($user['country']);
|
||||
$country = "<img src=\"pic/flag/".$arr['flagpic']."\" alt=\"".$arr['name']."\" style='margin-left: 8pt' />";
|
||||
@@ -240,7 +242,7 @@ if (user_can('userprofile') || $user["id"] == $CURUSER["id"])
|
||||
tr_small($lang_userdetails['row_ip_address'], hide_text($ip.$locationinfo.$seedBoxIcon), 1);
|
||||
}
|
||||
$clientselect = '';
|
||||
$res = sql_query("SELECT peer_id, agent, ipv4, ipv6, port FROM peers WHERE userid = {$user['id']} GROUP BY agent, ipv4, ipv6, port") or sqlerr();
|
||||
$res = sql_query("SELECT peer_id, agent, ipv4, ipv6, port FROM peers WHERE userid = {$user['id']} GROUP BY peer_id, agent, ipv4, ipv6, port") or sqlerr();
|
||||
if (mysql_num_rows($res) > 0)
|
||||
{
|
||||
$clientselect .= "<table border='1' cellspacing='0' cellpadding='5'><tr><td class='colhead'>Agent</td><td class='colhead'>IPV4</td><td class='colhead'>IPV6</td><td class='colhead'>Port</td></tr>";
|
||||
|
||||
Reference in New Issue
Block a user