mirror of
https://github.com/WhatCD/Gazelle.git
synced 2025-01-31 02:21:36 +00:00
Update sphinxapi for v2
Allow indexing by column 0 in ->to_array() Only need numeric indices in 'ip_bans' key Cache keys were completely broken on the debug pages Add bbcode missing functions to staffpms Add border to improve layout of torrent pages with postmod Fix a bug where users could download anyone's snatch/upload/seedlist regardless of paranoia settings Don't escape thread titles before caching Better BBCode URL matching Fix user search by tracker IP for ocelot data Fix bug where the same thread would show up twice in the announcements forum Update tables before sending invite email to prevent sending multiple invites
This commit is contained in:
parent
3b03508313
commit
dcaa536e58
@ -212,11 +212,6 @@ public function get_includes() {
|
||||
return get_included_files();
|
||||
}
|
||||
|
||||
public function get_cache() {
|
||||
global $Cache;
|
||||
return $Cache->CacheHits;
|
||||
}
|
||||
|
||||
public function get_cache_time() {
|
||||
global $Cache;
|
||||
return $Cache->Time;
|
||||
@ -360,18 +355,17 @@ public function constant_table($Constants=false) {
|
||||
<?
|
||||
}
|
||||
|
||||
public function cache_table($CacheData=false) {
|
||||
public function cache_table($CacheKeys=false) {
|
||||
global $Cache;
|
||||
$Header = 'Cache Keys';
|
||||
if (!is_array($CacheKeys)) {
|
||||
$CacheKeys = $this->get_cache_keys();
|
||||
if (!is_array($CacheData)) {
|
||||
$CacheData = $this->get_cache();
|
||||
$Header .= ' ('.number_format($this->get_cache_time(), 5).' ms)';
|
||||
}
|
||||
if (empty($CacheData)) {
|
||||
if (empty($CacheKeys)) {
|
||||
return;
|
||||
}
|
||||
$Header = ' '.number_format(count($CacheData)).' '.$Header.':';
|
||||
$Header = ' '.number_format(count($CacheKeys)).' '.$Header.':';
|
||||
|
||||
?>
|
||||
<table width="100%">
|
||||
@ -386,7 +380,7 @@ public function cache_table($CacheData=false) {
|
||||
<a href="#" onclick="$('#debug_cache_<?=$Key?>').toggle(); return false;"><?=display_str($Key)?></a>
|
||||
</td>
|
||||
<td align="left">
|
||||
<pre id="debug_cache_<?=$Key?>" class="hidden"><?=display_str(print_r($Cache->get_value($Key), true))?></pre>
|
||||
<pre id="debug_cache_<?=$Key?>" class="hidden"><?=display_str(print_r($Cache->get_value($Key, true), true))?></pre>
|
||||
</td>
|
||||
</tr>
|
||||
<? } ?>
|
||||
|
@ -305,7 +305,7 @@ function to_array($Key = false, $Type = MYSQLI_BOTH, $Escape = true) {
|
||||
if($Escape!==FALSE) {
|
||||
$Row = display_array($Row, $Escape);
|
||||
}
|
||||
if($Key) {
|
||||
if($Key !== false) {
|
||||
$Return[$Row[$Key]] = $Row;
|
||||
} else {
|
||||
$Return[]=$Row;
|
||||
|
@ -101,16 +101,16 @@ function valid_url($Str, $Extension = '', $Inline = false) {
|
||||
$Regex .= ')';
|
||||
$Regex .= '(:[0-9]{1,5})?'; // port
|
||||
$Regex .= '\/?'; // slash?
|
||||
$Regex .= '(\/?[0-9a-z\-_.,&=@~%\/:;()+!]+)*'; // /file
|
||||
$Regex .= '(\/?[0-9a-z\-_.,&=@~%\/:;()+!#]+)*'; // /file
|
||||
if(!empty($Extension)) {
|
||||
$Regex.=$Extension;
|
||||
}
|
||||
|
||||
// query string
|
||||
if ($Inline) {
|
||||
$Regex .= '(\?([0-9a-z\-_.,%\/\@~&=:;()+*\^$!]|\[\d*\])*)?';
|
||||
$Regex .= '(\?([0-9a-z\-_.,%\/\@~&=:;()+*\^$!#]|\[\d*\])*)?';
|
||||
} else {
|
||||
$Regex .= '(\?[0-9a-z\-_.,%\/\@[\]~&=:;()+*\^$!]*)?';
|
||||
$Regex .= '(\?[0-9a-z\-_.,%\/\@[\]~&=:;()+*\^$!#]*)?';
|
||||
}
|
||||
|
||||
$Regex .= '(#[a-z0-9\-_.,%\/\@[\]~&=:;()+*\^$!]*)?'; // #anchor
|
||||
|
@ -223,29 +223,23 @@
|
||||
}
|
||||
|
||||
// IP changed
|
||||
if($LoggedUser['IP']!=$_SERVER['REMOTE_ADDR'] && !check_perms('site_disable_ip_history')) {
|
||||
|
||||
if($LoggedUser['IP'] != $_SERVER['REMOTE_ADDR'] && !check_perms('site_disable_ip_history')) {
|
||||
if(site_ban_ip($_SERVER['REMOTE_ADDR'])) {
|
||||
error('Your IP has been banned.');
|
||||
}
|
||||
|
||||
if(!check_perms('site_disable_ip_history')) {
|
||||
$CurIP = db_string($LoggedUser['IP']);
|
||||
$NewIP = db_string($_SERVER['REMOTE_ADDR']);
|
||||
|
||||
$DB->query("UPDATE users_history_ips SET
|
||||
EndTime='".sqltime()."'
|
||||
WHERE EndTime IS NULL
|
||||
AND UserID='$LoggedUser[ID]'
|
||||
AND IP='$CurIP'");
|
||||
|
||||
$DB->query("INSERT IGNORE INTO users_history_ips
|
||||
(UserID, IP, StartTime) VALUES
|
||||
('$LoggedUser[ID]', '$NewIP', '".sqltime()."')");
|
||||
|
||||
$ipcc = geoip($_SERVER['REMOTE_ADDR']);
|
||||
// $DB->query("SELECT Code from geoip_country WHERE '".ip2long($_SERVER['REMOTE_ADDR'])."' BETWEEN StartIP AND EndIP");
|
||||
// list($ipcc) = $DB->next_record();
|
||||
$ipcc = geoip($NewIP);
|
||||
$DB->query("UPDATE users_main SET IP='$NewIP', ipcc='".$ipcc."' WHERE ID='$LoggedUser[ID]'");
|
||||
$Cache->begin_transaction('user_info_heavy_'.$LoggedUser['ID']);
|
||||
$Cache->update_row(false, array('IP' => $_SERVER['REMOTE_ADDR']));
|
||||
@ -253,7 +247,6 @@
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -398,7 +391,7 @@ function site_ban_ip($IP) {
|
||||
} else {
|
||||
$Cache->cache_value('ip_bans_lock', '1', 10);
|
||||
$DB->query("SELECT ID, FromIP, ToIP FROM ip_bans");
|
||||
$IPBans = $DB->to_array('ID');
|
||||
$IPBans = $DB->to_array(0, MYSQLI_NUM);
|
||||
$Cache->cache_value('ip_bans', $IPBans, 0);
|
||||
}
|
||||
}
|
||||
@ -1361,10 +1354,10 @@ function create_thread($ForumID, $AuthorID, $Title, $PostBody) {
|
||||
WHERE ID = '$TopicID'");
|
||||
|
||||
// Bump this topic to head of the cache
|
||||
list($Forum, $TopicIDs,,$Stickies) = $Cache->get_value('forums_'.$ForumID);
|
||||
list($Forum,,,$Stickies) = $Cache->get_value('forums_'.$ForumID);
|
||||
if (!empty($Forum)) {
|
||||
if (count($Forum) == TOPICS_PER_PAGE) {
|
||||
unset($Forum[(count($Forum)-1)]);
|
||||
if (count($Forum) == TOPICS_PER_PAGE && $Stickies < TOPICS_PER_PAGE) {
|
||||
array_pop($Forum);
|
||||
}
|
||||
$DB->query("SELECT f.IsLocked, f.IsSticky, f.NumPosts FROM forums_topics AS f WHERE f.ID ='$TopicID'");
|
||||
list($IsLocked,$IsSticky,$NumPosts) = $DB->next_record();
|
||||
@ -1385,11 +1378,17 @@ function create_thread($ForumID, $AuthorID, $Title, $PostBody) {
|
||||
)
|
||||
); //Bumped thread
|
||||
$Part3 = array_slice($Forum,$Stickies,TOPICS_PER_PAGE,true); //Rest of page
|
||||
$Forum = array_merge($Part1, $Part2, $Part3); //Merge it
|
||||
|
||||
$TopicArray=array_keys($Forum);
|
||||
$TopicIDs = implode(', ', $TopicArray);
|
||||
$Cache->cache_value('forums_'.$ForumID, array($Forum,$TopicIDs,0,$Stickies), 0);
|
||||
if ($Stickies > 0) {
|
||||
$Part1 = array_slice($Forum,0,$Stickies,true); //Stickies
|
||||
$Part3 = array_slice($Forum,$Stickies,TOPICS_PER_PAGE-$Stickies-1,true); //Rest of page
|
||||
} else {
|
||||
$Part1 = array();
|
||||
$Part3 = $Forum;
|
||||
}
|
||||
if (is_null($Part1)) { $Part1 = array(); }
|
||||
if (is_null($Part3)) { $Part3 = array(); }
|
||||
$Forum = $Part1 + $Part2 + $Part3;
|
||||
$Cache->cache_value('forums_'.$ForumID, array($Forum,'',0,$Stickies), 0);
|
||||
}
|
||||
|
||||
//Update the forum root
|
||||
@ -1875,7 +1874,7 @@ function update_tracker($Action, $Updates) {
|
||||
}
|
||||
|
||||
if($Return != "success") {
|
||||
send_irc("PRIVMSG #admin :Failed to update ocelot: ".$Err." : ".$Get);
|
||||
send_irc("PRIVMSG #tracker :Failed to update ocelot: ".$Err." : ".$Get);
|
||||
}
|
||||
return ($Return == "success");
|
||||
}
|
||||
|
@ -155,7 +155,7 @@
|
||||
LEFT JOIN users_main AS um ON um.ID=p.AuthorID
|
||||
WHERE t.ForumID='$OldForumID'
|
||||
ORDER BY t.LastPostID DESC LIMIT 1");
|
||||
list($NewLastTopic, $NewLastPostID, $NewLastTitle, $NewLastAuthorID, $NewLastAuthorName, $NewLastAddedTime, $NumPosts, $NewLocked, $NewSticky) = $DB->next_record();
|
||||
list($NewLastTopic, $NewLastPostID, $NewLastTitle, $NewLastAuthorID, $NewLastAuthorName, $NewLastAddedTime, $NumPosts, $NewLocked, $NewSticky) = $DB->next_record(MYSQLI_NUM, false);
|
||||
|
||||
$DB->query("UPDATE forums SET
|
||||
NumTopics=NumTopics-1,
|
||||
|
@ -121,13 +121,13 @@
|
||||
list($Forum,,,$Stickies) = $Forum;
|
||||
|
||||
//Remove the last thread from the index
|
||||
if (count($Forum) == TOPICS_PER_PAGE) {
|
||||
unset($Forum[(count($Forum)-1)]);
|
||||
if (count($Forum) == TOPICS_PER_PAGE && $Stickies < TOPICS_PER_PAGE) {
|
||||
array_pop($Forum);
|
||||
}
|
||||
|
||||
if ($Stickies > 0) {
|
||||
$Part1 = array_slice($Forum,0,$Stickies,true); //Stikys
|
||||
$Part3 = array_slice($Forum,$Stickies,TOPICS_PER_PAGE,true); //Rest of page
|
||||
$Part3 = array_slice($Forum,$Stickies,TOPICS_PER_PAGE-$Stickies-1,true); //Rest of page
|
||||
} else {
|
||||
$Part1 = array();
|
||||
$Part3 = $Forum;
|
||||
|
@ -432,7 +432,7 @@ function next_hour() {
|
||||
foreach($Passkeys as $Passkey) {
|
||||
update_tracker('update_user', array('passkey' => $Passkey, 'can_leech' => '1'));
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
// Put user on ratio watch if he doesn't meet the standards
|
||||
sleep(10);
|
||||
@ -458,7 +458,7 @@ function next_hour() {
|
||||
send_pm($UserID, 0, db_string("You have been put on Ratio Watch"), db_string("This happens when your ratio falls below the requirements we have outlined in the rules located [url=http://".NONSSL_SITE_URL."/rules.php?p=ratio]here[/url].\n For information about ratio watch, click the link above."), '');
|
||||
echo "Ratio watch on: $UserID\n";
|
||||
}
|
||||
|
||||
*/
|
||||
sleep(5);
|
||||
|
||||
//------------- Rescore 0.95 logs of disabled users
|
||||
@ -621,13 +621,12 @@ function next_hour() {
|
||||
t.Encoding,
|
||||
t.UserID
|
||||
FROM torrents AS t
|
||||
JOIN torrents_group AS tg ON tg.ID=t.GroupID
|
||||
LEFT JOIN artists_group AS ag ON ag.ArtistID=tg.ArtistID
|
||||
WHERE t.flags <> 1
|
||||
AND (t.last_action<'".time_minus(3600*24*28)."'
|
||||
AND t.last_action!='0000-00-00 00:00:00'
|
||||
OR t.Time<'".time_minus(3600*24*2)."'
|
||||
AND t.last_action='0000-00-00 00:00:00')");
|
||||
JOIN torrents_group AS tg ON tg.ID = t.GroupID
|
||||
LEFT JOIN artists_group AS ag ON ag.ArtistID = tg.ArtistID
|
||||
WHERE t.last_action < '".time_minus(3600*24*28)."'
|
||||
AND t.last_action != 0");
|
||||
// OR t.Time < '".time_minus(3600*24*2)."'
|
||||
// AND t.last_action = 0");
|
||||
$TorrentIDs = $DB->to_array();
|
||||
|
||||
$LogEntries = array();
|
||||
|
@ -15,7 +15,7 @@
|
||||
$Cache->delete_value('staff_pm_new_'.$LoggedUser['ID']);
|
||||
}
|
||||
|
||||
show_header('Staff PM', 'staffpm');
|
||||
show_header('Staff PM', 'staffpm,bbcode');
|
||||
|
||||
$UserInfo = user_info($UserID);
|
||||
$UserStr = format_username($UserID, $UserInfo['Username'], $UserInfo['Donor'], $UserInfo['Warned'], $UserInfo['Enabled'], $UserInfo['PermissionID']);
|
||||
|
@ -9,10 +9,9 @@
|
||||
error(403);
|
||||
}
|
||||
|
||||
if ($UserID != $LoggedUser['ID']) {
|
||||
$DB->query("SELECT m.Paranoia, p.Level FROM users_main AS m JOIN permissions AS p ON p.ID=m.PermissionID WHERE m.ID='".$UserID."'");
|
||||
list($Paranoia, $UserClass)=$DB->next_record();
|
||||
}
|
||||
$User = user_info($UserID);
|
||||
$Perms = get_permissions($User['PermissionID']);
|
||||
$UserClass = $Perms['Class'];
|
||||
|
||||
require(SERVER_ROOT.'/classes/class_torrent.php');
|
||||
require(SERVER_ROOT.'/classes/class_zip.php');
|
||||
@ -23,17 +22,17 @@
|
||||
|
||||
switch ($_GET['type']) {
|
||||
case 'uploads':
|
||||
if(!check_paranoia('uploads', $Paranoia, $UserClass, $UserID)) { error(403); }
|
||||
if(!check_paranoia('uploads', $User['Paranoia'], $UserClass, $UserID)) { error(403); }
|
||||
$SQL = "WHERE t.UserID='$UserID'";
|
||||
$Month = "t.Time";
|
||||
break;
|
||||
case 'snatches':
|
||||
if(!check_paranoia('snatched', $Paranoia, $UserClass, $UserID)) { error(403); }
|
||||
if(!check_paranoia('snatched', $User['Paranoia'], $UserClass, $UserID)) { error(403); }
|
||||
$SQL = "JOIN xbt_snatched AS x ON t.ID=x.fid WHERE x.uid='$UserID'";
|
||||
$Month = "FROM_UNIXTIME(x.tstamp)";
|
||||
break;
|
||||
case 'seeding':
|
||||
if(!check_paranoia('seeding', $Paranoia, $UserClass, $UserID)) { error(403); }
|
||||
if(!check_paranoia('seeding', $User['Paranoia'], $UserClass, $UserID)) { error(403); }
|
||||
$SQL = "JOIN xbt_files_users AS xfu ON t.ID = xfu.fid WHERE xfu.uid='$UserID' AND xfu.remaining = 0";
|
||||
$Month = "FROM_UNIXTIME(xfu.mtime)";
|
||||
break;
|
||||
@ -57,7 +56,8 @@
|
||||
FROM torrents as t
|
||||
JOIN torrents_group AS tg ON t.GroupID=tg.ID
|
||||
LEFT JOIN torrents_files AS f ON t.ID=f.TorrentID
|
||||
".$SQL);
|
||||
".$SQL."
|
||||
GROUP BY t.ID");
|
||||
$Downloads = $DB->to_array(false,MYSQLI_NUM,false);
|
||||
$Artists = get_artists($DB->collect('GroupID'));
|
||||
|
||||
|
@ -260,7 +260,7 @@ function num_compare($Field, $Operand, $Num1, $Num2 = ''){
|
||||
if(!empty($_GET['tracker_ip'])){
|
||||
$Distinct = 'DISTINCT ';
|
||||
$Join[]=' JOIN xbt_files_users AS xfu ON um1.ID=xfu.uid ';
|
||||
$Where[]= ' xfu.ipa '.$Match.wrap((int) ip2long($_GET['tracker_ip']));
|
||||
$Where[]= ' (xfu.ipa '.$Match.wrap((int) ip2long($_GET['tracker_ip'])).' OR xfu.ip '.$Match.wrap($_GET['tracker_ip']).')';
|
||||
}
|
||||
|
||||
|
||||
|
@ -69,19 +69,19 @@
|
||||
$SiteName Staff
|
||||
EOT;
|
||||
|
||||
send_email($CurEmail, 'You have been invited to '.SITE_NAME, $Message,'noreply');
|
||||
|
||||
$DB->query("INSERT INTO invites
|
||||
(InviterID, InviteKey, Email, Expires) VALUES
|
||||
('$LoggedUser[ID]', '$InviteKey', '".db_string($CurEmail)."', '$InviteExpires')");
|
||||
|
||||
if (!check_perms('site_send_unlimited_invites')) {
|
||||
$DB->query("UPDATE users_main SET Invites=Invites-1 WHERE ID='$LoggedUser[ID]'");
|
||||
$DB->query("UPDATE users_main SET Invites=GREATEST(Invites,1)-1 WHERE ID='$LoggedUser[ID]'");
|
||||
$Cache->begin_transaction('user_info_heavy_'.$LoggedUser['ID']);
|
||||
$Cache->update_row(false, array('Invites'=>'-1'));
|
||||
$Cache->commit_transaction(0);
|
||||
}
|
||||
|
||||
send_email($CurEmail, 'You have been invited to '.SITE_NAME, $Message,'noreply');
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -754,6 +754,7 @@ ul.poll li.graph {
|
||||
}
|
||||
.torrent_table tr.group_torrent {
|
||||
background-color:#fbfaf8;
|
||||
border-bottom:1px solid #efefef;
|
||||
}
|
||||
|
||||
tr.group_torrent td,
|
||||
|
Loading…
Reference in New Issue
Block a user