本文整理汇总了PHP中HasPermission函数的典型用法代码示例。如果您正苦于以下问题:PHP HasPermission函数的具体用法?PHP HasPermission怎么用?PHP HasPermission使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了HasPermission函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getWikiPage
function getWikiPage($id, $rev = 0)
{
global $canedit, $canmod;
$ptitle = $id;
if (!$ptitle) {
$ptitle = 'Main_page';
} else {
$ptitle = title2url($ptitle);
}
// so that we don't have for example 'Main page' and 'Main_page' being considered different pages
if ($rev < 0) {
$rev = 0;
}
$page = Query("SELECT p.*, pt.date, pt.user, pt.text FROM {wiki_pages} p LEFT JOIN {wiki_pages_text} pt ON pt.id=p.id AND pt.revision=" . ($rev > 0 ? 'LEAST(p.revision,{1})' : 'p.revision') . " WHERE p.id={0}", $ptitle, $rev);
if (!NumRows($page)) {
$page = array('id' => $ptitle, 'revision' => 0, 'flags' => 0, 'text' => '', 'new' => 1);
header('HTTP/1.1 404 Not Found');
header('Status: 404 Not Fount');
} else {
$page = Fetch($page);
}
$page['istalk'] = strtolower(substr($ptitle, 0, 5)) == 'talk:';
$page['ismain'] = strtolower($ptitle) == 'main_page';
$page['canedit'] = $canedit && (!($page['flags'] & WIKI_PFLAG_SPECIAL) || HasPermission('wiki.makepagesspecial'));
return $page;
}
示例2: GetNotifications
function GetNotifications()
{
global $loguserid, $NotifFormat;
$notifs = array();
if (!$loguserid) {
return $notifs;
}
// TODO do it better!
$staffnotif = '';
if (HasPermission('admin.viewstaffpms')) {
$staffnotif = ' OR user=-1';
}
$ndata = Query("SELECT type,id,date,args FROM {notifications} WHERE user={0}{$staffnotif} ORDER BY date DESC", $loguserid);
while ($n = Fetch($ndata)) {
$ncb = $NotifFormat[$n['type']];
if (function_exists($ncb)) {
$ndesc = $ncb($n['id'], $n['args'] ? unserialize($n['args']) : null);
} else {
$ndesc = htmlspecialchars($n['type'] . ':' . $n['id']);
}
$ts = '<span class="nobr">';
$te = '</span>';
$ndesc = $ts . str_replace("\n", $te . '<br>' . $ts, $ndesc) . $te;
$notifs[] = array('date' => $n['date'], 'formattedDate' => relativedate($n['date']), 'text' => $ndesc);
}
return $notifs;
}
示例3: makeThreadLink
function makeThreadLink($thread)
{
$tags = ParseThreadTags($thread['title']);
$link = actionLinkTag($tags[0], 'thread', $thread['id'], '', HasPermission('forum.viewforum', $thread['forum'], true) ? $tags[0] : '');
$tags = $tags[1];
if (Settings::get("tagsDirection") === 'Left') {
return $tags . " " . $link;
} else {
return $link . " " . $tags;
}
}
示例4: array
<?php
if (!defined('BLARG')) {
die;
}
$userMenu = array();
if ($loguserid) {
if (HasPermission('user.editprofile')) {
$userMenu[actionLink('editprofile')] = __('Edit profile');
if (HasPermission('user.editavatars')) {
$userMenu[actionLink('editavatars')] = __('Mood avatars');
}
}
$userMenu[actionLink('private')] = __('Private messages');
$userMenu[actionLink('favorites')] = __('Favorites');
$bucket = 'userMenu';
include __DIR__ . "/../lib/pluginloader.php";
}
$layout_userpanel = $userMenu;
示例5: makePost
function makePost($post, $type, $params = array())
{
global $loguser, $loguserid, $usergroups, $isBot, $blocklayouts;
$poster = getDataPrefix($post, 'u_');
$post['userlink'] = UserLink($poster);
LoadBlockLayouts();
$pltype = Settings::get('postLayoutType');
$isBlocked = $poster['globalblock'] || $loguser['blocklayouts'] || $post['options'] & 1 || isset($blocklayouts[$poster['id']]);
$post['type'] = $type;
$post['formattedDate'] = formatdate($post['date']);
if (!HasPermission('admin.viewips')) {
$post['ip'] = '';
} else {
$post['ip'] = htmlspecialchars($post['ip']);
}
// TODO IP formatting?
if ($post['deleted'] && $type == POST_NORMAL) {
$post['deluserlink'] = UserLink(getDataPrefix($post, 'du_'));
$post['delreason'] = htmlspecialchars($post['reason']);
$links = array();
if (HasPermission('mod.deleteposts', $params['fid'])) {
$links['undelete'] = actionLinkTag(__("Undelete"), "editpost", $post['id'], "delete=2&key=" . $loguser['token']);
$links['view'] = "<a href=\"#\" onclick=\"replacePost(" . $post['id'] . ",true); return false;\">" . __("View") . "</a>";
}
$post['links'] = $links;
RenderTemplate('postbox_deleted', array('post' => $post));
return;
}
$links = array();
if ($type != POST_SAMPLE) {
$forum = $params['fid'];
$thread = $params['tid'];
$notclosed = !$post['closed'] || HasPermission('mod.closethreads', $forum);
$extraLinks = array();
if (!$isBot) {
if ($type == POST_DELETED_SNOOP) {
if ($notclosed && HasPermission('mod.deleteposts', $forum)) {
$links['undelete'] = actionLinkTag(__("Undelete"), "editpost", $post['id'], "delete=2&key=" . $loguser['token']);
}
$links['close'] = "<a href=\"#\" onclick=\"replacePost(" . $post['id'] . ",false); return false;\">" . __("Close") . "</a>";
} else {
if ($type == POST_NORMAL) {
if ($notclosed) {
if ($loguserid && HasPermission('forum.postreplies', $forum) && !$params['noreplylinks']) {
$links['quote'] = actionLinkTag(__("Quote"), "newreply", $thread, "quote=" . $post['id']);
}
$editrights = 0;
if ($poster['id'] == $loguserid && HasPermission('user.editownposts') || HasPermission('mod.editposts', $forum)) {
$links['edit'] = actionLinkTag(__("Edit"), "editpost", $post['id']);
$editrights++;
}
if ($poster['id'] == $loguserid && HasPermission('user.deleteownposts') || HasPermission('mod.deleteposts', $forum)) {
if ($post['id'] != $post['firstpostid']) {
$link = htmlspecialchars(actionLink('editpost', $post['id'], 'delete=1&key=' . $loguser['token']));
$onclick = HasPermission('mod.deleteposts', $forum) ? " onclick=\"deletePost(this);return false;\"" : ' onclick="if(!confirm(\'Really delete this post?\'))return false;"';
$links['delete'] = "<a href=\"{$link}\"{$onclick}>" . __('Delete') . "</a>";
}
$editrights++;
}
if ($editrights < 2 && HasPermission('user.reportposts')) {
$links['report'] = actionLinkTag(__('Report'), 'reportpost', $post['id']);
}
}
// plugins should add to $extraLinks
$bucket = "topbar";
include __DIR__ . "/pluginloader.php";
}
}
$links['extra'] = $extraLinks;
}
//Threadlinks for listpost.php
if ($params['threadlink']) {
$thread = array();
$thread['id'] = $post['thread'];
$thread['title'] = $post['threadname'];
$thread['forum'] = $post['fid'];
$post['threadlink'] = makeThreadLink($thread);
} else {
$post['threadlink'] = '';
}
//Revisions
if ($post['revision']) {
$ru_link = UserLink(getDataPrefix($post, "ru_"));
$revdetail = ' ' . format(__('by {0} on {1}'), $ru_link, formatdate($post['revdate']));
if (HasPermission('mod.editposts', $forum)) {
$post['revdetail'] = "<a href=\"javascript:void(0);\" onclick=\"showRevisions(" . $post['id'] . ")\">" . Format(__('rev. {0}'), $post['revision']) . "</a>" . $revdetail;
} else {
$post['revdetail'] = Format(__('rev. {0}'), $post['revision']) . $revdetail;
}
}
//</revisions>
}
$post['links'] = $links;
// POST SIDEBAR
$sidebar = array();
// quit abusing custom syndromes you unoriginal fuckers
$poster['title'] = preg_replace('@Affected by \'?.*?Syndrome\'?@si', '', $poster['title']);
$sidebar['rank'] = GetRank($poster['rankset'], $poster['posts']);
if ($poster['title']) {
$sidebar['title'] = strip_tags(CleanUpPost($poster['title'], '', true), '<b><strong><i><em><span><s><del><img><a><br/><br><small>');
//.........这里部分代码省略.........
示例6: bbcodeForum
function bbcodeForum($contents, $arg, $parenttag)
{
global $forumLinkCache, $loguser;
$id = (int) $arg;
if (!isset($forumLinkCache[$id])) {
$rForum = Query("select id, title from {forums} where id={0} AND id IN ({1c})", $id, ForumsWithPermission('forum.viewforum'));
if (NumRows($rForum)) {
$forum = Fetch($rForum);
$forumLinkCache[$id] = actionLinkTag($forum['title'], "forum", $forum['id'], '', HasPermission('forum.viewforum', $forum['id'], true) ? $forum['title'] : '');
} else {
$forumLinkCache[$id] = "<invalid forum ID>";
}
}
return $forumLinkCache[$id];
}
示例7: CanEditPerm
function CanEditPerm($perm, $arg = 0)
{
global $loguser;
if ($loguser['root']) {
return true;
}
return HasPermission($perm, $arg);
}
示例8: Query
} else {
if (isset($_GET['tid']) && isset($_GET['time'])) {
$rPost = Query("select id,date,thread from {posts} where thread={0} AND date>{1} ORDER BY date LIMIT 1", $_GET['tid'], $_GET['time']);
} else {
Kill('blarg');
}
}
if (NumRows($rPost)) {
$post = Fetch($rPost);
} else {
Kill(__("Unknown post ID."));
}
$pid = $post['id'];
$tid = $post['thread'];
$rThread = Query("select id,title,forum from {threads} where id={0}", $tid);
if (NumRows($rThread)) {
$thread = Fetch($rThread);
} else {
Kill(__("Unknown thread ID."));
}
$tags = ParseThreadTags($thread['title']);
$ppp = $loguser['postsperpage'];
if (!$ppp) {
$ppp = 20;
}
$from = floor(FetchResult("SELECT COUNT(*) FROM {posts} WHERE thread={1} AND date<={2} AND id!={0}", $pid, $tid, $post['date']) / $ppp) * $ppp;
$url = actionLink("thread", $thread['id'], $from ? "from={$from}" : "", HasPermission('forum.viewforum', $thread['forum'], true) ? $tags[0] : '') . "#post" . $pid;
header("HTTP/1.1 301 Moved Permanently");
header("Status: 301 Moved Permanently");
header("Location: " . $url);
die;
示例9: makeThreadListing
function makeThreadListing($threads, $pagelinks, $dostickies = true, $showforum = false)
{
global $loguserid, $loguser, $misc;
$threadlist = array();
while ($thread = Fetch($threads)) {
$tdata = array('id' => $thread['id']);
$starter = getDataPrefix($thread, 'su_');
$last = getDataPrefix($thread, 'lu_');
$ispublic = HasPermission('forum.viewforum', $thread['forum'], true);
$tags = ParseThreadTags($thread['title']);
$urlname = $ispublic ? $tags[0] : '';
$threadlink = actionLinkTag($tags[0], 'thread', $thread['id'], '', $urlname);
$tdata['link'] = Settings::get("tagsDirection") === 'Left' ? $tags[1] . ' ' . $threadlink : $threadlink . ' ' . $tags[1];
$NewIcon = '';
$tdata['gotonew'] = '';
if ($thread['closed']) {
$NewIcon = 'off';
}
if ($thread['replies'] >= $misc['hotcount']) {
$NewIcon .= 'hot';
}
if (!$loguserid && $thread['lastpostdate'] > time() - 900 || $loguserid && $thread['lastpostdate'] > $thread['readdate']) {
$NewIcon .= 'new';
if ($loguserid) {
$tdata['gotonew'] = actionLinkTag('<img src="' . resourceLink('img/gotounread.png') . '" alt="[go to first unread post]">', 'post', '', 'tid=' . $thread['id'] . '&time=' . (int) $thread['readdate']);
}
} else {
if (!$thread['closed'] && !$thread['sticky'] && Settings::get("oldThreadThreshold") > 0 && $thread['lastpostdate'] < time() - 2592000 * Settings::get("oldThreadThreshold")) {
$NewIcon = 'old';
}
}
if ($NewIcon) {
$tdata['new'] = '<div class="statusIcon ' . $NewIcon . '"></div>';
} else {
$tdata['new'] = '';
}
$tdata['sticky'] = $thread['sticky'];
if ($thread['icon']) {
//This is a hack, but given how icons are stored in the DB, I can do nothing about it without breaking DB compatibility.
if (startsWith($thread['icon'], "img/")) {
$thread['icon'] = resourceLink($thread['icon']);
}
$tdata['icon'] = "<img src=\"" . htmlspecialchars($thread['icon']) . "\" alt=\"\" class=\"smiley\" style=\"max-width:32px; max-height:32px;\">";
} else {
$tdata['icon'] = '';
}
$tdata['poll'] = $thread['poll'] ? "<img src=\"" . resourceLink("img/poll.png") . "\" alt=\"[poll]\">" : "";
$n = 4;
$total = $thread['replies'];
$ppp = $loguser['postsperpage'];
if (!$ppp) {
$ppp = 20;
}
$numpages = floor($total / $ppp);
$pl = '';
if ($numpages <= $n * 2) {
for ($i = 1; $i <= $numpages; $i++) {
$pl .= " " . actionLinkTag($i + 1, "thread", $thread['id'], "from=" . $i * $ppp, $urlname);
}
} else {
for ($i = 1; $i < $n; $i++) {
$pl .= " " . actionLinkTag($i + 1, "thread", $thread['id'], "from=" . $i * $ppp, $urlname);
}
$pl .= " … ";
for ($i = $numpages - $n + 1; $i <= $numpages; $i++) {
$pl .= " " . actionLinkTag($i + 1, "thread", $thread['id'], "from=" . $i * $ppp, $urlname);
}
}
if ($pl) {
$tdata['pagelinks'] = actionLinkTag(1, "thread", $thread['id'], '', $urlname) . $pl;
} else {
$tdata['pagelinks'] = '';
}
if ($showforum) {
$tdata['forumlink'] = actionLinkTag(htmlspecialchars($thread["f_title"]), "forum", $thread["f_id"], "", $ispublic ? $thread["f_title"] : '');
}
$tdata['startuser'] = UserLink($starter);
$tdata['replies'] = $thread['replies'];
$tdata['views'] = $thread['views'];
$tdata['lastpostdate'] = formatdate($thread['lastpostdate']);
$tdata['lastpostuser'] = UserLink($last);
$tdata['lastpostlink'] = actionLink("post", $thread['lastpostid']);
$threadlist[$tdata['id']] = $tdata;
}
RenderTemplate('threadlist', array('threads' => $threadlist, 'pagelinks' => $pagelinks, 'dostickies' => $dostickies, 'showforum' => $showforum));
}
示例10: FetchResult
$staffpms = '';
$showWhat = 0;
if (isset($_GET['show'])) {
$showWhat = (int) $_GET['show'];
$show = "&show=" . $showWhat;
if ($showWhat == 1) {
$deleted = 1;
} else {
if ($showWhat == 2) {
$drafting = 1;
}
}
$onclause = 'p.userto';
} else {
$whereFrom = "p.userto = {0}";
if (HasPermission('admin.viewstaffpms') && $user == $loguserid) {
$staffpms = ' OR userto={4}';
}
$onclause = 'p.userfrom';
}
$whereFrom .= " and p.drafting = " . $drafting;
$total = FetchResult("select count(*) from {pmsgs} p where ({$whereFrom}{$staffpms}) and !(p.deleted & {1})", $user, $deleted, null, null, -1);
$ppp = $loguser['threadsperpage'];
if (isset($_GET['from'])) {
$from = (int) $_GET['from'];
} else {
$from = 0;
}
$links = array();
$links[] = $showWhat == 0 ? __("Show received") : actionLinkTag(__("Show received"), "private", "", substr($userGet, 1));
$links[] = $showWhat == 1 ? __("Show sent") : actionLinkTag(__("Show sent"), "private", "", "show=1" . $userGet);
示例11: actionLinkTag
$links[] = actionLinkTag('Unban user', 'banhammer', $id, 'unban=1');
}
}
if (HasPermission('user.editprofile') && $loguserid == $id) {
$links[] = actionLinkTag(__("Edit my profile"), "editprofile");
} else {
if (HasPermission('admin.editusers')) {
$links[] = actionLinkTag(__("Edit user"), "editprofile", $id);
}
}
if (HasPermission('admin.editusers')) {
$links[] = actionLinkTag(__('Edit permissions'), 'editperms', '', 'uid=' . $id);
}
if (HasPermission('admin.viewpms')) {
$links[] = actionLinkTag(__("Show PMs"), "private", "", "user=" . $id);
}
if (HasPermission('user.sendpms')) {
$links[] = actionLinkTag(__("Send PM"), "sendprivate", "", "uid=" . $id);
}
$links[] = actionLinkTag(__("Show posts"), "listposts", $id, "", $user['name']);
$links[] = actionLinkTag(__("Show threads"), "listthreads", $id, "", $user['name']);
if ($loguserid) {
$links[] = $blockLayoutLink;
}
MakeCrumbs(array(actionLink("profile", $id, '', $user['name']) => htmlspecialchars($uname)), $links);
$title = format(__("Profile for {0}"), htmlspecialchars($uname));
function IsReallyEmpty($subject)
{
$trimmed = trim(preg_replace("/&.*;/", "", $subject));
return strlen($trimmed) == 0;
}
示例12: HasPermission
<?php
$canhavenamecolor = HasPermission('user.editnamecolor') || $editUserMode;
if (!function_exists("HandleUsernameColor")) {
function HandleUsernameColor($field, $item)
{
global $user, $canhavenamecolor;
if ($canhavenamecolor) {
$unc = $_POST['color'];
if ($unc != '') {
$unc = filterPollColors(str_pad($unc, 6, '0'));
}
Query("UPDATE {users} SET color={0s} WHERE id={1}", $unc, $user['id']);
}
return true;
}
}
if ($canhavenamecolor) {
AddField('general', 'appearance', 'color', __('Name color'), 'color', array('hint' => __('Leave empty to use the default color.'), 'callback' => 'HandleUsernameColor'));
}
示例13: __
<?php
// AcmlmBoard XD - Realtime visitor statistics page
// Access: all
$title = __("Online users");
MakeCrumbs(array(actionLink("online") => __("Online users")));
$showIPs = HasPermission('admin.viewips');
$time = (int) $_GET['time'];
if (!$time) {
$time = 300;
}
$rUsers = Query("select * from {users} where lastactivity > {0} order by lastactivity desc", time() - $time);
$rGuests = Query("select * from {guests} where date > {0} and bot = 0 order by date desc", time() - $time);
$rBots = Query("select * from {guests} where date > {0} and bot = 1 order by date desc", time() - $time);
$spans = array(60, 300, 900, 3600, 86400);
$spanList = array();
foreach ($spans as $span) {
$spanList[] = $span == $time ? timeunits($span) : actionLinkTag(timeunits($span), "online", "", "time={$span}");
}
$userList = array();
$i = 1;
while ($user = Fetch($rUsers)) {
$udata = array();
$udata['num'] = $i++;
$udata['link'] = UserLink($user);
$udata['lastPost'] = $user['lastposttime'] ? cdate("d-m-y G:i:s", $user['lastposttime']) : __("Never");
$udata['lastView'] = cdate("d-m-y G:i:s", $user['lastactivity']);
if ($user['lasturl']) {
$udata['lastURL'] = "<a href=\"" . FilterURL($user['lasturl']) . "\">" . FilterURL($user['lasturl']) . "</a>";
} else {
$udata['lastURL'] = __("None");
示例14: FetchResult
$forumname = '';
if (HasPermission('forum.viewforum', $thread['forum'], true)) {
$forumname = FetchResult("SELECT title FROM {forums} WHERE id={0}", $thread['forum']);
}
die(header("Location: " . actionLink("forum", $thread['forum'], '', $forumname)));
} else {
Kill(__("No trash forum set. Check board settings."));
}
} elseif ($_POST['actionedit']) {
if ($thread['forum'] != $_POST['moveTo'] && $canMove) {
$moveto = (int) $_POST['moveTo'];
$dest = Fetch(Query("select * from {forums} where id={0}", $moveto));
if (!$dest) {
Kill(__("Unknown forum ID."));
}
$isHidden = HasPermission('forum.viewforum', $moveto, true);
//Tweak forum counters
$rForum = Query("update {forums} set numthreads=numthreads-1, numposts=numposts-{0} where id={1}", $thread['replies'] + 1, $thread['forum']);
$rForum = Query("update {forums} set numthreads=numthreads+1, numposts=numposts+{0} where id={1}", $thread['replies'] + 1, $moveto);
$rThread = Query("update {threads} set forum={0} where id={1}", (int) $_POST['moveTo'], $tid);
// Tweak forum counters #2
Query("\tUPDATE {forums} LEFT JOIN {threads}\n\t\t\t\tON {forums}.id={threads}.forum AND {threads}.lastpostdate=(SELECT MAX(nt.lastpostdate) FROM {threads} nt WHERE nt.forum={forums}.id)\n\t\t\t\tSET {forums}.lastpostdate=IFNULL({threads}.lastpostdate,0), {forums}.lastpostuser=IFNULL({threads}.lastposter,0), {forums}.lastpostid=IFNULL({threads}.lastpostid,0)\n\t\t\t\tWHERE {forums}.id={0} OR {forums}.id={1}", $thread['forum'], $moveto);
Report("[b]" . $loguser['name'] . "[/] moved thread [b]" . $thread['title'] . "[/] -> [g]#HERE#?tid=" . $tid, $isHidden);
}
$isClosed = $canClose ? isset($_POST['isClosed']) ? 1 : 0 : $thread['closed'];
$isSticky = $canStick ? isset($_POST['isSticky']) ? 1 : 0 : $thread['sticky'];
$trimmedTitle = $canRename ? trim(str_replace(' ', ' ', $_POST['title'])) : 'lolnotempty';
if ($trimmedTitle != "") {
if ($canRename) {
$thread['title'] = $_POST['title'];
if ($_POST['iconid']) {
示例15: ForumJump
function ForumJump()
{
global $fid, $loguserid, $loguser, $forum;
$viewableforums = ForumsWithPermission('forum.viewforum');
$viewhidden = HasPermission('user.viewhiddenforums');
$rCats = Query("SELECT id, name FROM {categories} WHERE board={0} ORDER BY corder, id", $forum['board']);
$cats = array();
while ($cat = Fetch($rCats)) {
$cats[$cat['id']] = $cat['name'];
}
$rFora = Query("\tSELECT\n\t\t\t\t\t\t\tf.id, f.title, f.catid, f.redirect\n\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\t{forums} f\n\t\t\t\t\t\tWHERE f.id IN ({0c})" . (!$viewhidden ? " AND f.hidden=0" : '') . "\n\t\t\t\t\t\tORDER BY f.forder, f.id", $viewableforums);
$fora = array();
while ($forum = Fetch($rFora)) {
$fora[$forum['catid']][] = $forum;
}
$theList = '';
foreach ($cats as $cid => $cname) {
if (empty($fora[$cid])) {
continue;
}
$theList .= ' <optgroup label="' . htmlspecialchars($cname) . '">
' . fj_forumBlock($fora, $cid, $fid, 0) . ' </optgroup>
';
}
$theList = '<select onchange="document.location=this.options[this.selectedIndex].value;">' . ($forum['board'] ? '<option value="' . actionLink('board') . '">Back to main forums</option>' : '') . $theList . '</select>';
RenderTemplate('forumjump', array('forumlist' => $theList));
}