Ejemplo n.º 1
0
 public function logActivity($size = null, $master = false, $thumbnailId = null)
 {
     if (!env('DEBUG')) {
         $con = Pdo::getInstance()->getConnection();
         $size = $size / 1024;
         $id = request()->source->id;
         $filename = $this->getFilename();
         $method = request()->getMethod();
         $userAgent = request()->getUserAgent();
         $referer = request()->getReferer();
         $ip = request()->getIp();
         $identifier = $this->getIdentifier();
         $con = $con->prepare("CALL LogActivity(:source_id, :thumbnail_id, :path, :method, :agent, :referer, :ip, :identifier, :filesize, :master)");
         $con->bindParam(':source_id', $id, \PDO::PARAM_STR);
         $con->bindParam(':thumbnail_id', $thumbnailId, \PDO::PARAM_INT);
         $con->bindParam(':path', $filename, \PDO::PARAM_STR);
         $con->bindParam(':method', $method, \PDO::PARAM_STR);
         $con->bindParam(':agent', $userAgent, \PDO::PARAM_STR);
         $con->bindParam(':referer', $referer, \PDO::PARAM_STR);
         $con->bindParam(':ip', $ip, \PDO::PARAM_STR);
         $con->bindParam(':identifier', $identifier, \PDO::PARAM_STR);
         $con->bindParam(':filesize', $size, \PDO::PARAM_INT);
         $con->bindParam(':master', $master, \PDO::PARAM_INT);
         // call the stored procedure
         $con->execute();
     }
 }
Ejemplo n.º 2
0
 public static function getUsers($organisationId)
 {
     $ids = array();
     $tmpIds = Pdo::getInstance()->all('SELECT `user_id` FROM `user_organisation` WHERE `organisation_id` = ?', [$organisationId]);
     foreach ($tmpIds as $id) {
         $ids[] = $id->user_id;
     }
     return ModelUser::getByIds($ids);
 }
Ejemplo n.º 3
0
 public static function getBandwidthByDate($organisationId, $startDate = null, $endDate = null)
 {
     $where = [PdoHelper::formatQuery('`source_id` IN ((SELECT `id` FROM `source` WHERE `organisation_id` = %s))', array($organisationId))];
     if ($startDate !== null) {
         $where[] = PdoHelper::formatQuery('`created` >= FROM_UNIXTIME(%s)', array(strtotime($startDate)));
     }
     if ($endDate !== null) {
         $where[] = PdoHelper::formatQuery('created <= FROM_UNIXTIME(%s)', array(strtotime($endDate)));
     }
     return Pdo::getInstance()->value('SELECT SUM(`filesize`) FROM `activity` WHERE ' . join(' && ', $where));
 }
Ejemplo n.º 4
0
 public function drop()
 {
     Pdo::getInstance()->nonQuery('DROP TABLE `' . $this->name . '`;');
 }
Ejemplo n.º 5
0
 public static function hasPayed($organisationId, $date)
 {
     return (bool) Pdo::getInstance()->value('SELECT COUNT(`id`) FROM `payment` WHERE `organisation_id` = ? && (`period_start` >= FROM_UNIXTIME(?) || `period_end` <= FROM_UNIXTIME(?))', [$organisationId, strtotime($date), strtotime($date)]);
 }
Ejemplo n.º 6
0
 public function getLastActivity()
 {
     return Pdo::getInstance()->value('SELECT `last_activity` FROM `source` WHERE `organisation_id` = ? ORDER BY `last_activity` DESC LIMIT 1', [$this->id]);
 }
Ejemplo n.º 7
0
 public function change()
 {
     $index = '';
     if ($this->getIndex() !== null) {
         $index = sprintf(', ADD %s (`%s`)', $this->getIndex(), $this->getName());
     }
     $query = 'ALTER TABLE `' . $this->table . '` MODIFY COLUMN ' . $this->getQuery() . $index . ';';
     Pdo::getInstance()->nonQuery($query);
 }
Ejemplo n.º 8
0
 public static function clear()
 {
     Pdo::getInstance()->nonQuery('DELETE FROM `settings`');
 }
Ejemplo n.º 9
0
 public static function escape($value)
 {
     return trim(Pdo::getInstance()->getConnection()->quote($value), '\'');
 }