Inheritance: extends Eloquent
Ejemplo n.º 1
0
 public function getTitle()
 {
     $donation = new Donations();
     $result = $donation->getContributorsName();
     $result = json_encode($result);
     return $result;
 }
Ejemplo n.º 2
0
 public function getIndex()
 {
     //	Session::put('userid','001');
     //	Session::put('username','jehdeguzman');
     $this->layout->title = "Welcome to Sagip.ph";
     // $campaign = new Campaign;
     // $result = $campaign->getImage();
     $campaign = new Campaign();
     $image = $campaign->getCampaignImage();
     $users = new Users();
     $member = $users->getRecentUsers();
     $this->layout->foot = View::make("landing.foot")->with(array('data' => $image, 'data2' => $member));
     if (Session::has('userid')) {
         $username = Session::get('username');
         $logstatus = true;
         $userid = Session::get('userid');
         $profile = new Profile();
         $pic = "#";
         $result = $profile->getProfile($userid);
         if ($result) {
             $pic = $result->profilepic;
         }
         $data = array('username' => $username, 'logstatus' => $logstatus, 'profilepic' => $pic);
         $campaign = new Campaign();
         $data2 = $campaign->getCampaignHome();
         $donation = new Donations();
         $data3 = $donation->getTopContributorsHome();
         $this->layout->head = View::make("landing.head")->with($data);
         $this->layout->body = View::make("landing.bodyhome")->with(array('data2' => $data2, 'data3' => $data3, 'logstatus' => $logstatus));
         //return View::make('home')->with($data);
     } else {
         $logstatus = false;
         $data = array('logstatus' => $logstatus);
         $campaign = new Campaign();
         $data2 = $campaign->getCampaignHome();
         $donation = new Donations();
         $data3 = $donation->getTopContributorsHome();
         $this->layout->head = View::make("landing.head")->with($data);
         $this->layout->body = View::make("landing.bodyhome")->with(array('data2' => $data2, 'data3' => $data3, 'logstatus' => $logstatus));
     }
 }
Ejemplo n.º 3
0
 public function updateAction()
 {
     $request = new Request();
     if ($request->isPost()) {
         $donations = Donations::find();
         $validIds = $request->getPost();
         foreach ($donations as $donation) {
             if (in_array($donation->getId(), $validIds)) {
                 $donation->setVerified(1);
             } else {
                 $donation->setVerified(0);
             }
             $donation->save();
         }
     }
     $this->dispatcher->forward(array('controller' => 'admin', 'action' => 'index'));
 }
Ejemplo n.º 4
0
View::show_header('Forums');
?>
<div class="thin">
	<h2>Forums</h2>
	<div class="forum_list">
