コード例 #1
0
ファイル: post.php プロジェクト: Advanture/Online-RolePlay
 /**
  * Constructor
  *
  * @param	object		$registry		Registry object
  * @return	@e void
  */
 public function __construct(ipsRegistry $registry)
 {
     //-----------------------------------------
     // Make object
     //-----------------------------------------
     $this->registry = $registry;
     $this->DB = $this->registry->DB();
     $this->settings =& $this->registry->fetchSettings();
     $this->request =& $this->registry->fetchRequest();
     $this->member = $this->registry->member();
     $this->memberData =& $this->registry->member()->fetchMemberData();
     $this->cache = $this->registry->cache();
     $this->caches =& $this->registry->cache()->fetchCaches();
     $this->lang = $this->registry->class_localization;
     ipsRegistry::getAppClass('forums');
 }
コード例 #2
0
 /**
  * Grab the RSS document content and return it
  * 
  * @return	string		RSS document
  */
 public function returnRSSDocument()
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $rss_export_id = intval(ipsRegistry::$request['id']);
     $rss_data = array();
     $to_print = '';
     $this->expires = time();
     //-----------------------------------------
     // Get RSS export
     //-----------------------------------------
     $rss_data = ipsRegistry::DB()->buildAndFetch(array('select' => '*', 'from' => 'rss_export', 'where' => 'rss_export_id=' . $rss_export_id));
     //-----------------------------------------
     // Got one?
     //-----------------------------------------
     if ($rss_data['rss_export_id'] and $rss_data['rss_export_enabled']) {
         //-----------------------------------------
         // Correct expires time
         //-----------------------------------------
         $this->expires += $rss_data['rss_export_cache_time'] * 60;
         //-----------------------------------------
         // Need to recache?
         //-----------------------------------------
         $time_check = time() - $rss_data['rss_export_cache_time'] * 60;
         if (!$rss_data['rss_export_cache_content'] or $time_check > $rss_data['rss_export_cache_last']) {
             //-----------------------------------------
             // Yes
             //-----------------------------------------
             define('IN_ACP', 1);
             ipsRegistry::getAppClass('forums');
             $classToLoad = IPSLib::loadActionOverloader(IPSLib::getAppDir('forums') . '/modules_admin/rss/export.php', 'admin_forums_rss_export');
             $rss_export = new $classToLoad();
             $rss_export->makeRegistryShortcuts(ipsRegistry::instance());
             return $rss_export->rssExportRebuildCache($rss_data['rss_export_id'], 0);
         } else {
             //-----------------------------------------
             // No
             //-----------------------------------------
             return $rss_data['rss_export_cache_content'];
         }
     }
 }
コード例 #3
0
ファイル: api.php プロジェクト: ConnorChristie/GrabViews
 /**
  * Returns the board's forums.
  * WARNING: Last option is deprecated and no longer supported.  User is automatically treated like a guest.
  * 
  * @param	string  $api_key		Authentication Key
  * @param	string  $api_module		Module
  * @param	string	$forum_ids		Comma separated list of forum ids
  * @param	bool	$view_as_guest	Treat user as a guest
  * @return	string	xml
  */
 public function fetchForums($api_key, $api_module, $forum_ids, $view_as_guest)
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $api_key = IPSText::md5Clean($api_key);
     $api_module = IPSText::parseCleanValue($api_module);
     $forum_ids = $forum_ids ? explode(',', IPSText::parseCleanValue($forum_ids)) : null;
     $view_as_guest = intval($view_as_guest);
     //-----------------------------------------
     // Authenticate
     //-----------------------------------------
     if ($this->__authenticate($api_key, $api_module, 'fetchForums') !== FALSE) {
         //-----------------------------------------
         // Add log
         //-----------------------------------------
         $this->addLogging($api_key);
         //-----------------------------------------
         // Get some classes
         //-----------------------------------------
         ipsRegistry::getAppClass('forums');
         //-----------------------------------------
         // Fetch forum list
         //-----------------------------------------
         $return = array();
         foreach ($forum_ids as $id) {
             $return[] = $this->registry->getClass('class_forums')->forumsFetchData($id);
         }
         //-----------------------------------------
         // Return the data
         //-----------------------------------------
         $this->classApiServer->apiSendReply($return);
         exit;
     }
 }
