Exemplo n.º 1
0
 public static function register($user, $pass, $email)
 {
     $query = "insert into account(username,password,email) values('{$user}','{$pass}','{$email}')";
     Mdb::nonSelectQuery($query);
     $query = "insert into profile(status) values('active')";
     Mdb::nonSelectQuery($query);
 }
Exemplo n.º 2
0
 public static function isUserInChat($chatId, $userId)
 {
     $db = Mdb::GetConnection();
     $collection = $db->selectCollection(Mdb::$dbname, 'chat');
     $result = $collection->findOne(['_id' => intval($chatId), 'members' => ['$all' => [intval($userId)]]], ['_id' => true]);
     return empty($result) ? false : true;
 }
Exemplo n.º 3
0
 public static function getExpressions($crit)
 {
     if ($crit != "") {
         $query = "select * from expression\n                        where (lower(name) like lower('%{$crit}%')) or\n                              (lower(description) like lower('%{$crit}%')) or\n                              (lower(content) like lower('%{$crit}%')) or\n                              (lower(formula) like lower('%{$crit}%'))\n                        order by popularity desc, ts desc limit 70";
     } else {
         $query = "select * from expression order by ts desc limit 70";
     }
     //echo $query;
     return Mdb::sqlTableQuery($query);
 }
Exemplo n.º 4
0
 public function start()
 {
     $host = Config::get('mongo.host', '127.0.0.1');
     $port = Config::get('mongo.port', 27017);
     $protocol = Config::get('mongo.protocol', 'mongodb');
     $auth = Config::get('mongo.auth', true);
     if ($auth) {
         $user = Config::get('mongo.username', SITE_NAME . '_master');
         $password = Config::get('mongo.password');
         $dsn = $protocol . '://' . $user . ':' . $password . '@' . $host . ':' . $port;
     } else {
         $dsn = $protocol . '://' . $host . ':' . $port;
     }
     return Mdb::connection($dsn, ['connect' => true]);
 }
Exemplo n.º 5
0
 public static function nonSelectQuery($query)
 {
     try {
         $host = self::HOST;
         $baza = self::BAZA;
         $user = self::USER;
         $pass = self::PASS;
         self::$dsn = "mysql:host={$host};dbname={$baza}";
         self::$dbh = new PDO(self::$dsn, $user, $pass, array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));
         $pdo_izraz = self::$dbh->prepare($query);
         $pdo_izraz->execute();
     } catch (PDOException $exc) {
         echo $exc->getMessage();
     }
     self::$dbh = null;
 }
Exemplo n.º 6
0
<?php

require_once '../init.php';
$minute = (int) date('i');
$hour = (int) date('H');
if ($hour != 4) {
    exit;
}
if ($minute != 0) {
    exit;
}
$mdb = new Mdb();
$types = ['characterID', 'corporationID', 'allianceID', 'factionID', 'groupID', 'shipTypeID', 'solarSystemID', 'regionID'];
$timer = new Timer();
$ninetyDayKillID = MongoFilter::getKillIDFromTime(time() - 90 * 86400);
$date = new MongoDate(strtotime(date('Y-m-d')));
// Clear out ranks more than two weeks old
$mdb->remove('ranksProgress', ['date' => ['$lt' => $mdb->now(-86400 * 14)]]);
foreach ($types as $type) {
    Util::out("Started recent calcs for {$type}");
    $calcStats = $mdb->find('information', ['type' => $type]);
    foreach ($calcStats as $row) {
        calcStats($row, $ninetyDayKillID);
    }
    Util::out("Completed recent calcs for {$type}");
}
function calcStats($row, $ninetyDayKillID)
{
    global $mdb, $debug;
    $type = $row['type'];
    $id = $row['id'];
Exemplo n.º 7
0
 public static function delete($id)
 {
     $query = "delete from expression where id={$id}";
     Mdb::nonSelectQuery($query);
 }
Exemplo n.º 8
0
<?php

require_once '../init.php';
$minute = (int) date('i');
if ($minute != 0) {
    exit;
}
$mdb = new Mdb();
$killsLastHour = new RedisTtlCounter('killsLastHour', 3600);
$kills = $killsLastHour->count();
$count = $mdb->findField('storage', 'contents', ['locker' => 'totalKills']);
if ($kills > 0) {
    Log::irc('|g|' . number_format($kills, 0) . '|n| kills processed.');
    Util::out(number_format($kills, 0) . ' kills added, now at ' . number_format($count, 0) . ' kills.');
}
$redis->set('zkb:totalKills', $mdb->count('killmails'));
$redis->set('zkb:crestRemaining', Db::queryField('select count(*) count from kills_by_dttm where status = 0', 'count'));
Exemplo n.º 9
0
 public static function GetConnection()
 {
     self::$dbname = 'social-network';
     $db = new MongoClient('mongodb://*****:*****@ds047335.mongolab.com:47335/social-network');
     return $db;
 }
Exemplo n.º 10
0
 public static function getContent($id)
 {
     $query = "select content from expression where id={$id}";
     $res = Mdb::sqlRowQuery($query);
     return $res['content'];
 }
Exemplo n.º 11
0
<?php

require_once '../init.php';
$mdb = new Mdb();
$old = $mdb->now(3600 * 3);
// 8 hours
$timer = new Timer();
$queueAllis = new RedisTimeQueue('tqAlliances', 9600);
$i = date('i');
if ($i == 45) {
    $allis = $mdb->find('information', ['type' => 'allianceID']);
    foreach ($allis as $alli) {
        $queueAllis->add($alli['id']);
    }
}
while ($timer->stop() <= 55000) {
    sleep(1);
    $id = (int) $queueAllis->next(false);
    if ($id == null) {
        exit;
    }
    $alliance = $mdb->findDoc('information', ['type' => 'allianceID', 'id' => $id]);
    $id = $alliance['id'];
    $name = $alliance['name'];
    $currentInfo = $mdb->findDoc('information', ['type' => 'alliance', 'id' => $id]);
    $alliCrest = CrestTools::getJSON("https://public-crest.eveonline.com/alliances/{$id}/");
    if ($alliCrest == null || !isset($alliCrest['name'])) {
        $mdb->set('information', ['type' => 'alliance', 'id' => $id], ['lastApiUpdate' => $mdb->now()]);
        continue;
    }
    $update = [];
Exemplo n.º 12
0
 public static function getForType($type)
 {
     $query = "select * from bexpression where type='{$type}'";
     return Mdb::sqlTableQuery($query);
 }
Exemplo n.º 13
0
 public static function getAccForId($accid)
 {
     $query = "select * from account where id={$accid}";
     return Mdb::sqlRowQuery($query);
 }
Exemplo n.º 14
0
<?php

require_once '../init.php';
$mdb = new Mdb();
$old = $mdb->now(3600 * 3);
// 8 hours
$timer = new Timer();
$mdb->getCollection('information')->update(['type' => 'allianceID', 'lastApiUpdate' => null], ['$set' => ['lastApiUpdate' => new MongoDate(2)]], ['multiple' => true]);
$alliances = $mdb->find('information', ['type' => 'allianceID', 'lastApiUpdate' => ['$lt' => $old]], ['lastApiUpdate' => 1], 100);
foreach ($alliances as $alliance) {
    if (Util::exitNow() || $timer->stop() > 110000) {
        exit;
    }
    $id = $alliance['id'];
    $name = $alliance['name'];
    //echo "$id $name\n";
    $currentInfo = $mdb->findDoc('information', ['type' => 'alliance', 'id' => $id]);
    if (false && @$currentInfo['deleted'] == true) {
        $mdb->set('information', ['type' => 'alliance', 'id' => $id], ['lastApiUpdate' => $mdb->now()]);
        continue;
    }
    $alliCrest = CrestTools::getJSON("https://public-crest.eveonline.com/alliances/{$id}/");
    if ($alliCrest == null || !isset($alliCrest['name'])) {
        sleep(1);
        $mdb->set('information', ['type' => 'alliance', 'id' => $id], ['lastApiUpdate' => $mdb->now()]);
        continue;
    }
    $update = [];
    $update['lastApiUpdate'] = $mdb->now();
    $update['corpCount'] = (int) $alliCrest['corporationsCount'];
    $update['executorCorpID'] = (int) $alliCrest['executorCorporation']['id'];
Exemplo n.º 15
0
<?php

require_once '../init.php';
$minute = (int) date('i');
if ($minute != 0) {
    exit;
}
$mdb = new Mdb();
$killsLastHour = new RedisTtlCounter('killsLastHour', 3600);
$kills = $killsLastHour->count();
$count = $mdb->count("killmails");
if ($kills > 0) {
    Log::irc('|g|' . number_format($kills, 0) . '|n| kills processed.');
    Util::out(number_format($kills, 0) . ' kills added, now at ' . number_format($count, 0) . ' kills.');
}
$redis->set('zkb:totalKills', $count);
Exemplo n.º 16
0
 public static function setLanguage($lng)
 {
     $db = Mdb::GetConnection();
     $collection = $db->selectCollection(Mdb::$dbname, 'user');
     $result = $collection->update(['_id' => self::getUserId()], ['$set' => ['lng' => $lng]]);
 }
Exemplo n.º 17
0
<?php

require_once '../init.php';
$minute = (int) date('i');
if ($minute != 0) {
    exit;
}
$mdb = new Mdb();
$killsLastHour = new RedisTtlCounter('killsLastHour', 3600);
$kills = $killsLastHour->count();
$count = $mdb->findField('storage', 'contents', ['locker' => 'totalKills']);
if ($kills > 0) {
    Log::irc('|g|' . number_format($kills, 0) . '|n| kills processed.');
    Util::out(number_format($kills, 0) . ' kills added, now at ' . number_format($count, 0) . ' kills.');
}
Exemplo n.º 18
0
 public static function updateExpression($id, $name, $desc, $content)
 {
     $query = "update expression set name='{$name}',description='{$desc}',content='{$content}' where id={$id}";
     Mdb::nonSelectQuery($query);
 }