本文整理汇总了PHP中sqltime函数的典型用法代码示例。如果您正苦于以下问题:PHP sqltime函数的具体用法?PHP sqltime怎么用?PHP sqltime使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sqltime函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: edit
/**
* Edit a comment
* @param int $PostID
* @param string $NewBody
* @param bool $SendPM If true, send a PM to the author of the comment informing him about the edit
* @todo move permission check out of here/remove hardcoded error(404)
*/
public static function edit($PostID, $NewBody, $SendPM = false)
{
$QueryID = G::$DB->get_query_id();
G::$DB->query("\n\t\t\tSELECT\n\t\t\t\tBody,\n\t\t\t\tAuthorID,\n\t\t\t\tPage,\n\t\t\t\tPageID,\n\t\t\t\tAddedTime\n\t\t\tFROM comments\n\t\t\tWHERE ID = {$PostID}");
if (!G::$DB->has_results()) {
return false;
}
list($OldBody, $AuthorID, $Page, $PageID, $AddedTime) = G::$DB->next_record();
if (G::$LoggedUser['ID'] != $AuthorID && !check_perms('site_moderate_forums')) {
return false;
}
G::$DB->query("\n\t\t\tSELECT CEIL(COUNT(ID) / " . TORRENT_COMMENTS_PER_PAGE . ") AS Page\n\t\t\tFROM comments\n\t\t\tWHERE Page = '{$Page}'\n\t\t\t\tAND PageID = {$PageID}\n\t\t\t\tAND ID <= {$PostID}");
list($CommPage) = G::$DB->next_record();
// Perform the update
G::$DB->query("\n\t\t\tUPDATE comments\n\t\t\tSET\n\t\t\t\tBody = '" . db_string($NewBody) . "',\n\t\t\t\tEditedUserID = " . G::$LoggedUser['ID'] . ",\n\t\t\t\tEditedTime = '" . sqltime() . "'\n\t\t\tWHERE ID = {$PostID}");
// Update the cache
$CatalogueID = floor((TORRENT_COMMENTS_PER_PAGE * $CommPage - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
G::$Cache->delete_value($Page . '_comments_' . $PageID . '_catalogue_' . $CatalogueID);
if ($Page == 'collages') {
// On collages, we also need to clear the collage key (collage_$CollageID), because it has the comments in it... (why??)
G::$Cache->delete_value('collage_' . $PageID);
}
G::$DB->query("\n\t\t\tINSERT INTO comments_edits (Page, PostID, EditUser, EditTime, Body)\n\t\t\tVALUES ('{$Page}', {$PostID}, " . G::$LoggedUser['ID'] . ", '" . sqltime() . "', '" . db_string($OldBody) . "')");
G::$DB->set_query_id($QueryID);
if ($SendPM && G::$LoggedUser['ID'] != $AuthorID) {
// Send a PM to the user to notify them of the edit
$PMSubject = "Your comment #{$PostID} has been edited";
$PMurl = site_url() . "comments.php?action=jump&postid={$PostID}";
$ProfLink = '[url=' . site_url() . 'user.php?id=' . G::$LoggedUser['ID'] . ']' . G::$LoggedUser['Username'] . '[/url]';
$PMBody = "One of your comments has been edited by {$ProfLink}: [url]{$PMurl}[/url]";
Misc::send_pm($AuthorID, 0, $PMSubject, $PMBody);
}
return true;
// TODO: this should reflect whether or not the update was actually successful, e.g. by checking G::$DB->affected_rows after the UPDATE query
}
示例2: unlock_account
/**
* Unlock an account
*
* @param int $UserID The ID of the user to unlock
* @param int $Type The lock type, should be a constant value. Used for database verification
* to avoid deleting the wrong lock type
* @param string $Reason The reason for unlock
* @param int $UnlockedByUserID The ID of the staff member unlocking $UserID's account. 0 for system
*/
public static function unlock_account($UserID, $Type, $Message, $Reason, $UnlockedByUserID)
{
if ($UnlockedByUserID == 0) {
$Username = "System";
} else {
G::$DB->query("SELECT Username FROM users_main WHERE ID = '" . $UnlockedByUserID . "'");
list($Username) = G::$DB->next_record();
}
G::$DB->query("DELETE FROM locked_accounts WHERE UserID = '{$UserID}' AND Type = '" . $Type . "'");
if (G::$DB->affected_rows() == 1) {
G::$Cache->delete_value("user_info_" . $UserID);
Tools::update_user_notes($UserID, sqltime() . " - " . db_string($Message) . " by {$Username}\nReason: " . db_string($Reason) . "\n\n");
}
}
示例3: quote_notify
/**
* Parse a post/comment body for quotes and notify all quoted users that have quote notifications enabled.
* @param string $Body
* @param int $PostID
* @param string $Page
* @param int $PageID
*/
public static function quote_notify($Body, $PostID, $Page, $PageID)
{
$QueryID = G::$DB->get_query_id();
/*
* Explanation of the parameters PageID and Page: Page contains where
* this quote comes from and can be forums, artist, collages, requests
* or torrents. The PageID contains the additional value that is
* necessary for the users_notify_quoted table. The PageIDs for the
* different Page are: forums: TopicID artist: ArtistID collages:
* CollageID requests: RequestID torrents: GroupID
*/
$Matches = array();
preg_match_all('/\\[quote(?:=(.*)(?:\\|.*)?)?]|\\[\\/quote]/iU', $Body, $Matches, PREG_SET_ORDER);
if (count($Matches)) {
$Usernames = array();
$Level = 0;
foreach ($Matches as $M) {
if ($M[0] != '[/quote]') {
if ($Level == 0 && isset($M[1]) && strlen($M[1]) > 0 && preg_match(USERNAME_REGEX, $M[1])) {
$Usernames[] = preg_replace('/(^[.,]*)|([.,]*$)/', '', $M[1]);
// wut?
}
++$Level;
} else {
--$Level;
}
}
}
// remove any dupes in the array (the fast way)
$Usernames = array_flip(array_flip($Usernames));
G::$DB->query("\n\t\t\tSELECT m.ID\n\t\t\tFROM users_main AS m\n\t\t\t\tLEFT JOIN users_info AS i ON i.UserID = m.ID\n\t\t\tWHERE m.Username IN ('" . implode("', '", $Usernames) . "')\n\t\t\t\tAND i.NotifyOnQuote = '1'\n\t\t\t\tAND i.UserID != " . G::$LoggedUser['ID']);
$Results = G::$DB->to_array();
foreach ($Results as $Result) {
$UserID = db_string($Result['ID']);
$QuoterID = db_string(G::$LoggedUser['ID']);
$Page = db_string($Page);
$PageID = db_string($PageID);
$PostID = db_string($PostID);
G::$DB->query("\n\t\t\t\tINSERT IGNORE INTO users_notify_quoted\n\t\t\t\t\t(UserID, QuoterID, Page, PageID, PostID, Date)\n\t\t\t\tVALUES\n\t\t\t\t\t('{$UserID}', '{$QuoterID}', '{$Page}', '{$PageID}', '{$PostID}', '" . sqltime() . "')");
G::$Cache->delete_value("notify_quoted_{$UserID}");
if ($Page == 'forums') {
$URL = site_url() . "forums.php?action=viewthread&postid={$PostID}";
} else {
$URL = site_url() . "comments.php?action=jump&postid={$PostID}";
}
NotificationsManager::send_push($UserID, 'New Quote!', 'Quoted by ' . G::$LoggedUser['Username'] . " {$URL}", $URL, NotificationsManager::QUOTES);
}
G::$DB->set_query_id($QueryID);
}
示例4: add_artist
function add_artist($CollageID, $ArtistID)
{
global $Cache, $LoggedUser, $DB;
$DB->query("\n\t\tSELECT MAX(Sort)\n\t\tFROM collages_artists\n\t\tWHERE CollageID = '{$CollageID}'");
list($Sort) = $DB->next_record();
$Sort += 10;
$DB->query("\n\t\tSELECT ArtistID\n\t\tFROM collages_artists\n\t\tWHERE CollageID = '{$CollageID}'\n\t\t\tAND ArtistID = '{$ArtistID}'");
if (!$DB->has_results()) {
$DB->query("\n\t\t\tINSERT IGNORE INTO collages_artists\n\t\t\t\t(CollageID, ArtistID, UserID, Sort, AddedOn)\n\t\t\tVALUES\n\t\t\t\t('{$CollageID}', '{$ArtistID}', '{$LoggedUser['ID']}', '{$Sort}', '" . sqltime() . "')");
$DB->query("\n\t\t\tUPDATE collages\n\t\t\tSET NumTorrents = NumTorrents + 1, Updated = '" . sqltime() . "'\n\t\t\tWHERE ID = '{$CollageID}'");
$Cache->delete_value("collage_{$CollageID}");
$Cache->delete_value("artists_collages_{$ArtistID}");
$Cache->delete_value("artists_collages_personal_{$ArtistID}");
$DB->query("\n\t\t\tSELECT UserID\n\t\t\tFROM users_collage_subs\n\t\t\tWHERE CollageID = {$CollageID}");
while (list($CacheUserID) = $DB->next_record()) {
$Cache->delete_value("collage_subs_user_new_{$CacheUserID}");
}
}
}
示例5: reset_image
function reset_image($UserID, $Type, $AdminComment, $PrivMessage)
{
if ($Type === 'avatar') {
$CacheKey = "user_info_{$UserID}";
$DBTable = 'users_info';
$DBColumn = 'Avatar';
$PMSubject = 'Your avatar has been automatically reset';
} elseif ($Type === 'avatar2') {
$CacheKey = "donor_info_{$UserID}";
$DBTable = 'donor_rewards';
$DBColumn = 'SecondAvatar';
$PMSubject = 'Your second avatar has been automatically reset';
} elseif ($Type === 'donoricon') {
$CacheKey = "donor_info_{$UserID}";
$DBTable = 'donor_rewards';
$DBColumn = 'CustomIcon';
$PMSubject = 'Your donor icon has been automatically reset';
}
$UserInfo = G::$Cache->get_value($CacheKey, true);
if ($UserInfo !== false) {
if ($UserInfo[$DBColumn] === '') {
// This image has already been reset
return;
}
$UserInfo[$DBColumn] = '';
G::$Cache->cache_value($CacheKey, $UserInfo, 2592000);
// cache for 30 days
}
// reset the avatar or donor icon URL
G::$DB->query("\n\t\tUPDATE {$DBTable}\n\t\tSET {$DBColumn} = ''\n\t\tWHERE UserID = '{$UserID}'");
// write comment to staff notes
G::$DB->query("\n\t\tUPDATE users_info\n\t\tSET AdminComment = CONCAT('" . sqltime() . ' - ' . db_string($AdminComment) . "\n\n', AdminComment)\n\t\tWHERE UserID = '{$UserID}'");
// clear cache keys
G::$Cache->delete_value($CacheKey);
Misc::send_pm($UserID, 0, $PMSubject, $PrivMessage);
}
示例6: error
/*
* This is the AJAX page that gets called from the JavaScript
* function NewReport(), any changes here should probably be
* replicated on static.php.
*/
if (!check_perms('admin_reports')) {
error(403);
}
$DB->query("\n\tSELECT\n\t\tr.ID,\n\t\tr.ReporterID,\n\t\treporter.Username,\n\t\tr.TorrentID,\n\t\tr.Type,\n\t\tr.UserComment,\n\t\tr.ResolverID,\n\t\tresolver.Username,\n\t\tr.Status,\n\t\tr.ReportedTime,\n\t\tr.LastChangeTime,\n\t\tr.ModComment,\n\t\tr.Track,\n\t\tr.Image,\n\t\tr.ExtraID,\n\t\tr.Link,\n\t\tr.LogMessage,\n\t\ttg.Name,\n\t\ttg.ID,\n\t\tCASE COUNT(ta.GroupID)\n\t\t\tWHEN 1 THEN aa.ArtistID\n\t\t\tWHEN 0 THEN '0'\n\t\t\tELSE '0'\n\t\tEND AS ArtistID,\n\t\tCASE COUNT(ta.GroupID)\n\t\t\tWHEN 1 THEN aa.Name\n\t\t\tWHEN 0 THEN ''\n\t\t\tELSE 'Various Artists'\n\t\tEND AS ArtistName,\n\t\ttg.Year,\n\t\ttg.CategoryID,\n\t\tt.Time,\n\t\tt.Remastered,\n\t\tt.RemasterTitle,\n\t\tt.RemasterYear,\n\t\tt.Media,\n\t\tt.Format,\n\t\tt.Encoding,\n\t\tt.Size,\n\t\tt.HasCue,\n\t\tt.HasLog,\n\t\tt.LogScore,\n\t\tt.UserID AS UploaderID,\n\t\tuploader.Username\n\tFROM reportsv2 AS r\n\t\tLEFT JOIN torrents AS t ON t.ID = r.TorrentID\n\t\tLEFT JOIN torrents_group AS tg ON tg.ID = t.GroupID\n\t\tLEFT JOIN torrents_artists AS ta ON ta.GroupID = tg.ID AND ta.Importance = '1'\n\t\tLEFT JOIN artists_alias AS aa ON aa.AliasID = ta.AliasID\n\t\tLEFT JOIN users_main AS resolver ON resolver.ID = r.ResolverID\n\t\tLEFT JOIN users_main AS reporter ON reporter.ID = r.ReporterID\n\t\tLEFT JOIN users_main AS uploader ON uploader.ID = t.UserID\n\tWHERE r.Status = 'New'\n\tGROUP BY r.ID\n\tORDER BY ReportedTime ASC\n\tLIMIT 1");
if (!$DB->has_results()) {
die;
}
list($ReportID, $ReporterID, $ReporterName, $TorrentID, $Type, $UserComment, $ResolverID, $ResolverName, $Status, $ReportedTime, $LastChangeTime, $ModComment, $Tracks, $Images, $ExtraIDs, $Links, $LogMessage, $GroupName, $GroupID, $ArtistID, $ArtistName, $Year, $CategoryID, $Time, $Remastered, $RemasterTitle, $RemasterYear, $Media, $Format, $Encoding, $Size, $HasCue, $HasLog, $LogScore, $UploaderID, $UploaderName) = $DB->next_record(MYSQLI_BOTH, array("ModComment"));
if (!$GroupID) {
//Torrent already deleted
$DB->query("\n\t\t\t\tUPDATE reportsv2\n\t\t\t\tSET\n\t\t\t\t\tStatus = 'Resolved',\n\t\t\t\t\tLastChangeTime = '" . sqltime() . "',\n\t\t\t\t\tModComment = 'Report already dealt with (torrent deleted)'\n\t\t\t\tWHERE ID = {$ReportID}");
$Cache->decrement('num_torrent_reportsv2');
?>
<div id="report<?php
echo $ReportID;
?>
" class="report box pad center" data-reportid="<?php
echo $ReportID;
?>
">
<a href="reportsv2.php?view=report&id=<?php
echo $ReportID;
?>
">Report <?php
echo $ReportID;
?>
示例7: log_attempt
function log_attempt($UserID)
{
global $DB, $Cache, $AttemptID, $Attempts, $Bans, $BannedUntil;
$IPStr = $_SERVER['REMOTE_ADDR'];
$IPA = substr($IPStr, 0, strcspn($IPStr, '.'));
$IP = Tools::ip_to_unsigned($IPStr);
if ($AttemptID) {
// User has attempted to log in recently
$Attempts++;
if ($Attempts > 5) {
// Only 6 allowed login attempts, ban user's IP
$BannedUntil = time_plus(60 * 60 * 6);
$DB->query("\n\t\t\t\t\tUPDATE login_attempts\n\t\t\t\t\tSET\n\t\t\t\t\t\tLastAttempt = '" . sqltime() . "',\n\t\t\t\t\t\tAttempts = '" . db_string($Attempts) . "',\n\t\t\t\t\t\tBannedUntil = '" . db_string($BannedUntil) . "',\n\t\t\t\t\t\tBans = Bans + 1\n\t\t\t\t\tWHERE ID = '" . db_string($AttemptID) . "'");
if ($Bans > 9) {
// Automated bruteforce prevention
$DB->query("\n\t\t\t\t\t\tSELECT Reason\n\t\t\t\t\t\tFROM ip_bans\n\t\t\t\t\t\tWHERE {$IP} BETWEEN FromIP AND ToIP");
if ($DB->has_results()) {
//Ban exists already, only add new entry if not for same reason
list($Reason) = $DB->next_record(MYSQLI_BOTH, false);
if ($Reason != 'Automated ban per >60 failed login attempts') {
$DB->query("\n\t\t\t\t\t\t\t\tUPDATE ip_bans\n\t\t\t\t\t\t\t\tSET Reason = CONCAT('Automated ban per >60 failed login attempts AND ', Reason)\n\t\t\t\t\t\t\t\tWHERE FromIP = {$IP}\n\t\t\t\t\t\t\t\t\tAND ToIP = {$IP}");
}
} else {
//No ban
$DB->query("\n\t\t\t\t\t\t\tINSERT IGNORE INTO ip_bans\n\t\t\t\t\t\t\t\t(FromIP, ToIP, Reason)\n\t\t\t\t\t\t\tVALUES\n\t\t\t\t\t\t\t\t('{$IP}','{$IP}', 'Automated ban per >60 failed login attempts')");
$Cache->delete_value("ip_bans_{$IPA}");
}
}
} else {
// User has attempted fewer than 6 logins
$DB->query("\n\t\t\t\t\tUPDATE login_attempts\n\t\t\t\t\tSET\n\t\t\t\t\t\tLastAttempt = '" . sqltime() . "',\n\t\t\t\t\t\tAttempts = '" . db_string($Attempts) . "',\n\t\t\t\t\t\tBannedUntil = '0000-00-00 00:00:00'\n\t\t\t\t\tWHERE ID = '" . db_string($AttemptID) . "'");
}
} else {
// User has not attempted to log in recently
$Attempts = 1;
$DB->query("\n\t\t\t\tINSERT INTO login_attempts\n\t\t\t\t\t(UserID, IP, LastAttempt, Attempts)\n\t\t\t\tVALUES\n\t\t\t\t\t('" . db_string($UserID) . "', '" . db_string($IPStr) . "', '" . sqltime() . "', 1)");
}
}
示例8: authorize
<?php
authorize();
if (!check_perms('site_edit_wiki')) {
error(403);
}
$UserID = $LoggedUser['ID'];
$GroupID = db_string($_POST['groupid']);
$Summaries = $_POST['summary'];
$Images = $_POST['image'];
$Time = sqltime();
if (!is_number($GroupID) || !$GroupID) {
error(0);
}
if (count($Images) != count($Summaries)) {
error('Missing an image or a summary');
}
$Changed = false;
for ($i = 0; $i < count($Images); $i++) {
$Image = $Images[$i];
$Summary = $Summaries[$i];
if (ImageTools::blacklisted($Image, true) || !preg_match("/^" . IMAGE_REGEX . "\$/i", $Image)) {
continue;
}
// sanitize inputs
$Image = db_string($Image);
$Summary = db_string($Summary);
$DB->query("\n\t\tINSERT IGNORE INTO cover_art\n\t\t\t(GroupID, Image, Summary, UserID, Time)\n\t\tVALUES\n\t\t\t('{$GroupID}', '{$Image}', '{$Summary}', '{$UserID}', '{$Time}')");
if ($DB->affected_rows()) {
$Changed = true;
}
示例9: delete_torrent
/**
* Delete a torrent.
*
* @param int $ID The ID of the torrent to delete.
* @param int $GroupID Set it if you have it handy, to save a query. Otherwise, it will be found.
* @param string $OcelotReason The deletion reason for ocelot to report to users.
*/
public static function delete_torrent($ID, $GroupID = 0, $OcelotReason = -1)
{
$QueryID = G::$DB->get_query_id();
if (!$GroupID) {
G::$DB->query("\n\t\t\t\tSELECT GroupID, UserID\n\t\t\t\tFROM torrents\n\t\t\t\tWHERE ID = '{$ID}'");
list($GroupID, $UploaderID) = G::$DB->next_record();
}
if (empty($UserID)) {
G::$DB->query("\n\t\t\t\tSELECT UserID\n\t\t\t\tFROM torrents\n\t\t\t\tWHERE ID = '{$ID}'");
list($UserID) = G::$DB->next_record();
}
$RecentUploads = G::$Cache->get_value("recent_uploads_{$UserID}");
if (is_array($RecentUploads)) {
foreach ($RecentUploads as $Key => $Recent) {
if ($Recent['ID'] == $GroupID) {
G::$Cache->delete_value("recent_uploads_{$UserID}");
}
}
}
G::$DB->query("\n\t\t\tSELECT info_hash\n\t\t\tFROM torrents\n\t\t\tWHERE ID = {$ID}");
list($InfoHash) = G::$DB->next_record(MYSQLI_BOTH, false);
G::$DB->query("\n\t\t\tDELETE FROM torrents\n\t\t\tWHERE ID = {$ID}");
Tracker::update_tracker('delete_torrent', array('info_hash' => rawurlencode($InfoHash), 'id' => $ID, 'reason' => $OcelotReason));
G::$Cache->decrement('stats_torrent_count');
G::$DB->query("\n\t\t\tSELECT COUNT(ID)\n\t\t\tFROM torrents\n\t\t\tWHERE GroupID = '{$GroupID}'");
list($Count) = G::$DB->next_record();
if ($Count == 0) {
Torrents::delete_group($GroupID);
} else {
Torrents::update_hash($GroupID);
}
// Torrent notifications
G::$DB->query("\n\t\t\tSELECT UserID\n\t\t\tFROM users_notify_torrents\n\t\t\tWHERE TorrentID = '{$ID}'");
while (list($UserID) = G::$DB->next_record()) {
G::$Cache->delete_value("notifications_new_{$UserID}");
}
G::$DB->query("\n\t\t\tDELETE FROM users_notify_torrents\n\t\t\tWHERE TorrentID = '{$ID}'");
G::$DB->query("\n\t\t\tUPDATE reportsv2\n\t\t\tSET\n\t\t\t\tStatus = 'Resolved',\n\t\t\t\tLastChangeTime = '" . sqltime() . "',\n\t\t\t\tModComment = 'Report already dealt with (torrent deleted)'\n\t\t\tWHERE TorrentID = {$ID}\n\t\t\t\tAND Status != 'Resolved'");
$Reports = G::$DB->affected_rows();
if ($Reports) {
G::$Cache->decrement('num_torrent_reportsv2', $Reports);
}
G::$DB->query("\n\t\t\tDELETE FROM torrents_files\n\t\t\tWHERE TorrentID = '{$ID}'");
G::$DB->query("\n\t\t\tDELETE FROM torrents_bad_tags\n\t\t\tWHERE TorrentID = {$ID}");
G::$DB->query("\n\t\t\tDELETE FROM torrents_bad_folders\n\t\t\tWHERE TorrentID = {$ID}");
G::$DB->query("\n\t\t\tDELETE FROM torrents_bad_files\n\t\t\tWHERE TorrentID = {$ID}");
G::$DB->query("\n\t\t\tDELETE FROM torrents_cassette_approved\n\t\t\tWHERE TorrentID = {$ID}");
G::$DB->query("\n\t\t\tDELETE FROM torrents_lossymaster_approved\n\t\t\tWHERE TorrentID = {$ID}");
G::$DB->query("\n\t\t\tDELETE FROM torrents_lossyweb_approved\n\t\t\tWHERE TorrentID = {$ID}");
// Tells Sphinx that the group is removed
G::$DB->query("\n\t\t\tREPLACE INTO sphinx_delta (ID, Time)\n\t\t\tVALUES ({$ID}, UNIX_TIMESTAMP())");
G::$Cache->delete_value("torrent_download_{$ID}");
G::$Cache->delete_value("torrent_group_{$GroupID}");
G::$Cache->delete_value("torrents_details_{$GroupID}");
G::$DB->set_query_id($QueryID);
}
示例10: site_url
Misc::send_pm($UserID, 0, 'You have been demoted to ' . Users::make_class_string(MEMBER), "You now only meet the requirements for the \"" . Users::make_class_string(MEMBER) . "\" user class.\n\nTo read more about " . SITE_NAME . "'s user classes, read [url=" . site_url() . "wiki.php?action=article&name=userclasses]this wiki article[/url].");
}
echo "demoted 2\n";
// Demote to User when the ratio drops below 0.65
$DemoteClasses = [MEMBER, POWER, ELITE, TORRENT_MASTER, POWER_TM, ELITE_TM];
$Query = $DB->query('
SELECT ID
FROM users_main
WHERE PermissionID IN(' . implode(', ', $DemoteClasses) . ')
AND Uploaded / Downloaded < 0.65');
echo "demoted 3\n";
$DB->query('
UPDATE users_info AS ui
JOIN users_main AS um ON um.ID = ui.UserID
SET
um.PermissionID = ' . USER . ",\n\t\t\tui.AdminComment = CONCAT('" . sqltime() . ' - Class changed to ' . Users::make_class_string(USER) . " by System\n\n', ui.AdminComment)\n\t\tWHERE um.PermissionID IN (" . implode(', ', $DemoteClasses) . ')
AND um.Uploaded / um.Downloaded < 0.65');
$DB->set_query_id($Query);
while (list($UserID) = $DB->next_record()) {
/*$Cache->begin_transaction("user_info_$UserID");
$Cache->update_row(false, array('PermissionID' => USER));
$Cache->commit_transaction(2592000);*/
$Cache->delete_value("user_info_{$UserID}");
$Cache->delete_value("user_info_heavy_{$UserID}");
Misc::send_pm($UserID, 0, 'You have been demoted to ' . Users::make_class_string(USER), "You now only meet the requirements for the \"" . Users::make_class_string(USER) . "\" user class.\n\nTo read more about " . SITE_NAME . "'s user classes, read [url=" . site_url() . "wiki.php?action=article&name=userclasses]this wiki article[/url].");
}
echo "demoted 4\n";
//------------- Lock old threads ----------------------------------------//
sleep(10);
$DB->query("\n\t\tSELECT t.ID, t.ForumID\n\t\tFROM forums_topics AS t\n\t\t\tJOIN forums AS f ON t.ForumID = f.ID\n\t\tWHERE t.IsLocked = '0'\n\t\t\tAND t.IsSticky = '0'\n\t\t\tAND DATEDIFF(CURDATE(), DATE(t.LastPostTime)) / 7 > f.AutoLockWeeks\n\t\t\tAND f.AutoLock = '1'");
$IDs = $DB->collect('ID');
示例11: geoip
$Class = USER;
$Enabled = '0';
}
$ipcc = geoip($_SERVER['REMOTE_ADDR']);
$DB->query("INSERT INTO users_main \n\t\t\t\t(Username,Email,PassHash,Secret,IP,PermissionID,Enabled,Invites,ipcc) VALUES\n\t\t\t\t('" . db_string(trim($_POST['username'])) . "','" . db_string($_POST['email']) . "','" . db_string(make_hash($_POST['password'], $Secret)) . "','" . db_string($Secret) . "','" . db_string($_SERVER['REMOTE_ADDR']) . "','" . $Class . "','" . $Enabled . "','" . STARTING_INVITES . "', '{$ipcc}')");
$UserID = $DB->inserted_id();
//User created, delete invite. If things break after this point then it's better to have a broken account to fix, or a 'free' invite floating around that can be reused
$DB->query("DELETE FROM invites WHERE InviteKey='" . db_string($_REQUEST['invite']) . "'");
$DB->query("SELECT ID FROM stylesheets WHERE `Default`='1'");
list($StyleID) = $DB->next_record();
$AuthKey = make_secret();
$DB->query("INSERT INTO users_info (UserID, StyleID,AuthKey, Inviter, JoinDate) VALUES ('{$UserID}','{$StyleID}','" . db_string($AuthKey) . "', '{$InviterID}', '" . sqltime() . "')");
$DB->query("INSERT INTO users_history_ips\n\t\t\t\t\t(UserID, IP, StartTime) VALUES\n\t\t\t\t\t('{$UserID}', '" . db_string($_SERVER['REMOTE_ADDR']) . "', '" . sqltime() . "')");
$DB->query("INSERT INTO users_history_emails\n\t\t\t\t(UserID, Email, Time, IP) VALUES \n\t\t\t\t('{$UserID}', '" . db_string($_REQUEST['email']) . "', '0000-00-00 00:00:00', '" . db_string($_SERVER['REMOTE_ADDR']) . "')");
if ($_REQUEST['email'] != $InviteEmail) {
$DB->query("INSERT INTO users_history_emails\n\t\t\t\t\t(UserID, Email, Time, IP) VALUES \n\t\t\t\t\t('{$UserID}', '{$InviteEmail}', '" . sqltime() . "', '" . db_string($_SERVER['REMOTE_ADDR']) . "')");
}
// Manage invite trees, delete invite
if ($InviterID !== NULL) {
$DB->query("SELECT \n\t\t\t\t\tTreePosition, TreeID, TreeLevel \n\t\t\t\t\tFROM invite_tree WHERE UserID='{$InviterID}'");
list($InviterTreePosition, $TreeID, $TreeLevel) = $DB->next_record();
// If the inviter doesn't have an invite tree
// Note - this should never happen unless you've transfered from another db, like we have
if ($DB->record_count() == 0) {
$DB->query("SELECT MAX(TreeID)+1 FROM invite_tree");
list($TreeID) = $DB->next_record();
$DB->query("INSERT INTO invite_tree\n\t\t\t\t\t\t(UserID, InviterID, TreePosition, TreeID, TreeLevel)\n\t\t\t\t\t\tVALUES ('{$InviterID}', '0', '1', '{$TreeID}', '1')");
$TreePosition = 2;
$TreeLevel = 2;
} else {
$DB->query("SELECT \n\t\t\t\t\t\tTreePosition \n\t\t\t\t\t\tFROM invite_tree \n\t\t\t\t\t\tWHERE TreePosition>'{$InviterTreePosition}'\n\t\t\t\t\t\tAND TreeLevel<='{$TreeLevel}' \n\t\t\t\t\t\tAND TreeID='{$TreeID}'\n\t\t\t\t\t\tORDER BY TreePosition \n\t\t\t\t\t\tLIMIT 1");
示例12: disable_users
/**
* Disable an array of users.
*
* @param array $UserIDs (You can also send it one ID as an int, because fuck types)
* @param BanReason 0 - Unknown, 1 - Manual, 2 - Ratio, 3 - Inactive, 4 - Unused.
*/
public static function disable_users($UserIDs, $AdminComment, $BanReason = 1)
{
$QueryID = G::$DB->get_query_id();
if (!is_array($UserIDs)) {
$UserIDs = array($UserIDs);
}
G::$DB->query("\n\t\t\tUPDATE users_info AS i\n\t\t\t\tJOIN users_main AS m ON m.ID = i.UserID\n\t\t\tSET m.Enabled = '2',\n\t\t\t\tm.can_leech = '0',\n\t\t\t\ti.AdminComment = CONCAT('" . sqltime() . " - " . ($AdminComment ? $AdminComment : 'Disabled by system') . "\n\n', i.AdminComment),\n\t\t\t\ti.BanDate = '" . sqltime() . "',\n\t\t\t\ti.BanReason = '{$BanReason}',\n\t\t\t\ti.RatioWatchDownload = " . ($BanReason == 2 ? 'm.Downloaded' : "'0'") . "\n\t\t\tWHERE m.ID IN(" . implode(',', $UserIDs) . ') ');
G::$Cache->decrement('stats_user_count', G::$DB->affected_rows());
foreach ($UserIDs as $UserID) {
G::$Cache->delete_value("enabled_{$UserID}");
G::$Cache->delete_value("user_info_{$UserID}");
G::$Cache->delete_value("user_info_heavy_{$UserID}");
G::$Cache->delete_value("user_stats_{$UserID}");
G::$DB->query("\n\t\t\t\tSELECT SessionID\n\t\t\t\tFROM users_sessions\n\t\t\t\tWHERE UserID = '{$UserID}'\n\t\t\t\t\tAND Active = 1");
while (list($SessionID) = G::$DB->next_record()) {
G::$Cache->delete_value("session_{$UserID}" . "_{$SessionID}");
}
G::$Cache->delete_value("users_sessions_{$UserID}");
G::$DB->query("\n\t\t\t\tDELETE FROM users_sessions\n\t\t\t\tWHERE UserID = '{$UserID}'");
}
// Remove the users from the tracker.
G::$DB->query('
SELECT torrent_pass
FROM users_main
WHERE ID in (' . implode(', ', $UserIDs) . ')');
$PassKeys = G::$DB->collect('torrent_pass');
$Concat = '';
foreach ($PassKeys as $PassKey) {
if (strlen($Concat) > 3950) {
// Ocelot's read buffer is 4 KiB and anything exceeding it is truncated
Tracker::update_tracker('remove_users', array('passkeys' => $Concat));
$Concat = $PassKey;
} else {
$Concat .= $PassKey;
}
}
Tracker::update_tracker('remove_users', array('passkeys' => $Concat));
G::$DB->set_query_id($QueryID);
}
示例13: with
GROUP BY r.ID
ORDER BY ReportedTime ASC
LIMIT 1");
if($DB->record_count() < 1) {
die();
}
list($ReportID, $ReporterID, $ReporterName, $TorrentID, $Type, $UserComment, $ResolverID, $ResolverName, $Status, $ReportedTime, $LastChangeTime,
$ModComment, $Tracks, $Images, $ExtraIDs, $Links, $LogMessage, $GroupName, $GroupID, $ArtistID, $ArtistName, $Year, $CategoryID, $Time, $Remastered, $RemasterTitle,
$RemasterYear, $Media, $Format, $Encoding, $Size, $HasCue, $HasLog, $LogScore, $UploaderID, $UploaderName) = $DB->next_record();
if(!$GroupID) {
//Torrent already deleted
$DB->query("UPDATE reportsv2 SET
Status='Resolved',
LastChangeTime='".sqltime()."',
ModComment='Report already dealt with (Torrent deleted)'
WHERE ID=".$ReportID);
?>
<div>
<table>
<tr>
<td class='center'>
<a href="reportsv2.php?view=report&id=<?php
echo $ReportID;
?>
">Report <?php
echo $ReportID;
?>
</a> for torrent <?php
echo $TorrentID;
示例14: array
if($_POST['submit'] == 'Delete'){ //Delete
if(!is_number($_POST['id']) || $_POST['id'] == ''){ error(0); }
$DB->query('DELETE FROM do_not_upload WHERE ID='.$_POST['id']);
} else { //Edit & Create, Shared Validation
$Val->SetFields('name', '1','string','The name must be set, and has a max length of 40 characters', array('maxlength'=>40, 'minlength'=>1));
$Val->SetFields('comment', '0','string','The description has a max length of 255 characters', array('maxlength'=>255));
$Err=$Val->ValidateForm($_POST); // Validate the form
if($Err){ error($Err); }
$P=array();
$P=db_array($_POST); // Sanitize the form
if($_POST['submit'] == 'Edit'){ //Edit
if(!is_number($_POST['id']) || $_POST['id'] == ''){ error(0); }
$DB->query("UPDATE do_not_upload SET
Name='$P[name]',
Comment='$P[comment]',
UserID='$LoggedUser[ID]',
Time='".sqltime()."'
WHERE ID='$P[id]'");
} else { //Create
$DB->query("INSERT INTO do_not_upload
(Name, Comment, UserID, Time) VALUES
('$P[name]','$P[comment]','$LoggedUser[ID]','".sqltime."')");
}
}
// Go back
header('Location: tools.php?action=dnu')
?>
示例15: update_event
public static function update_event($ID, $Date, $Title, $Link, $Category, $SubCategory, $Tags, $Body, $UserID)
{
if (empty($Date)) {
$Date = sqltime();
} else {
$Date = db_string($Date);
list($Y, $M, $D) = explode('-', $Date);
if (!checkdate($M, $D, $Y)) {
error("Error");
}
}
$ID = (int) $ID;
$Title = db_string($Title);
$Link = db_string($Link);
$Category = (int) $Category;
$SubCategory = (int) $SubCategory;
$Tags = db_string(strtolower(preg_replace('/\\s+/', '', $Tags)));
$ExplodedTags = explode(",", $Tags);
foreach ($ExplodedTags as $Tag) {
if (!in_array($Tag, self::get_tags())) {
error("Invalid tag");
}
}
$Body = db_string($Body);
$UserID = (int) $UserID;
if (empty($ID) || empty($Title) || empty($Category) || empty($SubCategory)) {
error("Error");
}
$QueryID = G::$DB->get_query_id();
G::$DB->query("\n\t\t\t\tUPDATE site_history\n\t\t\t\tSET\n\t\t\t\t\tTitle = '{$Title}',\n\t\t\t\t\tUrl = '{$Link}',\n\t\t\t\t\tCategory = '{$Category}',\n\t\t\t\t\tSubCategory = '{$SubCategory}',\n\t\t\t\t\tTags = '{$Tags}',\n\t\t\t\t\tBody = '{$Body}',\n\t\t\t\t\tAddedBy = '{$UserID}',\n\t\t\t\t\tDate = '{$Date}'\n\t\t\t\tWHERE ID = '{$ID}'");
G::$DB->set_query_id($QueryID);
G::$Cache->delete_value("site_history_months");
}