• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP gGetDb函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: getForRequest

    /**
     * @param integer $id
     * @param null|PdoDatabase $database
     * @return Comment[]
     * @throws Exception
     */
    public static function getForRequest($id, PdoDatabase $database = null)
    {
        if ($database == null) {
            $database = gGetDb();
        }
        if (User::getCurrent()->isAdmin() || User::getCurrent()->isCheckuser()) {
            // current user is an admin or checkuser, so retrieve everything.
            $statement = $database->prepare("SELECT * FROM comment WHERE request = :target;");
        } else {
            // current user isn't an admin, so limit to only those which are visible to users, and private comments
            // the user has posted themselves.
            $statement = $database->prepare(<<<SQL
SELECT * FROM comment
WHERE request = :target AND (visibility = 'user' OR user = :userid);
SQL
);
            $statement->bindValue(":userid", User::getCurrent()->getId());
        }
        $statement->bindValue(":target", $id);
        $statement->execute();
        $result = array();
        /** @var Comment $v */
        foreach ($statement->fetchAll(PDO::FETCH_CLASS, get_called_class()) as $v) {
            $v->isNew = false;
            $v->setDatabase($database);
            $result[] = $v;
        }
        return $result;
    }
开发者ID:FastLizard4,项目名称:waca,代码行数:35,代码来源:Comment.php


示例2: executeQueryToArray

 public function executeQueryToArray($query)
 {
     $database = gGetDb();
     $statement = $database->prepare($query);
     $statement->execute();
     return $statement->fetchAll($this->rowFetchMode);
 }
开发者ID:FastLizard4,项目名称:waca,代码行数:7,代码来源:queryBrowser.php


示例3: getUserDetail

    private function getUserDetail($userId)
    {
        $database = gGetDb();
        $user = User::getById($userId, $database);
        if ($user == false) {
            return BootstrapSkin::displayAlertBox("User not found", "alert-error", "Error", true, false, true);
        }
        global $smarty;
        $activitySummary = $database->prepare(<<<SQL
            SELECT COALESCE(c.mail_desc, l.log_action) AS action, COUNT(*) AS count 
            FROM acc_log l 
            LEFT JOIN closes c ON l.log_action = c.closes 
            WHERE l.log_user = :username 
            GROUP BY action;
SQL
);
        $activitySummary->execute(array(":username" => $user->getUsername()));
        $activitySummaryData = $activitySummary->fetchAll(PDO::FETCH_ASSOC);
        $smarty->assign("user", $user);
        $smarty->assign("activity", $activitySummaryData);
        $usersCreatedQuery = $database->prepare(<<<SQL
            SELECT l.log_time time, r.name name, r.id id 
            FROM acc_log l
            JOIN request r ON r.id = l.log_pend 
            LEFT JOIN emailtemplate e ON concat('Closed ', e.id) = l.log_action 
            WHERE l.log_user = :username 
                AND l.log_action LIKE 'Closed %' 
                AND (e.oncreated = '1' OR l.log_action = 'Closed custom-y') 
            ORDER BY l.log_time;
SQL
);
        $usersCreatedQuery->execute(array(":username" => $user->getUsername()));
        $usersCreated = $usersCreatedQuery->fetchAll(PDO::FETCH_ASSOC);
        $smarty->assign("created", $usersCreated);
        $usersNotCreatedQuery = $database->prepare(<<<SQL
            SELECT l.log_time time, r.name name, r.id id 
            FROM acc_log l
            JOIN request r ON r.id = l.log_pend 
            LEFT JOIN emailtemplate e ON concat('Closed ', e.id) = l.log_action 
            WHERE l.log_user = :username 
                AND l.log_action LIKE 'Closed %' 
                AND (e.oncreated = '0' OR l.log_action = 'Closed custom-n' OR l.log_action='Closed 0') 
            ORDER BY l.log_time;
SQL
);
        $usersNotCreatedQuery->execute(array(":username" => $user->getUsername()));
        $usersNotCreated = $usersNotCreatedQuery->fetchAll(PDO::FETCH_ASSOC);
        $smarty->assign("notcreated", $usersNotCreated);
        $accountLogQuery = $database->prepare(<<<SQL
            SELECT * 
            FROM acc_log l 
            WHERE l.log_pend = :userid 
\t            AND log_action IN ('Approved','Suspended','Declined','Promoted','Demoted','Renamed','Prefchange');     
SQL
);
        $accountLogQuery->execute(array(":userid" => $user->getId()));
        $accountLog = $accountLogQuery->fetchAll(PDO::FETCH_ASSOC);
        $smarty->assign("accountlog", $accountLog);
        return $smarty->fetch("statistics/userdetail.tpl");
    }
