/**
  * This method is called after a member's account has been merged into another member's account
  *
  * @access	public
  * @param	array	$member		Member account being kept
  * @param	array	$member2	Member account being removed
  * @return	void
  **/
 public function onMerge($member, $member2)
 {
     IPSDebug::addLogMessage("Markers init done:", 'merge', $member);
     if ($this->registry->DB()->checkForTable('cal_events')) {
         $this->registry->DB()->update('cal_events', array('event_member_id' => intval($member['member_id'])), "event_member_id=" . $member2['member_id']);
     }
 }
 /**
  * Get avatar images in a directory
  *
  * @access	protected
  * @return	void		[Outputs to screen]
  */
 protected function _getAvatarImages()
 {
     $dir = IPSText::alphanumericalClean(urldecode($this->request['cat']), ' ');
     $images = IPSMember::getFunction()->getHostedAvatarsFromCategory($dir);
     IPSDebug::fireBug('info', array('Directory: ' . $dir));
     if ($images === FALSE) {
         $this->returnJsonError($this->lang->words['m_nodir']);
         exit;
     } else {
         $output = $this->html->inline_avatar_images($images);
         $this->returnJsonArray(array('html' => $output));
     }
 }
Exemplo n.º 3
0
 /**
  * Run this task
  * 
  * @return	@e void
  */
 public function runTask()
 {
     /* INIT */
     if (!$this->registry->isClassLoaded('classItemMarking')) {
         $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/itemmarking/classItemMarking.php', 'classItemMarking');
         $this->registry->setClass('classItemMarking', new $classToLoad($this->registry));
     }
     $time = time() - 86400 * ipsRegistry::$settings['topic_marking_keep_days'];
     $itemsRemoved = 0;
     /* Remove 'deleted' items */
     $this->DB->delete('core_item_markers', 'item_is_deleted=1');
     $c = $this->DB->getAffectedRows();
     /* Now delete old markers - we use a separate query because there are separate indexes */
     $this->DB->delete('core_item_markers', 'item_last_saved < ' . $time);
     $c += $this->DB->getAffectedRows();
     IPSDebug::addLogMessage("{$c} item markers removed", 'markers_cleanout');
     /* Log task */
     $this->registry->getClass('class_localization')->loadLanguageFile(array('public_global'), 'core');
     $this->class->appendTaskLog($this->task, sprintf($this->lang->words['itemmarkers_task_log'], $itemsRemoved, $c));
     /* UNLOCK TASK */
     $this->class->unlockTask($this->task);
 }
 /**
  * Executes the ajax request, checks secure key
  *
  * @access	public
  * @param	object	ipsRegistry reference
  * @return	void
  **/
 public function execute(ipsRegistry $registry)
 {
     /* Setup Shortcuts First */
     $this->makeRegistryShortcuts($registry);
     /* Check the secure key */
     $this->request['secure_key'] = $this->request['secure_key'] ? $this->request['secure_key'] : $this->request['md5check'];
     //if( $this->request['secure_key'] && $this->request['secure_key'] != $this->member->form_hash )
     if ($this->request['secure_key'] != $this->member->form_hash) {
         IPSDebug::fireBug('error', array("The security key did not match the member's form hash"));
         $this->returnString('nopermission');
     }
     $this->doExecute($registry);
 }
Exemplo n.º 5
0
 /**
  * Get search results count
  *
  * @param	string	[$extraQuery]	Extra query where clause
  * @return	int 	Number of search results
  */
 public function getSearchResultsCount($extraQuery = '')
 {
     $extra = $extraQuery ? " AND " . $extraQuery : '';
     IPSDebug::fireBug('info', array('WHERE: ' . $this->getWhereClause() . $extra));
     $count = $this->DB->buildAndFetch(array('select' => 'COUNT(*) as count', 'from' => array('members' => 'm'), 'where' => $this->getWhereClause() . $extra, 'add_join' => array(array('from' => array('profile_portal' => 'pp'), 'where' => 'pp.pp_member_id=m.member_id', 'type' => 'left'), array('from' => array('pfields_content' => 'p'), 'where' => 'p.member_id=m.member_id', 'type' => 'left'), array('from' => array('members_partial' => 'par'), 'where' => 'par.partial_member_id=m.member_id', 'type' => 'left'), array('from' => array('validating' => 'val'), 'where' => 'val.member_id=m.member_id', 'type' => 'left'))));
     return intval($count['count']);
 }
Exemplo n.º 6
0
 /**
  * Returns debug data
  *
  * @access	protected
  * @return	string		Debug HTML
  */
 public function html_showDebugInfo()
 {
     $input = "";
     $queries = "";
     $sload = "";
     $stats = "";
     //-----------------------------------------
     // Form & Get & Skin
     //-----------------------------------------
     if ($this->settings['debug_level'] >= 2) {
         $stats .= "<br />\n<div class='tableborder'>\n<div class='subtitle'>IPSDebug сообщения</div><div class='row1' style='padding:6px'>\n";
         foreach (IPSDebug::getMessages() as $dx => $entry) {
             $stats .= "<strong>{$entry}</strong><br />\n";
         }
         $stats .= "</div>\n</div>";
         $stats .= "<br />\n<div class='tableborder'>\n<div class='subtitle'>IPSMember кеши</div><div class='row1' style='padding:6px'>\n";
         if (is_array(IPSMember::$debugData)) {
             foreach (IPSMember::$debugData as $entry) {
                 $stats .= "<strong>{$entry}</strong><br />\n";
             }
         }
         $stats .= "</div>\n</div>";
         /* Included Files */
         if (function_exists('get_included_files')) {
             $__files = get_included_files();
             $stats .= "<br />\n<div class='tableborder'>\n<div class='subtitle'>(" . count($__files) . ") подключенных файлов</div><div class='row1' style='padding:6px'>\n";
             foreach ($__files as $__f) {
                 $stats .= "<strong>{$__f}</strong><br />";
             }
             $stats .= '</div></div>';
         }
         /* Caches */
         $stats .= "<br />\n<div class='tableborder'>\n<div class='subtitle'>Загруженных кешей</div><div class='row1' style='padding:6px'>\n";
         $_total = 0;
         if (is_array($this->cache->debugInfo)) {
             foreach ($this->cache->debugInfo as $key => $data) {
                 $_size = $data['size'];
                 $_total += $_size;
                 $stats .= "<strong>{$key}</strong> - " . IPSLib::sizeFormat($_size) . "<br />\n";
             }
         }
         $stats .= "<strong>ИТОГО: " . IPSLib::sizeFormat($_total) . "</strong></div>\n</div>";
         /* Loaded classes */
         $loadedClasses = $this->registry->getLoadedClassesAsArray();
         $stats .= "<br />\n<div class='tableborder'>\n<div class='subtitle'>Загруженные классы через ipsRegistry::getClass()</div><div class='row1' style='padding:6px'>\n";
         if (is_array($loadedClasses)) {
             foreach ($loadedClasses as $entry) {
                 $stats .= "<strong>{$entry}</strong><br />\n";
             }
         }
         $stats .= "</div>\n</div>";
         $stats .= "<br />\n<div class='tableborder'>\n<div class='subtitle'>FORM и GET данные</div><div class='row1' style='padding:6px'>\n";
         foreach ($this->request as $k => $v) {
             if (in_array(strtolower($k), array('pass', 'password'))) {
                 $v = '*******';
             }
             $stats .= "<strong>{$k}</strong> = {$v}<br />\n";
         }
         $stats .= "</div>\n</div>";
         $stats .= "<br />\n<div class='tableborder'>\n<div class='subtitle'>SKIN, MEMBER & TASK Info</div><div class='row1' style='padding:6px'>\n";
         while (list($k, $v) = each($this->skin)) {
             if (is_array($v)) {
                 continue;
             }
             if (strlen($v) > 120) {
                 $v = substr($v, 0, 120) . '...';
             }
             $stats .= "<strong>{$k}</strong> = " . IPSText::htmlspecialchars($v) . "<br />\n";
         }
         //-----------------------------------------
         // Stop E_ALL moaning...
         //-----------------------------------------
         $cache = $this->caches['systemvars'];
         $cache['task_next_run'] = $cache['task_next_run'] ? $cache['task_next_run'] : 0;
         $stats .= "<b>Следующая задача</b> = " . $this->registry->getClass('class_localization')->getDate($cache['task_next_run'], 'LONG') . "\n<br /><b>Время</b> = " . $this->registry->getClass('class_localization')->getDate(time(), 'LONG');
         $stats .= "<br /><b>Сейчас</b> = " . time();
         $stats .= "<p>Пользователь: last_visit: " . $this->memberData['last_visit'] . " / " . $this->registry->getClass('class_localization')->getDate($this->memberData['last_visit'], 'LONG') . "</p>";
         $stats .= "<p>Пользователь: uagent_key: " . $this->memberData['userAgentKey'] . "</p>";
         $stats .= "<p>Пользователь: uagent_type: " . $this->memberData['userAgentType'] . "</p>";
         $stats .= "<p>Пользователь: uagent_version: " . $this->memberData['userAgentVersion'] . "</p>";
         $stats .= "</div>\n</div>";
         $stats .= "<br />\n<div class='tableborder'>\n<div class='subtitle'>Загруженные PHP шаблоны</div><div class='row1' style='padding:6px'>\n";
         $stats .= "<strong>" . implode(", ", array_keys($this->output->compiled_templates)) . "</strong><br />\n";
         $stats .= "<strong>" . implode(", ", array_keys($this->output->loaded_templates)) . "</strong><br />\n";
         $stats .= "<strong>" . implode(", ", array_values($this->registry->getClass('class_localization')->loaded_lang_files)) . "</strong><br />\n";
         $stats .= "</div>\n</div>";
     }
     //-----------------------------------------
     // SQL
     //-----------------------------------------
     if ($this->settings['debug_level'] >= 3) {
         $stats .= "<br />\n<div class='tableborder' style='overflow:auto'>\n<div class='subtitle'>Запросы</div><div class='row1' style='padding:6px'>";
         foreach ($this->DB->obj['cached_queries'] as $q) {
             $q = htmlspecialchars($q);
             $q = str_ireplace("SELECT", "<span style='color:red'>SELECT</span>", $q);
             $q = preg_replace("/^UPDATE/i", "<span style='color:blue'>UPDATE</span>", $q);
             $q = preg_replace("/^DELETE/i", "<span style='color:orange'>DELETE</span>", $q);
             $q = preg_replace("/^INSERT/i", "<span style='color:green'>INSERT</span>", $q);
             $q = str_replace("LEFT JOIN", "<span style='color:red'>LEFT JOIN</span>", $q);
             $stats .= "<p style='padding:6px;border-bottom:1px solid black'>{$q}</p>\n";
         }
         if (count($this->DB->obj['shutdown_queries'])) {
             foreach ($this->DB->obj['shutdown_queries'] as $q) {
                 $q = htmlspecialchars($q);
                 $q = preg_replace("/^SELECT/i", "<span style='color:red'>SELECT</span>", $q);
                 $q = preg_replace("/^UPDATE/i", "<span style='color:blue'>UPDATE</span>", $q);
                 $q = preg_replace("/^DELETE/i", "<span style='color:orange'>DELETE</span>", $q);
                 $q = preg_replace("/^INSERT/i", "<span style='color:green'>INSERT</span>", $q);
                 $q = str_replace("LEFT JOIN", "<span style='color:red'>LEFT JOIN</span>", $q);
                 //$q = preg_replace( "/(".$this->settings['sql_tbl_prefix'].")(\S+?)([\s\.,]|$)/", "<span class='purple'>\\1\\2</span>\\3", $q );
                 $stats .= "<div style='background:#DEDEDE'><b>SHUTDOWN:</b> {$q}</div><br />\n";
             }
         }
         $stats .= "</div>\n</div>";
     }
     //-----------------------------------------
     // Memory usage
     //-----------------------------------------
     if (IPS_MEMORY_DEBUG_MODE and defined('IPS_MEMORY_START') and $this->memberData['g_access_cp']) {
         if (is_array(IPSDebug::$memory_debug)) {
             $memory .= "<br />\n<div class='tableborder'>\n<div class='subtitle'>MEMORY USAGE</div><div class='row1' style='padding:6px'>\n";
             $memory .= "<table cellpadding='4' cellspacing='0' border='0' width='100%'>\n";
             $_c = 0;
             foreach (IPSDebug::$memory_debug as $usage) {
                 $_col = $_c % 2 ? '#eee' : '#ddd';
                 $_c++;
                 if ($usage[1] > 500 * 1024) {
                     $_col .= ";color:#D00000";
                 } else {
                     if ($usage[1] < 10 * 1024) {
                         $_col .= ";color:darkgreen";
                     } else {
                         if ($usage[1] < 100 * 1024) {
                             $_col .= ";color:darkorange";
                         }
                     }
                 }
                 $memory .= "<tr><td width='60%' style='background-color:{$_col}' align='left'>{$usage[0]}</td><td style='background-color:{$_col}' align='left'><strong>" . IPSLib::sizeFormat($usage[1]) . "</strong></td></tr>";
             }
             $memory .= "</table></div></div>";
         }
         $end = memory_get_usage();
         $peak_end = function_exists('memory_get_peak_usage') ? memory_get_peak_usage() : memory_get_usage();
         $_used = $end - IPS_MEMORY_START;
         $peak_used = $peak_end - IPS_MEMORY_START;
         $stats .= $memory;
         $stats .= "Total Memory Used: " . IPSLib::sizeFormat($_used) . " (Peak:" . IPSLib::sizeFormat($peak_used) . ")";
     }
     if ($stats) {
         $stats = "\n\t\t\t\t\t  <div align='center' style='width:92%; margin:120px auto 20px auto; overflow:auto;'>\n\t\t\t\t\t   <div class='tableborder' align='left'>\n\t\t\t\t\t\t<div class='maintitle'>Debug Information (<a href='#' onclick=\"\$('debug').toggle(); return false;\">Toggle Debug Information</a>)</div>\n\t\t\t\t\t\t <div style='padding:5px;background:#8394B2;' id='debug'>{$stats}</div>\n\t\t\t\t\t   </div>\n\t\t\t\t\t  </div>";
     }
     return $stats;
 }
 /**
  * Manual destructor called by ips_MemberRegistry::__myDestruct()
  * Gives us a chance to do anything we need to do before other
  * classes are culled
  *
  * @access	public
  * @return	void
  */
 public function __myDestruct()
 {
     $_updated = 0;
     $_deleted = 0;
     /* Update sessions... */
     if (is_array($this->_sessionsToSave) and count($this->_sessionsToSave)) {
         foreach ($this->_sessionsToSave as $sessionID => $data) {
             if ($sessionID) {
                 if (isset($this->_queryOverride[$sessionID]) and is_array($this->_queryOverride[$sessionID]) and count($this->_queryOverride[$sessionID])) {
                     foreach ($data as $field => $value) {
                         if (isset($this->_queryOverride[$sessionID][$field])) {
                             $data[$field] = $this->_queryOverride[$sessionID][$field];
                         }
                     }
                 }
                 $this->DB->force_data_type = array('member_name' => 'string');
                 $this->DB->update('sessions', $data, "id='" . $sessionID . "'", true);
             }
         }
     }
     /* Remove sessions */
     if (is_array($this->_sessionsToKill) and count($this->_sessionsToKill)) {
         $_c = count($this->_sessionsToKill);
         $this->DB->delete('sessions', "id IN('" . implode("','", array_keys($this->_sessionsToKill)) . "')");
     }
     IPSDebug::addLogMessage(get_class($this) . ": " . count($this->_sessionsToSave) . " sessions updated, " . count($this->_sessionsToKill) . " sessions deleted", 'sessions-' . $this->_memberData['member_id']);
 }
