Exemple #1
0
 /**
  * Class entry point
  *
  * @param	object		ipsRegistry reference
  * @return	@e void		[Outputs to screen]
  */
 public function doExecute(ipsRegistry $registry)
 {
     /* INIT */
     $smilie_id = 0;
     $editor_id = IPSText::alphanumericalClean($this->request['editor_id']);
     /* Query the emoticons */
     $this->DB->build(array('select' => 'typed, image', 'from' => 'emoticons', 'where' => "emo_set='" . $this->registry->output->skin['set_emo_dir'] . "'"));
     $this->DB->execute();
     /* Loop through and build output array */
     $rows = array();
     if ($this->DB->getTotalRows()) {
         while ($r = $this->DB->fetch()) {
             $smilie_id++;
             if (strstr($r['typed'], """)) {
                 $in_delim = "'";
                 $out_delim = '"';
             } else {
                 $in_delim = '"';
                 $out_delim = "'";
             }
             $rows[] = array('code' => stripslashes($r['typed']), 'image' => stripslashes($r['image']), 'in' => $in_delim, 'out' => $out_delim, 'smilie_id' => $smilie_id);
         }
     }
     /* Output */
     $this->returnHtml($this->registry->getClass('output')->getTemplate('legends')->emoticonPopUpList($editor_id, $rows));
 }
Exemple #2
0
 /**
  * Show the form
  *
  * @return	@e void		[Outputs to screen]
  */
 protected function show()
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $name = trim(IPSText::alphanumericalClean(ipsRegistry::$request['name']));
     $member_id = intval(ipsRegistry::$request['member_id']);
     $output = '';
     //-----------------------------------------
     // Get member data
     //-----------------------------------------
     $member = IPSMember::load($member_id, 'extendedProfile,customFields');
     //-----------------------------------------
     // Got a member?
     //-----------------------------------------
     if (!$member['member_id']) {
         $this->returnJsonError($this->lang->words['t_noid']);
     }
     //-----------------------------------------
     // Return the form
     //-----------------------------------------
     if (method_exists($this->html, $name)) {
         $output = $this->html->{$name}($member);
     }
     //-----------------------------------------
     // Print...
     //-----------------------------------------
     $this->returnHtml($output);
 }
Exemple #3
0
 /**
  * Refresh the captcha image
  *
  * @return	@e void		[Outputs to screen]
  */
 public function refresh()
 {
     $captcha_unique_id = trim(IPSText::alphanumericalClean(ipsRegistry::$request['captcha_unique_id']));
     $template = $this->registry->getClass('class_captcha')->getTemplate($captcha_unique_id);
     $newUniqueID = $this->registry->getClass('class_captcha')->captchaKey;
     $this->returnString($newUniqueID);
 }
Exemple #4
0
 /**
  * Class entry point
  *
  * @param	object		Registry reference
  * @return	@e void		[Outputs to screen]
  */
 public function doExecute(ipsRegistry $registry)
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $member_id = intval(ipsRegistry::$request['member_id']);
     $md5check = IPSText::md5Clean($this->request['md5check']);
     $CONFIG = array();
     $tab = explode(':', ipsRegistry::$request['tab']);
     $app = substr(IPSText::alphanumericalClean(str_replace('..', '', trim($tab[0]))), 0, 20);
     $tab = substr(IPSText::alphanumericalClean(str_replace('..', '', trim($tab[1]))), 0, 20);
     $this->registry->class_localization->loadLanguageFile(array('public_profile'), 'members');
     //-----------------------------------------
     // MD5 check
     //-----------------------------------------
     if ($md5check != $this->member->form_hash) {
         $this->returnString('error');
     }
     //-----------------------------------------
     // Load member
     //-----------------------------------------
     $member = IPSMember::load($member_id);
     //-----------------------------------------
     // Check
     //-----------------------------------------
     if (!$member['member_id']) {
         $this->returnString('error');
     }
     //-----------------------------------------
     // Load config
     //-----------------------------------------
     if (!is_file(IPSLib::getAppDir($app) . '/extensions/profileTabs/' . $tab . '.conf.php')) {
         $this->returnString('error');
     }
     require IPSLib::getAppDir($app) . '/extensions/profileTabs/' . $tab . '.conf.php';
     /*noLibHook*/
     //-----------------------------------------
     // Active?
     //-----------------------------------------
     if (!$CONFIG['plugin_enabled']) {
         $this->returnString('error');
     }
     //-----------------------------------------
     // Load main class...
     //-----------------------------------------
     if (!is_file(IPSLib::getAppDir($app) . '/extensions/profileTabs/' . $tab . '.php')) {
         $this->returnString('error');
     }
     require IPSLib::getAppDir('members') . '/sources/tabs/pluginParentClass.php';
     /*noLibHook*/
     $classToLoad = IPSLib::loadLibrary(IPSLib::getAppDir($app) . '/extensions/profileTabs/' . $tab . '.php', 'profile_' . $tab, $app);
     $plugin = new $classToLoad($this->registry);
     $html = $plugin->return_html_block($member);
     //-----------------------------------------
     // Return it...
     //-----------------------------------------
     $this->returnHtml($html);
 }
 /**
  * Run a task
  *
  * @access	public
  * @return	void
  */
 public function runTask()
 {
     if (ipsRegistry::$request['ck'] and ipsRegistry::$request['ck']) {
         $this->type = 'cron';
         $this->cron_key = substr(trim(stripslashes(IPSText::alphanumericalClean(ipsRegistry::$request['ck']))), 0, 32);
     }
     if ($this->type == 'internal') {
         //-----------------------------------------
         // Loaded by our image...
         // ... get next job
         //-----------------------------------------
         $this_task = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'task_manager', 'where' => 'task_enabled = 1 AND task_next_run <= ' . $this->time_now, 'order' => 'task_next_run ASC', 'limit' => array(0, 1)));
     } else {
         //-----------------------------------------
         // Cron.. load from cron key
         //-----------------------------------------
         $this_task = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'task_manager', 'where' => "task_cronkey='" . $this->cron_key . "'"));
     }
     if ($this_task['task_id']) {
         //-----------------------------------------
         // Locked?
         //-----------------------------------------
         if ($this_task['task_locked'] > 0) {
             # Yes - now, how long has it been locked for?
             # If longer than 30 mins, unlock as something
             # has gone wrong.
             if ($this_task['task_locked'] < time() - 1800) {
                 $newdate = $this->generateNextRun($this_task);
                 $this->DB->update('task_manager', array('task_next_run' => $newdate, 'task_locked' => 0), "task_id=" . $this_task['task_id']);
                 $this->saveNextRunStamp();
             }
             # Cancel and return
             return;
         }
         //-----------------------------------------
         // Got it, now update row, lock and run..
         //-----------------------------------------
         $newdate = $this->generateNextRun($this_task);
         $this->DB->update('task_manager', array('task_next_run' => $newdate, 'task_locked' => time()), "task_id=" . $this_task['task_id']);
         $this->saveNextRunStamp();
         if (file_exists(IPSLib::getAppDir($this_task['task_application']) . '/tasks/' . $this_task['task_file'])) {
             require_once IPSLib::getAppDir($this_task['task_application']) . '/tasks/' . $this_task['task_file'];
             $myobj = new task_item($this->registry, $this, $this_task);
             $myobj->runTask();
             //-----------------------------------------
             // Any shutdown queries
             //-----------------------------------------
             $this->DB->return_die = 0;
             if (count($this->DB->obj['shutdown_queries'])) {
                 foreach ($this->DB->obj['shutdown_queries'] as $q) {
                     $this->DB->query($q);
                 }
             }
             $this->DB->return_die = 1;
             $this->DB->obj['shutdown_queries'] = array();
         }
     }
 }
 /**
  * Class entry point
  *
  * @access	public
  * @param	object		Registry reference
  * @return	void		[Outputs to screen/redirects]
  */
 public function doExecute(ipsRegistry $registry)
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     if ($this->request['j_do']) {
         $this->request['do'] = $this->request['j_do'];
     }
     //-----------------------------------------
     // We offline?
     //-----------------------------------------
     if ($this->settings['board_offline']) {
         header("HTTP/1.1 503 Service Temporarily Unavailable");
         print $this->lang->words['rss_board_offline'];
         exit;
     }
     //-----------------------------------------
     // Grab the plugin
     //-----------------------------------------
     $type = 'forums';
     if ($this->request['type']) {
         if (file_exists(IPSLib::getAppDir(IPSText::alphanumericalClean($this->request['type'])) . '/extensions/rssOutput.php')) {
             $type = IPSText::alphanumericalClean($this->request['type']);
         }
     }
     //-----------------------------------------
     // And grab the content
     //-----------------------------------------
     require_once IPSLib::getAppDir($type) . '/extensions/rssOutput.php';
     $classname = "rss_output_" . $type;
     $rss_library = new $classname($this->registry);
     $this->to_print = $rss_library->returnRSSDocument();
     $expires = $rss_library->grabExpiryDate();
     //-----------------------------------------
     // Then output
     //-----------------------------------------
     @header('Content-Type: text/xml; charset=' . IPS_DOC_CHAR_SET);
     @header('Expires: ' . gmstrftime('%c', $expires) . ' GMT');
     @header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
     @header('Pragma: public');
     print $this->to_print;
     exit;
 }
 /**
  * Constructor
  *
  * @access	public
  * @param	object		ipsRegistry reference
  * @return	void
  */
 public function __construct($registry)
 {
     /* Make object */
     $this->registry = ipsRegistry::instance();
     $this->DB = $this->registry->DB();
     $this->settings =& $this->registry->fetchSettings();
     $this->request =& $this->registry->fetchRequest();
     $this->cache = $this->registry->cache();
     $this->caches =& $this->registry->cache()->fetchCaches();
     $this->_member = self::instance();
     $this->_memberData =& self::instance()->fetchMemberData();
     $this->_userAgent = substr($this->_member->user_agent, 0, 200);
     //-----------------------------------------
     // Fix up app / section / module
     //-----------------------------------------
     $this->current_appcomponent = IPS_APP_COMPONENT;
     $this->current_module = IPSText::alphanumericalClean($this->request['module']);
     $this->current_section = IPSText::alphanumericalClean($this->request['section']);
     $this->settings['session_expiration'] = $this->settings['session_expiration'] ? $this->settings['session_expiration'] : 60;
 }
 public function getName()
 {
     return $this->_skinSet['set_id'] . '__' . IPSText::alphanumericalClean($this->_skinSet['set_name']);
 }
Exemple #9
0
 /**
  * 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;
 }
Exemple #10
0
 public function getName()
 {
     if (strstr($this->_group, 'skin_')) {
         return preg_replace('#^skin_(.*)$#', '\\1', IPSText::alphanumericalClean($this->_group));
     } else {
         if ($this->_group == 'css') {
             return '0.css';
         }
     }
 }
 /**
  * Loads child extends class.
  *
  * @return	@e void
  */
 public function loadAttachmentPlugin()
 {
     /* INIT */
     $this->type = IPSText::alphanumericalClean($this->type);
     /* No plugin yet? Load it! */
     if (!is_object($this->plugin) && $this->type) {
         /* Load... */
         foreach (IPSLIb::getEnabledApplications() as $app) {
             if (is_file(IPSLib::getAppDir($app['app_directory']) . '/extensions/attachments/plugin_' . $this->type . '.php')) {
                 $classToLoad = IPSLib::loadLibrary(IPSLib::getAppDir($app['app_directory']) . '/extensions/attachments/plugin_' . $this->type . '.php', 'plugin_' . $this->type, $app['app_directory']);
                 $this->plugin = new $classToLoad($this->registry);
                 $this->plugin->getSettings();
                 /* Found it, stop */
                 break;
             }
         }
         /* Still here? Error out then.. */
         if (!is_object($this->plugin)) {
             print "Could not locate plugin {$this->type}";
             exit;
         }
     }
 }
Exemple #12
0
 /**
  * Class entry point
  *
  * @param	object		Registry reference
  * @return	@e void		[Outputs to screen/redirects]
  */
 public function doExecute(ipsRegistry $registry)
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     if ($this->request['j_do']) {
         $this->request['do'] = $this->request['j_do'];
     }
     //-----------------------------------------
     // We offline?
     //-----------------------------------------
     if ($this->settings['board_offline']) {
         if (isset($_SERVER['SERVER_PROTOCOL']) and strstr($_SERVER['SERVER_PROTOCOL'], '/1.0')) {
             header("HTTP/1.0 503 Service Temporarily Unavailable");
         } else {
             header("HTTP/1.1 503 Service Temporarily Unavailable");
         }
         print $this->lang->words['rss_board_offline'];
         exit;
     }
     //-----------------------------------------
     // Grab the plugin
     //-----------------------------------------
     $type = 'forums';
     if ($this->request['type']) {
         if (IPSLib::appIsInstalled(IPSText::alphanumericalClean($this->request['type']))) {
             if (is_file(IPSLib::getAppDir(IPSText::alphanumericalClean($this->request['type'])) . '/extensions/rssOutput.php')) {
                 $type = IPSText::alphanumericalClean($this->request['type']);
             }
         }
     }
     //-----------------------------------------
     // And grab the content
     //-----------------------------------------
     if (IPSLib::appIsInstalled($type)) {
         $classToLoad = IPSLib::loadLibrary(IPSLib::getAppDir($type) . '/extensions/rssOutput.php', 'rss_output_' . $type, $type);
         $rss_library = new $classToLoad($this->registry);
         $this->to_print = $rss_library->returnRSSDocument();
         $expires = $rss_library->grabExpiryDate();
     }
     //-----------------------------------------
     // No output?
     //-----------------------------------------
     if (!$this->to_print) {
         if (isset($_SERVER['SERVER_PROTOCOL']) and strstr($_SERVER['SERVER_PROTOCOL'], '/1.0')) {
             header("HTTP/1.0 503 Service Temporarily Unavailable");
         } else {
             header("HTTP/1.1 503 Service Temporarily Unavailable");
         }
         print $this->lang->words['rssappoffline'];
         exit;
     }
     //-----------------------------------------
     // Then output
     //-----------------------------------------
     @header('Content-Type: text/xml; charset=' . IPS_DOC_CHAR_SET);
     @header('Expires: ' . gmstrftime('%c', $expires) . ' GMT');
     @header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
     @header('Pragma: public');
     print $this->to_print;
     exit;
 }
Exemple #13
0
 /**
  * Fetch creator image
  *
  * @return	string (img URL)
  */
 public function creatorImage($status)
 {
     /* Got a creator? */
     if (!$status['status_creator']) {
         $status['status_creator'] = 'ipb';
     }
     $creator = IPSText::alphanumericalClean($status['status_creator']);
     /* Image exists? */
     if (!is_file(IPS_PUBLIC_PATH . 'style_status/' . $creator . '.png')) {
         $creator = 'ipb';
     }
     return $this->settings['public_dir'] . 'style_status/' . $creator . '.png';
 }
 /**
  * Main function for making reports and uses the custom plugins
  *
  * @access	private
  * @return	void
  */
 private function _initReportForm()
 {
     //-----------------------------------------
     // Make sure we have an rcom
     //-----------------------------------------
     $rcom = IPSText::alphanumericalClean($this->request['rcom']);
     if (!$rcom) {
         $this->registry->output->showError('reports_what_now', 10134);
     }
     //-----------------------------------------
     // Request plugin info from database
     //-----------------------------------------
     $row = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'rc_classes', 'where' => "my_class='{$rcom}' AND onoff=1"));
     if (!$row['com_id']) {
         $this->registry->output->showError('reports_what_now', 10135);
     } else {
         //-----------------------------------------
         // Can this group report this type of page?
         //-----------------------------------------
         if ($row['my_class'] == '' || count(array_diff($this->member_group_ids, explode(',', $row['group_can_report']))) >= count($this->member_group_ids)) {
             $this->registry->output->showError('reports_cant_report', 10136);
         }
         require_once IPSLib::getAppDir('core') . '/sources/classes/reportNotifications.php';
         $notify = new reportNotifications($this->registry);
         //-----------------------------------------
         // Let's get cooking! Load the plugin
         //-----------------------------------------
         $this->registry->getClass('reportLibrary')->loadPlugin($row['my_class']);
         //-----------------------------------------
         // Process 'extra data' for the plugin
         //-----------------------------------------
         if ($row['extra_data'] && $row['extra_data'] != 'N;') {
             $this->registry->getClass('reportLibrary')->plugins[$row['my_class']]->_extra = unserialize($row['extra_data']);
         } else {
             $this->registry->getClass('reportLibrary')->plugins[$row['my_class']]->_extra = array();
         }
         $send_code = intval($this->request['send']);
         if ($send_code == 0) {
             //-----------------------------------------
             // Request report form from plugin
             //-----------------------------------------
             $this->output .= $this->registry->getClass('reportLibrary')->plugins[$row['my_class']]->reportForm($row);
         } else {
             //-----------------------------------------
             // Form key not valid
             //-----------------------------------------
             if ($this->request['k'] != $this->member->form_hash) {
                 $this->registry->getClass('output')->showError('no_permission', 20114);
             }
             //-----------------------------------------
             // Empty report
             //-----------------------------------------
             if (!trim(strip_tags($this->request['message']))) {
                 $this->registry->output->showError('reports_cant_empty', 10181);
             }
             //-----------------------------------------
             // Sending report... do necessary things
             //-----------------------------------------
             $report_data = $this->registry->getClass('reportLibrary')->plugins[$row['my_class']]->processReport($row);
             $this->registry->getClass('reportLibrary')->updateCacheTime();
             //-----------------------------------------
             // Send out notfications...
             //-----------------------------------------
             $notify->initNotify($this->registry->getClass('reportLibrary')->plugins[$row['my_class']]->getNotificationList(substr($row['mod_group_perm'], 1, strlen($row['mod_group_perm']) - 2), $report_data), $report_data);
             $notify->sendNotifications();
             //-----------------------------------------
             // Redirect...
             //-----------------------------------------
             $this->registry->getClass('reportLibrary')->plugins[$row['my_class']]->reportRedirect($report_data);
         }
     }
 }
 /**
  * Export skin and languages
  * 
  * @return	@e void
  */
 public function exportSkinLang()
 {
     /* INIT */
     $start = intval($this->request['st']);
     $converted = 0;
     $options = IPSSetUp::getSavedData('custom_options');
     $_doSkin = $options['core'][30001]['exportSkins'];
     $_doLang = $options['core'][30001]['exportLangs'];
     /* Doing anything? */
     if (!$_doSkin and !$_doLang) {
         $this->registry->output->addMessage("Нечего экспортировать");
         /* Next Page */
         $this->request['workact'] = 'pms';
         return;
     }
     /* Ok... */
     if (!$start) {
         /* Do langs.. */
         if ($_doLang) {
             if (!is_dir(IPS_CACHE_PATH . 'cache/previousLangFiles')) {
                 if (@mkdir(IPS_CACHE_PATH . 'cache/previousLangFiles', IPS_FOLDER_PERMISSION)) {
                     @chmod(IPS_CACHE_PATH . 'cache/previousLangFiles', IPS_FOLDER_PERMISSION);
                 }
             }
             try {
                 foreach (new DirectoryIterator(IPS_CACHE_PATH . 'cache/lang_cache') as $file) {
                     if (!$file->isDot() and $file->isDir()) {
                         $name = $file->getFilename();
                         if (substr($name, 0, 1) != '.') {
                             $this->registry->output->addMessage("Перенесена директория языка: {$name}");
                             @rename(IPS_CACHE_PATH . 'cache/lang_cache/' . $name, IPS_CACHE_PATH . 'cache/previousLangFiles/' . $name);
                         }
                     }
                 }
             } catch (Exception $e) {
             }
         }
     }
     /* Doing skins? */
     if ($_doSkin) {
         $this->DB->build(array('select' => '*', 'from' => 'skin_sets', 'where' => 'set_skin_set_id > ' . $start, 'limit' => array(0, 1), 'order' => 'set_skin_set_id ASC'));
         $this->DB->execute();
         $set = $this->DB->fetch();
         if (!$set) {
             $this->request['st'] = 0;
             /* All done.. */
             $this->registry->output->addMessage("Все стили обработаны");
             /* Next Page */
             $this->request['workact'] = 'pms';
             return;
         } else {
             if (!is_dir(IPS_CACHE_PATH . 'cache/previousSkinFiles')) {
                 if (@mkdir(IPS_CACHE_PATH . 'cache/previousSkinFiles', IPS_FOLDER_PERMISSION)) {
                     @chmod(IPS_CACHE_PATH . 'cache/previousSkinFiles', IPS_FOLDER_PERMISSION);
                 }
             }
             $safeName = IPSText::alphanumericalClean($set['set_name']);
             $dirPath = IPS_CACHE_PATH . 'cache/previousSkinFiles/' . $safeName;
             if (@mkdir($dirPath, IPS_FOLDER_PERMISSION)) {
                 @chmod($dirPath, IPS_FOLDER_PERMISSION);
             }
             if (is_dir($dirPath)) {
                 /* Export CSS */
                 if (@mkdir($dirPath . '/css', IPS_FOLDER_PERMISSION)) {
                     @chmod($dirPath . '/css', IPS_FOLDER_PERMISSION);
                 }
                 @file_put_contents($dirPath . '/css/css.css', $set['set_cache_css']);
                 /* Export Wrapper */
                 if (@mkdir($dirPath . '/wrapper', IPS_FOLDER_PERMISSION)) {
                     @chmod($dirPath . '/wrapper', IPS_FOLDER_PERMISSION);
                 }
                 @file_put_contents($dirPath . '/wrapper/wrapper.html', $set['set_wrapper']);
                 /* Export Templates */
                 if (@mkdir($dirPath . '/templates', IPS_FOLDER_PERMISSION)) {
                     @chmod($dirPath . '/templates', IPS_FOLDER_PERMISSION);
                 }
                 $this->DB->build(array('select' => '*', 'from' => 'skin_templates_old', 'where' => 'set_id=' . $set['set_skin_set_id'], 'order' => 'func_name ASC'));
                 $this->DB->execute();
                 while ($row = $this->DB->fetch()) {
                     $_groupName = IPSText::alphanumericalClean($row['group_name']);
                     $_bitName = IPSText::alphanumericalClean($row['func_name']);
                     /* Make section dir */
                     if (@mkdir($dirPath . '/templates/' . $_groupName, IPS_FOLDER_PERMISSION)) {
                         @chmod($dirPath . '/templates/' . $_groupName, IPS_FOLDER_PERMISSION);
                     }
                     @file_put_contents($dirPath . '/templates/' . $_groupName . '/' . $_bitName . '.html', $row['section_content']);
                 }
             }
             /* Set ID */
             $this->request['st'] = $set['set_skin_set_id'];
             /* We did some, go check again.. */
             $this->registry->output->addMessage($set['set_name'] . " Exported");
             /* Next Page */
             $this->request['workact'] = 'skinlang';
             return;
         }
     }
     /* We did some, go check again.. */
     $this->registry->output->addMessage('Нет языков или стилей для экспорта');
     /* Next Page */
     $this->request['workact'] = 'pms';
     return;
 }
 /**
  * Validation completion.  This is the action hit when a user clicks a validation link from their email for
  * lost password, email change and new registration.
  *
  * @access	private
  * @return	void
  */
 private function _autoValidate()
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $in_user_id = intval(trim(urldecode($this->request['uid'])));
     $in_validate_key = substr(IPSText::alphanumericalClean(urldecode($this->request['aid'])), 0, 32);
     $in_type = trim($this->request['type']);
     $in_type = $in_type ? $in_type : 'reg';
     //-----------------------------------------
     // Attempt to get the profile of the requesting user
     //-----------------------------------------
     $member = IPSMember::load($in_user_id, 'members');
     if (!$member['member_id']) {
         $this->_showManualForm($in_type, 'reg_error_validate');
         return;
     }
     //-----------------------------------------
     // Get validating info..
     //-----------------------------------------
     if ($in_type == 'lostpass') {
         $validate = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'validating', 'where' => 'member_id=' . $in_user_id . " AND lost_pass=1"));
     } else {
         if ($in_type == 'newemail') {
             $validate = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'validating', 'where' => 'member_id=' . $in_user_id . " AND email_chg=1"));
         } else {
             $validate = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'validating', 'where' => 'member_id=' . $in_user_id));
         }
     }
     //-----------------------------------------
     // Checks...
     //-----------------------------------------
     if (!$validate['member_id']) {
         $this->registry->output->showError('no_validate_key', 10120);
     }
     if ($validate['new_reg'] == 1 && $this->settings['reg_auth_type'] == "admin") {
         $this->registry->output->showError('validate_admin_turn', 10121);
     }
     if ($validate['vid'] != $in_validate_key) {
         $this->registry->output->showError('validation_key_invalid', 10122);
     }
     //-----------------------------------------
     // Captcha (from posted form, not GET)
     //-----------------------------------------
     if ($this->settings['use_captcha'] and $this->request['uid']) {
         if ($this->registry->getClass('class_captcha')->validate($this->request['captcha_unique_id'], $this->request['captcha_input']) !== TRUE) {
             $this->_showManualForm($in_type, 'reg_error_anti_spam');
             return;
         }
     }
     //-----------------------------------------
     // REGISTER VALIDATE
     //-----------------------------------------
     if ($validate['new_reg'] == 1) {
         if (!$validate['real_group']) {
             $validate['real_group'] = $this->settings['member_group'];
         }
         //-----------------------------------------
         // SELF-VERIFICATION...
         //-----------------------------------------
         if ($this->settings['reg_auth_type'] != 'admin_user') {
             IPSMember::save($member['member_id'], array('members' => array('member_group_id' => $validate['real_group'])));
             /* Reset newest member */
             $stat_cache = $this->caches['stats'];
             if ($member['members_display_name'] and $member['member_id']) {
                 $stat_cache['last_mem_name'] = $member['members_display_name'];
                 $stat_cache['last_mem_id'] = $member['member_id'];
             }
             $stat_cache['mem_count'] += 1;
             $this->cache->setCache('stats', $stat_cache, array('array' => 1, 'deletefirst' => 0));
             //-----------------------------------------
             // Remove "dead" validation
             //-----------------------------------------
             $this->DB->delete('validating', "vid='" . $validate['vid'] . "'");
             $this->registry->output->silentRedirect($this->settings['base_url'] . '&app=core&module=global&section=login&do=autologin&fromreg=1');
         } else {
             //-----------------------------------------
             // Update DB row...
             //-----------------------------------------
             $this->DB->update('validating', array('user_verified' => 1), 'vid="' . $validate['vid'] . '"');
             //-----------------------------------------
             // Print message
             //-----------------------------------------
             $this->registry->output->setTitle($this->lang->words['validation_complete']);
             $this->output = $this->registry->getClass('output')->getTemplate('register')->showPreview($member);
         }
     } else {
         if ($validate['lost_pass'] == 1) {
             //-----------------------------------------
             // INIT
             //-----------------------------------------
             $save_array = array();
             //-----------------------------------------
             // Generate a new random password
             //-----------------------------------------
             $new_pass = IPSLib::makePassword();
             //-----------------------------------------
             // Generate a new salt
             //-----------------------------------------
             $salt = IPSMember::generatePasswordSalt(5);
             $salt = str_replace('\\', "\\\\", $salt);
             //-----------------------------------------
             // New log in key
             //-----------------------------------------
             $key = IPSMember::generateAutoLoginKey();
             //-----------------------------------------
             // Update...
             //-----------------------------------------
             $save_array['members_pass_salt'] = $salt;
             $save_array['members_pass_hash'] = md5(md5($salt) . md5($new_pass));
             $save_array['member_login_key'] = $key;
             $save_array['member_login_key_expire'] = $this->settings['login_key_expire'] * 60 * 60 * 24;
             //-----------------------------------------
             // Load handler...
             //-----------------------------------------
             require_once IPS_ROOT_PATH . 'sources/handlers/han_login.php';
             $this->han_login = new han_login($this->registry);
             $this->han_login->init();
             $this->han_login->changePass($member['email_address'], md5($new_pass));
             if ($this->han_login->return_code != 'METHOD_NOT_DEFINED' and $this->han_login->return_code != 'SUCCESS') {
                 $this->registry->output->showError('lostpass_external_fail', 2015, true);
             }
             IPSMember::save($member['member_id'], array('members' => $save_array));
             //-----------------------------------------
             // Send out the email...
             //-----------------------------------------
             IPSText::getTextClass('email')->getTemplate("lost_pass_email_pass");
             IPSText::getTextClass('email')->buildMessage(array('NAME' => $member['members_display_name'], 'THE_LINK' => $this->settings['base_url'] . 'app=core&module=usercp&tab=core&area=password', 'PASSWORD' => $new_pass, 'LOGIN' => $this->settings['base_url'] . 'app=core&module=global&section=login', 'USERNAME' => $member['name'], 'EMAIL' => $member['email'], 'ID' => $member['member_id']));
             IPSText::getTextClass('email')->subject = $this->lang->words['lp_random_pass_subject'] . ' ' . $this->settings['board_name'];
             IPSText::getTextClass('email')->to = $member['email'];
             IPSText::getTextClass('email')->sendMail();
             $this->registry->output->setTitle($this->lang->words['validation_complete']);
             //-----------------------------------------
             // Remove "dead" validation
             //-----------------------------------------
             $this->DB->delete('validating', "vid='" . $validate['vid'] . "' OR (member_id={$member['member_id']} AND lost_pass=1)");
             $this->output = $this->registry->getClass('output')->getTemplate('register')->showLostPassWaitRandom($member);
         } else {
             if ($validate['email_chg'] == 1) {
                 if (!$validate['real_group']) {
                     $validate['real_group'] = $this->settings['member_group'];
                 }
                 IPSMember::save($member['member_id'], array('members' => array('member_group_id' => intval($validate['real_group']))));
                 IPSCookie::set("member_id", $member['member_id'], 1);
                 IPSCookie::set("pass_hash", $member['member_login_key'], 1);
                 //-----------------------------------------
                 // Remove "dead" validation
                 //-----------------------------------------
                 $this->DB->delete('validating', "vid='" . $validate['vid'] . "' OR (member_id={$member['member_id']} AND email_chg=1)");
                 $this->registry->output->silentRedirect($this->settings['base_url'] . '&app=core&module=global&section=login&do=autologin&fromemail=1');
             }
         }
     }
 }
Exemple #17
0
 /**
  * Show the form
  *
  * @return	@e void		[Outputs to screen]
  */
 protected function show()
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $name = trim(IPSText::alphanumericalClean($this->request['name']));
     $this->hookId = intval($this->request['id']);
     $this->hook = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'core_hooks', 'where' => 'hook_id=' . $this->hookId));
     $this->data = unserialize($this->hook['hook_extra_data']);
     $output = '';
     //-----------------------------------------
     // Got a member?
     //-----------------------------------------
     if (!$this->hook['hook_id']) {
         $this->returnJsonError($this->lang->words['hook_cannot_load']);
     }
     //-----------------------------------------
     // Run the proper operation
     //-----------------------------------------
     switch ($name) {
         case 'settings':
             $_settingGroups = $this->hooksFunctions->getSettingGroups();
             $_settings = $this->hooksFunctions->getSettings();
             $form = array();
             $form['groups'] = $this->registry->output->formMultiDropdown("setting_groups[]", $_settingGroups, $this->data['settingGroups'], 5, "setting_groups");
             $form['settings'] = $this->registry->output->formMultiDropdown("settings[]", $_settings, $this->data['settings'], 5, "settings");
             $output = $this->html->inline_settings($this->hook, $form);
             break;
         case 'languages':
             // We'll show the lang files and let them select lang file, then select strings, then they can repeat
             $_langFiles = $this->hooksFunctions->getLanguageFiles();
             $i = 1;
             $form = array();
             if (count($this->data['language'])) {
                 foreach ($this->data['language'] as $file => $strings) {
                     $form["language_file_{$i}"] = $this->registry->output->formDropdown("language_{$i}", $_langFiles, $file, "language_{$i}", "onchange='acp.hooks.generateStrings({$i});'");
                     $_strings = $this->hooksFunctions->getStrings($file);
                     $form["language_strings_{$i}"] = $this->registry->output->formMultiDropdown("strings_{$i}[]", $_strings, $strings, 5, "strings_{$i}", "", "' style='width: 100%'");
                     $i++;
                 }
             }
             $form["language_file_{$i}"] = $this->registry->output->formDropdown("language_{$i}", $_langFiles, null, "language_{$i}", "onchange='acp.hooks.generateStrings({$i});'");
             $output = $this->html->inline_languages($this->hook, $form, $i);
             break;
         case 'modules':
             $_modules = $this->hooksFunctions->getModules();
             $form = array();
             $form['modules'] = $this->registry->output->formMultiDropdown("modules[]", $_modules, $this->data['modules'], 5, "modules");
             $output = $this->html->inline_modules($this->hook, $form);
             break;
         case 'help':
             $_help = $this->hooksFunctions->getHelpFiles();
             $form = array();
             $form['help'] = $this->registry->output->formMultiDropdown("help[]", $_help, $this->data['help'], 5, "help");
             $output = $this->html->inline_help($this->hook, $form);
             break;
         case 'skins':
             // We'll show the skin groups and let them select skin file, then select templates, then they can repeat
             $_skinFiles = $this->hooksFunctions->getSkinGroups();
             $i = 1;
             $form = array();
             if (count($this->data['templates'])) {
                 foreach ($this->data['templates'] as $file => $methods) {
                     $form["skin_file_{$i}"] = $this->registry->output->formDropdown("skin_{$i}", $_skinFiles, $file, "skin_{$i}", "onchange='acp.hooks.generateTemplates({$i});'");
                     $_methods = $this->hooksFunctions->getSkinMethods($file);
                     $form["skin_method_{$i}"] = $this->registry->output->formMultiDropdown("templates_{$i}[]", $_methods, $methods, 5, "templates_{$i}", "", "' style='width: 100%'");
                     $i++;
                 }
             }
             $form["skin_file_{$i}"] = $this->registry->output->formDropdown("skin_{$i}", $_skinFiles, null, "skin_{$i}", "onchange='acp.hooks.generateTemplates({$i});'");
             $output = $this->html->inline_skins($this->hook, $form, $i);
             break;
         case 'css':
             $_cssFiles = $this->hooksFunctions->getCSSFiles();
             $form = array();
             $form['css'] = $this->registry->output->formMultiDropdown("css[]", $_cssFiles, $this->data['css'], 5, "css");
             $output = $this->html->inline_css($this->hook, $form);
             break;
         case 'replacements':
             $_replacements = $this->hooksFunctions->getSkinReplacements();
             $form = array();
             $form['replacements'] = $this->registry->output->formMultiDropdown("replacements[]", $_replacements, $this->data['replacements'], 5, "replacements");
             $output = $this->html->inline_replacements($this->hook, $form);
             break;
         case 'tasks':
             $_tasks = $this->hooksFunctions->getTasks();
             $form = array();
             $form['tasks'] = $this->registry->output->formMultiDropdown("tasks[]", $_tasks, $this->data['tasks'], 5, "tasks");
             $output = $this->html->inline_tasks($this->hook, $form);
             break;
         case 'database':
             // First we'll show their current DB changes, then give them a dropdown to add another
             $i = 1;
             $form = array();
             $types = array(array('0', $this->lang->words['hook_db_select']), array('create', $this->lang->words['hook_db_create']), array('alter', $this->lang->words['hook_db_alter']), array('update', $this->lang->words['hook_db_update']), array('insert', $this->lang->words['hook_db_insert']));
             $alters = array(array('add', $this->lang->words['hook_db_addnew']), array('change', $this->lang->words['hook_db_change']), array('remove', $this->lang->words['hook_db_drop']));
             if (count($this->data['database'])) {
                 foreach ($this->data['database'] as $type => $data) {
                     foreach ($data as $change) {
                         $form["type_{$i}"] = $this->registry->output->formDropdown("type_{$i}", $types, $type, "type_{$i}", "onchange='acp.hooks.generateFields({$i});'");
                         switch ($type) {
                             case 'create':
                                 $form['field_1_' . $i] = $this->registry->output->formInput("name_{$i}", $change['name']);
                                 $form['description_1_' . $i] = $this->lang->words['desc_newtable'];
                                 $form['field_2_' . $i] = $this->registry->output->formTextarea("fields_{$i}", htmlspecialchars($change['fields'], ENT_QUOTES));
                                 $form['description_2_' . $i] = $this->lang->words['desc_fieldnames'];
                                 $form['field_3_' . $i] = $this->registry->output->formInput("tabletype_{$i}", $change['tabletype']);
                                 $form['description_4_' . $i] = $this->lang->words['desc_tabletype'];
                                 break;
                             case 'alter':
                                 $form['field_1_' . $i] = $this->registry->output->formDropdown("altertype_{$i}", $alters, $change['altertype']);
                                 $form['description_1_' . $i] = $this->lang->words['desc_altertype'];
                                 $form['field_2_' . $i] = $this->registry->output->formInput("table_{$i}", $change['table']);
                                 $form['description_2_' . $i] = $this->lang->words['desc_newtable'];
                                 $form['field_3_' . $i] = $this->registry->output->formInput("field_{$i}", $change['field']);
                                 $form['description_3_' . $i] = $this->lang->words['desc_field'];
                                 $form['field_4_' . $i] = $this->registry->output->formInput("newfield_{$i}", $change['newfield']);
                                 $form['description_4_' . $i] = $this->lang->words['desc_changefield'];
                                 $form['field_5_' . $i] = $this->registry->output->formInput("fieldtype_{$i}", $change['fieldtype']);
                                 $form['description_5_' . $i] = $this->lang->words['desc_definition'];
                                 $form['field_6_' . $i] = $this->registry->output->formInput("default_{$i}", htmlspecialchars($change['default'], ENT_QUOTES));
                                 $form['description_6_' . $i] = $this->lang->words['desc_defaultvalue'];
                                 break;
                             case 'update':
                                 $form['field_1_' . $i] = $this->registry->output->formInput("table_{$i}", $change['table']);
                                 $form['description_1_' . $i] = $this->lang->words['desc_newtable'];
                                 $form['field_2_' . $i] = $this->registry->output->formInput("field_{$i}", $change['field']);
                                 $form['description_2_' . $i] = $this->lang->words['desc_field'];
                                 $form['field_3_' . $i] = $this->registry->output->formInput("newvalue_{$i}", htmlspecialchars($change['newvalue'], ENT_QUOTES));
                                 $form['description_3_' . $i] = $this->lang->words['desc_newvalue'];
                                 $form['field_4_' . $i] = $this->registry->output->formInput("oldvalue_{$i}", htmlspecialchars($change['oldvalue'], ENT_QUOTES));
                                 $form['description_4_' . $i] = $this->lang->words['desc_oldvalue'];
                                 $form['field_5_' . $i] = $this->registry->output->formInput("where_{$i}", htmlspecialchars($change['where'], ENT_QUOTES));
                                 $form['description_5_' . $i] = $this->lang->words['desc_where'];
                                 break;
                             case 'insert':
                                 $form['field_1_' . $i] = $this->registry->output->formInput("table_{$i}", $change['table']);
                                 $form['description_1_' . $i] = $this->lang->words['desc_newtable'];
                                 $form['field_2_' . $i] = $this->registry->output->formTextarea("updates_{$i}", htmlspecialchars($change['updates'], ENT_QUOTES));
                                 $form['description_2_' . $i] = $this->lang->words['desc_data'];
                                 $form['field_3_' . $i] = $this->registry->output->formInput("fordelete_{$i}", htmlspecialchars($change['fordelete'], ENT_QUOTES));
                                 $form['description_3_' . $i] = $this->lang->words['desc_revert'];
                                 break;
                         }
                         $i++;
                     }
                 }
             }
             $form["type_{$i}"] = $this->registry->output->formDropdown("type_{$i}", $types, null, "type_{$i}", "onchange='acp.hooks.generateFields({$i});'");
             $output = $this->html->inline_database($this->hook, $form, $i);
             break;
         case 'custom':
             $form = array();
             $form['custom'] = $this->registry->output->formInput("custom", $this->data['custom']);
             $output = $this->html->inline_custom($this->hook, $form);
             break;
     }
     //-----------------------------------------
     // Print...
     //-----------------------------------------
     $this->returnHtml($output);
 }
 /**
  * Show the form
  *
  * @return	@e void		[Outputs to screen]
  */
 protected function show()
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $name = trim(IPSText::alphanumericalClean($this->request['name']));
     $member_id = intval($this->request['member_id']);
     $output = '';
     //-----------------------------------------
     // Load language and skin
     //-----------------------------------------
     $html = $this->registry->output->loadTemplate('cp_skin_member_form');
     $this->lang->loadLanguageFile(array('admin_member'));
     //-----------------------------------------
     // Get member data
     //-----------------------------------------
     $member = IPSMember::load($member_id, 'extendedProfile,customFields');
     //-----------------------------------------
     // Got a member?
     //-----------------------------------------
     if (!$member['member_id']) {
         $this->returnJsonError($this->lang->words['m_noid']);
     }
     //-----------------------------------------
     // Return the form
     //-----------------------------------------
     if (method_exists($html, $name)) {
         $output = $html->{$name}($member);
     } else {
         $save_to = '';
         $div_id = '';
         $form_field = '';
         $text = '';
         $description = '';
         $method = '';
         switch ($name) {
             case 'inline_ban_member':
                 if (!$this->registry->getClass('class_permissions')->checkPermission('member_ban', 'members', 'members')) {
                     $this->returnJsonError($this->lang->words['m_noban']);
                 }
                 if ($member['g_access_cp'] and !$this->registry->getClass('class_permissions')->checkPermission('member_ban_admin', 'members', 'members')) {
                     $this->returnJsonError($this->lang->words['m_noban']);
                 }
                 //-----------------------------------------
                 // INIT
                 //-----------------------------------------
                 $ban_filters = array('email' => array(), 'name' => array(), 'ip' => array());
                 $email_banned = false;
                 $ip_banned = array();
                 $name_banned = false;
                 //-----------------------------------------
                 // Grab existing ban filters
                 //-----------------------------------------
                 $this->DB->build(array('select' => '*', 'from' => 'banfilters'));
                 $this->DB->execute();
                 while ($r = $this->DB->fetch()) {
                     $ban_filters[$r['ban_type']][] = $r['ban_content'];
                 }
                 //-----------------------------------------
                 // Check name and email address
                 //-----------------------------------------
                 if (in_array($member['email'], $ban_filters['email'])) {
                     $email_banned = true;
                 }
                 if (in_array($member['name'], $ban_filters['name'])) {
                     $name_banned = true;
                 }
                 //-----------------------------------------
                 // Retrieve IP addresses
                 //-----------------------------------------
                 $ip_addresses = IPSMember::findIPAddresses($member['member_id']);
                 //-----------------------------------------
                 // Start form fields
                 //-----------------------------------------
                 $form['member'] = ipsRegistry::getClass('output')->formCheckbox("ban__member", $member['member_banned']);
                 $form['email'] = ipsRegistry::getClass('output')->formCheckbox("ban__email", $email_banned);
                 $form['name'] = ipsRegistry::getClass('output')->formCheckbox("ban__name", $name_banned);
                 $form['note'] = ipsRegistry::getClass('output')->formCheckbox("ban__note", 0);
                 $form['note_field'] = ipsRegistry::getClass('output')->formTextarea("ban__note_field");
                 $form['ips'] = array();
                 //-----------------------------------------
                 // What about IPs?
                 //-----------------------------------------
                 if (is_array($ip_addresses) and count($ip_addresses)) {
                     foreach ($ip_addresses as $ip_address => $count) {
                         if (in_array($ip_address, $ban_filters['ip'])) {
                             $form['ips'][$ip_address] = ipsRegistry::getClass('output')->formCheckbox("ban__ip_" . str_replace('.', '_', $ip_address), true);
                         } else {
                             $form['ips'][$ip_address] = ipsRegistry::getClass('output')->formCheckbox("ban__ip_" . str_replace('.', '_', $ip_address), false);
                         }
                     }
                 }
                 $member_groups = array();
                 foreach (ipsRegistry::cache()->getCache('group_cache') as $group) {
                     if ($group['g_id'] == $member['member_group_id']) {
                         $member['_group_title'] = $group['g_title'];
                     }
                     /* If it's an admin group, make sure the admin banning can promote to this group */
                     if ($group['g_access_cp'] and !$this->registry->getClass('class_permissions')->checkPermission('member_move_admin2')) {
                         continue;
                     }
                     $member_groups[] = array($group['g_id'], $group['g_title']);
                 }
                 $form['groups_confirm'] = ipsRegistry::getClass('output')->formCheckbox("ban__group_change", 0);
                 $form['groups'] = ipsRegistry::getClass('output')->formDropdown("ban__group", $member_groups, $member['member_group_id']);
                 $output = $html->inline_ban_member_form($member, $form);
                 break;
         }
         if (!$output and $method and method_exists($html, $method)) {
             $output = $html->{$method}($member, $save_to, $div_id, $form_field, $text, $description);
         }
     }
     //-----------------------------------------
     // Print...
     //-----------------------------------------
     $this->returnHtml($output);
 }
 /**
  * Add content to the document <head>
  *
  * @access	public
  * @param	string		Type of data to add: inlinecss, importcss, js, javascript, raw, rss, rsd, etc
  * @param	string		Data to add
  * @return	@e void
  */
 public function addToDocumentHead($type, $data)
 {
     if ($type == 'js') {
         $type = 'javascript';
     }
     if ($type == 'inlinecss') {
         $this->_css['inline'][] = array('content' => $data);
     } else {
         if ($type == 'importcss') {
             //-----------------------------------------
             // Use $data as key to prevent CSS being
             // included more than once (breaks Minify)
             //-----------------------------------------
             if ($this->_usingSafeModeSkins and !IN_ACP) {
                 $path = preg_replace('#^(.*)/(style_css/.*)$#', '\\2', $data);
                 if ($this->settings['assume_css_written']) {
                     $this->_css['import'][$data] = array('content' => $data);
                 } else {
                     if (@is_file(IPS_PUBLIC_PATH . $path)) {
                         $this->_css['import'][$data] = array('content' => $data);
                     } else {
                         /* Bug #33264 - If safe mode is on then we are going to have to load from DB. I hope you're happy safe mode users! */
                         $cssName = IPSText::alphanumericalClean(@str_replace('.css', '', @array_pop(@explode('/', $data))), '-_');
                         if ($cssName) {
                             $cssData = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'skin_cache', 'where' => "cache_set_id=" . intval($this->skin['set_id']) . " AND cache_type='css' and cache_value_1='" . $this->DB->addSlashes($cssName) . "'"));
                             if ($cssData['cache_content']) {
                                 return $this->addToDocumentHead('inlinecss', $this->parseIPSTags($cssData['cache_content']));
                             }
                         }
                     }
                 }
             } else {
                 $this->_css['import'][$data] = array('content' => $data);
             }
         } else {
             $this->_documentHeadItems[$type][] = $data;
         }
     }
 }
Exemple #20
0
 /**
  * Check against XSS
  *
  * NOTE: When this function is updated, please also update classIncomingEmail::cleanMessage()
  *
  * @access	public
  * @param	string		Original string
  * @param	boolean		Fix script HTML tags
  * @return	string		"Cleaned" text
  */
 public function checkXss($txt = '', $fixScript = false, $tag = '')
 {
     //-----------------------------------------
     // Opening script tags...
     // Check for spaces and new lines...
     //-----------------------------------------
     if ($fixScript) {
         $txt = preg_replace('#<(\\s+?)?s(\\s+?)?c(\\s+?)?r(\\s+?)?i(\\s+?)?p(\\s+?)?t#is', "&lt;script", $txt);
         $txt = preg_replace('#<(\\s+?)?/(\\s+?)?s(\\s+?)?c(\\s+?)?r(\\s+?)?i(\\s+?)?p(\\s+?)?t#is', "&lt;/script", $txt);
     }
     /* got a tag? */
     if ($tag) {
         $tag = strip_tags($tag, '<br>');
         switch ($tag) {
             case 'entry':
             case 'blog':
             case 'topic':
             case 'post':
                 $test = str_replace(array('"', "'", '&quot;', '&#39;'), "", $txt);
                 if (!is_numeric($test)) {
                     $txt = false;
                 }
                 break;
             case 'acronym':
                 $test = str_replace(array('"', "'", '&quot;', '&#39;'), "", $txt);
                 $test1 = str_replace(array('<', ">", '[', ']'), "", $test);
                 //IPSText::alphanumericalClean( $test, '.+&#; ' );
                 if ($test != $test1) {
                     $txt = false;
                 }
                 break;
             case 'email':
                 $test = str_replace(array('"', "'", '&quot;', '&#39;'), "", $txt);
                 $test = IPSText::checkEmailAddress($test) ? $txt : FALSE;
                 break;
             case 'font':
                 /* Make sure it's clean */
                 $test = str_replace(array('&amp;quot;', '"', "'", '&quot;', '&#39;'), "", $txt);
                 $test1 = IPSText::alphanumericalClean($test, '#.+, ');
                 if ($test != $test1) {
                     $txt = false;
                 }
                 break;
             case 'background':
             case 'color':
                 /* Make sure it's clean */
                 $test = str_replace(array('&amp;quot;', '"', "'", '&quot;', '&#39;'), "", $txt);
                 /* Make rgb() safe */
                 $test = preg_replace('#rgb(a)?\\(([^\\)]+?)\\)#i', '', $test);
                 $test1 = IPSText::alphanumericalClean($test, '#.+, ');
                 if ($test != $test1) {
                     $txt = false;
                 }
                 break;
             default:
                 $_regex = null;
                 $_bbcodes = $this->cache->getCache('bbcode');
                 if (!$txt and $_bbcodes[$tag]['bbcode_optional_option']) {
                     continue;
                 }
                 $_regex = $_bbcodes[$tag]['bbcode_custom_regex'];
                 if ($_regex) {
                     $test = str_replace(array('"', "'", '&quot;', '&#39;'), "", $txt);
                     if (!preg_match($_regex, $test)) {
                         $txt = false;
                     }
                 }
                 break;
         }
         /* If we didn't actually get any option data, then return false */
         $test = str_replace(array('"', "'", '&quot;', '&#39;'), "", $txt);
         if (strlen($txt) and strlen($test) < 1) {
             $txt = false;
         }
         if ($txt === false) {
             return false;
         }
         /* Still here? Safety, then */
         $txt = strip_tags($txt, '<br>');
         if (strpos($txt, '[') !== false or strpos($txt, ']') !== false) {
             $txt = str_replace(array('[', ']'), array('&#91;', '&#93;'), $txt);
         }
     }
     /* Attempt to make JS safe */
     $txt = IPSText::xssMakeJavascriptSafe($txt);
     return $txt;
 }
 /**
  * Prints any header information for this output module
  *
  * @access	public
  * @return	@e void		Prints header() information
  */
 public function printHeader()
 {
     //-----------------------------------------
     // Start GZIP compression
     //-----------------------------------------
     if ($this->settings['disable_gzip'] != 1) {
         $buffer = "";
         if (count(ob_list_handlers())) {
             $buffer = ob_get_contents();
             ob_end_clean();
         }
         if (isset($_SERVER['HTTP_ACCEPT_ENCODING']) and strstr($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) {
             @ob_start('ob_gzhandler');
         } else {
             @ob_start();
         }
         print $buffer;
     }
     if (isset($_SERVER['SERVER_PROTOCOL']) and strstr($_SERVER['SERVER_PROTOCOL'], '/1.0')) {
         header("HTTP/1.0 " . $this->_headerCode . ' ' . $this->_headerStatus);
     } else {
         header("HTTP/1.1 " . $this->_headerCode . ' ' . $this->_headerStatus);
     }
     if ($this->settings['print_headers']) {
         /* Forcing a download? */
         if ($this->_forceDownload) {
             header("Content-type: unknown/unknown");
             header("Content-Disposition: attachment; filename=\"" . IPSText::alphanumericalClean(IPSText::transliterate(mb_strtolower($this->registry->output->getTitle()))) . ".html\"");
         } else {
             header("Content-type: text/html;charset=" . IPS_DOC_CHAR_SET);
         }
         if ($this->settings['nocache']) {
             $expires = $this->_headerExpire ? gmdate("D, d M Y H:i:s", time() + $this->_headerExpire) . " GMT" : gmdate("D, d M Y H:i:s", time() - 86400) . " GMT";
             $maxAge = $this->_headerExpire;
             $nocache = !$this->_headerExpire ? 'no-cache, ' : '';
             header("Cache-Control:  " . $nocache . "must-revalidate, max-age=" . $maxAge);
             header("Expires: " . $expires);
             if (!$this->_headerExpire) {
                 header("Pragma: no-cache");
             }
         }
     }
 }
Exemple #22
0
 /**
  * Begin installation
  *
  * @return	@e void
  */
 public function start()
 {
     /* INIT */
     $app_directory = IPSText::alphanumericalClean($this->request['app_directory']);
     $type = 'upgrade';
     $data = array();
     $ok = 1;
     $errors = array();
     $localfiles = array(DOC_IPS_ROOT_PATH . 'cache/skin_cache');
     $info = array();
     /* Init Data */
     $data = IPSSetUp::fetchXmlAppInformation($app_directory, $this->settings['gb_char_set']);
     $_numbers = IPSSetUp::fetchAppVersionNumbers($app_directory);
     $_files = IPSSetUp::fetchXmlAppWriteableFiles($app_directory);
     /* Grab Data */
     $data['app_directory'] = $app_directory;
     $data['current_version'] = $_numbers['current'][0] ? $_numbers['current'][0] : $this->lang->words['cur_version_none'];
     $data['latest_version'] = $_numbers['latest'][1];
     $data['next_version'] = $_numbers['next'][0];
     /* Install, or upgrade? */
     if (!$_numbers['current'][0]) {
         $type = 'install';
     } else {
         @header("Location: {$this->settings['board_url']}/" . CP_DIRECTORY . "/upgrade/");
         exit;
     }
     /* Version Check */
     if ($data['current_version'] > 0 and $data['current_version'] == $data['latest_version']) {
         $this->registry->output->global_message = $this->lang->words['error__up_to_date'];
         $this->registry->output->silentRedirectWithMessage($this->settings['base_url']);
         return;
     }
     /* Check local files */
     foreach ($localfiles as $_path) {
         if (!file_exists($_path)) {
             if ($data['dir']) {
                 if (!@mkdir($_path, IPS_FOLDER_PERMISSION, TRUE)) {
                     $info['notexist'][] = $_path;
                 }
             } else {
                 $info['notexist'][] = $_path;
             }
         } else {
             if (!is_writeable($_path)) {
                 if (!@chmod($_path, is_dir($_path) ? IPS_FOLDER_PERMISSION : IPS_FILE_PERMISSION)) {
                     $info['notwrite'][] = $_path;
                 }
             }
         }
     }
     /* Check files... */
     if (is_array($_files) and count($_files)) {
         $info = array_merge($info, $_files);
     }
     if (count($info['notexist'])) {
         foreach ($info['notexist'] as $path) {
             $errors[] = sprintf($this->lang->words['error__file_missing'], $path);
         }
     }
     if (count($info['notwrite'])) {
         foreach ($info['notwrite'] as $path) {
             $errors[] = sprintf($this->lang->words['error__file_chmod'], $path);
         }
     }
     /**
      * Custom errors
      */
     if (count($info['other'])) {
         foreach ($info['other'] as $error) {
             $errors[] = $error;
         }
     }
     /* Check for xml files */
     $required_xml = array("information");
     foreach ($required_xml as $r) {
         if (!is_file($this->app_full_path . "xml/{$r}.xml")) {
             $errors[] = sprintf($this->lang->words['error__file_needed'], $this->app_full_path . "xml/{$r}.xml");
         }
     }
     /* Show splash */
     $this->registry->output->html .= $this->html->setup_splash_screen($data, $errors, $type);
 }
Exemple #23
0
 /**
  * List all current friends.
  *
  * @return	@e void		[Prints to screen]
  * @since	IPB 2.2.0.2006-08-08
  */
 protected function _viewList()
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $friends = array();
     $tab = substr(IPSText::alphanumericalClean($this->request['tab']), 0, 20);
     $per_page = 25;
     $start = intval($this->request['st']);
     //-----------------------------------------
     // Check we're a member
     //-----------------------------------------
     if (!$this->memberData['member_id']) {
         $this->registry->output->showError('no_friend_mid', 10267, null, null, 404);
     }
     //-----------------------------------------
     // To what are we doing to whom?
     //-----------------------------------------
     if ($tab == 'pending') {
         $query = 'f.friends_approved=0 AND f.friends_friend_id=' . $this->memberData['member_id'];
         $joinKey = 'f.friends_member_id';
     } else {
         $query = 'f.friends_approved=1 AND f.friends_member_id=' . $this->memberData['member_id'];
         $joinKey = 'f.friends_friend_id';
     }
     /* Not banned or spammed */
     $query .= ' AND m.member_banned=0 AND ( ! ' . IPSBWOptions::sql('bw_is_spammer', 'members_bitoptions', 'members', 'global', 'has') . ')';
     //-----------------------------------------
     // Get count...
     //-----------------------------------------
     $count = $this->DB->buildAndFetch(array('select' => 'COUNT(*) as count', 'from' => array('profile_friends' => 'f'), 'where' => $query, 'add_join' => array(array('select' => '', 'from' => array('members' => 'm'), 'where' => 'm.member_id=' . $joinKey, 'type' => 'inner'))));
     //-----------------------------------------
     // Pages...
     //-----------------------------------------
     $pages = $this->registry->output->generatePagination(array('totalItems' => intval($count['count']), 'noDropdown' => 1, 'itemsPerPage' => $per_page, 'currentStartValue' => $start, 'baseUrl' => 'app=members&amp;module=profile&amp;section=friends&amp;do=list&amp;tab=' . $tab));
     //-----------------------------------------
     // Get current friends...
     //-----------------------------------------
     $this->DB->build(array('select' => 'f.*', 'from' => array('profile_friends' => 'f'), 'where' => $query, 'order' => 'm.members_l_display_name ASC', 'limit' => array($start, $per_page), 'add_join' => array(array('select' => 'pp.*', 'from' => array('profile_portal' => 'pp'), 'where' => 'pp.pp_member_id=' . $joinKey, 'type' => 'left'), array('select' => 'm.*', 'from' => array('members' => 'm'), 'where' => 'm.member_id=' . $joinKey, 'type' => 'left'))));
     $q = $this->DB->execute();
     //-----------------------------------------
     // Get and store...
     //-----------------------------------------
     while ($row = $this->DB->fetch($q)) {
         $row = IPSMember::buildDisplayData($row, array('warn' => 0));
         $friends[] = $row;
     }
     //-----------------------------------------
     // Show...
     //-----------------------------------------
     $content = $this->registry->getClass('output')->getTemplate('profile')->friendsList($friends, $pages);
     $this->registry->output->setTitle($this->lang->words['m_title_friends'] . ' - ' . ipsRegistry::$settings['board_name']);
     $this->registry->output->addNavigation($this->lang->words['m_title_friends'], '');
     $this->registry->getClass('output')->addContent($content);
     $this->registry->getClass('output')->sendOutput();
 }
Exemple #24
0
 /**
  * Saves the CSS
  *
  * @return	string		Json
  */
 protected function _saveCSS()
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $setID = intval($this->request['setID']);
     $cssID = intval($this->request['css_id']);
     $type = $this->request['type'] == 'add' ? 'add' : 'edit';
     $css_content = $_POST['css_content'];
     $css_group = IPSText::alphanumericalClean($_POST['_css_group']);
     $css_position = intval($this->request['css_position']);
     $css_attributes = $_POST['css_attributes'];
     $css_app = IPSText::alphanumericalClean($_POST['css_app']);
     $css_app_hide = intval($this->request['css_app_hide']);
     $css_modules = trim($this->request['css_modules']);
     //-----------------------------------------
     // Checks...
     //-----------------------------------------
     if (!$setID or $type == 'edit' and !$cssID) {
         $this->returnJsonError($this->lang->words['ajax_missing_data']);
         exit;
     }
     //-----------------------------------------
     // Add checks
     //-----------------------------------------
     if ($type == 'add') {
         if (!$css_group) {
             $this->returnJsonError($this->lang->words['ajax_missing_data']);
             exit;
         }
     }
     //-----------------------------------------
     // Save it
     //-----------------------------------------
     if ($type == 'edit') {
         $css_id = $this->skinFunctions->saveCSSFromEdit($cssID, $setID, $css_content, $css_group, $css_position, $css_attributes, $css_app, $css_app_hide, $css_modules);
     } else {
         try {
             $css_id = $this->skinFunctions->saveCSSFromAdd($setID, $css_content, str_replace('.css', '', $css_group), $css_position, $css_attributes, $css_app, $css_app_hide, $css_modules);
         } catch (Exception $err) {
             $this->returnJsonError($err->getMessage());
             exit;
         }
     }
     //-----------------------------------------
     // Get Data
     //-----------------------------------------
     $css = $this->skinFunctions->fetchCSSForEdit($css_id, $setID);
     $this->returnJsonArray(array('cssData' => $css, 'errors' => $this->skinFunctions->fetchErrorMessages()));
 }
 /**
  * Run a task
  *
  * @return	@e void
  */
 public function runTask()
 {
     if (ipsRegistry::$request['ck'] and ipsRegistry::$request['ck']) {
         if (ipsRegistry::$request['ck'] == 'all') {
             if (ipsRegistry::$settings['task_use_cron'] and ipsRegistry::$request['allpass'] == ipsRegistry::$settings['task_cron_key']) {
                 $this->type = 'internal';
             } else {
                 die;
             }
         } else {
             $this->type = 'cron';
             $this->cron_key = substr(trim(stripslashes(IPSText::alphanumericalClean(ipsRegistry::$request['ck']))), 0, 32);
         }
     }
     /* Forcing a task? */
     if (defined('FORCE_TASK_KEY')) {
         $this_task = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'task_manager', 'where' => "task_key='" . FORCE_TASK_KEY . "'"));
         /* Check to make sure the app is enabled and exists */
         $this_task = $this->_checkAppEnabled($this_task);
     } else {
         if ($this->type == 'internal') {
             //-----------------------------------------
             // Loaded by our image...
             // ... get next job
             //-----------------------------------------
             $this_task = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'task_manager', 'where' => 'task_enabled = 1 AND task_next_run <= ' . $this->time_now, 'order' => 'task_next_run ASC', 'limit' => array(0, 1)));
             /* Check to make sure the app is enabled and exists */
             $this_task = $this->_checkAppEnabled($this_task);
         } else {
             if ($this->type == 'cron') {
                 //-----------------------------------------
                 // Cron.. load from cron key
                 //-----------------------------------------
                 $this_task = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'task_manager', 'where' => "task_cronkey='" . $this->cron_key . "'"));
                 //-----------------------------------------
                 // Verify application is enabled
                 //-----------------------------------------
                 if (!$this_task['task_application'] or !ipsRegistry::$applications[$this_task['task_application']]['app_enabled']) {
                     return;
                 }
             }
         }
     }
     if ($this_task['task_id']) {
         //-----------------------------------------
         // Locked?
         //-----------------------------------------
         if ($this_task['task_locked'] > 0) {
             # Yes - now, how long has it been locked for?
             # If longer than 30 mins, unlock as something
             # has gone wrong.
             if ($this_task['task_locked'] < time() - 1800) {
                 $newdate = $this->generateNextRun($this_task);
                 $this->DB->update('task_manager', array('task_next_run' => $newdate, 'task_locked' => 0), "task_id=" . $this_task['task_id']);
                 $this->saveNextRunStamp();
             }
             # Cancel and return if locked
             return;
         }
         //-----------------------------------------
         // Got it, now update row, lock and run..
         //-----------------------------------------
         $newdate = $this->generateNextRun($this_task);
         $this->DB->update('task_manager', array('task_next_run' => $newdate, 'task_locked' => time()), "task_id=" . $this_task['task_id']);
         $this->saveNextRunStamp();
         if (is_file(IPSLib::getAppDir($this_task['task_application']) . '/tasks/' . $this_task['task_file'])) {
             $classToLoad = IPSLib::loadLibrary(IPSLib::getAppDir($this_task['task_application']) . '/tasks/' . $this_task['task_file'], 'task_item', $this_task['task_application']);
             $myobj = new $classToLoad($this->registry, $this, $this_task);
             $myobj->runTask();
             //-----------------------------------------
             // Any shutdown queries
             //-----------------------------------------
             $this->DB->return_die = 0;
             if (count($this->DB->obj['shutdown_queries'])) {
                 foreach ($this->DB->obj['shutdown_queries'] as $q) {
                     $this->DB->query($q);
                 }
             }
             $this->DB->return_die = 1;
             $this->DB->obj['shutdown_queries'] = array();
         }
     }
 }
 /**
  * Generate context-menu filter boxes. 
  * Pass &_nosave=1 to not store / read from a cookie
  *
  * @author	Matt Mecham
  * @since	IPB 3.0.0
  * @return	array
  */
 public function generateFilterBoxes()
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     static $_return = array();
     if (count($_return)) {
         return $_return;
     }
     $form = array();
     $custom_field_data = array();
     $filters_preset = 0;
     //-----------------------------------------
     // Custom filtering
     //-----------------------------------------
     $member_string = $this->request['string'] ? trim($this->request['string']) : '';
     $member_contains = $this->request['f_member_contains'] ? trim($this->request['f_member_contains']) : '';
     $member_contains_type = $this->request['f_member_contains_type'] ? trim($this->request['f_member_contains_type']) : '';
     $member_contains_text = $this->request['f_member_contains_text'] ? trim($this->request['f_member_contains_text']) : '';
     $_member_contains = array(0 => array('members_display_name', $this->lang->words['m_f_display']), 1 => array('name', $this->lang->words['m_f_login']), 2 => array('member_id', $this->lang->words['m_f_id']), 3 => array('email', $this->lang->words['m_f_email']), 4 => array('ip_address', $this->lang->words['m_f_ip']), 5 => array('signature', $this->lang->words['m_f_sig']));
     $_member_contains_type = array(0 => array('contains', $this->lang->words['m_f_contains']), 1 => array('equals', $this->lang->words['m_f_equals']), 2 => array('begins', $this->lang->words['m_f_begins']), 3 => array('ends', $this->lang->words['m_f_ends']));
     //-----------------------------------------
     // Order by
     //-----------------------------------------
     $order_by = '';
     $order_by = $this->request['order_by'] ? $this->request['order_by'] : 'joined';
     $_order_by = array(0 => array('joined', $this->lang->words['m_f_joined']), 1 => array('members_l_username', $this->lang->words['m_f_slogin']), 2 => array('members_l_display_name', $this->lang->words['m_f_sdisplay']), 3 => array('email', $this->lang->words['m_f_email']), 4 => array('posts', $this->lang->words['m_f_posts']));
     $order_direction = $this->request['order_direction'] ? strtolower($this->request['order_direction']) : 'desc';
     $_order_direction = array(0 => array('asc', $this->lang->words['m_f_orderaz']), 1 => array('desc', $this->lang->words['m_f_orderza']));
     //-----------------------------------------
     // Member status type
     //-----------------------------------------
     $member_status = ($this->request['type'] and in_array($this->request['type'], array('all', 'banned', 'spam', 'validating', 'incomplete', 'locked'))) ? $this->request['type'] : 'all';
     $_member_status = array(0 => array('all', $this->lang->words['m_f_sall']), 1 => array('banned', $this->lang->words['m_f_sbanned']), 2 => array('spam', $this->lang->words['m_f_sspam']), 3 => array('validating', $this->lang->words['m_f_svalidating']), 4 => array('incomplete', $this->lang->words['m_f_simpcomplete']), 5 => array('locked', $this->lang->words['m_f_slocked']));
     //-----------------------------------------
     // Search type
     //-----------------------------------------
     $search_type = $this->request['f_search_type'] ? $this->request['f_search_type'] : 'normal';
     $_search_type = array(0 => array('normal', $this->lang->words['m_f_toedit']));
     if ($this->registry->getClass('class_permissions')->checkPermission('member_delete')) {
         $_search_type[1] = array('delete', $this->lang->words['m_f_todelete']);
     }
     if ($this->registry->getClass('class_permissions')->checkPermission('member_move')) {
         $_search_type[2] = array('move', $this->lang->words['m_f_tomove']);
     }
     //-----------------------------------------
     // Date ranges
     //-----------------------------------------
     $date_reg_from = $this->request['f_date_reg_from'] ? trim($this->request['f_date_reg_from']) : '';
     $date_reg_to = $this->request['f_date_reg_to'] ? trim($this->request['f_date_reg_to']) : '';
     $date_post_from = $this->request['f_date_post_from'] ? trim($this->request['f_date_post_from']) : '';
     $date_post_to = $this->request['f_date_post_to'] ? trim($this->request['f_date_post_to']) : '';
     $date_active_from = $this->request['f_date_active_from'] ? trim($this->request['f_date_active_from']) : '';
     $date_active_to = $this->request['f_date_active_to'] ? trim($this->request['f_date_active_to']) : '';
     //-----------------------------------------
     // Groups
     //-----------------------------------------
     $primary_group = $this->request['f_primary_group'] ? trim($this->request['f_primary_group']) : 0;
     $secondary_group = $this->request['f_secondary_group'] ? trim($this->request['f_secondary_group']) : 0;
     $include_secondary = $this->request['f_inc_secondary'] ? 1 : 0;
     IPSDebug::fireBug('info', array('Включая вторичные группы: ' . var_export($include_secondary, true)));
     $_primary_group = array(0 => array('0', $this->lang->words['m_f_primany']));
     $_secondary_group = array(0 => array('0', $this->lang->words['m_f_secany']));
     foreach (ipsRegistry::cache()->getCache('group_cache') as $_gdata) {
         $_primary_group[] = array($_gdata['g_id'], $_gdata['g_title']);
         $_secondary_group[] = array($_gdata['g_id'], $_gdata['g_title']);
     }
     //-----------------------------------------
     // Post counts
     //-----------------------------------------
     $post_count = $this->request['f_post_count'] || $this->request['f_post_count'] == '0' ? trim($this->request['f_post_count']) : '';
     $post_count_type = $this->request['f_post_count_type'] ? trim($this->request['f_post_count_type']) : '';
     $_post_count_types = array(0 => array('lt', $this->lang->words['pc_lt']), 1 => array('gt', $this->lang->words['pc_gt']), 2 => array('eq', $this->lang->words['pc_eq']));
     //-----------------------------------------
     // Reset filters if set to
     //-----------------------------------------
     if ($this->request['reset_filters']) {
         ipsRegistry::getClass('adminFunctions')->staffSaveCookie('memberFilter', array());
     }
     //-----------------------------------------
     // Retrieve filter from "cookie"
     //-----------------------------------------
     /* Commented out nosave - @link http://community.invisionpower.com/resources/bugs.html/_/ip-board/acp-member-search-pagination-r40480 */
     if (!$this->request['__update']) {
         $_cookie_array = ipsRegistry::getClass('adminFunctions')->staffGetCookie('memberFilter');
         if (is_array($_cookie_array) and count($_cookie_array)) {
             $member_contains = substr($_cookie_array['c_member_contains'], 0, 20);
             $member_contains_type = substr($_cookie_array['c_member_contains_type'], 0, 20);
             $member_contains_text = substr($_cookie_array['c_member_contains_text'], 0, 50);
             $member_status = trim(IPSText::alphanumericalClean($_cookie_array['c_member_status']));
             $member_string = trim($_cookie_array['c_member_string']);
             $post_count = trim(IPSText::alphanumericalClean($_cookie_array['c_post_count']));
             $post_count_type = trim(IPSText::alphanumericalClean($_cookie_array['c_post_count_type']));
             if (!isset($this->request['order_by'])) {
                 $order_by = trim(IPSText::alphanumericalClean($_cookie_array['c_order_by']));
             }
             if (!isset($this->request['order_direction'])) {
                 $order_direction = trim(IPSText::alphanumericalClean($_cookie_array['c_order_direction']));
             }
             $date_reg_from = trim(IPSText::alphanumericalClean($_cookie_array['c_date_reg_from'], '/-'));
             $date_reg_to = trim(IPSText::alphanumericalClean($_cookie_array['c_date_reg_to'], '/-'));
             $date_post_from = trim(IPSText::alphanumericalClean($_cookie_array['c_date_post_from'], '/-'));
             $date_post_to = trim(IPSText::alphanumericalClean($_cookie_array['c_date_post_to'], '/-'));
             $date_active_from = trim(IPSText::alphanumericalClean($_cookie_array['c_date_active_from'], '/-'));
             $date_active_to = trim(IPSText::alphanumericalClean($_cookie_array['c_date_active_to'], '/-'));
             $primary_group = trim(IPSText::alphanumericalClean($_cookie_array['c_primary_group'], '/-'));
             $include_secondary = trim(IPSText::alphanumericalClean($_cookie_array['c_include_secondary'], '/-'));
             $secondary_group = trim(IPSText::alphanumericalClean($_cookie_array['c_secondary_group'], '/-'));
             $custom_field_cookie = explode('||', $_cookie_array['c_custom_fields']);
             if ($member_contains || $member_contains_type || $member_contains_text || $order_by || $order_direction || $date_reg_from || $date_reg_to || $date_post_from || $date_post_to || $date_active_from || $date_active_to || $primary_group || $secondary_group || $post_count || $post_count_type || $include_secondary || $member_status || $member_string) {
                 $filters_preset = 1;
             }
             if (is_array($custom_field_cookie) and count($custom_field_cookie)) {
                 foreach ($custom_field_cookie as $field) {
                     $data = explode('==', $field);
                     $custom_field_data['field_' . $data[0]] = $data[1];
                     ipsRegistry::$request['field_' . $data[0]] = $data[1];
                     if ($data[1]) {
                         $filters_preset = 1;
                     }
                 }
             }
         }
     }
     //-----------------------------------------
     // Get custom profile information
     //-----------------------------------------
     $custom_field_data = count($custom_field_data) ? $custom_field_data : $_REQUEST;
     foreach ($custom_field_data as $k => $v) {
         if (strpos($k, 'ignore_field_') === 0) {
             $key = substr($k, 13);
             $custom_field_data['field_' . $key] = '';
         }
     }
     $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/customfields/profileFields.php', 'customProfileFields');
     $fields = new $classToLoad();
     $fields->member_data = $custom_field_data;
     $fields->initData('edit', 1);
     $fields->parseToEdit();
     $custom_field_data_imploded = array();
     foreach ($custom_field_data as $k => $v) {
         if (strpos($k, 'field_') === 0 and $v) {
             if (is_array($v)) {
                 $v = implode(',', array_keys($v));
             }
             $custom_field_data_imploded[] = substr($k, 6) . '==' . $v;
         }
     }
     $custom_field_data_imploded = implode('||', $custom_field_data_imploded);
     //-----------------------------------------
     // Generate form data
     //-----------------------------------------
     $form['_member_contains'] = $this->registry->output->formDropdown('f_member_contains', $_member_contains, $member_contains);
     $form['_member_contains_type'] = $this->registry->output->formDropdown('f_member_contains_type', $_member_contains_type, $member_contains_type);
     $form['_member_contains_text'] = $this->registry->output->formInput('f_member_contains_text', $member_contains_text, 'f_member_contains_text', 15, '', ' no_width');
     $form['_member_status'] = $this->registry->output->formDropdown('type', $_member_status, $member_status);
     $form['_member_string'] = $this->registry->output->formSimpleInput('string', $member_string, 15);
     $form['_order_by'] = $this->registry->output->formDropdown('order_by', $_order_by, preg_replace("#.*\\.(.*)\$#", "\\1", $order_by));
     $form['_order_direction'] = $this->registry->output->formDropdown('order_direction', $_order_direction, $order_direction);
     $form['_search_type'] = $this->registry->output->formDropdown('f_search_type', $_search_type, $search_type);
     $form['_post_count'] = $this->registry->output->formSimpleInput('f_post_count', $post_count, 10);
     $form['_post_count_type'] = $this->registry->output->formDropdown('f_post_count_type', $_post_count_types, $post_count_type);
     $form['_date_reg_from'] = $this->registry->output->formInput('f_date_reg_from', $date_reg_from, 'f_date_reg_from', 15, 'text', '', ' no_width');
     $form['_date_reg_to'] = $this->registry->output->formInput('f_date_reg_to', $date_reg_to, 'f_date_reg_to', 15, 'text', '', ' no_width');
     $form['_date_post_from'] = $this->registry->output->formInput('f_date_post_from', $date_post_from, 'f_date_post_from', 15, 'text', '', ' no_width');
     $form['_date_post_to'] = $this->registry->output->formInput('f_date_post_to', $date_post_to, 'f_date_post_to', 15, 'text', '', ' no_width');
     $form['_date_active_from'] = $this->registry->output->formInput('f_date_active_from', $date_active_from, 'f_date_active_from', 15, 'text', '', ' no_width');
     $form['_date_active_to'] = $this->registry->output->formInput('f_date_active_to', $date_active_to, 'f_date_active_to', 15, 'text', '', ' no_width');
     $form['_primary_group'] = $this->registry->output->formDropdown('f_primary_group', $_primary_group, $primary_group);
     $form['_secondary_group'] = $this->registry->output->formDropdown('f_secondary_group', $_secondary_group, $secondary_group);
     $form['_include_secondary'] = $this->registry->output->formCheckbox('f_inc_secondary', $include_secondary);
     //-----------------------------------------
     // Store the cooookie
     // @see http://community.invisionpower.com/tracker/issue-19031-acp-members-page-always-thinks-its-being-filtered/
     //-----------------------------------------
     if (($this->request['__update'] or $this->request['f_search_type']) and !$this->request['_nosave']) {
         $_cookie = array('c_member_status' => $member_status, 'c_member_string' => $member_string, 'c_member_contains' => $member_contains, 'c_member_contains_type' => $member_contains_type, 'c_member_contains_text' => $member_contains_text, 'c_order_by' => preg_replace("#.*\\.(.*)\$#", "\\1", $order_by), 'c_order_direction' => $order_direction, 'c_post_count' => $post_count, 'c_post_count_type' => $post_count_type, 'c_date_reg_from' => $date_reg_from, 'c_date_reg_to' => $date_reg_to, 'c_date_post_from' => $date_post_from, 'c_date_post_to' => $date_post_to, 'c_date_active_from' => $date_active_from, 'c_date_active_to' => $date_active_to, 'c_primary_group' => $primary_group, 'c_secondary_group' => $secondary_group, 'c_include_secondary' => $include_secondary, 'c_custom_fields' => $custom_field_data_imploded);
         ipsRegistry::getClass('adminFunctions')->staffSaveCookie('memberFilter', $_cookie);
     } elseif ((isset($this->request['order_by']) or isset($this->request['order_direction'])) and !$this->request['_nosave']) {
         $_cookie = ipsRegistry::getClass('adminFunctions')->staffGetCookie('memberFilter');
         $_cookie['c_order_by'] = preg_replace("#.*\\.(.*)\$#", "\\1", $order_by);
         $_cookie['c_order_direction'] = $order_direction;
         ipsRegistry::getClass('adminFunctions')->staffSaveCookie('memberFilter', $_cookie);
     }
     //-----------------------------------------
     // Create filter boxes
     //-----------------------------------------
     $this->htmlPresets = array('form' => $form, 'fields' => $fields, 'presets' => $filters_preset);
     //-----------------------------------------
     // Return data
     //-----------------------------------------
     $_return['custom_fields'] = '';
     if (is_array($fields->out_fields) and count($fields->out_fields)) {
         foreach ($fields->out_fields as $id => $data) {
             $_return['custom_fields'][$id] = $fields->in_fields[$id];
         }
     }
     foreach (array_keys($form) as $_key) {
         $__key = substr($_key, 1);
         $_return[$__key] = ${$__key};
     }
     return $_return;
 }
Exemple #27
0
 /**
  * Show the online list
  *
  * @return	@e void		[Stores HTML in $this->output]
  */
 protected function _listAll()
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $this->first = intval($this->request['st']) > 0 ? intval($this->request['st']) : 0;
     $final = array();
     $modules = array();
     $memberIDs = array();
     if (!$this->settings['au_cutoff']) {
         $this->settings['au_cutoff'] = 15;
     }
     $defaults = array('show_mem' => ($this->request['show_mem'] and in_array($this->request['show_mem'], array('reg', 'guest', 'all'))) ? $this->request['show_mem'] : 'all', 'sort_order' => ($this->request['sort_order'] and in_array($this->request['sort_order'], array('desc', 'asc'))) ? $this->request['sort_order'] : 'asc', 'sort_key' => ($this->request['sort_key'] and in_array($this->request['sort_key'], array('click', 'name'))) ? $this->request['sort_key'] : 'click');
     //-----------------------------------------
     // Sort the db query
     //-----------------------------------------
     $cut_off = $this->settings['au_cutoff'] * 60;
     $t_time = time() - $cut_off;
     $db_order = $defaults['sort_order'] == 'asc' ? 'asc' : 'desc';
     $db_key = $defaults['sort_key'] == 'click' ? 'running_time' : 'member_name';
     $wheres = array('running_time > ' . $t_time);
     switch ($defaults['show_mem']) {
         case 'reg':
             $wheres[] = "member_id > 0";
             $wheres[] = "member_group != " . $this->settings['guest_group'];
             break;
         case 'guest':
             $wheres[] = "member_group = " . $this->settings['guest_group'];
             break;
     }
     if (!$this->settings['spider_active'] and !$this->memberData['g_access_cp']) {
         $wheres[] = $this->DB->buildRight('id', 8) . " != '_session'";
     }
     if (!$this->memberData['g_access_cp']) {
         $wheres[] = "login_type != 1";
     }
     //-----------------------------------------
     // Grab all the current sessions.
     //-----------------------------------------
     $this->DB->build(array('select' => '*', 'from' => 'sessions', 'where' => implode(' AND ', $wheres), 'calcRows' => TRUE, 'order' => $db_key . ' ' . $db_order, 'limit' => array($this->first, $this->perpage)));
     $outer = $this->DB->execute();
     $max = $this->DB->fetchCalculatedRows();
     if (!$this->DB->getTotalRows($outer) && $this->first > 0) {
         // We are request page 2 - but there is no page 2 now...
         $this->registry->output->silentRedirect($this->settings['base_url'] . "app=members&amp;section=online&amp;module=online&amp;sortkey={$defaults['sort_key']}&amp;show_mem={$defaults['show_mem']}&amp;sort_order={$defaults['sort_order']}");
     }
     //-----------------------------------------
     // Put results into array
     //-----------------------------------------
     while ($r = $this->DB->fetch($outer)) {
         if (strstr($r['id'], '_session')) {
             $r['is_bot'] = 1;
         }
         $r['where_line'] = '';
         $r['where_link'] = '';
         //-----------------------------------------
         // Sessions aren't updated until shutdown
         // so reset our session now
         //-----------------------------------------
         if ($this->memberData['member_id'] and $r['member_id'] == $this->memberData['member_id']) {
             $r['current_appcomponent'] = 'members';
             $r['current_module'] = 'online';
             $r['current_section'] = 'online';
         }
         //-----------------------------------------
         // Is this a member?
         //-----------------------------------------
         if ($r['member_id']) {
             $memberIDs[] = $r['member_id'];
         }
         //-----------------------------------------
         // Don't parse if in an error
         //-----------------------------------------
         if ($r['in_error']) {
             $r['current_appcomponent'] = 'core';
         }
         $final[$r['id']] = $r;
         //-----------------------------------------
         // Module?
         //-----------------------------------------
         $modules[$r['current_section']] = array('app' => $r['current_appcomponent']);
     }
     $links = $this->registry->output->generatePagination(array('totalItems' => $max, 'itemsPerPage' => $this->perpage, 'currentStartValue' => $this->first, 'baseUrl' => "app=members&amp;section=online&amp;module=online&amp;sort_key={$defaults['sort_key']}&amp;sort_order={$defaults['sort_order']}&amp;show_mem={$defaults['show_mem']}"));
     //-----------------------------------------
     // Pass off entries to modules..
     //-----------------------------------------
     if (count($modules)) {
         foreach ($modules as $module_array) {
             if (IPSLib::appIsInstalled($module_array['app'])) {
                 $module_array['app'] = IPSText::alphanumericalClean($module_array['app']);
                 $filename = IPSLib::getAppDir($module_array['app']) . '/extensions/coreExtensions.php';
                 if (is_file($filename)) {
                     $classToLoad = IPSLib::loadLibrary($filename, 'publicSessions__' . $module_array['app'], $module_array['app']);
                     $loader = new $classToLoad();
                     if (method_exists($loader, 'parseOnlineEntries')) {
                         $final = $loader->parseOnlineEntries($final);
                     }
                 }
             }
         }
     }
     //-----------------------------------------
     // Finally, members...
     //-----------------------------------------
     if (count($memberIDs)) {
         $members = IPSMember::load($memberIDs, 'all');
     }
     $newFinal = array();
     if (is_array($final) and count($final)) {
         foreach ($final as $id => $data) {
             if ($data['member_id']) {
                 $newFinal['member-' . $data['member_id']] = $data;
                 $newFinal['member-' . $data['member_id']]['memberData'] = $members[$data['member_id']];
                 $newFinal['member-' . $data['member_id']]['_memberData'] = IPSMember::buildProfilePhoto($members[$data['member_id']]);
             } else {
                 $newFinal[$data['id']] = $data;
                 $newFinal[$data['id']]['memberData'] = array();
                 $newFinal[$data['id']]['_memberData'] = IPSMember::buildProfilePhoto(0);
             }
         }
     }
     //-----------------------------------------
     // Set defaults
     //-----------------------------------------
     foreach (array('sort_key', 'sort_order', 'show_mem') as $k) {
         if (!$this->request[$k]) {
             $this->request[$k] = $defaults[$k];
         }
     }
     //-----------------------------------------
     // Output
     //-----------------------------------------
     $this->output .= $this->registry->getClass('output')->getTemplate('online')->showOnlineList($newFinal, $links, $defaults);
 }
 /**
  * Perform the actual upload
  *
  * @return	@e void
  */
 public function attachUploadiFrame()
 {
     /* INIT */
     $attach_post_key = trim(IPSText::alphanumericalClean($this->request['attach_post_key']));
     $attach_rel_module = trim(IPSText::alphanumericalClean($this->request['attach_rel_module']));
     $attach_rel_id = intval($this->request['attach_rel_id']);
     $attach_current_items = '';
     $this->registry->getClass('class_localization')->loadLanguageFile(array('public_post'), 'forums');
     /* INIT module */
     $this->class_attach->type = $attach_rel_module;
     $this->class_attach->attach_post_key = $attach_post_key;
     $this->class_attach->attach_rel_id = $attach_rel_id;
     $this->class_attach->init();
     /* Process upload */
     $insert_id = $this->class_attach->processUpload();
     /* Got an error? */
     if ($this->class_attach->error) {
         $JSON = $this->attachmentUploadShow($this->class_attach->error, 1, $insert_id);
     } else {
         $JSON = $this->attachmentUploadShow('upload_ok', 0, $insert_id);
     }
     $this->ajax->returnHtml($this->registry->output->getTemplate('post')->attachiFrame($JSON, $attach_rel_id));
 }
 /**
  * Build the secondary menu
  *
  * @access	private
  * @return	string		Menu HTML
  */
 private function _buildSubMenu()
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $clean_module = IPSText::alphanumericalClean(ipsRegistry::$current_module);
     $this->menu = array();
     $_nav_main_done = 0;
     /* Fetch fke apps */
     $fakeApps = $this->registry->output->fetchFakeApps();
     $inFakeApp = FALSE;
     $fakeApp = '';
     //-----------------------------------------
     // In a fake app?
     //-----------------------------------------
     foreach ($fakeApps as $_app => $_fdata) {
         foreach ($_fdata as $__fdata) {
             if (ipsRegistry::$current_application == $__fdata['app'] and $__fdata['module'] == ipsRegistry::$current_module) {
                 $fakeApp = $_app;
                 $inFakeApp = TRUE;
                 break 2;
             }
         }
     }
     //-----------------------------------------
     // Got a cache?
     //-----------------------------------------
     if (IN_DEV) {
         ipsRegistry::cache()->updateCacheWithoutSaving('app_menu_cache', array());
     }
     if (!is_array(ipsRegistry::cache()->getCache('app_menu_cache')) or !count(ipsRegistry::cache()->getCache('app_menu_cache'))) {
         $this->cache->rebuildCache('app_menu_cache', 'global');
     }
     //-----------------------------------------
     // Get child XML tabs
     //-----------------------------------------
     if (ipsRegistry::$current_application and $clean_module) {
         //-----------------------------------------
         // Do stuff
         //-----------------------------------------
         foreach (ipsRegistry::cache()->getCache('app_menu_cache') as $app_dir => $data) {
             if (!ipsRegistry::$applications[$app_dir]['app_enabled']) {
                 continue;
             }
             /* Not in this app? */
             if ($app_dir != ipsRegistry::$current_application) {
                 continue;
             }
             foreach ($data as $_current_module => $module_data) {
                 $skip = TRUE;
                 $__current_module = $_current_module;
                 $_current_module = preg_replace('/^\\d+?_(.*)$/', "\\1", $_current_module);
                 /* Fake app content? If so.. remove.. */
                 foreach ($fakeApps as $_app => $_fdata) {
                     foreach ($_fdata as $__fdata) {
                         /* If the fake app matches the menu we're gonna show... */
                         if ($__fdata['app'] == $app_dir and $__fdata['module'] == $_current_module) {
                             if ($inFakeApp === TRUE && $_app == $fakeApp) {
                                 $skip = FALSE;
                             }
                         } else {
                             /* If we're in a fake app, skip non fake apps */
                             if ($inFakeApp !== TRUE) {
                                 $skip = FALSE;
                             }
                         }
                     }
                 }
                 if ($skip === TRUE) {
                     continue;
                 }
                 if ($app_dir == ipsRegistry::$request['app'] and !stristr($this->settings['query_string_safe'], 'module=')) {
                     $this->settings['query_string_safe'] = $this->settings['query_string_safe'] . '&amp;module=' . $clean_module;
                 }
                 foreach ($module_data['items'] as $id => $item) {
                     //-----------------------------------------
                     // Permission mask?
                     //-----------------------------------------
                     if ($item['rolekey']) {
                         ipsRegistry::getClass('class_permissions')->return = 1;
                         if (ipsRegistry::getClass('class_permissions')->checkPermission($item['rolekey'], $app_dir, $_current_module) !== TRUE) {
                             //print '<pre>';print $app_dir . ' '. $_current_module.'<br>';print_r($module_data);print_r($item);
                             continue;
                         }
                     }
                     //-----------------------------------------
                     // Force a module/section parameter into the input array
                     //-----------------------------------------
                     if ($app_dir == ipsRegistry::$current_application and ipsRegistry::$current_module == $item['module'] and !ipsRegistry::$request['section'] and $item['section']) {
                         ipsRegistry::$request['section'] = $item['section'];
                     }
                     //-----------------------------------------
                     // Add to nav?
                     //-----------------------------------------
                     if ($app_dir == ipsRegistry::$current_application and ipsRegistry::$request['section'] and ipsRegistry::$request['section'] == $item['section'] and ipsRegistry::$current_module == $item['module']) {
                         //-----------------------------------------
                         // Sure?
                         //-----------------------------------------
                         $_ok = 1;
                         $__sub_item_url = $item['url'] ? '&amp;' . $item['url'] : '';
                         if (!$_nav_main_done) {
                             if (!$this->ignoreCoreNav) {
                                 $this->core_nav[] = array($this->settings['base_url'] . 'module=' . $_current_module . '&amp;section=' . $item['section'], $module_data['title']);
                             }
                             $_nav_main_done = 1;
                             //-----------------------------------------
                             // Sort out do param?
                             //-----------------------------------------
                             if ($item['url'] and !isset($_GET['do'])) {
                                 $_do = str_replace("do=", "", $item['url']);
                                 ipsRegistry::$request['do'] = $_do;
                                 if (!stristr($this->settings['query_string_safe'], 'section=')) {
                                     $this->settings['query_string_safe'] = $this->settings['query_string_safe'] . '&amp;section=' . ipsRegistry::$request['section'];
                                 }
                                 $this->settings['query_string_safe'] = '&amp;do=' . $_do;
                             }
                         }
                         if ($item['url']) {
                             /* Reset */
                             $_ok = 0;
                             /* Trying something a little different with the nav */
                             $_url = explode('=', $item['url']);
                             /* Now we're first going to check for an exact do match */
                             $_ok = $_url[1] == ipsRegistry::$request['do'];
                             /* No?  Check the Query string then */
                             if (!$_ok) {
                                 $_n = str_replace('&amp;', '&', strtolower($item['url']));
                                 $_h = str_replace('&amp;', '&', strtolower(my_getenv('QUERY_STRING')));
                                 if (strstr($_h, $_n)) {
                                     $_ok = 1;
                                 }
                             }
                         }
                         if (!$this->ignoreCoreNav and $_ok) {
                             $this->core_nav[] = array($this->settings['base_url'] . 'module=' . $_current_module . '&amp;section=' . $item['section'] . $__sub_item_url, $item['title']);
                         }
                     }
                     //-----------------------------------------
                     // Continue...
                     //-----------------------------------------
                     if ($item['title'] and $item['section']) {
                         $this->menu[$app_dir][$__current_module]['items'][] = array('title' => $item['title'], 'module' => $_current_module, 'section' => $item['section'], 'url' => $item['url'], 'redirect' => $item['redirect']);
                         $this->menu[$app_dir][$__current_module]['title'] = count($this->menu[$app_dir][$__current_module]['items']) > 1 ? $module_data['title'] : $item['title'];
                     }
                 }
             }
         }
     }
     //print_r($this->menu);
     if (isset($this->menu) && count($this->menu)) {
         return $this->global_template->menu_sub_navigation($this->menu);
     }
 }
Exemple #30
-1
 /**
  * Send Bulk Mail via Mandrill
  */
 protected function _mailSendMandrill()
 {
     //-----------------------------------------
     // Load it
     //-----------------------------------------
     $id = intval($this->request['id']);
     $mail = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'bulk_mail', 'where' => 'mail_id=' . $id));
     if (!$mail['mail_id'] or !$mail['mail_subject'] or !$mail['mail_content']) {
         $this->registry->output->global_message = $this->lang->words['b_nosend'];
         $this->_mailStart();
         return;
     }
     $opts = unserialize($mail['mail_opts']);
     //-----------------------------------------
     // Work out which vars we've actually used
     //-----------------------------------------
     $usedVars = array('unsubscribe');
     foreach (array_keys($this->_getVariableInformation($this->memberData)) as $k) {
         if (strpos($mail['mail_content'], '{' . $k . '}') !== FALSE) {
             $usedVars[] = $k;
         }
     }
     //-----------------------------------------
     // Build the JSON document
     //-----------------------------------------
     $pergo = 2000;
     $recipientsTo = array();
     $recipientsMerge = array();
     /* Start with a basic query */
     $queryData = array('select' => 'm.*', 'from' => array('members' => 'm'), 'order' => 'm.member_id', 'limit' => array($this->request['st'], $pergo));
     /* Add in filters */
     $done = 0;
     $complete = FALSE;
     $_queryData = $this->_buildMembersQuery($opts['filters']);
     $queryData['add_join'] = $_queryData['add_join'];
     $queryData['where'] = implode(' AND ', $_queryData['where']);
     /* Write the file */
     $this->DB->build($queryData);
     $e = $this->DB->execute();
     if (!$this->DB->getTotalRows($e)) {
         $complete = TRUE;
     }
     while ($r = $this->DB->fetch($e)) {
         /* Skip any invalid emails - the chars presented here are allowed via RFC (note that _ and - are already allowed in alphanumericClean and don't need to be specified) */
         if (!$r['email'] or !$r['members_display_name'] or !IPSText::checkEmailAddress($r['email']) or $r['email'] != IPSText::alphanumericalClean($r['email'], '@.+!#$%&\'*/=?^`{|}~ ')) {
             continue;
         }
         $recipientsTo[] = array('email' => $r['email'], 'name' => $r['members_display_name']);
         $vars = array();
         foreach ($this->_getVariableInformation($r, 1) as $k => $v) {
             if (in_array($k, $usedVars)) {
                 $vars[] = array('name' => $k, 'content' => $v);
             }
         }
         if (!empty($vars)) {
             $recipientsMerge[] = array('rcpt' => $r['email'], 'vars' => $vars);
         }
         $done++;
     }
     //-----------------------------------------
     // Build Content
     //-----------------------------------------
     /* Sort out member vars */
     $content = $mail['mail_content'];
     foreach ($this->_getVariableInformation($this->memberData) as $k => $v) {
         $content = str_replace('{' . $k . '}', '*|' . $k . '|*', $content);
     }
     /* Sort out global vars */
     $globalMergeVars = array();
     foreach ($this->_getVariableInformation(NULL, 2) as $k => $v) {
         if (in_array($k, $usedVars)) {
             $globalMergeVars[] = array('name' => $k, 'content' => $v);
         }
     }
     /* Get the full content */
     IPSText::getTextClass('email')->clearContent();
     IPSText::getTextClass('email')->unsubscribe = true;
     if ($opts['mail_html_on']) {
         IPSText::getTextClass('email')->setHtmlEmail(true);
         IPSText::getTextClass('email')->setHtmlTemplate(str_replace("\n", "", $content));
         IPSText::getTextClass('email')->setHtmlWrapper('<#content#>');
     } else {
         if ($this->settings['email_use_html']) {
             IPSText::getTextClass('email')->setHtmlEmail(true);
             IPSText::getTextClass('email')->setHtmlTemplate($content);
         } else {
             IPSText::getTextClass('email')->setPlainTextTemplate($content, true);
         }
     }
     if ($opts['mail_html_on'] or $this->settings['email_use_html']) {
         IPSText::getTextClass('email')->buildMessage(array('UNSUBSCRIBE' => '*|unsubscribe|*'), true, true);
         $content = IPSText::getTextClass('email')->getHtmlContent();
     } else {
         IPSText::getTextClass('email')->buildMessage(array('UNSUBSCRIBE' => '*|unsubscribe|*'));
         $content = nl2br(IPSText::getTextClass('email')->getPlainTextContent());
     }
     //-----------------------------------------
     // Send to Mandrill
     //-----------------------------------------
     if (IPS_DOC_CHAR_SET != "UTF-8") {
         $mail['mail_subject'] = IPSText::convertCharsets($mail['mail_subject'], IPS_DOC_CHAR_SET, "UTF-8");
     }
     require_once IPSLib::getAppDir('members') . '/sources/classes/mandrill.php';
     $mandrill = new Mandrill();
     $response = $mandrill->messages_send(array('message' => array('html' => $content, 'subject' => $mail['mail_subject'], 'from_email' => $this->settings['email_out'], 'from_name' => $this->settings['board_name'], 'to' => $recipientsTo, 'auto_text' => true, 'url_strip_qs' => false, 'preserve_recipients' => false, 'merge' => true, 'global_merge_vars' => $globalMergeVars, 'merge_vars' => $recipientsMerge, 'tags' => array_merge(array('ips'), array_filter($opts['mandrill_tags'], create_function('$v', 'return (bool) $v;')))), 'async' => true));
     if (isset($response->status) and $response->status == 'error') {
         $this->registry->output->showError('mandrill_error');
     }
     //-----------------------------------------
     // Save
     //-----------------------------------------
     $this->DB->update('bulk_mail', array('mail_active' => 0, 'mail_updated' => time(), 'mail_sentto' => $mail['mail_sentto'] + count($recipientsTo)), 'mail_id=' . $mail['mail_id']);
     if ($complete !== TRUE) {
         $url = "{$this->settings['base_url']}app=members&module=bulkmail&section=bulkmail&do=mail_send_mandrill&id={$id}&countmembers={$this->request['countmembers']}&st=" . ($this->request['st'] + $pergo);
         if (!$this->request['st']) {
             $this->registry->output->multipleRedirectInit($url);
             $this->registry->getClass('output')->html_main .= $this->registry->getClass('output')->global_template->global_frame_wrapper();
             $this->registry->getClass('output')->sendOutput();
         } else {
             $percentage = 100 / $this->request['countmembers'] * $this->request['st'];
             $percentage = floor($percentage);
             $this->registry->output->multipleRedirectHit($url, "Processing ({$percentage}% complete)");
         }
         return;
     } else {
         $this->registry->output->multipleRedirectFinish();
     }
 }