コード例 #4
0
ファイル: index.php プロジェクト: ConnorChristie/GrabViews
 /**
  * Handle posting a new reply
  * 
  * @return	string		XML
  */
 protected function _handlePostReply()
 {
     /* Check the form hash */
     if ($this->member->form_hash != $this->request['form_hash']) {
         $this->_returnError("Invalid Request");
     }
     $topic_forum = intval($this->request['f']);
     $topic_topic = intval($this->request['t']);
     ipsRegistry::getAppClass('forums');
     $classToLoad = IPSLib::loadLibrary(IPSLib::getAppDir('forums') . '/sources/classes/post/classPost.php', 'classPost');
     $this->registry->setClass('classPost', new $classToLoad(ipsRegistry::instance()));
     $this->registry->getClass('class_forums')->strip_invisible = true;
     $this->registry->getClass('class_forums')->forumsInit();
     //-----------------------------------------
     // Need the topic...
     //-----------------------------------------
     $topic = $this->registry->DB()->buildAndFetch(array('select' => '*', 'from' => 'topics', 'where' => 'tid=' . $topic_topic));
     $this->registry->classPost->setIsPreview(false);
     $this->registry->classPost->setForumData($this->registry->getClass('class_forums')->forum_by_id[$topic_forum]);
     $this->registry->classPost->setForumID($topic_forum);
     $this->registry->classPost->setTopicID($topic_topic);
     $this->registry->classPost->setTopicData($topic);
     $this->registry->classPost->setTopicTitle($_POST['title']);
     $this->registry->classPost->setPostContent($_POST['body']);
     $this->registry->classPost->setAuthor($this->memberData['member_id']);
     $this->registry->classPost->setPublished(true);
     $this->registry->classPost->setSettings(array('enableSignature' => 1, 'enableEmoticons' => 1, 'post_htmlstatus' => 0, 'enableTracker' => 0));
     try {
         if ($this->registry->classPost->addReply() === FALSE) {
             $this->_returnError("Reply could not be posted: " . $this->registry->classPost->getPostError());
         } else {
             $topic_id = $this->registry->classPost->getTopicData('tid');
             $post_id = $this->registry->classPost->getPostData('pid');
         }
     } catch (Exception $ex) {
         $this->_returnError("Error posting reply: " . $ex->getMessage());
     }
     require_once IPS_KERNEL_PATH . 'classXML.php';
     /*noLibHook*/
     $xml = new classXML('utf-8');
     $xml->newXMLDocument();
     $xml->addElement('topic');
     $xml->addElementAsRecord('topic', 'info', array('topic_id' => $topic_id));
     $xml->addElementAsRecord('topic', 'info', array('post_id' => $post_id));
     echo $xml->fetchDocument();
     exit;
 }
コード例 #5
0
 /**
  * Retrieve modcp tab based
  *
  * @return	@e void
  */
 protected function _getTab()
 {
     //-----------------------------------------
     // Init
     //-----------------------------------------
     ipsRegistry::getAppClass('forums');
     $app = trim($this->request['fromapp']);
     $plugin = trim($this->request['tab']);
     $moderator = $this->registry->class_forums->getModerator();
     $_output = '';
     //-----------------------------------------
     // Get plugin output
     //-----------------------------------------
     if (is_file(IPSLib::getAppDir($app) . '/extensions/modcp/plugin_' . $app . '_' . $plugin . '.php')) {
         $classToLoad = IPSLib::loadLibrary(IPSLib::getAppDir($app) . '/extensions/modcp/plugin_' . $app . '_' . $plugin . '.php', 'plugin_' . $app . '_' . $plugin, $app);
         $_thisPlugin = new $classToLoad($this->registry);
         $_output = $_thisPlugin->executePlugin($moderator);
     }
     //-----------------------------------------
     // Output
     //-----------------------------------------
     if ($_output) {
         $this->returnJsonArray(array('html' => $_output));
     } else {
         $this->returnJsonError($this->lang->words['plugin_not_found']);
     }
 }
