Inheritance: extends CI_Controller
Example #1
0
 /**
  * process a request
  *
  * @param $params
  */
 function processRequest($params)
 {
     // create new instance
     $instanceStats = new Stats($params);
     // call instance-method
     $instanceStats->instance_processRequest();
 }
Example #2
0
 function FindNewGenerations($bitcoinController)
 {
     $blockcount = 0;
     $username = '';
     //Get list of last 200 transactions
     $transactions = $bitcoinController->query("listtransactions", "*", "200");
     //Go through all the transactions check if there is 50BTC inside
     $numAccounts = count($transactions);
     for ($i = 0; $i < $numAccounts; $i++) {
         //Check for 50BTC inside only if they are in the generate category
         if ($transactions[$i]["category"] == "generate" || $transactions[$i]["category"] == "immature") {
             //At this point we may or may not have found a block,
             //Check to see if this account addres is already added to `networkBlocks`
             $accountExistsQ = mysql_query("SELECT id FROM networkBlocks WHERE accountAddress = '" . $transactions[$i]["txid"] . "' ORDER BY blockNumber DESC LIMIT 0,1") or sqlerr(__FILE__, __LINE__);
             $accountExists = mysql_num_rows($accountExistsQ);
             //Insert txid into latest network block
             if (!$accountExists) {
                 //Get last winning block
                 $lastSuccessfullBlockQ = mysql_query("SELECT blockNumber, id, username FROM winning_shares ORDER BY id DESC LIMIT 1") or sqlerr(__FILE__, __LINE__);
                 $lastSuccessfullBlockR = mysql_fetch_object($lastSuccessfullBlockQ);
                 $timestamp = $transactions[$i]["time"];
                 $id = $lastSuccessfullBlockR->id;
                 $rpcType = "http";
                 // http or https
                 $rpcUsername = "******";
                 // username
                 $rpcPassword = "******";
                 // password
                 $rpcHost = "localhost";
                 $rpcPort = 9000;
                 $bitcoinController = new BitcoinClient($rpcType, $rpcUsername, $rpcPassword, $rpcHost, $rpcPort);
                 $currentBlockNumber = $bitcoinController->getblocknumber();
                 $confirms = $transactions[$i]["confirmations"];
                 $lastBlockNumber = $currentBlockNumber + 1 - $confirms;
                 $stats = new Stats();
                 mysql_query("INSERT INTO networkBlocks (blockNumber, timestamp, accountAddress, confirms) " . "VALUES ('{$lastBlockNumber}', '{$timestamp}', '" . $transactions[$i]["txid"] . "', '" . $transactions[$i]["confirmations"] . "')") or sqlerr(__FILE__, __LINE__);
                 $stats = new Stats();
                 $lastwinningid = $stats->lastWinningShareId();
                 $shareQ = mysql_query("SELECT sum(shares) as total from rounddetails WHERE blockNumber = {$lastBlockNumber}");
                 $shareC = mysql_fetch_object($shareQ);
                 $winningShareQ = mysql_query("SELECT id, username FROM shares where upstream_result = 'Y' AND id > {$lastwinningid}") or sqlerr(__FILE__, __LINE__);
                 while ($winningShareR = mysql_fetch_object($winningShareQ)) {
                     mysql_query("INSERT INTO winning_shares (blockNumber, username, share_id) VALUES ({$lastBlockNumber},'{$winningShareR->username}',{$winningShareR->id})") or sqlerr(__FILE__, __LINE__);
                     removeCache("last_winning_share_id");
                 }
                 //					$q = "UPDATE winning_shares SET amount = " . $transactions[$i]["amount"] . ", timestamp = " . $timestamp . ", txid = '".$transactions[$i]["txid"] . "', type = '" . $transactions[$i]["category"] . "', shares = ". $shareC->total . " WHERE blockNumber = $lastBlockNumber";
                 $q = "UPDATE winning_shares SET amount = " . $transactions[$i]["amount"] . ", timestamp = " . $timestamp . ", txid = '" . $transactions[$i]["txid"] . "', type = '" . $transactions[$i]["category"] . "' WHERE blockNumber = {$lastBlockNumber}";
                 echo $q;
                 mysql_query($q) or sqlerr(__FILE__, __LINE__);
                 $username = $lastSuccessfullBlockR->username;
                 $splitUsername = explode(".", $username);
                 $realUsername = $splitUsername[0];
                 $blockcount = $blockcount + 1;
                 $username .= $realUsername . ' ';
             }
         }
     }
 }