开发者ID:Austin503,项目名称:waca,代码行数:60,代码来源:StatsUsers.php


示例4: displayInternalFooter

 /**
  * Prints the internal interface footer to the screen.
  *
  * @param string|null $tailscript JavaScript to append to the page, usually so it can call jQuery
  * @throws Exception
  */
 public static function displayInternalFooter($tailscript = null)
 {
     global $smarty;
     // close all declared open tags
     while (count(self::$tagstack) != 0) {
         echo array_pop(self::$tagstack);
     }
     $last5min = time() - 300;
     $last5mins = date("Y-m-d H:i:s", $last5min);
     $database = gGetDb();
     $statement = $database->prepare("SELECT * FROM user WHERE lastactive > :lastfive;");
     $statement->execute(array(":lastfive" => $last5mins));
     $resultSet = $statement->fetchAll(PDO::FETCH_CLASS, "User");
     $resultSetCount = count($resultSet);
     $creators = implode(", ", array_map(function ($arg) {
         /** @var User $arg */
         return "<a href=\"statistics.php?page=Users&amp;user=" . $arg->getId() . "\">" . htmlentities($arg->getUsername()) . "</a>";
     }, $resultSet));
     // not equal to one, as zero uses the plural form too.
     if ($resultSetCount != 1) {
         $onlinemessage = $resultSetCount . " Account Creators currently online (past 5 minutes): {$creators}";
     } else {
         $onlinemessage = $resultSetCount . " Account Creator currently online (past 5 minutes): {$creators}";
     }
     $online = '<p class="span6 text-right"><small>' . $onlinemessage . '</small></p>';
     if (isset($_SESSION['user'])) {
         $smarty->assign("onlineusers", $online);
     } else {
         $emptystring = "";
         $smarty->assign("onlineusers", $emptystring);
     }
     $smarty->assign("tailscript", $tailscript);
     $smarty->display("footer.tpl");
 }
开发者ID:FastLizard4,项目名称:waca,代码行数:40,代码来源:BootstrapSkin.php


示例5: isTrusted

 /**
  * Returns a value if the IP address is a trusted proxy
  * @param string $ip
  * @param PdoDatabase $database
  * @return bool
  */
 public function isTrusted($ip, PdoDatabase $database = null)
 {
     if (in_array($ip, $this->trustedCache)) {
         return true;
     }
     if (in_array($ip, $this->untrustedCache)) {
         return false;
     }
     if ($database == null) {
         $database = gGetDb();
     }
     $query = "SELECT COUNT(*) FROM xfftrustcache WHERE ip = :ip;";
     $statement = $database->prepare($query);
     $statement->execute(array(":ip" => $ip));
     $result = $statement->fetchColumn();
     $statement->closeCursor();
     if ($result == 0) {
         $this->untrustedCache[] = $ip;
         return false;
     }
     if ($result >= 1) {
         $this->trustedCache[] = $ip;
         return true;
     }
     // something weird has happened if we've got here.
     // default to untrusted.
     return false;
 }
开发者ID:Austin503,项目名称:waca,代码行数:34,代码来源:XffTrustProvider.php


