/**
  * 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']);
     }
 }
Ejemplo n.º 2
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);
 }
Ejemplo n.º 3
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;
 }
Ejemplo n.º 4
0
 /**
  * Silent redirect (Redirects without a screen or other notification)
  *
  * @access	public
  * @param	string		URL
  * @param	string		[SEO Title]
  * @param	string		[Send a 301 redirect header first]
  * @param	string		SEO Template
  * @return	mixed
  */
 public function silentRedirect($url, $seoTitle = '', $send301 = FALSE, $seoTemplate = '')
 {
     # SEO?
     if ($seoTitle or $seoTemplate) {
         $url = $this->registry->getClass('output')->buildSEOUrl($url, 'none', $seoTitle, $seoTemplate);
     }
     # Ensure &amp;s are taken care of
     $url = str_replace("&amp;", "&", $url);
     # Dirty hack @todo look at real reason for this - happens when URL is already SEO and passed via buildSEOUrl above
     $url = str_replace("?//", "?/", $url);
     # 301?
     if ($send301 !== false) {
         /* Kill caching as Firefox loves to cache redirects */
         $this->settings['nocache'] = 1;
         $this->_headerExpire = 0;
         /* Strip session URL if there wasn't one */
         if (!IN_ACP and $this->member->session_type != 'cookie' and !$this->request['s']) {
             $url = preg_replace('/\\?s=([a-zA-Z0-9]{32})(&amp;|&|$)/', '?', $url);
             $url = rtrim($url, '?');
             // Let's remove ? just in case there's nothing after it..
         }
         /* Log it */
         IPSDebug::addLogMessage("Redirecting: " . $_SERVER['REQUEST_URI'] . ' to ' . $url, '301log');
         /* Set codes */
         if ($this->settings['header_redirect'] != 'html') {
             $this->setHeaderCode($send301 === true ? 301 : intval($send301));
         }
         $this->printHeader();
     }
     if ($this->settings['header_redirect'] == 'refresh') {
         @header("Refresh: 0;url=" . $url);
     } else {
         if ($this->settings['header_redirect'] == 'html') {
             $url = str_replace('&', '&amp;', str_replace('&amp;', '&', $url));
             echo "<html><head><meta http-equiv='refresh' content='0; url={$url}'></head><body></body></html>";
             exit;
         } else {
             @header("Location: " . $url);
         }
     }
     exit;
 }
Ejemplo n.º 5
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);
     }
 }
Ejemplo n.º 6
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);
 }
 /**
  * Silent redirect (Redirects without a screen or other notification)
  *
  * @access	public
  * @param	string		URL
  * @param	string		[SEO Title]
  * @param	string		[Send a 301 redirect header first]
  * @return	mixed
  */
 public function silentRedirect($url, $seoTitle = '', $send301 = FALSE)
 {
     # SEO?
     if (isset($seoTitle) and !is_null($seoTitle)) {
         $url = $this->registry->getClass('output')->buildSEOUrl($url, 'none', $seoTitle, '');
     }
     # Ensure &amp;s are taken care of
     $url = str_replace("&amp;", "&", $url);
     # 301?
     if ($send301 === TRUE) {
         /* Log it */
         IPSDebug::addLogMessage("Redirecting: " . $_SERVER['REQUEST_URI'] . ' to ' . $url, '301log');
         /* Set codes */
         $this->setHeaderCode(301);
         $this->printHeader();
     }
     if ($this->settings['header_redirect'] == 'refresh') {
         @header("Refresh: 0;url=" . $url);
     } else {
         if ($this->settings['header_redirect'] == 'html') {
             $url = str_replace('&', '&amp;', str_replace('&amp;', '&', $url));
             echo "<html><head><meta http-equiv='refresh' content='0; url={$url}'></head><body></body></html>";
             exit;
         } else {
             @header("Location: " . $url);
         }
     }
     exit;
 }