Example #3
0
 public static function getStats($campaign)
 {
     $params = array('id' => $campaign);
     # Call
     $response = static::$mj->messageStatistics($params);
     # Result
     $res = (array) $response->result;
     $stats = new Stats();
     return $stats->populate($res);
 }
 public static function show($id)
 {
     $pokemon = Pokemons::find($id);
     //$joins = Joins::getJoins($id);
     $stats = Stats::getStats($id);
     View::make('Pokemons/:id.html', array('pokemon' => $pokemon, 'stats' => $stats));
 }
Example #5
0
 public function getStats()
 {
     if (is_null(self::$me)) {
         self::$me = new Stats();
     }
     return self::$me;
 }
 public function index()
 {
     $stats = new Stats();
     $stats->addStatSubject('ViralList', 'List');
     $todayStats = $stats->getTodayStats();
     $overallStats = $stats->getOverallStats();
     View::share(array('overallStats' => $overallStats, 'todayStats' => $todayStats));
     /*
             $last30DaysNewItems = Stats::getDailyStatsFor('ItemModelName', 30);
             View::share(array('last30DaysNewItems' => json_encode($last30DaysNewItems)));
     */
     $last30DaysUserRegistrations = Stats::getDailyStatsFor('User', 30);
     $last30DaysNewLists = Stats::getDailyStatsFor('ViralList', 30);
     View::share(array('last30DaysUserRegistrations' => json_encode($last30DaysUserRegistrations), 'last30DaysNewLists' => json_encode($last30DaysNewLists)));
     return View::make('admin/index');
 }
Example #7
0
 public function procede()
 {
     $aStats = Stats::getGlobalStats();
     $this->oView->addData('textItems', $aStats);
     $this->oView->addData('trackers', Tracker::getTrackersSelect());
     $this->oView->Create();
 }
Example #8
0
 public static function newInstance()
 {
     if (!self::$instance instanceof self) {
         self::$instance = new self();
     }
     return self::$instance;
 }
 public function testRanked()
 {
     $this->client->shouldReceive('baseUrl')->once();
     $this->client->shouldReceive('request')->with('na/v1.3/stats/by-summoner/74602/ranked', ['api_key' => 'key'])->once()->andReturn(file_get_contents('tests/Json/stats.ranked.74602.season4.json'));
     Api::setKey('key', $this->client);
     $stats = Stats::ranked(74602);
     $this->assertTrue($stats->champion(0) instanceof LeagueWrap\Dto\ChampionStats);
 }
Example #10
0
 /**
  * Get the query builder object for the Stats model's table prepared with the requested items,
  * ordered by one of the stats column.
  *
  * @param $days String one_day_stats|seven_days_stats|thirty_days_stats|all_time_stats
  * @param $orderType String ASC|DESC
  * @param $modelType String Filter by this Eloquent Model type
  * @param $limit int Number of items to return
  * @return \Illuminate\Database\Eloquent\Builder
  */
 public function getStats($days = 'one_day_stats', $orderType = 'DESC', $modelType = '', $limit = null)
 {
     $stats = new Stats();
     $query = $stats->newQuery();
     if (!empty($modelType)) {
         $query->where('trackable_type', '=', $modelType);
     }
     // Only retrieve elements with at least 1 hit in the requested period
     if (!empty($days)) {
         $query->where($days, '!=', 0);
     }
     if (!empty($limit)) {
         $query->take($limit);
     }
     $query->orderBy($days, $orderType);
     return $query;
 }
