Signups::query PHP Method

query() public method

public query ( $limit = 25, $index )
    public function query($limit = 25, $index = 0)
    {
        if ($this->user->getClass() < User::CLASS_ADMIN) {
            throw new Exception(L::get("PERMISSION_DENIED"), 401);
        }
        $sth = $this->db->query("SELECT COUNT(*) FROM nyregg");
        $res = $sth->fetch();
        $totalCount = $res[0];
        $sth = $this->db->prepare("SELECT nyregg.ip, nyregg.userid, nyregg.datum AS added, nyregg.email, nyregg.hostname, nyregg.log_mail, nyregg.log_ip, nyregg.level, users.warned, users.enabled, users.username FROM nyregg LEFT JOIN users ON nyregg.userid = users.id ORDER BY nyregg.id DESC LIMIT ?, ?");
        $sth->bindParam(1, $index, PDO::PARAM_INT);
        $sth->bindParam(2, $limit, PDO::PARAM_INT);
        $sth->execute();
        $result = array();
        while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
            $r = array();
            $r["added"] = $row["added"];
            $r["hostname"] = $row["hostname"];
            $r["ip"] = $row["ip"];
            $r["email"] = $row["email"];
            $r["log_ip"] = $row["log_ip"];
            $r["level"] = $row["level"];
            $r["log_mail"] = $row["log_mail"];
            $r["user"] = array("id" => $row["userid"], "username" => $row["username"], "warned" => $row["warned"], "enabled" => $row["enabled"]);
            array_push($result, $r);
        }
        return array($result, $totalCount);
    }

Usage Example

Exemplo n.º 1
0
 case validateRoute('DELETE', 'donations/\\d+'):
     $donate = new Donations($db, $user);
     httpResponse($donate->delete((int) $params[1], $postdata));
     break;
 case validateRoute('GET', 'login-attempts'):
     $loginAttempts = new LoginAttempts($db, $user);
     list($result, $totalCount) = $loginAttempts->query(array("limit" => $_GET["limit"], "index" => $_GET["index"]));
     httpResponse($result, $totalCount);
     break;
 case validateRoute('DELETE', 'login-attempts/\\d+'):
     $loginAttempts = new LoginAttempts($db, $user);
     httpResponse($loginAttempts->delete((int) $params[1]));
     break;
 case validateRoute('GET', 'signups'):
     $signups = new Signups($db, $user);
     list($result, $totalCount) = $signups->query((int) $_GET["limit"], (int) $_GET["index"]);
     httpResponse($result, $totalCount);
     break;
 case validateRoute('GET', 'ipchanges'):
     $ipchanges = new IpChanges($db, $user);
     list($result, $totalCount) = $ipchanges->query((int) $_GET["limit"], (int) $_GET["index"]);
     httpResponse($result, $totalCount);
     break;
 case validateRoute('POST', 'reports'):
     $reports = new Reports($db, $user);
     httpResponse($reports->create($postdata));
     break;
 case validateRoute('GET', 'reports'):
     $mailbox = new Mailbox($db, $user);
     $torrent = new Torrent($db, $user);
     $subtitles = new Subtitles($db, $user);