コード例 #6
0
 /**
  * Parse/format the online list data for the records
  *
  * @author	Brandon Farber
  * @param	array 			Online list rows to check against
  * @return	array 			Online list rows parsed
  */
 public function parseOnlineEntries($rows)
 {
     if (!is_array($rows) or !count($rows)) {
         return $rows;
     }
     //-----------------------------------------
     // Init
     //-----------------------------------------
     $forums_raw = array();
     $forums = array();
     $topics_raw = array();
     $topics = array();
     $posts_raw = array();
     $posts = array();
     $final = array();
     //-----------------------------------------
     // Extract the topic/forum data
     //-----------------------------------------
     foreach ($rows as $row) {
         if ($row['current_appcomponent'] != 'forums' or !$row['current_module']) {
             continue;
         }
         if ($row['current_section'] == 'forums') {
             $forums_raw[$row['location_2_id']] = '';
         } else {
             if ($row['current_section'] == 'topics') {
                 $topics_raw[$row['location_1_id']] = $row['location_1_id'];
             } else {
                 if ($row['current_section'] == 'post') {
                     $forums_raw[$row['location_2_id']] = '';
                     $topics_raw[$row['location_1_id']] = $row['location_1_id'];
                 }
             }
         }
     }
     //-----------------------------------------
     // Get the forums, if you dare
     //-----------------------------------------
     ipsRegistry::getAppClass('forums');
     if (count($forums_raw)) {
         foreach (ipsRegistry::getClass('class_forums')->forum_by_id as $fid => $forum) {
             if (isset($forums_raw[$fid])) {
                 if (ipsRegistry::getClass('permissions')->check('view', $forum) !== false) {
                     $forums[$fid] = $forum['name'];
                 }
             }
         }
     }
     //-----------------------------------------
     // Get the topics, if you care
     //-----------------------------------------
     if (count($topics_raw)) {
         $_approved = ipsRegistry::getClass('class_forums')->fetchTopicHiddenQuery(array('visible'), 't.');
         ipsRegistry::DB()->build(array('select' => 't.*', 'from' => array('topics' => 't'), 'where' => $_approved . ' AND t.tid IN(' . implode(',', $topics_raw) . ') AND ' . ipsRegistry::getClass('permissions')->buildPermQuery('p'), 'add_join' => array(array('from' => array('permission_index' => 'p'), 'where' => "p.perm_type_id=t.forum_id AND p.app='forums' AND p.perm_type='forum'", 'type' => 'left'))));
         $tr = ipsRegistry::DB()->execute();
         while ($r = ipsRegistry::DB()->fetch($tr)) {
             $_forum = ipsRegistry::getClass('class_forums')->getForumByid($r['forum_id']);
             if (count($_forum) and ipsRegistry::getClass('class_forums')->forumsCheckAccess($_forum['id'], false, 'topic', $r, true)) {
                 if (ipsRegistry::getClass('permissions')->check('read', $_forum) !== false) {
                     if ($_forum['password'] == '' or IPSMember::isInGroup(ipsRegistry::member()->fetchMemberData(), explode(',', $_forum['password_override'])) or IPSCookie::get("ipbforumpass_{$_forum['id']}") == md5($_forum['password'])) {
                         $topics[$r['tid']] = $r['title'];
                     }
                 }
             }
         }
     }
     //-----------------------------------------
     // Put humpty dumpty together again
     //-----------------------------------------
     foreach ($rows as $row) {
         if ($row['current_appcomponent'] != 'forums') {
             $final[$row['id']] = $row;
             continue;
         }
         if (!$row['current_module']) {
             $row['where_line'] = ipsRegistry::getClass('class_localization')->words['board_index'];
             $final[$row['id']] = $row;
             continue;
         }
         if ($row['current_section'] == 'forums') {
             if (isset($forums[$row['location_2_id']])) {
                 $row['where_line'] = ipsRegistry::getClass('class_localization')->words['WHERE_sf'];
                 $row['where_line_more'] = $forums[$row['location_2_id']];
                 $row['where_link'] = 'showforum=' . $row['location_2_id'];
                 $row['_whereLinkSeo'] = ipsRegistry::getClass('output')->formatUrl(ipsRegistry::getClass('output')->buildUrl("showforum=" . $row['location_2_id'], 'public'), IPSText::makeSeoTitle($forums[$row['location_2_id']]), 'showforum');
             }
         } else {
             if ($row['current_section'] == 'topics') {
                 if (isset($topics[$row['location_1_id']])) {
                     $row['where_line'] = ipsRegistry::getClass('class_localization')->words['WHERE_st'];
                     $row['where_line_more'] = $topics[$row['location_1_id']];
                     $row['where_link'] = 'showtopic=' . $row['location_1_id'];
                     $row['_whereLinkSeo'] = ipsRegistry::getClass('output')->formatUrl(ipsRegistry::getClass('output')->buildUrl("showtopic=" . $row['location_1_id'], 'public'), IPSText::makeSeoTitle($topics[$row['location_1_id']]), 'showtopic');
                 }
             } else {
                 if ($row['current_section'] == 'post') {
                     if ($row['location_1_id']) {
                         if (isset($topics[$row['location_1_id']])) {
                             $row['where_line'] = ipsRegistry::getClass('class_localization')->words['WHERE_postrep'];
                             $row['where_line_more'] = $topics[$row['location_1_id']];
                             $row['where_link'] = 'showtopic=' . $row['location_1_id'];
                             $row['_whereLinkSeo'] = ipsRegistry::getClass('output')->formatUrl(ipsRegistry::getClass('output')->buildUrl("showtopic=" . $row['location_1_id'], 'public'), IPSText::makeSeoTitle($topics[$row['location_1_id']]), 'showtopic');
                         }
                     } else {
                         if ($row['location_2_id']) {
                             if (isset($forums[$row['location_2_id']])) {
                                 $row['where_line'] = ipsRegistry::getClass('class_localization')->words['WHERE_postnew'];
                                 $row['where_line_more'] = $forums[$row['location_2_id']];
                                 $row['where_link'] = 'showforum=' . $row['location_2_id'];
                                 $row['_whereLinkSeo'] = ipsRegistry::getClass('output')->formatUrl(ipsRegistry::getClass('output')->buildUrl("showforum=" . $row['location_2_id'], 'public'), IPSText::makeSeoTitle($forums[$row['location_2_id']]), 'showforum');
                             }
                         }
                     }
                 }
             }
         }
         $final[$row['id']] = $row;
     }
     return $final;
 }