Ejemplo n.º 8
0
 /**
  * Process the mail queue
  *
  * @return	@e void
  */
 public static function processMailQueue()
 {
     //-----------------------------------------
     // SET UP
     //-----------------------------------------
     $doReset = 0;
     $cache = self::$handles['caches']->getCache('systemvars');
     self::$settings['mail_queue_per_blob'] = isset(self::$settings['mail_queue_per_blob']) ? self::$settings['mail_queue_per_blob'] : 10;
     if (!isset($cache['mail_queue']) or $cache['mail_queue'] < 0) {
         $mailQueue = self::DB()->buildAndFetch(array('select' => 'COUNT(*) as total', 'from' => 'mail_queue'));
         $mailQueueCount = intval($mailQueue['total']);
         $cache['mail_queue'] = $mailQueueCount;
         $doReset = 1;
     } else {
         $mailQueueCount = intval($cache['mail_queue']);
     }
     $sent_ids = array();
     if ($mailQueueCount > 0) {
         /* Test lock */
         $test = self::DB()->buildAndFetch(array('select' => 'cs_value, cs_updated', 'from' => 'cache_store', 'where' => 'cs_key=\'mail_processing\''));
         if (!empty($test['cs_value'])) {
             /* Check time */
             if (empty($test['cs_updated']) or time() - 30 > $test['cs_updated']) {
                 /* 30 seconds, so unlock incase its stuck */
                 self::DB()->replace('cache_store', array('cs_key' => 'mail_processing', 'cs_value' => 0, 'cs_updated' => time()), array('cs_key'));
             }
             return false;
         }
         /* LOCK- Race condition when mail queue table is locked so it cannot delete mail so dupe emails are sent */
         self::DB()->replace('cache_store', array('cs_key' => 'mail_processing', 'cs_value' => 1, 'cs_updated' => time()), array('cs_key'));
         if (!self::DB()->getAffectedRows()) {
             return;
         }
         //-----------------------------------------
         // Get the mail stuck in the queue
         //-----------------------------------------
         self::DB()->build(array('select' => '*', 'from' => 'mail_queue', 'order' => 'mail_id ASC', 'limit' => array(0, self::$settings['mail_queue_per_blob'])));
         self::DB()->execute();
         while ($r = self::DB()->fetch()) {
             $data[] = $r;
             $sent_ids[] = $r['mail_id'];
         }
         if (count($sent_ids)) {
             //-----------------------------------------
             // Delete sent mails and update count
             //-----------------------------------------
             $mailQueueCount = $mailQueueCount - count($sent_ids);
             self::DB()->delete('mail_queue', 'mail_id IN (' . implode(",", $sent_ids) . ')');
             foreach ($data as $mail) {
                 if ($mail['mail_to'] and $mail['mail_subject'] and $mail['mail_content']) {
                     /* Clear out previous data */
                     IPSText::getTextClass('email')->clearContent();
                     /* Turn off HTML by default */
                     IPSText::getTextClass('email')->setHtmlEmail(false);
                     /* Specifically a HTML email */
                     if ($mail['mail_html_on']) {
                         IPSText::getTextClass('email')->setHtmlEmail(true);
                         if ($mail['mail_html_content']) {
                             IPSText::getTextClass('email')->setHtmlTemplate($mail['mail_html_content']);
                         } else {
                             IPSText::getTextClass('email')->setPlainTextTemplate($mail['mail_content']);
                             IPSText::getTextClass('email')->buildHtmlContent(array());
                         }
                     }
                     /* We want to parse the plain text emails */
                     IPSText::getTextClass('email')->setPlainTextTemplate($mail['mail_content']);
                     IPSText::getTextClass('email')->buildPlainTextContent(false);
                     IPSText::getTextClass('email')->to = $mail['mail_to'];
                     IPSText::getTextClass('email')->cc = empty($mail['mail_cc']) ? array() : explode(',', $mail['mail_cc']);
                     IPSText::getTextClass('email')->from = $mail['mail_from'] ? $mail['mail_from'] : self::$settings['email_out'];
                     IPSText::getTextClass('email')->subject = $mail['mail_subject'];
                     IPSText::getTextClass('email')->sendMail();
                     IPSDebug::addLogMessage('Email Sent: ' . $mail['mail_to'], 'bulkemail');
                 }
             }
         } else {
             //-----------------------------------------
             // No mail after all?
             //-----------------------------------------
             $mailQueueCount = 0;
             $doReset = 1;
         }
         //-----------------------------------------
         // Set new mail_queue count
         //-----------------------------------------
         $cache['mail_queue'] = $mailQueueCount;
     }
     //-----------------------------------------
     // Update cache with remaning email count
     //-----------------------------------------
     if ($mailQueueCount > 0 or $doReset) {
         self::$handles['caches']->setCache('systemvars', $cache, array('array' => 1, 'donow' => 1));
         /* UNLOCK */
         self::DB()->replace('cache_store', array('cs_key' => 'mail_processing', 'cs_value' => 0, 'cs_updated' => time()), array('cs_key'));
     }
 }
 /**
  * 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']);
 }
 /**
  * Run this task
  *
  * @access	public
  * @return	void
  */
 public function runTask()
 {
     $this->registry->getClass('class_localization')->loadLanguageFile(array('public_global'), 'core');
     //-----------------------------------------
     // This is mysql only
     //-----------------------------------------
     if (strtolower($this->settings['sql_driver']) != 'mysql') {
         $this->class->unlockTask($this->task);
         return;
     }
     //-----------------------------------------
     // Clean out sleeping mysql processes
     //-----------------------------------------
     $this->DB->return_die = true;
     $resource = $this->DB->query("SHOW PROCESSLIST", true);
     while ($r = $this->DB->fetch($resource)) {
         //-----------------------------------------
         // Make sure we're only killing stuff on our db
         //-----------------------------------------
         if ($r['db'] == $this->settings['sql_database'] and $r['Command'] == 'Sleep' and $r['Time'] > 60) {
             $this->DB->return_die = true;
             $this->DB->query("KILL {$r['Id']}");
             /* Log */
             IPSDebug::addLogMessage('Task - MySQL Clean Up Performed. Killed id ' . $r['Id'], 'mysqlCleanUp', $r);
         }
     }
     $this->DB->return_die = false;
     //-----------------------------------------
     // Log to log table - modify but dont delete
     //-----------------------------------------
     $this->class->appendTaskLog($this->task, $this->lang->words['task_mysqlcleanup']);
     //-----------------------------------------
     // Unlock Task: DO NOT MODIFY!
     //-----------------------------------------
     $this->class->unlockTask($this->task);
 }
Ejemplo n.º 11
0
 /**
  * Runs the specified member sync module, takes a variable number of arguments.
  *
  * @param	string	$module		The module to run, ex: onCreateAccount, onRegisterForm, etc
  * @param	mixed	...			Remaining params should match the module being called. ex: array of member data for onCreateAccount,
  *								or an id and email for onEmailChange
  * @return	@e void
  */
 public static function runMemberSync($module)
 {
     /* ipsRegistry::$applications only contains apps with a public title #15785 */
     $app_cache = ipsRegistry::cache()->getCache('app_cache');
     /* Params */
     $params = func_get_args();
     array_shift($params);
     /* Loop through applications */
     foreach ($app_cache as $app_dir => $app) {
         /* Only if app enabled... */
         if ($app['app_enabled']) {
             /* Setup */
             $_file = self::getAppDir($app['app_directory']) . '/extensions/memberSync.php';
             /* Check for the file */
             if (is_file($_file)) {
                 /* Get the file */
                 $_class = self::loadLibrary($_file, $app['app_directory'] . 'MemberSync', $app['app_directory']);
                 /* Check for the class */
                 if (class_exists($_class)) {
                     /* Create an object */
                     $_obj = new $_class();
                     /* Check for the module */
                     if (method_exists($_obj, $module)) {
                         /* Call it */
                         call_user_func_array(array($_obj, $module), $params);
                         IPSDebug::addLogMessage($app_dir . '-' . $module, 'mem');
                     }
                 }
             }
         }
     }
     /* IPS Connect Group Change */
     if ($module == 'onCompleteAccount') {
         $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/handlers/han_login.php', 'han_login');
         $han_login = new $classToLoad(ipsRegistry::instance());
         $han_login->init();
         $han_login->validateAccount($params[0]);
     }
 }
<?php