function smarty_function_mtstatssnippet($args, &$ctx)
{
    $provider = Stats::readied_provider($ctx->stash('blog'));
    if (empty($provider)) {
        return '';
    }
    return $provider->snippet($args, $ctx);
}
Example #12
0
 /**
  * executes query
  *
  * @param string $sql
  * @return result
  */
 public function query($sql)
 {
     $sqlDebug = defined("DEBUG") && DEBUG && isset($_REQUEST["sql_debug"]);
     $sql = $sql;
     if ($sqlDebug) {
         $stats = new Stats();
     }
     $this->querycount++;
     $res = mysql_query($sql, $this->connection) or $this->error(mysql_error(), $sql);
     if ($sqlDebug) {
         $stats->storeDifference();
         echo "\n<!--\n";
         echo "Query #{$this->querycount}: {$sql}\n";
         echo "Memory used: {$stats->memUsedFmted} bytes\n";
         echo "Time spent: {$stats->timeSpent} seconds\n";
         echo "-->\n";
     }
     return $res;
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     try {
         $log = new Process();
         $log->name = "get-shares";
         $log->status = "running";
         $log->save();
         $filterDate = new DateTime('now');
         $filterDate->sub(new DateInterval('P1D'));
         //Load shares
         Link::where('date', '>', $filterDate)->chunk(100, function ($links) {
             foreach ($links as $value) {
                 $shares = $this->getSharesCount($value->final_url);
                 $ref = Stats::where('id_link', $value->id)->orderBy('created_at', 'DESC')->first();
                 if (!$ref) {
                     $ref = new stdClass();
                     $ref->total = 0;
                 }
                 $stat = new Stats();
                 $stat->id_link = $value->id;
                 $stat->facebook = $shares['facebook'] != null ? $shares['facebook'] : $value->facebook;
                 $stat->twitter = $shares['twitter'] != null ? $shares['twitter'] : $value->twitter;
                 $stat->linkedin = $shares['linkedin'] != null ? $shares['linkedin'] : $value->linkedin;
                 $stat->googleplus = $shares['googleplus'] != null ? $shares['googleplus'] : $value->googleplus;
                 $stat->total = $stat->facebook + $stat->twitter + $stat->linkedin + $stat->googleplus;
                 $stat->dif_total = $stat->total - $ref->total;
                 $stat->save();
                 $value->facebook = $stat->facebook;
                 $value->twitter = $stat->twitter;
                 $value->linkedin = $stat->linkedin;
                 $value->googleplus = $stat->googleplus;
                 $value->total = $stat->total;
                 $value->save();
             }
         });
         $log->status = "finished";
         $log->save();
     } catch (Exception $e) {
         $this->info($url);
         $this->info($e->getMessage());
     }
 }
		function visit($countRobotVisit = 'y') {
			global $database, $db;
			if ($countRobotVisit == 'n' && Stats::isKnownBot($_SERVER["HTTP_USER_AGENT"])) return;

			$now = time();
			$db->query('SELECT date FROM '.$database['prefix'].'DailyStatistics WHERE date="'.date('Ymd', $now).'"');
			if ($db->numRows() < 1) {
				$db->execute('INSERT INTO '.$database['prefix'].'DailyStatistics (date) VALUES ("'.date('Ymd', $now).'")');
			}
			$db->free();
			$db->execute('UPDATE '.$database['prefix'].'DailyStatistics SET visits=visits+1 WHERE date="'.date('Ymd', $now).'"');
			$db->execute('UPDATE '.$database['prefix'].'Settings SET value=value+1 WHERE name = "totalVisit"');
		}
 public function getSparklinesData($ids)
 {
     $ids = explode(',', $ids);
     if (count($ids) > 10) {
         $ids = array_slice($ids, 0, 10);
     }
     $response = array();
     foreach ($ids as $key => $id) {
         $response[$id]['total'] = Stats::where('id_link', $id)->lists('total');
         $response[$id]['dif_total'] = Stats::where('id_link', $id)->lists('dif_total');
     }
     return Response::json(array('data' => $response));
 }
Example #16
0
function doSupers($row)
{
    global $mdb;
    $type = $row['type'];
    $id = (int) $row['id'];
    $query = [$type => (int) $id, 'isVictim' => false, 'groupID' => [659, 30], 'pastSeconds' => 90 * 86400];
    $query = MongoFilter::buildQuery($query);
    $hasSupers = $mdb->exists('killmails', $query);
    if ($hasSupers == false) {
        $mdb->set("statistics", ['type' => $type, 'id' => $id], ['hasSupers' => false, 'supers' => []]);
    } else {
        $supers = Stats::getSupers($type, $id);
        $mdb->set("statistics", ['type' => $type, 'id' => $id], ['hasSupers' => true, 'supers' => $supers]);
    }
}
Example #17
0
 public function execute($parameters, $db)
 {
     $p = array();
     $p["limit"] = 5;
     $p["pastSeconds"] = 3 * 86400;
     $p["kills"] = true;
     Storage::store("Top3dayChars", json_encode(Info::doMakeCommon("Top Characters - Last 3 Days", "characterID", Stats::getTopPilots($p))));
     Storage::store("Top3dayCorps", json_encode(Info::doMakeCommon("Top Corporations - Last 3 Days", "corporationID", Stats::getTopCorps($p))));
     Storage::store("Top3dayAlli", json_encode(Info::doMakeCommon("Top Alliances - Last 3 Days", "allianceID", Stats::getTopAllis($p))));
     Storage::store("TopIsk", json_encode(Stats::getTopIsk(array("pastSeconds" => 3 * 86400, "limit" => 5))));
     Storage::store("TopPods", json_encode(Stats::getTopIsk(array("groupID" => 29, "pastSeconds" => 3 * 86400, "limit" => 5))));
     Storage::store("TopPoints", json_encode(Stats::getTopPoints("killID", array("losses" => true, "pastSeconds" => 3 * 86400, "limit" => 5))));
     Storage::store("KillCount", $db->queryField("select count(*) count from zz_killmails", "count"));
     Storage::store("ActualKillCount", $db->queryField("select count(*) count from zz_killmails where processed = 1", "count"));
 }
Example #18
0
function calcTop($row)
{
    global $mdb;
    if (date('d') != '01' && isset($row['topAllTime'])) {
        return;
    }
    $parameters = [$row['type'] => $row['id']];
    $parameters['limit'] = 10;
    $parameters['kills'] = true;
    $topLists[] = array('type' => 'character', 'data' => Stats::getTop('characterID', $parameters));
    $topLists[] = array('type' => 'corporation', 'data' => Stats::getTop('corporationID', $parameters, true));
    $topLists[] = array('type' => 'alliance', 'data' => Stats::getTop('allianceID', $parameters, true));
    $topLists[] = array('type' => 'faction', 'data' => Stats::getTop('factionID', $parameters, true));
    $topLists[] = array('type' => 'ship', 'data' => Stats::getTop('shipTypeID', $parameters, true));
    $topLists[] = array('type' => 'system', 'data' => Stats::getTop('solarSystemID', $parameters, true));
    do {
        $r = $mdb->set('statistics', $row, ['topAllTime' => $topLists]);
    } while ($r['ok'] != 1);
}
Example #19
0
function calcTop($row)
{
    global $mdb;
    $timer = new Timer();
    $currentSum = (int) @$row['shipsDestroyed'];
    $parameters = [$row['type'] => $row['id']];
    $parameters['limit'] = 10;
    $parameters['kills'] = true;
    $topLists[] = array('type' => 'character', 'data' => Stats::getTop('characterID', $parameters));
    $topLists[] = array('type' => 'corporation', 'data' => Stats::getTop('corporationID', $parameters, true));
    $topLists[] = array('type' => 'alliance', 'data' => Stats::getTop('allianceID', $parameters, true));
    $topLists[] = array('type' => 'faction', 'data' => Stats::getTop('factionID', $parameters, true));
    $topLists[] = array('type' => 'ship', 'data' => Stats::getTop('shipTypeID', $parameters, true));
    $topLists[] = array('type' => 'system', 'data' => Stats::getTop('solarSystemID', $parameters, true));
    $mdb->set('statistics', $row, ['topAllTime' => $topLists, 'allTimeSum' => $currentSum]);
    if ($timer->stop() > 60000) {
        exit;
    }
}
Example #20
0
 public function route()
 {
     if ($this->runlevel == 1) {
         $this->startup();
     }
     $cache = CMS7_Content_Cache::getInstance();
     $vars = $this->getURIVars();
     if (isset($vars['flushCache'])) {
         $cache->flush();
     }
     $key = $this->cacheGetKey();
     if (!($content = $this->cacheGet($key))) {
         $this->runlevel = 3;
         $content = $this->renderRoute((object) $vars);
         $this->cacheSet($key, $content);
     }
     $this->runlevel = 4;
     echo $content;
     Stats::logRequest();
 }