示例6: execute

 /**
  * Summary of execute
  * @param \DOMElement $apiDocument
  * @return \DOMElement
  * @throws ApiException
  * @throws \Exception
  */
 public function execute(\DOMElement $apiDocument)
 {
     $username = isset($_GET['user']) ? trim($_GET['user']) : '';
     $wikiusername = isset($_GET['wikiuser']) ? trim($_GET['wikiuser']) : '';
     if ($username === '' && $wikiusername === '') {
         throw new ApiException("Please specify a username using either user or wikiuser parameters.");
     }
     $userElement = $this->document->createElement("user");
     $apiDocument->appendChild($userElement);
     $this->database = gGetDb();
     if ($username !== '') {
         $this->user = \User::getByUsername($username, $this->database);
     } else {
         $this->user = \User::getByOnWikiUsername($wikiusername, $this->database);
     }
     if ($this->user === false) {
         $userElement->setAttribute("missing", "true");
         return $apiDocument;
     }
     $userElement->setAttribute("username", $this->user->getUsername());
     $userElement->setAttribute("status", $this->user->getStatus());
     $userElement->setAttribute("lastactive", $this->user->getLastActive());
     $userElement->setAttribute("welcome_template", $this->user->getWelcomeTemplate());
     $userElement->setAttribute("onwikiname", $this->user->getOnWikiName());
     $userElement->setAttribute("oauth", $this->user->isOAuthLinked() ? "true" : "false");
     return $apiDocument;
 }
开发者ID:FastLizard4,项目名称:waca,代码行数:34,代码来源:StatsAction.php


示例7: smallStats

 /**
  * Gets the relevant statistics from the database for the small statistics table
  */
 private function smallStats()
 {
     global $smarty;
     $database = gGetDb();
     $requestsQuery = "SELECT COUNT(*) FROM request WHERE status = :status AND emailconfirm = 'Confirmed';";
     $requestsStatement = $database->prepare($requestsQuery);
     // TODO: use the request states thing here.
     // Open Requests
     $requestsStatement->execute(array(":status" => "Open"));
     $open = $requestsStatement->fetchColumn();
     $requestsStatement->closeCursor();
     $smarty->assign("statsOpen", $open);
     // Admin Requests
     $requestsStatement->execute(array(":status" => "Admin"));
     $admin = $requestsStatement->fetchColumn();
     $requestsStatement->closeCursor();
     $smarty->assign("statsAdmin", $admin);
     // Checkuser Requests
     $requestsStatement->execute(array(":status" => "Checkuser"));
     $checkuser = $requestsStatement->fetchColumn();
     $requestsStatement->closeCursor();
     $smarty->assign("statsCheckuser", $checkuser);
     // Unconfirmed requests
     $unconfirmedStatement = $database->query("SELECT COUNT(*) FROM request WHERE emailconfirm != 'Confirmed' AND emailconfirm != '';");
     $unconfirmed = $unconfirmedStatement->fetchColumn();
     $unconfirmedStatement->closeCursor();
     $smarty->assign("statsUnconfirmed", $unconfirmed);
     $userStatusStatement = $database->prepare("SELECT COUNT(*) FROM user WHERE status = :status;");
     // Admin users
     $userStatusStatement->execute(array(":status" => "Admin"));
     $adminusers = $userStatusStatement->fetchColumn();
     $userStatusStatement->closeCursor();
     $smarty->assign("statsAdminUsers", $adminusers);
     // Users
     $userStatusStatement->execute(array(":status" => "User"));
     $users = $userStatusStatement->fetchColumn();
     $userStatusStatement->closeCursor();
     $smarty->assign("statsUsers", $users);
     // Suspended users
     $userStatusStatement->execute(array(":status" => "Suspended"));
     $suspendedUsers = $userStatusStatement->fetchColumn();
     $userStatusStatement->closeCursor();
     $smarty->assign("statsSuspendedUsers", $suspendedUsers);
     // New users
     $userStatusStatement->execute(array(":status" => "New"));
     $newUsers = $userStatusStatement->fetchColumn();
     $userStatusStatement->closeCursor();
     $smarty->assign("statsNewUsers", $newUsers);
     // Most comments on a request
     $mostCommentsStatement = $database->query("SELECT request FROM comment GROUP BY request ORDER BY COUNT(*) DESC LIMIT 1;");
     $mostComments = $mostCommentsStatement->fetchColumn();
     $mostCommentsStatement->closeCursor();
     $smarty->assign("mostComments", $mostComments);
 }
开发者ID:cyberpower678,项目名称:waca,代码行数:57,代码来源:StatsMain.php