コード例 #7
0
 /**
  * Constructor: calls parent init() method and runs other additional calls
  *
  * @return	@e void
  */
 public function __construct()
 {
     $this->init();
     /* Load forums app main class */
     ipsRegistry::getAppClass('forums');
 }
コード例 #8
0
 /**
  * Load all necessary properties
  *
  * @return	@e void
  */
 public function loadData()
 {
     //-----------------------------------------
     // Get forum libraries
     //-----------------------------------------
     ipsRegistry::getAppClass('forums');
     //-----------------------------------------
     // Make sure we're a moderator...
     //-----------------------------------------
     $pass = 0;
     if ($this->memberData['member_id']) {
         if ($this->memberData['g_is_supmod'] == 1) {
             $pass = 1;
         } else {
             if ($this->memberData['is_mod']) {
                 $other_mgroups = array();
                 $_other_mgroups = IPSText::cleanPermString($this->memberData['mgroup_others']);
                 if ($_other_mgroups) {
                     $other_mgroups = explode(",", $_other_mgroups);
                 }
                 $other_mgroups[] = $this->memberData['member_group_id'];
                 $this->DB->build(array('select' => '*', 'from' => 'moderators', 'where' => "(member_id='" . $this->memberData['member_id'] . "' OR (is_group=1 AND group_id IN(" . implode(",", $other_mgroups) . ")))"));
                 $this->DB->execute();
                 while ($this->moderator = $this->DB->fetch()) {
                     if ($this->moderator['allow_warn']) {
                         $pass = 1;
                     }
                 }
             }
         }
     }
     if (!$pass) {
         $this->registry->output->showError('warn_no_access', 2025, null, null, 403);
     }
     //-----------------------------------------
     // Ensure we have a valid member
     //-----------------------------------------
     $mid = intval($this->request['mid']);
     if ($mid < 1) {
         $this->registry->output->showError('warn_no_user', 10249, null, null, 404);
     }
     $this->warn_member = IPSMember::load($mid, 'all');
     if (!$this->warn_member['member_id']) {
         $this->registry->output->showError('warn_no_user', 10250, null, null, 404);
     }
     //-----------------------------------------
     // Get editor
     //-----------------------------------------
     $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/editor/composite.php', 'classes_editor_composite');
     $this->editor = new $classToLoad();
 }