本文整理匯總了PHP中IPSText::cleanPermString方法的典型用法代碼示例。如果您正苦於以下問題:PHP IPSText::cleanPermString方法的具體用法?PHP IPSText::cleanPermString怎麽用?PHP IPSText::cleanPermString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類IPSText
的用法示例。
在下文中一共展示了IPSText::cleanPermString方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: doExecute
/**
* Main class entry point
*
* @param object ipsRegistry reference
* @return @e void [Outputs to screen]
*/
public function doExecute(ipsRegistry $registry)
{
//-----------------------------------------
// Got sess ID and mem ID?
//-----------------------------------------
if (!$this->member->getProperty('member_id')) {
$this->returnString("no");
}
//-----------------------------------------
// Check that we have the key
//-----------------------------------------
if ($this->settings['ipb_reg_number']) {
$this->settings['ipschat_account_key'] = $this->settings['ipb_reg_number'];
}
if (!$this->settings['ipschat_account_key']) {
$this->returnString("no");
}
//-----------------------------------------
// Can we access?
//-----------------------------------------
$access_groups = explode(",", $this->settings['ipschat_group_access']);
$my_groups = array($this->memberData['member_group_id']);
if ($this->memberData['mgroup_others']) {
$my_groups = array_merge($my_groups, explode(",", IPSText::cleanPermString($this->memberData['mgroup_others'])));
}
$access_allowed = false;
foreach ($my_groups as $group_id) {
if (in_array($group_id, $access_groups)) {
$access_allowed = 1;
break;
}
}
if (!$access_allowed) {
$this->returnString("no");
}
if ($this->memberData['chat_banned']) {
$this->returnString("no");
}
$permissions = 0;
if ($this->settings['ipschat_mods']) {
$mod_groups = explode(",", $this->settings['ipschat_mods']);
foreach ($my_groups as $group_id) {
if (in_array($group_id, $mod_groups)) {
$permissions = 1;
break;
}
}
}
if (!$permissions) {
$this->returnString("no");
}
//-----------------------------------------
// Ban member
//-----------------------------------------
IPSMember::save($this->request['id'], array('core' => array('chat_banned' => 1)));
//-----------------------------------------
// Something to return
//-----------------------------------------
$this->returnString("ok");
}
示例2: doExecute
/**
* Main class entry point
*
* @access public
* @param object ipsRegistry reference
* @return void [Outputs to screen]
*/
public function doExecute(ipsRegistry $registry)
{
//-----------------------------------------
// Check online/offline first
//-----------------------------------------
if (!$this->settings['ccs_online']) {
$show = false;
if ($this->settings['ccs_offline_groups']) {
$groups = explode(',', $this->settings['ccs_offline_groups']);
$myGroups = array($this->memberData['member_group_id']);
$secondary = IPSText::cleanPermString($this->memberData['mgroup_others']);
$secondary = explode(',', $secondary);
if (count($secondary)) {
$myGroups = array_merge($myGroups, $secondary);
}
foreach ($myGroups as $groupId) {
if (in_array($groupId, $groups)) {
$show = true;
break;
}
}
}
if (!$show) {
$this->registry->output->showError($this->settings['ccs_offline_message']);
}
}
//-----------------------------------------
// Load skin file
//-----------------------------------------
require_once IPSLib::getAppDir('ccs') . '/sources/pages.php';
$this->pageBuilder = new pageBuilder($this->registry);
$this->pageBuilder->loadSkinFile();
//-----------------------------------------
// Load Language
//-----------------------------------------
ipsRegistry::getClass('class_localization')->loadLanguageFile(array('public_lang'));
//-----------------------------------------
// What to do?
//-----------------------------------------
switch ($this->request['do']) {
case 'redirect':
$this->_redirector();
break;
case 'blockPreview':
$this->_showBlockPreview();
break;
default:
$this->_view();
break;
}
}
示例3: doExecute
/**
* Main class entry point
*
* @param object ipsRegistry reference
* @return @e void [Outputs to screen]
*/
public function doExecute(ipsRegistry $registry)
{
//-----------------------------------------
// Get member data and format
//-----------------------------------------
$user = intval($this->request['user']);
$id = intval($this->request['id']);
if (!$user) {
$this->returnString("no");
}
if ($id) {
$member = IPSMember::buildDisplayData(IPSMember::load($id));
} else {
$member = IPSMember::buildDisplayData(IPSMember::setUpGuest($this->lang->words['global_guestname'] . "_" . $user));
}
//-----------------------------------------
// Mod permissions
//-----------------------------------------
$my_groups = array($this->memberData['member_group_id']);
if ($this->memberData['mgroup_others']) {
$my_groups = array_merge($my_groups, explode(",", IPSText::cleanPermString($this->memberData['mgroup_others'])));
}
$permissions = 0;
$private = 0;
if ($this->settings['ipschat_mods']) {
$mod_groups = explode(",", $this->settings['ipschat_mods']);
foreach ($my_groups as $group_id) {
if (in_array($group_id, $mod_groups)) {
$permissions = 1;
break;
}
}
}
if ($this->settings['ipschat_private']) {
$mod_groups = explode(",", $this->settings['ipschat_private']);
foreach ($my_groups as $group_id) {
if (in_array($group_id, $mod_groups)) {
$private = 1;
break;
}
}
}
//-----------------------------------------
// Return output
//-----------------------------------------
$this->returnJsonArray(array('html' => ipsRegistry::getClass('output')->replaceMacros($this->registry->getClass('output')->getTemplate('ipchat')->ajaxNewUser(array('user_id' => $user, 'moderator' => $permissions, 'private' => $private, 'member' => $member))), 'prefix' => $this->settings['ipschat_format_names'] ? str_replace('"', '__DBQ__', $member['prefix']) : '', 'suffix' => $this->settings['ipschat_format_names'] ? str_replace('"', '__DBQ__', $member['suffix']) : '', 'pp_small_photo' => $member['pp_small_photo'], 'name' => $member['members_display_name'], '_canBeIgnored' => $member['member_id'] ? $member['_canBeIgnored'] : 1, 'g_id' => $member['g_id']));
}
示例4: warning_mods
public function warning_mods($member)
{
if (!ipsRegistry::$settings['warn_on']) {
return FALSE;
}
if ($member['g_is_supmod']) {
return TRUE;
} elseif ($member['is_mod']) {
$other_mgroups = array();
$_other_mgroups = IPSText::cleanPermString($member['mgroup_others']);
if ($_other_mgroups) {
$other_mgroups = explode(",", $_other_mgroups);
}
$other_mgroups[] = $member['member_group_id'];
ipsRegistry::DB()->build(array('select' => '*', 'from' => 'moderators', 'where' => "(member_id='" . $member['member_id'] . "' OR (is_group=1 AND group_id IN(" . implode(",", $other_mgroups) . ")))"));
ipsRegistry::DB()->execute();
while ($this->moderator = ipsRegistry::DB()->fetch()) {
if ($this->moderator['allow_warn']) {
return TRUE;
}
}
}
return FALSE;
}
示例5: _mergeComplete
/**
* Merge two topics
*
* @return @e void [Outputs to screen]
*/
protected function _mergeComplete()
{
$this->_resetModerator($this->topic['forum_id']);
$this->_genericPermissionCheck('split_merge');
//-----------------------------------------
// Check the input
//-----------------------------------------
if ($this->request['topic_url'] == "" or $this->request['title'] == "") {
$this->_showError('mod_missing_url_title', 10388);
}
//-----------------------------------------
// Get the topic ID of the entered URL
//-----------------------------------------
$old_id = $this->_getTidFromUrl();
if (!$old_id) {
$this->_showError('mod_missing_old_topic', 10389);
}
//-----------------------------------------
// Get the topic from the DB
//-----------------------------------------
$old_topic = $this->DB->buildAndFetch(array('select' => 'tid, title, forum_id, last_post, last_poster_id, last_poster_name, posts, views, topic_hasattach, approved', 'from' => 'topics', 'where' => 'tid=' . intval($old_id)));
if (!$old_topic['tid']) {
$this->_showError('mod_missing_old_topic', 10390);
}
//-----------------------------------------
// Did we try and merge the same topic?
//-----------------------------------------
if ($old_id == $this->topic['tid']) {
$this->_showError('mod_same_topics', 10391);
}
//-----------------------------------------
// Do we have moderator permissions for this
// topic (ie: in the forum the topic is in)
//-----------------------------------------
$pass = FALSE;
if ($this->topic['forum_id'] == $old_topic['forum_id']) {
$pass = TRUE;
} else {
if ($this->memberData['g_is_supmod'] == 1) {
$pass = TRUE;
} else {
if ($this->memberData['member_id']) {
$other_mgroups = array();
$_mgroup_others = IPSText::cleanPermString($this->memberData['mgroup_others']);
if ($_mgroup_others) {
$other_mgroups = explode(",", $_mgroup_others);
}
$other_mgroups[] = $this->memberData['member_group_id'];
$this->DB->build(array('select' => 'mid', 'from' => 'moderators', 'where' => "forum_id LIKE '%,{$old_topic['forum_id']},%' AND (member_id='" . $this->memberData['member_id'] . "' OR (is_group=1 AND group_id IN(" . implode(",", $other_mgroups) . ")))"));
$this->DB->execute();
if ($this->DB->getTotalRows()) {
$pass = TRUE;
}
}
}
}
if ($pass == FALSE) {
// No, we don't have permission
$this->_showError();
}
//-----------------------------------------
// Sort out polls
//-----------------------------------------
/* Who has a poll? */
$main_topic_poll = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'polls', 'where' => "tid={$this->topic['tid']}"));
$old_topic_poll = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'polls', 'where' => "tid={$old_topic['tid']}"));
/* The old topic has a poll and the new one doesn't */
if ($old_topic_poll['pid'] and !$main_topic_poll['pid']) {
// Make that poll the poll for the master topic
$this->DB->update('polls', array('tid' => $this->topic['tid']), "tid={$old_topic_poll['tid']}");
// Make the votes for that now
$this->DB->update('voters', array('tid' => $this->topic['tid']), "tid={$old_topic_poll['tid']}");
// Let the master topic know that it has a poll now
$this->DB->update('topics', array('poll_state' => 1), "tid={$this->topic['tid']}");
} elseif ($old_topic_poll['pid'] and $main_topic_poll['pid']) {
// Have we selected one?
if ($this->request['chosenpolltid']) {
$chosenTid = intval($this->request['chosenpolltid']);
// Remove the non chosen ones
$this->DB->delete('polls', "tid={$this->topic['tid']}");
$this->DB->delete('polls', "tid={$old_topic_poll} AND tid <> {$chosenTid}");
$this->DB->delete('voters', "tid={$this->topic['tid']}");
$this->DB->delete('voters', "tid={$old_topic_poll} AND tid <> {$chosenTid}");
// Make the chosen poll the poll for the master topic
$this->DB->update('polls', array('tid' => $this->topic['tid']), "tid={$chosenTid}");
// Make the votes for that now
$this->DB->update('voters', array('tid' => $this->topic['tid']), "tid={$chosenTid}");
// Let the master topic know that it has a poll now
$this->DB->update('topics', array('poll_state' => 1), "tid={$this->topic['tid']}");
} else {
ipsRegistry::getClass('class_localization')->loadLanguageFile(array('public_topic'));
$this->output .= $this->registry->getClass('output')->getTemplate('mod')->mergeMultiplePolls(array($main_topic_poll, $old_topic_poll), ",{$main_topic_poll['tid']},{$old_topic_poll['tid']}");
$this->registry->getClass('output')->addNavigation($this->forum['name'], "showforum={$this->forum['id']}", $this->forum['name_seo'], 'showforum');
$this->registry->getClass('output')->addNavigation($this->topic['title'], "showtopic={$this->topic['tid']}", $this->topic['title_seo'], 'showtopic');
$this->registry->getClass('output')->setTitle($this->lang->words['mt_top'] . " " . $this->topic['title'] . ' - ' . ipsRegistry::$settings['board_name']);
//.........這裏部分代碼省略.........
示例6: login
/**
* Process Login
*
* @param string Identifier - may be 'id', 'email' or 'username'
* @param string Value for identifier (for example, the user's ID number)
* @param string The password, md5 encoded
* @param string md5( IPS Connect Key (see login method) . Identifier Value )
* @param string Redirect URL, Base64 encoded
* @param string md5( IPS Connect Key . $redirect )
* @return mixed If the redirect URL is provided, this function should redirect the user to that URL with additional paramaters:
* connect_status value from below
* connect_id the ID number in this app
* connect_username the username
* connect_displayname the display name
* connect_email the email address
* connect_unlock If the account is locked, the time that it was locked
* connect_unlock_period The number of minutes until the account is unlocked (will be 0 if account does not automatically unlock)
* If blank, will output to screen a JSON object with the same parameters
* Values:
* SUCCESS login successful
* WRONG_AUTH Password incorrect
* NO_USER Identifier did not match member account
* MISSING_DATA Identifier or password was blank
* ACCOUNT_LOCKED Account has been locked by brute-force prevention
*/
public function login($identifier, $identifierValue, $md5Password, $key, $redirect, $redirectHash)
{
$member = NULL;
$statusCode = 'MISSING_DATA';
$secondsUntilUnlock = 0;
$revalidateUrl = '';
/* Check */
if (in_array($identifier, array('id', 'email', 'username'))) {
$member = IPSMember::load($identifierValue, 'none', $identifier);
if ($member['member_id']) {
/* Check we're not blocked */
if ($this->settings['ipb_bruteforce_attempts'] > 0) {
$failed_attempts = explode(",", IPSText::cleanPermString($member['failed_logins']));
$failed_count = 0;
$total_failed = 0;
$thisip_failed = 0;
$non_expired_att = array();
if (is_array($failed_attempts) and count($failed_attempts)) {
foreach ($failed_attempts as $entry) {
if (!strpos($entry, "-")) {
continue;
}
list($timestamp, $ipaddress) = explode("-", $entry);
if (!$timestamp) {
continue;
}
$total_failed++;
if ($ipaddress != $this->member->ip_address) {
continue;
}
$thisip_failed++;
if ($this->settings['ipb_bruteforce_period'] and $timestamp < time() - $this->settings['ipb_bruteforce_period'] * 60) {
continue;
}
$non_expired_att[] = $entry;
$failed_count++;
}
sort($non_expired_att);
$oldest_entry = array_shift($non_expired_att);
list($oldest, ) = explode("-", $oldest_entry);
}
if ($thisip_failed >= $this->settings['ipb_bruteforce_attempts']) {
if ($this->settings['ipb_bruteforce_unlock']) {
if ($failed_count >= $this->settings['ipb_bruteforce_attempts']) {
$secondsUntilUnlock = $oldest;
$statusCode = 'ACCOUNT_LOCKED';
}
} else {
$statusCode = 'ACCOUNT_LOCKED';
}
}
}
/* Check the password is valid */
if ($statusCode != 'ACCOUNT_LOCKED') {
if (IPSMember::authenticateMember($member['member_id'], $md5Password)) {
/* Are we validating? */
if ($member['ipsconnect_revalidate_url']) {
$statusCode = 'VALIDATING';
$revalidateUrl = $member['ipsconnect_revalidate_url'];
} else {
$validating = ipsRegistry::DB()->buildAndFetch(array('select' => '*', 'from' => 'validating', 'where' => "member_id={$member['member_id']} AND new_reg=1"));
if ($validating['vid']) {
$statusCode = 'VALIDATING';
if ($validating['user_verified'] == 1 or $this->settings['reg_auth_type'] == 'admin') {
$revalidateUrl = 'ADMIN_VALIDATION';
} else {
$revalidateUrl = ipsRegistry::getClass('output')->buildUrl('app=core&module=global&section=register&do=reval', 'public');
}
}
}
if ($statusCode != 'VALIDATING') {
/* Login Successful */
$statusCode = 'SUCCESS';
/* Log us in locally */
$this->han_login->loginWithoutCheckingCredentials($member['member_id'], TRUE);
//.........這裏部分代碼省略.........
示例7: getDataByAreaAndLastSentOlderThanDate
/**
* Get data based on an area and last sent greater than date [unix timestampe]
*
* @param integer $date Unix timestamp
* @param array $types Array of notification types (optional)
* @param array $parseMembers Parse extra data for each member and build display photo (false is default)
* @param integer $sendMax Null (use ipsRegistry::$setting or send INT only)
* @return @e mixed Array of likes data OR null
* @see allowedFrequencies()
*/
public function getDataByAreaAndLastSentOlderThanDate($date, $types = array(), $parseMembers = false, $sendMax = null)
{
/* Init */
$mids = array();
$members = array();
$rows = array();
$joins = array();
$where = is_array($types) ? ' AND l.like_notify_freq IN (\'' . implode("','", $types) . '\')' : '';
$sendMax = $sendMax !== null ? $sendMax : ipsRegistry::$settings['like_notifications_limit'];
/* figure out joins */
$joins[] = array('select' => 'm.*', 'from' => array('members' => 'm'), 'where' => 'm.member_id=l.like_member_id', 'type' => 'left');
$moreJoins = $this->getDataJoins();
if (is_array($moreJoins) and count($moreJoins)) {
foreach ($moreJoins as $join) {
$joins[] = $join;
}
}
/* Prevent it going back EONS AND EONS */
$oldestPossDate = 0;
if (in_array('weekly', $types)) {
$oldestPossDate = $date - 86400 * 7;
} else {
$oldestPossDate = $date - 86400;
}
if ($oldestPossDate) {
$where .= ' AND ( CASE WHEN l.like_notify_sent > 0 THEN l.like_notify_sent ELSE l.like_added END ) < ' . intval($oldestPossDate);
}
/* Fetch data */
$this->DB->build(array('select' => 'l.*', 'from' => array('core_like' => 'l'), 'where' => 'l.like_notify_do=1 AND l.like_app=\'' . classes_like_registry::getApp() . '\' AND l.like_area=\'' . classes_like_registry::getArea() . '\' AND l.like_visible=1 AND ( CASE WHEN l.like_notify_sent > 0 THEN l.like_notify_sent ELSE l.like_added END ) < ' . intval($date) . $where, 'order' => 'l.like_notify_sent ASC', 'limit' => array(0, $sendMax), 'add_join' => $joins));
$o = $this->DB->execute();
while ($row = $this->DB->fetch($o)) {
$row['like_member_id'] = intval($row['like_member_id']);
$mids[$row['like_member_id']] = $row['like_member_id'];
/* Need to apply secondary groups and grab g_perm_id if $parseMembers is false (default)
@link http://community.invisionpower.com/tracker/issue-34691-digest-notifications-not-going-out/ */
$row['mgroup_others'] = $row['mgroup_others'] != '' ? IPSText::cleanPermString($row['mgroup_others']) : '';
//by denchu
if (is_array($this->caches['group_cache'][$row['member_group_id']])) {
$row = array_merge($row, $this->caches['group_cache'][$row['member_group_id']]);
}
$row = $this->registry->member()->setUpSecondaryGroups($row);
if ($row['topic_last_post']) {
$row['last_post'] = $row['topic_last_post'];
}
/* @link http://community.invisionpower.com/tracker/issue-32204-dailyweekly-notifications */
$data[$row['like_member_id']][$row['like_id']] = $row;
}
/* Just the one? */
if ($parseMembers && count($mids)) {
$members = IPSMember::load($mids, 'all');
foreach ($members as $i => $d) {
$_m = IPSMember::buildProfilePhoto($d);
foreach ($data[$i] as $likeId => $likeData) {
$data[$i][$likeId] = array_merge((array) $_m, (array) $data[$i][$likeId]);
}
}
}
return is_array($data) ? $data : null;
}
示例8: parseBbcode
/**
* Loop over the bbcode and make replacements as necessary
*
* @access public
* @param string Current text
* @param string [db|display] Current method to parse
* @param mixed [optional] Only parse the selected code(s)
* @return string Converted text
*/
public function parseBbcode($txt, $cur_method = 'db', $_code = null)
{
//-----------------------------------------
// Pull out the non-replacable codes
//-----------------------------------------
if (!is_string($_code)) {
$txt = $this->_storeNonParsed($txt, $cur_method);
}
//-----------------------------------------
// We want preDbParse method called for shared
// media for permission checking, so force it for now..
//-----------------------------------------
if ($cur_method == 'db') {
$this->_bbcodes[$cur_method]['sharedmedia'] = $this->_bbcodes['display']['sharedmedia'];
$txt = preg_replace_callback('#(\\[code.*\\[/code\\])#is', array($this, '_checkForEmbeddedCode'), $txt);
}
//-----------------------------------------
// Regular replacing
//-----------------------------------------
if (isset($this->_bbcodes[$cur_method]) and is_array($this->_bbcodes[$cur_method]) and count($this->_bbcodes[$cur_method])) {
foreach ($this->_bbcodes[$cur_method] as $_bbcode) {
//-----------------------------------------
// Can this group use this bbcode?
//-----------------------------------------
if ($_bbcode['bbcode_groups'] != 'all' and $this->parsing_mgroup) {
$pass = false;
$groups = array_diff(explode(',', $_bbcode['bbcode_groups']), array(''));
$mygroups = array($this->parsing_mgroup);
if ($this->parsing_mgroup_others) {
$mygroups = array_diff(array_merge($mygroups, explode(',', IPSText::cleanPermString($this->parsing_mgroup_others))), array(''));
}
foreach ($groups as $g_id) {
if (in_array($g_id, $mygroups)) {
$pass = true;
break;
}
}
if (!$pass) {
continue;
}
}
//-----------------------------------------
// Reset our current position
//-----------------------------------------
$this->cur_pos = 0;
//-----------------------------------------
// Store teh tags
//-----------------------------------------
$_tags = array($_bbcode['bbcode_tag']);
//-----------------------------------------
// We'll also need to check for any aliases
//-----------------------------------------
if ($_bbcode['bbcode_aliases']) {
$aliases = explode(',', trim($_bbcode['bbcode_aliases']));
if (is_array($aliases) and count($aliases)) {
foreach ($aliases as $alias) {
$_tags[] = trim($alias);
}
}
}
//-----------------------------------------
// If we have a plugin, just pass off
//-----------------------------------------
if ($_bbcode['bbcode_php_plugin']) {
/* Legacy issues */
if ($_bbcode['bbcode_php_plugin'] == 'defaults.php') {
$file = IPS_ROOT_PATH . 'sources/classes/text/parser/bbcode/' . $_bbcode['bbcode_php_plugin'];
$class = 'bbcode_plugin_' . IPSText::alphanumericalClean($_bbcode['bbcode_tag']);
$method = "run";
} else {
$file = IPS_ROOT_PATH . 'sources/classes/bbcode/custom/' . $_bbcode['bbcode_php_plugin'];
$class = 'bbcode_' . IPSText::alphanumericalClean($_bbcode['bbcode_tag']);
$method = "pre" . ucwords($cur_method) . "Parse";
}
//-----------------------------------------
// Are we only parsing one code?
//-----------------------------------------
if (is_array($_code)) {
$good = false;
foreach ($_tags as $_tag) {
if (in_array($_tag, $_code)) {
$good = true;
break;
// Got one, stop here
}
}
if (!$good) {
continue;
}
} else {
if (is_string($_code)) {
//.........這裏部分代碼省略.........
示例9: renderForum
/**
* Build forum
*
* @param integer $r
* @param string $depth_guide
* @return string
*/
public function renderForum($r, $depth_guide = "")
{
//-----------------------------------------
// INIT
//-----------------------------------------
$desc = "";
$mod_string = "";
$r['skin_id'] = isset($r['skin_id']) ? $r['skin_id'] : '';
//-----------------------------------------
// Manage forums?
//-----------------------------------------
if ($this->type == 'manage') {
//-----------------------------------------
// Show main forums...
//-----------------------------------------
$children = $this->forumsGetChildren($r['id']);
$sub = array();
$subforums = "";
$count = 0;
//-----------------------------------------
// Build sub-forums link
//-----------------------------------------
if (count($children)) {
$r['name'] = "<a href='{$this->settings['base_url']}f={$r['id']}'>" . $r['name'] . "</a>";
foreach ($children as $cid) {
$count++;
$cfid = $cid;
if ($count == count($children)) {
//-----------------------------------------
// Last subforum, link to parent
// forum...
//-----------------------------------------
if (!isset($children[$count - 2]) or !($cfid = $children[$count - 2])) {
$cfid = $r['id'];
}
}
$sub[] = "<a href='{$this->settings['base_url']}f={$this->forum_by_id[$cid]['parent_id']}'>" . $this->forum_by_id[$cid]['name'] . "</a>";
}
}
if (count($sub)) {
$subforums = '<fieldset class="subforums"><legend>' . $this->lang->words['acp_subforum_legend'] . '</legend>' . implode(", ", $sub) . '</fieldset>';
}
$desc = "{$r['description']}{$subforums}";
//-----------------------------------------
// Moderators
//-----------------------------------------
$r['_modstring'] = "";
$r['_mods'] = array();
foreach ($this->moderators as $data) {
$forum_ids = explode(',', IPSText::cleanPermString($data['forum_id']));
foreach ($forum_ids as $forum_id) {
if ($forum_id == $r['id']) {
if ($data['is_group'] == 1) {
$data['_fullname'] = $this->lang->words['fc_group_prefix'] . $data['group_name'];
} else {
$data['_fullname'] = $data['members_display_name'];
}
$data['randId'] = substr(str_replace(array(' ', '.'), '', uniqid(microtime(), true)), 0, 10);
$data['forum_id'] = $forum_id;
$r['_mods'][] = $data;
}
}
}
if (count($r['_mods'])) {
$r['_modstring'] = $this->html->renderModeratorEntry($r['_mods']);
}
//-----------------------------------------
// Print
//-----------------------------------------
$this->skins[$r['skin_id']] = !empty($this->skins[$r['skin_id']]) ? $this->skins[$r['skin_id']] : '';
return $this->html->renderForumRow($desc, $r, $depth_guide, $this->skins[$r['skin_id']]);
}
}
示例10: addTopic
/**
* Post a new topic
* Very simply posts a new topic. Simple.
*
* Usage:
* $post->setTopicID(100);
* $post->setForumID(5);
* $post->setAuthor( $member );
*
* $post->setPostContent( "Hello [b]there![/b]" );
* # Optional: No bbcode, etc parsing will take place
* # $post->setPostContentPreFormatted( "Hello [b]there![/b]" );
* $post->setTopicTitle('Hi!');
* $post->addTopic();
*
* Exception Error Codes:
* NO_FORUM_ID : No forum ID set
* NO_AUTHOR_SET : No Author set
* NO_CONTENT : No post content set
* NO_SUCH_FORUM : No such forum
* NO_REPLY_PERM : Author cannot reply to this topic
* NO_POST_FORUM : Unable to post in that forum
* FORUM_LOCKED : Forum read only
*
* @return mixed
*/
public function addTopic()
{
//-----------------------------------------
// Global checks and functions
//-----------------------------------------
try {
$this->globalSetUp();
} catch (Exception $error) {
$this->_postErrors = $error->getMessage();
}
if ($this->_bypassPermChecks !== TRUE && IPSMember::isOnModQueue($this->getAuthor()) === NULL) {
$this->_postErrors = 'warnings_restrict_post_perm';
}
if (!$this->getPostContent() and !$this->getPostContentPreFormatted() and !$this->getIsPreview()) {
$this->_postErrors = 'NO_CONTENT';
}
//-----------------------------------------
// Get topic
//-----------------------------------------
try {
$topic = $this->topicSetUp();
} catch (Exception $error) {
$this->_postErrors = $error->getMessage();
}
//-----------------------------------------
// Parse the post, and check for any errors.
//-----------------------------------------
$post = $this->compilePostData();
//-----------------------------------------
// Do we have a valid post?
//-----------------------------------------
if ($this->getIsPreview() !== TRUE) {
if (strlen(trim(IPSText::removeControlCharacters(IPSText::br2nl($post['post'])))) < 1) {
$this->_postErrors = 'post_too_short';
}
if (IPSText::mbstrlen($post['post']) > $this->settings['max_post_length'] * 1024) {
$this->_postErrors = 'post_too_long';
}
/* Got a topic title? */
if (!$this->_topicTitle) {
$this->_postErrors = 'no_topic_title';
}
}
//-----------------------------------------
// Compile the poll
//-----------------------------------------
$this->poll_questions = $this->compilePollData();
if ($this->_postErrors != "" or $this->getIsPreview() === TRUE) {
//-----------------------------------------
// Show the form again
//-----------------------------------------
return FALSE;
}
//-----------------------------------------
// Build the master array
//-----------------------------------------
$topic = array('title' => $this->_topicTitle, 'title_seo' => IPSText::makeSeoTitle($this->_topicTitle), 'state' => $topic['state'], 'posts' => 0, 'starter_id' => $this->getAuthor('member_id'), 'starter_name' => $this->getAuthor('member_id') ? $this->getAuthor('members_display_name') : $this->request['UserName'], 'seo_first_name' => IPSText::makeSeoTitle($this->getAuthor('member_id') ? $this->getAuthor('members_display_name') : $this->request['UserName']), 'start_date' => $this->getDate() ? $this->getDate() : IPS_UNIX_TIME_NOW, 'last_poster_id' => $this->getAuthor('member_id'), 'last_poster_name' => $this->getAuthor('member_id') ? $this->getAuthor('members_display_name') : $this->request['UserName'], 'seo_last_name' => IPSText::makeSeoTitle($this->getAuthor('member_id') ? $this->getAuthor('members_display_name') : $this->request['UserName']), 'last_post' => $this->getDate() ? $this->getDate() : IPS_UNIX_TIME_NOW, 'author_mode' => $this->getAuthor('member_id') ? 1 : 0, 'poll_state' => (count($this->poll_questions) and $this->can_add_poll) ? 1 : 0, 'last_vote' => 0, 'views' => 0, 'forum_id' => $this->getForumData('id'), 'approved' => $this->getPublished() === TRUE ? 1 : 0, 'topic_archive_status' => $this->getPreventFromArchiving() ? 3 : 0, 'pinned' => intval($topic['pinned']), 'topic_open_time' => intval($this->times['open']), 'topic_close_time' => intval($this->times['close']));
//-----------------------------------------
// Check if we're ok with tags
//-----------------------------------------
$where = array('meta_parent_id' => $this->getForumData('id'), 'member_id' => $this->getAuthor('member_id'), 'existing_tags' => explode(',', IPSText::cleanPermString($this->request['ipsTags'])));
if ($this->registry->tags->can('add', $where) and $this->settings['tags_enabled'] and (!empty($_POST['ipsTags']) or $this->settings['tags_min'])) {
$this->registry->tags->checkAdd($_POST['ipsTags'], array('meta_parent_id' => $topic['forum_id'], 'member_id' => $this->memberData['member_id'], 'meta_visible' => $topic['approved']));
if ($this->registry->tags->getErrorMsg()) {
$this->_postErrors = $this->registry->tags->getFormattedError();
return FALSE;
}
$_storeTags = true;
}
//-----------------------------------------
// Insert the topic into the database to get the
// last inserted value of the auto_increment field
// follow suit with the post
//-----------------------------------------
//.........這裏部分代碼省略.........
示例11: saveItemPermMatrix
/**
* Builds a permission selection matrix
*
* @access public
* @param array Input perm matrix
* @param int Set ID
* @param array Applications originally on the form
* @return void
*/
public function saveItemPermMatrix($perm_matrix, $set_id, $applications = array())
{
//print_r($applications);exit;
/* Loop through all the applications originally on the form */
foreach ($applications as $app => $types) {
/* Loop through the types */
foreach ($types as $type => $confirmed) {
/* Reset the ID Array */
$_perm_row = array();
/* We need the mappings for this application */
require_once IPSLib::getAppDir($app) . '/extensions/coreExtensions.php';
/* Create the mapping object */
$map_class = $app . 'PermMapping' . $type;
$mapping = new $map_class();
$mapping_array = $mapping->getMapping();
/* Loop through each perm in this app */
if (count($perm_matrix[$app][$type]) and is_array($perm_matrix[$app][$type])) {
/* Loop through the perms in this app that we submitted */
foreach ($perm_matrix[$app][$type] as $perm => $ids) {
/* Build the ID Array */
foreach ($ids as $k => $v) {
/* Add the id to the array, this id can be a forum id, a gallery category id, etc */
if ($v == 1) {
$_perm_row[intval($k)][$mapping_array[$perm]] = $set_id;
}
}
}
}
/* Now we need to query all the existing permission rows for this type, so tha we can add in the other sets */
$this->registry->DB()->build(array('select' => '*', 'from' => 'permission_index', 'where' => "app='{$app}' AND perm_type='" . strtolower($type) . "'"));
$outer = $this->registry->DB()->execute();
/* Now to loop through those results and merge the existing permission set with the new modified ones */
while ($r = $this->registry->DB()->fetch($outer)) {
/* Our new permissions for this set */
$new_set_perm = $_perm_row[$r['perm_type_id']];
$perm_id = $r['perm_id'];
foreach ($mapping_array as $k => $v) {
/* Create an array from this permission */
$_perm_arr = explode(',', IPSText::cleanPermString($r[$v]));
/* Should this perm be active? */
if ($new_set_perm[$v] == $set_id) {
/* Yes, it should, is it already there? */
if (!($r[$v] == '*' || in_array($set_id, $_perm_arr))) {
/* It wasn't, so we need to add it */
$_perm_arr[] = $set_id;
}
} else {
/* IF this was global, that has to be updated */
if ($r[$v] == '*') {
/* Okay...so this means we need a list of every set id but the one being removed */
$this->registry->DB()->build(array('select' => 'perm_id', 'from' => 'forum_perms', 'where' => "perm_id <> {$set_id}"));
$this->registry->DB()->execute();
/* Reset this, to remove the '*' */
$_perm_arr = array();
/* And now add all those other ids to the array */
while ($p = $this->registry->DB()->fetch()) {
$_perm_arr[] = $p['perm_id'];
}
} else {
if (in_array($set_id, $_perm_arr)) {
unset($_perm_arr[array_search($set_id, $_perm_arr)]);
}
}
}
/* Set the new perm column */
$r[$v] = $_perm_arr[0] == '*' ? '*' : ',' . implode(',', $_perm_arr) . ',';
}
unset($r['perm_id']);
/* Update the record here */
$this->registry->DB()->update('permission_index', $r, "perm_id=" . $perm_id);
unset($_perm_row[$r['perm_type_id']]);
}
/* Left overs? */
if (isset($_perm_row) && is_array($_perm_row) && count($_perm_row)) {
/* Ok, there are leftovers, this means that there is no existing permission row, we need to add one */
foreach ($_perm_row as $new_perm_type_id => $_new_perm_s) {
$_new_insert = array('app' => $app, 'perm_type' => strtolower($type), 'perm_type_id' => $new_perm_type_id);
$_new_insert = array_merge($_new_insert, $_new_perm_s);
$this->registry->DB()->insert('permission_index', $_new_insert);
}
}
}
}
}
示例12: setUpMember
/**
* Set up a member
*
* @return @e void
*/
protected static function setUpMember()
{
//-----------------------------------------
// INIT
//-----------------------------------------
$cache = ipsRegistry::cache()->getCache('group_cache');
//-----------------------------------------
// Unpack cache
//-----------------------------------------
if (isset(self::$data_store['members_cache'])) {
self::$data_store['_cache'] = IPSMember::unpackMemberCache(self::$data_store['members_cache']);
} else {
self::$data_store['_cache'] = array();
}
if (!isset(self::$data_store['_cache']['friends']) or !is_array(self::$data_store['_cache']['friends'])) {
self::$data_store['_cache']['friends'] = array();
}
//-----------------------------------------
// Unpack ignored users
//-----------------------------------------
if (isset(self::$data_store['ignored_users'])) {
self::$data_store['_ignoredUsers'] = @unserialize(self::$data_store['ignored_users']);
} else {
self::$data_store['_ignoredUsers'] = array();
}
//-----------------------------------------
// Set up main 'display' group
//-----------------------------------------
if (is_array($cache[self::$data_store['member_group_id']])) {
self::$data_store = array_merge(self::$data_store, $cache[self::$data_store['member_group_id']]);
}
//-----------------------------------------
// Work out permissions
//-----------------------------------------
self::$data_store = self::instance()->setUpSecondaryGroups(self::$data_store);
/* Ensure we don't have a ,, string */
self::$data_store['org_perm_id'] = IPSText::cleanPermString(self::$data_store['org_perm_id']);
self::instance()->perm_id = !empty(self::$data_store['org_perm_id']) ? self::$data_store['org_perm_id'] : self::$data_store['g_perm_id'];
self::instance()->perm_id_array = explode(",", self::instance()->perm_id);
//-----------------------------------------
// Synchronise the last visit and activity times if
// we have some in the member profile
//-----------------------------------------
if (!self::$data_store['last_activity']) {
self::$data_store['last_activity'] = IPS_UNIX_TIME_NOW;
}
//-----------------------------------------
// If there hasn't been a cookie update in 2 hours,
// we assume that they've gone and come back
//-----------------------------------------
if (!self::$data_store['last_visit']) {
//-----------------------------------------
// No last visit set, do so now!
//-----------------------------------------
ipsRegistry::DB()->update('members', array('last_visit' => self::$data_store['last_activity'], 'last_activity' => IPS_UNIX_TIME_NOW), "member_id=" . self::$data_store['member_id'], true);
self::$data_store['last_visit'] = self::$data_store['last_activity'];
} else {
if (IPS_UNIX_TIME_NOW - self::$data_store['last_activity'] > 300) {
//-----------------------------------------
// If the last click was longer than 5 mins ago and this is a member
// Update their profile.
//-----------------------------------------
$be_anon = IPSMember::isLoggedInAnon(self::$data_store);
ipsRegistry::DB()->update('members', array('login_anonymous' => "{$be_anon}&1", 'last_activity' => IPS_UNIX_TIME_NOW), 'member_id=' . self::$data_store['member_id'], true);
}
}
//-----------------------------------------
// Group promotion based on time since joining
//-----------------------------------------
/* Are we checking for auto promotion? */
if (self::$data_store['g_promotion'] != '-1&-1') {
/* Are we checking for post based auto incrementation? 0 is post based, 1 is date based, so... */
if (self::$data_store['gbw_promote_unit_type']) {
list($gid, $gdate) = explode('&', self::$data_store['g_promotion']);
if ($gid > 0 and $gdate > 0) {
if (self::$data_store['joined'] <= time() - $gdate * 86400) {
IPSMember::save(self::$data_store['member_id'], array('core' => array('member_group_id' => $gid)));
/* Now reset the members group stuff */
self::$data_store = array_merge(self::$data_store, $cache[$gid]);
self::$data_store = self::instance()->setUpSecondaryGroups(self::$data_store);
self::instance()->perm_id = !empty(self::$data_store['org_perm_id']) ? self::$data_store['org_perm_id'] : self::$data_store['g_perm_id'];
self::instance()->perm_id_array = explode(",", self::instance()->perm_id);
}
}
}
}
}
示例13: _makePermOrdered
/**
* Fetch all relevant Perm IDs and make them ordered
* @param array $member
*/
private function _makePermOrdered($member)
{
$perms = array();
if (!empty($member['org_perm_id'])) {
$perms = explode(',', IPSText::cleanPermString($member['org_perm_id']));
}
if (!count($perms)) {
$groups = array($member['member_group_id']);
if (!empty($member['mgroup_others'])) {
$others = explode(',', IPSText::cleanPermString($member['mgroup_others']));
if (is_array($others)) {
$groups = array_merge($groups, $others);
}
}
foreach ($groups as $gid) {
$_perms = IPSText::cleanPermString($this->caches['group_cache'][$gid]['g_perm_id']);
if (!empty($_perms)) {
$__perms = explode(',', $_perms);
if (is_array($__perms)) {
$perms = array_merge($perms, $__perms);
}
}
}
}
if (is_array($perms) and count($perms)) {
sort($perms, SORT_NUMERIC);
$perms = array_unique($perms);
return implode(',', $perms);
} else {
return '';
}
}
示例14: buildDisplayData
//.........這裏部分代碼省略.........
}
if (stripos($member['pp_bio_content'], '[i]') !== false) {
if (stripos($member['pp_bio_content'], '[/i]') > stripos($member['pp_bio_content'], '[i]')) {
$member['pp_bio_content'] = str_ireplace('[i]', '<em>', $member['pp_bio_content']);
$member['pp_bio_content'] = str_ireplace('[/i]', '</em>', $member['pp_bio_content']);
}
}
if (stripos($member['pp_bio_content'], '[u]') !== false) {
if (stripos($member['pp_bio_content'], '[/u]') > stripos($member['pp_bio_content'], '[u]')) {
$member['pp_bio_content'] = str_ireplace('[u]', '<span class="underscore">', $member['pp_bio_content']);
$member['pp_bio_content'] = str_ireplace('[/u]', '</span>', $member['pp_bio_content']);
}
}
//-----------------------------------------
// Signature bbcode
//-----------------------------------------
if (isset($member['signature']) and $member['signature'] and $parseFlags['signature']) {
if (isset(self::$_parsedSignatures[$member['member_id']])) {
$member['signature'] = self::$_parsedSignatures[$member['member_id']];
} else {
if ($member['cache_content']) {
$member['signature'] = '<!--cached-' . gmdate('r', $member['cache_updated']) . '-->' . $member['cache_content'];
} else {
IPSText::getTextClass('bbcode')->parse_bbcode = ipsRegistry::$settings['sig_allow_ibc'];
IPSText::getTextClass('bbcode')->parse_smilies = 1;
IPSText::getTextClass('bbcode')->parse_html = ipsRegistry::$settings['sig_allow_html'];
IPSText::getTextClass('bbcode')->parse_nl2br = 1;
IPSText::getTextClass('bbcode')->parsing_section = 'signatures';
IPSText::getTextClass('bbcode')->parsing_mgroup = $member['member_group_id'];
IPSText::getTextClass('bbcode')->parsing_mgroup_others = $member['mgroup_others'];
$member['signature'] = IPSText::getTextClass('bbcode')->preDisplayParse($member['signature']);
IPSContentCache::update($member['member_id'], 'sig', $member['signature']);
}
self::$_parsedSignatures[$member['member_id']] = $member['signature'];
}
}
//-----------------------------------------
// If current session, reset last_activity
//-----------------------------------------
if (!empty($member['running_time'])) {
$member['last_activity'] = $member['running_time'] > $member['last_activity'] ? $member['running_time'] : $member['last_activity'];
}
//-----------------------------------------
// Online?
//-----------------------------------------
$time_limit = time() - ipsRegistry::$settings['au_cutoff'] * 60;
$member['_online'] = 0;
if (!ipsRegistry::$settings['disable_anonymous'] and isset($member['login_anonymous'])) {
list($be_anon, $loggedin) = explode('&', $member['login_anonymous']);
} else {
$be_anon = 0;
$loggedin = $member['last_activity'] > $time_limit ? 1 : 0;
}
$bypass_anon = 0;
$our_mgroups = array();
if (ipsRegistry::member()->getProperty('mgroup_others')) {
$our_mgroups = explode(",", IPSText::cleanPermString(ipsRegistry::member()->getProperty('mgroup_others')));
}
$our_mgroups[] = ipsRegistry::member()->getProperty('member_group_id');
if (ipsRegistry::member()->getProperty('g_access_cp') and !ipsRegistry::$settings['disable_admin_anon']) {
$bypass_anon = 1;
}
if (($member['last_visit'] > $time_limit or $member['last_activity'] > $time_limit) and ($be_anon != 1 or $bypass_anon == 1) and $loggedin == 1) {
$member['_online'] = 1;
}
//-----------------------------------------
// Last Active
//-----------------------------------------
$member['_last_active'] = ipsRegistry::getClass('class_localization')->getDate($member['last_activity'], 'SHORT');
if ($be_anon == 1) {
// Member last logged in anonymous
if (!ipsRegistry::member()->getProperty('g_access_cp') or ipsRegistry::$settings['disable_admin_anon']) {
$member['_last_active'] = ipsRegistry::getClass('class_localization')->words['private'];
}
}
//-----------------------------------------
// Rating
//-----------------------------------------
$member['_pp_rating_real'] = intval($member['pp_rating_real']);
//-----------------------------------------
// Long display names
//-----------------------------------------
$member['members_display_name_short'] = IPSText::truncate($member['members_display_name'], 16);
//-----------------------------------------
// Reputation
//-----------------------------------------
if (!ipsRegistry::isClassLoaded('repCache')) {
require_once IPS_ROOT_PATH . 'sources/classes/class_reputation_cache.php';
ipsRegistry::setClass('repCache', new classReputationCache());
}
$member['pp_reputation_points'] = $member['pp_reputation_points'] ? $member['pp_reputation_points'] : 0;
$member['author_reputation'] = ipsRegistry::getClass('repCache')->getReputation($member['pp_reputation_points']);
//-----------------------------------------
// Other stuff not worthy of individual comments
//-----------------------------------------
$member['members_profile_views'] = isset($member['members_profile_views']) ? $member['members_profile_views'] : 0;
$member['_pp_profile_views'] = ipsRegistry::getClass('class_localization')->formatNumber($member['members_profile_views']);
IPSDebug::setMemoryDebugFlag("IPSMember::buildDisplayData: " . $member['member_id'] . " - Completed", $_NOW);
return $member;
}
示例15: guestCanSeeTopic
/**
* Does a guest have access to this forum?
*
* @param int Forum ID
* @param int Override guest group with another (Facebook bot, spider search engine bots)
* @return boolean
* @author Matt
*/
public function guestCanSeeTopic($forumId = 0, $groupOverride = 0)
{
$forumId = $forumId ? $forumId : intval($this->request['f']);
$gid = $groupOverride ? $groupOverride : $this->settings['guest_group'];
$perms = explode(',', IPSText::cleanPermString($this->caches['group_cache'][$gid]['g_perm_id']));
if ($forumId) {
$forum = $this->forum_by_id[$forumId];
if (strstr($forum['perm_read'], '*')) {
return true;
} else {
foreach ($perms as $_perm) {
if (strstr(',' . $forum['perm_read'] . ',', ',' . $_perm . ',')) {
return true;
}
}
}
}
return false;
}