示例8: execute

 protected function execute()
 {
     global $smarty;
     $showImmune = false;
     if (isset($_GET['showimmune'])) {
         $showImmune = true;
     }
     $smarty->assign("showImmune", $showImmune);
     $inactiveUsers = User::getAllInactive(gGetDb());
     $smarty->assign("inactiveUsers", $inactiveUsers);
     return $smarty->fetch("statistics/inactiveusers.tpl");
 }
开发者ID:Austin503,项目名称:waca,代码行数:12,代码来源:StatsInactiveUsers.php


示例9: execute

    public function execute(\DOMElement $apiDocument)
    {
        $this->database = gGetDb();
        $statusElement = $this->document->createElement("status");
        $apiDocument->appendChild($statusElement);
        $query = $this->database->prepare(<<<SQL
            SELECT /* Api/StatusAction */ COUNT(*) AS count
            FROM request
            WHERE
                status = :pstatus
                AND emailconfirm = 'Confirmed';
SQL
);
        global $availableRequestStates;
        foreach ($availableRequestStates as $key => $value) {
            $query->bindValue(":pstatus", $key);
            $query->execute();
            $sus = $query->fetchColumn();
            $statusElement->setAttribute($value['api'], $sus);
            $query->closeCursor();
        }
        $query = $this->database->prepare(<<<SQL
            SELECT /* Api/StatusAction */ COUNT(*) AS count
            FROM ban
            WHERE
                (duration > UNIX_TIMESTAMP() OR duration = -1)
                AND active = 1;
SQL
);
        $query->execute();
        $sus = $query->fetchColumn();
        $statusElement->setAttribute("bans", $sus);
        $query->closeCursor();
        $query = $this->database->prepare("SELECT /* Api/StatusAction */ COUNT(*) AS count FROM user WHERE status = :ulevel;");
        $query->bindValue(":ulevel", "Admin");
        $query->execute();
        $sus = $query->fetchColumn();
        $statusElement->setAttribute("useradmin", $sus);
        $query->closeCursor();
        $query->bindValue(":ulevel", "User");
        $query->execute();
        $sus = $query->fetchColumn();
        $statusElement->setAttribute("user", $sus);
        $query->closeCursor();
        $query->bindValue(":ulevel", "New");
        $query->execute();
        $sus = $query->fetchColumn();
        $statusElement->setAttribute("usernew", $sus);
        $query->closeCursor();
        return $apiDocument;
    }
开发者ID:FastLizard4,项目名称:waca,代码行数:51,代码来源:StatusAction.php


示例10: cleanExpiredUnconfirmedRequests

    /**
     * This function removes all old requests which are not yet email-confirmed
     * from the database.
     */
    public static function cleanExpiredUnconfirmedRequests()
    {
        global $emailConfirmationExpiryDays;
        $database = gGetDb();
        $statement = $database->prepare(<<<SQL
            DELETE FROM request
            WHERE
                date < DATE_SUB(CURRENT_TIMESTAMP(), INTERVAL {$emailConfirmationExpiryDays} DAY)
                AND emailconfirm != 'Confirmed'
                AND emailconfirm != '';
SQL
);
        $statement->execute();
    }
开发者ID:Austin503,项目名称:waca,代码行数:18,代码来源:Request.php


示例11: execute

 public function execute(\DOMElement $apiDocument)
 {
     $this->database = gGetDb();
     $now = new \DateTime();
     $old = $this->getOldest();
     $oldest = new \DateTime($old);
     $new = $this->getNewest();
     $newest = new \DateTime($new);
     $monitoringElement = $this->document->createElement("data");
     $monitoringElement->setAttribute("date", $now->format('c'));
     $monitoringElement->setAttribute("oldest", $old == null ? null : $oldest->format('c'));
     $monitoringElement->setAttribute("newest", $new == null ? null : $newest->format('c'));
     $apiDocument->appendChild($monitoringElement);
     return $apiDocument;
 }
开发者ID:Austin503,项目名称:waca,代码行数:15,代码来源:MonitorAction.php


