コード例 #1
0
ファイル: ban.php プロジェクト: mover5/imobackup
 /**
  * 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
0
 /**
  * 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
0
ファイル: adduser.php プロジェクト: mover5/imobackup
 /**
  * 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
0
ファイル: config.php プロジェクト: Advanture/Online-RolePlay
 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
0
ファイル: moderate.php プロジェクト: mover5/imobackup
 /**
  * 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']);
             return false;
         }
     }
     //-----------------------------------------
     // Update the posts, remove old polls, subs and topic
     //-----------------------------------------
     /* Remove from deletion log */
     IPSDeleteLog::removeEntries(array($old_topic['tid']), 'topic', TRUE);
     $this->DB->update('posts', array('topic_id' => $this->topic['tid']), 'topic_id=' . $old_topic['tid']);
     $this->DB->delete('voters', "tid=" . $old_topic['tid']);
     $this->DB->delete('topics', "tid=" . $old_topic['tid']);
     //-----------------------------------------
     // Update attachments
     //-----------------------------------------
     $this->DB->update('attachments', array('attach_parent_id' => $this->topic['tid']), "attach_rel_module='post' AND attach_parent_id=" . $old_topic['tid']);
     //-----------------------------------------
     // Update followers
     //-----------------------------------------
     require_once IPS_ROOT_PATH . 'sources/classes/like/composite.php';
     /*noLibHook*/
     $_like = classes_like::bootstrap('forums', 'topics');
     $_like->merge($old_topic['tid'], $this->topic['tid']);
     //-----------------------------------------
     // Tags
     //-----------------------------------------
     $this->registry->tags->moveTagsByMetaId($old_topic['tid'], $this->topic['tid']);
     //-----------------------------------------
     // Update the newly merged topic
     //-----------------------------------------
     $updater = array('title' => $this->request['title'], 'views' => $old_topic['views'] + $this->topic['views']);
     if ($old_topic['last_post'] > $this->topic['last_post']) {
         $updater['last_post'] = $old_topic['last_post'];
         $updater['last_poster_name'] = $old_topic['last_poster_name'];
         $updater['seo_last_name'] = IPSText::makeSeoTitle($old_topic['last_poster_name']);
         $updater['last_poster_id'] = $old_topic['last_poster_id'];
     }
     if ($old_topic['topic_hasattach']) {
         $updater['topic_hasattach'] = intval($this->topic['topic_hasattach']) + $old_topic['topic_hasattach'];
     }
     $this->DB->update('topics', $updater, 'tid=' . $this->topic['tid']);
     //-----------------------------------------
     // Fix up the "new_topic" attribute.
     //-----------------------------------------
     $this->DB->build(array('select' => 'pid, author_name, author_id, post_date', 'from' => 'posts', 'where' => "topic_id=" . $this->topic['tid'], 'order' => 'post_date ASC', 'limit' => array(0, 1)));
     $this->DB->execute();
     if ($first_post = $this->DB->fetch()) {
         $this->DB->update('posts', array('new_topic' => 0), "topic_id={$this->topic['tid']}");
         $this->DB->update('posts', array('new_topic' => 1), "pid={$first_post['pid']}");
     }
     //-----------------------------------------
     // Reset the post count for this topic
     //-----------------------------------------
     $amode = $first_post['author_id'] ? 1 : 0;
     $_queued = $this->registry->class_forums->fetchPostHiddenQuery(array('visible'), '');
     $this->DB->build(array('select' => 'COUNT(*) as posts', 'from' => 'posts', 'where' => $_queued . " AND topic_id=" . $this->topic['tid']));
     $this->DB->execute();
     if ($post_count = $this->DB->fetch()) {
         $post_count['posts']--;
         //Remove first post
         $this->DB->update('topics', array('posts' => $post_count['posts'], 'starter_name' => $first_post['author_name'], 'starter_id' => $first_post['author_id'], 'start_date' => $first_post['post_date'], 'author_mode' => $amode, 'topic_firstpost' => $first_post['pid']), 'tid=' . $this->topic['tid']);
     }
     $this->modLibrary->rebuildTopic($this->topic['tid']);
     //-----------------------------------------
     // Update the forum(s)
     //-----------------------------------------
     $this->registry->class_forums->allForums[$this->topic['forum_id']]['_update_deletion'] = 1;
     $this->modLibrary->forumRecount($this->topic['forum_id']);
     if ($this->topic['forum_id'] != $old_topic['forum_id']) {
         $this->registry->class_forums->allForums[$old_topic['forum_id']]['_update_deletion'] = 1;
         $this->modLibrary->forumRecount($old_topic['forum_id']);
     }
     /* Run moderation sync */
     $this->modLibrary->runModSync('topicMerge', $old_topic['tid'], $this->topic['tid']);
     $this->_addModeratorLog(sprintf($this->lang->words['acp_merged_topic'], $old_topic['title'], $this->topic['title']));
     $this->registry->output->redirectScreen($this->lang->words['mt_redirect'], $this->settings['base_url'] . "showtopic=" . $this->topic['tid'], $this->topic['title_seo'], 'showtopic');
 }
コード例 #6
0
 /**
  * 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&amp;module=global&amp;section=register&amp;do=reval', 'public');
                             }
                         }
                     }
                     if ($statusCode != 'VALIDATING') {
                         /* Login Successful */
                         $statusCode = 'SUCCESS';
                         /* Log us in locally */
                         $this->han_login->loginWithoutCheckingCredentials($member['member_id'], TRUE);
                         /* Run memberSync */
                         IPSLib::runMemberSync('onLogin', $member);
                     }
                 } else {
                     /* Login Failed */
                     $statusCode = 'WRONG_AUTH';
                     /* Append failed login */
                     if ($this->settings['ipb_bruteforce_attempts'] > 0) {
                         $failed_logins = explode(",", $member['failed_logins']);
                         $failed_logins[] = time() . '-' . $this->member->ip_address;
                         $failed_count = 0;
                         $total_failed = 0;
                         $non_expired_att = array();
                         foreach ($failed_logins as $entry) {
                             list($timestamp, $ipaddress) = explode("-", $entry);
                             if (!$timestamp) {
                                 continue;
                             }
                             $total_failed++;
                             if ($ipaddress != $this->member->ip_address) {
                                 continue;
                             }
                             if ($this->settings['ipb_bruteforce_period'] > 0 and $timestamp < time() - $this->settings['ipb_bruteforce_period'] * 60) {
                                 continue;
                             }
                             $failed_count++;
                             $non_expired_att[] = $entry;
                         }
                         if ($member['member_id'] and !$this->settings['failed_done']) {
                             IPSMember::save($member['email'], array('core' => array('failed_logins' => implode(",", $non_expired_att), 'failed_login_count' => $total_failed)));
                         }
                     }
                 }
             }
         } else {
             $statusCode = 'NO_USER';
         }
     }
     /* Run any custom code */
     $this->_runCustom('login', array($member, $statusCode));
     /* Hide the email if necessary */
     if ($statusCode != 'SUCCESS' and $identifier != 'email') {
         $member['email'] = '';
     }
     /* Return */
     if ($redirect) {
         $redirect = ($key == md5($this->masterKey . $identifierValue) and $redirectHash == md5($this->masterKey . $redirect)) ? $redirect : base64_encode($this->settings['board_url']);
     }
     $this->_return($redirect, array('connect_status' => $statusCode, 'connect_id' => $member['member_id'], 'connect_username' => $member['name'], 'connect_displayname' => $member['members_display_name'], 'connect_email' => $member['email'], 'connect_unlock' => $secondsUntilUnlock, 'connect_revalidate_url' => $revalidateUrl, 'connect_unlock_period' => $this->settings['ipb_bruteforce_period']));
 }
コード例 #7
0
 /**
  * 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
0
ファイル: core.php プロジェクト: mover5/imobackup
 /**
  * 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)) {
                         if (!in_array($_code, $_tags)) {
                             continue;
                         }
                     }
                 }
                 $_key = md5($_bbcode['bbcode_tag']);
                 //-----------------------------------------
                 // Do we already have this plugin in our registry?
                 //-----------------------------------------
                 if (isset($this->plugins[$_key])) {
                     //-----------------------------------------
                     // Run the method if it exists
                     //-----------------------------------------
                     if (method_exists($this->plugins[$_key], $method)) {
                         $_original = $txt;
                         $txt = $this->plugins[$_key]->{$method}($txt, $method == 'run' ? $cur_method == 'db' ? 'html' : 'display' : 'bbcode');
                         if (!$txt) {
                             $txt = $_original;
                         } else {
                             if ($this->plugins[$_key]->error) {
                                 $this->error = $this->plugins[$_key]->error;
                                 return $txt;
                             } else {
                                 if ($this->plugins[$_key]->warning) {
                                     $this->warning = $this->plugins[$_key]->warning;
                                 }
                             }
                         }
                     }
                 } elseif (is_file($file)) {
                     $_classname = IPSLib::loadLibrary($file, $class);
                     //-----------------------------------------
                     // Class we need exists
                     //-----------------------------------------
                     if (class_exists($_classname)) {
                         //-----------------------------------------
                         // New instance of class, store in plugin registry for use next time
                         //-----------------------------------------
                         $plugin = new $_classname($this->registry, $this);
                         //$method	= "pre" . ucwords($cur_method) . "Parse";
                         $this->plugins[md5($_bbcode['bbcode_tag'])] = $plugin;
                         //-----------------------------------------
                         // Method we need exists
                         //-----------------------------------------
                         if (method_exists($plugin, $method)) {
                             $_original = $txt;
                             $txt = $plugin->{$method}($txt, $method == 'run' ? $cur_method == 'db' ? 'html' : 'display' : 'bbcode');
                             if (!$txt) {
                                 $txt = $_original;
                             } else {
                                 if ($plugin->error) {
                                     $this->error = $plugin->error;
                                     return $txt;
                                 } else {
                                     if ($plugin->warning) {
                                         $this->warning = $plugin->warning;
                                     }
                                 }
                             }
                         }
                     }
                 }
                 //-----------------------------------------
                 // When we run a plugin, we don't do any other processing "automatically".
                 // Plugin is capable of doing what it wants that way.
                 //-----------------------------------------
                 continue;
             }
             //-----------------------------------------
             // Loop over this bbcode's tags
             //-----------------------------------------
             foreach ($_tags as $_tag) {
                 //-----------------------------------------
                 // Are we only parsing one code?
                 //-----------------------------------------
                 if (is_array($_code) and !in_array($_tag, $_code)) {
                     continue;
                 } else {
                     if (is_string($_code) and $_tag != $_code) {
                         continue;
                     }
                 }
                 //-----------------------------------------
                 // Infinite loop catcher
                 //-----------------------------------------
                 $_iteration = 0;
                 //-----------------------------------------
                 // Start building open tag
                 //-----------------------------------------
                 $open_tag = '[' . $_tag;
                 //-----------------------------------------
                 // Doz I can haz opin tag? Loopy loo
                 //-----------------------------------------
                 while (($this->cur_pos = stripos($txt, $open_tag, $this->cur_pos)) !== false) {
                     //-----------------------------------------
                     // Stop infinite loops
                     //-----------------------------------------
                     if ($_iteration > $this->settings['max_bbcodes_per_post']) {
                         break;
                     }
                     $open_length = strlen($open_tag);
                     //-----------------------------------------
                     // Grab the new position to jump to
                     //-----------------------------------------
                     $new_pos = strpos($txt, ']', $this->cur_pos) ? strpos($txt, ']', $this->cur_pos) : $this->cur_pos + 1;
                     //-----------------------------------------
                     // Extract the option (like surgery)
                     //-----------------------------------------
                     $_option = '';
                     if ($_bbcode['bbcode_useoption']) {
                         //-----------------------------------------
                         // Is option optional?
                         //-----------------------------------------
                         if ($_bbcode['bbcode_optional_option']) {
                             //-----------------------------------------
                             // Does we haz it?
                             //-----------------------------------------
                             if (substr($txt, $this->cur_pos + strlen($open_tag), 1) == '=') {
                                 $open_length += 1;
                                 $_option = substr($txt, $this->cur_pos + $open_length, strpos($txt, ']', $this->cur_pos) - ($this->cur_pos + $open_length));
                             } else {
                                 if (strpos($txt, ']', $this->cur_pos) - ($this->cur_pos + $open_length) !== 0) {
                                     if (strpos($txt, ']', $this->cur_pos)) {
                                         $this->cur_pos = $new_pos;
                                         continue;
                                     } else {
                                         break;
                                     }
                                 }
                             }
                         } else {
                             $open_length += 1;
                             $_option = substr($txt, $this->cur_pos + $open_length, strpos($txt, ']', $this->cur_pos) - ($this->cur_pos + $open_length));
                         }
                     } else {
                         if (strpos($txt, ']', $this->cur_pos) - ($this->cur_pos + $open_length) !== 0) {
                             if (strpos($txt, ']', $this->cur_pos)) {
                                 $this->cur_pos = $new_pos;
                                 continue;
                             }
                         }
                     }
                     $_iteration++;
                     //-----------------------------------------
                     // Protect against XSS
                     //-----------------------------------------
                     $_optionStrLen = IPSText::mbstrlen($_option);
                     $_optionSlenstr = strlen($_option);
                     $_option = $this->checkXss($_option, false, $_tag);
                     if ($_option !== FALSE) {
                         /* Not parsing URls? - Needs to be AFTER the FALSE check just above */
                         if (!empty($_bbcode['bbcode_no_auto_url_parse'])) {
                             $_option = preg_replace("#(http|https|news|ftp)://#i", "\\1&#58;//", $_option);
                         }
                         //-----------------------------------------
                         // If this is a single tag, that's it
                         //-----------------------------------------
                         if ($_bbcode['bbcode_single_tag']) {
                             $txt = substr_replace($txt, $this->_bbcodeToHtml($_bbcode, $_option, ''), $this->cur_pos, $open_length + $_optionSlenstr + 1);
                         } else {
                             $close_tag = '[/' . $_tag . ']';
                             if (stripos($txt, $close_tag, $new_pos) !== false) {
                                 $_content = substr($txt, $this->cur_pos + $open_length + $_optionSlenstr + 1, stripos($txt, $close_tag, $this->cur_pos) - ($this->cur_pos + $open_length + $_optionSlenstr + 1));
                                 if ($_bbcode['bbcode_useoption'] and $_bbcode['bbcode_optional_option'] and !$_option and !stristr($_bbcode['bbcode_replace'], '{option}')) {
                                     $_option = $_content;
                                     $_option = $this->checkXss($_option, false, $_tag);
                                 }
                                 /* Not parsing URls? */
                                 if (!empty($_bbcode['bbcode_no_auto_url_parse'])) {
                                     $_content = preg_replace("#(http|https|news|ftp)://#i", "\\1&#58;//", $_content);
                                 }
                                 $txt = substr_replace($txt, $this->_bbcodeToHtml($_bbcode, $_option, $_content), $this->cur_pos, stripos($txt, $close_tag, $this->cur_pos) + strlen($close_tag) - $this->cur_pos);
                             } else {
                                 //-----------------------------------------
                                 // If there's no close tag, no need to continue
                                 //-----------------------------------------
                                 break;
                             }
                         }
                     }
                     //-----------------------------------------
                     // And reset current position to end of open tag
                     // Bug 14744 - if we jump to $new_pos it can skip the opening of the next bbcode tag
                     // when the replacement HTML is shorter than the full bbcode representation...
                     //-----------------------------------------
                     $this->cur_pos = stripos($txt, $open_tag) ? stripos($txt, $open_tag) : $this->cur_pos + 1;
                     //$new_pos;
                     if ($this->cur_pos > strlen($txt)) {
                         break;
                     }
                 }
             }
         }
     }
     //-----------------------------------------
     // (c) (r) and (tm)
     //-----------------------------------------
     if ($cur_method == 'display' and $_code !== 'code' and $_code !== 'php' and $_code !== 'sql' and $_code !== 'xml') {
         $txt = str_ireplace("(c)", "&copy;", $txt);
         $txt = str_ireplace("(tm)", "&#153;", $txt);
         $txt = str_ireplace("(r)", "&reg;", $txt);
     }
     //-----------------------------------------
     // And finally replace those bbcodes
     //-----------------------------------------
     if (!$_code) {
         $txt = $this->_parseNonParsed($txt, $cur_method);
     }
     //-----------------------------------------
     // Auto parse URLs (only if this is full sweep)
     //-----------------------------------------
     if (!$_code and $cur_method == 'display') {
         /* If we parse <a href='http://site.com'>http://site[color=red].com[/color]</a>, it breaks
          * @link http://community.invisionpower.com/tracker/issue-24318-colors-in-urls-as-names-breaks-them/ 
          * Here we will extract <a></a> pairs, put in */
         $_storedLinks = array();
         $_counter = 0;
         while (preg_match('/<a href=\'(.+?)\'(.*?)>(.+?)<\\/a>/is', $txt, $matches)) {
             /* Is this a linked media URL? */
             if ($this->settings['bbcode_automatic_media'] and isset($this->_bbcodes['display']['media']) and ($this->_bbcodes['display']['media']['bbcode_sections'] == 'all' or in_array($this->parsing_section, explode(',', $this->_bbcodes['display']['media']['bbcode_sections'])))) {
                 $media = $this->cache->getCache('mediatag');
                 #href must match text (or has been shortened) and not a <a href="vid.com/4/">check this out!</a> style link
                 if ($matches[1] == $matches[3] or strstr($matches[3], '...')) {
                     if (is_array($media) and count($media)) {
                         foreach ($media as $type => $r) {
                             if (preg_match("#^" . $r['match'] . "\$#is", $matches[1])) {
                                 $this->cache->updateCacheWithoutSaving('_tmp_autoparse_media', 1);
                                 $_result = $this->parseBbcode('[media]' . $matches[1] . '[/media]', 'display', 'media');
                                 $this->cache->updateCacheWithoutSaving('_tmp_autoparse_media', 0);
                                 $txt = str_replace($matches[0], $_result, $txt);
                                 $this->_mediaUrlConverted[] = $matches[1];
                                 continue;
                             }
                         }
                     }
                 }
             }
             $_counter++;
             $_storedLinks[$_counter] = $matches[0];
             $txt = str_replace($matches[0], '<!--LINKS_TEMP--' . $_counter . '-->', $txt);
         }
         /* Capture 'href="' and '</a>' as [URL] is now parsed first, we discard these in _autoParseUrls */
         /**
          * @link	http://community.invisionpower.com/tracker/issue-23726-parser-wrong-url-with-unicode-chars/
          * I had to add the /u modifier to correct this.  Previously, the first byte sequence of the word was matching \s.
          * @link	http://community.invisionpower.com/tracker/issue-24684-posts-are-blankmissing/
          * Reverting this fix as it's breaking in some environments - not really sure what we can do about this at this point
          */
         //$opts = ( IPS_DOC_CHAR_SET == 'UTF-8' ) ? 'isu' : 'is';
         if (!$this->parse_html) {
             $opts = "is";
             $txt = preg_replace_callback('#(^|\\s|\\)|\\(|\\{|\\}|>|\\]|\\[|;|href=\\S)((http|https|news|ftp)://(?:[^<>\\)\\[\\"\\s]+|[a-zA-Z0-9/\\._\\-!&\\#;,%\\+\\?:=]+))(</a>)?#' . $opts, array($this, '_autoParseUrls'), $txt);
         }
         /* Now put back stored links */
         foreach ($_storedLinks as $_inc => $_storedLink) {
             $txt = str_replace('<!--LINKS_TEMP--' . $_inc . '-->', $_storedLink, $txt);
         }
     }
     return $txt;
 }
コード例 #9
0
 /**
  * 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
0
    /**
     * 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
        //-----------------------------------------
        $this->DB->setDataType(array('title', 'starter_name', 'seo_first_name', 'last_poster_name', 'seo_last_name'), 'string');
        /* Data Hook Location */
        IPSLib::doDataHooks($topic, 'postAddTopic');
        $this->DB->insert('topics', $topic);
        $post['topic_id'] = $this->DB->getInsertId();
        $topic['tid'] = $post['topic_id'];
        //-----------------------------------------
        // Update the post info with the upload array info
        //-----------------------------------------
        $post['post_key'] = $this->post_key;
        $post['new_topic'] = 1;
        //-----------------------------------------
        // Unqueue the post if we're starting a new topic
        //-----------------------------------------
        $post['queued'] = 0;
        /* Typecast */
        $this->DB->setDataType('post', 'string');
        /* Data Hook Location */
        IPSLib::doDataHooks($post, 'postFirstPost');
        /* Add post to DB */
        $this->DB->insert('posts', $post);
        $post['pid'] = $this->DB->getInsertId();
        //-----------------------------------------
        // Require pre-approval of topics?
        //-----------------------------------------
        if (!$topic['approved']) {
            $this->DB->insert('mod_queued_items', array('type' => 'topic', 'type_id' => $topic['tid']));
            /*noLibHook*/
        }
        /* Add to cache */
        IPSContentCache::update($post['pid'], 'post', $this->formatPostForCache($post['post']));
        //-----------------------------------------
        // Update topic with firstpost ID
        //-----------------------------------------
        $this->DB->update('topics', array('topic_firstpost' => $post['pid']), 'tid=' . $topic['tid']);
        //-----------------------------------------
        // Tagging
        //-----------------------------------------
        if ($_storeTags) {
            $this->registry->tags->add($_POST['ipsTags'], array('meta_id' => $topic['tid'], 'meta_parent_id' => $topic['forum_id'], 'member_id' => $this->memberData['member_id'], 'meta_visible' => $topic['approved']));
        }
        //-----------------------------------------
        // Add the poll to the polls table
        //-----------------------------------------
        if (count($this->poll_questions) and $this->can_add_poll) {
            $poll_only = 0;
            if ($this->settings['ipb_poll_only'] and $this->request['poll_only'] == 1) {
                $poll_only = 1;
            }
            $_pollData = array('tid' => $topic['tid'], 'forum_id' => $this->getForumData('id'), 'start_date' => IPS_UNIX_TIME_NOW, 'choices' => addslashes(serialize($this->poll_questions)), 'starter_id' => $this->getAuthor('member_id'), 'votes' => 0, 'poll_question' => IPSText::stripAttachTag($this->request['poll_question']), 'poll_only' => $poll_only, 'poll_view_voters' => intval($this->request['poll_view_voters']));
            /* Data Hook Location */
            IPSLib::doDataHooks($_pollData, 'postAddTopicPoll');
            $this->DB->insert('polls', $_pollData);
        }
        /* remove saved content */
        if ($this->memberData['member_id']) {
            $this->editor->removeAutoSavedContent(array('member_id' => $this->memberData['member_id'], 'autoSaveKey' => 'new-' . intval($this->getForumData('id'))));
        }
        //-----------------------------------------
        // If we are still here, lets update the
        // board/forum stats
        //-----------------------------------------
        $this->updateForumAndStats($topic, 'new');
        /* Upload Attachments */
        $this->uploadAttachments($this->post_key, $post['pid']);
        //-----------------------------------------
        // Make attachments "permanent"
        //-----------------------------------------
        $this->makeAttachmentsPermanent($this->post_key, $post['pid'], 'post', array('topic_id' => $topic['tid']));
        //-----------------------------------------
        // If we are a member, lets update thier last post
        // date and increment their post count.
        //-----------------------------------------
        $this->incrementUsersPostCount();
        //-----------------------------------------
        // Are we tracking new topics we start 'auto_track'?
        //-----------------------------------------
        $this->addTopicToTracker($topic['tid']);
        //-----------------------------------------
        // Moderating?
        //-----------------------------------------
        if ($this->getPublished() === FALSE) {
            /* Send email to mods about new unapproved topics */
            $this->sendNewTopicForApprovalEmails($topic['tid'], $topic['title'], $topic['starter_name'], $post['post'], $post['pid']);
            /* Do we want to skip the redirect? Useful in APIs */
            if ($this->getPublishedRedirectSkip() !== TRUE) {
                ipsRegistry::getClass('output')->redirectScreen($this->lang->words['moderate_topic'], $this->settings['base_url'] . "showforum=" . $this->getForumData('id'));
            }
        } else {
            /* add to recent post cache */
            if ($this->memberData['member_id']) {
                $this->registry->topics->addRecentPost(array('post_id' => $post['pid'], 'post_topic_id' => $topic['tid'], 'post_forum_id' => $topic['forum_id'], 'post_author_id' => $this->memberData['member_id'], 'post_date' => IPS_UNIX_TIME_NOW));
            }
            //-----------------------------------------
            // Are we tracking this forum? If so generate some mailies - yay!
            //-----------------------------------------
            $this->sendOutTrackedForumEmails($this->getForumData(), $topic, $post['post']);
            /* Send out social shares */
            $this->sendSocialShares($topic);
        }
        //-----------------------------------------
        // Ping Services
        //-----------------------------------------
        $services = ipsRegistry::$settings['ipseo_ping_services'];
        if (!empty($services)) {
            $services = explode(PHP_EOL, ipsRegistry::$settings['ipseo_ping_services']);
            if (is_array($services) and !empty($services)) {
                $url = ipsRegistry::getClass('output')->buildSEOUrl('showtopic=' . $topic['tid'], 'publicNoSession', $topic['title_seo'], 'showtopic');
                foreach ($services as $service) {
                    $service = trim($service);
                    if (!empty($service)) {
                        $context = array();
                        $context['http']['method'] = 'POST';
                        $context['http']['header'] = 'Content-Type: text/xml';
                        $context['http']['user_agent'] = 'Mozilla/5.0 (compatible; IP.SEO Bot)';
                        $context['http']['timeout'] = 1;
                        $context['http']['content'] = <<<EOF

<?xml version="1.0"?>
<methodCall>
\t<methodName>weblogUpdates.ping</methodName>
\t<params>
\t\t<param>
\t\t\t<value>{$topic['title']}</value>
\t\t</param>
\t\t<param>
\t\t\t<value>{$url}</value>
\t\t</param>
\t</params>
</methodCall>\t
EOF;
                        $context = stream_context_create($context);
                        @file_get_contents($service, false, $context);
                    }
                }
            }
        }
        //-----------------------------------------
        // Leave data for other apps
        //-----------------------------------------
        $this->setTopicData($topic);
        $this->setPostData($post);
        return TRUE;
    }
 /**
  * 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
0
 /**
  * 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
0
ファイル: simple.php プロジェクト: mover5/imobackup
 /**
  * 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
0
 /**
  * Parse a member for display
  *
  * @access	public
  * @param	mixed	Either array of member data, or member ID to self load
  * @param	array 	Array of flags to parse: 'signature', 'customFields', 'avatar', 'warn'
  * @return	array 	Parsed member data
  */
 public static function buildDisplayData($member, $_parseFlags = array())
 {
     $_NOW = IPSDebug::getMemoryDebugFlag();
     //-----------------------------------------
     // Figure out parse flags
     //-----------------------------------------
     $parseFlags = array('signature' => isset($_parseFlags['signature']) ? $_parseFlags['signature'] : 0, 'customFields' => isset($_parseFlags['customFields']) ? $_parseFlags['customFields'] : 0, 'avatar' => isset($_parseFlags['avatar']) ? $_parseFlags['avatar'] : 1, 'warn' => isset($_parseFlags['warn']) ? $_parseFlags['warn'] : 1, 'cfSkinGroup' => isset($_parseFlags['cfSkinGroup']) ? $_parseFlags['cfSkinGroup'] : '', 'cfGetGroupData' => isset($_parseFlags['cfGetGroupData']) ? $_parseFlags['cfGetGroupData'] : '', 'cfLocation' => isset($_parseFlags['cfLocation']) ? $_parseFlags['cfLocation'] : '', 'checkFormat' => isset($_parseFlags['checkFormat']) ? $_parseFlags['checkFormat'] : 0);
     if (isset($_parseFlags['__all__'])) {
         foreach ($parseFlags as $k => $v) {
             $parseFlags[$k] = 1;
         }
         $parseFlags['cfSkinGroup'] = '';
     }
     //-----------------------------------------
     // Load the member?
     //-----------------------------------------
     if (!is_array($member) and ($member == intval($member) and $member > 0)) {
         $member = self::load($member, 'all');
     }
     if (!$member['member_group_id']) {
         $member['member_group_id'] = ipsRegistry::$settings['guest_group'];
     }
     /* Unpack bitwise if required */
     if (!isset($member['bw_is_spammer'])) {
         $member = self::buildBitWiseOptions($member);
     }
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $rank_cache = ipsRegistry::cache()->getCache('ranks');
     $group_cache = ipsRegistry::cache()->getCache('group_cache');
     $group_name = IPSLib::makeNameFormatted($group_cache[$member['member_group_id']]['g_title'], $member['member_group_id']);
     $pips = 0;
     $topic_id = intval(isset(ipsRegistry::$request['t']) ? ipsRegistry::$request['t'] : 0);
     $forum_id = intval(isset(ipsRegistry::$request['f']) ? ipsRegistry::$request['f'] : 0);
     //-----------------------------------------
     // SEO Name
     //-----------------------------------------
     $member['members_seo_name'] = self::fetchSeoName($member);
     //-----------------------------------------
     // Avatar
     //-----------------------------------------
     if ($parseFlags['avatar']) {
         $member['avatar'] = self::buildAvatar($member);
     }
     $member['_group_formatted'] = $group_name;
     //-----------------------------------------
     // Ranks
     //-----------------------------------------
     if (is_array($rank_cache) and count($rank_cache)) {
         foreach ($rank_cache as $k => $v) {
             if ($member['posts'] >= $v['POSTS']) {
                 if (!isset($member['title']) || $member['title'] === '' || is_null($member['title'])) {
                     $member['title'] = $v['TITLE'];
                 }
                 $pips = $v['PIPS'];
                 break;
             }
         }
     }
     //-----------------------------------------
     // Group image
     //-----------------------------------------
     $member['member_rank_img'] = '';
     $member['member_rank_img_i'] = '';
     if ($group_cache[$member['member_group_id']]['g_icon']) {
         $_img = $group_cache[$member['member_group_id']]['g_icon'];
         if (substr($_img, 0, 4) != 'http') {
             $_img = ipsRegistry::$settings['_original_base_url'] . '/' . ltrim($_img, '/');
         }
         $member['member_rank_img_i'] = 'img';
         $member['member_rank_img'] = $_img;
     } else {
         if ($pips) {
             if (is_numeric($pips)) {
                 for ($i = 1; $i <= $pips; ++$i) {
                     $member['member_rank_img_i'] = 'pips';
                     $member['member_rank_img'] .= ipsRegistry::getClass('output')->getReplacement('pip_pip');
                 }
             } else {
                 $member['member_rank_img_i'] = 'img';
                 $member['member_rank_img'] = ipsRegistry::$settings['public_dir'] . 'style_extra/team_icons/' . $pips;
             }
         }
     }
     //-----------------------------------------
     // Spammer status
     //-----------------------------------------
     $member['spamStatus'] = NULL;
     $member['spamImage'] = NULL;
     $moderator = ipsRegistry::member()->getProperty('forumsModeratorData');
     if (isset($moderator[$forum_id]['bw_flag_spammers']) and $moderator[$forum_id]['bw_flag_spammers'] or ipsRegistry::member()->getProperty('g_is_supmod') == 1) {
         if (!ipsRegistry::$settings['warn_on'] or !strstr(',' . ipsRegistry::$settings['warn_protected'] . ',', ',' . $member['member_group_id'] . ',')) {
             if ($member['bw_is_spammer']) {
                 $member['spamStatus'] = TRUE;
             } else {
                 $member['spamStatus'] = FALSE;
             }
         }
     }
     //-----------------------------------------
     // Warny porny?
     //-----------------------------------------
     if ($parseFlags['warn'] and $member['member_id']) {
         $member['warn_percent'] = NULL;
         $member['can_edit_warn'] = false;
         $member['warn_img'] = NULL;
         if (ipsRegistry::$settings['warn_on'] and !strstr(',' . ipsRegistry::$settings['warn_protected'] . ',', ',' . $member['member_group_id'] . ',')) {
             /* Warnings */
             if (isset($moderator[$forum_id]['allow_warn']) and $moderator[$forum_id]['allow_warn'] or ipsRegistry::member()->getProperty('g_is_supmod') == 1 or ipsRegistry::$settings['warn_show_own'] and ipsRegistry::member()->getProperty('member_id') == $member['member_id']) {
                 // Work out which image to show.
                 if ($member['warn_level'] <= ipsRegistry::$settings['warn_min']) {
                     $member['warn_img'] = '{parse replacement="warn_0"}';
                     $member['warn_percent'] = 0;
                 } else {
                     if ($member['warn_level'] >= ipsRegistry::$settings['warn_max']) {
                         $member['warn_img'] = '{parse replacement="warn_5"}';
                         $member['warn_percent'] = 100;
                     } else {
                         $member['warn_percent'] = $member['warn_level'] ? sprintf("%.0f", $member['warn_level'] / ipsRegistry::$settings['warn_max'] * 100) : 0;
                         if ($member['warn_percent'] > 100) {
                             $member['warn_percent'] = 100;
                         }
                         if ($member['warn_percent'] >= 81) {
                             $member['warn_img'] = '{parse replacement="warn_5"}';
                         } else {
                             if ($member['warn_percent'] >= 61) {
                                 $member['warn_img'] = '{parse replacement="warn_4"}';
                             } else {
                                 if ($member['warn_percent'] >= 41) {
                                     $member['warn_img'] = '{parse replacement="warn_3"}';
                                 } else {
                                     if ($member['warn_percent'] >= 21) {
                                         $member['warn_img'] = '{parse replacement="warn_2"}';
                                     } else {
                                         if ($member['warn_percent'] >= 1) {
                                             $member['warn_img'] = '{parse replacement="warn_1"}';
                                         } else {
                                             $member['warn_img'] = '{parse replacement="warn_0"}';
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
                 if ($member['warn_percent'] < 1) {
                     $member['warn_percent'] = 0;
                 }
                 /* Bug 14770 - Change so you can't warn yourself */
                 if ((isset($moderator[$forum_id]['allow_warn']) and $moderator[$forum_id]['allow_warn'] or ipsRegistry::member()->getProperty('g_is_supmod') == 1) and $member['member_id'] != ipsRegistry::member()->getProperty('member_id')) {
                     $member['can_edit_warn'] = true;
                 }
             }
         }
     }
     //-----------------------------------------
     // Profile fields stuff
     //-----------------------------------------
     $member['custom_fields'] = "";
     if ($parseFlags['customFields'] == 1 and $member['member_id']) {
         if (isset(self::$_parsedCustomFields[$member['member_id']])) {
             $member['custom_fields'] = self::$_parsedCustomFields[$member['member_id']];
             if ($parseFlags['cfGetGroupData'] and isset(self::$_parsedCustomGroups[$member['member_id']]) and is_array(self::$_parsedCustomGroups[$member['member_id']])) {
                 $member['custom_field_groups'] = self::$_parsedCustomGroups[$member['member_id']];
             }
         } else {
             if (!is_object(self::$custom_fields_class)) {
                 require_once IPS_ROOT_PATH . 'sources/classes/customfields/profileFields.php';
                 self::$custom_fields_class = new customProfileFields();
             }
             if (self::$custom_fields_class) {
                 self::$custom_fields_class->member_data = $member;
                 self::$custom_fields_class->skinGroup = $parseFlags['cfSkinGroup'];
                 self::$custom_fields_class->initData();
                 self::$custom_fields_class->parseToView($parseFlags['checkFormat'], $parseFlags['cfLocation']);
                 $member['custom_fields'] = self::$custom_fields_class->out_fields;
                 self::$_parsedCustomFields[$member['member_id']] = $member['custom_fields'];
                 if ($parseFlags['cfGetGroupData']) {
                     $member['custom_field_groups'] = self::$custom_fields_class->fetchGroupTitles();
                     self::$_parsedCustomGroups[$member['member_id']] = $member['custom_field_groups'];
                 }
             }
         }
     }
     //-----------------------------------------
     // Profile photo
     //-----------------------------------------
     $member = self::buildProfilePhoto($member);
     //-----------------------------------------
     // Personal statement 'bbcode'
     //-----------------------------------------
     if (stripos($member['pp_bio_content'], '[b]') !== false) {
         if (stripos($member['pp_bio_content'], '[/b]') > stripos($member['pp_bio_content'], '[b]')) {
             $member['pp_bio_content'] = str_ireplace('[b]', '<strong>', $member['pp_bio_content']);
             $member['pp_bio_content'] = str_ireplace('[/b]', '</strong>', $member['pp_bio_content']);
         }
     }
     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
0
 /**
  * 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;
 }
コード例 #16
0
ファイル: moderate.php プロジェクト: mover5/imobackup
 /**
  * Move a topic
  *
  * @param	mixed 		Topic id | Array of topic ids
  * @param	integer		Source forum
  * @param	integer		Move to forum
  * @param	boolean		Leave the 'link'
  * @return	boolean
  */
 public function topicMove($topics, $source = 0, $moveto = 0, $leavelink = 0)
 {
     $this->error = "";
     $source = intval($source);
     $moveto = intval($moveto);
     $forumIDSQL = $source ? " forum_id={$source} AND " : '';
     $ids = array();
     if (is_array($topics)) {
         $topics = IPSLib::cleanIntArray($topics);
         if (count($topics) > 0) {
             $tid = " IN(" . implode(",", $topics) . ")";
             $ids = $topics;
         } else {
             return false;
         }
         //-----------------------------------------
         // Mark as read in new forum
         //-----------------------------------------
         foreach ($topics as $_tid) {
             $this->registry->classItemMarking->markRead(array('forumID' => $moveto, 'itemID' => $_tid), 'forums');
         }
     } else {
         if (intval($topics)) {
             $tid = "={$topics}";
             $ids = array($topics);
         } else {
             return false;
         }
         //-----------------------------------------
         // Mark as read in new forum
         //-----------------------------------------
         $this->registry->classItemMarking->markRead(array('forumID' => $moveto, 'itemID' => $topics), 'forums');
     }
     /* GET AND EXAMINE */
     $_topics = $this->registry->topics->getTopics(array('topicId' => $ids, 'archiveState' => array('not', 'exclude'), 'topicType' => array('all')));
     if (!count($_topics)) {
         return false;
     } else {
         $ids = array_keys($_topics);
         $tid = " IN(" . implode(",", $ids) . ")";
     }
     /* Update recent posts */
     $this->registry->topics->updateRecentPost(array('post_forum_id' => $moveto), array('post_topic_id' => $ids));
     //-----------------------------------------
     // Update the topic
     //-----------------------------------------
     $this->DB->update('topics', array('forum_id' => $moveto), $forumIDSQL . "tid" . $tid);
     //-----------------------------------------
     // Update the polls
     //-----------------------------------------
     $this->DB->update('polls', array('forum_id' => $moveto), $forumIDSQL . "tid" . $tid);
     //-----------------------------------------
     // Update the voters
     //-----------------------------------------
     $this->DB->update('voters', array('forum_id' => $moveto), $forumIDSQL . "tid" . $tid);
     //-----------------------------------------
     // Are we leaving a stink er link?
     //-----------------------------------------
     if ($leavelink and $source) {
         $this->DB->build(array('select' => '*', 'from' => 'topics', 'where' => "tid" . $tid));
         $oq = $this->DB->execute();
         while ($row = $this->DB->fetch($oq)) {
             $this->DB->setDataType(array('title', 'starter_name', 'last_poster_name', 'seo_last_name'), 'string');
             $this->DB->insert('topics', array('title' => $row['title'], 'state' => 'link', 'posts' => 0, 'views' => 0, 'starter_id' => $row['starter_id'], 'start_date' => $row['start_date'], 'starter_name' => $row['starter_name'], 'seo_first_name' => IPSText::makeSeoTitle($row['starter_name']), 'last_post' => $row['last_post'], 'forum_id' => $source, 'approved' => 1, 'pinned' => 0, 'moved_to' => $row['tid'] . '&' . $moveto, 'moved_on' => time(), 'last_poster_id' => $row['last_poster_id'], 'last_poster_name' => $row['last_poster_name'], 'seo_last_name' => IPSText::makeSeoTitle($row['starter_name'])));
         }
     }
     /* Tagging */
     $this->registry->tags->moveTagsToParentId($ids, $moveto);
     //-----------------------------------------
     // Sort out subscriptions
     //-----------------------------------------
     $trid_to_delete = array();
     //-----------------------------------------
     // Like class - remove if you don't have access
     //-----------------------------------------
     require_once IPS_ROOT_PATH . 'sources/classes/like/composite.php';
     /*noLibHook*/
     $_like = classes_like::bootstrap('forums', 'topics');
     $topics = $_like->getDataByRelationshipId($tid);
     if (count($topics)) {
         foreach ($topics as $r) {
             $perm_id = $r['org_perm_id'] ? $r['org_perm_id'] : $r['g_perm_id'];
             if ($this->registry->permissions->check('read', $this->registry->class_forums->allForums[$moveto], explode(',', IPSText::cleanPermString($perm_id))) !== TRUE) {
                 $trid_to_delete[] = $r['like_id'];
             }
         }
     }
     if (count($trid_to_delete) > 0) {
         $this->DB->delete('core_like', "like_id IN('" . implode("','", $trid_to_delete) . "')");
     }
     return true;
 }
コード例 #17
0
    /**
     * List the applications
     *
     * @param	array 		Application
     * @param	array 		Uninstalled applications
     * @return	string		HTML
     */
    public function applications_list($applications, $uninstalled = array(), $message = NULL)
    {
        $IPBHTML = "";
        //--starthtml--//
        $canInstall = $this->registry->class_permissions->checkPermission('app_install');
        $IPBHTML .= <<<EOF
<div class='section_title'>
\t<h2>{$this->lang->words['a_apps']}</h2>
\t
\t<div class='ipsActionBar clearfix'>
\t\t<ul>
EOF;
        if ($canInstall) {
            $IPBHTML .= <<<EOF
\t\t\t<li class='ipsActionButton'>
\t\t\t\t<a href='{$this->settings['base_url']}module=applications&amp;section=applications&amp;do=application_add'><img src='{$this->settings['skin_acp_url']}/images/icons/application_add.png' alt='' /> {$this->lang->words['a_addnewapp']}</a>
\t\t\t</li>
EOF;
        }
        $IPBHTML .= <<<EOF
\t\t\t<li class='ipsActionButton'>
\t\t\t\t<a href='{$this->settings['base_url']}module=applications&amp;section=applications&amp;do=module_recache_all'><img src='{$this->settings['skin_acp_url']}/images/icons/arrow_refresh.png' alt='' /> {$this->lang->words['recache_link']}</a>
\t\t\t</li>
EOF;
        if ($this->settings['search_method'] == 'sphinx' && $this->registry->class_permissions->checkPermission('build_sphinx')) {
            $IPBHTML .= <<<EOF
\t\t\t<li class='ipsActionButton'>
\t\t\t\t<a href='#' class='ipbmenu' id='sphinx_conf' title='{$this->lang->words['sphinx_menu_desc']}'><img src='{$this->settings['skin_acp_url']}/images/icons/cog.png' /> {$this->lang->words['sphinx_menu_title']} <img src='{$this->settings['skin_acp_url']}/images/useropts_arrow.png' /></a>
\t\t\t\t<ul class='ipbmenu_content' id='sphinx_conf_menucontent' style='display: none'>
\t\t\t\t\t<li>
\t\t\t\t\t\t<img src='{$this->settings['skin_acp_url']}/images/icons/page_white_code.png' alt='' /> <a href='{$this->settings['base_url']}module=applications&amp;section=applications&amp;do=sphinxBuildConf'>{$this->lang->words['sphinx_build_conf']}</a>
\t\t\t\t\t</li>
\t\t\t\t\t<li>
\t\t\t\t\t\t<img src='{$this->settings['skin_acp_url']}/images/icons/page_white_code.png' alt='' /> <a href="{$this->settings['base_url']}module=applications&amp;section=applications&amp;do=sphinxBuildCron">{$this->lang->words['sphinx_build_cronjob']}</a>
\t\t\t\t\t</li>
\t\t\t\t</ul>
\t\t\t</li>
EOF;
        }
        $IPBHTML .= <<<EOF
\t\t\t<li class='ipsActionButton'>
\t\t\t\t<a href='{$this->settings['base_url']}{$this->form_code}do=applications_overview&amp;checkUpdates=1'><img src='{$this->settings['skin_acp_url']}/images/icons/cog.png' /> {$this->lang->words['hook_check_updates']}</a>
\t\t\t</li>
\t\t\t<li class='ipsActionButton inDev'>
\t\t\t\t<a href='{$this->settings['base_url']}module=applications&amp;section=applications&amp;do=inDevExportApps'><img src='{$this->settings['skin_acp_url']}/images/icons/arrow_rotate_anticlockwise.png' alt='' /> {$this->lang->words['export_apps_xml']}</a>
\t\t\t</li>
\t\t\t<li class='ipsActionButton inDev'>
\t\t\t\t<a href='{$this->settings['base_url']}{$this->form_code}&amp;do=inDevExportAll'><img src='{$this->settings['skin_acp_url']}/images/icons/export.png' alt='' /> {$this->lang->words['export_modules_xml']}</a>
\t\t\t</li>
\t\t\t<li class='ipsActionButton inDev'>
\t\t\t\t<a href='{$this->settings['base_url']}{$this->form_code}&amp;do=inDevRebuildAll'><img src='{$this->settings['skin_acp_url']}/images/icons/import.png' alt='' /> {$this->lang->words['import_modules_xml']}</a>
\t\t\t</li>
\t\t</ul>
\t</div>
</div>

EOF;
        if ($message) {
            $IPBHTML .= "<div class='information-box'>{$message}</div><br />";
        }
        $IPBHTML .= <<<EOF
<!-- LEFT SIDEBAR -->
<div class='acp-box left' style='width: 69%'>
 \t<h3>{$this->lang->words['a_installedapps']}</h3>
 \t
\t<div id='tabstrip_appsList' class='ipsTabBar with_left with_right'>
\t\t<span class='tab_left'>&laquo;</span>
\t\t<span class='tab_right'>&raquo;</span>
\t\t<ul>
\t\t\t<li id='tab_appsEnabled'>{$this->lang->words['a_apps_enabled']}</li>
\t\t\t<li id='tab_appsDisabled'>{$this->lang->words['a_apps_disabled']}</li>
\t\t</ul>
\t</div>
\t
\t<div id='tabstrip_appsList_content' class='ipsTabBar_content'>
\t\t
\t\t<div id='tab_appsEnabled_content'>
\t\t\t<table class='ipsTable' id='apps_enabled'>
\t\t\t\t<tr>
\t\t\t\t\t<th width='1%'>&nbsp;</th>
\t\t\t\t\t<th width='1%'>&nbsp;</th>
\t\t\t\t\t<th width='55%'>{$this->lang->words['a_hookapp']}</th>
\t\t\t\t\t<th width='15%' class='center'>{$this->lang->words['app_tab_permissions']}</th>
\t\t\t\t\t<th width='20%' class='center'>{$this->lang->words['a_lastupdated']}</th>
\t\t\t\t\t<th class='col_buttons'>&nbsp;</th>
\t\t\t\t</tr>
EOF;
        if (count($applications['enabled'])) {
            foreach ($applications['enabled'] as $app) {
                $img = is_file(IPSLib::getAppDir($app['app_directory']) . '/skin_cp/appIcon.png') ? $this->settings['base_acp_url'] . '/' . IPSLib::getAppFolder($app['app_directory']) . '/' . $app['app_directory'] . '/skin_cp/appIcon.png' : "{$this->settings['skin_acp_url']}/images/applications/{$app['app_directory']}.png";
                # IPS app?
                $app['titlePrefix'] = in_array($app['app_location'], array('root', 'ips')) ? "<span class='ipsBadge badge_purple'>{$this->lang->words['gl_ipsapp']}</span>&nbsp;&nbsp;" : '';
                # Sort title
                $app['app_title'] = IN_DEV ? "<a href='{$this->settings['base_url']}{$this->form_code}do=application_edit&amp;app_id={$app['app_id']}'>{$app['app_title']}</a>" : $app['app_title'];
                $app['app_description'] = $app['app_description'] ? "<br /><span class='desctext'>{$app['app_description']}</span>" : '';
                # Tab Restrictions
                $app['_tab_restricted'] = $app['app_hide_tab'] || IPSText::cleanPermString($app['app_tab_groups']) ? "<a href='{$this->settings['base_url']}{$this->form_code}do=application_edit&amp;app_id={$app['app_id']}&amp;_tab=restrictions' title='{$this->lang->words['a_edit_restrictions']}'><img src='{$this->settings['skin_acp_url']}/images/icons/tick.png' alt='' /></a>" : '';
                # Update available?
                if ($app['app_update_available'][0]) {
                    $_update = "<span class='ipsBadge badge_purple'>{$this->lang->words['hook_update_available']}</span>";
                    if (!empty($app['app_update_available'][1])) {
                        $_update = "<a href='{$app['app_update_available'][1]}' target='_blank'>{$_update}</a>";
                    } elseif ($app['app_website']) {
                        $_update = "<a href='{$app['app_website']}' target='_blank'>{$_update}</a>";
                    }
                    $app['_updated'] = $_update;
                } elseif (isset($app['_long_version']) && $app['_long_version'] > $app['_long_current']) {
                    $app['_updated'] = "<a href='{$this->settings['board_url']}/" . CP_DIRECTORY . "/upgrade/' class='ipsBadge badge_green'>{$this->lang->words['a_upgradeavail']}</a>";
                } else {
                    $app['_updated'] = "<span class='desctext'>{$this->lang->words['a_oh_kay']}</span>";
                }
                if ($app['app_directory'] == 'core') {
                    $IPBHTML .= <<<EOF
\t\t\t<tr class='ipsControlRow'>
\t\t\t\t<td>&nbsp;</td>
EOF;
                } else {
                    $IPBHTML .= <<<EOF
\t\t\t<tr class='ipsControlRow isDraggable' id='apps_{$app['app_id']}'>
\t\t\t\t<td class='col_drag'>
\t\t\t\t\t<span class='draghandle'>&nbsp;</span>
\t\t\t\t</td>
EOF;
                }
                $IPBHTML .= <<<EOF
\t\t\t\t<td>
\t\t\t\t\t<img src='{$img}' alt='' />
\t\t\t\t</td>
\t\t\t\t<td>
\t\t\t\t\t<strong><span class='larger_text'>{$app['titlePrefix']}{$app['app_title']}</span></strong><span class='desctext'>&nbsp;&nbsp;v{$app['_human_current']}</span>
\t\t\t\t\t{$app['app_description']}
\t\t\t\t</td>
\t\t\t\t<td class='center'>{$app['_tab_restricted']}</td>
\t\t\t\t<td class='center'>{$app['_updated']}</td>
\t\t\t\t<td class='col_buttons'>
\t\t\t\t\t<ul class='ipsControlStrip'>
EOF;
                if (!in_array($app['app_directory'], array('core', 'forums', 'members'))) {
                    $IPBHTML .= <<<EOF
\t\t\t\t\t\t<li class='i_disable'><a href='{$this->settings['base_url']}{$this->form_code}do=toggle_app&amp;app_id={$app['app_id']}' title='{$this->lang->words['a_disable_app']}'>{$this->lang->words['a_disable_app']}</a></li>
EOF;
                }
                $IPBHTML .= <<<EOF
\t\t\t\t\t\t<li class='i_edit'><a href='{$this->settings['base_url']}{$this->form_code}do=application_edit&amp;app_id={$app['app_id']}' title='{$this->lang->words['a_editapp_details']}'>{$this->lang->words['a_editapp_details']}</a></li>
\t\t\t\t\t\t<li class='ipsControlStrip_more ipbmenu' id='menu_{$app['app_id']}'><a href='#'>{$this->lang->words['more']}</a></li>
\t\t\t\t\t</ul>
\t\t\t\t\t
\t\t\t\t\t<ul class='acp-menu' id='menu_{$app['app_id']}_menucontent' style='display: none'>
\t\t\t\t\t\t<li class='icon view'><a href='{$this->settings['base_url']}{$this->form_code}do=application_details&amp;app_id={$app['app_id']}'>{$this->lang->words['a_viewhook']}</a></li>
\t\t\t\t\t\t<li class='icon manage'><a href='{$this->settings['base_url']}{$this->form_code}&amp;do=modules_overview&amp;app_id={$app['app_id']}&amp;sys_module_admin=1'>{$this->lang->words['a_manageadmin']}</a></li>
\t\t\t\t\t\t<li class='icon manage'><a href='{$this->settings['base_url']}{$this->form_code}&amp;do=modules_overview&amp;app_id={$app['app_id']}&amp;sys_module_admin=0'>{$this->lang->words['a_managepublic']}</a></li>
EOF;
                if ($app['app_protected'] != 1 or IN_DEV) {
                    $IPBHTML .= <<<EOF
\t\t\t\t\t\t<li class='icon delete'><a href='{$this->settings['base_url']}{$this->form_code}do=application_remove_splash&amp;app_id={$app['app_id']}'>{$this->lang->words['a_removeapp']}</a></li>
EOF;
                }
                $IPBHTML .= <<<EOF
\t\t\t\t\t</ul>
\t\t\t\t</td>
\t\t\t</tr>
EOF;
            }
        } else {
            $IPBHTML .= <<<EOF
\t\t\t\t<tr>
\t\t\t\t\t<td colspan='4' class='no_messages'>{$this->lang->words['a_noapps_enabled']}</td>
\t\t\t\t</tr>
EOF;
        }
        $IPBHTML .= <<<EOF
\t\t\t</table>
\t\t</div>
\t\t<script type='text/javascript'>
\t\t\tjQ("#apps_enabled").ipsSortable( 'table', { 
\t\t\t\turl: "{$this->settings['base_url']}{$this->form_code_js}do=application_manage_position&md5check={$this->registry->adminFunctions->getSecurityKey()}".replace( /&amp;/g, '&' ),
\t\t\t\tserializeOptions: { key: 'apps[]' }
\t\t\t} );
\t\t</script>
\t\t
\t\t<div id='tab_appsDisabled_content'>
\t\t\t<table class='ipsTable'>
\t\t\t\t<tr>
\t\t\t\t\t<th width='1%'>&nbsp;</th>
\t\t\t\t\t<th width='1%'>&nbsp;</th>
\t\t\t\t\t<th width='55%'>{$this->lang->words['a_hookapp']}</th>
\t\t\t\t\t<th width='15%' class='center'>{$this->lang->words['app_tab_permissions']}</th>
\t\t\t\t\t<th width='20%' class='center'>{$this->lang->words['a_lastupdated']}</th>
\t\t\t\t\t<th class='col_buttons'>&nbsp;</th>
\t\t\t\t</tr>
EOF;
        if (count($applications['disabled'])) {
            foreach ($applications['disabled'] as $app) {
                $img = is_file(IPSLib::getAppDir($app['app_directory']) . '/skin_cp/appIcon.png') ? $this->settings['base_acp_url'] . '/' . IPSLib::getAppFolder($app['app_directory']) . '/' . $app['app_directory'] . '/skin_cp/appIcon.png' : "{$this->settings['skin_acp_url']}/images/applications/{$app['app_directory']}.png";
                # IPS app?
                $app['titlePrefix'] = in_array($app['app_location'], array('root', 'ips')) ? "<span class='ipsBadge badge_purple'>{$this->lang->words['gl_ipsapp']}</span>&nbsp;&nbsp;" : '';
                # Sort title
                $app['app_title'] = IN_DEV ? "<a href='{$this->settings['base_url']}{$this->form_code}do=application_edit&amp;app_id={$app['app_id']}'>{$app['app_title']}</a>" : $app['app_title'];
                $app['app_description'] = $app['app_description'] ? "<br /><span class='desctext'>{$app['app_description']}</span>" : '';
                # Tab Restrictions
                $app['_tab_restricted'] = $app['app_hide_tab'] || IPSText::cleanPermString($app['app_tab_groups']) ? "<a href='{$this->settings['base_url']}{$this->form_code}do=application_edit&amp;app_id={$app['app_id']}&amp;_tab=restrictions' title='{$this->lang->words['a_edit_restrictions']}'><img src='{$this->settings['skin_acp_url']}/images/icons/tick.png' alt='' /></a>" : '';
                # Update available?
                if ($app['app_update_available'][0]) {
                    $_update = "<span class='ipsBadge badge_purple'>{$this->lang->words['hook_update_available']}</span>";
                    if (!empty($app['app_update_available'][1])) {
                        $_update = "<a href='{$app['app_update_available'][1]}' target='_blank'>{$_update}</a>";
                    } elseif ($app['app_website']) {
                        $_update = "<a href='{$app['app_website']}' target='_blank'>{$_update}</a>";
                    }
                    $app['_updated'] = $_update;
                } elseif (isset($app['_long_version']) && $app['_long_version'] > $app['_long_current']) {
                    $app['_updated'] = "<a href='{$this->settings['board_url']}/" . CP_DIRECTORY . "/upgrade/' class='ipsBadge badge_green'>{$this->lang->words['a_upgradeavail']}</a>";
                } else {
                    $app['_updated'] = "<span class='desctext'>{$this->lang->words['a_oh_kay']}</span>";
                }
                $IPBHTML .= <<<EOF
\t\t\t<tr class='ipsControlRow'>
\t\t\t\t<td>&nbsp;</td>
\t\t\t\t<td>
\t\t\t\t\t<img src='{$img}' alt='' />
\t\t\t\t</td>
\t\t\t\t<td>
\t\t\t\t\t<strong><span class='larger_text'>{$app['titlePrefix']}{$app['app_title']}</span></strong><span class='desctext'>&nbsp;&nbsp;v{$app['_human_current']}</span>
\t\t\t\t\t{$app['app_description']}
\t\t\t\t</td>
\t\t\t\t<td class='center'>{$app['_tab_restricted']}</td>
\t\t\t\t<td class='center'>{$app['_updated']}</td>
\t\t\t\t<td class='col_buttons'>
\t\t\t\t\t<ul class='ipsControlStrip'>
\t\t\t\t\t\t<li class='i_add'><a href='{$this->settings['base_url']}{$this->form_code}do=toggle_app&amp;app_id={$app['app_id']}' title='{$this->lang->words['a_enable_app']}'>{$this->lang->words['a_enable_app']}</a></li>
\t\t\t\t\t\t<li class='i_edit'><a href='{$this->settings['base_url']}{$this->form_code}do=application_edit&amp;app_id={$app['app_id']}' title='{$this->lang->words['a_editapp_details']}'>{$this->lang->words['a_editapp_details']}</a></li>
\t\t\t\t\t\t<li class='ipsControlStrip_more ipbmenu' id='menu_{$app['app_id']}'><a href='#'>{$this->lang->words['more']}</a></li>
\t\t\t\t\t</ul>
\t\t\t\t\t
\t\t\t\t\t<ul class='acp-menu' id='menu_{$app['app_id']}_menucontent' style='display: none'>
\t\t\t\t\t\t<li class='icon view'><a href='{$this->settings['base_url']}{$this->form_code}do=application_details&amp;app_id={$app['app_id']}'>{$this->lang->words['a_viewhook']}</a></li>
\t\t\t\t\t\t<li class='icon manage'><a href='{$this->settings['base_url']}{$this->form_code}&amp;do=modules_overview&amp;app_id={$app['app_id']}&amp;sys_module_admin=1'>{$this->lang->words['a_manageadmin']}</a></li>
\t\t\t\t\t\t<li class='icon manage'><a href='{$this->settings['base_url']}{$this->form_code}&amp;do=modules_overview&amp;app_id={$app['app_id']}&amp;sys_module_admin=0'>{$this->lang->words['a_managepublic']}</a></li>
EOF;
                if ($app['app_protected'] != 1 or IN_DEV) {
                    $IPBHTML .= <<<EOF
\t\t\t\t\t\t<li class='icon delete'><a href='{$this->settings['base_url']}{$this->form_code}do=application_remove_splash&amp;app_id={$app['app_id']}'>{$this->lang->words['a_removeapp']}</a></li>
EOF;
                }
                $IPBHTML .= <<<EOF
\t\t\t\t\t</ul>
\t\t\t\t</td>
\t\t\t</tr>
EOF;
            }
        } else {
            $IPBHTML .= <<<EOF
\t\t\t\t<tr>
\t\t\t\t\t<td colspan='4' class='no_messages'>{$this->lang->words['a_noapps_disabled']}</td>
\t\t\t\t</tr>
EOF;
        }
        $IPBHTML .= <<<EOF
\t\t\t</table>
\t\t</div>
\t\t
\t</div>
</div>
<script type='text/javascript'>
\tjQ("#tabstrip_appsList").ipsTabBar({ tabWrap: "#tabstrip_appsList_content" });
</script>

<!-- RIGHT SIDEBAR -->
<div class='right' style='width: 30%'>
EOF;
        if (is_array($uninstalled) and count($uninstalled)) {
            $IPBHTML .= <<<EOF
\t<div class='acp-box'>
\t\t<h3>{$this->lang->words['a_unapps']}</h3>
\t \t<table class='ipsTable'>
EOF;
            foreach ($uninstalled as $app) {
                if (strstr($app['path'], 'applications_addon/ips')) {
                    $app['_location'] = 'ips';
                    $img = "<img src='{$this->settings['skin_acp_url']}/images/icons/medal.png' title='{$this->lang->words['a_officialapp']}' />";
                } else {
                    if (strstr($app['path'], 'applications_addon/other')) {
                        $app['_location'] = 'other';
                        $img = '';
                    } else {
                        $app['_location'] = 'root';
                        $img = "<img src='{$this->settings['skin_acp_url']}/images/icons/medal.png' title='{$this->lang->words['a_officialapp']}' />";
                    }
                }
                if ($app['okToGo']) {
                    $warning = '';
                    $install = <<<EOF
\t\t<a href='{$this->settings['base_url']}module=applications&amp;section=setup&amp;do=install&amp;app_directory={$app['directory']}&amp;app_location={$app['_location']}' class='ipsBadge badge_purple'>{$this->lang->words['a_install']}</a>
EOF;
                } else {
                    $install = "<span class='ipsBadge badge_grey'>{$this->lang->words['a_cannotinstall']}</span>";
                    $warning = <<<EOF
\t\t\t\t<br /><span style='color: red'>{$this->lang->words['a_cantinstall_info']}</span>
EOF;
                }
                $install = $canInstall ? $install : '';
                $IPBHTML .= <<<EOF
\t<tr>
\t\t<td style='width: 16px; padding: 10px 0 10px 6px; text-align: center; vertical-align: top'>
\t\t\t{$img}
\t\t</td>
\t\t<td>
\t\t\t<strong>{$app['title']}</strong><br />
\t\t\t<span class='desctext'>{$app['author']}</span>
\t\t\t{$warning}
\t\t</td>
\t\t<td style='width: 20%'>
\t\t\t{$install}
\t\t</td>
\t</tr>
EOF;
            }
            $IPBHTML .= <<<EOF
\t </table>
\t</div>
EOF;
        }
        if (!IPSLib::appIsInstalled('nexus', false) and !isset($uninstalled['nexus']) or !IPSLib::appIsInstalled('blog', false) and !isset($uninstalled['blog']) or !IPSLib::appIsInstalled('gallery', false) and !isset($uninstalled['gallery']) or !IPSLib::appIsInstalled('ccs', false) and !isset($uninstalled['ccs']) or !IPSLib::appIsInstalled('downloads', false) and !isset($uninstalled['downloads']) or !$this->settings['ips_cp_purchase']) {
            $IPBHTML .= <<<EOF
\t<br />
\t<div class='acp-box'>
\t\t<table class='ipsTable'>
EOF;
            foreach (array('nexus', 'blog', 'gallery', 'ccs', 'downloads') as $__app) {
                if (!IPSLib::appIsInstalled($__app, false) and !isset($uninstalled[$__app])) {
                    $_app_name = $__app == 'ccs' ? 'Content' : ucfirst($__app);
                    $IPBHTML .= <<<EOF
\t\t\t<tr>
\t\t\t\t<td style='width: 16px;'>
\t\t\t\t\t<img src='{$this->settings['skin_acp_url']}/images/icon_components/{$__app}.png' alt='' />
\t\t\t\t</td>
\t\t\t\t<td>
\t\t\t\t\t<a href='{$this->settings['base_url']}module=applications&amp;section={$__app}'>IP.{$_app_name}</a>
\t\t\t\t</td>
\t\t\t</tr>
EOF;
                }
            }
            if (!$this->settings['ips_cp_purchase']) {
                $IPBHTML .= <<<EOF
\t\t\t<tr>
\t\t\t\t<td style='width: 16px'>
\t\t\t\t\t<img src='{$this->settings['skin_acp_url']}/images/icons/package.png' alt='' />
\t\t\t\t</td>
\t\t\t\t<td>
\t\t\t\t\t<a href='{$this->settings['base_url']}module=applications&amp;section=copyright'>Copyright Removal</a>
\t\t\t\t</td>
\t\t\t</tr>
EOF;
            }
            $IPBHTML .= <<<EOF
\t\t</table>
\t</div>
EOF;
        }
        $IPBHTML .= <<<EOF
</div>
EOF;
        //--endhtml--//
        return $IPBHTML;
    }
コード例 #18
0
ファイル: rsvp.php プロジェクト: mover5/imobackup
 /**
  * Class entry point
  *
  * @access	public
  * @param	object		Registry reference
  * @return	@e void		[Outputs to screen/redirects]
  */
 public function doExecute(ipsRegistry $registry)
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $event_id = intval($this->request['event_id']);
     $this->registry->class_localization->loadLanguageFile(array('public_calendar'));
     //-----------------------------------------
     // Functions class
     //-----------------------------------------
     $classToLoad = IPSLib::loadLibrary(IPSLib::getAppDir('calendar') . "/sources/functions.php", 'app_calendar_classes_functions', 'calendar');
     $functions = new $classToLoad($this->registry);
     //-----------------------------------------
     // Get data
     //-----------------------------------------
     if (!$event_id) {
         $this->returnJsonError($this->lang->words['rsvp__no_event']);
     }
     $event = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'cal_events', 'where' => 'event_id=' . $event_id));
     if (!$event['event_id']) {
         $this->returnJsonError($this->lang->words['rsvp__no_event']);
     }
     //-----------------------------------------
     // Check permissions
     //-----------------------------------------
     if (!$event['event_approved']) {
         $this->returnJsonError($this->lang->words['rsvp__no_event']);
     }
     if ($event['event_private']) {
         if (!$this->memberData['member_id'] or $this->memberData['member_id'] != $event['event_member_id']) {
             $this->returnJsonError($this->lang->words['rsvp__no_event']);
         }
     }
     if ($event['event_perms'] != '*') {
         $permissionGroups = explode(',', IPSText::cleanPermString($event['event_perms']));
         if (!IPSMember::isInGroup($this->memberData, $permissionGroups)) {
             $this->returnJsonError($this->lang->words['rsvp__no_event']);
         }
     }
     //-----------------------------------------
     // Get our calendar
     //-----------------------------------------
     $calendar = $functions->getCalendar($event['event_calendar_id']);
     if (!$calendar['cal_id'] or $calendar['cal_id'] != $event['event_calendar_id']) {
         $this->returnJsonError($this->lang->words['rsvp__no_event']);
     }
     //-----------------------------------------
     // Can we RSVP?
     //-----------------------------------------
     $_can_rsvp = ($this->memberData['member_id'] and $this->registry->permissions->check('rsvp', $calendar) and $event['event_rsvp']) ? 1 : 0;
     if (!$_can_rsvp) {
         $this->returnJsonError($this->lang->words['rsvp__no_perm']);
     }
     //-----------------------------------------
     // Have we already RSVP?
     //-----------------------------------------
     $_check = $this->DB->buildAndFetch(array('select' => 'rsvp_id', 'from' => 'cal_event_rsvp', 'where' => 'rsvp_event_id=' . $event['event_id'] . ' AND rsvp_member_id=' . $this->memberData['member_id']));
     if ($_check['rsvp_id']) {
         $this->returnJsonError($this->lang->words['rsvp__already_rsvp']);
     }
     //-----------------------------------------
     // Store RSVP
     //-----------------------------------------
     $_insert = array('rsvp_event_id' => $event['event_id'], 'rsvp_member_id' => $this->memberData['member_id'], 'rsvp_date' => time());
     $this->DB->insert('cal_event_rsvp', $_insert);
     $rsvp_id = $this->DB->getInsertId();
     $this->returnJsonArray(array('html' => $this->registry->output->getTemplate('calendar')->eventAttendee(array_merge(array('rsvp_id' => $rsvp_id, 'rsvp_date' => time()), $this->memberData), $event)));
 }
コード例 #19
0
 /**
  * Check permissions for "can report"
  *
  * @param	string	$className	Report center class name
  * @return	@e bool
  */
 public function canReport($className)
 {
     if (!$this->caches['report_plugins'][$className]['com_id']) {
         return false;
     }
     if (IPSMember::isInGroup($this->memberData, explode(',', IPSText::cleanPermString($this->caches['report_plugins'][$className]['group_can_report'])))) {
         return true;
     }
     return false;
 }
コード例 #20
0
 /**
  * Edit a member [process]
  *
  * @access	private
  * @return	void		[Outputs to screen]
  */
 private function _memberDoEdit()
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $this->request['member_id'] = intval($this->request['member_id']);
     //-----------------------------------------
     // Auth check...
     //-----------------------------------------
     ipsRegistry::getClass('adminFunctions')->checkSecurityKey($this->request['secure_key']);
     //-----------------------------------------
     // Load and config the std/rte editors
     //-----------------------------------------
     IPSText::getTextClass('editor')->from_acp = 1;
     //-----------------------------------------
     // Get member
     //-----------------------------------------
     $member = IPSMember::load($this->request['member_id'], 'all');
     //-----------------------------------------
     // Allowed to edit administrators?
     //-----------------------------------------
     if ($member['member_id'] != $this->memberData['member_id'] and $member['g_access_cp'] and !$this->registry->getClass('class_permissions')->checkPermission('member_edit_admin')) {
         $this->registry->output->global_message = $this->lang->words['m_editadmin'];
         $this->_memberView();
         return;
     }
     //-----------------------------------------
     // Allowed to change an admin's groups?
     //-----------------------------------------
     if ($member['g_access_cp'] and !$this->registry->getClass('class_permissions')->checkPermission('member_move_admin1')) {
         $same = false;
         if ($this->request['member_group_id'] == $member['member_group_id']) {
             $omgroups = explode(',', IPSText::cleanPermString($member['mgroup_others']));
             $groups = $_POST['mgroup_others'] ? $_POST['mgroup_others'] : array();
             if (!count(array_diff($omgroups, $groups))) {
                 $same = true;
             }
         }
         if (!$same) {
             $this->registry->output->global_message = $this->lang->words['m_admindemote'];
             $this->_memberView();
             return;
         }
     }
     //-----------------------------------------
     // What about promoting to admin?
     //-----------------------------------------
     if (!$member['g_access_cp'] and !$this->registry->getClass('class_permissions')->checkPermission('member_move_admin2')) {
         $groups = $_POST['mgroup_others'] ? $_POST['mgroup_others'] : array();
         $groups[] = intval($this->request['member_group_id']);
         foreach ($groups as $group_id) {
             if ($this->caches['group_cache'][$group_id]['g_access_cp']) {
                 $this->registry->output->global_message = $this->lang->words['m_adminpromote'];
                 $this->_memberView();
                 return;
             }
         }
     }
     if ($this->request['identity_url']) {
         $account = $this->DB->buildAndFetch(array('select' => 'member_id', 'from' => 'members', 'where' => "identity_url='" . trim($this->request['identity_url']) . "' AND member_id<>" . $member['member_id']));
         if ($account['member_id']) {
             $this->registry->output->global_message = $this->lang->words['identity_url_inuse'];
             $this->_memberView();
             return;
         }
     }
     //-----------------------------------------
     // Convert sig
     //-----------------------------------------
     $signature = IPSText::getTextClass('editor')->processRawPost('signature');
     IPSText::getTextClass('bbcode')->parse_smilies = 0;
     IPSText::getTextClass('bbcode')->parse_bbcode = $this->settings['sig_allow_ibc'];
     IPSText::getTextClass('bbcode')->parse_html = $this->settings['sig_allow_html'];
     IPSText::getTextClass('bbcode')->parse_nl2br = 1;
     IPSText::getTextClass('bbcode')->parsing_section = 'signatures';
     $signature = IPSText::getTextClass('bbcode')->preDbParse($signature);
     $cacheSignature = IPSText::getTextClass('bbcode')->preDisplayParse($signature);
     //-----------------------------------------
     // And 'About Me'
     //-----------------------------------------
     $aboutme = IPSText::getTextClass('editor')->processRawPost('aboutme');
     IPSText::getTextClass('bbcode')->parse_smilies = $this->settings['aboutme_emoticons'];
     IPSText::getTextClass('bbcode')->parse_bbcode = $this->settings['aboutme_bbcode'];
     IPSText::getTextClass('bbcode')->parse_html = $this->settings['aboutme_html'];
     IPSText::getTextClass('bbcode')->parse_nl2br = 1;
     IPSText::getTextClass('bbcode')->parsing_section = 'aboutme';
     $aboutme = IPSText::getTextClass('bbcode')->preDbParse($aboutme);
     //-----------------------------------------
     // Ok? Load interface and child classes
     //-----------------------------------------
     $additionalCore = array();
     $additionalExtended = array();
     IPSLib::loadInterface('admin/member_form.php');
     foreach (ipsRegistry::$applications as $app_dir => $app_data) {
         if (!IPSLib::appIsInstalled($app_dir)) {
             continue;
         }
         if (file_exists(IPSLib::getAppDir($app_dir) . '/extensions/admin/member_form.php')) {
             require_once IPSLib::getAppDir($app_dir) . '/extensions/admin/member_form.php';
             $_class = 'admin_member_form__' . $app_dir;
             $_object = new $_class($this->registry);
             $remote = $_object->getForSave();
             $additionalCore = array_merge($remote['core'], $additionalCore);
             $additionalExtended = array_merge($remote['extendedProfile'], $additionalExtended);
         }
     }
     //-----------------------------------------
     // Fix custom title
     // @see	http://forums./index.php?app=tracker&showissue=17383
     //-----------------------------------------
     $memberTitle = $this->request['title'];
     $rankCache = ipsRegistry::cache()->getCache('ranks');
     if (is_array($rankCache) && count($rankCache)) {
         foreach ($rankCache as $k => $v) {
             if ($member['posts'] >= $v['POSTS']) {
                 /* If this is the title passed to us from the form, we didn't have a custom title */
                 if ($v['TITLE'] == $memberTitle) {
                     $memberTitle = '';
                 }
                 break;
             }
         }
     }
     $newMember = array('member_group_id' => intval($this->request['member_group_id']), 'title' => $memberTitle, 'time_offset' => floatval($this->request['time_offset']), 'language' => $this->request['language'], 'skin' => intval($this->request['skin']), 'hide_email' => intval($this->request['hide_email']), 'allow_admin_mails' => intval($this->request['allow_admin_mails']), 'view_sigs' => intval($this->request['view_sigs']), 'view_pop' => intval($this->request['view_pop']), 'email_pm' => intval($this->request['email_pm']), 'posts' => intval($this->request['posts']), 'bday_day' => intval($this->request['bday_day']), 'bday_month' => intval($this->request['bday_month']), 'bday_year' => intval($this->request['bday_year']), 'warn_level' => intval($this->request['warn_level']), 'members_disable_pm' => intval($this->request['members_disable_pm']), 'mgroup_others' => $_POST['mgroup_others'] ? ',' . implode(",", $_POST['mgroup_others']) . ',' : '', 'identity_url' => trim($this->request['identity_url']));
     //-----------------------------------------
     // Throw to the DB
     //-----------------------------------------
     IPSMember::save($this->request['member_id'], array('core' => array_merge($newMember, $additionalCore), 'extendedProfile' => array_merge(array('pp_gender' => $this->request['pp_gender'] == 'male' ? 'male' : ($this->request['pp_gender'] == 'female' ? 'female' : ''), 'pp_bio_content' => IPSText::mbsubstr(nl2br($this->request['pp_bio_content']), 0, 300), 'pp_about_me' => $aboutme, 'signature' => $signature, 'pp_reputation_points' => intval($this->request['pp_reputation_points']), 'pp_status' => $this->request['pp_status'], 'pp_setting_count_visitors' => intval($this->request['pp_setting_count_visitors']), 'pp_setting_count_comments' => intval($this->request['pp_setting_count_comments']), 'pp_setting_count_friends' => intval($this->request['pp_setting_count_friends']), 'pp_setting_notify_comments' => $this->request['pp_setting_notify_comments'], 'pp_setting_notify_friend' => $this->request['pp_setting_notify_friend'], 'pp_setting_moderate_comments' => intval($this->request['pp_setting_moderate_comments']), 'pp_setting_moderate_friends' => intval($this->request['pp_setting_moderate_friends'])), $additionalExtended)));
     if ($member['member_group_id'] != $newMember['member_group_id']) {
         IPSLib::runMemberSync('onGroupChange', $this->request['member_id'], $newMember['member_group_id']);
         //-----------------------------------------
         // Remove restrictions if member demoted
         // Commenting out as this may cause more problems than it's worth
         // e.g. if you had accidentally changed their group, you'd need to reconfigure all restrictions
         //-----------------------------------------
         /*if( !$this->caches['group_cache'][ $newMember['member_group_id'] ]['g_access_cp'] )
         		{
         			$this->DB->delete( 'admin_permission_rows', 'row_id=' . $member['member_id'] . " AND row_id_type='member'" );
         		}*/
     }
     //-----------------------------------------
     // Restriction permissions stuff
     //-----------------------------------------
     if (is_array($this->registry->getClass('class_permissions')->restrictions_row) and count($this->registry->getClass('class_permissions')->restrictions_row)) {
         $is_admin = 0;
         $groups = ipsRegistry::cache()->getCache('group_cache');
         if (is_array($this->request['mgroup_others']) and count($this->request['mgroup_others'])) {
             foreach ($this->request['mgroup_others'] as $omg) {
                 if ($groups[intval($omg)]['g_access_cp']) {
                     $is_admin = 1;
                     break;
                 }
             }
         }
         if ($groups[intval($this->request['member_group_id'])]['g_access_cp']) {
             $is_admin = 1;
         }
         if ($is_admin) {
             //-------------------------------------------------
             // Copy restrictions if they do not have any yet...
             //-------------------------------------------------
             $check = $this->DB->buildAndFetch(array('select' => 'row_updated', 'from' => 'admin_permission_rows', 'where' => "row_id_type='member' AND row_id=" . $this->request['member_id']));
             if (!$check['row_updated']) {
                 $this->DB->replace('admin_permission_rows', array('row_id' => $this->request['member_id'], 'row_id_type' => 'member', 'row_perm_cache' => serialize($this->registry->getClass('class_permissions')->restrictions_row), 'row_updated' => time()), array('row_id', 'row_id_type'));
             }
         }
     }
     //-----------------------------------------
     // Moved from validating group?
     //-----------------------------------------
     if ($member['member_group_id'] == $this->settings['auth_group']) {
         if ($this->request['member_group_id'] != $this->settings['auth_group']) {
             //-----------------------------------------
             // Yes...
             //-----------------------------------------
             $this->DB->delete('validating', "member_id=" . $this->request['member_id']);
         }
     }
     //-----------------------------------------
     // Custom profile field stuff
     //-----------------------------------------
     require_once IPS_ROOT_PATH . 'sources/classes/customfields/profileFields.php';
     $fields = new customProfileFields();
     $fields->initData('edit');
     $fields->parseToSave($_POST);
     //-----------------------------------------
     // Custom profile field stuff
     //-----------------------------------------
     if (count($fields->out_fields)) {
         //-----------------------------------------
         // Do we already have an entry in
         // the content table?
         //-----------------------------------------
         $test = $this->DB->buildAndFetch(array('select' => 'member_id', 'from' => 'pfields_content', 'where' => 'member_id=' . $this->request['member_id']));
         if ($test['member_id']) {
             //-----------------------------------------
             // We have it, so simply update
             //-----------------------------------------
             $this->DB->force_data_type = array();
             foreach ($fields->out_fields as $_field => $_data) {
                 $this->DB->force_data_type[$_field] = 'string';
             }
             $this->DB->update('pfields_content', $fields->out_fields, 'member_id=' . $this->request['member_id']);
         } else {
             $this->DB->force_data_type = array();
             foreach ($fields->out_fields as $_field => $_data) {
                 $this->DB->force_data_type[$_field] = 'string';
             }
             $fields->out_fields['member_id'] = $this->request['member_id'];
             $this->DB->insert('pfields_content', $fields->out_fields);
         }
     }
     /* Update cache */
     IPSContentCache::update($this->request['member_id'], 'sig', $cacheSignature);
     //-----------------------------------------
     // Redirect
     //-----------------------------------------
     ipsRegistry::getClass('adminFunctions')->saveAdminLog(sprintf($this->lang->words['m_editedlog'], $member['members_display_name']));
     $this->registry->output->global_message = $this->lang->words['m_edited'];
     $newMember['member_id'] = $this->request['member_id'];
     $newMember['members_display_name'] = $member['members_display_name'];
     $triggerGroups = $member['mgroup_others'] ? implode(',', array_merge(is_array($member['mgroup_others']) ? $member['mgroup_others'] : array(), array($member['member_group_id']))) : $member['member_group_id'];
     //$this->_memberView();
     $this->registry->output->silentRedirectWithMessage($this->settings['base_url'] . $this->form_code . '&do=viewmember&trigger=' . $triggerGroups . '&member_id=' . $this->request['member_id']);
 }
コード例 #21
0
ファイル: hooks.php プロジェクト: mover5/imobackup
 /**
  * Retrieve upcoming events
  *
  * @return	string
  */
 public function getUpcomingEvents()
 {
     //-----------------------------------------
     // Make sure calendar app is installed
     //-----------------------------------------
     if (!$this->settings['show_calendar'] or !IPSLib::appIsInstalled('calendar')) {
         return '';
     }
     //-----------------------------------------
     // Get current date data
     //-----------------------------------------
     $a = explode(',', gmdate('Y,n,j,G,i,s', time() + $this->registry->class_localization->getTimeOffset()));
     $day = $a[2];
     $month = $a[1];
     $year = $a[0];
     //-----------------------------------------
     // Check calendar limit
     //-----------------------------------------
     $this->settings['calendar_limit'] = intval($this->settings['calendar_limit']) < 2 ? 1 : intval($this->settings['calendar_limit']);
     $our_unix = gmmktime(0, 0, 0, $month, $day, $year);
     $max_date = $our_unix + $this->settings['calendar_limit'] * 86400;
     $events = array();
     $show_events = array();
     //-----------------------------------------
     // Loop over the cache
     //-----------------------------------------
     if (is_array($this->caches['calendar_events']) and count($this->caches['calendar_events'])) {
         foreach ($this->caches['calendar_events'] as $u) {
             //-----------------------------------------
             // Private?
             //-----------------------------------------
             if ($u['event_private'] == 1 and $this->memberData['member_id'] != $u['event_member_id']) {
                 continue;
             }
             //-----------------------------------------
             // Got perms?
             //-----------------------------------------
             if ($u['event_perms'] != '*') {
                 $permissionGroups = explode(',', IPSText::cleanPermString($u['event_perms']));
                 if (!IPSMember::isInGroup($this->memberData, $permissionGroups)) {
                     continue;
                 }
             }
             //-----------------------------------------
             // Got calendar perms?
             //-----------------------------------------
             if (!$this->registry->permissions->check('view', $u)) {
                 continue;
             }
             //-----------------------------------------
             // Times and dates
             //-----------------------------------------
             $u['isoDate'] = gmdate('c', strtotime($u['event_start_date']));
             $u['_start_time'] = strtotime($u['event_start_date']);
             $u['_end_time'] = ($u['event_end_date'] and $u['event_end_date'] != '0000-00-00 00:00:00') ? strtotime($u['event_end_date']) : 0;
             if (!$u['event_all_day']) {
                 if ($this->memberData['member_id'] and $this->memberData['time_offset']) {
                     $u['_start_time'] = $u['_start_time'] + $this->memberData['time_offset'] * 3600;
                 } else {
                     if (!$this->memberData['member_id'] and $this->settings['time_offset']) {
                         $u['_start_time'] = $u['_start_time'] + $this->settings['time_offset'] * 3600;
                     }
                 }
                 if ($this->memberData['member_id'] and $this->memberData['time_offset']) {
                     $u['_end_time'] = $u['_end_time'] ? $u['_end_time'] + $this->memberData['time_offset'] * 3600 : 0;
                 } else {
                     if (!$this->memberData['member_id'] and $this->settings['time_offset']) {
                         $u['_end_time'] = $u['_end_time'] ? $u['_end_time'] + $this->settings['time_offset'] * 3600 : 0;
                     }
                 }
             }
             //-----------------------------------------
             // In range?
             //-----------------------------------------
             if (!$u['event_recurring'] and ($u['_end_time'] >= $our_unix and $u['_start_time'] <= $max_date or !$u['_end_time'] and $u['_start_time'] >= $our_unix and $u['_start_time'] <= $max_date)) {
                 if ($u['_end_time']) {
                     if ($u['_start_time'] < gmmktime(0)) {
                         $u['_start_time'] = gmmktime(0);
                     }
                 }
                 $events[str_pad($u['_start_time'] . $u['event_id'], 15, "0")] = $u;
             } elseif ($u['event_recurring'] > 0) {
                 $cust_range_s = $u['_start_time'];
                 while ($cust_range_s <= $u['_end_time']) {
                     if ($cust_range_s >= $our_unix and $cust_range_s <= $max_date) {
                         //-----------------------------------------
                         // Special case for "monthly" to ensure it lands on the same day
                         //-----------------------------------------
                         if ($u['event_recurring'] != 1) {
                             $u['_start_time'] = gmmktime(1, 1, 1, gmdate('n', $cust_range_s), gmdate('j', $u['_start_time']), gmdate('Y', $cust_range_s));
                         } else {
                             $u['_start_time'] = $cust_range_s;
                         }
                         $events[str_pad($u['_start_time'] . $u['event_id'], 15, "0")] = $u;
                     }
                     if ($u['event_recurring'] == 1) {
                         $cust_range_s += 604800;
                     } elseif ($u['event_recurring'] == 2) {
                         $cust_range_s += 2628000;
                     } else {
                         $cust_range_s += 31536000;
                     }
                 }
             }
         }
     }
     //-----------------------------------------
     // Sort and format
     //-----------------------------------------
     ksort($events);
     foreach ($events as $event) {
         //-----------------------------------------
         // Recurring?
         //-----------------------------------------
         $c_time = gmstrftime('%x', $event['_start_time']);
         $url = $this->registry->output->buildSEOUrl("app=calendar&amp;module=calendar&amp;section=view&amp;do=showevent&amp;event_id={$event['event_id']}", 'public', $event['event_title_seo'], 'cal_event');
         $show_events[] = array('url' => $url, 'isoDate' => $event['isoDate'], 'date' => $c_time, 'title' => $event['event_title'], 'calendar' => $this->caches['calendars'][$event['event_calendar_id']]);
     }
     //-----------------------------------------
     // Send output to template and return HTML
     //-----------------------------------------
     $this->lang->words['calender_f_title'] = sprintf($this->lang->words['calender_f_title'], $this->settings['calendar_limit']);
     if (count($show_events) > 0) {
         $event_string = $show_events;
     } else {
         if (!$this->settings['autohide_calendar']) {
             $event_string = $this->lang->words['no_calendar_events'];
         }
     }
     return $this->registry->output->getTemplate('calendar')->boardIndexCalEvents($event_string);
 }
コード例 #22
0
ファイル: reports.php プロジェクト: Advanture/Online-RolePlay
 /**
  * Post save
  * Accepts an array of GENERIC data and allows manipulation after it's added to DB
  *
  * @param	string	Type of action (edit/add)
  * @param	array	Array of GENERIC data (comment_xxxx)
  * @param	int		Comment id (if available)
  * @param	int		Parent id
  * @return 	array	Array of GENERIC data
  */
 public function postSave($type, array $array, $commentId = 0, $parentId = 0)
 {
     $_cnt = $this->DB->buildAndFetch(array('select' => 'count(*) as total', 'from' => 'rc_comments', 'where' => 'rid=' . $parentId));
     $this->DB->update('rc_reports_index', array('num_comments' => intval($_cnt['total']), 'date_updated' => IPS_UNIX_TIME_NOW, 'updated_by' => $this->memberData['member_id']), "id=" . $parentId);
     $report = $this->fetchParent($parentId);
     //-----------------------------------------
     // Notify other moderators
     //-----------------------------------------
     if ($type == 'add') {
         $this->registry->class_localization->loadLanguageFile(array('public_reports'));
         $this->DB->loadCacheFile(IPSLib::getAppDir('core') . '/sql/' . ips_DBRegistry::getDriverType() . '_report_queries.php', 'report_sql_queries');
         $classToLoad = IPSLib::loadLibrary(IPSLib::getAppDir('core') . '/sources/classes/reportLibrary.php', 'reportLibrary');
         $this->registry->setClass('reportLibrary', new $classToLoad($this->registry));
         $classToLoad = IPSLib::loadLibrary(IPSLib::getAppDir('core') . '/sources/classes/reportNotifications.php', 'reportNotifications');
         $notify = new $classToLoad($this->registry);
         $this->registry->getClass('reportLibrary')->loadPlugin($report['my_class'], $report['app']);
         if (is_object($this->registry->getClass('reportLibrary')->plugins[$report['my_class']])) {
             if ($report['extra_data'] && $report['extra_data'] != 'N;') {
                 $this->registry->getClass('reportLibrary')->plugins[$report['my_class']]->_extra = unserialize($report['extra_data']);
             } else {
                 $this->registry->getClass('reportLibrary')->plugins[$report['my_class']]->_extra = array();
             }
             $report_data = $this->registry->getClass('reportLibrary')->plugins[$report['my_class']]->formatReportData($report);
             $notify->initNotify($this->registry->getClass('reportLibrary')->plugins[$report['my_class']]->getNotificationList(IPSText::cleanPermString($report['mod_group_perm']), $report_data), $report_data);
             $notify->sendReplyNotifications($array['comment_text']);
         }
     }
     //-----------------------------------------
     // Mark read
     //-----------------------------------------
     $this->registry->classItemMarking->markRead(array('forumID' => 0, 'itemID' => $report['id']), 'core');
     return $array;
 }
コード例 #23
0
 function portalPage($output, $tabs = array(), $_activeNav = array())
 {
     $IPBHTML = "";
     if (IPSLib::locationHasHooks('skin_modcp', $this->_funcHooks['portalPage'])) {
         $count_4b0815a22323ae41fee4cea611d36d08 = is_array($this->functionData['portalPage']) ? count($this->functionData['portalPage']) : 0;
         $this->functionData['portalPage'][$count_4b0815a22323ae41fee4cea611d36d08]['output'] = $output;
         $this->functionData['portalPage'][$count_4b0815a22323ae41fee4cea611d36d08]['tabs'] = $tabs;
         $this->functionData['portalPage'][$count_4b0815a22323ae41fee4cea611d36d08]['_activeNav'] = $_activeNav;
     }
     $IPBHTML .= "<h1 class='ipsType_pagetitle'>{$this->lang->words['modcp_page_title']}</h1>\n<br />\n<div class='ipsBox'>\n\t<div class='ipsVerticalTabbed ipsLayout ipsLayout_withleft ipsLayout_smallleft clearfix'>\n\t\t<div class='ipsVerticalTabbed_tabs ipsLayout_left' id='modcp_tabs'>\n\t\t\t<ul class='clear'>\n\t\t\t\t<li id='index' class='" . ($_activeNav['primary'] == 'index' && $_activeNav['secondary'] == 'index' ? "active " : "") . "tab_toggle'>\n\t\t\t\t\t<a href='" . $this->registry->getClass('output')->formatUrl($this->registry->getClass('output')->buildUrl("app=core&amp;module=modcp", "public", ''), "", "") . "'>{$this->lang->words['modcp_tab_index']}</a>\n\t\t\t\t</li>\n\t\t\t\t" . (IPSMember::isInGroup($this->memberData, explode(',', IPSText::cleanPermString($this->settings['report_mod_group_access']))) ? "<li id='reported_content' class='" . ($_activeNav['primary'] == 'reported_content' && $_activeNav['secondary'] == 'reports' ? "active " : "") . "tab_toggle'>\n\t\t\t\t\t\t<a href='" . $this->registry->getClass('output')->formatUrl($this->registry->getClass('output')->buildUrl("app=core&amp;module=reports&amp;do=index", "public", ''), "", "") . "'>{$this->lang->words['modcp_tab_reports']}</a>\n\t\t\t\t\t</li>" : "") . "\n\t\t\t\t" . $this->__f__6bf8cc55ec9f44287662e825eacb265d($output, $tabs, $_activeNav) . "\t\t\t</ul>\n\t\t</div>\n\t\t<div class='ipsVerticalTabbed_content ipsLayout_content ipsBox_container' id='modcp_content'>\n\t\t\t<div class='ipsPad'>\n\t\t\t\t{$output}\n\t\t\t</div>\n\t\t</div>\n\t</div>\n</div>\n<script type='text/javascript'>\n\t\$(\"modcp_content\").setStyle( { minHeight: \$('modcp_tabs').measure('margin-box-height') + 5 + \"px\" } );\n</script>";
     return $IPBHTML;
 }
コード例 #24
0
ファイル: forums.php プロジェクト: Advanture/Online-RolePlay
 /**
  * Delete a forum
  *
  * @return	@e void		Outputs to screen
  */
 public function doDelete()
 {
     //-----------------------------------------
     // Auth check...
     //-----------------------------------------
     $this->registry->adminFunctions->checkSecurityKey();
     //-----------------------------------------
     // Continue
     //-----------------------------------------
     $this->request['f'] = intval($this->request['f']);
     $this->request['new_parent_id'] = intval($this->request['new_parent_id']);
     $forum = $this->registry->class_forums->forum_by_id[$this->request['f']];
     if (!$forum['id']) {
         $this->registry->output->showError($this->lang->words['for_noid_source'], 11313);
     }
     if (!$this->request['new_parent_id']) {
         $this->request['new_parent_id'] = -1;
     } else {
         if ($this->request['new_parent_id'] == $this->request['f']) {
             $this->registry->output->global_message = $this->lang->words['for_child_no_parent'];
             $this->deleteForm();
             return;
         }
     }
     //-----------------------------------------
     // Would deleting this category orphan the only
     // remaining forums?
     //-----------------------------------------
     if ($forum['parent_id'] == -1) {
         $otherParent = 0;
         foreach ($this->registry->class_forums->forum_by_id as $id => $data) {
             if ($data['parent_id'] == -1) {
                 $otherParent = $id;
                 break;
             }
         }
         if (!$otherParent) {
             $this->registry->output->showError($this->lang->words['nodelete_last_cat'], 11364);
         }
     }
     //-----------------------------------------
     // Get library
     //-----------------------------------------
     $classToLoad = IPSLib::loadLibrary(IPSLib::getAppDir('forums') . '/sources/classes/moderate.php', 'moderatorLibrary', 'forums');
     $modfunc = new $classToLoad($this->registry);
     /* Load tagging stuff */
     if (!$this->registry->isClassLoaded('tags')) {
         require_once IPS_ROOT_PATH . 'sources/classes/tags/bootstrap.php';
         /*noLibHook*/
         $this->registry->setClass('tags', classes_tags_bootstrap::run('forums', 'topics'));
     }
     //-----------------------------------------
     // Move stuff
     //-----------------------------------------
     if (isset($this->request['MOVE_ID'])) {
         $this->request['MOVE_ID'] = intval($this->request['MOVE_ID']);
         if (!$this->request['MOVE_ID']) {
             $this->registry->output->global_error = $this->lang->words['forum_delete_none_selected'];
             $this->deleteForm();
             return;
         }
         if ($this->request['MOVE_ID'] == $this->request['f']) {
             $this->registry->output->global_error = $this->lang->words['for_wherewhatwhy'];
             $this->deleteForm();
             return;
         }
         //-----------------------------------------
         // Move topics...
         //-----------------------------------------
         $this->DB->update('topics', array('forum_id' => $this->request['MOVE_ID']), 'forum_id=' . $this->request['f']);
         //-----------------------------------------
         // Move polls...
         //-----------------------------------------
         $this->DB->update('polls', array('forum_id' => $this->request['MOVE_ID']), 'forum_id=' . $this->request['f']);
         //-----------------------------------------
         // Move voters...
         //-----------------------------------------
         $this->DB->update('voters', array('forum_id' => $this->request['MOVE_ID']), 'forum_id=' . $this->request['f']);
         /* Move tags */
         $this->registry->tags->moveTagsByParentId($this->request['f'], $this->request['MOVE_ID']);
         $modfunc->forumRecount($this->request['MOVE_ID']);
     }
     //-----------------------------------------
     // Delete the forum
     //-----------------------------------------
     $this->DB->delete('forums', "id=" . $this->request['f']);
     $this->DB->delete('permission_index', "app='forums' AND perm_type='forum' AND perm_type_id=" . $this->request['f']);
     //-----------------------------------------
     // Remove moderators from this forum
     //-----------------------------------------
     $this->DB->build(array('select' => '*', 'from' => 'moderators', 'where' => "forum_id LIKE '%,{$this->request['f']},%'"));
     $outer = $this->DB->execute();
     while ($r = $this->DB->fetch($outer)) {
         $forums = explode(',', IPSText::cleanPermString($r['forum_id']));
         $newForums = array();
         foreach ($forums as $aForumId) {
             if ($aForumId != $this->request['f']) {
                 $newForums[] = $aForumId;
             }
         }
         if (!count($newForums)) {
             $this->DB->delete('moderators', "mid=" . $r['mid']);
         } else {
             $this->DB->update('moderators', array('forum_id' => ',' . implode(',', $newForums) . ','), 'mid=' . $r['mid']);
         }
     }
     //-----------------------------------------
     // Delete forum subscriptions
     //-----------------------------------------
     require_once IPS_ROOT_PATH . 'sources/classes/like/composite.php';
     /*noLibHook*/
     $_like = classes_like::bootstrap('forums', 'forums');
     $_like->remove($this->request['f']);
     //-----------------------------------------
     // Update children
     //-----------------------------------------
     $this->DB->update('forums', array('parent_id' => $this->request['new_parent_id']), "parent_id=" . $this->request['f']);
     //-----------------------------------------
     // Rebuild moderator cache
     //-----------------------------------------
     $classToLoad = IPSLib::loadActionOverloader(IPSLib::getAppDir('forums') . '/modules_admin/forums/moderator.php', 'admin_forums_forums_moderator');
     $moderator = new $classToLoad();
     $moderator->makeRegistryShortcuts($this->registry);
     $moderator->rebuildModeratorCache();
     $this->registry->adminFunctions->saveAdminLog(sprintf($this->lang->words['for_removedlog'], $forum['name']));
     $this->registry->output->global_message = $this->lang->words['for_removed'];
     $this->registry->output->silentRedirectWithMessage($this->settings['base_url'] . $this->form_code);
 }
コード例 #25
0
 /**
  * Creates a nwe permission set
  *
  * @return	@e void		[Outputs to screen]
  */
 protected function _doCreatePermissionSet()
 {
     /* INIT */
     $set_name = $this->request['new_perm_name'];
     $base_on = $this->request['new_perm_copy'];
     if (!$set_name) {
         $this->registry->output->global_message = $this->words['err_specify_set_name'];
         $this->_mainScreen();
         return;
     }
     /* Permissions Class */
     $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/class_public_permissions.php', 'classPublicPermissions');
     $perm_obj = new $classToLoad($this->registry);
     /* Loop through applications */
     $where = array();
     foreach ($this->registry->getApplications() as $app) {
         /* Check to see if there is a permission map */
         $_file = IPSLib::getAppDir($app['app_directory']) . '/extensions/coreExtensions.php';
         if (is_file($_file)) {
             /* Get the permission mappings */
             $_PERM_CONFIG = array();
             require_once $_file;
             /*noLibHook*/
             /* Check for a config array */
             if (is_array($_PERM_CONFIG) && count($_PERM_CONFIG)) {
                 /* Loop through the types */
                 foreach ($_PERM_CONFIG as $perm_type) {
                     $where[] = " app='{$app['app_directory']}' AND perm_type='" . strtolower($perm_type) . "' ";
                 }
             }
         }
     }
     /* Create the set */
     $this->DB->insert('forum_perms', array('perm_name' => $set_name));
     $new_set_id = $this->DB->getInsertId();
     /* Query Permission Rows */
     $this->DB->build(array('select' => '*', 'from' => 'permission_index', 'where' => implode(' OR ', $where)));
     $outer = $this->DB->execute();
     while ($r = $this->DB->fetch($outer)) {
         $perm_id = $r['perm_id'];
         foreach (array('perm_view', 'perm_2', 'perm_3', 'perm_4', 'perm_5', 'perm_6', 'perm_7') as $p) {
             if ($r[$p] != '*') {
                 if (in_array($base_on, explode(',', IPSText::cleanPermString($r[$p])))) {
                     $r[$p] .= $new_set_id . ',';
                 }
             }
         }
         /* Unset main ID */
         unset($r['perm_id']);
         /* Update */
         $this->DB->update('permission_index', $r, "perm_id=" . $perm_id);
     }
     /* Fire callbacks */
     $this->_fireAppCallbacks();
     /* Done */
     $this->registry->output->global_message = $this->lang->words['per_saved'];
     $this->registry->output->silentRedirectWithMessage($this->settings['base_url'] . $this->form_code . 'do=edit_set_form&amp;id=' . $new_set_id);
 }
コード例 #26
0
 /**
  * Delete the group
  *
  * @return	@e void		[Outputs to screen]
  */
 protected function _doDelete()
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $this->request['id'] = intval($this->request['id']);
     $this->request['to_id'] = intval($this->request['to_id']);
     //-----------------------------------------
     // Auth check...
     //-----------------------------------------
     ipsRegistry::getClass('adminFunctions')->checkSecurityKey($this->request['secure_key']);
     //-----------------------------------------
     // Check
     //-----------------------------------------
     if (!$this->request['id']) {
         $this->registry->output->showError($this->lang->words['g_whichgroup'], 1122);
     }
     if ($this->request['id'] < 6) {
         $this->registry->output->showError($this->lang->words['g_preset'], 1124);
     }
     if (!$this->request['to_id']) {
         $this->registry->output->showError($this->lang->words['g_mecries'], 1123);
     }
     //-----------------------------------------
     // Check to make sure that the relevant groups exist.
     //-----------------------------------------
     $original = $this->caches['group_cache'][$this->request['id']];
     $move_to = $this->caches['group_cache'][$this->request['to_id']];
     if (!count($original)) {
         $this->registry->output->showError($this->lang->words['g_whichgroup'], 1125);
     }
     if (!count($move_to)) {
         $this->registry->output->showError($this->lang->words['g_mecries'], 1126);
     }
     //-----------------------------------------
     // Check restrictions.
     //-----------------------------------------
     if ($original['g_access_cp']) {
         $this->registry->getClass('class_permissions')->checkPermissionAutoMsg('groups_delete_admin');
         $this->registry->getClass('class_permissions')->checkPermissionAutoMsg('member_move_admin1', 'members', 'members');
     } else {
         if ($move_to['g_access_cp']) {
             $this->registry->getClass('class_permissions')->checkPermissionAutoMsg('member_move_admin2', 'members', 'members');
         }
     }
     //-----------------------------------------
     // Move and delete
     //-----------------------------------------
     $this->DB->update('members', array('member_group_id' => $this->request['to_id']), 'member_group_id=' . $this->request['id']);
     $this->DB->delete('groups', "g_id=" . $this->request['id']);
     $this->DB->delete('admin_permission_rows', "row_id_type='group' AND row_id=" . $this->request['id']);
     //-----------------------------------------
     // Can't promote to non-existent group
     //-----------------------------------------
     foreach ($this->cache->getCache('group_cache') as $row) {
         $promotion = explode('&', $row['g_promotion']);
         if ($promotion[0] == $this->request['id']) {
             $this->DB->update('groups', array('g_promotion' => '-1&-1'), 'g_id=' . $row['g_id']);
         }
     }
     //-----------------------------------------
     // Remove from moderators table
     //-----------------------------------------
     $this->DB->delete('moderators', "is_group=1 AND group_id=" . $this->request['id']);
     //-----------------------------------------
     // Remove as a secondary group
     //-----------------------------------------
     $this->DB->build(array('select' => 'member_group_id, mgroup_others, member_id', 'from' => 'members', 'where' => "mgroup_others LIKE '%," . $this->request['id'] . ",%'"));
     $exg = $this->DB->execute();
     while ($others = $this->DB->fetch($exg)) {
         $extra = array();
         $extra = explode(",", IPSText::cleanPermString($others['mgroup_others']));
         $to_insert = array();
         if (count($extra)) {
             foreach ($extra as $mgroup_other) {
                 if ($mgroup_other != $this->request['id']) {
                     if ($mgroup_other != "") {
                         $to_insert[] = $mgroup_other;
                     }
                 }
             }
             if (count($to_insert)) {
                 $new_others = ',' . implode(',', $to_insert) . ',';
             } else {
                 $new_others = "";
             }
             $this->DB->update('members', array('mgroup_others' => $new_others), 'member_id=' . $others['member_id']);
         }
     }
     //-----------------------------------------
     // Fix settings
     //-----------------------------------------
     $_toUpdate = array();
     $this->DB->build(array('select' => '*', 'from' => 'core_sys_conf_settings', 'where' => "conf_extra='#show_groups#'"));
     $o = $this->DB->execute();
     while ($r = $this->DB->fetch($o)) {
         /* Dropdown with the deleted group selected? Return to default. */
         if ($r['conf_type'] == 'dropdown' and $r['conf_value'] == $this->request['id']) {
             $_toUpdate[$r['conf_key']] = $r['conf_default'];
         } else {
             if ($r['conf_type'] == 'multi' and strpos($r['conf_value'], (string) $this->request['id']) !== false) {
                 $_values = explode(',', $r['conf_value']);
                 $_newValues = array();
                 foreach ($_values as $_value) {
                     if ($_value != $this->request['id']) {
                         $_newValues[] = $_value;
                     }
                 }
                 $_toUpdate[$r['conf_key']] = count($_newValues) ? $_newValues : $r['conf_default'];
             }
         }
     }
     if (count($_toUpdate)) {
         /* The multiselect settings have evalphp which forces it to inspect $_POST */
         $_POST = array_merge($_POST, $_toUpdate);
         IPSLib::updateSettings($_toUpdate);
     }
     //-----------------------------------------
     // Rebuild caches
     //-----------------------------------------
     $this->rebuildGroupCache();
     $this->cache->rebuildCache('moderators', 'forums');
     ipsRegistry::getClass('adminFunctions')->saveAdminLog(sprintf($this->lang->words['g_removedlog'], $original['g_title']));
     $this->registry->output->global_message = $this->lang->words['g_removed'];
     $this->_mainScreen();
 }
コード例 #27
0
ファイル: view.php プロジェクト: mover5/imobackup
 /**
  * Show a single event based on eventid
  *
  * @return	@e void
  */
 public function calendarShowEvent()
 {
     //-----------------------------------------
     // Init
     //-----------------------------------------
     $event_id = intval($this->request['event_id']);
     if (!$event_id) {
         $this->registry->output->showError('calendar_event_not_found', 10429, null, null, 404);
     }
     //-----------------------------------------
     // Get the event data
     //-----------------------------------------
     $_joins = array(array('select' => 'm.*', 'from' => array('members' => 'm'), 'where' => 'm.member_id=e.event_member_id', 'type' => 'left'), array('select' => 'pp.*', 'from' => array('profile_portal' => 'pp'), 'where' => 'm.member_id=pp.pp_member_id', 'type' => 'left'));
     if ($this->settings['reputation_enabled']) {
         $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/class_reputation_cache.php', 'classReputationCache');
         $this->registry->setClass('repCache', new $classToLoad());
         $_joins[] = $this->registry->getClass('repCache')->getTotalRatingJoin('event_id', $event_id, 'calendar');
         $_joins[] = $this->registry->getClass('repCache')->getUserHasRatedJoin('event_id', $event_id, 'calendar');
     }
     $event = $this->DB->buildAndFetch(array('select' => 'e.*', 'from' => array('cal_events' => 'e'), 'where' => 'e.event_id=' . $event_id, 'add_join' => $_joins));
     if (!$event['event_id']) {
         $this->registry->output->showError('calendar_event_not_found', 10430, null, null, 404);
     }
     //-----------------------------------------
     // Reset calendar
     //-----------------------------------------
     $this->calendar = $this->functions->getCalendar($event['event_calendar_id']);
     if ($this->calendar['cal_id'] != $event['event_calendar_id']) {
         $this->registry->output->showError('cal_no_perm', 1040.22, null, null, 403);
     }
     //-----------------------------------------
     // Check permissions
     //-----------------------------------------
     if ($event['event_private'] and $this->memberData['member_id'] != $event['event_member_id']) {
         $this->registry->output->showError('calendar_event_not_found', 10431, null, null, 403);
     }
     if (!$this->memberData['g_is_supmod'] and !$event['event_approved']) {
         $this->registry->output->showError('calendar_event_not_found', 10432.1, null, null, 404);
     }
     if ($event['event_perms'] != '*') {
         $permissionGroups = explode(',', IPSText::cleanPermString($event['event_perms']));
         if (!IPSMember::isInGroup($this->memberData, $permissionGroups)) {
             $this->registry->output->showError('calendar_event_not_found', 10432, null, null, 404);
         }
     }
     //-----------------------------------------
     // Are we RSVPing?
     //-----------------------------------------
     if ($this->request['_rsvp'] and $event['event_rsvp']) {
         if ($this->registry->permissions->check('rsvp', $this->calendar) and $this->memberData['member_id']) {
             //-----------------------------------------
             // Make sure we aren't already RSVPed
             //-----------------------------------------
             $_check = $this->DB->buildAndFetch(array('select' => 'rsvp_id', 'from' => 'cal_event_rsvp', 'where' => 'rsvp_event_id=' . $event['event_id'] . ' AND rsvp_member_id=' . $this->memberData['member_id']));
             if (!$_check['rsvp_id']) {
                 $_insert = array('rsvp_event_id' => $event['event_id'], 'rsvp_member_id' => $this->memberData['member_id'], 'rsvp_date' => time());
                 $this->DB->insert('cal_event_rsvp', $_insert);
                 $this->registry->output->redirectScreen($this->lang->words['rsvp_saved_im'], $this->settings['base_url'] . "app=calendar&amp;module=calendar&amp;section=view&amp;do=showevent&amp;event_id=" . $event['event_id'], $event['event_title_seo'], 'cal_event');
             }
         }
     }
     //-----------------------------------------
     // Comments class
     //-----------------------------------------
     require_once IPS_ROOT_PATH . 'sources/classes/comments/bootstrap.php';
     /*noLibHook*/
     $this->_comments = classes_comments_bootstrap::controller('calendar-events');
     $comments = array('html' => $this->_comments->fetchFormatted($event, array('offset' => intval($this->request['st']))), 'count' => $this->_comments->count($event));
     //-----------------------------------------
     // Highlight...
     //-----------------------------------------
     if ($this->request['hl']) {
         $event['event_content'] = IPSText::searchHighlight($event['event_content'], $this->request['hl']);
         $event['event_title'] = IPSText::searchHighlight($event['event_title'], $this->request['hl']);
     }
     //-----------------------------------------
     // Can we report?
     //-----------------------------------------
     $classToLoad = IPSLib::loadLibrary(IPSLib::getAppDir('core') . '/sources/classes/reportLibrary.php', 'reportLibrary', 'core');
     $reports = new $classToLoad($this->registry);
     $event['_canReport'] = $reports->canReport('calendar');
     //-----------------------------------------
     // Output
     //-----------------------------------------
     $member = IPSMember::load($event['event_member_id'], 'all');
     $this->registry->output->addNavigation($this->calendar['cal_title'], "app=calendar&amp;module=calendar&amp;section=view&amp;cal_id={$this->calendar['cal_id']}", $this->calendar['cal_title_seo'], 'cal_calendar');
     //-----------------------------------------
     // Try to match out and improve navigation
     //-----------------------------------------
     $_referrer = $_SERVER['HTTP_REFERER'];
     if ($_referrer) {
         //-----------------------------------------
         // Came from add form?
         //-----------------------------------------
         if (preg_match("#/add\$#", $_referrer)) {
             $_data = $this->calendarMakeEventHTML($event, true);
             $_dateBits = explode('-', gmstrftime('%Y-%m-%d-%B', $_data['event']['_start_time']));
             $this->registry->output->addNavigation($_dateBits[3] . ' ' . $_dateBits[0], "app=calendar&amp;module=calendar&amp;section=view&amp;cal_id={$this->calendar['cal_id']}&amp;m={$_dateBits[1]}&amp;y={$_dateBits[0]}", $this->calendar['cal_title_seo'], 'cal_month');
             $this->registry->output->addNavigation($_dateBits[3] . ' ' . $_dateBits[2] . ', ' . $_dateBits[0], "app=calendar&amp;module=calendar&amp;section=view&amp;cal_id={$this->calendar['cal_id']}&amp;do=showday&amp;y={$_dateBits[0]}&amp;m={$_dateBits[1]}&amp;d={$_dateBits[2]}", $this->calendar['cal_title_seo'], 'cal_day');
         } else {
             if (preg_match("#/day\\-(\\d{4})\\-(\\d{1,2})\\-(\\d{1,2})\$#i", $_referrer, $matches)) {
                 $_dateBits = explode('-', gmstrftime('%Y-%m-%d-%B', gmmktime(0, 0, 0, $matches[2], $matches[3], $matches[1])));
                 $this->registry->output->addNavigation($_dateBits[3] . ' ' . $_dateBits[0], "app=calendar&amp;module=calendar&amp;section=view&amp;cal_id={$this->calendar['cal_id']}&amp;m={$_dateBits[1]}&amp;y={$_dateBits[0]}", $this->calendar['cal_title_seo'], 'cal_month');
                 $this->registry->output->addNavigation($_dateBits[3] . ' ' . $_dateBits[2] . ', ' . $_dateBits[0], "app=calendar&amp;module=calendar&amp;section=view&amp;cal_id={$this->calendar['cal_id']}&amp;do=showday&amp;y={$_dateBits[0]}&amp;m={$_dateBits[1]}&amp;d={$_dateBits[2]}", $this->calendar['cal_title_seo'], 'cal_day');
             } else {
                 if (preg_match("#/week\\-(\\d+?)\$#i", $_referrer, $matches)) {
                     $_dateBits = explode('-', gmstrftime('%Y-%m-%d-%B', $matches[1]));
                     $this->registry->output->addNavigation($_dateBits[3] . ' ' . $_dateBits[0], "app=calendar&amp;module=calendar&amp;section=view&amp;cal_id={$this->calendar['cal_id']}&amp;m={$_dateBits[1]}&amp;y={$_dateBits[0]}", $this->calendar['cal_title_seo'], 'cal_month');
                     $this->registry->output->addNavigation("{$this->lang->words['week_beginning']} " . gmstrftime('%B %d, %Y', $matches[1]), "app=calendar&amp;module=calendar&amp;section=view&amp;cal_id={$this->calendar['cal_id']}&amp;do=showweek&amp;week={$matches[1]}", $this->calendar['cal_title_seo'], 'cal_week');
                 } else {
                     if (preg_match("#/(\\d{1,2})\\-(\\d{4})\$#i", $_referrer, $matches)) {
                         $_dateBits = explode('-', gmstrftime('%Y-%m-%d-%B', gmmktime(0, 0, 0, $matches[1], 15, $matches[2])));
                         $this->registry->output->addNavigation($_dateBits[3] . " " . $_dateBits[0], "app=calendar&amp;module=calendar&amp;section=view&amp;cal_id={$this->calendar['cal_id']}&amp;m={$_dateBits[1]}&amp;y={$_dateBits[0]}", $this->calendar['cal_title_seo'], 'cal_month');
                     } else {
                         if (preg_match("#/(\\d+?)\\-(.+?)\$#i", $_referrer, $matches)) {
                             $_data = $this->calendarMakeEventHTML($event, true);
                             $_dateBits = explode('-', gmstrftime('%Y-%m-%d-%B', $_data['event']['_start_time']));
                             $this->registry->output->addNavigation($_dateBits[3] . " " . $_dateBits[0], "app=calendar&amp;module=calendar&amp;section=view&amp;cal_id={$this->calendar['cal_id']}&amp;m={$_dateBits[1]}&amp;y={$_dateBits[0]}", $this->calendar['cal_title_seo'], 'cal_month');
                         } else {
                             $_data = $this->calendarMakeEventHTML($event, true);
                             $_dateBits = explode('-', gmstrftime('%Y-%m-%d-%B', $_data['event']['_start_time']));
                             $this->registry->output->addNavigation($_dateBits[3] . ' ' . $_dateBits[0], "app=calendar&amp;module=calendar&amp;section=view&amp;cal_id={$this->calendar['cal_id']}&amp;m={$_dateBits[1]}&amp;y={$_dateBits[0]}", $this->calendar['cal_title_seo'], 'cal_month');
                             $this->registry->output->addNavigation($_dateBits[3] . ' ' . $_dateBits[2] . ', ' . $_dateBits[0], "app=calendar&amp;module=calendar&amp;section=view&amp;cal_id={$this->calendar['cal_id']}&amp;do=showday&amp;y={$_dateBits[0]}&amp;m={$_dateBits[1]}&amp;d={$_dateBits[2]}", $this->calendar['cal_title_seo'], 'cal_day');
                         }
                     }
                 }
             }
         }
     }
     //-----------------------------------------
     // Finish output
     //-----------------------------------------
     $this->registry->output->addNavigation($event['event_title']);
     $this->registry->output->addMetaTag('keywords', $this->chosen_date['month_name'] . ' ' . $_dateBits[2] . ' events event calendar ' . $event['event_title'] . ' ' . IPSText::getTextClass('bbcode')->stripAllTags($event['event_content']), TRUE);
     $this->registry->output->addMetaTag('description', str_replace("\n", " ", str_replace("\r", "", IPSText::getTextClass('bbcode')->stripAllTags($event['event_content']))), FALSE, 155);
     $this->registry->output->addToDocumentHead('raw', "<link rel='up' href='" . $this->registry->output->buildSEOUrl('app=calendar&amp;module=calendar&amp;section=view&amp;cal_id=' . $event['event_calendar_id'], 'publicNoSession', $this->calendar['cal_title_seo'], 'cal_calendar') . "' />");
     $this->registry->output->addToDocumentHead('raw', "<link rel='author' href='" . $this->registry->output->buildSEOUrl('showuser='******'event_member_id'], 'publicNoSession', $member['members_seo_name'], 'showuser') . "' />");
     $this->registry->getClass('output')->addCanonicalTag('app=calendar&amp;module=calendar&amp;section=view&amp;do=showevent&amp;event_id=' . $event['event_id'], $event['event_title_seo'], 'cal_event');
     $this->page_title = $event['event_title'];
     $this->output .= $this->registry->output->getTemplate('calendar')->calendarShowEvent($this->calendarMakeEventHTML($event), $comments);
 }
コード例 #28
0
 /**
  * Get report permissions
  *
  * @access	public
  * @param	string 		Type of perms to check
  * @param 	array 		Permissions data
  * @param 	array 		group ids
  * @param 	string		Special permissions
  * @return	boolean
  */
 public function getReportPermissions($check, $com_dat, $group_ids, &$to_return)
 {
     if ($this->memberData['g_is_supmod'] == 1 && (!isset($this->_extra['report_supermod']) || $this->_extra['report_supermod'] == 1)) {
         return true;
     } else {
         $forum_ids = array();
         foreach ($this->caches['moderators'] as $mod) {
             if ($mod['member_id'] == $this->memberData['member_id']) {
                 $these_forums = explode(',', IPSText::cleanPermString($mod['forum_id']));
                 foreach ($these_forums as $forum_id) {
                     $forum_ids['exdat1'][] = $forum_id;
                 }
             } elseif ($mod['is_group'] == 1 && in_array($mod['group_id'], $group_ids) == true) {
                 $these_forums = explode(',', IPSText::cleanPermString($mod['forum_id']));
                 foreach ($these_forums as $forum_id) {
                     $forum_ids['exdat1'][] = $forum_id;
                 }
             }
         }
         if (count($forum_ids) > 0) {
             $to_return = $forum_ids;
             return true;
         } else {
             return false;
         }
     }
 }
コード例 #29
0
 /**
  * Sort out bbcode and permissions
  * 
  * @return	@e void
  */
 public function permsAndBbcode()
 {
     /* INIT */
     $options = IPSSetUp::getSavedData('custom_options');
     $rootAdmins = $options['core'][30001]['rootAdmins'];
     /* First off, import default BBCode */
     $apps = array();
     $bbcodeOld = array();
     $bbcodeNew = array();
     /* Load apps */
     $this->DB->build(array('select' => '*', 'from' => 'core_applications'));
     $this->DB->execute();
     while ($row = $this->DB->fetch()) {
         $apps[$row['app_directory']] = $row;
     }
     /* Load old codes */
     $this->DB->build(array('select' => '*', 'from' => 'custom_bbcode_old'));
     $this->DB->execute();
     while ($row = $this->DB->fetch()) {
         $bbcodeOld[$row['bbcode_tag']] = $row;
     }
     /* Add 'em */
     foreach ($apps as $dir => $data) {
         if (is_file(IPSLib::getAppDir($dir) . '/xml/' . $dir . '_bbcode.xml')) {
             //-----------------------------------------
             // Continue
             //-----------------------------------------
             $classToLoad = IPSLib::loadActionOverloader(IPS_ROOT_PATH . 'applications/core/modules_admin/posts/bbcode.php', 'admin_core_posts_bbcode');
             $bbcode = new $classToLoad();
             $bbcode->makeRegistryShortcuts($this->registry);
             $bbcode->bbcodeImportDo(file_get_contents(IPSLib::getAppDir($dir) . '/xml/' . $dir . '_bbcode.xml'));
         }
         if (is_file(IPSLib::getAppDir($dir) . '/xml/' . $dir . '_mediatag.xml')) {
             //-----------------------------------------
             // Continue
             //-----------------------------------------
             $classToLoad = IPSLib::loadActionOverloader(IPS_ROOT_PATH . 'applications/core/modules_admin/posts/media.php', 'admin_core_posts_media');
             $bbcode = new $classToLoad();
             $bbcode->makeRegistryShortcuts($this->registry);
             $bbcode->doMediaImport(file_get_contents(IPSLib::getAppDir($dir) . '/xml/' . $dir . '_mediatag.xml'));
         }
     }
     /* Load current code */
     $this->DB->build(array('select' => '*', 'from' => 'custom_bbcode'));
     $this->DB->execute();
     while ($row = $this->DB->fetch()) {
         $bbcodeCurrent[$row['bbcode_tag']] = $row;
         //-----------------------------------------
         // Need to take into account aliases too!
         //-----------------------------------------
         if ($row['bbcode_aliases']) {
             $aliases = explode(',', $row['bbcode_aliases']);
             if (count($aliases)) {
                 foreach ($aliases as $alias) {
                     $bbcodeCurrent[$alias] = $row;
                 }
             }
         }
     }
     if (count($bbcodeOld)) {
         foreach ($bbcodeOld as $tag => $row) {
             if (!$bbcodeCurrent[$row['bbcode_tag']]) {
                 $bbcodeNew[$row['bbcode_tag']] = $row;
             }
         }
     }
     $this->registry->output->addMessage("BB-коды обновлены....");
     /* Now see if there's anything we need to move back over */
     if (count($bbcodeNew)) {
         foreach ($bbcodeNew as $tag => $data) {
             $bbarray = array('bbcode_title' => $data['bbcode_title'], 'bbcode_desc' => $data['bbcode_desc'], 'bbcode_tag' => $data['bbcode_tag'], 'bbcode_replace' => IPSText::safeslashes($data['bbcode_replace']), 'bbcode_useoption' => $data['bbcode_useoption'], 'bbcode_example' => $data['bbcode_example'], 'bbcode_switch_option' => $data['bbcode_switch_option'], 'bbcode_menu_option_text' => $data['bbcode_menu_option_text'], 'bbcode_menu_content_text' => $data['bbcode_menu_content_text'], 'bbcode_groups' => 'all', 'bbcode_sections' => 'all', 'bbcode_php_plugin' => '', 'bbcode_parse' => 2, 'bbcode_no_parsing' => 0, 'bbcode_optional_option' => 0, 'bbcode_aliases' => '', 'bbcode_image' => '');
             $this->DB->insert('custom_bbcode', $bbarray);
         }
     }
     /* OK, now onto permissions... */
     /* Insert basic perms for profiles and help */
     $this->DB->insert('permission_index', array('app' => 'members', 'perm_type' => 'profile_view', 'perm_type_id' => 1, 'perm_view' => '*', 'perm_2' => '', 'perm_3' => '', 'perm_4' => '', 'perm_5' => '', 'perm_6' => '', 'perm_7' => ''));
     $this->DB->insert('permission_index', array('app' => 'core', 'perm_type' => 'help', 'perm_type_id' => 1, 'perm_view' => '*', 'perm_2' => '', 'perm_3' => '', 'perm_4' => '', 'perm_5' => '', 'perm_6' => '', 'perm_7' => ''));
     /* And now calendars */
     $this->DB->build(array('select' => '*', 'from' => 'cal_calendars'));
     $o = $this->DB->execute();
     while ($row = $this->DB->fetch($o)) {
         if (strstr($row['cal_permissions'], 'a:')) {
             $_perms = unserialize(stripslashes($row['cal_permissions']));
             if (is_array($_perms)) {
                 $_view = $_perms['perm_read'] ? ',' . implode(',', explode(',', $_perms['perm_read'])) . ',' : '';
                 $_start = $_perms['perm_post'] ? ',' . implode(',', explode(',', $_perms['perm_post'])) . ',' : '';
                 $_nomod = $_perms['perm_nomod'] ? ',' . implode(',', explode(',', $_perms['perm_nomod'])) . ',' : '';
                 $this->DB->insert('permission_index', array('app' => 'calendar', 'perm_type' => 'calendar', 'perm_type_id' => $row['cal_id'], 'perm_view' => str_replace(',*,', '*', $_view), 'perm_2' => str_replace(',*,', '*', $_start), 'perm_3' => str_replace(',*,', '*', $_nomod), 'perm_4' => '', 'perm_5' => '', 'perm_6' => '', 'perm_7' => ''));
             } else {
                 $this->DB->insert('permission_index', array('app' => 'calendar', 'perm_type' => 'calendar', 'perm_type_id' => $row['cal_id'], 'perm_view' => '', 'perm_2' => '', 'perm_3' => '', 'perm_4' => '', 'perm_5' => '', 'perm_6' => '', 'perm_7' => ''));
             }
         } else {
             $this->DB->insert('permission_index', array('app' => 'calendar', 'perm_type' => 'calendar', 'perm_type_id' => $row['cal_id'], 'perm_view' => '', 'perm_2' => '', 'perm_3' => '', 'perm_4' => '', 'perm_5' => '', 'perm_6' => '', 'perm_7' => ''));
         }
     }
     /* And now forums */
     $this->DB->build(array('select' => '*', 'from' => 'forums'));
     $o = $this->DB->execute();
     while ($row = $this->DB->fetch($o)) {
         /* Do we need to tidy up the title? */
         if (strstr($row['name'], '&')) {
             $row['name'] = preg_replace("#& #", "&amp; ", $row['name']);
             $this->DB->update('forums', array('name' => $row['name']), 'id=' . $row['id']);
         }
         if (strstr($row['permission_array'], 'a:')) {
             $_perms = unserialize(stripslashes($row['permission_array']));
             if (is_array($_perms)) {
                 $_view = $_perms['show_perms'] ? ',' . implode(',', explode(',', $_perms['show_perms'])) . ',' : '';
                 $_read = $_perms['read_perms'] ? ',' . implode(',', explode(',', $_perms['read_perms'])) . ',' : '';
                 $_reply = $_perms['reply_perms'] ? ',' . implode(',', explode(',', $_perms['reply_perms'])) . ',' : '';
                 $_start = $_perms['start_perms'] ? ',' . implode(',', explode(',', $_perms['start_perms'])) . ',' : '';
                 $_upload = $_perms['upload_perms'] ? ',' . implode(',', explode(',', $_perms['upload_perms'])) . ',' : '';
                 $_download = $_perms['download_perms'] ? ',' . implode(',', explode(',', $_perms['download_perms'])) . ',' : '';
                 $this->DB->insert('permission_index', array('app' => 'forums', 'perm_type' => 'forum', 'perm_type_id' => $row['id'], 'perm_view' => str_replace(',*,', '*', $_view), 'perm_2' => str_replace(',*,', '*', $_read), 'perm_3' => str_replace(',*,', '*', $_reply), 'perm_4' => str_replace(',*,', '*', $_start), 'perm_5' => str_replace(',*,', '*', $_upload), 'perm_6' => str_replace(',*,', '*', $_download), 'perm_7' => ''));
             } else {
                 $this->DB->insert('permission_index', array('app' => 'forums', 'perm_type' => 'forum', 'perm_type_id' => $row['id'], 'perm_view' => '', 'perm_2' => '', 'perm_3' => '', 'perm_4' => '', 'perm_5' => '', 'perm_6' => '', 'perm_7' => ''));
                 IPSSetUp::addLogMessage("Пропущены права доступа для форума ID: " . $row['id'], '30001', 'core');
             }
         } else {
             $this->DB->insert('permission_index', array('app' => 'forums', 'perm_type' => 'forum', 'perm_type_id' => $row['id'], 'perm_view' => '', 'perm_2' => '', 'perm_3' => '', 'perm_4' => '', 'perm_5' => '', 'perm_6' => '', 'perm_7' => ''));
             IPSSetUp::addLogMessage("Пропущены права доступа для форума ID: " . $row['id'], '30001', 'core');
         }
     }
     $this->registry->output->addMessage("Права доступа обновлены....");
     /* Fix up forum moderators */
     $this->DB->build(array('select' => '*', 'from' => 'moderators'));
     $o = $this->DB->execute();
     while ($r = $this->DB->fetch($o)) {
         $this->DB->update('moderators', array('forum_id' => ',' . IPSText::cleanPermString($r['forum_id']) . ','), 'mid=' . $r['mid']);
     }
     $this->registry->output->addMessage("Модераторы форумов обновлены....");
     /* Root admin reset? */
     if ($rootAdmins) {
         /* Find all admin groups */
         $this->DB->build(array('select' => '*', 'from' => 'groups', 'where' => 'g_id != ' . $this->settings['admin_group'] . ' AND g_access_cp=1'));
         $o = $this->DB->execute();
         while ($row = $this->DB->fetch($o)) {
             /* Insert blank perm row */
             $this->DB->insert('admin_permission_rows', array('row_id' => $row['g_id'], 'row_id_type' => 'group', 'row_perm_cache' => serialize(array()), 'row_updated' => time()));
         }
         $this->registry->output->addMessage("Удалены вторичные группы администраторов....");
     }
     /* Report center reset */
     $canReport = array();
     $canView = array();
     $this->DB->build(array('select' => 'g_id, g_view_board, g_access_cp, g_is_supmod', 'from' => 'groups'));
     $o = $this->DB->execute();
     while ($r = $this->DB->fetch($o)) {
         if ($r['g_access_cp'] or $r['g_is_supmod']) {
             $canView[] = $r['g_id'];
         }
         if ($r['g_view_board'] and $r['g_id'] != $this->settings['guest_group']) {
             $canReport[] = $r['g_id'];
         }
     }
     $this->DB->update('rc_classes', array('group_can_report' => ',' . implode(',', $canReport) . ',', 'mod_group_perm' => ',' . implode(',', $canView) . ','));
     /* Next Page */
     $this->request['workact'] = 'skinlang';
 }
コード例 #30
0
ファイル: bbcode.php プロジェクト: mover5/imobackup
 /**
  * Loop over the bbcode and make replacements as necessary
  *
  * @access public
  * @param string		Current text
  * @return string text
  */
 protected function _parseBBCode($txt, $mode = 'html', $bbcodes = array())
 {
     // -----------------------------------------
     // We want preDbParse method called for shared
     // media for permission checking, so force it for now..
     // -----------------------------------------
     //$this->_bbcodes[$cur_method]['sharedmedia'] = $this->_bbcodes['display']['sharedmedia'];
     /* Replace them */
     if (count($this->_bbcodes)) {
         foreach ($this->_bbcodes as $_tag => $_bbcode) {
             /* Check to see if we can parse these */
             if (is_array($bbcodes) and count($bbcodes)) {
                 if (!in_array($_bbcode['bbcode_tag'], $bbcodes)) {
                     continue;
                 }
             }
             /* Allowed to use this? */
             if ($_bbcode['bbcode_groups'] != 'all' and parent::$Perms['memberData']['member_group_id']) {
                 $pass = false;
                 $groups = array_diff(explode(',', $_bbcode['bbcode_groups']), array(''));
                 $mygroups = array(parent::$Perms['memberData']['member_group_id']);
                 if (parent::$Perms['memberData']['mgroup_others']) {
                     $mygroups = array_diff(array_merge($mygroups, explode(',', IPSText::cleanPermString(parent::$Perms['memberData']['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']) {
                 $file = IPS_ROOT_PATH . 'sources/classes/text/parser/bbcode/' . $_bbcode['bbcode_php_plugin'];
                 $_key = md5($_bbcode['bbcode_tag']);
                 /* The legacy 'list' bbcode tag replaces \n out of necessity, however this breaks legacy code boxes upon upgrade.  Ticket 853240 */
                 if ($_bbcode['bbcode_tag'] == 'list') {
                     /* Preserve newlines in codeboxes */
                     $txt = $this->_preserveCodeBoxes($txt);
                 }
                 // -----------------------------------------
                 // Do we already have this plugin in our registry?
                 // -----------------------------------------
                 if (isset($this->plugins[$_key])) {
                     // -----------------------------------------
                     // Run the method if it exists
                     // -----------------------------------------
                     if (method_exists($this->plugins[$_key], 'run')) {
                         $_original = $txt;
                         $txt = $this->plugins[$_key]->run($txt, $mode);
                         if (!$txt) {
                             $txt = $_original;
                         } else {
                             if ($this->plugins[$_key]->error) {
                                 $this->_addParsingError($this->plugins[$_key]->error);
                                 if ($_bbcode['bbcode_tag'] == 'list') {
                                     /* Restore preserved newlines */
                                     $txt = str_replace("<!-preserve.newline-->", "\n", $txt);
                                 }
                                 continue;
                             } else {
                                 if ($this->plugins[$_key]->warning) {
                                     $this->warning = $this->plugins[$_key]->warning;
                                 }
                             }
                         }
                     }
                 } elseif (is_file($file)) {
                     $_classname = IPSLib::loadLibrary($file, 'bbcode_plugin_' . IPSText::alphanumericalClean($_bbcode['bbcode_tag']));
                     // -----------------------------------------
                     // Class we need exists
                     // -----------------------------------------
                     if (class_exists($_classname)) {
                         // -----------------------------------------
                         // New instance of class, store in plugin registry
                         // for use next time
                         // -----------------------------------------
                         $plugin = new $_classname($this->registry, $this);
                         $this->plugins[md5($_bbcode['bbcode_tag'])] = $plugin;
                         // -----------------------------------------
                         // Method we need exists
                         // -----------------------------------------
                         if (method_exists($plugin, 'run')) {
                             $_original = $txt;
                             $txt = $plugin->run($txt, $mode);
                             if (!$txt) {
                                 $txt = $_original;
                             } else {
                                 if ($plugin->error) {
                                     $this->_addParsingError($plugin->error);
                                     if ($_bbcode['bbcode_tag'] == 'list') {
                                         /* Restore preserved newlines */
                                         $txt = str_replace("<!-preserve.newline-->", "\n", $txt);
                                     }
                                     continue;
                                 } else {
                                     if ($plugin->warning) {
                                         $this->warning = $plugin->warning;
                                     }
                                 }
                             }
                         }
                     }
                 }
                 // -----------------------------------------
                 // When we run a plugin, we don't do any other processing
                 // "automatically".
                 // Plugin is capable of doing what it wants that way.
                 // -----------------------------------------
                 if ($_bbcode['bbcode_tag'] == 'list') {
                     /* Restore preserved newlines */
                     $txt = str_replace("<!-preserve.newline-->", "\n", $txt);
                 }
                 continue;
             }
             // -----------------------------------------
             // Loop over this bbcode's tags
             // -----------------------------------------
             foreach ($_tags as $_tag) {
                 // -----------------------------------------
                 // Infinite loop catcher
                 // -----------------------------------------
                 $_iteration = 0;
                 // -----------------------------------------
                 // Start building open tag
                 // -----------------------------------------
                 $open_tag = '[' . $_tag;
                 // -----------------------------------------
                 // Doz I can haz opin tag? Loopy loo
                 // -----------------------------------------
                 while (($this->cur_pos = stripos($txt, $open_tag, $this->cur_pos)) !== false) {
                     // -----------------------------------------
                     // Stop infinite loops
                     // -----------------------------------------
                     if ($_iteration > $this->settings['max_bbcodes_per_post']) {
                         break;
                     }
                     $open_length = strlen($open_tag);
                     // -----------------------------------------
                     // Grab the new position to jump to
                     // -----------------------------------------
                     $new_pos = strpos($txt, ']', $this->cur_pos) ? strpos($txt, ']', $this->cur_pos) : $this->cur_pos + 1;
                     // -----------------------------------------
                     // Extract the option (like surgery)
                     // -----------------------------------------
                     $_option = '';
                     if ($_bbcode['bbcode_useoption']) {
                         // -----------------------------------------
                         // Is option optional?
                         // -----------------------------------------
                         if ($_bbcode['bbcode_optional_option']) {
                             // -----------------------------------------
                             // Does we haz it?
                             // -----------------------------------------
                             if (substr($txt, $this->cur_pos + strlen($open_tag), 1) == '=') {
                                 $open_length += 1;
                                 $_option = substr($txt, $this->cur_pos + $open_length, strpos($txt, ']', $this->cur_pos) - ($this->cur_pos + $open_length));
                             } else {
                                 if (strpos($txt, ']', $this->cur_pos) - ($this->cur_pos + $open_length) !== 0) {
                                     if (strpos($txt, ']', $this->cur_pos)) {
                                         $this->cur_pos = $new_pos;
                                         continue;
                                     } else {
                                         break;
                                     }
                                 }
                             }
                         } else {
                             $open_length += 1;
                             $_option = substr($txt, $this->cur_pos + $open_length, strpos($txt, ']', $this->cur_pos) - ($this->cur_pos + $open_length));
                         }
                     } else {
                         if (strpos($txt, ']', $this->cur_pos) - ($this->cur_pos + $open_length) !== 0) {
                             if (strpos($txt, ']', $this->cur_pos)) {
                                 $this->cur_pos = $new_pos;
                                 continue;
                             }
                         }
                     }
                     $_iteration++;
                     // -----------------------------------------
                     // Protect against XSS
                     // -----------------------------------------
                     $_optionStrLen = IPSText::mbstrlen($_option);
                     $_optionSlenstr = strlen($_option);
                     $_option = $this->checkXss($_option, false, $_tag);
                     if ($_option !== FALSE) {
                         /*
                          * Not parsing URls? - Needs to be AFTER the FALSE
                          * check just above
                          */
                         if (!empty($_bbcode['bbcode_no_auto_url_parse'])) {
                             $_option = preg_replace("#(http|https|news|ftp)://#i", "\\1&#58;//", $_option);
                         }
                         // -----------------------------------------
                         // If this is a single tag, that's it
                         // -----------------------------------------
                         if ($_bbcode['bbcode_single_tag']) {
                             $txt = substr_replace($txt, $this->_parseBBCodeTag($_bbcode, $_option, ''), $this->cur_pos, $open_length + $_optionSlenstr + 1);
                         } else {
                             $close_tag = '[/' . $_tag . ']';
                             if (stripos($txt, $close_tag, $new_pos) !== false) {
                                 $_content = substr($txt, $this->cur_pos + $open_length + $_optionSlenstr + 1, stripos($txt, $close_tag, $this->cur_pos) - ($this->cur_pos + $open_length + $_optionSlenstr + 1));
                                 if ($_bbcode['bbcode_useoption'] and $_bbcode['bbcode_optional_option'] and !$_option and !stristr($_bbcode['bbcode_replace'], '{option}')) {
                                     $_option = $_content;
                                     $_option = $this->checkXss($_option, false, $_tag);
                                 }
                                 /* Not parsing URls? */
                                 if (!empty($_bbcode['bbcode_no_auto_url_parse'])) {
                                     $_content = preg_replace("#(http|https|news|ftp)://#i", "\\1&#58;//", $_content);
                                 }
                                 $txt = substr_replace($txt, $this->_parseBBCodeTag($_bbcode, $_option, $_content), $this->cur_pos, stripos($txt, $close_tag, $this->cur_pos) + strlen($close_tag) - $this->cur_pos);
                             } else {
                                 // -----------------------------------------
                                 // If there's no close tag, no need to
                                 // continue
                                 // -----------------------------------------
                                 break;
                             }
                         }
                     }
                     // -----------------------------------------
                     // And reset current position to end of open tag
                     // Bug 14744 - if we jump to $new_pos it can skip the
                     // opening of the next bbcode tag
                     // when the replacement HTML is shorter than the full
                     // bbcode representation...
                     // -----------------------------------------
                     $this->cur_pos = stripos($txt, $open_tag) ? stripos($txt, $open_tag) : $this->cur_pos + 1;
                     // $new_pos;
                     if ($this->cur_pos > strlen($txt)) {
                         break;
                     }
                 }
             }
         }
     }
     return $txt;
 }