/**
 * Invision Power Services
 * IP.Board v3.0.3
 * Main public executable wrapper.
 * Set-up and load module to run
 * Last Updated: $Date: 2009-07-08 21:23:44 -0400 (Wed, 08 Jul 2009) $
 *
 * @author 		$Author: bfarber $
 * @copyright	(c) 2001 - 2008 Invision Power Services, Inc.
 * @package		Invision Power Board
 * @version		$Rev: 4856 $
 *
 */
define('IPB_THIS_SCRIPT', 'public');
require_once '../../initdata.php';
require_once IPS_ROOT_PATH . 'sources/base/ipsRegistry.php';
require_once IPS_ROOT_PATH . 'sources/base/ipsController.php';
$registry = ipsRegistry::instance();
$registry->init();
IPSDebug::addLogMessage('fbc', 'fbc', $_POST);
//require_once( IPS_ROOT_PATH . 'sources/base/ipsController.php' );
//ipsController::run();
exit;
Ejemplo n.º 13
0
 /**
  * Rebuild CSS cache
  *
  * @access	public
  * @param	int		Skin set id to rebuild
  * @param	boolean	Force rebuild regardless of if it requires it
  * @return	boolean
  */
 public function rebuildCSSCache($setID, $forceRebuild = FALSE)
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $cssSkinCollections = array();
     $skinSetData = $this->fetchSkinData($setID);
     $cachedCSS = array();
     $thisCSS = array();
     $needToRebuild = array();
     $this->_resetErrorHandle();
     $this->_resetMessageHandle();
     //-----------------------------------------
     // Push the current skin set ID onto the beginnging
     //-----------------------------------------
     if (is_numeric($setID)) {
         array_unshift($skinSetData['_childTree'], $setID);
     }
     //-----------------------------------------
     // Fetch CSS that needs to be rebuilt
     //-----------------------------------------
     $needToRebuild = $this->_CSSNeedToRebuild($skinSetData['_childTree'], $setID, $forceRebuild);
     IPSDebug::addLogMessage("Set ID: " . $setID . " - " . serialize($needToRebuild), 'css');
     //-----------------------------------------
     // Loop through and rebuild
     //-----------------------------------------
     foreach (array_keys($needToRebuild) as $_setID) {
         $_css = $this->fetchCSS($_setID);
         $_skinSetData = $this->fetchSkinData($_setID);
         /* If this is a child skin, just flag for recache */
         if ($_setID != $setID) {
             if ($this->getIgnoreChildrenWhenRecaching() === false) {
                 $this->flagSetForRecache($_setID, true);
             }
             continue;
         }
         foreach ($_css as $name => $css) {
             if (!in_array($name, array_keys($needToRebuild[$_setID]))) {
                 continue;
             }
             $this->DB->delete('skin_cache', 'cache_type=\'css\' AND cache_set_id=' . $_setID . " AND cache_value_1='" . addslashes($name) . "'");
             /* Build skin set row*/
             $cssSkinCollections[$_setID][$css['css_position'] . '.' . $css['css_id']] = array('css_group' => $css['css_group'], 'css_position' => $css['css_position']);
             /* Update skin cache */
             $this->DB->insert('skin_cache', array('cache_updated' => time(), 'cache_set_id' => $_setID, 'cache_type' => 'css', 'cache_key_1' => 'name', 'cache_value_1' => $css['css_group'], 'cache_key_2' => 'position', 'cache_value_2' => $css['css_position'], 'cache_key_3' => 'setBy', 'cache_value_3' => $css['css_set_id'], 'cache_key_4' => 'appInfo', 'cache_value_4' => $css['css_app'] . '-' . $css['css_app_hide'], 'cache_key_5' => 'attributes', 'cache_value_5' => $css['css_attributes'], 'cache_key_6' => 'modules', 'cache_value_6' => $css['css_modules'], 'cache_content' => $this->_CSS_fromDBtoFile($css['css_content'], $_skinSetData)));
         }
         $this->cache->putWithCacheLib('Skin_Store_' . $_setID, array(), 1);
     }
     //-----------------------------------------
     // Finally, remove any cached items that no
     // longer 'exist' (since been deleted, etc)
     //-----------------------------------------
     $_css = $this->fetchCSS($setID);
     $_del = array();
     /* Get cached items */
     $this->DB->build(array('select' => '*', 'from' => 'skin_cache', 'where' => 'cache_type=\'css\' AND cache_set_id=' . $setID));
     $this->DB->execute();
     while ($row = $this->DB->fetch()) {
         if (!$_css[$row['cache_value_1']]) {
             $_del[] = $row['cache_value_1'];
         }
     }
     if (count($_del)) {
         $this->DB->delete('skin_cache', 'cache_type=\'css\' AND cache_set_id=' . $setID . " AND cache_value_1 IN('" . implode("','", $_del) . "')");
     }
     //-----------------------------------------
     // Update skin sets
     //-----------------------------------------
     if (count($cssSkinCollections)) {
         foreach ($cssSkinCollections as $setID => $data) {
             $this->DB->update('skin_collections', array('set_css_groups' => serialize($cssSkinCollections[$setID])), 'set_id=' . $setID);
             $this->cache->putWithCacheLib('Skin_Store_' . $setID, array(), 1);
         }
     }
     /* Recache skin sets */
     $this->rebuildSkinSetsCache();
     return TRUE;
 }
 /**
  * Generate XML Archive for skin set
  *
  * @access	public
  * @param	int			Skin set ID
  * @param	boolean		Modifications in this set only
  * @param	array		[Array of apps to export from. Default is all]
  * @return	string		XML
  */
 public function generateSetXMLArchive($setID = 0, $setOnly = FALSE, $appslimit = null)
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $templates = array();
     $csss = array();
     $replacements = "";
     $css = "";
     $setData = $this->fetchSkinData($setID);
     //-----------------------------------------
     // Reset handlers
     //-----------------------------------------
     $this->_resetErrorHandle();
     $this->_resetMessageHandle();
     //-----------------------------------------
     // First up... fetch templates
     //-----------------------------------------
     $apps = new IPSApplicationsIterator();
     foreach ($apps as $app) {
         if (is_array($appslimit) and !in_array($apps->fetchAppDir(), $appslimit)) {
             continue;
         }
         if ($apps->isActive()) {
             $templates[$apps->fetchAppDir()] = $this->generateTemplateXML($apps->fetchAppDir(), $setID, $setOnly);
             $csss[$apps->fetchAppDir()] = $this->generateCSSXML($apps->fetchAppDir(), $setID, $setOnly);
         }
     }
     //-----------------------------------------
     // Replacements
     //-----------------------------------------
     $replacements = $this->generateReplacementsXML($setID, $setOnly);
     //-----------------------------------------
     // Information
     //-----------------------------------------
     $info = $this->generateInfoXML($setID);
     //-----------------------------------------
     // De-bug
     //-----------------------------------------
     foreach ($templates as $app_dir => $templateXML) {
         IPSDebug::addLogMessage("Template Export: {$app_dir}\n" . $templateXML, 'admin-setExport');
     }
     foreach ($csss as $app_dir => $cssXML) {
         IPSDebug::addLogMessage("CSS Export: {$app_dir}\n" . $cssXML, 'admin-setExport');
     }
     IPSDebug::addLogMessage("Replacements Export:\n" . $replacements, 'admin-setExport');
     IPSDebug::addLogMessage("Info Export:\n" . $info, 'admin-setExport');
     //-----------------------------------------
     // Create new XML archive...
     //-----------------------------------------
     require_once IPS_KERNEL_PATH . 'classXMLArchive.php';
     $xmlArchive = new classXMLArchive();
     # Templates
     foreach ($templates as $app_dir => $templateXML) {
         $xmlArchive->add($templateXML, "templates/" . $app_dir . ".xml");
     }
     # CSS
     foreach ($csss as $app_dir => $cssXML) {
         $xmlArchive->add($cssXML, "css/" . $app_dir . ".xml");
     }
     # Replacements
     $xmlArchive->add($replacements, "replacements.xml");
     # Information
     $xmlArchive->add($info, 'info.xml');
     return $xmlArchive->getArchiveContents();
 }
 /**
  * Generate XML Archive for skin set
  *
  * @access	public
  * @param	int			Skin set ID
  * @param	boolean		Modifications in this set only
  * @param	array		[Array of apps to export from. Default is all]
  * @return	string		XML
  */
 public function generateSetXMLArchive($setID = 0, $setOnly = FALSE, $appslimit = null)
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $templates = array();
     $csss = array();
     $replacements = "";
     $css = "";
     $setData = $this->fetchSkinData($setID);
     //-----------------------------------------
     // Reset handlers
     //-----------------------------------------
     $this->_resetErrorHandle();
     $this->_resetMessageHandle();
     //-----------------------------------------
     // First up... fetch templates
     //-----------------------------------------
     foreach (ipsRegistry::$applications as $appDir => $data) {
         if (is_array($appslimit) and !in_array($appDir, $appslimit)) {
             continue;
         }
         if (!empty($data['app_enabled'])) {
             $templates[$appDir] = $this->generateTemplateXML($appDir, $setID, $setOnly);
             $csss[$appDir] = $this->generateCSSXML($appDir, $setID, $setOnly);
         }
     }
     //-----------------------------------------
     // Replacements
     //-----------------------------------------
     $replacements = $this->generateReplacementsXML($setID, $setOnly);
     //-----------------------------------------
     // Information
     //-----------------------------------------
     $info = $this->generateInfoXML($setID);
     //-----------------------------------------
     // De-bug
     //-----------------------------------------
     foreach ($templates as $app_dir => $templateXML) {
         IPSDebug::addLogMessage("Template Export: {$app_dir}\n" . $templateXML, 'admin-setExport', false, true, true);
     }
     foreach ($csss as $app_dir => $cssXML) {
         IPSDebug::addLogMessage("CSS Export: {$app_dir}\n" . $cssXML, 'admin-setExport', false, true);
     }
     IPSDebug::addLogMessage("Replacements Export:\n" . $replacements, 'admin-setExport', false, true);
     IPSDebug::addLogMessage("Info Export:\n" . $info, 'admin-setExport', false, true);
     //-----------------------------------------
     // Create new XML archive...
     //-----------------------------------------
     require_once IPS_KERNEL_PATH . 'classXMLArchive.php';
     /*noLibHook*/
     $xmlArchive = new classXMLArchive();
     /* Add in version numbers */
     $version = IPSLib::fetchVersionNumber();
     $xmlArchive->addRootTagValues(array('ipbLongVersion' => $version['long'], 'ipbHumanVersion' => $version['human']));
     # Templates
     foreach ($templates as $app_dir => $templateXML) {
         $xmlArchive->add($templateXML, "templates/" . $app_dir . ".xml");
     }
     # CSS
     foreach ($csss as $app_dir => $cssXML) {
         $xmlArchive->add($cssXML, "css/" . $app_dir . ".xml");
     }
     # Replacements
     $xmlArchive->add($replacements, "replacements.xml");
     # Information
     $xmlArchive->add($info, 'info.xml');
     return $xmlArchive->getArchiveContents();
 }
 /**
  * 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()
 {
     /* Task? */
     if (IPS_IS_TASK === TRUE) {
         return;
     }
     /* Search engine? */
     if ($this->member->is_not_human === TRUE) {
         return;
     }
     /* Save the storage table if not done so already */
     $this->_saveStorage();
     /* Grab sessions to be removed */
     if ($this->settings['topic_marking_enable']) {
         /* Check every 5 mins */
         $cache = $this->caches['systemvars'];
         $update = 0;
         /* Fail safe */
         if (!$cache['itemMarkerClean']) {
             $cache['itemMarkerClean'] = 0;
             $update = 1;
         }
         if (time() - 300 > $cache['itemMarkerClean']) {
             /* session_expiration is seconds */
             $_time = ceil($this->settings['session_expiration'] / 3600);
             /* less than an hour? */
             if ($_time < 1) {
                 $_time = 1;
             }
             /* Clean 'em up */
             $_c = $this->manualCleanUp(50, ++$_time, FALSE);
             if ($_c) {
                 IPSDebug::addLogMessage("Manually cleaned up: " . $_c . ' hit by ID ' . $this->memberData['member_id'], 'markerClean');
             }
             $update = 1;
         }
         /* Update */
         if ($update) {
             /* Save Cache */
             $cache['itemMarkerClean'] = time();
             $this->cache->setCache('systemvars', $cache, array('array' => 1, 'donow' => 1, 'deletefirst' => 0));
         }
     }
 }