本文整理汇总了PHP中L::get方法的典型用法代码示例。如果您正苦于以下问题:PHP L::get方法的具体用法?PHP L::get怎么用?PHP L::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类L
的用法示例。
在下文中一共展示了L::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: query
public function query($postdata)
{
if ($this->user->getClass() < User::CLASS_ADMIN) {
throw new Exception(L::get("PERMISSION_DENIED"), 401);
}
$limit = (int) $postdata["limit"] ?: 25;
$index = (int) $postdata["index"] ?: 0;
$search = $postdata["search"] ?: "";
$where = "";
if (strlen($search) > 0) {
$searchWords = Helper::searchTextToWordParams($search);
$where = "WHERE MATCH (adminlog.search_text) AGAINST (" . $this->db->quote($searchWords) . " IN BOOLEAN MODE)";
}
$sth = $this->db->query("SELECT COUNT(*) FROM adminlog " . $where);
$res = $sth->fetch();
$totalCount = $res[0];
$sth = $this->db->prepare("SELECT adminlog.added, adminlog.id AS aid, adminlog.txt, users.id, users.username FROM adminlog LEFT JOIN users ON adminlog.userid = users.id " . $where . " ORDER BY adminlog.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["id"] = $row["aid"];
$r["added"] = $row["added"];
$r["txt"] = str_replace("{{username}}", "[url=/user/" . $row["id"] . "/" . $row["username"] . "][b]" . $row["username"] . "[/b][/url]", $row["txt"]);
array_push($result, $r);
}
return array($result, $totalCount);
}
示例2: create
public function create($postdata = null)
{
if ($this->user->getClass() < User::CLASS_ACTOR) {
throw new Exception(L::get("SEED_REQUEST_CLASS_REQUIREMENT"), 401);
}
$sth = $this->db->prepare('SELECT * FROM reseed_requests WHERE torrentid = ? AND added > DATE_ADD(NOW(),INTERVAL -1 MONTH)');
$sth->bindParam(1, $postdata["torrentid"], PDO::PARAM_INT);
$sth->execute();
if ($sth->rowCount() > 0) {
throw new Exception(L::get("SEED_REQUEST_ALREADY_REQUESTED"), 412);
}
if ($this->user->getBonus() < 5) {
throw new Exception(L::get("NOT_ENOUGH_BONUS"), 412);
}
$torrent = $this->torrent->get($postdata["torrentid"]);
if ($torrent["seeders"] > 2) {
throw new Exception(L::get("SEED_REQUEST_SEEDERS_REQUIREMENT"), 412);
}
$this->user->bonusLog(-5, L::get("SEED_REQUEST_BONUS_LOG"), $this->user->getId());
$sth = $this->db->query("SELECT snatch.userid, users.language FROM snatch LEFT JOIN users ON users.id = snatch.userid WHERE torrentid = " . $torrent["id"] . " AND lastaction > DATE_ADD(NOW(),INTERVAL -6 MONTH) AND timesCompleted > 0 AND userid != " . $this->user->getId());
while ($res = $sth->fetch(PDO::FETCH_ASSOC)) {
$this->mailbox->sendSystemMessage($res["userid"], L::get("SEED_REQUEST_PM_SUBJECT", null, $res["language"]), L::get("SEED_REQUEST_PM_BODY", [$torrent["id"], $torrent["name"], $torrent["name"]], $res["language"]));
}
$sth = $this->db->prepare("INSERT INTO reseed_requests(torrentid, userid, added) VALUES(?, ?, NOW())");
$sth->bindParam(1, $torrent["id"], PDO::PARAM_INT);
$sth->bindValue(2, $this->user->getId(), PDO::PARAM_INT);
$sth->execute();
$this->log->log(1, L::get("SEED_REQUEST_SITE_LOG", [$torrent["id"], $torrent["name"], $torrent["name"]], Config::DEFAULT_LANGUAGE), $this->user->getId(), 1);
}
示例3: query
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);
}
示例4: testGetSetWorks
public function testGetSetWorks()
{
$lingua = "l";
L::set($lingua);
$check_lingua = L::get();
$this->assertEquals($check_lingua, $lingua);
}
示例5: run
public function run()
{
if ($_SERVER['SERVER_ADDR'] != $_SERVER["REMOTE_ADDR"]) {
throw new Exception(L::get("MUST_BE_RUN_BY_SERVER_ERROR"), 401);
}
/* 1. Save all users current seed amount. Run every hour */
$now = time('Y-m-d H');
$user = $this->db->query('SELECT * FROM users WHERE enabled = "yes"');
while ($u = $user->fetch(PDO::FETCH_ASSOC)) {
$res = $this->db->query('SELECT torrents.size, peers.to_go FROM peers JOIN torrents ON peers.torrent = torrents.id WHERE userid = ' . $u["id"] . ' GROUP BY userid, torrent');
$seededAmount = 0;
while ($r = $res->fetch(PDO::FETCH_ASSOC)) {
$seededAmount += $r["size"] - $r["to_go"];
}
$gb = round($seededAmount / 1073741824);
if ($gb > 0) {
$this->db->query('INSERT INTO leechbonus(userid, datum, gbseed) VALUES(' . $u["id"] . ', ' . $now . ', ' . $gb . ')');
}
}
/* 2. Erase all logs older than 3 days */
$timeSpan = time() - 259200;
// 3 days
$this->db->query('DELETE FROM leechbonus WHERE datum < ' . $timeSpan);
/* 3. Update all leechbonus percent based on the last 3 days */
$user = $this->db->query('SELECT id, UNIX_TIMESTAMP(added) AS added FROM users');
while ($u = $user->fetch(PDO::FETCH_ASSOC)) {
$res = $this->db->query('SELECT SUM(gbseed) AS seedsum FROM leechbonus WHERE userid = ' . $u["id"] . ' ');
$res2 = $res->fetch(PDO::FETCH_ASSOC);
$leechbonus = $this->leechbonus($res2["seedsum"] / 72);
// Split into 24*3 hours
$this->db->query('UPDATE users SET leechbonus = ' . $leechbonus . ' WHERE id = ' . $u["id"]);
}
}
示例6: create
/**
* Create the category menu with his childrens
* @todo test
*/
public function create()
{
// get the categories
$categories = $this->r->getRootNodes();
$cat_menu = new Collection();
if ($categories) {
foreach ($categories as $category) {
// get the childrens
$childrens = $category->children()->whereLang(L::get())->count() ? $category->children()->whereLang(L::get())->get(["id", "description", "slug_lang"]) : null;
// create the menuitems
//@todo handle multiple recursive subitems with a better algorithm
$cat_menu_item = new MenuItem($category->description, $category->slug_lang, $this->cat_type, null, $this->getActive($category->slug_lang));
if ($childrens) {
foreach ($childrens as $children) {
$children_item = new MenuItem($children->description, $children->slug_lang, $this->cat_type, null, $this->getActive($children->slug_lang));
// if has sub-subcategories
if ($children->children()->whereLang(L::get())->count()) {
$childrens_children = $children->children()->whereLang(L::get())->get(["id", "description", "slug_lang"]);
foreach ($childrens_children as $children_children) {
$children_item->add(new MenuItem($children_children->description, $children_children->slug_lang, $this->cat_type, null, $this->getActive($children_children->slug_lang)));
}
}
$cat_menu_item->add($children_item);
}
}
// append to original menu
$cat_menu->push($cat_menu_item);
}
}
return $cat_menu;
}
示例7: delete
public function delete($id, $postdata = null)
{
$bookmark = $this->get($id);
if ($bookmark["userid"] != $this->user->getId()) {
throw new Exception(L::get("PERMISSION_DENIED"), 401);
}
$this->db->query('DELETE FROM torrent_list_bookmarks WHERE id = ' . $bookmark["id"]);
}
示例8: delete
public function delete($id)
{
if ($this->user->getClass() < User::CLASS_ADMIN) {
throw new Exception(L::get("PERMISSION_DENIED"), 401);
}
$sth = $this->db->prepare("DELETE FROM rules WHERE id = ?");
$sth->bindParam(1, $id, PDO::PARAM_INT);
$sth->execute();
}
示例9: checkValidity
public function checkValidity($secret)
{
$sth = $this->db->prepare('SELECT * FROM invites WHERE secret = ?');
$sth->bindParam(1, $secret, PDO::PARAM_STR);
$sth->execute();
if (!$sth->fetch()) {
throw new Exception(L::get("INVITE_NOT_FOUND"), 404);
}
}
示例10: base
/**
* Base url translator
* @param $type
* @param $name
* @param null $params
* @return string
*/
protected function base($type, $name, $params)
{
$base_url = URL::to('/');
$new_url = "{$base_url}/" . L::get();
$desired_url = URL::$type($name, $params);
$last_url = substr($desired_url, strlen($base_url));
$new_url .= $last_url;
// baseurl/lingua/parte_finale
return $new_url;
}
示例11: get
public function get($id)
{
$sth = $this->db->prepare('SELECT * FROM blocks WHERE id = ?');
$sth->bindParam(1, $id, PDO::PARAM_INT);
$sth->execute();
$res = $sth->fetch(PDO::FETCH_ASSOC);
if (!$res) {
throw new Exception(L::get("BLOCK_NOT_EXIST"));
}
return $res;
}
示例12: get
private function get($id)
{
$sth = $this->db->prepare("SELECT * FROM nonscene WHERE id = ?");
$sth->bindParam(1, $id, PDO::PARAM_INT);
$sth->execute();
$res = $sth->fetch(PDO::FETCH_ASSOC);
if (!$res) {
throw new Exception(L::get("ITEM_NOT_FOUND"), 404);
}
return $res;
}
示例13: get
public function get($id)
{
$sth = $this->db->prepare('SELECT * FROM friends WHERE id = ?');
$sth->bindParam(1, $id, PDO::PARAM_INT);
$sth->execute();
$res = $sth->fetch(PDO::FETCH_ASSOC);
if (!$res) {
throw new Exception(L::get("USER_FRIEND_NOT_FOUND"), 404);
}
return $res;
}
示例14: update
public function update($id, $postdata)
{
if ($this->user->getClass() < User::CLASS_ADMIN) {
throw new Exception(L::get("PERMISSION_DENIED"), 401);
}
$sth = $this->db->prepare("UPDATE donated SET status = ?, sum = ? WHERE id = ?");
$sth->bindParam(1, $postdata["status"], PDO::PARAM_INT);
$sth->bindParam(2, $postdata["sum"], PDO::PARAM_INT);
$sth->bindParam(3, $id, PDO::PARAM_INT);
$sth->execute();
}
示例15: check
public function check()
{
$date = date("Y-m-d H:i:s", time() - 300);
$sth = $this->db->prepare('SELECT COUNT(*) FROM inlogg WHERE ip = ? AND tid > ?');
$sth->bindParam(1, $_SERVER["REMOTE_ADDR"], PDO::PARAM_STR, 15);
$sth->bindParam(2, $date, PDO::PARAM_STR);
$sth->execute();
$arr = $sth->fetch();
if ($arr[0] > $this->maximumLoginAttempts) {
throw new Exception(L::get("LOGIN_ATTEMPTS_EXCEEDED"), 401);
}
}