Example #21
0
function calcTop($row)
{
    global $mdb;
    $allTimeSum = (int) @$row['allTimeSum'];
    $currentSum = (int) @$row['shipsDestroyed'];
    if ($allTimeSum == $currentSum) {
        return;
    }
    $parameters = [$row['type'] => $row['id']];
    $parameters['limit'] = 10;
    $parameters['kills'] = true;
    $topLists[] = array('type' => 'character', 'data' => Stats::getTop('characterID', $parameters));
    $topLists[] = array('type' => 'corporation', 'data' => Stats::getTop('corporationID', $parameters, true));
    $topLists[] = array('type' => 'alliance', 'data' => Stats::getTop('allianceID', $parameters, true));
    $topLists[] = array('type' => 'faction', 'data' => Stats::getTop('factionID', $parameters, true));
    $topLists[] = array('type' => 'ship', 'data' => Stats::getTop('shipTypeID', $parameters, true));
    $topLists[] = array('type' => 'system', 'data' => Stats::getTop('solarSystemID', $parameters, true));
    do {
        $r = $mdb->set('statistics', $row, ['topAllTime' => $topLists, 'allTimeSum' => $currentSum]);
    } while ($r['ok'] != 1);
}
Example #22
0
 function doModel()
 {
     switch ($this->action) {
         case 'logout':
             // unset only the required parameters in Session
             $this->logout();
             $this->redirectTo(osc_admin_base_url(true));
             break;
         default:
             //default dashboard page (main page at oc-admin)
             $this->_exportVariableToView("numItemsPerCategory", osc_get_non_empty_categories());
             $this->_exportVariableToView("numUsers", User::newInstance()->count());
             $this->_exportVariableToView("numItems", Item::newInstance()->count());
             $this->_exportVariableToView('newsList', osc_listNews());
             $this->_exportVariableToView('twitterRSS', osc_latestTweets());
             // stats
             $items = array();
             $stats_items = Stats::newInstance()->new_items_count(date('Y-m-d H:i:s', mktime(0, 0, 0, date("m"), date("d") - 10, date("Y"))), 'day');
             for ($k = 10; $k >= 0; $k--) {
                 $items[date('Y-m-d', mktime(0, 0, 0, date("m"), date("d") - $k, date("Y")))] = 0;
             }
             foreach ($stats_items as $item) {
                 $items[$item['d_date']] = $item['num'];
             }
             $users = array();
             $stats_users = Stats::newInstance()->new_users_count(date('Y-m-d H:i:s', mktime(0, 0, 0, date("m"), date("d") - 10, date("Y"))), 'day');
             for ($k = 10; $k >= 0; $k--) {
                 $users[date('Y-m-d', mktime(0, 0, 0, date("m"), date("d") - $k, date("Y")))] = 0;
             }
             foreach ($stats_users as $user) {
                 $users[$user['d_date']] = $user['num'];
             }
             $this->_exportVariableToView("item_stats", $items);
             $this->_exportVariableToView("user_stats", $users);
             //calling the view...
             $this->doView('main/index.php');
     }
 }
Example #23
0
 public function execute($nick, $uhost, $channel, $command, $parameters, $nickAccessLevel)
 {
     if (Util::isMaintenanceMode()) {
         irc_error("|r|Cannot reprice while in maintenance mode");
     }
     @($killID = (int) $parameters[0]);
     if ($killID == 0) {
         irc_error("|r|Please provide a valid killID.");
     }
     $count = Db::queryField("select count(*) count from zz_participants where killID = :killID", "count", array(":killID" => $killID));
     if ($count == 0) {
         irc_error("|r|KillID {$killID} does not exist!");
     }
     Stats::calcStats($killID, false);
     Db::execute("update zz_killmails set processed = 0 where killID = :killID", array(":killID" => $killID));
     do {
         sleep(1);
         $processed = Db::queryField("select processed from zz_killmails where killID = :killID", "processed", array(":killID" => $killID), 0);
     } while ($processed == 0);
     $kill = Db::queryRow("select * from zz_participants where isVictim = 1 and killID = :killID", array(":killID" => $killID), 0);
     $total = $kill["total_price"];
     $points = $kill["points"];
     irc_out("|g|{$killID}|n| repriced to|g| " . number_format($total, 2) . "|n| ISK and |g|" . number_format($points, 0) . "|n| points");
 }
Example #24
0
 $topPoints = array();
 $topIsk = Stats::getTopIsk(array('cacheTime' => 15 * 60, 'pastSeconds' => 7 * 86400, 'limit' => 5));
 $topPods = array();
 $top = array();
 $top[] = json_decode(Storage::retrieve('TopChars', [], 900), true);
 $top[] = json_decode(Storage::retrieve('TopCorps', [], 900), true);
 $top[] = json_decode(Storage::retrieve('TopAllis', [], 900), true);
 $top[] = json_decode(Storage::retrieve('TopShips', [], 900), true);
 $top[] = json_decode(Storage::retrieve('TopSystems', [], 900), true);
 // get latest kills
 $kills = Kills::getKills(array('cacheTime' => 60, 'limit' => 50));
 // Collect active PVP stats
 $types = ['characterID', 'corporationID', 'allianceID', 'shipTypeID', 'solarSystemID', 'regionID'];
 $activePvP = [];
 foreach ($types as $type) {
     $result = Stats::getDistinctCount($type, []);
     if ($result <= 1) {
         continue;
     }
     $type = str_replace('ID', '', $type);
     if ($type == 'shipType') {
         $type = 'Ship';
     } elseif ($type == 'solarSystem') {
         $type = 'System';
     } else {
         $type = ucfirst($type);
     }
     $type = $type . 's';
     $row['type'] = $type;
     $row['count'] = $result;
     $activePvP[] = $row;
Example #25
0
 public function procede()
 {
     if (!$this->oRequest->existParam('key')) {
         throw new Error('Vous devez renseigner la clé.', 3003);
     }
     if ($this->oRequest->getParam('key', 'string') != Config::get('ingestkey')) {
         throw new Error('La clé est invalide.', 3003);
     }
     //Ajoute du titre
     $this->oView->addData('titre', 'Analyse des flux RSS');
     //On récupère les éléments pour les statistiques
     $iNbReleases = Release::getCount();
     $iNbTorrents = Torrent::getCount();
     $iStartTime = time();
     //Traitement des Trackers
     $aTrackers = Tracker::getTrackers();
     //Ajout des flux
     $aRssList = Rss::getFlux();
     foreach ($aRssList as $oRss) {
         $aTrackers[$oRss->getTrackerId()]->addFlux($oRss);
     }
     //Parsage des flux
     $aResults = array();
     foreach ($aTrackers as $oTracker) {
         $aResults = array_merge($aResults, $oTracker->parseRss());
     }
     //Traitement des résultats
     $oTable = new TableGenerator();
     $oTable->setId(md5('Ingest'));
     $oTable->addColumn('Tags');
     $oTable->addColumn('Tracker');
     $oTable->addColumn('Release');
     foreach ($aResults as $oResult) {
         if (is_string($oResult)) {
             Logger::log('ingest', $oResult);
             $this->oView->addAlert($oResult, 'danger');
         } else {
             $oResult->store();
             $sTags = '';
             foreach ($oResult->getTags() as $oTag) {
                 $oTagView = new View('label');
                 $oTagView->addData('type', 'info');
                 $oTagView->addData('text', $oTag->getName());
                 $oTagView->create();
                 $sTags .= $oTagView->getCode() . '&nbsp;';
             }
             $oTable->addLine(array($sTags, $aTrackers[$oResult->getTracker()]->getName(), $oResult->getReleaseName()));
         }
     }
     //Statistiques
     $iNewReleases = Release::getCount() - $iNbReleases;
     $iNewTorrents = Torrent::getCount() - $iNbTorrents;
     Stats::storeIngestStats($iNewReleases, $iNewTorrents, date("Y-m-j G:i:s", $iStartTime));
     //Enregistrement de la dernière date de vérification
     Rss::updateLastCheck(date("Y-m-j G:i:s", $iStartTime));
     Logger::log('ingest', $iNewReleases . ' nouvelles releases et ' . $iNewTorrents . ' nouveaux torrents.');
     $oTable->setBottom($iNewReleases . ' nouvelles releases et ' . $iNewTorrents . ' nouveaux torrents.');
     $oTable->create();
     $this->oView->addData('content', $oTable->getCode());
     $this->oView->Create();
 }
Example #26
0
<!DOCTYPE html>
<?php 
require_once 'config.php';
if (!file_exists(NN_WWW . DS . 'config.php')) {
    # send the browser to the configuration page, something is wrong!
    header("Location: configure.php");
}
require_once 'lib/stats.php';
$stats = new Stats();
?>

<html lang="en">
<meta http-equiv="refresh" content="30">
<?php 
include 'includes/header.php';
?>
<body>
<?php 
include 'includes/topbar.php';
?>
<div class="container-fluid">
	<div class="row-fluid">
		<?php 
include 'includes/leftmenu.php';
?>
		<noscript>
			<div class="alert alert-block span10">
				<h4 class="alert-heading">Warning!</h4>
				<p>You need to have <a href="http://en.wikipedia.org/wiki/JavaScript" target="_blank">JavaScript</a>
					enabled to use this site.</p>
			</div>
Example #27
0
 /**
  * save_songplay
  * This takes care of queueing and then submitting the tracks.
  */
 public function save_mediaplay($song)
 {
     // Only support songs
     if (strtolower(get_class($song)) != 'song') {
         return false;
     }
     // Make sure there's actually a session before we keep going
     if (!$this->challenge) {
         debug_event($this->name, 'Session key missing', '5');
         return false;
     }
     // Let's pull the last song submitted by this user
     $previous = Stats::get_last_song($this->user_id);
     $diff = time() - $previous['date'];
     // Make sure it wasn't within the last min
     if ($diff < 60) {
         debug_event($this->name, 'Last song played within ' . $diff . ' seconds, not recording stats', '3');
         return false;
     }
     if ($song->time < 30) {
         debug_event($this->name, 'Song less then 30 seconds not queueing', '3');
         return false;
     }
     // Create our scrobbler and then queue it
     $scrobbler = new scrobbler($this->api_key, $this->scheme, $this->api_host, $this->challenge, $this->secret);
     // Check to see if the scrobbling works by queueing song
     if (!$scrobbler->queue_track($song->f_artist_full, $song->f_album_full, $song->title, time(), $song->time, $song->track)) {
         return false;
     }
     // Go ahead and submit it now
     if (!$scrobbler->submit_tracks()) {
         debug_event($this->name, 'Error Submit Failed: ' . $scrobbler->error_msg, '3');
         return false;
     }
     debug_event($this->name, 'Submission Successful', '5');
     return true;
 }
Example #28
0
$atom_list = array();
$tmps = 0;
#$res = $DBc->sendSQL("SELECT at_id FROM ach_task WHERE NOT EXISTS (SELECT * FROM ach_player_task WHERE apt_player='".$cdata['cid']."' AND apt_task=at_id) AND at_dev='0' AND (NOT EXISTS (SELECT * FROM ach_task_tie_align WHERE atta_task=at_id) OR EXISTS (SELECT * FROM ach_task_tie_align WHERE atta_task=at_id AND atta_alignment LIKE '".$cdata['cult'].'|'.$cdata['civ']."'))","ARRAY");
#foreach($res as $task) {
//get unfinished atoms belonging to unfinished objectives
$res2 = $DBc->sendSQL("SELECT ach_atom.* FROM ach_atom,ach_objective,ach_task WHERE ao_task=at_id AND ao_id=atom_objective AND NOT EXISTS (SELECT * FROM ach_player_objective WHERE apo_player='" . $cdata['cid'] . "' AND apo_objective=ao_id) AND NOT EXISTS (SELECT * FROM ach_player_task WHERE apt_player='" . $cdata['cid'] . "' AND apt_task=at_id) AND at_dev='0' AND (NOT EXISTS (SELECT * FROM ach_task_tie_align WHERE atta_task=at_id) OR EXISTS (SELECT * FROM ach_task_tie_align WHERE atta_task=at_id AND atta_alignment LIKE '" . $cdata['cult'] . '|' . $cdata['civ'] . "'))", "ARRAY");
foreach ($res2 as $atom) {
    $a = new Atom($atom, $cdata);
    $atom_list[] = $a;
    $atom_list[] = $a;
    $a->register();
}
$tmps += sizeof($res2);
#}
$log->logf("loaded atoms: " . $tmps);
$statsdb = new Stats();
$statsdb->register();
#$log->logf("done!");
#$log->logf("Memory load: ".memory_get_usage()." bytes");
$microstop = explode(' ', microtime());
$stop_time = $microstop[0] + $microstop[1];
#$log->logf("Expired time: ".($stop_time - $start_time));
#$log->logi("Driving data... ",false);
#STEP 2: drive data
$_CACHE->setChar($cdata);
$res = $DBc->sendSQL("SELECT sum(at_value) as anz FROM ach_task,ach_player_task WHERE at_id=apt_task AND apt_player='" . $cdata['cid'] . "'", "ARRAY");
$_DISPATCHER->dispatchValue("yubopoints", $res[0]['anz']);
$_DISPATCHER->dispatchValue("aid", $cdata['aid']);
$_DISPATCHER->dispatchValue("cid", $cdata['cid']);
$_DISPATCHER->dispatchValue("sid", $cdata['sid']);
$_DATASOURCE->drive($cdata);
 public function __construct($startDate = NULL, $endDate = NULL, $network = NULL, $clicks = NULL, $impressions = NULL, $cost = NULL, $averagePosition = NULL, $averageCpc = NULL, $averageCpm = NULL, $ctr = NULL, $conversions = NULL, $viewThroughConversions = NULL, $totalBudget = NULL, $StatsType = NULL)
 {
     parent::__construct();
     $this->startDate = $startDate;
     $this->endDate = $endDate;
     $this->network = $network;
     $this->clicks = $clicks;
     $this->impressions = $impressions;
     $this->cost = $cost;
     $this->averagePosition = $averagePosition;
     $this->averageCpc = $averageCpc;
     $this->averageCpm = $averageCpm;
     $this->ctr = $ctr;
     $this->conversions = $conversions;
     $this->viewThroughConversions = $viewThroughConversions;
     $this->totalBudget = $totalBudget;
     $this->StatsType = $StatsType;
 }
Example #30
0
 public function setStats($node, $node_id, $set_avg = false)
 {
     foreach (Stats::getAllStats(T_OBJ_COACH, $this->coach_id, $node, $node_id, $set_avg) as $key => $val) {
         $this->{$key} = $val;
     }
     return true;
 }