<?php 
$Row = 'a';
$LastCategoryID = 0;
$OpenTable = false;
foreach ($Forums as $Forum) {
    list($ForumID, $CategoryID, $ForumName, $ForumDescription, $MinRead, $MinWrite, $MinCreate, $NumTopics, $NumPosts, $LastPostID, $LastAuthorID, $LastTopicID, $LastTime, $SpecificRules, $LastTopic, $Locked, $Sticky) = array_values($Forum);
    if (!Forums::check_forumperm($ForumID)) {
        continue;
    }
    if ($ForumID == DONOR_FORUM) {
        $ForumDescription = Donations::get_forum_description();
    }
    $Tooltip = $ForumID == DONOR_FORUM ? 'tooltip_gold' : 'tooltip';
    $Row = $Row === 'a' ? 'b' : 'a';
    $ForumDescription = display_str($ForumDescription);
    if ($CategoryID != $LastCategoryID) {
        $Row = 'b';
        $LastCategoryID = $CategoryID;
        if ($OpenTable) {
            ?>
	</table>
<?php 
        }
        ?>
<h3><?php 
        echo $ForumCats[$CategoryID];
Ejemplo n.º 5
0
				WHERE ID = '$UserID'");
		} else {
			$DB->query("
				UPDATE lastfm_users
				SET Username = '******'
				WHERE ID = '$UserID'");
		}
	}
} elseif (!empty($LastFMUsername)) {
	$DB->query("
		INSERT INTO lastfm_users (ID, Username)
		VALUES ('$UserID', '$LastFMUsername')");
}
G::$Cache->delete_value("lastfm_username_$UserID");

Donations::update_rewards($UserID);
NotificationsManager::save_settings($UserID);

// Information on how the user likes to download torrents is stored in cache
if ($DownloadAlt != $LoggedUser['DownloadAlt']) {
	$Cache->delete_value('user_'.$LoggedUser['torrent_pass']);
}

$Cache->begin_transaction("user_info_$UserID");
$Cache->update_row(false, array(
		'Avatar' => display_str($_POST['avatar']),
		'Paranoia' => $Paranoia
));
$Cache->commit_transaction(0);

$Cache->begin_transaction("user_info_heavy_$UserID");
Ejemplo n.º 6
0
 /**
  * Find and process new donations since the last time this function was called.
  */
 public static function find_new_donations()
 {
     global $Debug;
     if (($OldAmount = G::$Cache->get_value('btc_total_received')) === false) {
         $QueryID = G::$DB->get_query_id();
         G::$DB->query("\n\t\t\t\tSELECT IFNULL(SUM(Amount), 0)\n\t\t\t\tFROM donations_bitcoin");
         list($OldAmount) = G::$DB->next_record(MYSQLI_NUM, false);
         G::$DB->set_query_id($QueryID);
     }
     $NewAmount = self::get_total_received();
     if ($NewAmount < $OldAmount) {
         // This shouldn't happen. Perhaps bitcoind was restarted recently
         // or the block index was removed. Either way, try again later
         send_irc('PRIVMSG ' . LAB_CHAN . " :Bad bitcoin donation data (is {$NewAmount}, was {$OldAmount}). If this persists, something is probably wrong");
         return false;
     }
     if ($NewAmount > $OldAmount) {
         // I really wish we didn't have to do it like this
         $QueryID = G::$DB->get_query_id();
         G::$DB->query("\n\t\t\t\tSELECT BitcoinAddress, SUM(Amount)\n\t\t\t\tFROM donations_bitcoin\n\t\t\t\tGROUP BY BitcoinAddress");
         $OldDonations = G::$DB->to_pair(0, 1, false);
         G::$DB->set_query_id($QueryID);
         $NewDonations = self::get_received();
         foreach ($NewDonations as $Address => &$Amount) {
             if (isset($OldDonations[$Address])) {
                 if ($Amount == $OldDonations[$Address]) {
                     // Direct comparison should be fine as everything comes from bitcoind
                     unset($NewDonations[$Address]);
                     continue;
                 }
                 $Debug->log_var(array('old' => $OldDonations[$Address], 'new' => $Amount), "New donations from {$Address}");
                 // PHP doesn't do fixed-point math, and json_decode has already botched the precision
                 // so let's just round this off to satoshis and pray that we're on a 64 bit system
                 $Amount = round($Amount - $OldDonations[$Address], 8);
             }
             $NewDonations[$Address] = $Amount;
         }
         $Debug->log_var($NewDonations, '$NewDonations');
         foreach (self::get_userids(array_keys($NewDonations)) as $Address => $UserID) {
             Donations::regular_donate($UserID, $NewDonations[$Address], 'Bitcoin Parser', '', 'BTC');
             self::store_donation($Address, $NewDonations[$Address]);
         }
         G::$Cache->cache_value('btc_total_received', $NewAmount, 0);
     }
 }
Ejemplo n.º 7
0
}
if ($SiteOptions) {
    $SiteOptions = unserialize($SiteOptions);
} else {
    $SiteOptions = array();
}
View::show_header("{$Username} &gt; Settings", 'user,jquery-ui,release_sort,password_validate,validate,cssgallery,preview_paranoia,bbcode,user_settings,donor_titles');
$DonorRank = Donations::get_rank($UserID);
$DonorIsVisible = Donations::is_visible($UserID);
if ($DonorIsVisible === null) {
    $DonorIsVisible = true;
}
extract(Donations::get_enabled_rewards($UserID));
$Rewards = Donations::get_rewards($UserID);
$ProfileRewards = Donations::get_profile_rewards($UserID);
$DonorTitles = Donations::get_titles($UserID);
$DB->query("\n\tSELECT username\n\tFROM lastfm_users\n\tWHERE ID = '{$UserID}'");
$LastFMUsername = '';
list($LastFMUsername) = $DB->next_record();
echo $Val->GenerateJS('userform');
?>
<div class="thin">
	<div class="header">
		<h2><?php 
echo Users::format_username($UserID, false, false, false);
?>
 &gt; Settings</h2>
	</div>
	<form class="edit_form" name="user" id="userform" action="" method="post" autocomplete="off">
	<div class="sidebar settings_sidebar">
		<div class="box box2" id="settings_sections">
Ejemplo n.º 8
0
<?php