示例12: getAll

 /**
  * Summary of getAll
  * @param PdoDatabase $database
  * @return WelcomeTemplate[]
  */
 public static function getAll(PdoDatabase $database = null)
 {
     if ($database == null) {
         $database = gGetDb();
     }
     $statement = $database->prepare("SELECT * FROM welcometemplate;");
     $statement->execute();
     $result = array();
     foreach ($statement->fetchAll(PDO::FETCH_CLASS, get_called_class()) as $v) {
         $v->isNew = false;
         $v->setDatabase($database);
         $result[] = $v;
     }
     return $result;
 }
开发者ID:Austin503,项目名称:waca,代码行数:20,代码来源:WelcomeTemplate.php


示例13: getCurrent

 /**
  * Summary of getCurrent
  * @param PdoDatabase $database
  * @return User The currently logged in user, or an anonymous coward with userid -1.
  */
 public static function getCurrent(PdoDatabase $database = null)
 {
     if ($database === null) {
         $database = gGetDb();
     }
     if (self::$currentUser === null) {
         if (isset($_SESSION['userID'])) {
             self::$currentUser = self::getById($_SESSION['userID'], $database);
         } else {
             $anonymousCoward = new CommunityUser();
             self::$currentUser = $anonymousCoward;
         }
     }
     return self::$currentUser;
 }
开发者ID:FastLizard4,项目名称:waca,代码行数:20,代码来源:User.php


示例14: getAllActiveTemplates

 /**
  * Gets active non-preload and preload templates
  * @param string $defaultAction Default action to take (EmailTemplate::CREATED or EmailTemplate::NOT_CREATED)
  * @param PdoDatabase $database 
  * @return array|false
  */
 public static function getAllActiveTemplates($defaultAction, PdoDatabase $database = null)
 {
     if ($database == null) {
         $database = gGetDb();
     }
     $statement = $database->prepare("SELECT * FROM `emailtemplate` WHERE defaultaction = :forcreated AND active = 1;");
     if ($defaultAction === false) {
         $statement = $database->prepare("SELECT * FROM `emailtemplate` WHERE defaultaction not in ('created', 'not created') AND active = 1;");
     }
     $statement->bindValue(":forcreated", $defaultAction);
     $statement->execute();
     $resultObject = $statement->fetchAll(PDO::FETCH_CLASS, get_called_class());
     foreach ($resultObject as $t) {
         $t->setDatabase($database);
         $t->isNew = false;
     }
     return $resultObject;
 }
开发者ID:Austin503,项目名称:waca,代码行数:24,代码来源:EmailTemplate.php


示例15: getSpoofs

 public function getSpoofs($username)
 {
     global $mediawikiWebServiceEndpoint;
     $cacheResult = AntiSpoofCache::getByUsername($username, gGetDb());
     if ($cacheResult == false) {
         // get the data from the API
         $data = file_get_contents($mediawikiWebServiceEndpoint . "?action=antispoof&format=php&username=" . urlencode($username));
         $cacheEntry = new AntiSpoofCache();
         $cacheEntry->setDatabase(gGetDb());
         $cacheEntry->setUsername($username);
         $cacheEntry->setData($data);
         $cacheEntry->save();
         $cacheResult = $cacheEntry;
     } else {
         $data = $cacheResult->getData();
     }
     $result = unserialize($data);
     if (!isset($result['antispoof']) || !isset($result['antispoof']['result'])) {
         $cacheResult->delete();
         if (isset($result['error']['info'])) {
             throw new Exception("Unrecognised API response to query: " . $result['error']['info']);
         }
         throw new Exception("Unrecognised API response to query.");
     }
     if ($result['antispoof']['result'] == "pass") {
         // All good here!
         return array();
     }
     if ($result['antispoof']['result'] == "conflict") {
         // we've got conflicts, let's do something with them.
         return $result['antispoof']['users'];
     }
     if ($result['antispoof']['result'] == "error") {
         // we've got conflicts, let's do something with them.
         throw new Exception("Encountered error while getting result: " . $result['antispoof']['error']);
     }
     throw new Exception("Unrecognised API response to query.");
 }
开发者ID:Austin503,项目名称:waca,代码行数:38,代码来源:CachedApiAntispoofProvider.php


