当前位置: 首页>>代码示例>>PHP>>正文


PHP es函数代码示例

本文整理汇总了PHP中es函数的典型用法代码示例。如果您正苦于以下问题:PHP es函数的具体用法?PHP es怎么用?PHP es使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了es函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _

 /**
  * @param int $key
  * @return \mysqli;
  */
 public static function _($key = 0)
 {
     if (!isset(self::$mysqli[$key])) {
         if (!isset(self::$connect['server'])) {
             self::$connect['server'] = Core::$DB_LOCAL;
         }
         if (!isset(self::$connect['user'])) {
             self::$connect['user'] = Core::$DB_LOGIN;
         }
         if (!isset(self::$connect['pass'])) {
             self::$connect['pass'] = Core::$DB_PASS;
         }
         if (!isset(self::$connect['db'])) {
             self::$connect['db'] = Core::$DB_NAME;
         }
         self::$mysqli[$key] = @new \mysqli(self::$connect['server'], self::$connect['user'], self::$connect['pass'], self::$connect['db']);
         // WARNING
         if (mysqli_connect_errno()) {
             echo 'Не удалось подключиться к Базе Данных';
             exit;
         }
         if (!self::$mysqli[$key]->set_charset("utf8")) {
             echo 'Ошибка при загрузке набора символов utf8:' . self::$mysqli[$key]->error;
             exit;
         }
         if (!empty(Core::$DB_TIME_ZONE)) {
             self::$mysqli[$key]->query("set time_zone = '" . es(Core::$DB_TIME_ZONE) . "'");
         }
     }
     return self::$mysqli[$key];
 }
开发者ID:schoolphp,项目名称:library,代码行数:35,代码来源:DB.php

示例2: clear

 public function clear()
 {
     $conditions = array();
     $conditions[] = es('Pin.member_id = %s', $this->member->id);
     $this->Pin->deleteAll($conditions);
     $this->renderJSONStatus(true);
 }
开发者ID:kaz0636,项目名称:openflp,代码行数:7,代码来源:api_pin_controller.php

示例3: activate

 function activate($id, $hash)
 {
     q("\n\t\t\tUPDATE `fw_users` SET\n\t\t\t`access` = 1\n\t\t\tWHERE `id` = " . (int) $id . "\n\t\t\t  AND `access` = 0\n\t\t\t  AND `hash` = '" . es($hash) . "'\n\t\t");
     if (!\DB::_()->affected_rows) {
         return false;
     }
     return true;
 }
开发者ID:schoolphp,项目名称:library,代码行数:8,代码来源:Registration.php

示例4: getFolder

 protected function getFolder()
 {
     $id = $this->params('folder_id', 0);
     $conditions = array();
     $conditions[] = es('Member.id = %s', $this->member->id);
     $conditions[] = es('Dir.id = %s', $id);
     return $this->Dir->find($conditions);
 }
开发者ID:kaz0636,项目名称:openflp,代码行数:8,代码来源:api_folder_controller.php

示例5: updateSubscribersCount

 public function updateSubscribersCount($data = null)
 {
     $this->set($data);
     $conditions = es('Subscription.feed_id = %s', $this->id);
     $n = $this->Subscription->findCount($conditions);
     CakeLog::write(LOG_INFO, "subscribers: {$n}");
     return $this->saveField('subscribers_count', $n);
 }
开发者ID:kaz0636,项目名称:openflp,代码行数:8,代码来源:feed.php

示例6: getMaxPercentageForTheNight

function getMaxPercentageForTheNight()
{
    $today = time();
    $dateSMYSQL = es(date("Y-m-d 00:00", $today));
    // midnight
    $dateEMYSQL = es(date("Y-m-d 09:00", $today));
    // 9am
    $query = "SELECT\n                timestamp,\n                FLOOR(100*wind/demand) AS percent\n              FROM\n                wind_vs_demand\n              WHERE\n                timestamp BETWEEN '{$dateSMYSQL}' AND '{$dateEMYSQL}'\n              ORDER BY\n                percent DESC\n              LIMIT 1";
    return fetchAssoc(query($query));
}
开发者ID:aniston,项目名称:winderful,代码行数:10,代码来源:night-tweet.php

示例7: addAddress

 public function addAddress($address, $name = '')
 {
     $res = q("\n\t\t\tSELECT 1\n\t\t\tFROM `fw_unsubscribe`\n\t\t\tWHERE `email` = '" . es($address) . "'\n\t\t");
     if ($res->num_rows) {
         if ($this->exceptions) {
             throw new phpmailerException('E-mail blocked');
         }
         $this->ErrorInfo = 'E-mail blocked';
         return false;
     }
     return parent::addAddress($address, $name);
 }
开发者ID:schoolphp,项目名称:library,代码行数:12,代码来源:MailProxy.php

示例8: authByHash

 function authByHash($id, $hash)
 {
     /*
     		if(!$this->ipDefender()) {
     			$this->error = 'ip-defender';
     			return false;
     		}
     */
     $res = q("\n\t\t\tSELECT *\n\t\t\tFROM `fw_users`\n\t\t\tWHERE `id` = " . (int) $id . "\n\t\t\t  AND `hash` = '" . es($hash) . "'\n\t\t\tLIMIT 1\n\t\t");
     if (!$res->num_rows) {
         $this->error = 'wrong-hash';
         return false;
     }
     $row = $res->fetch_assoc();
     if ($row['access'] != 1) {
         if ($row['access'] == 0) {
             $this->error = 'wrong-access-confirm';
         } else {
             $this->error = 'wrong-access';
         }
         return false;
     }
     if ($this->browser) {
         if ($row['browser'] != $_SERVER['HTTP_USER_AGENT']) {
             $this->error = 'wrong-browser';
             return false;
         }
     }
     if ($this->ip == 1) {
         if ($row['ip'] != $_SERVER['REMOTE_ADDR']) {
             $this->error = 'wrong-ip';
             return false;
         }
     } elseif ($this->ip == 2) {
         preg_match('#(^\\d+\\.\\d+\\.)#isuU', $row['ip'], $matches);
         if (isset($matches[1])) {
             $ipbase = $matches[1];
         }
         preg_match('#(^\\d+\\.\\d+\\.)#isuU', $row['REMOTE_ADDR'], $matches);
         if (isset($matches[1])) {
             $ipnow = $matches[1];
         }
         if (isset($ipbase, $ipnow) && $ipbase != $ipnow) {
             $this->error = 'wrong-ip';
             return false;
         }
     }
     $row['hash'] = $this->rememberMe($row['id']);
     \User::$data = $row;
     $_SESSION['user']['id'] = $row['id'];
     return true;
 }
开发者ID:schoolphp,项目名称:library,代码行数:52,代码来源:Authorization.php

示例9: stats

function stats($query = null)
{
    $es = es();
    $stats = [];
    $q = ['match_all' => new \StdClass()];
    if ($query != null && is_string($query)) {
        $q = ['query_string' => ['analyze_wildcard' => false, 'query' => $query]];
    }
    /* taxa count */
    $params = ['index' => INDEX, 'type' => 'analysis', 'body' => ['query' => $q]];
    $stats['accepted_count'] = $es->count($params)['count'];
    /* last update */
    $params = ['index' => INDEX, 'type' => 'analysis', 'body' => ['size' => 1, '_source' => ['timestamp'], 'query' => ['match_all' => new \StdClass()], 'sort' => ['timestamp' => 'desc']]];
    $r = $es->search($params)['hits']['hits'][0]['_source']['timestamp'][0] / 1000;
    $stats['last_updated'] = date('Y-m-d H:m:s', $r);
    // main stats
    $params = ['index' => INDEX, 'type' => 'analysis', 'size' => 0, 'body' => ['size' => 0, 'query' => $q, 'aggs' => ['categories' => ['terms' => ['field' => 'main-risk-assessment.category', 'size' => 9]], 'occs_count' => ['sum' => ['field' => 'occurrences.count']], 'points_count' => ['sum' => ['field' => 'points.count']], 'occs_ranges' => ['range' => ['field' => 'occurrences.count', 'ranges' => [["from" => 0, "to" => 1], ["from" => 1, "to" => 3], ["from" => 3, "to" => 10], ["from" => 10, "to" => 100], ["from" => 100, "to" => 99999]]]], 'points_ranges' => ['range' => ['field' => 'points.count', 'ranges' => [["from" => 0, "to" => 1], ["from" => 1, "to" => 3], ["from" => 3, "to" => 10], ["from" => 10, "to" => 100], ["from" => 100, "to" => 99999]]]], 'clusters_ranges' => ['range' => ['field' => 'clusters.all.count', 'ranges' => [["from" => 0, "to" => 1], ["from" => 1, "to" => 3], ["from" => 3, "to" => 10], ["from" => 10, "to" => 100], ["from" => 100, "to" => 99999]]]], 'aoo_ranges' => ['range' => ['field' => 'aoo.all.area', 'ranges' => [["from" => 0, "to" => 1], ["from" => 1, "to" => 10], ["from" => 10, "to" => 50], ["from" => 50, "to" => 100], ["from" => 100, "to" => 500], ["from" => 500, "to" => 2000], ["from" => 2000, "to" => 5000], ["from" => 5000, "to" => 99999]]]], 'eoo_ranges' => ['range' => ['field' => 'eoo.all.area', 'ranges' => [["from" => 0, "to" => 1], ["from" => 1, "to" => 100], ["from" => 100, "to" => 5000], ["from" => 500, "to" => 5000], ["from" => 5000, "to" => 20000], ["from" => 20000, "to" => 50000], ["from" => 50000, "to" => 999999]]]]]]];
    $r = $es->search($params);
    foreach ($r['aggregations'] as $k => $agg) {
        if (isset($agg['buckets'])) {
            $stats[$k] = [];
            foreach ($agg['buckets'] as $value) {
                $key = str_replace("-", " ~ ", str_replace(".0", "", strtoupper($value['key'])));
                $q = null;
                if (strpos($key, "~") !== false) {
                    $partsq = explode(" ~ ", $key);
                    $q = '(>=' . $partsq[0] . ' AND <' . $partsq[1] . ')';
                } else {
                    $q = $key;
                }
                $stats[$k][] = ['label' => $key, 'value' => $value['doc_count'], 'q' => $q];
            }
        } else {
            if (isset($agg['value'])) {
                $stats[$k] = $agg['value'];
            }
        }
    }
    $stats['not_points_count'] = $stats['occs_count'] - $stats['points_count'];
    $stats['occurrence_count'] = $stats['occs_count'];
    $stats['json'] = json_encode($stats);
    return $stats;
}
开发者ID:diogok,项目名称:biodiv-ui,代码行数:43,代码来源:utils.php

示例10: isAllow

 static function isAllow($group, $action, $full = false)
 {
     if (!self::isAuth()) {
         return false;
     }
     if (isset(self::$groups[$group]['*'])) {
         return true;
     }
     if ($full && isset(self::$groups[$group]['full'])) {
         if (!isset(self::$groups[$group][$action])) {
             return false;
         }
         return self::$groups[$group][$action];
     } elseif (!$full && isset(self::$groups[$group][$action])) {
         return self::$groups[$group][$action];
     }
     if (!count(self::$roles)) {
         self::getRoles();
     }
     if (isset(self::$roles['guest'])) {
         return false;
     }
     if ($full) {
         self::$groups[$group]['full'] = true;
         $s_action = '';
     } else {
         $s_action = "AND `action` IN ('" . es($action) . "','*')";
     }
     $res = q("\n\t\t\tSELECT `action`\n\t\t\tFROM `fw_users_role2action`\n\t\t\tWHERE `role` IN (" . implode(',', self::$roles) . ")\n\t\t\t  AND `group` = '" . es($group) . "'\n\t\t\t  " . $s_action . "\n\t\t");
     while ($row = $res->fetch_assoc()) {
         self::$groups[$group][$row['action']] = true;
     }
     if (!isset(self::$groups[$group][$action])) {
         self::$groups[$group][$action] = false;
     }
     if (isset(self::$groups[$group]['*'])) {
         return true;
     }
     return self::$groups[$group][$action];
 }
开发者ID:schoolphp,项目名称:library,代码行数:40,代码来源:Access.php

示例11: Start

 static function Start($auth = [])
 {
     $called_class = get_called_class();
     if (count($auth)) {
         $where = [];
         foreach ($auth as $k => $v) {
             $where[] = "`" . es($k) . "` = '" . es($v) . "'";
         }
         $res = q("\n\t\t\t\tSELECT `access`" . (count($called_class::$datas) ? ',`' . implode('`,`', $called_class::$datas) . '`' : '') . "\n\t\t\t\tFROM `fw_users`\n\t\t\t\tWHERE " . implode(" AND ", $where) . "\n\t\t\t");
         if (!$res->num_rows) {
             Authorization::logout();
             redirect('/');
         }
         $row = $res->fetch_assoc();
         if ($row['access'] != 1) {
             Authorization::logout();
             $_SESSION['error'] = 'no-access';
             redirect('/');
         }
         foreach ($called_class::$datas as $k => $v) {
             $called_class::${$v} = $row[$v];
             // unset($row[$v]); -- Раскомментировать после обновления функционала на сайте
         }
         if (count($row)) {
             self::$data = $row;
         }
     } elseif (isset($_COOKIE['autologinid'], $_COOKIE['autologinhash'])) {
         $auth = new Authorization();
         if (!$auth->authByHash($_COOKIE['autologinid'], $_COOKIE['autologinhash'])) {
             Authorization::logout();
             redirect('/');
         }
     }
     if (!empty(self::$data['id']) && !empty(self::$autoupdate)) {
         q("\n\t\t\t\tUPDATE `fw_users` SET\n\t\t\t\t`browser` = '" . (isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '') . "',\n\t\t\t\t`ip` = '" . es($_SERVER['REMOTE_ADDR']) . "'\n\t\t\t\tWHERE `id` = " . (int) self::$data['id'] . "\n\t\t\t");
     }
 }
开发者ID:schoolphp,项目名称:library,代码行数:37,代码来源:User.php

示例12: getCurrentData

function getCurrentData()
{
    // get latest data
    // inner select grabs highest % tweeted today
    // only check today's readings
    $hour = date('H');
    if ($hour < 12) {
        $start = time();
        $end = time();
        $dateSMYSQL = es(date("Y-m-d 00:00", $start));
        // today 00
        $dateEMYSQL = es(date("Y-m-d 12:00", $end));
        // today 12
    } else {
        $start = time();
        $end = time() + 3600 * 24;
        $dateSMYSQL = es(date("Y-m-d 12:00", $start));
        // today 12
        $dateEMYSQL = es(date("Y-m-d 00:00", $end));
        // tomorrow 00
    }
    $query = "SELECT\n                timestamp,\n                FLOOR(100*wind/demand) AS percent,\n                (SELECT percentage FROM tweets WHERE timestamp BETWEEN '{$dateSMYSQL}' AND '{$dateEMYSQL}' ORDER BY percentage DESC LIMIT 1) AS day_max\n              FROM\n                wind_vs_demand\n              WHERE\n                timestamp BETWEEN '{$dateSMYSQL}' AND '{$dateEMYSQL}'\n              ORDER BY\n                timestamp DESC\n              LIMIT 1";
    return fetchAssoc(query($query));
}
开发者ID:aniston,项目名称:winderful,代码行数:24,代码来源:tweet.php

示例13: afterDelete

 public function afterDelete()
 {
     $conditions = array();
     $conditions[] = es('Subscription.folder_id = %s', $this->id);
     $this->Subscription->updateAll(array('folder_id' => 0), $conditions);
 }
开发者ID:kaz0636,项目名称:openflp,代码行数:6,代码来源:dir.php

示例14: q

<?php

//Активация регистрации
if (isset($_GET['hash'], $_GET['id'])) {
    q("\n      UPDATE `users`\n      SET `active`= '1'\n      WHERE `id` = " . (int) $_GET['id'] . "\n      AND `hash` = '" . es($_GET['hash']) . "'\n  ");
    $info = 'Вы активны на сайте';
} else {
    $info = 'Вы прошли по неверной ссылке';
}
开发者ID:IvanZozylya,项目名称:coursePHP,代码行数:9,代码来源:activate.php

示例15: getSubscription

 protected function getSubscription()
 {
     $id = $this->params('subscribe_id', 0);
     $conditions = array();
     $conditions[] = es('Member.id = %s', $this->member->id);
     $conditions[] = es('Subscription.id = %s', $id);
     return $this->Subscription->find($conditions);
 }
开发者ID:kaz0636,项目名称:openflp,代码行数:8,代码来源:api_feed_controller.php


注:本文中的es函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。