authorize();
if (!check_perms('users_give_donor')) {
    error(403);
}
if (!is_number($_POST['id']) || !is_numeric($_POST['donation_amount']) || empty($_POST['donation_currency'])) {
    error(404);
}
$ConvID = (int) $_POST['id'];
$DB->query("\n\tSELECT c.Subject, c.UserID, c.Level, c.AssignedToUser, c.Unread, c.Status, u.Donor\n\tFROM staff_pm_conversations AS c\n\t\tJOIN users_info AS u ON u.UserID = c.UserID\n\tWHERE ID = {$ConvID}");
list($Subject, $UserID, $Level, $AssignedToUser, $Unread, $Status, $Donor) = $DB->next_record();
if ($DB->record_count() == 0) {
    error(404);
}
$Message = "Thank for for helping to support the site. It's users like you who make all of this possible.";
if ((int) $Donor === 0) {
    $Message .= ' Enjoy your new love from us!';
} else {
    $Message .= ' ';
}
/*
$DB->query("
	INSERT INTO staff_pm_messages
		(UserID, SentDate, Message, ConvID)
	VALUES
		(".$LoggedUser['ID'].", '".sqltime()."', '".db_string($Message)."', $ConvID)");
*/
$DB->query("\n\tUPDATE staff_pm_conversations\n\tSET Date = '" . sqltime() . "',\n\t\tUnread = true,\n\t\tStatus = 'Resolved',\n\t\tResolverID = " . $LoggedUser['ID'] . "\n\tWHERE ID = {$ConvID}");
Donations::donate($UserID, array("Source" => "Staff PM", "Price" => $_POST['donation_amount'], "Currency" => $_POST['donation_currency'], "Reason" => $_POST['donation_reason'], "SendPM" => true));
header('Location: staffpm.php');
Ejemplo n.º 9
0
 /**
  * Donations 
  */
 public function executeDons(sfWebRequest $r)
 {
     $this->dons = array(5, 10, 15, 20, 30, 50);
     // TODO : needs a little more control if the payment has really passed.
     if ($r->hasParameter("hash")) {
         $sesDons = $this->getUser()->getAttribute("donations");
         foreach ($sesDons as $id => $don) {
             if ($r->getUrlParameter("hash") == $don['hash']) {
                 // Save donation
                 $d = new Donations();
                 $d->setAmount($sesDons[$id]['amount']);
                 $d->setDonor($this->getUser()->getAttribute("id"));
                 $d->save();
                 // Shout
                 /*sfProjectConfiguration::getActive()->loadHelpers('Number');
                   $sh = Doctrine::getTable("Shoutbox")->ecrireShout(array(
                     "img" => "money_add",
                     "msg" => $this->getContext()->getI18N()->__("has just made a donation of %amount% !", 
                             array("%amount%" => format_currency($don['amount'], 'EUR'))),
                     "url" => $this->getContext()->getController()->genUrl('membres/dons'),
                     "titre" => $this->getContext()->getI18N()->__("Go to donations page !"),
                   ));*/
                 // On confirme
                 $this->getUser()->setFlash("notice", $this->getContext()->getI18N()->__("Thanks for your donation !"));
                 // On redirige
                 $this->redirect("@homepage");
             }
         }
     } else {
         // Generating hash for each donation
         foreach ($this->dons as $id => $don) {
             $amount = $don;
             $hash = md5(sfConfig::get("sf_csrf_secret") . $don);
             $this->dons[$id] = array("hash" => $hash, "amount" => $amount);
         }
         $this->getUser()->setAttribute("donations", $this->dons);
     }
     $this->donations = Doctrine::getTable("Donations")->getAmount();
     $this->donationsPercentage = $this->donations / sfConfig::get('app_dons_objectif') * 100;
     if ($this->donationsPercentage > 100) {
         $this->donationsPercentage = 100;
     }
     $this->bestDonors = Doctrine::getTable("Donations")->getBestDonors(10);
     $this->lastDonations = Doctrine::getTable("Donations")->getLastDonations(10);
     $this->r = $r;
     return $this->renderText(json_encode(array("right" => array("donations" => $this->getTab("Donations", "money_add.png", $this->getPartial($this->getModuleName() . '/donate_choices')), "goal" => $this->getTab("Objective", "credit.png", $this->getPartial($this->getModuleName() . '/donate_goal'))))));
 }
Ejemplo n.º 10
0
    $Tree = new INVITE_TREE($UserID, array('visible' => false));
    ?>
		<div class="box" id="invitetree_box">
			<div class="head">
				Invite Tree <a href="#" onclick="$('#invitetree').gtoggle(); return false;" class="brackets">View</a>
			</div>
			<div id="invitetree" class="hidden">
<?php 
    $Tree->make_tree();
    ?>
			</div>
		</div>