示例16: execute

 public function execute(\DOMElement $apiDocument)
 {
     $username = isset($_GET['user']) ? trim($_GET['user']) : '';
     if ($username == '') {
         throw new ApiException("Please specify a username");
     }
     $userElement = $this->document->createElement("user");
     $userElement->setAttribute("name", $username);
     $apiDocument->appendChild($userElement);
     $this->database = gGetDb();
     $this->user = \User::getByUsername($username, $this->database);
     if ($this->user === false) {
         $userElement->setAttribute("missing", "true");
         return $apiDocument;
     }
     $userElement->setAttribute("level", $this->user->getStatus());
     $userElement->setAttribute("created", $this->getAccountsCreated());
     $userElement->setAttribute("today", $this->getToday());
     if ($this->user->isAdmin()) {
         $this->fetchAdminData($userElement);
     }
     return $apiDocument;
 }
开发者ID:Austin503,项目名称:waca,代码行数:23,代码来源:CountAction.php


示例17: execute

 protected function execute()
 {
     $qb = new QueryBrowser();
     $query = "SELECT COUNT(DISTINCT log_id) AS 'Requests Closed', YEAR(log_time) AS 'Year', MONTHNAME(log_time) AS 'Month' FROM acc_log WHERE log_action LIKE 'Closed%' GROUP BY EXTRACT(YEAR_MONTH FROM log_time) ORDER BY YEAR(log_time), MONTH(log_time) ASC;";
     $out = $qb->executeQueryToTable($query);
     global $showGraphs;
     if ($showGraphs == 1) {
         global $filepath;
         require_once $filepath . 'graph/pChart/pChart.class';
         require_once $filepath . 'graph/pChart/pData.class';
         $queries = array();
         $queries[] = array('query' => "SELECT COUNT(DISTINCT log_id) AS 'y', CONCAT( YEAR(log_time), '/' , MONTHNAME(log_time)) AS 'x' FROM acc_log WHERE log_action LIKE 'Closed%' AND YEAR(log_time) != 0 GROUP BY EXTRACT(YEAR_MONTH FROM log_time) ORDER BY YEAR(log_time), MONTH(log_time) ASC;", 'series' => "All closed requests by month");
         $queries[] = array('query' => "SELECT COUNT(DISTINCT log_id) AS 'y', CONCAT( YEAR(log_time), '/' , MONTHNAME(log_time)) AS 'x' FROM acc_log WHERE log_action LIKE 'Closed 0' AND YEAR(log_time) != 0 GROUP BY EXTRACT(YEAR_MONTH FROM log_time) ORDER BY YEAR(log_time), MONTH(log_time) ASC;", 'series' => "Dropped requests by month");
         $query = gGetDb()->query("SELECT id, name FROM emailtemplate WHERE active = '1';");
         if (!$query) {
             die("Query error.");
         }
         foreach ($query->fetchAll(PDO::FETCH_ASSOC) as $row) {
             $id = $row['id'];
             $name = $row['name'];
             $queries[] = array('query' => "SELECT COUNT(DISTINCT log_id) AS 'y', CONCAT( YEAR(log_time), '/' , MONTHNAME(log_time)) AS 'x' FROM acc_log WHERE log_action LIKE 'Closed {$id}' AND YEAR(log_time) != 0 GROUP BY EXTRACT(YEAR_MONTH FROM log_time) ORDER BY YEAR(log_time), MONTH(log_time) ASC;", 'series' => "{$name} requests by month");
         }
         $queries[] = array('query' => "SELECT COUNT(DISTINCT log_id) AS 'y', CONCAT( YEAR(log_time), '/' , MONTHNAME(log_time)) AS 'x' FROM acc_log WHERE log_action LIKE 'Closed custom-y' AND YEAR(log_time) != 0 GROUP BY EXTRACT(YEAR_MONTH FROM log_time) ORDER BY YEAR(log_time), MONTH(log_time) ASC;", 'series' => "Custom created requests by month");
         $queries[] = array('query' => "SELECT COUNT(DISTINCT log_id) AS 'y', CONCAT( YEAR(log_time), '/' , MONTHNAME(log_time)) AS 'x' FROM acc_log WHERE log_action LIKE 'Closed custom-n' AND YEAR(log_time) != 0 GROUP BY EXTRACT(YEAR_MONTH FROM log_time) ORDER BY YEAR(log_time), MONTH(log_time) ASC;", 'series' => "Custom not created requests by month");
         global $availableRequestStates;
         foreach ($availableRequestStates as $state) {
             $queries[] = array('query' => "SELECT COUNT(DISTINCT log_id) AS 'y', CONCAT( YEAR(log_time), '/' , MONTHNAME(log_time)) AS 'x' FROM acc_log WHERE log_action LIKE 'Deferred to " . $state['defertolog'] . "' AND YEAR(log_time) != 0 GROUP BY EXTRACT(YEAR_MONTH FROM log_time) ORDER BY YEAR(log_time), MONTH(log_time) ASC;", 'series' => "Requests deferred to " . $state['deferto'] . " by month");
         }
         global $baseurl;
         foreach ($this->createClosuresGraph($queries) as $i) {
             $out .= '<img src="' . $baseurl . '/render/' . $i[0] . '" alt="' . $i[1] . '"/>';
         }
     } else {
         $out .= BootstrapSkin::displayAlertBox("Graph drawing is currently disabled.", "alert-info", "", false, false, true);
     }
     return $out;
 }