Exemplo n.º 8
0
 /**
  * Insert record into table if not present, otherwise update existing record
  *
  * @param	string 		Table name
  * @param	array 		Array of field => values
  * @param	array 		Array of fields to check
  * @param	boolean		[Optional] Run on shutdown
  * @return	@e resource
  */
 public function replace($table, $set, $where, $shutdown = false)
 {
     //-----------------------------------------
     // Form query
     //-----------------------------------------
     $dba = $this->compileInsertString($set);
     if (REPLACE_TYPE == 1 or $this->getSqlVersion() < 41000) {
         $query = "REPLACE INTO " . $this->obj['sql_tbl_prefix'] . $table . " ({$dba['FIELD_NAMES']}) VALUES({$dba['FIELD_VALUES']})";
     } else {
         //$dbb	= $this->compileUpdateString( $set );
         $dbb = array();
         foreach ($set as $k => $v) {
             $dbb[] = "{$k}=VALUES({$k})";
         }
         $dbb = implode(',', $dbb);
         $query = "INSERT INTO " . $this->obj['sql_tbl_prefix'] . $table . " ({$dba['FIELD_NAMES']}) VALUES({$dba['FIELD_VALUES']}) ON DUPLICATE KEY UPDATE " . $dbb;
     }
     if (class_exists('IPSDebug')) {
         IPSDebug::addLogMessage($query, 'replaceintolog');
     }
     return $this->_determineShutdownAndRun($query, $shutdown);
 }
 /**
  * Find a particular row
  *
  * @access	protected
  * @param	array 		Array of data
  * @param	string		App
  * @return	array 		Array of data: core_item_marking row, effectively
  */
 protected function _findMainRowByKey($data, $app)
 {
     /* Not interested in this for the main row */
     unset($data['itemID'], $data['itemLastUpdate']);
     $_key = $this->_makeKey($data);
     if (!isset($this->_itemMarkers[$app]) or !is_array($this->_itemMarkers[$app])) {
         /* Mark markers as having changed */
         $this->_changesMade = TRUE;
         /* Add in extra items */
         $data['item_app'] = $app;
         $data['item_key'] = $_key;
         $data['item_member_id'] = $this->memberData['member_id'];
         $data['item_read_array'] = array();
         $this->_itemMarkers[$app] = array();
         $this->_itemMarkers[$app][$_key] = $data;
         IPSDebug::addMessage("Item Marking Key Created! {$_key}");
         return $_key;
     }
     if (!empty($this->_itemMarkers[$app][$_key]) and is_array($this->_itemMarkers[$app][$_key])) {
         /* Make sure it contains the app & key */
         $this->_itemMarkers[$app][$_key]['item_app'] = $app;
         $this->_itemMarkers[$app][$_key]['item_key'] = $_key;
         $this->_itemMarkers[$app][$_key]['item_member_id'] = $this->memberData['member_id'];
         /* Make sure read IDs are unserialized */
         if (isset($this->_itemMarkers[$app][$_key]['item_read_array']) and !is_array($this->_itemMarkers[$app][$_key]['item_read_array'])) {
             $this->_itemMarkers[$app][$_key]['item_read_array'] = unserialize($this->_itemMarkers[$app][$_key]['item_read_array']);
         }
         return $_key;
     } else {
         /* Mark markers as having changed */
         $this->_changesMade = TRUE;
         /* Make sure it contains the app & key */
         $this->_itemMarkers[$app][$_key]['item_app'] = $app;
         $this->_itemMarkers[$app][$_key]['item_key'] = $_key;
         $this->_itemMarkers[$app][$_key]['item_member_id'] = $this->memberData['member_id'];
         $this->_itemMarkers[$app][$_key]['item_read_array'] = array();
         $this->_itemMarkers[$app][$_key] = $data;
         IPSDebug::addMessage("Item Marking Key returned! {$_key}");
         return $_key;
     }
     /* Mark markers as having changed */
     /**
      * @todo	Matt: this code is not used anymore? We already return in the if/else above..
      */
     $this->_changesMade = TRUE;
     // Create a new key ...
     $data['item_app'] = $app;
     $data['item_key'] = $_key;
     $data['item_member_id'] = $this->memberData['member_id'];
     $data['item_read_array'] = array();
     $this->_itemMarkers[$app] = array();
     $this->_itemMarkers[$app][$_key] = $data;
     return $_key;
 }
 /**
  * Parse a member for display
  *
  * @access	public
  * @param	mixed	Either array of member data, or member ID to self load
  * @param	array 	Array of flags to parse: 'signature', 'customFields', 'avatar', 'warn'
  * @return	array 	Parsed member data
  */
 public static function buildDisplayData($member, $_parseFlags = array())
 {
     $_NOW = IPSDebug::getMemoryDebugFlag();
     //-----------------------------------------
     // Figure out parse flags
     //-----------------------------------------
     $parseFlags = array('signature' => isset($_parseFlags['signature']) ? $_parseFlags['signature'] : 0, 'customFields' => isset($_parseFlags['customFields']) ? $_parseFlags['customFields'] : 0, 'avatar' => isset($_parseFlags['avatar']) ? $_parseFlags['avatar'] : 1, 'warn' => isset($_parseFlags['warn']) ? $_parseFlags['warn'] : 1, 'cfSkinGroup' => isset($_parseFlags['cfSkinGroup']) ? $_parseFlags['cfSkinGroup'] : '', 'cfGetGroupData' => isset($_parseFlags['cfGetGroupData']) ? $_parseFlags['cfGetGroupData'] : '', 'cfLocation' => isset($_parseFlags['cfLocation']) ? $_parseFlags['cfLocation'] : '', 'checkFormat' => isset($_parseFlags['checkFormat']) ? $_parseFlags['checkFormat'] : 0);
     if (isset($_parseFlags['__all__'])) {
         foreach ($parseFlags as $k => $v) {
             $parseFlags[$k] = 1;
         }
         $parseFlags['cfSkinGroup'] = '';
     }
     //-----------------------------------------
     // Load the member?
     //-----------------------------------------
     if (!is_array($member) and ($member == intval($member) and $member > 0)) {
         $member = self::load($member, 'all');
     }
     if (!$member['member_group_id']) {
         $member['member_group_id'] = ipsRegistry::$settings['guest_group'];
     }
     /* Unpack bitwise if required */
     if (!isset($member['bw_is_spammer'])) {
         $member = self::buildBitWiseOptions($member);
     }
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $rank_cache = ipsRegistry::cache()->getCache('ranks');
     $group_cache = ipsRegistry::cache()->getCache('group_cache');
     $group_name = IPSLib::makeNameFormatted($group_cache[$member['member_group_id']]['g_title'], $member['member_group_id']);
     $pips = 0;
     $topic_id = intval(isset(ipsRegistry::$request['t']) ? ipsRegistry::$request['t'] : 0);
     $forum_id = intval(isset(ipsRegistry::$request['f']) ? ipsRegistry::$request['f'] : 0);
     //-----------------------------------------
     // SEO Name
     //-----------------------------------------
     $member['members_seo_name'] = self::fetchSeoName($member);
     //-----------------------------------------
     // Avatar
     //-----------------------------------------
     if ($parseFlags['avatar']) {
         $member['avatar'] = self::buildAvatar($member);
     }
     $member['_group_formatted'] = $group_name;
     //-----------------------------------------
     // Ranks
     //-----------------------------------------
     if (is_array($rank_cache) and count($rank_cache)) {
         foreach ($rank_cache as $k => $v) {
             if ($member['posts'] >= $v['POSTS']) {
                 if (!isset($member['title']) || $member['title'] === '' || is_null($member['title'])) {
                     $member['title'] = $v['TITLE'];
                 }
                 $pips = $v['PIPS'];
                 break;
             }
         }
     }
     //-----------------------------------------
     // Group image
     //-----------------------------------------
     $member['member_rank_img'] = '';
     $member['member_rank_img_i'] = '';
     if ($group_cache[$member['member_group_id']]['g_icon']) {
         $_img = $group_cache[$member['member_group_id']]['g_icon'];
         if (substr($_img, 0, 4) != 'http') {
             $_img = ipsRegistry::$settings['_original_base_url'] . '/' . ltrim($_img, '/');
         }
         $member['member_rank_img_i'] = 'img';
         $member['member_rank_img'] = $_img;
     } else {
         if ($pips) {
             if (is_numeric($pips)) {
                 for ($i = 1; $i <= $pips; ++$i) {
                     $member['member_rank_img_i'] = 'pips';
                     $member['member_rank_img'] .= ipsRegistry::getClass('output')->getReplacement('pip_pip');
                 }
             } else {
                 $member['member_rank_img_i'] = 'img';
                 $member['member_rank_img'] = ipsRegistry::$settings['public_dir'] . 'style_extra/team_icons/' . $pips;
             }
         }
     }
     //-----------------------------------------
     // Spammer status
     //-----------------------------------------
     $member['spamStatus'] = NULL;
     $member['spamImage'] = NULL;
     $moderator = ipsRegistry::member()->getProperty('forumsModeratorData');
     if (isset($moderator[$forum_id]['bw_flag_spammers']) and $moderator[$forum_id]['bw_flag_spammers'] or ipsRegistry::member()->getProperty('g_is_supmod') == 1) {
         if (!ipsRegistry::$settings['warn_on'] or !strstr(',' . ipsRegistry::$settings['warn_protected'] . ',', ',' . $member['member_group_id'] . ',')) {
             if ($member['bw_is_spammer']) {
                 $member['spamStatus'] = TRUE;
             } else {
                 $member['spamStatus'] = FALSE;
             }
         }
     }
     //-----------------------------------------
     // Warny porny?
     //-----------------------------------------
     if ($parseFlags['warn'] and $member['member_id']) {
         $member['warn_percent'] = NULL;
         $member['can_edit_warn'] = false;
         $member['warn_img'] = NULL;
         if (ipsRegistry::$settings['warn_on'] and !strstr(',' . ipsRegistry::$settings['warn_protected'] . ',', ',' . $member['member_group_id'] . ',')) {
             /* Warnings */
             if (isset($moderator[$forum_id]['allow_warn']) and $moderator[$forum_id]['allow_warn'] or ipsRegistry::member()->getProperty('g_is_supmod') == 1 or ipsRegistry::$settings['warn_show_own'] and ipsRegistry::member()->getProperty('member_id') == $member['member_id']) {
                 // Work out which image to show.
                 if ($member['warn_level'] <= ipsRegistry::$settings['warn_min']) {
                     $member['warn_img'] = '{parse replacement="warn_0"}';
                     $member['warn_percent'] = 0;
                 } else {
                     if ($member['warn_level'] >= ipsRegistry::$settings['warn_max']) {
                         $member['warn_img'] = '{parse replacement="warn_5"}';
                         $member['warn_percent'] = 100;
                     } else {
                         $member['warn_percent'] = $member['warn_level'] ? sprintf("%.0f", $member['warn_level'] / ipsRegistry::$settings['warn_max'] * 100) : 0;
                         if ($member['warn_percent'] > 100) {
                             $member['warn_percent'] = 100;
                         }
                         if ($member['warn_percent'] >= 81) {
                             $member['warn_img'] = '{parse replacement="warn_5"}';
                         } else {
                             if ($member['warn_percent'] >= 61) {
                                 $member['warn_img'] = '{parse replacement="warn_4"}';
                             } else {
                                 if ($member['warn_percent'] >= 41) {
                                     $member['warn_img'] = '{parse replacement="warn_3"}';
                                 } else {
                                     if ($member['warn_percent'] >= 21) {
                                         $member['warn_img'] = '{parse replacement="warn_2"}';
                                     } else {
                                         if ($member['warn_percent'] >= 1) {
                                             $member['warn_img'] = '{parse replacement="warn_1"}';
                                         } else {
                                             $member['warn_img'] = '{parse replacement="warn_0"}';
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
                 if ($member['warn_percent'] < 1) {
                     $member['warn_percent'] = 0;
                 }
                 /* Bug 14770 - Change so you can't warn yourself */
                 if ((isset($moderator[$forum_id]['allow_warn']) and $moderator[$forum_id]['allow_warn'] or ipsRegistry::member()->getProperty('g_is_supmod') == 1) and $member['member_id'] != ipsRegistry::member()->getProperty('member_id')) {
                     $member['can_edit_warn'] = true;
                 }
             }
         }
     }
     //-----------------------------------------
     // Profile fields stuff
     //-----------------------------------------
     $member['custom_fields'] = "";
     if ($parseFlags['customFields'] == 1 and $member['member_id']) {
         if (isset(self::$_parsedCustomFields[$member['member_id']])) {
             $member['custom_fields'] = self::$_parsedCustomFields[$member['member_id']];
             if ($parseFlags['cfGetGroupData'] and isset(self::$_parsedCustomGroups[$member['member_id']]) and is_array(self::$_parsedCustomGroups[$member['member_id']])) {
                 $member['custom_field_groups'] = self::$_parsedCustomGroups[$member['member_id']];
             }
         } else {
             if (!is_object(self::$custom_fields_class)) {
                 require_once IPS_ROOT_PATH . 'sources/classes/customfields/profileFields.php';
                 self::$custom_fields_class = new customProfileFields();
             }
             if (self::$custom_fields_class) {
                 self::$custom_fields_class->member_data = $member;
                 self::$custom_fields_class->skinGroup = $parseFlags['cfSkinGroup'];
                 self::$custom_fields_class->initData();
                 self::$custom_fields_class->parseToView($parseFlags['checkFormat'], $parseFlags['cfLocation']);
                 $member['custom_fields'] = self::$custom_fields_class->out_fields;
                 self::$_parsedCustomFields[$member['member_id']] = $member['custom_fields'];
                 if ($parseFlags['cfGetGroupData']) {
                     $member['custom_field_groups'] = self::$custom_fields_class->fetchGroupTitles();
                     self::$_parsedCustomGroups[$member['member_id']] = $member['custom_field_groups'];
                 }
             }
         }
     }
     //-----------------------------------------
     // Profile photo
     //-----------------------------------------
     $member = self::buildProfilePhoto($member);
     //-----------------------------------------
     // Personal statement 'bbcode'
     //-----------------------------------------
     if (stripos($member['pp_bio_content'], '[b]') !== false) {
         if (stripos($member['pp_bio_content'], '[/b]') > stripos($member['pp_bio_content'], '[b]')) {
             $member['pp_bio_content'] = str_ireplace('[b]', '<strong>', $member['pp_bio_content']);
             $member['pp_bio_content'] = str_ireplace('[/b]', '</strong>', $member['pp_bio_content']);
         }
     }
     if (stripos($member['pp_bio_content'], '[i]') !== false) {
         if (stripos($member['pp_bio_content'], '[/i]') > stripos($member['pp_bio_content'], '[i]')) {
             $member['pp_bio_content'] = str_ireplace('[i]', '<em>', $member['pp_bio_content']);
             $member['pp_bio_content'] = str_ireplace('[/i]', '</em>', $member['pp_bio_content']);
         }
     }
     if (stripos($member['pp_bio_content'], '[u]') !== false) {
         if (stripos($member['pp_bio_content'], '[/u]') > stripos($member['pp_bio_content'], '[u]')) {
             $member['pp_bio_content'] = str_ireplace('[u]', '<span class="underscore">', $member['pp_bio_content']);
             $member['pp_bio_content'] = str_ireplace('[/u]', '</span>', $member['pp_bio_content']);
         }
     }
     //-----------------------------------------
     // Signature bbcode
     //-----------------------------------------
     if (isset($member['signature']) and $member['signature'] and $parseFlags['signature']) {
         if (isset(self::$_parsedSignatures[$member['member_id']])) {
             $member['signature'] = self::$_parsedSignatures[$member['member_id']];
         } else {
             if ($member['cache_content']) {
                 $member['signature'] = '<!--cached-' . gmdate('r', $member['cache_updated']) . '-->' . $member['cache_content'];
             } else {
                 IPSText::getTextClass('bbcode')->parse_bbcode = ipsRegistry::$settings['sig_allow_ibc'];
                 IPSText::getTextClass('bbcode')->parse_smilies = 1;
                 IPSText::getTextClass('bbcode')->parse_html = ipsRegistry::$settings['sig_allow_html'];
                 IPSText::getTextClass('bbcode')->parse_nl2br = 1;
                 IPSText::getTextClass('bbcode')->parsing_section = 'signatures';
                 IPSText::getTextClass('bbcode')->parsing_mgroup = $member['member_group_id'];
                 IPSText::getTextClass('bbcode')->parsing_mgroup_others = $member['mgroup_others'];
                 $member['signature'] = IPSText::getTextClass('bbcode')->preDisplayParse($member['signature']);
                 IPSContentCache::update($member['member_id'], 'sig', $member['signature']);
             }
             self::$_parsedSignatures[$member['member_id']] = $member['signature'];
         }
     }
     //-----------------------------------------
     // If current session, reset last_activity
     //-----------------------------------------
     if (!empty($member['running_time'])) {
         $member['last_activity'] = $member['running_time'] > $member['last_activity'] ? $member['running_time'] : $member['last_activity'];
     }
     //-----------------------------------------
     // Online?
     //-----------------------------------------
     $time_limit = time() - ipsRegistry::$settings['au_cutoff'] * 60;
     $member['_online'] = 0;
     if (!ipsRegistry::$settings['disable_anonymous'] and isset($member['login_anonymous'])) {
         list($be_anon, $loggedin) = explode('&', $member['login_anonymous']);
     } else {
         $be_anon = 0;
         $loggedin = $member['last_activity'] > $time_limit ? 1 : 0;
     }
     $bypass_anon = 0;
     $our_mgroups = array();
     if (ipsRegistry::member()->getProperty('mgroup_others')) {
         $our_mgroups = explode(",", IPSText::cleanPermString(ipsRegistry::member()->getProperty('mgroup_others')));
     }
     $our_mgroups[] = ipsRegistry::member()->getProperty('member_group_id');
     if (ipsRegistry::member()->getProperty('g_access_cp') and !ipsRegistry::$settings['disable_admin_anon']) {
         $bypass_anon = 1;
     }
     if (($member['last_visit'] > $time_limit or $member['last_activity'] > $time_limit) and ($be_anon != 1 or $bypass_anon == 1) and $loggedin == 1) {
         $member['_online'] = 1;
     }
     //-----------------------------------------
     // Last Active
     //-----------------------------------------
     $member['_last_active'] = ipsRegistry::getClass('class_localization')->getDate($member['last_activity'], 'SHORT');
     if ($be_anon == 1) {
         // Member last logged in anonymous
         if (!ipsRegistry::member()->getProperty('g_access_cp') or ipsRegistry::$settings['disable_admin_anon']) {
             $member['_last_active'] = ipsRegistry::getClass('class_localization')->words['private'];
         }
     }
     //-----------------------------------------
     // Rating
     //-----------------------------------------
     $member['_pp_rating_real'] = intval($member['pp_rating_real']);
     //-----------------------------------------
     // Long display names
     //-----------------------------------------
     $member['members_display_name_short'] = IPSText::truncate($member['members_display_name'], 16);
     //-----------------------------------------
     // Reputation
     //-----------------------------------------
     if (!ipsRegistry::isClassLoaded('repCache')) {
         require_once IPS_ROOT_PATH . 'sources/classes/class_reputation_cache.php';
         ipsRegistry::setClass('repCache', new classReputationCache());
     }
     $member['pp_reputation_points'] = $member['pp_reputation_points'] ? $member['pp_reputation_points'] : 0;
     $member['author_reputation'] = ipsRegistry::getClass('repCache')->getReputation($member['pp_reputation_points']);
     //-----------------------------------------
     // Other stuff not worthy of individual comments
     //-----------------------------------------
     $member['members_profile_views'] = isset($member['members_profile_views']) ? $member['members_profile_views'] : 0;
     $member['_pp_profile_views'] = ipsRegistry::getClass('class_localization')->formatNumber($member['members_profile_views']);
     IPSDebug::setMemoryDebugFlag("IPSMember::buildDisplayData: " . $member['member_id'] . " - Completed", $_NOW);
     return $member;
 }
Exemplo n.º 11
0
 /**
  * Clear out the mod-queue table appropriately
  *
  * @param	string		[topic|post] Type of item moved
  * @param	mixed		ID of topic or post, or array of ids
  * @param	boolean		Was content approved?
  * @return	@e void
  */
 public function clearModQueueTable($type, $typeId, $approved = false)
 {
     //-----------------------------------------
     // Are we operating on one id, or an array
     //-----------------------------------------
     if (is_array($typeId)) {
         $where = "type_id IN(" . implode(',', IPSLib::cleanIntArray($typeId)) . ")";
     } else {
         $where = "type_id=" . intval($typeId);
     }
     //-----------------------------------------
     // Was content deleted
     //-----------------------------------------
     if (!$approved) {
         $this->DB->delete('mod_queued_items', "type='{$type}' AND {$where}");
     } else {
         //-----------------------------------------
         // Get post class..
         //-----------------------------------------
         require_once IPSLib::getAppDir('forums') . '/sources/classes/post/classPost.php';
         /*noLibHook*/
         $classToLoad = IPSLib::loadLibrary(IPSLib::getAppDir('forums') . '/sources/classes/post/classPostForms.php', 'classPostForms', 'forums');
         $_postClass = new $classToLoad($this->registry);
         //-----------------------------------------
         // Working with posts?
         //-----------------------------------------
         if ($type == 'post') {
             IPSDebug::fireBug('info', array('type is post'));
             $this->DB->build(array('select' => 'm.id', 'from' => array('mod_queued_items' => 'm'), 'where' => "m.type='{$type}' AND m.{$where}", 'add_join' => array(array('select' => 'p.pid, p.post, p.author_id, p.post_date, p.topic_id', 'from' => array('posts' => 'p'), 'where' => 'p.pid=m.type_id', 'type' => 'left'), array('select' => 't.*', 'from' => array('topics' => 't'), 'where' => 't.tid=p.topic_id', 'type' => 'left'))));
             $outer = $this->DB->execute();
             while ($r = $this->DB->fetch($outer)) {
                 $member = IPSMember::load($r['author_id'], 'extendedProfile,groups');
                 $_postClass->setPublished(true);
                 $_postClass->setAuthor($member);
                 $_postClass->setForumData($this->registry->class_forums->allForums[$r['forum_id']]);
                 $_postClass->incrementUsersPostCount();
                 $_postClass->sendOutTrackedTopicEmails($r, $r['post']);
                 $this->DB->delete('mod_queued_items', 'id=' . $r['id']);
             }
         } else {
             IPSDebug::fireBug('info', array('type is topic'));
             $this->DB->build(array('select' => 'm.id', 'from' => array('mod_queued_items' => 'm'), 'where' => "m.type='{$type}' AND m.{$where}", 'add_join' => array(array('select' => 't.*', 'from' => array('topics' => 't'), 'where' => 't.tid=m.type_id', 'type' => 'left'), array('select' => 'p.pid, p.post, p.post_date', 'from' => array('posts' => 'p'), 'where' => 'p.pid=t.topic_firstpost', 'type' => 'left'))));
             $outer = $this->DB->execute();
             while ($r = $this->DB->fetch($outer)) {
                 $member = IPSMember::load($r['starter_id'], 'extendedProfile,groups');
                 $_postClass->setPublished(true);
                 $_postClass->setAuthor($member);
                 $_postClass->setForumData($this->registry->class_forums->allForums[$r['forum_id']]);
                 $_postClass->incrementUsersPostCount();
                 $_postClass->sendOutTrackedForumEmails($this->registry->class_forums->getForumById($r['forum_id']), $r, $r['post']);
                 $this->DB->delete('mod_queued_items', 'id=' . $r['id']);
             }
         }
     }
 }
 /**
  * This function processes the DB post before printing as output
  *
  * @access	public
  * @param	string			Raw text
  * @return	string			Converted text
  */
 public function preDisplayParse($txt = "")
 {
     if ($this->parse_html) {
         $txt = $this->_parseHtml($txt);
     }
     //-----------------------------------------
     // Fix "{style_images_url}"
     //-----------------------------------------
     $txt = str_replace("{style_images_url}", "&#123;style_images_url&#125;", $txt);
     //-----------------------------------------
     // Custom BB code
     //-----------------------------------------
     $_NOW = IPSDebug::getMemoryDebugFlag();
     if ($this->parse_bbcode) {
         $txt = $this->parseBbcode($txt, 'display');
     }
     IPSDebug::setMemoryDebugFlag("PreDisplayParse - parsed BBCode", $_NOW);
     $_NOW = IPSDebug::getMemoryDebugFlag();
     if ($this->parse_wordwrap > 0) {
         $txt = $this->applyWordwrap($txt, $this->parse_wordwrap);
     }
     IPSDebug::setMemoryDebugFlag("PreDisplayParse - applied wordwrap", $_NOW);
     //-----------------------------------------
     // Protect against XSS
     //-----------------------------------------
     $txt = $this->checkXss($txt);
     //-----------------------------------------
     // And fix old youtube embedded videos..
     //-----------------------------------------
     /*if( stripos( $txt, "<object" ) AND stripos( $txt, "<embed" ) )
     		{
     			//$txt = preg_replace( "#<object(.+?)<embed(.+?)></embed></object>#i", "<embed\\2</embed>", $txt );
     			$txt = preg_replace( "#<object(.+?)<embed.+?></embed></object>#i", "<object\\1</object>", $txt );
     		}*/
     return $txt;
 }
Exemplo n.º 13
0
 /**
  * Load a template file
  *
  * @param	string		Template name
  * @param	string		Application [defaults to current application]
  * @return	object
  */
 public function loadTemplate($template, $app = '')
 {
     $app = $app ? $app : IPS_APP_COMPONENT;
     /* Skin file exists? */
     if (is_file(IPSLib::getAppDir($app) . "/skin_cp/" . $template . ".php")) {
         $_pre_load = IPSDebug::getMemoryDebugFlag();
         $classToLoad = IPSLib::loadLibrary(IPSLib::getAppDir($app) . '/skin_cp/' . $template . '.php', $template, $app);
         IPSDebug::setMemoryDebugFlag("CORE: Template Loaded ({$classToLoad})", $_pre_load);
         $class = new $classToLoad($this->registry);
         $this->compiled_templates[$app . '.' . $template] = $class;
         return $class;
     } else {
         $this->showError(sprintf($this->lang->words['notemplatefiletoload'], $template), 4100, true);
     }
 }
Exemplo n.º 14
0
 /**
  * Load a 'master_skin' template file. Used when developing
  *
  * @access	public
  * @param	string		Name of skin file
  * @return	@e void		Evals the skin to add the class in memory
  */
 public function loadMasterSkinTemplate($name, $id)
 {
     if (!count($this->remapData)) {
         $this->remapData = $this->registry->output->buildRemapData();
     }
     $_id = $id == 0 ? $this->remapData['inDevDefault'] : $id;
     $_dir = $this->remapData['templates'][$_id];
     if (!is_file(IPS_CACHE_PATH . "cache/skin_cache/" . $_dir . "/" . $name . ".php")) {
         return;
     }
     //-----------------------------------------
     // Get data...
     //-----------------------------------------
     $data = implode('', file(IPS_CACHE_PATH . "cache/skin_cache/" . $_dir . "/" . $name . ".php"));
     //-----------------------------------------
     // Get template class
     //-----------------------------------------
     $toeval = $this->registry->templateEngine->convertCacheToEval($data, $name . '_' . $id);
     $showme = strstr($data, '{{{SHOWME}}}') ? $name : '';
     if (!class_exists($name . '_' . $id)) {
         ob_start();
         eval($toeval);
         $result = ob_get_contents();
         ob_end_clean();
         if (strstr($result, "Parse error") or strstr($result, 'Catchable fatal error:') or $showme == $name) {
             IPSDebug::showTemplateError($result, $toeval);
         }
     }
 }
 /**
  * Parses the bbcode to be shown in the browser.  Expects preDbParse has already been done before the save.
  * If all bbcodes are parse on save, this method does nothing really
  *
  * @access	public
  * @param 	string			Raw input text to parse
  * @return	string			Parsed text ready to be displayed
  */
 public function preDisplayParse($text)
 {
     $_NOW = IPSDebug::getMemoryDebugFlag();
     $this->_passSettings();
     //-----------------------------------------
     // Parse
     //-----------------------------------------
     $text = $this->bbclass->preDisplayParse($text);
     IPSDebug::setMemoryDebugFlag("PreDisplayParse completed", $_NOW);
     return $text;
 }
Exemplo n.º 16
0
 /**
  * Returns an array of the allowed upload sizes in bytes.
  * Return 'space_allowed' as -1 to not allow uploads.
  * Return 'space_allowed' as 0 to allow unlimited uploads
  * Return 'max_single_upload' as 0 to not set a limit
  *
  * @param	string		MD5 post key
  * @param	id			Member ID
  * @return	array 		[ 'space_used', 'space_left', 'space_allowed', 'max_single_upload' ]
  */
 public function getSpaceAllowance($post_key = '', $member_id = '')
 {
     $max_php_size = IPSLib::getMaxPostSize();
     $member_id = intval($member_id ? $member_id : $this->memberData['member_id']);
     $forum_id = intval(ipsRegistry::$request['forum_id'] ? ipsRegistry::$request['forum_id'] : ipsRegistry::$request['f']);
     $space_left = 0;
     $space_used = 0;
     $space_allowed = 0;
     $max_single_upload = 0;
     $space_calculated = 0;
     if ($post_key) {
         //-----------------------------------------
         // Check to make sure we're not attempting
         // to upload to another's post...
         //-----------------------------------------
         if (!$this->memberData['g_is_supmod'] and !$this->memberData['is_mod']) {
             $post = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'posts', 'where' => "post_key='{$post_key}'"));
             if ($post['post_key'] and $post['author_id'] != $member_id) {
                 $space_allowed = -1;
                 $space_calculated = 1;
             }
         }
     }
     //-----------------------------------------
     // Generate total space allowed
     //-----------------------------------------
     $total_space_allowed = ($this->memberData['g_attach_per_post'] ? $this->memberData['g_attach_per_post'] : $this->memberData['g_attach_max']) * 1024;
     //-----------------------------------------
     // Allowed to attach?
     //-----------------------------------------
     if (!$member_id or !$forum_id) {
         $space_allowed = -1;
     }
     if (IPSMember::checkPermissions('upload', $forum_id) !== TRUE) {
         $space_allowed = -1;
     } else {
         if (!$space_calculated) {
             //-----------------------------------------
             // Generate space allowed figure
             //-----------------------------------------
             if ($this->memberData['g_attach_per_post']) {
                 //-----------------------------------------
                 // Per post limit...
                 //-----------------------------------------
                 $_space_used = $this->DB->buildAndFetch(array('select' => 'SUM(attach_filesize) as figure', 'from' => 'attachments', 'where' => "attach_post_key='{$post_key}'"));
                 $space_used = $_space_used['figure'] ? $_space_used['figure'] : 0;
             } else {
                 //-----------------------------------------
                 // Global limit...
                 //-----------------------------------------
                 $_space_used = $this->DB->buildAndFetch(array('select' => 'SUM(attach_filesize) as figure', 'from' => 'attachments', 'where' => "attach_member_id={$member_id} AND attach_rel_module IN( 'post', 'msg' )"));
                 $space_used = $_space_used['figure'] ? $_space_used['figure'] : 0;
             }
             if ($this->memberData['g_attach_max'] > 0) {
                 if ($this->memberData['g_attach_per_post']) {
                     $_g_space_used = $this->DB->buildAndFetch(array('select' => 'SUM(attach_filesize) as figure', 'from' => 'attachments', 'where' => "attach_member_id={$member_id} AND attach_rel_module IN( 'post', 'msg' )"));
                     $g_space_used = $_g_space_used['figure'] ? $_g_space_used['figure'] : 0;
                     if ($this->memberData['g_attach_max'] * 1024 - $g_space_used < 0) {
                         $space_used = $g_space_used;
                         $total_space_allowed = $this->memberData['g_attach_max'] * 1024;
                         $space_allowed = $this->memberData['g_attach_max'] * 1024 - $space_used;
                         $space_allowed = $space_allowed < 0 ? -1 : $space_allowed;
                     } else {
                         $space_allowed = $this->memberData['g_attach_per_post'] * 1024 - $space_used;
                         $space_allowed = $space_allowed < 0 ? -1 : $space_allowed;
                     }
                 } else {
                     $space_allowed = $this->memberData['g_attach_max'] * 1024 - $space_used;
                     $space_allowed = $space_allowed < 0 ? -1 : $space_allowed;
                 }
             } else {
                 if ($this->memberData['g_attach_per_post']) {
                     $space_allowed = $this->memberData['g_attach_per_post'] * 1024 - $space_used;
                     $space_allowed = $space_allowed < 0 ? -1 : $space_allowed;
                 } else {
                     # Unlimited
                     $space_allowed = 0;
                 }
             }
             //-----------------------------------------
             // Generate space left figure
             //-----------------------------------------
             $space_left = $space_allowed ? $space_allowed : 0;
             $space_left = $space_left < 0 ? -1 : $space_left;
             //-----------------------------------------
             // Generate max upload size
             //-----------------------------------------
             if (!$max_single_upload) {
                 if ($space_left > 0 and $space_left < $max_php_size) {
                     $max_single_upload = $space_left;
                 } else {
                     if ($max_php_size) {
                         $max_single_upload = $max_php_size;
                     }
                 }
             }
         }
     }
     IPSDebug::fireBug('info', array('Space left: ' . $space_left));
     IPSDebug::fireBug('info', array('Max PHP size: ' . $max_php_size));
     IPSDebug::fireBug('info', array('Max single file size: ' . $max_single_upload));
     $return = array('space_used' => $space_used, 'space_left' => $space_left, 'space_allowed' => $space_allowed, 'max_single_upload' => $max_single_upload, 'total_space_allowed' => $total_space_allowed);
     return $return;
 }
Exemplo n.º 17
0
 /**
  * Main output function
  *
  * @param	bool	Return finished output instead of printing
  * @return	@e void 
  */
 public function sendOutput($return = false)
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $_NOW = IPSDebug::getMemoryDebugFlag();
     $this->_sendOutputSetUp('normal');
     //-----------------------------------------
     // Ad Code
     //-----------------------------------------
     $adCodeData = array();
     if ($this->registry->getClass('IPSAdCode')->userCanViewAds()) {
         $adCodeData['adHeaderCode'] = $this->registry->getClass('IPSAdCode')->getGobalCode('header');
         $adCodeData['adFooterCode'] = $this->registry->getClass('IPSAdCode')->getGobalCode('footer');
         $adCodeData['adHeaderCode'] = $adCodeData['adHeaderCode'] ? $adCodeData['adHeaderCode'] : $this->registry->getClass('IPSAdCode')->getAdCode('ad_code_global_header');
         $adCodeData['adFooterCode'] = $adCodeData['adFooterCode'] ? $adCodeData['adFooterCode'] : $this->registry->getClass('IPSAdCode')->getAdCode('ad_code_global_footer');
     }
     //-----------------------------------------
     // Meta Tags
     //-----------------------------------------
     /* What's the page URL? */
     $currentUrl = !$_SERVER['HTTPS'] || $_SERVER['HTTPS'] == 'off' ? 'http://' : 'https://';
     $currentUrl .= $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
     $currentUrl = str_replace(array(ipsRegistry::$settings['board_url'], '/index.php?', '/index.php'), '', $currentUrl);
     /* @link http://community.invisionpower.com/resources/bugs.html/_/ip-board/add-meta-tags-not-working-with-urls-containing-a-special-character-r41497 */
     $encUrl = urldecode($currentUrl);
     /* Add em in */
     $metaTags = array();
     $meta = $this->cache->getCache('meta_tags');
     if (is_array($meta) && count($meta)) {
         foreach ($meta as $page => $tags) {
             if (is_array($tags) && count($tags)) {
                 $match = str_replace('/', '\\/', $page);
                 $match = str_replace('-', '\\-', $match);
                 $match = str_replace('_', '\\_', $match);
                 $match = str_replace('.', '\\.', $match);
                 $match = str_replace('*', '(.*)?', $match);
                 if (preg_match('/^' . $match . '$/', $currentUrl) or preg_match('/^' . $match . '$/', $encUrl)) {
                     foreach ($tags as $tag => $val) {
                         if ($tag == 'title') {
                             $this->setTitle($val);
                         } else {
                             $this->addMetaTag($tag, $val);
                         }
                         $metaTags[$tag] = $val;
                     }
                 }
             }
         }
     }
     //-----------------------------------------
     // Gather output
     //-----------------------------------------
     $output = $this->outputFormatClass->fetchOutput($this->_html, $this->_title, $this->_navigation, $this->_documentHeadItems, $this->_jsLoader, $adCodeData);
     $output = $this->templateHooks($output);
     $output = $this->replaceMacros($output);
     /* Live editing meta tags? */
     if ($this->memberData['g_access_cp'] && !empty($this->memberData['_cache']['ipseo_live_meta_edit'])) {
         $output = str_replace("<body id='ipboard_body'>", $this->registry->output->getTemplate('global')->metaEditor($metaTags, $currentUrl) . "<body id='ipboard_body'>", $output);
     }
     /* Gooooogle analytics?! */
     if (!empty($this->settings['ipseo_ga'])) {
         $output = preg_replace("#</head>#", $this->settings['ipseo_ga'] . '</head>', $output, 1);
     }
     //-----------------------------------------
     // Check for SQL Debug
     //-----------------------------------------
     $this->_checkSQLDebug();
     //-----------------------------------------
     // Print it...
     //-----------------------------------------
     $this->outputFormatClass->printHeader();
     /* Remove unused hook comments */
     $output = preg_replace('#<!--hook\\.([^\\>]+?)-->#', '', $output);
     /* Insert stats */
     $output = str_replace('<!--DEBUG_STATS-->', $this->outputFormatClass->html_showDebugInfo(), $output);
     /* Return output instead of printing? */
     if ($return) {
         IPSDebug::setMemoryDebugFlag("Output sent", $_NOW);
         $this->outputFormatClass->finishUp();
         return $output;
     }
     print $output;
     IPSDebug::setMemoryDebugFlag("Output sent", $_NOW);
     $this->outputFormatClass->finishUp();
     exit;
 }
Exemplo n.º 18
0
 /**
  * Initiate class
  *
  * @return	@e void
  */
 private function init()
 {
     if (self::$initiated !== TRUE) {
         //--------------------------------
         // Eaccelerator...
         //--------------------------------
         if (function_exists('eaccelerator_get') and ipsRegistry::$settings['use_eaccelerator'] == 1) {
             require IPS_KERNEL_PATH . 'interfaces/interfaceCache.php';
             /*noLibHook*/
             require IPS_KERNEL_PATH . 'classCacheEaccelerator.php';
             /*noLibHook*/
             self::$cacheLib = new classCacheEaccelerator(ipsRegistry::$settings['board_url']);
         } else {
             if (function_exists('memcache_connect') and ipsRegistry::$settings['use_memcache'] == 1) {
                 require IPS_KERNEL_PATH . 'interfaces/interfaceCache.php';
                 /*noLibHook*/
                 require IPS_KERNEL_PATH . 'classCacheMemcache.php';
                 /*noLibHook*/
                 self::$cacheLib = new classCacheMemcache(ipsRegistry::$settings['board_url'], ipsRegistry::$settings);
             } else {
                 if (function_exists('xcache_get') and ipsRegistry::$settings['use_xcache'] == 1) {
                     require IPS_KERNEL_PATH . 'interfaces/interfaceCache.php';
                     /*noLibHook*/
                     require IPS_KERNEL_PATH . 'classCacheXcache.php';
                     /*noLibHook*/
                     self::$cacheLib = new classCacheXcache(ipsRegistry::$settings['board_url']);
                 } else {
                     if (function_exists('apc_fetch') and ipsRegistry::$settings['use_apc'] == 1) {
                         require IPS_KERNEL_PATH . 'interfaces/interfaceCache.php';
                         /*noLibHook*/
                         require IPS_KERNEL_PATH . 'classCacheApc.php';
                         /*noLibHook*/
                         self::$cacheLib = new classCacheApc(ipsRegistry::$settings['board_url']);
                     } else {
                         if (function_exists('wincache_ucache_get') and ipsRegistry::$settings['use_wincache'] == 1) {
                             require IPS_KERNEL_PATH . 'interfaces/interfaceCache.php';
                             /*noLibHook*/
                             require IPS_KERNEL_PATH . 'classCacheWincache.php';
                             /*noLibHook*/
                             self::$cacheLib = new classCacheWincache(ipsRegistry::$settings['board_url']);
                         } else {
                             if (!empty(ipsRegistry::$settings['use_diskcache'])) {
                                 require IPS_KERNEL_PATH . 'interfaces/interfaceCache.php';
                                 /*noLibHook*/
                                 require IPS_KERNEL_PATH . 'classCacheDiskcache.php';
                                 /*noLibHook*/
                                 self::$cacheLib = new classCacheDiskcache(ipsRegistry::$settings['board_url']);
                             }
                         }
                     }
                 }
             }
         }
         if (is_object(self::$cacheLib) and self::$cacheLib->crashed) {
             // There was a problem - not installed maybe?
             // unset(self::$cacheLib);
             self::$cacheLib = NULL;
         }
         $caches = array();
         $_caches = array();
         $_load = array();
         $_pre_load = IPSDebug::getMemoryDebugFlag();
         //-----------------------------------------
         // Get default cache list
         //-----------------------------------------
         $CACHE = ipsRegistry::_fetchCoreVariables('cache');
         $_LOAD = ipsRegistry::_fetchCoreVariables('cacheload');
         if (is_array($CACHE)) {
             foreach ($CACHE as $key => $data) {
                 if (!empty($data['acp_only']) and IPS_AREA != 'admin') {
                     continue;
                 }
                 $_caches[$key] = $CACHE;
                 if ($data['default_load']) {
                     $caches[$key] = $key;
                 }
             }
             if (count($_LOAD)) {
                 foreach ($_LOAD as $key => $one) {
                     $_load[$key] = $key;
                 }
             }
         }
         //-----------------------------------------
         // Get application cache list
         //-----------------------------------------
         if (IPS_APP_COMPONENT) {
             $CACHE = ipsRegistry::_fetchAppCoreVariables(IPS_APP_COMPONENT, 'cache');
             $_LOAD = ipsRegistry::_fetchAppCoreVariables(IPS_APP_COMPONENT, 'cacheload');
             if (is_array($CACHE)) {
                 foreach ($CACHE as $key => $data) {
                     if (!empty($data['acp_only']) and IPS_AREA != 'admin') {
                         continue;
                     }
                     $_caches[$key] = $CACHE;
                     if ($data['default_load']) {
                         $caches[$key] = $key;
                     }
                 }
                 if (count($_LOAD)) {
                     foreach ($_LOAD as $key => $one) {
                         $_load[$key] = $key;
                     }
                 }
             }
         }
         //-----------------------------------------
         // Get global caches list
         //-----------------------------------------
         if (is_file(GLOBAL_CACHE_PATH)) {
             $GLOBAL_CACHES = array();
             include GLOBAL_CACHE_PATH;
             /*noLibHook*/
             if (is_array($GLOBAL_CACHES) and count($GLOBAL_CACHES)) {
                 foreach ($GLOBAL_CACHES as $key) {
                     $_load[$key] = $key;
                 }
             }
         }
         //-----------------------------------------
         // Add caches to the load list
         //-----------------------------------------
         if (is_array($_load) and count($_load)) {
             foreach ($_load as $key) {
                 $caches[$key] = $key;
             }
         }
         //-----------------------------------------
         // Load 'em
         //-----------------------------------------
         self::_loadCaches($caches);
     }
     self::$initiated = TRUE;
 }
Exemplo n.º 19
0
 /**
  * Add a new statussesses
  *
  * @return	@e void
  */
 protected function _new()
 {
     IPSDebug::fireBug('info', array('Status content: ' . $_POST['content']));
     IPSDebug::fireBug('info', array('Cleaned status: ' . trim($this->convertAndMakeSafe($_POST['content']))));
     /* INIT */
     $smallSpace = intval($this->request['smallSpace']);
     $su_Twitter = intval($this->request['su_Twitter']);
     $su_Facebook = intval($this->request['su_Facebook']);
     $skin_group = $this->getSkinGroup();
     $forMemberId = intval($this->request['forMemberId']);
     /* Got content? */
     if (!trim($this->convertAndMakeSafe(str_replace(array('&nbsp;', '&#160;'), '', $_POST['content'])))) {
         $this->returnJsonError($this->lang->words['no_status_sent']);
     }
     /* Set Author */
     $this->registry->getClass('memberStatus')->setAuthor($this->memberData);
     /* Set Content */
     $this->registry->getClass('memberStatus')->setContent(trim($this->convertAndMakeSafe($_POST['content'])));
     /* Can we create? */
     if (!$this->registry->getClass('memberStatus')->canCreate()) {
         $this->returnJsonError($this->lang->words['status_off']);
     }
     /* Update or comment? */
     if ($forMemberId && $forMemberId != $this->memberData['member_id']) {
         $owner = IPSMember::load($forMemberId);
         if (!$owner['pp_setting_count_comments']) {
             $this->returnJsonError($this->lang->words['status_off']);
         }
         /* Set owner */
         $this->registry->getClass('memberStatus')->setStatusOwner($owner);
     } else {
         /* Set post outs */
         $this->registry->getClass('memberStatus')->setExternalUpdates(array('twitter' => $su_Twitter, 'facebook' => $su_Facebook));
     }
     /* Update */
     $newStatus = $this->registry->getClass('memberStatus')->create();
     if (!$newStatus) {
         $this->returnJsonError($this->lang->words['status_off']);
     }
     /* Now grab the reply and return it */
     $status = $this->registry->getClass('memberStatus')->fetch($this->memberData['member_id'], array('relatedTo' => $forMemberId, 'sort_dir' => 'desc', 'limit' => 1));
     $last = $status;
     $last = array_pop($last);
     if ($last['status_approved']) {
         $new = $this->registry->getClass('output')->getTemplate($skin_group)->statusUpdates($status, $smallSpace);
         $this->returnJsonArray(array('status' => 'success', 'html' => $new), true);
     } else {
         $this->returnJsonError('prof_comment_mod');
     }
 }
 /**
  * Returns debug data
  *
  * @access	private
  * @return	string		Debug HTML
  */
 public function html_showDebugInfo()
 {
     $input = "";
     $queries = "";
     $sload = "";
     $stats = "";
     //-----------------------------------------
     // Form & Get & Skin
     //-----------------------------------------
     /* Admins only */
     if (!$this->memberData['g_access_cp']) {
         //return '';
     }
     if ($this->settings['debug_level'] >= 2) {
         $stats .= "<br />\n<div class='tableborder'>\n<div class='subtitle'>IPSDebug Messages</div><div class='row1' style='padding:6px'>\n";
         foreach (IPSDebug::getMessages() as $dx => $entry) {
             $stats .= "<strong>{$entry}</strong><br />\n";
         }
         $stats .= "</div>\n</div>";
         $stats .= "<br />\n<div class='tableborder'>\n<div class='subtitle'>IPSMember Cache Actions</div><div class='row1' style='padding:6px'>\n";
         if (is_array(IPSMember::$debugData)) {
             foreach (IPSMember::$debugData as $entry) {
                 $stats .= "<strong>{$entry}</strong><br />\n";
             }
         }
         $stats .= "</div>\n</div>";
         /* Included Files */
         if (function_exists('get_included_files')) {
             $__files = get_included_files();
             $stats .= "<br />\n<div class='tableborder'>\n<div class='subtitle'>(" . count($__files) . ") Included Files</div><div class='row1' style='padding:6px'>\n";
             foreach ($__files as $__f) {
                 $stats .= "<strong>{$__f}</strong><br />";
             }
             $stats .= '</div></div>';
         }
         /* Caches */
         $stats .= "<br />\n<div class='tableborder'>\n<div class='subtitle'>Loaded Caches</div><div class='row1' style='padding:6px'>\n";
         $_total = 0;
         if (is_array($this->cache->debugInfo)) {
             foreach ($this->cache->debugInfo as $key => $data) {
                 $_size = $data['size'];
                 $_total += $_size;
                 $stats .= "<strong>{$key}</strong> - " . IPSLib::sizeFormat($_size) . "<br />\n";
             }
         }
         $stats .= "<strong>TOTAL: " . IPSLib::sizeFormat($_total) . "</strong></div>\n</div>";
         /* Loaded classes */
         $loadedClasses = $this->registry->getLoadedClassesAsArray();
         $stats .= "<br />\n<div class='tableborder'>\n<div class='subtitle'>Loaded Classes In ipsRegistry::getClass()</div><div class='row1' style='padding:6px'>\n";
         if (is_array($loadedClasses)) {
             foreach ($loadedClasses as $entry) {
                 $stats .= "<strong>{$entry}</strong><br />\n";
             }
         }
         $stats .= "</div>\n</div>";
         $stats .= "<br />\n<div class='tableborder'>\n<div class='subtitle'>FORM and GET Input</div><div class='row1' style='padding:6px'>\n";
         foreach ($this->request as $k => $v) {
             if (in_array(strtolower($k), array('pass', 'password'))) {
                 $v = '*******';
             }
             $stats .= "<strong>{$k}</strong> = {$v}<br />\n";
         }
         $stats .= "</div>\n</div>";
         $stats .= "<br />\n<div class='tableborder'>\n<div class='subtitle'>SKIN, MEMBER & TASK Info</div><div class='row1' style='padding:6px'>\n";
         while (list($k, $v) = each($this->skin)) {
             if (is_array($v)) {
                 continue;
             }
             if (strlen($v) > 120) {
                 $v = substr($v, 0, 120) . '...';
             }
             $stats .= "<strong>{$k}</strong> = " . IPSText::htmlspecialchars($v) . "<br />\n";
         }
         //-----------------------------------------
         // Stop E_ALL moaning...
         //-----------------------------------------
         $cache = $this->caches['systemvars'];
         $cache['task_next_run'] = $cache['task_next_run'] ? $cache['task_next_run'] : 0;
         $stats .= "<b>Next task</b> = " . $this->registry->getClass('class_localization')->getDate($cache['task_next_run'], 'LONG') . "\n<br /><b>Time now</b> = " . $this->registry->getClass('class_localization')->getDate(time(), 'LONG');
         $stats .= "<br /><b>Timestamp Now</b> = " . time();
         $stats .= "<p>MEMBER: last_visit: " . $this->memberData['last_visit'] . " / " . $this->registry->getClass('class_localization')->getDate($this->memberData['last_visit'], 'LONG') . "</p>";
         $stats .= "<p>MEMBER: uagent_key: " . $this->memberData['userAgentKey'] . "</p>";
         $stats .= "<p>MEMBER: uagent_type: " . $this->memberData['userAgentType'] . "</p>";
         $stats .= "<p>MEMBER: uagent_version: " . $this->memberData['userAgentVersion'] . "</p>";
         $stats .= "</div>\n</div>";
         $stats .= "<br />\n<div class='tableborder'>\n<div class='subtitle'>Loaded PHP Templates</div><div class='row1' style='padding:6px'>\n";
         $stats .= "<strong>" . implode(", ", array_keys($this->output->compiled_templates)) . "</strong><br />\n";
         $stats .= "<strong>" . implode(", ", array_keys($this->output->loaded_templates)) . "</strong><br />\n";
         $stats .= "<strong>" . implode(", ", array_values($this->registry->getClass('class_localization')->loaded_lang_files)) . "</strong><br />\n";
         $stats .= "</div>\n</div>";
     }
     //-----------------------------------------
     // SQL
     //-----------------------------------------
     if ($this->settings['debug_level'] >= 3) {
         $stats .= "<br />\n<div class='tableborder' style='overflow:auto'>\n<div class='subtitle'>Queries Used</div><div class='row1' style='padding:6px'>";
         foreach ($this->DB->obj['cached_queries'] as $q) {
             $q = htmlspecialchars($q);
             $q = str_ireplace("SELECT", "<span style='color:red'>SELECT</span>", $q);
             $q = preg_replace("/^UPDATE/i", "<span style='color:blue'>UPDATE</span>", $q);
             $q = preg_replace("/^DELETE/i", "<span style='color:orange'>DELETE</span>", $q);
             $q = preg_replace("/^INSERT/i", "<span style='color:green'>INSERT</span>", $q);
             $q = str_replace("LEFT JOIN", "<span style='color:red'>LEFT JOIN</span>", $q);
             $stats .= "<p style='padding:6px;border-bottom:1px solid black'>{$q}</p>\n";
         }
         if (count($this->DB->obj['shutdown_queries'])) {
             foreach ($this->DB->obj['shutdown_queries'] as $q) {
                 $q = htmlspecialchars($q);
                 $q = preg_replace("/^SELECT/i", "<span style='color:red'>SELECT</span>", $q);
                 $q = preg_replace("/^UPDATE/i", "<span style='color:blue'>UPDATE</span>", $q);
                 $q = preg_replace("/^DELETE/i", "<span style='color:orange'>DELETE</span>", $q);
                 $q = preg_replace("/^INSERT/i", "<span style='color:green'>INSERT</span>", $q);
                 $q = str_replace("LEFT JOIN", "<span style='color:red'>LEFT JOIN</span>", $q);
                 //$q = preg_replace( "/(".$this->settings['sql_tbl_prefix'].")(\S+?)([\s\.,]|$)/", "<span class='purple'>\\1\\2</span>\\3", $q );
                 $stats .= "<div style='background:#DEDEDE'><b>SHUTDOWN:</b> {$q}</div><br />\n";
             }
         }
         $stats .= "</div>\n</div>";
     }
     if ($stats) {
         $stats = "\n\t\t\t\t\t  <div align='center'>\n\t\t\t\t\t   <div class='row2' style='padding:8px;vertical-align:middle'><a href='#' onclick=\"\$('debug').toggle(); return false;\">Hide Debug Information</a></div>\n\t\t\t\t\t   <br />\n\t\t\t\t\t   <div class='tableborder' align='left' id='debug'>\n\t\t\t\t\t\t<div class='maintitle'>Debug Information</div>\n\t\t\t\t\t\t <div style='padding:5px;background:#8394B2;'>{$stats}</div>\n\t\t\t\t\t   </div>\n\t\t\t\t\t  </div>";
     }
     return $stats;
 }
 /**
  * Load a template file
  *
  * @access	public
  * @param	string		Template name
  * @param	string		Application [defaults to current application]
  * @return	object
  */
 public function loadTemplate($template, $app = '')
 {
     $app = $app ? $app : IPS_APP_COMPONENT;
     /* Skin file exists? */
     if (file_exists(IPSLib::getAppDir($app) . "/skin_cp/" . $template . ".php")) {
         $_pre_load = IPSDebug::getMemoryDebugFlag();
         require_once IPSLib::getAppDir($app) . "/skin_cp/" . $template . ".php";
         IPSDebug::setMemoryDebugFlag("CORE: Template Loaded ({$template})", $_pre_load);
         return new $template($this->registry);
     } else {
         $this->showError("Could not locate template: {$template}", 4100, true);
     }
 }
Exemplo n.º 22
0
 /**
  * Fetches the output
  *
  * @access	public
  * @param	string		Output gathered
  * @param	string		Title of the document
  * @param	array 		Navigation gathered
  * @param	array 		Array of document head items
  * @param	array 		Array of JS loader items
  * @param	array 		Array of extra data
  * @return	string		Output to be printed to the client
  */
 public function fetchOutput($output, $title, $navigation, $documentHeadItems, $jsLoaderItems, $extraData = array())
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $system_vars_cache = $this->caches['systemvars'];
     $showPMBox = '';
     $currentCharSet = $this->settings['gb_char_set'];
     /* Force UTF-8 for the skin */
     $this->settings['gb_char_set'] = 'UTF-8';
     //-----------------------------------------
     // NORMAL
     //-----------------------------------------
     if ($this->_outputType == 'normal') {
         //-----------------------------------------
         // Grab output
         //-----------------------------------------
         $finalOutput = $this->output->getTemplate('global')->globalTemplate($output, $documentHeadItems, $this->_css, $jsLoaderItems, $this->_metaTags, array('title' => $title, 'applications' => $this->core_fetchApplicationData(), 'page' => $this->_current_page_title), array('navigation' => $navigation), array('time' => $this->registry->getClass('class_localization')->getDate(time(), 'SHORT', 1), 'lang_chooser' => $this->html_buildLanguageDropDown(), 'skin_chooser' => $this->html_fetchSetsDropDown(), 'stats' => $this->html_showDebugInfo(), 'copyright' => $this->html_fetchCopyright()), array('ex_time' => sprintf("%.4f", IPSDebug::endTimer()), 'gzip_status' => $this->settings['disable_gzip'] == 1 ? $this->lang->words['gzip_off'] : $this->lang->words['gzip_on'], 'server_load' => ipsRegistry::$server_load, 'queries' => $this->DB->getQueryCount()));
     } else {
         if ($this->_outputType == 'redirect') {
             # SEO?
             if ($extraData['seoTitle']) {
                 $extraData['url'] = $this->output->buildSEOUrl($extraData['url'], 'none', $extraData['seoTitle']);
                 $extraData['full'] = 1;
             }
             $finalOutput = $this->output->getTemplate('global')->redirectTemplate($documentHeadItems, $this->_css, $jsLoaderItems, $extraData['text'], $extraData['url'], $extraData['full']);
         } else {
             if ($this->_outputType == 'popup') {
                 $finalOutput = $this->output->getTemplate('global')->displayPopUpWindow($documentHeadItems, $this->_css, $jsLoaderItems, $title, $output);
             }
         }
     }
     //-----------------------------------------
     // Return
     //-----------------------------------------
     $finalOutput = $this->parseIPSTags($finalOutput);
     /* Attempt to clean HTML */
     return IPSText::stripNonUtf8(IPSText::convertCharsets($finalOutput, $currentCharSet, 'UTF-8'));
 }
Exemplo n.º 23
0
 /**
  * Checks and logs any errors
  *
  * @access	public
  * @return	@e void
  */
 public function logSphinxWarnings()
 {
     $error = $this->sphinxClient->GetLastError();
     $warning = $this->sphinxClient->GetLastWarning();
     if ($error) {
         IPSDebug::addLogMessage("Sphinx Error: {$error}", 'sphinx_error_' . date('m_d_y'), $error, TRUE);
     }
     if ($warning) {
         IPSDebug::addLogMessage("Sphinx Warning: {$warning}", 'sphinx_warning_' . date('m_d_y'), $warning, TRUE);
     }
 }
 /**
  * Main output function
  *
  * @access	public
  * @return	void 
  */
 public function sendOutput()
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $_NOW = IPSDebug::getMemoryDebugFlag();
     $this->_sendOutputSetUp('normal');
     //-----------------------------------------
     // Gather output
     //-----------------------------------------
     $output = $this->outputFormatClass->fetchOutput($this->_html, $this->_title, $this->_navigation, $this->_documentHeadItems, $this->_jsLoader);
     $output = $this->templateHooks($output);
     //-----------------------------------------
     // Check for SQL Debug
     //-----------------------------------------
     $this->_checkSQLDebug();
     //-----------------------------------------
     // Print it...
     //-----------------------------------------
     $this->outputFormatClass->printHeader();
     /* Remove unused hook comments */
     $output = preg_replace("#<!--hook\\.([^\\>]+?)-->#", '', $output);
     /* Insert stats */
     $output = str_replace('<!--DEBUG_STATS-->', $this->outputFormatClass->html_showDebugInfo(), $output);
     print $output;
     IPSDebug::setMemoryDebugFlag("Output sent", $_NOW);
     $this->outputFormatClass->finishUp();
     exit;
 }
Exemplo n.º 25
0
 /**
  * This function processes the DB post before printing as output
  *
  * @access	public
  * @param	string			Raw text
  * @return	string			Converted text
  */
 public function preDisplayParse($txt = "")
 {
     $this->cache->updateCacheWithoutSaving('_tmp_bbcode_media', 0);
     $this->cache->updateCacheWithoutSaving('_tmp_bbcode_images', 0);
     if ($this->parse_html) {
         //-----------------------------------------
         // Store true line breaks first
         //-----------------------------------------
         $txt = str_replace('<br />', "~~~~~_____~~~~~", $txt);
         $txt = $this->_parseHtml($txt);
         /* We still don't want XSS thx */
         if (!$this->skipXssCheck) {
             $txt = $this->checkXss($txt, true);
         }
     }
     /* http://community.invisionpower.com/resources/bugs.html/_/ip-board/profile-quotes-in-likes-tab-does-not-appear-r42346
     		else
     		{
     			$txt = str_replace( '  ', '&nbsp;&nbsp;', $txt );
     		}*/
     //-----------------------------------------
     // Fix "{style_images_url}"
     //-----------------------------------------
     $txt = str_replace("{style_images_url}", "&#123;style_images_url&#125;", $txt);
     //-----------------------------------------
     // Custom BB code
     //-----------------------------------------
     $_NOW = IPSDebug::getMemoryDebugFlag();
     IPSDebug::setMemoryDebugFlag("PreDisplayParse - parsed BBCode", $_NOW);
     //-----------------------------------------
     // Fix line breaks
     //-----------------------------------------
     if ($this->parse_html) {
         $txt = str_replace("~~~~~_____~~~~~", '<br />', $txt);
     }
     $_memberData = array('member_group_id' => $this->parsing_mgroup, 'mgroup_others' => $this->parsing_mgroup_others);
     if ($this->parsing_mgroup) {
         $_memberData = array_merge($_memberData, $this->caches['group_cache'][$this->parsing_mgroup]);
     }
     if ($this->parsing_mgroup_others) {
         $_memberData = ips_MemberRegistry::setUpSecondaryGroups($_memberData);
     }
     /* Finish hiiiiiiiiiiiiiiim */
     $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/text/parser.php', 'classes_text_parser');
     $parser = new $classToLoad();
     $parser->set(array('memberData' => $_memberData, 'parseBBCode' => $this->parse_bbcode, 'parseArea' => $this->parsing_section, 'parseHtml' => $this->parse_html, 'parseEmoticons' => $this->parse_smilies));
     /* Convert emos back into code */
     $txt = $parser->emoticonImgtoCode($txt);
     $txt = $parser->display($txt);
     //-----------------------------------------
     // Fix images nested inside anchors
     //-----------------------------------------
     $txt = preg_replace_callback('#(\\<a[^\\>]+bbc_url[^\\>]+\\>)\\s*?(.+?)\\s*?(\\<\\/a\\>)#im', array($this, 'removeLightboxSpans'), $txt);
     return $txt;
 }
Exemplo n.º 26
0
 /**
  * View new posts since your last visit
  *
  * @return	@e void
  */
 public function viewNewContent()
 {
     IPSSearchRegistry::set('in.search_app', $this->request['search_app']);
     /* Fetch member cache to see if we have a value set */
     $vncPrefs = IPSMember::getFromMemberCache($this->memberData, 'vncPrefs');
     /* Guests */
     if (!$this->memberData['member_id'] and (!$this->request['period'] or $this->request['period'] == 'unread')) {
         $this->request['period'] = 'today';
     }
     /* In period */
     if ($vncPrefs === null or !isset($vncPrefs[IPSSearchRegistry::get('in.search_app')]['view']) or !empty($this->request['period']) and isset($this->request['change'])) {
         $vncPrefs[IPSSearchRegistry::get('in.search_app')]['view'] = !empty($this->request['period']) ? $this->request['period'] : $this->settings['default_vnc_method'];
     }
     /* Follow filter enabled */
     if ($vncPrefs === null or !isset($vncPrefs[IPSSearchRegistry::get('in.search_app')]['view']) or isset($this->request['followedItemsOnly'])) {
         $vncPrefs[IPSSearchRegistry::get('in.search_app')]['vncFollowFilter'] = !empty($this->request['followedItemsOnly']) ? 1 : 0;
     }
     /* User mode */
     if ($vncPrefs === null or !isset($vncPrefs[IPSSearchRegistry::get('in.search_app')]['view']) or isset($this->request['userMode'])) {
         $vncPrefs[IPSSearchRegistry::get('in.search_app')]['userMode'] = !empty($this->request['userMode']) ? $this->request['userMode'] : '';
     }
     /* Set filters up */
     IPSSearchRegistry::set('forums.vncForumFilters', $vncPrefs['forums']['vnc_forum_filter']);
     IPSSearchRegistry::set('in.period', $vncPrefs[IPSSearchRegistry::get('in.search_app')]['view']);
     IPSSearchRegistry::set('in.vncFollowFilterOn', $vncPrefs[IPSSearchRegistry::get('in.search_app')]['vncFollowFilter']);
     IPSSearchRegistry::set('in.userMode', $vncPrefs[IPSSearchRegistry::get('in.search_app')]['userMode']);
     /* Update member cache */
     if (isset($this->request['period']) and isset($this->request['change'])) {
         IPSMember::setToMemberCache($this->memberData, array('vncPrefs' => $vncPrefs));
     }
     IPSDebug::addMessage(var_export($vncPrefs, true));
     IPSDebug::addMessage('Using: ' . IPSSearchRegistry::get('in.period'));
     /* Can we do this? */
     if (IPSLib::appIsSearchable(IPSSearchRegistry::get('in.search_app'), 'vnc') || IPSLib::appIsSearchable(IPSSearchRegistry::get('in.search_app'), 'active')) {
         /* Can't do a specific unread search, so */
         if (IPSSearchRegistry::get('in.period') == 'unread' && !IPSLib::appIsSearchable(IPSSearchRegistry::get('in.search_app'), 'vncWithUnreadContent')) {
             IPSSearchRegistry::set('in.period', 'lastvisit');
         }
         /* Perform the search */
         $this->searchController->viewNewContent();
         /* Get count */
         $count = $this->searchController->getResultCount();
         /* Get results which will be array of IDs */
         $results = $this->searchController->getResultSet();
         /* Get templates to use */
         $template = $this->searchController->fetchTemplates();
         /* Fetch sort details */
         $sortDropDown = $this->searchController->fetchSortDropDown();
         /* Fetch sort details */
         $sortIn = $this->searchController->fetchSortIn();
         /* Reset for template */
         $this->_resetRequestParameters();
         if (IPSSearchRegistry::get('in.start') > 0 and !count($results)) {
             $new_url = 'app=core&amp;module=search&amp;do=viewNewContent&amp;period=' . IPSSearchRegistry::get('in.period') . '&amp;userMode=' . IPSSearchRegistry::get('in.userMode') . '&amp;search_app=' . IPSSearchRegistry::get('in.search_app') . '&amp;sid=' . $this->request['_sid'];
             $new_url .= '&amp;st=' . (IPSSearchRegistry::get('in.start') - IPSSearchRegistry::get('opt.search_per_page')) . '&amp;search_app_filters[' . IPSSearchRegistry::get('in.search_app') . '][searchInKey]=' . $this->request['search_app_filters'][IPSSearchRegistry::get('in.search_app')]['searchInKey'];
             $this->registry->output->silentRedirect($this->settings['base_url'] . $new_url);
         }
         /* Parse result set */
         $results = $this->registry->output->getTemplate($template['group'])->{$template}['template']($results, IPSSearchRegistry::get('opt.searchType') == 'titles' || IPSSearchRegistry::get('opt.noPostPreview') ? 1 : 0);
         /* Build pagination */
         $links = $this->registry->output->generatePagination(array('totalItems' => $count, 'itemsPerPage' => IPSSearchRegistry::get('opt.search_per_page'), 'currentStartValue' => IPSSearchRegistry::get('in.start'), 'baseUrl' => 'app=core&amp;module=search&amp;do=viewNewContent&amp;period=' . IPSSearchRegistry::get('in.period') . '&amp;userMode=' . IPSSearchRegistry::get('in.userMode') . '&amp;search_app=' . IPSSearchRegistry::get('in.search_app') . '&amp;sid=' . $this->request['_sid'] . $this->_returnSearchAppFilters()));
         /* Showing */
         $showing = array('start' => IPSSearchRegistry::get('in.start') + 1, 'end' => IPSSearchRegistry::get('in.start') + IPSSearchRegistry::get('opt.search_per_page') > $count ? $count : IPSSearchRegistry::get('in.start') + IPSSearchRegistry::get('opt.search_per_page'));
     } else {
         $count = 0;
         $results = array();
     }
     /* Add Debug message */
     IPSDebug::addMessage("View New Content Matches: " . $count);
     /* Check for sortIn */
     if (count($sortIn) && !$this->request['search_app_filters'][$this->request['search_app']]['searchInKey']) {
         $this->request['search_app_filters'][$this->request['search_app']]['searchInKey'] = $sortIn[0][0];
     }
     /* Output */
     $this->title = $this->lang->words['new_posts_title'];
     $this->registry->output->addNavigation($this->lang->words['new_posts_title'], '');
     $this->output .= $this->registry->output->getTemplate('search')->newContentView($results, $links, $count, $sortDropDown, $sortIn, IPSSearchRegistry::get('set.resultCutToDate'));
 }
Exemplo n.º 27
0
 /**
  * Show the overview page
  *
  * @return	@e void		[Outputs to screen]
  */
 public function _listFunctions()
 {
     //-----------------------------------------
     // PHP INFO?
     //-----------------------------------------
     if ($this->request['phpinfo'] and $this->request['phpinfo']) {
         @ob_start();
         phpinfo();
         $parsed = @ob_get_contents();
         @ob_end_clean();
         preg_match("#<body>(.*)</body>#is", $parsed, $match1);
         $php_body = $match1[1];
         # PREVENT WRAP: Most cookies
         $php_body = str_replace("; ", ";<br />", $php_body);
         # PREVENT WRAP: Very long string cookies
         $php_body = str_replace("%3B", "<br />", $php_body);
         # PREVENT WRAP: Serialized array string cookies
         $php_body = str_replace(";i:", ";<br />i:", $php_body);
         # PREVENT WRAP: LS_COLORS env
         $php_body = str_replace(":*.", "<br />:*.", $php_body);
         # PREVENT WRAP: PATH env
         $php_body = str_replace("bin:/", "bin<br />:/", $php_body);
         # PREVENT WRAP: Cookie %2C split
         $php_body = str_replace("%2C", "%2C<br />", $php_body);
         #PREVENT WRAP: Cookie , split
         $php_body = preg_replace("#,(\\d+),#", ",<br />\\1,", $php_body);
         $this->registry->output->html .= $this->html->phpInfo($php_body);
         return;
     }
     //-----------------------------------------
     // Stats
     //-----------------------------------------
     $reg = $this->DB->buildAndFetch(array('select' => 'COUNT(*) as reg', 'from' => array('validating' => 'v'), 'where' => 'v.lost_pass <> 1 AND m.member_group_id=' . $this->settings['auth_group'], 'add_join' => array(array('from' => array('members' => 'm'), 'where' => 'm.member_id=v.member_id', 'type' => 'left'))));
     if ($this->settings['ipb_bruteforce_attempts']) {
         $lock = $this->DB->buildAndFetch(array('select' => 'COUNT(*) as mems', 'from' => 'members', 'where' => 'failed_login_count >= ' . $this->settings['ipb_bruteforce_attempts']));
     }
     $my_timestamp = time() - $this->settings['au_cutoff'] * 60;
     $online = $this->DB->buildAndFetch(array('select' => 'COUNT(*) as sessions', 'from' => 'sessions', 'where' => 'running_time>' . $my_timestamp));
     $pending = $this->DB->buildAndFetch(array('select' => 'SUM(queued_topics) as topics, SUM(queued_posts) as posts', 'from' => 'forums'));
     $spammers = $this->DB->buildAndFetch(array('select' => 'COUNT(*) as count', 'from' => 'members', 'where' => "members_bitoptions = '1'"));
     $statsbox = $this->html->acp_stats_wrapper(array('topics' => ipsRegistry::getClass('class_localization')->formatNumber($this->caches['stats']['total_topics']), 'replies' => ipsRegistry::getClass('class_localization')->formatNumber($this->caches['stats']['total_replies']), 'topics_mod' => ipsRegistry::getClass('class_localization')->formatNumber($pending['topics']), 'posts_mod' => ipsRegistry::getClass('class_localization')->formatNumber($pending['posts']), 'members' => ipsRegistry::getClass('class_localization')->formatNumber($this->caches['stats']['mem_count']), 'validate' => ipsRegistry::getClass('class_localization')->formatNumber($reg['reg']), 'spammer' => ipsRegistry::getClass('class_localization')->formatNumber($spammers['count']), 'locked' => ipsRegistry::getClass('class_localization')->formatNumber($lock['mems']), 'sql_driver' => strtoupper(SQL_DRIVER), 'sql_version' => $this->DB->true_version, 'php_version' => phpversion(), 'sessions' => ipsRegistry::getClass('class_localization')->formatNumber($online['sessions']), 'php_sapi' => @php_sapi_name(), 'ipb_version' => ipsRegistry::$version, 'ipb_id' => ipsRegistry::$vn_full));
     //-----------------------------------------
     // Server stuff
     //-----------------------------------------
     $this->DB->getSqlVersion();
     $sql_version = strtoupper($this->settings['sql_driver']) . " " . $this->DB->true_version;
     $php_version = phpversion() . " (" . @php_sapi_name() . ")  ( <a href='{$this->settings['base_url']}{$this->form_code}&amp;phpinfo=1'>{$this->lang->words['d_aphpinfo']}</a> )";
     $server_software = @php_uname();
     $load_limit = IPSDebug::getServerLoad();
     $server_load_found = 0;
     $total_memory = "--";
     $avail_memory = "--";
     $_disabled = @ini_get('disable_functions') ? explode(',', @ini_get('disable_functions')) : array();
     $_shellExecAvail = in_array('shell_exec', $_disabled) ? false : true;
     //-----------------------------------------
     // Check memory
     //-----------------------------------------
     if (strpos(strtolower(PHP_OS), 'win') === 0) {
         $mem = $_shellExecAvail ? @shell_exec('systeminfo') : null;
         if ($mem) {
             $server_reply = explode("\n", str_replace("\r", "", $mem));
             if (count($server_reply)) {
                 foreach ($server_reply as $info) {
                     if (strstr($info, $this->lang->words['d_atotal'])) {
                         $total_memory = trim(str_replace(":", "", strrchr($info, ":")));
                     }
                     if (strstr($info, $this->lang->words['d_aavail'])) {
                         $avail_memory = trim(str_replace(":", "", strrchr($info, ":")));
                     }
                 }
             }
         }
     } else {
         $mem = $_shellExecAvail ? @shell_exec("free -m") : null;
         if ($mem) {
             $server_reply = explode("\n", str_replace("\r", "", $mem));
             $mem = array_slice($server_reply, 1, 1);
             $mem = preg_split("#\\s+#", $mem[0]);
             $total_memory = $mem[1] ? $mem[1] . ' MB' : '--';
             $avail_memory = $mem[3] ? $mem[3] . ' MB' : '--';
         } else {
             $total_memory = '--';
             $avail_memory = '--';
         }
     }
     $disabled_functions = is_array($_disabled) && count($_disabled) ? implode(', ', $_disabled) : $this->lang->words['d_anoinfo'];
     $extensions = get_loaded_extensions();
     $extensions = array_combine($extensions, $extensions);
     sort($extensions, SORT_STRING);
     //-----------------------------------------
     // Set variables and pass to skin
     //-----------------------------------------
     $data = array('version' => 'v' . IPB_VERSION, 'version_full' => IPB_LONG_VERSION, 'version_sql' => $sql_version, 'driver_type' => strtoupper($this->settings['sql_driver']), 'version_php' => $php_version, 'disabled' => $disabled_functions, 'extensions' => str_replace("suhosin", "<strong>suhosin</strong>", implode(", ", $extensions)), 'safe_mode' => SAFE_MODE_ON == 1 ? "<span style='color:red;font-weight:bold;'>{$this->lang->words['d_aon']}</span>" : "<span style='color:green;font-weight:bold;'>{$this->lang->words['d_aoff']}</span>", 'server' => $server_software, 'load' => $load_limit, 'total_memory' => $total_memory, 'avail_memory' => $avail_memory);
     if ($_shellExecAvail) {
         if (strpos(strtolower(PHP_OS), 'win') === 0) {
             $tasks = @shell_exec("tasklist");
             $tasks = str_replace(" ", "&nbsp;", $tasks);
         } else {
             if (strtolower(PHP_OS) == 'darwin') {
                 $tasks = @shell_exec("top -l 1");
                 $tasks = str_replace(" ", "&nbsp;", $tasks);
             } else {
                 $tasks = @shell_exec("top -b -n 1");
                 $tasks = str_replace(" ", "&nbsp;", $tasks);
             }
         }
     } else {
         $tasks = '';
     }
     if (!$tasks) {
         $tasks = $this->lang->words['d_aunable'];
     } else {
         $tasks = "<pre>" . $tasks . "</pre>";
     }
     $data['tasks'] = $tasks;
     $this->registry->output->html .= $this->html->diagnosticsOverview($data, $statsbox);
 }
 /**
  * Loads the language file, also loads the global lang file if not loaded
  * 
  * @access	public
  * @param	array 	[$load]		Array of lang files to load
  * @param	string	[$app]		Specify application to use
  * @param	string	[$lang]		Language pack to use
  * @return	void
  */
 public function loadLanguageFile($load = array(), $app = '', $lang = '')
 {
     $_MASTER2 = IPSDebug::getMemoryDebugFlag();
     /* App */
     $app = $app ? $app : IPS_APP_COMPONENT;
     $load = $load ? $load : array();
     $global = IPS_AREA == 'admin' ? 'core_admin_global' : 'core_public_global';
     $_global = str_replace('core_', '', $global);
     if ($lang and !IN_DEV) {
         $tempLangId = $this->lang_id;
         $this->lang_id = $lang;
     }
     /* Some older calls may still think $load is a string... */
     if (is_string($load)) {
         $load = array($load);
     }
     /* Has the global language file been loaded? */
     if (!in_array($global, $this->loaded_lang_files) and ($app == 'core' and !in_array($_global, $load))) {
         $load[] = $global;
     }
     /* Load the language file */
     $errors = '';
     if ($this->load_from_db or $this->_forceEnglish) {
         if (is_array($load) and count($load)) {
             /* Reformat for query and make sure we're not loading something twice */
             $_load = array();
             foreach ($load as $l) {
                 /* Already loaded? */
                 if (!in_array($app . $l, $this->loaded_lang_files)) {
                     /* Reformat */
                     $_load[] = "'{$l}'";
                 }
                 /* Add to the loaded array */
                 $this->loaded_lang_files[] = $app . '_' . $l;
             }
             /* Query the lang entries */
             $this->DB->build(array('select' => 'word_key, word_default, word_custom', 'from' => 'core_sys_lang_words', 'where' => "lang_id={$this->lang_id} AND word_app='{$app}' AND word_pack IN ( " . implode(',', $_load) . " )"));
             $this->DB->execute();
             /* Add to the language array */
             while ($r = $this->DB->fetch()) {
                 $this->words[$r['word_key']] = $this->_forceEnglish ? $r['word_default'] : ($r['word_custom'] ? $r['word_custom'] : $r['word_default']);
             }
         }
     } else {
         if (is_array($load) and count($load)) {
             foreach ($load as $l) {
                 /* Load global from the core app */
                 if ($l == $global) {
                     $_file = IPS_CACHE_PATH . 'cache/lang_cache/' . $this->lang_id . '/' . $l . '.php';
                     $_test = $l;
                 } else {
                     $_file = IPS_CACHE_PATH . 'cache/lang_cache/' . $this->lang_id . '/' . $app . '_' . $l . '.php';
                     $_test = $app . '_' . $l;
                 }
                 if (!in_array($_test, $this->loaded_lang_files)) {
                     if (file_exists($_file)) {
                         require $_file;
                         foreach ($lang as $k => $v) {
                             $this->words[$k] = $v;
                         }
                         $this->loaded_lang_files[] = $_test;
                         IPSDebug::setMemoryDebugFlag("Loaded Language File: " . str_replace(IPS_CACHE_PATH, '', $_file), $_MASTER2);
                     } else {
                         $errors .= "<li>Missing Language File: " . $_file;
                         IPSDebug::setMemoryDebugFlag("NO SUCH Language File: " . str_replace(IPS_CACHE_PATH, '', $_file), $_MASTER2);
                     }
                 } else {
                     IPSDebug::setMemoryDebugFlag("ALREADY LOADED Language File: " . str_replace(IPS_CACHE_PATH, '', $_file), $_MASTER2);
                 }
             }
         }
     }
     if (isset($tempLangId) and $tempLangId) {
         $this->lang_id = $tempLangId;
     }
     if ($errors && IN_ACP) {
         return "<ul>{$errors}</ul>";
     }
 }
Exemplo n.º 29
0
 /**
  * Show the attach upload field
  *
  * @param	string	$msg
  * @param	bool	$is_error
  * @param	integer	$insert_id
  * @return	@e void
  */
 public function attachmentUploadShow($msg = "ready", $is_error = 0, $insert_id = 0)
 {
     /* INIT JSON */
     $JSON = array();
     $JSON['msg'] = $msg;
     $JSON['is_error'] = $is_error;
     $is_reset = 0;
     /* JSON Data */
     $JSON['attach_post_key'] = $attach_post_key = trim(IPSText::alphanumericalClean($this->request['attach_post_key']));
     $JSON['attach_rel_module'] = $attach_rel_module = trim(IPSText::alphanumericalClean($this->request['attach_rel_module']));
     $JSON['attach_rel_id'] = $attach_rel_id = intval($this->request['attach_rel_id']);
     if ($insert_id) {
         $JSON['insert_id'] = $insert_id;
     }
     /* Get extra form fields */
     foreach ($this->request as $k => $v) {
         if (preg_match("#^--ff--#", $k)) {
             $JSON['extra_upload_form_url'] .= '&amp;' . str_replace('--ff--', '', $k) . '=' . $v;
             $JSON['extra_upload_form_url'] .= '&amp;' . $k . '=' . $v;
         }
     }
     /* INIT module */
     $this->class_attach->type = $attach_rel_module;
     $this->class_attach->attach_post_key = $attach_post_key;
     $this->class_attach->init();
     $this->class_attach->getUploadFormSettings();
     /* Load Language Bits */
     $this->registry->getClass('class_localization')->loadLanguageFile(array('lang_post'));
     /* Generate current items... */
     $_more = $attach_rel_id ? ' OR c.attach_rel_id=' . $attach_rel_id : '';
     $this->DB->build(array('select' => 'c.*', 'from' => array('attachments' => 'c'), 'where' => "c.attach_rel_module='{$attach_rel_module}' AND c.attach_post_key='{$attach_post_key}'{$_more}", 'add_join' => array(array('select' => 't.*', 'from' => array('attachments_type' => 't'), 'where' => 't.atype_extension=c.attach_ext', 'type' => 'left'))));
     $this->DB->execute();
     while ($row = $this->DB->fetch()) {
         if ($attach_rel_module != $row['attach_rel_module']) {
             continue;
         }
         if ($insert_id && $row['attach_id'] == $insert_id || $this->request['fetch_all']) {
             if ($row['attach_is_image'] and !$row['attach_thumb_location']) {
                 $row['attach_thumb_location'] = $row['attach_location'];
                 $row['attach_thumb_width'] = $row['attach_width'];
                 $row['attach_thumb_height'] = $row['attach_height'];
             }
             $JSON['current_items'][$row['attach_id']] = array($row['attach_id'], str_replace(array('[', ']'), '', $row['attach_file']), $row['attach_filesize'], $row['attach_is_image'], $row['attach_thumb_location'], $row['attach_thumb_width'], $row['attach_thumb_height'], $row['atype_img']);
         }
     }
     $JSON['attach_stats'] = $this->class_attach->attach_stats;
     /* Formatting nonsense for special char sets */
     $result = IPSText::jsonEncodeForTemplate($JSON);
     IPSDebug::addLogMessage($result, 'uploads');
     /* Return JSON */
     return $result;
 }
 /**
  * Execute a direct database query
  *
  * @param	string		Database query
  * @param	boolean		[Optional] Do not convert table prefix
  * @return	@e resource
  */
 public function query($the_query, $bypass = false)
 {
     //-----------------------------------------
     // Debug?
     //-----------------------------------------
     if ($this->obj['debug'] or $this->obj['use_debug_log'] and $this->obj['debug_log'] or $this->obj['use_bad_log'] and $this->obj['bad_log']) {
         IPSDebug::startTimer();
         $_MEMORY = IPSDebug::getMemoryDebugFlag();
     }
     //-----------------------------------------
     // Stop sub selects? (UNION)
     //-----------------------------------------
     if (!IPS_DB_ALLOW_SUB_SELECTS) {
         # On the spot allowance?
         if (!$this->allow_sub_select) {
             $_tmp = strtolower($this->_removeAllQuotes($the_query));
             if (preg_match("#(?:/\\*|\\*/)#i", $_tmp)) {
                 $this->throwFatalError("You are not allowed to use comments in your SQL query.\nAdd \\ipsRegistry::DB()->allow_sub_select=1; before any query construct to allow them");
                 return false;
             }
             if (preg_match("#[^_a-zA-Z]union[^_a-zA-Z]#s", $_tmp)) {
                 $this->throwFatalError("UNION query joins are not allowed.\nAdd \\ipsRegistry::DB()->allow_sub_select=1; before any query construct to allow them");
                 return false;
             } else {
                 if (preg_match_all("#[^_a-zA-Z](select)[^_a-zA-Z]#s", $_tmp, $matches)) {
                     if (count($matches) > 1) {
                         $this->throwFatalError("SUB SELECT query joins are not allowed.\nAdd \\ipsRegistry::DB()->allow_sub_select=1; before any query construct to allow them");
                         return false;
                     }
                 }
             }
         }
     }
     //-----------------------------------------
     // Run the query
     //-----------------------------------------
     $this->_tmpQ = substr($the_query, 0, 100) . '...';
     $this->query_id = mysqli_query($this->connection_id, $the_query);
     //-----------------------------------------
     // Reset array...
     //-----------------------------------------
     $this->resetDataTypes();
     $this->allow_sub_select = false;
     if (!$this->query_id) {
         $this->throwFatalError("mySQL query error: {$the_query}");
     }
     //-----------------------------------------
     // Logging?
     //-----------------------------------------
     if ($this->obj['use_debug_log'] and $this->obj['debug_log'] or $this->obj['use_bad_log'] and $this->obj['bad_log'] or $this->obj['use_slow_log'] and $this->obj['slow_log']) {
         $endtime = IPSDebug::endTimer();
         $_data = '';
         if (preg_match("/^(?:\\()?select/i", $the_query)) {
             $eid = mysqli_query($this->connection_id, "EXPLAIN {$the_query}");
             $_bad = false;
             while ($array = mysqli_fetch_array($eid)) {
                 $array['extra'] = isset($array['extra']) ? $array['extra'] : '';
                 $_data .= "\n+------------------------------------------------------------------------------+";
                 $_data .= "\n|Table: " . $array['table'];
                 $_data .= "\n|Type: " . $array['type'];
                 $_data .= "\n|Possible Keys: " . $array['possible_keys'];
                 $_data .= "\n|Key: " . $array['key'];
                 $_data .= "\n|Key Len: " . $array['key_len'];
                 $_data .= "\n|Ref: " . $array['ref'];
                 $_data .= "\n|Rows: " . $array['rows'];
                 $_data .= "\n|Extra: " . $array['Extra'];
                 //$_data .= "\n+------------------------------------------------------------------------------+";
                 if ($this->obj['use_bad_log'] and $this->obj['bad_log'] and (stristr($array['Extra'], 'filesort') or stristr($array['Extra'], 'temporary'))) {
                     $this->writeDebugLog($the_query, $_data, $endtime, $this->obj['bad_log'], TRUE);
                 }
                 if ($this->obj['use_slow_log'] and $this->obj['slow_log'] and $endtime >= $this->obj['use_slow_log']) {
                     $this->writeDebugLog($the_query, $_data, $endtime, $this->obj['slow_log'], TRUE);
                 }
             }
             if ($this->obj['use_debug_log'] and $this->obj['debug_log']) {
                 $this->writeDebugLog($the_query, $_data, $endtime);
             }
         } else {
             if ($this->obj['use_debug_log'] and $this->obj['debug_log']) {
                 $this->writeDebugLog($the_query, $_data, $endtime);
             }
         }
     }
     //-----------------------------------------
     // Debugging?
     //-----------------------------------------
     if ($this->obj['debug']) {
         $endtime = IPSDebug::endTimer();
         $memoryUsed = IPSDebug::setMemoryDebugFlag('', $_MEMORY);
         $memory = '';
         $shutdown = $this->is_shutdown ? 'SHUTDOWN QUERY: ' : '';
         if (preg_match("/^(?:\\()?select/i", $the_query)) {
             $eid = mysqli_query($this->connection_id, "EXPLAIN {$the_query}");
             $this->debug_html .= "<table width='95%' border='1' cellpadding='6' cellspacing='0' bgcolor='#FFE8F3' align='center'>\r\n\t\t\t\t\t\t\t\t\t\t   <tr>\r\n\t\t\t\t\t\t\t\t\t\t   \t <td colspan='8' style='font-size:14px' bgcolor='#FFC5Cb'><b>{$shutdown}Select Query</b></td>\r\n\t\t\t\t\t\t\t\t\t\t   </tr>\r\n\t\t\t\t\t\t\t\t\t\t   <tr>\r\n\t\t\t\t\t\t\t\t\t\t    <td colspan='8' style='font-family:courier, monaco, arial;font-size:14px;color:black'>{$the_query}</td>\r\n\t\t\t\t\t\t\t\t\t\t   </tr>\r\n\t\t\t\t\t\t\t\t\t\t   <tr bgcolor='#FFC5Cb'>\r\n\t\t\t\t\t\t\t\t\t\t\t <td><b>table</b></td><td><b>type</b></td><td><b>possible_keys</b></td>\r\n\t\t\t\t\t\t\t\t\t\t\t <td><b>key</b></td><td><b>key_len</b></td><td><b>ref</b></td>\r\n\t\t\t\t\t\t\t\t\t\t\t <td><b>rows</b></td><td><b>Extra</b></td>\r\n\t\t\t\t\t\t\t\t\t\t   </tr>\n";
             while ($array = mysqli_fetch_array($eid)) {
                 $type_col = '#FFFFFF';
                 if ($array['type'] == 'ref' or $array['type'] == 'eq_ref' or $array['type'] == 'const') {
                     $type_col = '#D8FFD4';
                 } else {
                     if ($array['type'] == 'ALL') {
                         $type_col = '#FFEEBA';
                     }
                 }
                 $this->debug_html .= "<tr bgcolor='#FFFFFF'>\r\n\t\t\t\t\t\t\t\t\t\t\t <td>{$array['table']}&nbsp;</td>\r\n\t\t\t\t\t\t\t\t\t\t\t <td bgcolor='{$type_col}'>{$array['type']}&nbsp;</td>\r\n\t\t\t\t\t\t\t\t\t\t\t <td>{$array['possible_keys']}&nbsp;</td>\r\n\t\t\t\t\t\t\t\t\t\t\t <td>{$array['key']}&nbsp;</td>\r\n\t\t\t\t\t\t\t\t\t\t\t <td>{$array['key_len']}&nbsp;</td>\r\n\t\t\t\t\t\t\t\t\t\t\t <td>{$array['ref']}&nbsp;</td>\r\n\t\t\t\t\t\t\t\t\t\t\t <td>{$array['rows']}&nbsp;</td>\r\n\t\t\t\t\t\t\t\t\t\t\t <td>{$array['Extra']}&nbsp;</td>\r\n\t\t\t\t\t\t\t\t\t\t   </tr>\n";
             }
             $this->sql_time += $endtime;
             if ($endtime > 0.1) {
                 $endtime = "<span style='color:red'><b>{$endtime}</b></span>";
             }
             if ($memoryUsed) {
                 $memory = '<br />Memory Used: ' . IPSLib::sizeFormat($memoryUsed, TRUE);
             }
             $this->debug_html .= "<tr>\r\n\t\t\t\t\t\t\t\t\t\t  <td colspan='8' bgcolor='#FFD6DC' style='font-size:14px'><b>MySQL time</b>: {$endtime}{$memory}</b></td>\r\n\t\t\t\t\t\t\t\t\t\t  </tr>\r\n\t\t\t\t\t\t\t\t\t\t  </table>\n<br />\n";
         } else {
             $this->debug_html .= "<table width='95%' border='1' cellpadding='6' cellspacing='0' bgcolor='#FEFEFE'  align='center'>\r\n\t\t\t\t\t\t\t\t\t\t <tr>\r\n\t\t\t\t\t\t\t\t\t\t  <td style='font-size:14px' bgcolor='#EFEFEF'><b>{$shutdown}Non Select Query</b></td>\r\n\t\t\t\t\t\t\t\t\t\t </tr>\r\n\t\t\t\t\t\t\t\t\t\t <tr>\r\n\t\t\t\t\t\t\t\t\t\t  <td style='font-family:courier, monaco, arial;font-size:14px'>{$the_query}</td>\r\n\t\t\t\t\t\t\t\t\t\t </tr>\r\n\t\t\t\t\t\t\t\t\t\t <tr>\r\n\t\t\t\t\t\t\t\t\t\t  <td style='font-size:14px' bgcolor='#EFEFEF'><b>MySQL time</b>: {$endtime}</span></td>\r\n\t\t\t\t\t\t\t\t\t\t </tr>\r\n\t\t\t\t\t\t\t\t\t\t</table><br />\n\n";
         }
     }
     $this->query_count++;
     $this->obj['cached_queries'][] = $the_query;
     return $this->query_id;
 }