<?php 
}
if (check_perms('users_mod')) {
    DonationsView::render_donation_history(Donations::get_donation_history($UserID));
}
// Requests
if (empty($LoggedUser['DisableRequests']) && check_paranoia_here('requestsvoted_list')) {
    $SphQL = new SphinxqlQuery();
    $SphQLResult = $SphQL->select('id, votes, bounty')->from('requests, requests_delta')->where('userid', $UserID)->where('torrentid', 0)->order_by('votes', 'desc')->order_by('bounty', 'desc')->limit(0, 100, 100)->query();
    if ($SphQLResult->has_results()) {
        $SphRequests = $SphQLResult->to_array('id', MYSQLI_ASSOC);
        ?>
		<div class="box" id="requests_box">
			<div class="head">
				Requests <a href="#" onclick="$('#requests').gtoggle(); return false;" class="brackets">View</a>
			</div>
			<div id="requests" class="request_table hidden">
				<table cellpadding="6" cellspacing="1" border="0" class="border" width="100%">
					<tr class="colhead_dark">
Ejemplo n.º 11
0
     break;
 case validateRoute('GET', 'donations'):
     $donations = new Donations($db, $user);
     list($result, $totalCount) = $donations->query(array("limit" => $_GET["limit"], "index" => $_GET["index"]));
     httpResponse($result, $totalCount);
     break;
 case validateRoute('POST', 'donations'):
     $donate = new Donations($db, $user);
     httpResponse($donate->create($postdata));
     break;
 case validateRoute('PATCH', 'donations/\\d+'):
     $donate = new Donations($db, $user);
     httpResponse($donate->update((int) $params[1], $postdata));
     break;
 case validateRoute('DELETE', 'donations/\\d+'):
     $donate = new Donations($db, $user);
     httpResponse($donate->delete((int) $params[1], $postdata));
     break;
 case validateRoute('GET', 'login-attempts'):
     $loginAttempts = new LoginAttempts($db, $user);
     list($result, $totalCount) = $loginAttempts->query(array("limit" => $_GET["limit"], "index" => $_GET["index"]));
     httpResponse($result, $totalCount);
     break;
 case validateRoute('DELETE', 'login-attempts/\\d+'):
     $loginAttempts = new LoginAttempts($db, $user);
     httpResponse($loginAttempts->delete((int) $params[1]));
     break;
 case validateRoute('GET', 'signups'):
     $signups = new Signups($db, $user);
     list($result, $totalCount) = $signups->query((int) $_GET["limit"], (int) $_GET["index"]);
     httpResponse($result, $totalCount);
Ejemplo n.º 12
0
<?php

if (check_perms('users_mod') || $OwnProfile || Donations::is_visible($UserID)) {
    ?>
	<div class="box box_info box_userinfo_donor_stats">
		<div class="head colhead_dark">Donor Statistics</div>
		<ul class="stats nobullet">
			<li>
				Total donor points: <?php 
    echo Donations::get_total_rank($UserID);
    ?>
			</li>
			<li>
				Current donor rank: <?php 
    echo Donations::render_rank(Donations::get_rank($UserID), true);
    ?>
			</li>
			<li>
				Last donated: <?php 
    echo time_diff(Donations::get_donation_time($UserID));
    ?>
			</li>
		</ul>
	</div>
<?php 
}
class Donations extends WP_List_Table
{
    function get_columns()
    {
        return array('progress_name' => 'Name', 'campaign_name' => 'Campaign', 'progress_type' => 'Type', 'progress_id' => 'Progress Id');
    }
    function prepare_items()
    {
        $this->_column_headers = array($this->get_columns(), array('progress_id'), $this->get_sortable_columns());
        global $wpdb;
        $this->items = $result = $wpdb->get_results("select progress_name,coalesce(campaign.name,'Default') campaign_name,progress_type,progress_id\n                                                    from " . SMART_DONATIONS_PROGRESS_TABLE . " progress\n                                                    left join " . SMART_DONATIONS_CAMPAIGN_TABLE . " campaign\n                                                    on campaign.campaign_id=progress.campaign_id ");
    }
    function get_sortable_columns()
    {
    }
    function column_default($item, $column_name)
    {
        return $item->{$column_name};
    }
    function column_progress_name($item)
    {
        $actions = array('edit' => sprintf('<a href="?page=%s&$progress_id=%s&action=%s">Edit</a>', $_REQUEST['page'], $item->progress_id, 'edit'), 'delete' => sprintf('<a href="?page=%s&$progress_id=%s&action=%s">Delete</a>', $_REQUEST['page'], $item->progress_id, 'delete'));
        return sprintf('%1$s %2$s', $item->progress_name, $this->row_actions($actions));
    }
}
$donationList = new Donations();
$donationList->prepare_items();
$donationList->display();
?>

Ejemplo n.º 14
0
 public function getContributors()
 {
     $campaignid = Input::get('campaignid');
     $donation = new Donations();
     $result = $donation->getContributors($campaignid);
     //dd($result);
     if ($result) {
         $str = "";
         foreach ($result as $row) {
             $str .= "<a style='font-weight:lighter;' href='/" . $row->username . "' class='label label-important'><strong><i class='icon-tag'></i> " . $row->username . "</strong></a> ";
         }
         return $str;
     } else {
         return "<strong style='font-weight:lighter;'>No contributors yet.</strong>";
     }
 }
Ejemplo n.º 15
0
$sanity = new Sanity();
require_once $_SERVER['DOCUMENT_ROOT'] . "/" . $_SESSION['SiteFolder'] . "Manager/System/LoggedOnly.class.php";
new LoggedOnly();
require $_SERVER['DOCUMENT_ROOT'] . "/" . $_SESSION['SiteFolder'] . "System/IniSets.class.php";
new IniSets();
require_once $_SERVER['DOCUMENT_ROOT'] . "/" . $_SESSION['SiteFolder'] . "Manager/System/Manager.class.php";
$mn = new Manager();
require_once $_SERVER['DOCUMENT_ROOT'] . "/" . $_SESSION['SiteFolder'] . "System/MuDatabase.class.php";
$db = new MuDatabase();
if ($mn->GetUserLevel($_SESSION['ManagerId'], $db) < $ManagerDonationLevel) {
    require $_SERVER['DOCUMENT_ROOT'] . "/" . $_SESSION['SiteFolder'] . "Manager/Language/{$MainLanguage}/Manager.php";
    $db->Disconnect();
    exit($ManagerMessage01);
}
require_once $_SERVER['DOCUMENT_ROOT'] . "/" . $_SESSION['SiteFolder'] . "Manager/System/Donations.class.php";
$dn = new Donations();
switch ($_GET['action']) {
    default:
    case "confirmations":
        echo $dn->Confirmations($db);
        break;
    case "viewConfirmation":
        echo $dn->ViewConfirmation($db, $_GET['idx']);
        break;
    case "cancelConfirmation":
        echo $dn->CancelConfirmation($db, $_POST);
        break;
    case "confirmDonation":
        echo $dn->ConfirmDonation($db, $_POST['idx']);
        break;
    case "config":
Ejemplo n.º 16
0
 public static function schedule()
 {
     self::$IsSchedule = true;
     DonationsBitcoin::find_new_donations();
     self::expire_ranks();
     self::get_new_conversion_rates();
 }
Ejemplo n.º 17
0
        echo $NewDonations[$Address];
        ?>
 (<?php 
        echo "{$DonationEUR} EUR";
        ?>
)</td>
			<td><?php 
        echo $AllDonations[$Address];
        ?>
</td>
			<td><?php 
        echo (int) Donations::get_rank($UserID);
        ?>
</td>
			<td><?php 
        echo (int) Donations::get_special_rank($UserID);
        ?>
</td>
		</tr>
<?php 
    }
} else {
    ?>
		<tr>
			<td colspan="7">No unprocessed Bitcoin donations</td>
		</tr>
<?php 
}
?>
	</table>
</div>
Ejemplo n.º 18
0
 public function postDonate()
 {
     date_default_timezone_set('Asia/Manila');
     $carbon = new Carbon();
     $datedonated = $carbon->toDateString();
     $usersid = Session::get('userid');
     $donation = new Donations();
     $donation->amountdonated = Input::get('amountdonated');
     $donation->datedonated = $datedonated;
     $donation->usersid = $usersid;
     $donation->campaignid = Input::get('campaignid');
     $donation->bankname = Input::get('bankname');
     $donation->bankaccount = Input::get('bankaccount');
     $donation->userbankname = Input::get('userbankname');
     $donation->save();
     $result = DB::table('campaign')->select('campaign.name')->where('campaign.id', Input::get('campaignid'))->get();
     foreach ($result as $row) {
         $name = $row->name;
     }
     $activityname = "Donated P" . Input::get('amountdonated') . ' to campaign: ' . $name;
     DB::table('activity')->insertGetId(array('name' => $activityname, 'usersid' => $usersid, 'date' => $datedonated));
 }
Ejemplo n.º 19
0
 if (!is_array($UserStats)) {
     $DB->query("\n\t\t\tSELECT Uploaded AS BytesUploaded, Downloaded AS BytesDownloaded, RequiredRatio\n\t\t\tFROM users_main\n\t\t\tWHERE ID = '{$LoggedUser['ID']}'");
     $UserStats = $DB->next_record(MYSQLI_ASSOC);
     $Cache->cache_value('user_stats_' . $LoggedUser['ID'], $UserStats, 3600);
 }
 // Get info such as username
 $LightInfo = Users::user_info($LoggedUser['ID']);
 $HeavyInfo = Users::user_heavy_info($LoggedUser['ID']);
 // Create LoggedUser array
 $LoggedUser = array_merge($HeavyInfo, $LightInfo, $UserStats);
 $LoggedUser['RSS_Auth'] = md5($LoggedUser['ID'] . RSS_HASH . $LoggedUser['torrent_pass']);
 // $LoggedUser['RatioWatch'] as a bool to disable things for users on Ratio Watch
 $LoggedUser['RatioWatch'] = $LoggedUser['RatioWatchEnds'] != '0000-00-00 00:00:00' && time() < strtotime($LoggedUser['RatioWatchEnds']) && $LoggedUser['BytesDownloaded'] * $LoggedUser['RequiredRatio'] > $LoggedUser['BytesUploaded'];
 // Load in the permissions
 $LoggedUser['Permissions'] = Permissions::get_permissions_for_user($LoggedUser['ID'], $LoggedUser['CustomPermissions']);
 $LoggedUser['Permissions']['MaxCollages'] += Donations::get_personal_collages($LoggedUser['ID']);
 // Change necessary triggers in external components
 $Cache->CanClear = check_perms('admin_clear_cache');
 // Because we <3 our staff
 if (check_perms('site_disable_ip_history')) {
     $_SERVER['REMOTE_ADDR'] = '127.0.0.1';
 }
 // Update LastUpdate every 10 minutes
 if (strtotime($UserSessions[$SessionID]['LastUpdate']) + 600 < time()) {
     $DB->query("\n\t\t\tUPDATE users_main\n\t\t\tSET LastAccess = '" . sqltime() . "'\n\t\t\tWHERE ID = '{$LoggedUser['ID']}'");
     $DB->query("\n\t\t\tUPDATE users_sessions\n\t\t\tSET\n\t\t\t\tIP = '" . $_SERVER['REMOTE_ADDR'] . "',\n\t\t\t\tBrowser = '{$Browser}',\n\t\t\t\tOperatingSystem = '{$OperatingSystem}',\n\t\t\t\tLastUpdate = '" . sqltime() . "'\n\t\t\tWHERE UserID = '{$LoggedUser['ID']}'\n\t\t\t\tAND SessionID = '" . db_string($SessionID) . "'");
     $Cache->begin_transaction("users_sessions_{$UserID}");
     $Cache->delete_row($SessionID);
     $Cache->insert_front($SessionID, array('SessionID' => $SessionID, 'Browser' => $Browser, 'OperatingSystem' => $OperatingSystem, 'IP' => $_SERVER['REMOTE_ADDR'], 'LastUpdate' => sqltime()));
     $Cache->commit_transaction(0);
 }
Ejemplo n.º 20
0
 /**
  * Generate HTML for a user's avatar or just return the avatar URL
  * @param unknown $Avatar
  * @param unknown $UserID
  * @param unknown $Username
  * @param unknown $Setting
  * @param number $Size
  * @param string $ReturnHTML
  * @return string
  */
 public static function show_avatar($Avatar, $UserID, $Username, $Setting, $Size = 150, $ReturnHTML = True)
 {
     $Avatar = ImageTools::process($Avatar, false, 'avatar', $UserID);
     $Style = 'style="max-height: 400px;"';
     $AvatarMouseOverText = '';
     $SecondAvatar = '';
     $Class = 'class="double_avatar"';
     $EnabledRewards = Donations::get_enabled_rewards($UserID);
     if ($EnabledRewards['HasAvatarMouseOverText']) {
         $Rewards = Donations::get_rewards($UserID);
         $AvatarMouseOverText = $Rewards['AvatarMouseOverText'];
     }
     if (!empty($AvatarMouseOverText)) {
         $AvatarMouseOverText = "title=\"{$AvatarMouseOverText}\" alt=\"{$AvatarMouseOverText}\"";
     } else {
         $AvatarMouseOverText = "alt=\"{$Username}'s avatar\"";
     }
     if ($EnabledRewards['HasSecondAvatar'] && !empty($Rewards['SecondAvatar'])) {
         $SecondAvatar = ' data-gazelle-second-avatar="' . ImageTools::process($Rewards['SecondAvatar'], false, 'avatar2', $UserID) . '"';
     }
     // case 1 is avatars disabled
     switch ($Setting) {
         case 0:
             if (!empty($Avatar)) {
                 $ToReturn = $ReturnHTML ? "<div><img src=\"{$Avatar}\" width=\"{$Size}\" {$Style} {$AvatarMouseOverText}{$SecondAvatar} {$Class} /></div>" : $Avatar;
             } else {
                 $URL = STATIC_SERVER . 'common/avatars/default.png';
                 $ToReturn = $ReturnHTML ? "<div><img src=\"{$URL}\" width=\"{$Size}\" {$Style} {$AvatarMouseOverText}{$SecondAvatar} /></div>" : $URL;
             }
             break;
         case 2:
             $ShowAvatar = true;
             // Fallthrough
         // Fallthrough
         case 3:
             switch (G::$LoggedUser['Identicons']) {
                 case 0:
                     $Type = 'identicon';
                     break;
                 case 1:
                     $Type = 'monsterid';
                     break;
                 case 2:
                     $Type = 'wavatar';
                     break;
                 case 3:
                     $Type = 'retro';
                     break;
                 case 4:
                     $Type = '1';
                     $Robot = true;
                     break;
                 case 5:
                     $Type = '2';
                     $Robot = true;
                     break;
                 case 6:
                     $Type = '3';
                     $Robot = true;
                     break;
                 default:
                     $Type = 'identicon';
             }
             $Rating = 'pg';
             if (!$Robot) {
                 $URL = 'https://secure.gravatar.com/avatar/' . md5(strtolower(trim($Username))) . "?s={$Size}&amp;d={$Type}&amp;r={$Rating}";
             } else {
                 $URL = 'https://robohash.org/' . md5($Username) . "?set=set{$Type}&amp;size={$Size}x{$Size}";
             }
             if ($ShowAvatar == true && !empty($Avatar)) {
                 $ToReturn = $ReturnHTML ? "<div><img src=\"{$Avatar}\" width=\"{$Size}\" {$Style} {$AvatarMouseOverText}{$SecondAvatar} {$Class} /></div>" : $Avatar;
             } else {
                 $ToReturn = $ReturnHTML ? "<div><img src=\"{$URL}\" width=\"{$Size}\" {$Style} {$AvatarMouseOverText}{$SecondAvatar} {$Class} /></div>" : $URL;
             }
             break;
         default:
             $URL = STATIC_SERVER . 'common/avatars/default.png';
             $ToReturn = $ReturnHTML ? "<div><img src=\"{$URL}\" width=\"{$Size}\" {$Style} {$AvatarMouseOverText}{$SecondAvatar} {$Class}/></div>" : $URL;
     }
     return $ToReturn;
 }
Ejemplo n.º 21
0
            $ArtistName = Artists::display_artists(Artists::get_artist($GroupID), false, false, false);
            if ($ArtistName) {
                $Name = "{$ArtistName} - {$Name}";
            }
            if ($Format && $Encoding) {
                $Name .= " [{$Format} / {$Encoding}]";
            }
            $TorrentAlerts[$UserID]['Msg'] .= "\n[url=" . site_url() . "torrents.php?torrentid={$ID}]" . $Name . "[/url]";
            $TorrentAlerts[$UserID]['Count']++;
        }
        foreach ($TorrentAlerts as $UserID => $MessageInfo) {
            Misc::send_pm($UserID, 0, 'Unseeded torrent notification', $MessageInfo['Count'] . " of your uploads will be deleted for inactivity soon. Unseeded torrents are deleted after 4 weeks. If you still have the files, you can seed your uploads by ensuring the torrents are in your client and that they aren't stopped. You can view the time that a torrent has been unseeded by clicking on the torrent description line and looking for the \"Last active\" time. For more information, please go [url=" . site_url() . "wiki.php?action=article&amp;id=663]here[/url].\n\nThe following torrent" . ($MessageInfo['Count'] > 1 ? 's' : '') . ' will be removed for inactivity:' . $MessageInfo['Msg'] . "\n\nIf you no longer wish to receive these notifications, please disable them in your profile settings.");
        }
    }
    $DB->query("\n\t\tUPDATE staff_pm_conversations\n\t\tSET Status = 'Resolved', ResolverID = '0'\n\t\tWHERE Date < NOW() - INTERVAL 1 MONTH\n\t\t\tAND Status = 'Open'\n\t\t\tAND AssignedToUser IS NULL");
    Donations::schedule();
}
/*************************************************************************\
//--------------Run twice per month -------------------------------------//

These functions are twice per month, on the 8th and the 22nd.

\*************************************************************************/
if ($BiWeek != $NextBiWeek || $_GET['runbiweek']) {
    echo "Ran bi-weekly functions\n";
    //------------- Cycle auth keys -----------------------------------------//
    $DB->query("\n\t\tUPDATE users_info\n\t\tSET AuthKey =\n\t\t\tMD5(\n\t\t\t\tCONCAT(\n\t\t\t\t\tAuthKey, RAND(), '" . db_string(Users::make_secret()) . "',\n\t\t\t\t\tSHA1(\n\t\t\t\t\t\tCONCAT(\n\t\t\t\t\t\t\tRAND(), RAND(), '" . db_string(Users::make_secret()) . "'\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t);");
    //------------- Give out invites! ---------------------------------------//
    /*
    	Power Users have a cap of 2 invites. Elites have a cap of 4.
    	Every month, on the 8th and the 22nd, each PU/Elite user gets one invite up to their max.
Ejemplo n.º 22
0
 /**
  * Create the part of WHERE in the sql queries used to filter forums for a
  * specific user (MinClassRead, restricted and permitted forums).
  * @return string
  */
 public static function user_forums_sql()
 {
     // I couldn't come up with a good name, please rename this if you can. -- Y
     $RestrictedForums = self::get_restricted_forums();
     $PermittedForums = self::get_permitted_forums();
     if (Donations::has_donor_forum(G::$LoggedUser['ID']) && !in_array(DONOR_FORUM, $PermittedForums)) {
         $PermittedForums[] = DONOR_FORUM;
     }
     $SQL = "((f.MinClassRead <= '" . G::$LoggedUser['Class'] . "'";
     if (count($RestrictedForums)) {
         $SQL .= " AND f.ID NOT IN ('" . implode("', '", $RestrictedForums) . "')";
     }
     $SQL .= ')';
     if (count($PermittedForums)) {
         $SQL .= " OR f.ID IN ('" . implode("', '", $PermittedForums) . "')";
     }
     $SQL .= ')';
     return $SQL;
 }
Ejemplo n.º 23
0
    header("Location: log.php?search=User+{$UserID}");
}
$Cur = $DB->next_record(MYSQLI_ASSOC, false);
if ($_POST['comment_hash'] != $Cur['CommentHash']) {
    error("Somebody else has moderated this user since you loaded it. Please go back and refresh the page.");
}
//NOW that we know the class of the current user, we can see if one staff member is trying to hax0r us.
if (!check_perms('users_mod', $Cur['Class'])) {
    //Son of a f*****g bitch
    error(403);
    die;
}
if (!empty($_POST['donor_points_submit']) && !empty($_POST['donation_value']) && is_numeric($_POST['donation_value'])) {
    Donations::regular_donate($UserID, $_POST['donation_value'], "Add Points", $_POST['donation_reason'], $_POST['donation_currency']);
} elseif (!empty($_POST['donor_values_submit'])) {
    Donations::update_rank($UserID, $_POST['donor_rank'], $_POST['total_donor_rank'], $_POST['reason']);
}
// If we're deleting the user, we can ignore all the other crap
if ($_POST['UserStatus'] === 'delete' && check_perms('users_delete_users')) {
    Misc::write_log("User account {$UserID} (" . $Cur['Username'] . ") was deleted by " . $LoggedUser['Username']);
    $DB->query("\n\t\tDELETE FROM users_main\n\t\tWHERE id = {$UserID}");
    $DB->query("\n\t\tDELETE FROM users_info\n\t\tWHERE UserID = {$UserID}");
    $Cache->delete_value("user_info_{$UserID}");
    Tracker::update_tracker('remove_user', array('passkey' => $Cur['torrent_pass']));
    header("Location: log.php?search=User+{$UserID}");
    die;
}
// User was not deleted. Perform other stuff.
$UpdateSet = array();
$EditSummary = array();
$TrackerUserUpdates = array('passkey' => $Cur['torrent_pass']);
Ejemplo n.º 24
0
    public static function render_donor_stats($UserID)
    {
        $OwnProfile = G::$LoggedUser['ID'] == $UserID;
        if (check_perms("users_mod") || $OwnProfile || Donations::is_visible($UserID)) {
            ?>
			<div class="box box_info box_userinfo_donor_stats">
				<div class="head colhead_dark">Donor Statistics</div>
				<ul class="stats nobullet">
<?php 
            if (Donations::is_donor($UserID)) {
                if (check_perms('users_mod') || $OwnProfile) {
                    ?>
					<li>
						Total donor points: <?php 
                    echo Donations::get_total_rank($UserID);
                    ?>
					</li>
<?php 
                }
                ?>
					<li>
						Current donor rank: <?php 
                echo self::render_rank(Donations::get_rank($UserID), Donations::get_special_rank($UserID), true);
                ?>
					</li>
					<li>
						Leaderboard position: <?php 
                echo Donations::get_leaderboard_position($UserID);
                ?>
					</li>
					<li>
						Last donated: <?php 
                echo time_diff(Donations::get_donation_time($UserID));
                ?>
					</li>
					<li>
						Rank expires: <?php 
                echo Donations::get_rank_expiration($UserID);
                ?>
					</li>
<?php 
            } else {
                ?>
					<li>
						This user hasn't donated.
					</li>
<?php 
            }
            ?>
				</ul>
			</div>
<?php 
        }
    }