开发者ID:Austin503,项目名称:waca,代码行数:37,代码来源:StatsMonthlyStats.php


示例18: get

 /**
  * Get a message.
  *
  * This is going to be used as a new way of dealing with saved messages for #28
  *
  * The basic idea is there's a key stored in a new column, and we do lookups on that
  * instead of a possibly variable auto-incrementing ID.
  *
  * We can use class constants so the keys are defined in one place only for now, and for
  * now we are using the auto-incrementing ID as the value of the key, so this function
  * just uses getById() at the moment.
  *
  * @param mixed $key
  * @return mixed
  */
 public static function get($key)
 {
     return self::getById($key, gGetDb())->getContentForDisplay();
 }
开发者ID:Austin503,项目名称:waca,代码行数:19,代码来源:InterfaceMessage.php


示例19: zoomPage

function zoomPage($id, $urlhash)
{
    global $session, $availableRequestStates, $createdid;
    global $smarty, $locationProvider, $rdnsProvider, $antispoofProvider;
    global $xffTrustProvider, $enableEmailConfirm;
    $database = gGetDb();
    $request = Request::getById($id, $database);
    if ($request == false) {
        // Notifies the user and stops the script.
        BootstrapSkin::displayAlertBox("Could not load the requested request!", "alert-error", "Error", true, false);
        BootstrapSkin::displayInternalFooter();
        die;
    }
    $smarty->assign('ecenable', $enableEmailConfirm);
    if (isset($_GET['ecoverride']) && User::getCurrent()->isAdmin()) {
        $smarty->assign('ecoverride', true);
    } else {
        $smarty->assign('ecoverride', false);
    }
    $smarty->assign('request', $request);
    $smarty->assign("usernamerawunicode", html_entity_decode($request->getName()));
    $smarty->assign("iplocation", $locationProvider->getIpLocation($request->getTrustedIp()));
    $createdreason = EmailTemplate::getById($createdid, gGetDb());
    $smarty->assign("createdEmailTemplate", $createdreason);
    #region setup whether data is viewable or not
    $viewableDataStatement = $database->prepare(<<<SQL
        SELECT COUNT(*) 
        FROM request 
        WHERE 
            (
                email = :email 
                OR ip = :trustedIp 
                OR forwardedip LIKE :trustedProxy
            ) 
            AND reserved = :reserved 
            AND emailconfirm = 'Confirmed' 
            AND status != 'Closed';
SQL
);
    $viewableDataStatement->bindValue(":email", $request->getEmail());
    $viewableDataStatement->bindValue(":reserved", User::getCurrent()->getId());
    $viewableDataStatement->bindValue(":trustedIp", $request->getTrustedIp());
    $viewableDataStatement->bindValue(":trustedProxy", '%' . $request->getTrustedIp() . '%');
    $viewableDataStatement->execute();
    $viewableData = $viewableDataStatement->fetchColumn();
    $viewableDataStatement->closeCursor();
    $hideinfo = $viewableData == 0;
    #endregion
    if ($request->getStatus() == "Closed") {
        $hash = md5($request->getId() . $request->getEmail() . $request->getTrustedIp() . microtime());
        //If the request is closed, change the hash based on microseconds similar to the checksums.
        $smarty->assign("isclosed", true);
    } else {
        $hash = md5($request->getId() . $request->getEmail() . $request->getTrustedIp());
        $smarty->assign("isclosed", false);
    }
    $smarty->assign("hash", $hash);
    if ($hash == $urlhash) {
        $correcthash = true;
    } else {
        $correcthash = false;
    }
    $smarty->assign("showinfo", false);
    if ($hideinfo == false || $correcthash == true || User::getCurrent()->isAdmin() || User::getCurrent()->isCheckuser()) {
        $smarty->assign("showinfo", true);
    }
    // force to not show, overriden later
    $smarty->assign("proxyip", "");
    if ($hideinfo == false || $correcthash == true || User::getCurrent()->isAdmin() || User::getCurrent()->isCheckuser()) {
        $smarty->assign("proxyip", $request->getForwardedIp());
        if ($request->getForwardedIp()) {
            $smartyproxies = array();
            // Initialize array to store data to be output in Smarty template.
            $smartyproxiesindex = 0;
            $proxies = explode(",", $request->getForwardedIp());
            $proxies[] = $request->getIp();
            $origin = $proxies[0];
            $smarty->assign("origin", $origin);
            $proxies = array_reverse($proxies);
            $trust = true;
            global $rfc1918ips;
            foreach ($proxies as $proxynum => $p) {
                $p2 = trim($p);
                $smartyproxies[$smartyproxiesindex]['ip'] = $p2;
                // get data on this IP.
                $trusted = $xffTrustProvider->isTrusted($p2);
                $ipisprivate = ipInRange($rfc1918ips, $p2);
                if (!$ipisprivate) {
                    $iprdns = $rdnsProvider->getRdns($p2);
                    $iplocation = $locationProvider->getIpLocation($p2);
                } else {
                    // this is going to fail, so why bother trying?
                    $iprdns = false;
                    $iplocation = false;
                }
                // current trust chain status BEFORE this link
                $pretrust = $trust;
                // is *this* link trusted?
                $smartyproxies[$smartyproxiesindex]['trustedlink'] = $trusted;
                // current trust chain status AFTER this link
//.........这里部分代码省略.........
开发者ID:Austin503,项目名称:waca,代码行数:101,代码来源:zoompage.php


示例20: gGetDb

require_once 'functions.php';
require_once 'includes/PdoDatabase.php';
require_once 'includes/SmartyInit.php';
// Check to see if the database is unavailable.
// Uses the true variable as the public uses this page.
if (Offline::isOffline()) {
    echo Offline::getOfflineMessage(true);
    die;
}
// TODO: move me to a maintenance job
if ($enableEmailConfirm == 1) {
    Request::cleanExpiredUnconfirmedRequests();
}
$antispoofProvider = new $antispoofProviderClass();
$xffTrustProvider = new $xffTrustProviderClass($squidIpList);
$database = gGetDb();
// Display the header of the interface.
BootstrapSkin::displayPublicHeader();
if (isset($_GET['action']) && $_GET['action'] == "confirm") {
    try {
        if (!isset($_GET['id']) || !isset($_GET['si'])) {
            BootstrapSkin::displayAlertBox("Please check the link you received", "alert-error", "Missing parameters", true, false);
            BootstrapSkin::displayPublicFooter();
            die;
        }
        $request = Request::getById($_GET['id'], $database);
        if ($request === false) {
            BootstrapSkin::displayAlertBox($smarty->fetch('request/request-not-found.tpl'), "alert-error", "Request not found", true, false);
            BootstrapSkin::displayPublicFooter();
            die;
        }
开发者ID:Austin503,项目名称:waca,代码行数:31,代码来源:index.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP gParam函数代码示例发布时间:2022-05-15
下一篇:
PHP g2u函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap