Beispiel #1
0
 /**
  * 
  * @return string
  */
 public function routeStatisticsJson($code, $dataset)
 {
     try {
         $context = $this->getContext('statistics');
         if ($context) {
             $stats = Statistics::getInstance();
             $stats->setAccount($this->user->getAccount());
             if (preg_match('!^wallet-([0-9]+)$!', $dataset, $m)) {
                 $method = 'getDatasetWallet';
                 if (method_exists($stats, $method)) {
                     $data = $stats->{$method}($m[1]);
                     if (!empty($data)) {
                         $response = new ResponseJson($data);
                     }
                 }
             } else {
                 $method = 'getDataset' . $dataset;
                 if (method_exists($stats, $method)) {
                     $response = new ResponseJson($stats->{$method}());
                 }
             }
             if (isset($response)) {
                 $response->setMaxAge(900);
                 $response->setExpires(new \DateTime('@' . (time() + 900)));
                 $response->setPublic();
                 return $response;
             }
         }
     } catch (\Exception $ex) {
         return new ResponseJson(['error' => $ex->getMessage()]);
     }
 }
<?php

/*
 * This file is part of the Arnapou FileStore package.
 *
 * (c) Arnaud Buathier <*****@*****.**>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
include_once __DIR__ . '/../vendor/autoload.php';
Arnapou\GW2Tools\Service::getInstance();
use Arnapou\GW2Tools\User;
/*
 * STATISTICS
 */
foreach (User::getConnection()->query("SELECT * FROM `" . User::table() . "`") as $row) {
    try {
        $user = new User($row);
        $account = $user->checkAccount();
        if (empty($account)) {
            continue;
        }
        $account->calculateStatistics();
    } catch (\Exception $ex) {
        echo $user->getAccount()->getName() . " " . $ex->getMessage() . "\n";
    }
}