Version 3.2.3
This commit is contained in:
1 parent
ae5c01cc78
commit
78706903a2
2641 files changed
+228363
-201264
No files matched your search
@@ -5,6 +5,6 @@
|
||||
<hr>
|
||||
You have reached this page in error, please use your back button to return to the forum.
|
||||
<hr>
|
||||
<a href="http://www.invisionboard.com/">IP.Board</a>
|
||||
<a href="http://www.invisionpower.com">IP.Board</a>
|
||||
</body>
|
||||
</html>
|
||||
@@ -3,19 +3,19 @@
|
||||
/**
|
||||
* <pre>
|
||||
* Invision Power Services
|
||||
* IP.Board v3.1.4
|
||||
* IP.Board v3.2.3
|
||||
* Skin Caching Functions
|
||||
* Last Updated: $Date: 2010-10-14 06:42:56 -0400 (Thu, 14 Oct 2010) $
|
||||
* Last Updated: $Date: 2011-09-16 15:32:18 -0400 (Fri, 16 Sep 2011) $
|
||||
* </pre>
|
||||
*
|
||||
* Owner: Matt
|
||||
* @author $Author: mmecham $
|
||||
* @author $Author: bfarber $
|
||||
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/community/board/license.html
|
||||
* @license This is NULLED!
|
||||
* @package IP.Board
|
||||
* @link http://www.invisionpower.com
|
||||
* @link http://hatynka.in
|
||||
* @since 9th July 2008
|
||||
* @version $Revision: 6975 $
|
||||
* @version $Revision: 9503 $
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -30,7 +30,7 @@ if ( ! defined( 'IN_IPB' ) )
|
||||
*/
|
||||
if ( ! class_exists( 'skinFunctions' ) )
|
||||
{
|
||||
require_once( dirname( __FILE__ ) . '/skinFunctions.php' );
|
||||
require_once( dirname( __FILE__ ) . '/skinFunctions.php' );/*noLibHook*/
|
||||
}
|
||||
|
||||
class skinCaching extends skinFunctions
|
||||
@@ -47,7 +47,9 @@ class skinCaching extends skinFunctions
|
||||
protected $request;
|
||||
protected $lang;
|
||||
protected $member;
|
||||
protected $memberData;
|
||||
protected $cache;
|
||||
protected $caches;
|
||||
/**#@-*/
|
||||
|
||||
/**
|
||||
@@ -58,12 +60,30 @@ class skinCaching extends skinFunctions
|
||||
*/
|
||||
protected $_cssNeedToRebuildArray = array();
|
||||
|
||||
/**
|
||||
* Ignore children when recaching ...
|
||||
* @var boolean
|
||||
*/
|
||||
protected $_ignoreChildrenWhenRecaching = false;
|
||||
|
||||
/**
|
||||
* Recache skin sets on shutdown
|
||||
* @var bool
|
||||
*/
|
||||
protected $_recacheSkinsCache = false;
|
||||
|
||||
/**
|
||||
* Remember which skins we've already flagged for recache
|
||||
* @var array
|
||||
*/
|
||||
protected $_flaggedForRecache = array();
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @access public
|
||||
* @param object Registry object
|
||||
* @return void
|
||||
* @return @e void
|
||||
*/
|
||||
public function __construct( ipsRegistry $registry )
|
||||
{
|
||||
@@ -71,6 +91,24 @@ class skinCaching extends skinFunctions
|
||||
parent::__construct( $registry );
|
||||
}
|
||||
|
||||
/**
|
||||
* Set ignore children when recaching
|
||||
* @param boolean $val
|
||||
*/
|
||||
public function setIgnoreChildrenWhenRecaching( $val )
|
||||
{
|
||||
$this->_ignoreChildrenWhenRecaching = ( ! empty( $val ) ) ? true : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get ignore children when recaching
|
||||
* @return boolean
|
||||
*/
|
||||
public function getIgnoreChildrenWhenRecaching()
|
||||
{
|
||||
return $this->_ignoreChildrenWhenRecaching;
|
||||
}
|
||||
|
||||
/**
|
||||
* Rebuild Replacements cache
|
||||
*
|
||||
@@ -121,6 +159,17 @@ class skinCaching extends skinFunctions
|
||||
$_setID = $setID;
|
||||
}
|
||||
|
||||
/* If this is a child skin, just flag for recache */
|
||||
if ( $_setID != $setID )
|
||||
{
|
||||
if ( $this->getIgnoreChildrenWhenRecaching() === false )
|
||||
{
|
||||
$this->flagSetForRecache( $_setID, true );
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$__replacements = $this->fetchReplacements( $_setID );
|
||||
$_replacements = array();
|
||||
|
||||
@@ -155,7 +204,7 @@ class skinCaching extends skinFunctions
|
||||
//-----------------------------------------
|
||||
// INIT
|
||||
//-----------------------------------------
|
||||
|
||||
|
||||
$skinSetData = $this->fetchSkinData( $setID );
|
||||
|
||||
$skinSetData['set_image_dir'] = ( $skinSetData['set_image_dir'] ) ? $skinSetData['set_image_dir'] : 'master';
|
||||
@@ -182,6 +231,17 @@ class skinCaching extends skinFunctions
|
||||
|
||||
foreach( $skinSetData['_childTree'] as $_setID )
|
||||
{
|
||||
/* If this is a child skin, just flag for recache */
|
||||
if ( $_setID != $setID )
|
||||
{
|
||||
if ( $this->getIgnoreChildrenWhenRecaching() === false )
|
||||
{
|
||||
$this->flagSetForRecache( $_setID, true );
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Get template set titles
|
||||
//-----------------------------------------
|
||||
@@ -390,6 +450,11 @@ EOF;
|
||||
|
||||
foreach( $phpKeep as $_setID => $data )
|
||||
{
|
||||
if ( ( $_setID != $setID ) && $this->getIgnoreChildrenWhenRecaching() === true )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$_path = IPS_CACHE_PATH . 'cache/skin_cache/cacheid_' . $_setID;
|
||||
|
||||
if ( is_dir( $_path ) )
|
||||
@@ -512,6 +577,11 @@ EOF;
|
||||
|
||||
foreach( $cssKeep as $_setID => $data )
|
||||
{
|
||||
if ( ( $_setID != $setID ) && $this->getIgnoreChildrenWhenRecaching() === true )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$_path = DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_css/css_' . $_setID;
|
||||
|
||||
if ( is_dir( $_path ) )
|
||||
@@ -563,7 +633,7 @@ EOF;
|
||||
* @access public
|
||||
* @param int [Optional Skin set id to rebuild. If no value given, all skin sets are rebuilt]
|
||||
* @param boolean Force rebuild regardless of if it requires it
|
||||
* @return void
|
||||
* @return @e void
|
||||
*/
|
||||
public function rebuildCSS( $setID, $forceRebuild=FALSE )
|
||||
{
|
||||
@@ -590,7 +660,7 @@ EOF;
|
||||
*/
|
||||
public function rebuildCSSFlatFiles( $setID, $forceRebuild=FALSE )
|
||||
{
|
||||
$skinSetData = $this->fetchSkinData( $setID );
|
||||
$skinSetData = $this->fetchSkinData( $setID );
|
||||
|
||||
$this->_resetErrorHandle();
|
||||
$this->_resetMessageHandle();
|
||||
@@ -649,16 +719,26 @@ EOF;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* If this is a child skin, just flag for recache */
|
||||
if ( $_setID != $setID )
|
||||
{
|
||||
if ( $this->getIgnoreChildrenWhenRecaching() === false )
|
||||
{
|
||||
$this->flagSetForRecache( $_setID, true );
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
IPSDebug::addLogMessage( "Attempting to write CSS " . $_setID . ", " . $_group . ".css", 'css' );
|
||||
|
||||
$this->_writeCSSFile( $_setID, $_group, $_css );
|
||||
|
||||
//-----------------------------------------
|
||||
// Got any error messages?
|
||||
//-----------------------------------------
|
||||
|
||||
/* Any problems? */
|
||||
if ( $this->fetchErrorMessages() !== FALSE )
|
||||
{
|
||||
/* Flag as using inline */
|
||||
$this->flagSetAsNonCachedCSS( $_setID );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -717,6 +797,17 @@ EOF;
|
||||
$_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 ] ) ) )
|
||||
@@ -783,7 +874,7 @@ EOF;
|
||||
//-----------------------------------------
|
||||
// Update skin sets
|
||||
//-----------------------------------------
|
||||
|
||||
|
||||
if ( count( $cssSkinCollections ) )
|
||||
{
|
||||
foreach( $cssSkinCollections as $setID => $data )
|
||||
@@ -800,6 +891,26 @@ EOF;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Flag skin as not able to serve cached CSS
|
||||
*
|
||||
* @access public
|
||||
* @return boolean
|
||||
*/
|
||||
public function flagSetAsNonCachedCSS( $setId=null )
|
||||
{
|
||||
/* Update DB row */
|
||||
if ( $setId !== null )
|
||||
{
|
||||
$this->DB->update( 'skin_collections', array( 'set_css_inline' => 1 ), 'set_id=' . intval( $setId ) );
|
||||
}
|
||||
|
||||
/* Build cache */
|
||||
$this->rebuildSkinSetsCache();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Rebuild master replacements from cache/skin_cache/master_skin/_replacements.inc
|
||||
*
|
||||
@@ -817,7 +928,7 @@ EOF;
|
||||
// Master file exists?
|
||||
//-----------------------------------------
|
||||
|
||||
if ( ! file_exists( $dir . '/_replacements.inc' ) )
|
||||
if ( ! is_file( $dir . '/_replacements.inc' ) )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
@@ -830,28 +941,47 @@ EOF;
|
||||
{
|
||||
$this->DB->delete( 'skin_replacements', "replacement_master_key='" . $setId . "'" );
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->DB->delete( 'skin_replacements', "replacement_set_id='" . intval($setId) . "'" );
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Grab file
|
||||
//-----------------------------------------
|
||||
|
||||
$replacements = array();
|
||||
require( $dir . '/_replacements.inc' );
|
||||
include( $dir . '/_replacements.inc' );/*noLibHook*/
|
||||
|
||||
if ( !is_array($replacements) || !count($replacements) )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Insert... */
|
||||
//-----------------------------------------
|
||||
// Get proper set key/id
|
||||
//-----------------------------------------
|
||||
|
||||
$set_id = ( is_numeric( $setId ) ) ? $setId : $this->fetchSetIdByKey( $setId );
|
||||
$set_key = '';
|
||||
|
||||
if( $this->isMasterSet( $setId ) )
|
||||
{
|
||||
$set_key = ( is_numeric( $setId ) ) ? $this->fetchSetKeyById( $setId ) : $setId;
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Insert
|
||||
//-----------------------------------------
|
||||
|
||||
foreach( $replacements as $k => $v )
|
||||
{
|
||||
$messages[] = $this->lang->words['basicimportedpre'] . $k;
|
||||
|
||||
$this->DB->insert( 'skin_replacements', array( 'replacement_key' => $k,
|
||||
'replacement_content' => $v,
|
||||
'replacement_master_key' => ( is_numeric( $setId ) ) ? $this->fetchSetKeyById( $setId ) : $setId,
|
||||
'replacement_set_id' => 0,
|
||||
'replacement_master_key' => $set_key,
|
||||
'replacement_set_id' => $set_id,
|
||||
'replacement_added_to' => 0 ) );
|
||||
}
|
||||
|
||||
@@ -874,7 +1004,7 @@ EOF;
|
||||
{
|
||||
/* Set directory */
|
||||
$setId = is_numeric( $setId ) ? intval( $setId ) : trim( $setId );
|
||||
$cssDir = DOC_IPS_ROOT_PATH . 'public/style_css/' . $this->remapData['css'][ $setId ];
|
||||
$cssDir = DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_css/' . $this->remapData['css'][ $setId ];
|
||||
$messages = array();
|
||||
$css = array();
|
||||
|
||||
@@ -910,6 +1040,18 @@ EOF;
|
||||
$css = $this->fetchCSS( $setId );
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Set key and ID
|
||||
//-----------------------------------------
|
||||
|
||||
$set_id = ( is_numeric( $setId ) ) ? $setId : $this->fetchSetIdByKey( $setId );
|
||||
$set_key = '';
|
||||
|
||||
if( $this->isMasterSet( $setId ) )
|
||||
{
|
||||
$set_key = ( is_numeric( $setId ) ) ? $this->fetchSetKeyById( $setId ) : $setId;
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Recurse over the directory
|
||||
//-----------------------------------------
|
||||
@@ -923,36 +1065,36 @@ EOF;
|
||||
|
||||
if ( substr( $_name, -4 ) == '.css' )
|
||||
{
|
||||
$cssName = substr( $_name, 0, -4 );
|
||||
$cssContent = @file_get_contents( $cssDir . '/' . $_name );
|
||||
$_css_added_to = 0;
|
||||
$cssContent = str_replace( array( "\r\n", "\r" ), "\n", $cssContent );
|
||||
$cssName = substr( $_name, 0, -4 );
|
||||
$cssContent = @file_get_contents( $cssDir . '/' . $_name );
|
||||
$_css_added_to = 0;
|
||||
$cssContent = str_replace( array( "\r\n", "\r" ), "\n", $cssContent );
|
||||
|
||||
/* Encode */
|
||||
$cssContent = IPSText::encodeForXml( $cssContent );
|
||||
$cssContent = IPSText::encodeForXml( $cssContent );
|
||||
|
||||
$messages[] = $this->lang->words['basicimportedpre'] . $cssName;
|
||||
$messages[] = $this->lang->words['basicimportedpre'] . $cssName;
|
||||
|
||||
$cssData = $this->_CSS_fetchImportBlock( $cssContent );
|
||||
$cssContent = $this->_CSS_fromFileToDB( $cssContent );
|
||||
$cssData = $this->_CSS_fetchImportBlock( $cssContent );
|
||||
$cssContent = $this->_CSS_fromFileToDB( $cssContent );
|
||||
|
||||
/* 'Master' bit? */
|
||||
if ( ! $css[ $cssName ] )
|
||||
{
|
||||
$_css_added_to = $setId;
|
||||
$_css_added_to = $set_id;
|
||||
}
|
||||
|
||||
$this->DB->insert( 'skin_css', array( 'css_updated' => time(),
|
||||
'css_set_id' => ( is_numeric( $setId ) ) ? $setId : $this->fetchSetIdByKey( $setId ),
|
||||
'css_added_to' => ( is_numeric( $_css_added_to ) ) ? $_css_added_to : $this->fetchSetIdByKey( $_css_added_to ),
|
||||
'css_app' => $cssData['css_app'],
|
||||
'css_app_hide' => intval( $cssData['css_app_hide'] ),
|
||||
'css_modules' => trim( $cssData['css_modules'] ),
|
||||
'css_position' => intval( $cssData['css_position'] ),
|
||||
'css_attributes' => $cssData['css_attributes'],
|
||||
'css_master_key' => ( is_numeric( $setId ) ) ? $this->fetchSetKeyById( $setId ) : $setId,
|
||||
'css_group' => $cssName,
|
||||
'css_content' => $cssContent ) );
|
||||
$this->DB->insert( 'skin_css', array( 'css_updated' => time(),
|
||||
'css_set_id' => $set_id,
|
||||
'css_added_to' => $_css_added_to,
|
||||
'css_app' => $cssData['css_app'],
|
||||
'css_app_hide' => intval( $cssData['css_app_hide'] ),
|
||||
'css_modules' => trim( $cssData['css_modules'] ),
|
||||
'css_position' => intval( $cssData['css_position'] ),
|
||||
'css_attributes' => $cssData['css_attributes'],
|
||||
'css_master_key' => $set_key,
|
||||
'css_group' => $cssName,
|
||||
'css_content' => $cssContent ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1029,6 +1171,18 @@ EOF;
|
||||
$templates = $this->fetchTemplates( $setId, 'allTemplates' );
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Set key and ID
|
||||
//-----------------------------------------
|
||||
|
||||
$set_id = ( is_numeric( $setId ) ) ? $setId : $this->fetchSetIdByKey( $setId );
|
||||
$set_key = '';
|
||||
|
||||
if( $this->isMasterSet( $setId ) )
|
||||
{
|
||||
$set_key = ( is_numeric( $setId ) ) ? $this->fetchSetKeyById( $setId ) : $setId;
|
||||
}
|
||||
|
||||
/* Loop through the directory */
|
||||
try
|
||||
{
|
||||
@@ -1058,10 +1212,10 @@ EOF;
|
||||
continue;
|
||||
}
|
||||
|
||||
$farray = explode( "\n", $fdata );
|
||||
$functions = array();
|
||||
$added = 0;
|
||||
$updated = 0;
|
||||
$farray = explode( "\n", $fdata );
|
||||
$functions = array();
|
||||
$added = 0;
|
||||
$updated = 0;
|
||||
|
||||
foreach( $farray as $f )
|
||||
{
|
||||
@@ -1156,22 +1310,25 @@ EOF;
|
||||
$content = IPSText::encodeForXml( $content );
|
||||
|
||||
/* Build array */
|
||||
$array = array( 'template_set_id' => $setId,
|
||||
$array = array( 'template_set_id' => $set_id,
|
||||
'template_group' => $name,
|
||||
'template_content' => $content,
|
||||
'template_name' => $fname,
|
||||
'template_data' => trim($config[$fname]),
|
||||
'template_updated' => time(),
|
||||
'template_removable' => ( is_numeric( $setId ) AND $setId ) ? 1 : 0,
|
||||
'template_master_key' => ( is_numeric( $setId ) ) ? $this->fetchSetKeyById( $setId ) : $setId,
|
||||
'template_added_to' => ( is_numeric( $setId ) ) ? intval( $setId ) : $this->fetchSetIdByKey( $setId ) );
|
||||
'template_master_key' => $set_key,
|
||||
'template_added_to' => $set_id );
|
||||
|
||||
if ( ! $setId OR ! $templates[ $name ][ strtolower( $fname ) ] )
|
||||
if ( ! $setId )
|
||||
{
|
||||
$added++;
|
||||
|
||||
/* All new bits go to 'master' skin */
|
||||
$array['template_set_id'] = 0;
|
||||
$array['template_added_to'] = 0;
|
||||
$array['template_set_id'] = 0;
|
||||
$array['template_added_to'] = 0;
|
||||
$array['template_master_key'] = 'root';
|
||||
|
||||
$this->DB->insert( 'skin_templates', $array );
|
||||
}
|
||||
else
|
||||
@@ -1192,6 +1349,7 @@ EOF;
|
||||
}
|
||||
}
|
||||
} catch ( Exception $e ) {}
|
||||
|
||||
/* Recache */
|
||||
if ( is_numeric( $setId ) AND $setId )
|
||||
{
|
||||
@@ -1201,19 +1359,63 @@ EOF;
|
||||
$this->cache->putWithCacheLib( 'Skin_Store_' . $setId, array(), 1 );
|
||||
}
|
||||
|
||||
if ( $set_key == 'mobile' )
|
||||
{
|
||||
$this->rebuildMobileSkinUserAgentsFromSetDataXml();
|
||||
}
|
||||
|
||||
/* Return */
|
||||
$messages[] = $this->lang->words['cpltrebuildfromcaches'];
|
||||
|
||||
return $messages;
|
||||
}
|
||||
|
||||
/**
|
||||
* Flag skin as needing recache
|
||||
*
|
||||
* @param int Set ID
|
||||
* @param bool Skip rebuild skin sets cache
|
||||
* @return boolean
|
||||
*/
|
||||
public function flagSetForRecache( $setId=null, $skipRebuild=false )
|
||||
{
|
||||
/* If we're already flagged, just return
|
||||
@link http://community.invisionpower.com/tracker/issue-31472-skin-recaching-optimizations */
|
||||
$_key = md5( $setId . $skipRebuild );
|
||||
|
||||
if( isset($this->_flaggedForRecache[ $_key ]) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
$this->_flaggedForRecache[ $_key ] = 1;
|
||||
|
||||
/* Update DB row */
|
||||
if ( $setId !== null )
|
||||
{
|
||||
$this->DB->update( 'skin_collections', array( 'set_updated' => -2 ), 'set_id=' . intval( $setId ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->DB->update( 'skin_collections', array( 'set_updated' => -2 ) );
|
||||
}
|
||||
|
||||
/* Build cache */
|
||||
if( !$skipRebuild )
|
||||
{
|
||||
$this->rebuildSkinSetsCache();
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Flag skin as needing recache
|
||||
*
|
||||
* @access public
|
||||
* @return boolean
|
||||
*/
|
||||
public function flagSetForRecache( $setId=null )
|
||||
public function flagSetAsRecaching( $setId=null )
|
||||
{
|
||||
/* Update DB row */
|
||||
if ( $setId !== null )
|
||||
@@ -1231,14 +1433,33 @@ EOF;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* We set a flag to rebuild the skin sets cache on shutdown. We do it this way to ensure we only rebuild the cache once per page load.
|
||||
*
|
||||
* @link http://community.invisionpower.com/tracker/issue-31472-skin-recaching-optimizations
|
||||
* @access public
|
||||
* @return boolean
|
||||
*/
|
||||
public function rebuildSkinSetsCache()
|
||||
{
|
||||
if( !$this->_recacheSkinsCache )
|
||||
{
|
||||
$this->_recacheSkinsCache = true;
|
||||
|
||||
register_shutdown_function( array( $this, '__rebuildSkinSetsCache' ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Rebuild skinsets cache in the cache_store table
|
||||
*
|
||||
* @access public
|
||||
* @return boolean
|
||||
*/
|
||||
public function rebuildSkinSetsCache()
|
||||
public function __rebuildSkinSetsCache()
|
||||
{
|
||||
|
||||
//-----------------------------------------
|
||||
// INIT
|
||||
//-----------------------------------------
|
||||
@@ -1325,7 +1546,7 @@ EOF;
|
||||
{
|
||||
/* Set directory */
|
||||
$css = array();
|
||||
$cssDir = DOC_IPS_ROOT_PATH . 'public/style_css/' . $dir;
|
||||
$cssDir = DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_css/' . $dir;
|
||||
$messages = array();
|
||||
|
||||
if ( ! file_exists( $cssDir ) )
|
||||
@@ -1409,7 +1630,7 @@ EOF;
|
||||
|
||||
$setData = $this->fetchSkinData( $id );
|
||||
|
||||
$path = DOC_IPS_ROOT_PATH . 'public/style_css/' . $dir;
|
||||
$path = DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_css/' . $dir;
|
||||
$msgs = array();
|
||||
|
||||
if ( ! isset( $setData['set_id'] ) )
|
||||
@@ -1597,7 +1818,7 @@ EOF;
|
||||
}
|
||||
else
|
||||
{
|
||||
@chmod( $path . '/' . $_file, 0777 );
|
||||
@chmod( $path . '/' . $_file, IPS_FILE_PERMISSION );
|
||||
$msgs[] = $this->lang->words['basicwrittenpre'] . $path . '/' . $_file;
|
||||
}
|
||||
}
|
||||
@@ -1613,11 +1834,11 @@ EOF;
|
||||
/**
|
||||
* Creates CSS master block
|
||||
*
|
||||
* @access private
|
||||
* @access protected
|
||||
* @param array Array of CSS data from the DB
|
||||
* @return string
|
||||
*/
|
||||
private function _masterWrite_createCssBlock( $data )
|
||||
protected function _masterWrite_createCssBlock( $data )
|
||||
{
|
||||
$block = array();
|
||||
|
||||
@@ -1663,11 +1884,11 @@ EOF;
|
||||
/**
|
||||
* Wrap content for a master skin function
|
||||
*
|
||||
* @access private
|
||||
* @access protected
|
||||
* @param array Template bit data
|
||||
* @param string Content
|
||||
*/
|
||||
private function _masterWrite_format( $data )
|
||||
protected function _masterWrite_format( $data )
|
||||
{
|
||||
$_open = '<<<EOF';
|
||||
$_close = 'EOF';
|
||||
@@ -1693,11 +1914,11 @@ EOF;
|
||||
/**
|
||||
* Wrap content for a master skin class
|
||||
*
|
||||
* @access private
|
||||
* @access protected
|
||||
* @param string Content
|
||||
* @param string Content
|
||||
*/
|
||||
private function _masterWrite_wrap( $content )
|
||||
protected function _masterWrite_wrap( $content )
|
||||
{
|
||||
$_date = gmdate( 'r' );
|
||||
$return = <<<EOF
|
||||
@@ -1721,7 +1942,7 @@ EOF;
|
||||
* @param int Skin set ID
|
||||
* @param string Group Name
|
||||
* @param string CSS content
|
||||
* @return void
|
||||
* @return @e void
|
||||
*/
|
||||
protected function _writeCSSFile( $setID, $css_group, $css_content )
|
||||
{
|
||||
@@ -1744,7 +1965,7 @@ EOF;
|
||||
|
||||
if ( ! is_dir( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_css/css_' . $setID ) )
|
||||
{
|
||||
if ( ! @ mkdir( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_css/css_' . $setID, 0777 ) )
|
||||
if ( ! @ mkdir( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_css/css_' . $setID, IPS_FOLDER_PERMISSION ) )
|
||||
{
|
||||
$this->_addErrorMessage( sprintf( $this->lang->words['couldnotcreatecssdir'], $setID ) );
|
||||
return $this->_errorMsgs;
|
||||
@@ -1752,7 +1973,7 @@ EOF;
|
||||
else
|
||||
{
|
||||
@file_put_contents( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_css/css_' . $setID . '/index.html', '' );
|
||||
@chmod( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_css/css_'.$setID, 0777 );
|
||||
@chmod( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_css/css_'.$setID, IPS_FOLDER_PERMISSION );
|
||||
$good_to_go = 1;
|
||||
}
|
||||
}
|
||||
@@ -1763,7 +1984,7 @@ EOF;
|
||||
$this->_addErrorMessage( sprintf( $this->lang->words['cssdirnotwritaaaable'], $setID ) );
|
||||
$good_to_go = 0;
|
||||
}
|
||||
else if ( file_exists( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_css/css_'.$setID.'/'.$css_group.'.css' ) )
|
||||
else if ( is_file( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_css/css_'.$setID.'/'.$css_group.'.css' ) )
|
||||
{
|
||||
if ( is_writable( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_css/css_'.$setID.'/'.$css_group.'.css' ) !== TRUE )
|
||||
{
|
||||
@@ -1803,7 +2024,7 @@ EOF;
|
||||
{
|
||||
fwrite( $FH, $css_content, strlen($css_content) );
|
||||
fclose( $FH );
|
||||
@chmod( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_css/css_'.$setID.'/'.$css_group.'.css', 0777 );
|
||||
@chmod( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_css/css_'.$setID.'/'.$css_group.'.css', IPS_FILE_PERMISSION );
|
||||
|
||||
$this->_addMessage( $this->lang->words['basicwrittenpre']. "skin_cache/css_{$setID}/{$css_group}.css" );
|
||||
}
|
||||
@@ -1842,7 +2063,7 @@ EOF;
|
||||
|
||||
if ( ! is_dir( IPS_CACHE_PATH.'cache/skin_cache/cacheid_'.$setID ) )
|
||||
{
|
||||
if ( ! @ mkdir( IPS_CACHE_PATH.'cache/skin_cache/cacheid_'.$setID, 0777 ) )
|
||||
if ( ! @ mkdir( IPS_CACHE_PATH.'cache/skin_cache/cacheid_'.$setID, IPS_FOLDER_PERMISSION ) )
|
||||
{
|
||||
$this->_addErrorMessage( sprintf( $this->lang->words['fatalnotemplatew'], $setID ) );
|
||||
return;
|
||||
@@ -1850,13 +2071,13 @@ EOF;
|
||||
else
|
||||
{
|
||||
@file_put_contents( IPS_CACHE_PATH.'cache/skin_cache/cacheid_' . $setID . '/index.html', '' );
|
||||
@chmod( IPS_CACHE_PATH.'cache/skin_cache/cacheid_'.$setID, 0777 );
|
||||
@chmod( IPS_CACHE_PATH.'cache/skin_cache/cacheid_'.$setID, IPS_FOLDER_PERMISSION );
|
||||
$good_to_go = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( file_exists( IPS_CACHE_PATH.'cache/skin_cache/cacheid_'.$setID.'/'.$groupName.'.php' ) )
|
||||
if ( is_file( IPS_CACHE_PATH.'cache/skin_cache/cacheid_'.$setID.'/'.$groupName.'.php' ) )
|
||||
{
|
||||
if ( IPSLib::isWritable( IPS_CACHE_PATH.'cache/skin_cache/cacheid_'.$setID.'/'.$groupName.'.php' ) !== TRUE )
|
||||
{
|
||||
@@ -1890,7 +2111,7 @@ EOF;
|
||||
{
|
||||
fwrite( $FH, $content, strlen($content) );
|
||||
fclose( $FH );
|
||||
@chmod( IPS_CACHE_PATH.'cache/skin_cache/cacheid_'.$setID.'/'.$groupName.'.php', 0777 );
|
||||
@chmod( IPS_CACHE_PATH.'cache/skin_cache/cacheid_'.$setID.'/'.$groupName.'.php', IPS_FILE_PERMISSION );
|
||||
|
||||
$this->_addMessage( $this->lang->words['basicwrittenpre'] . "skin_cache/cacheid_{$setID}/{$groupName}.php" );
|
||||
}
|
||||
@@ -2009,6 +2230,9 @@ EOF;
|
||||
}
|
||||
}
|
||||
|
||||
/* remove phpdoc style comments */
|
||||
$cssContent = preg_replace( '#/\*\*(\s+?)(.+?)\n(\s+?)?\*/#s', '', $cssContent );
|
||||
|
||||
$cssContent = preg_replace( '#url\((\"|\')?.+?style_images/([\d\w]+?)/#i', "url(\\1{style_images_url}/", $cssContent );
|
||||
$cssContent = preg_replace( '#url\((\"|\')?/style_images/([\d\w]+?)#i' , "url(\\1{style_images_url}/", $cssContent );
|
||||
|
||||
@@ -2066,13 +2290,13 @@ EOF;
|
||||
/**
|
||||
* Determine which CSS files need rebuilding
|
||||
*
|
||||
* @access private
|
||||
* @access protected
|
||||
* @param array Array of child skins (including current setID)
|
||||
* @param int Set ID we're recaching
|
||||
* @param boolean Force all css sets to recache
|
||||
* @return array Array of items to rebuild
|
||||
*/
|
||||
private function _CSSNeedToRebuild( $childTree, $setID, $forceRebuild=FALSE )
|
||||
protected function _CSSNeedToRebuild( $childTree, $setID, $forceRebuild=FALSE )
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Already been 'ere?
|
||||
@@ -2088,9 +2312,28 @@ EOF;
|
||||
$needToRebuild = array();
|
||||
|
||||
//-----------------------------------------
|
||||
// Fetch cached CSS data
|
||||
// Fetch cached CSS data - need to add parent tree and select parent css first
|
||||
//-----------------------------------------
|
||||
|
||||
|
||||
/* Do we need a parent? */
|
||||
$setData = $this->fetchSkinData( $setID );
|
||||
|
||||
if ( count( $setData['_parentTree'] ) )
|
||||
{
|
||||
/* Allow parent data to be overwritten by child data */
|
||||
$this->DB->build( array( 'select' => '*',
|
||||
'from' => 'skin_cache',
|
||||
'where' => "cache_type='css' AND cache_set_id IN (" . implode( ',', $setData['_parentTree'] ) . ')' ) );
|
||||
|
||||
$this->DB->execute();
|
||||
|
||||
while( $row = $this->DB->fetch() )
|
||||
{
|
||||
$row['cache_content'] = md5( $row['cache_content'] );
|
||||
$cachedCSS[ $row['cache_set_id'] ][ $row['cache_value_1'] ] = $row;
|
||||
}
|
||||
}
|
||||
|
||||
$this->DB->build( array( 'select' => '*',
|
||||
'from' => 'skin_cache',
|
||||
'where' => "cache_type='css' AND cache_set_id IN (" . implode( ',', $childTree ) . ')' ) );
|
||||
@@ -2120,6 +2363,12 @@ EOF;
|
||||
$thisCSS[ $row['css_set_id'] ][ $row['css_group'] ] = $row;
|
||||
}
|
||||
|
||||
/* Add in parent skins */
|
||||
if ( count( $setData['_parentTree'] ) )
|
||||
{
|
||||
$childTree = array_merge( $childTree, $setData['_parentTree'] );
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// First off, any caches missing?
|
||||
//-----------------------------------------
|
||||
@@ -2198,10 +2447,34 @@ EOF;
|
||||
/* This CSS inherits our skin set, so recache */
|
||||
$needToRebuild[ $_setID ][ $group ] = 1;
|
||||
}
|
||||
|
||||
/* Now lets see if there are any parent CSS that need to be added */
|
||||
if ( count( $setData['_parentTree'] ) )
|
||||
{
|
||||
foreach( $setData['_parentTree'] as $id )
|
||||
{
|
||||
if ( $cacheData['cache_key_3'] == 'setBy' && $cacheData['cache_value_3'] == $id )
|
||||
{
|
||||
/* Add to current set id */
|
||||
$needToRebuild[ $setID ][ $group ] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Finally, we don't want to recache parents so remove them */
|
||||
if ( count( $setData['_parentTree'] ) )
|
||||
{
|
||||
foreach( $setData['_parentTree'] as $id )
|
||||
{
|
||||
if ( is_array( $needToRebuild[ $id ] ) )
|
||||
{
|
||||
unset( $needToRebuild[ $id ] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->_cssNeedToRebuildArray[ $setID ] = $needToRebuild;
|
||||
|
||||
|
||||
@@ -3,19 +3,19 @@
|
||||
/**
|
||||
* <pre>
|
||||
* Invision Power Services
|
||||
* IP.Board v3.1.4
|
||||
* IP.Board v3.2.3
|
||||
* Skin Functions
|
||||
* Last Updated: $Date: 2010-09-13 05:53:37 -0400 (Mon, 13 Sep 2010) $
|
||||
* Last Updated: $Date: 2011-05-05 07:03:47 -0400 (Thu, 05 May 2011) $
|
||||
* </pre>
|
||||
*
|
||||
* Owner: Matt
|
||||
* @author $Author: terabyte $
|
||||
* @author $Author: ips_terabyte $
|
||||
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/community/board/license.html
|
||||
* @license This is NULLED!
|
||||
* @package IP.Board
|
||||
* @link http://www.invisionpower.com
|
||||
* @link http://hatynka.in
|
||||
* @since 9th March 2005 11:03
|
||||
* @version $Revision: 6854 $
|
||||
* @version $Revision: 8644 $
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -39,7 +39,9 @@ class skinDifferences extends skinCaching
|
||||
protected $request;
|
||||
protected $lang;
|
||||
protected $member;
|
||||
protected $memberData;
|
||||
protected $cache;
|
||||
protected $caches;
|
||||
/**#@-*/
|
||||
|
||||
/**
|
||||
@@ -52,12 +54,12 @@ class skinDifferences extends skinCaching
|
||||
*
|
||||
* @access public
|
||||
* @param object Registry object
|
||||
* @return void
|
||||
* @return @e void
|
||||
*/
|
||||
public function __construct( ipsRegistry $registry )
|
||||
{
|
||||
/* Make diff class object */
|
||||
require_once( IPS_KERNEL_PATH . 'classDifference.php' );
|
||||
require_once( IPS_KERNEL_PATH . 'classDifference.php' );/*noLibHook*/
|
||||
$this->classDifference = new classDifference();
|
||||
$this->classDifference->method = 'PHP';
|
||||
|
||||
@@ -631,7 +633,7 @@ class skinDifferences extends skinCaching
|
||||
$sessions = array();
|
||||
|
||||
/* Fetch set up class */
|
||||
require_once( IPS_ROOT_PATH . "setup/sources/base/setup.php" );
|
||||
require_once( IPS_ROOT_PATH . "setup/sources/base/setup.php" );/*noLibHook*/
|
||||
|
||||
/* Fetch version numbers */
|
||||
$versions = IPSSetUp::fetchXmlAppVersions('core');
|
||||
@@ -874,7 +876,7 @@ class skinDifferences extends skinCaching
|
||||
if ( $session['merge_id'] AND $parse === true )
|
||||
{
|
||||
/* Fetch set up class */
|
||||
require_once( IPS_ROOT_PATH . "setup/sources/base/setup.php" );
|
||||
require_once( IPS_ROOT_PATH . "setup/sources/base/setup.php" );/*noLibHook*/
|
||||
|
||||
/* Fetch version numbers */
|
||||
$versions = IPSSetUp::fetchXmlAppVersions('core');
|
||||
|
||||
@@ -3,19 +3,19 @@
|
||||
/**
|
||||
* <pre>
|
||||
* Invision Power Services
|
||||
* IP.Board v3.1.4
|
||||
* IP.Board v3.2.3
|
||||
* Skin Functions
|
||||
* Last Updated: $Date: 2010-10-13 14:43:52 -0400 (Wed, 13 Oct 2010) $
|
||||
* Last Updated: $Date: 2011-10-14 10:25:10 -0400 (Fri, 14 Oct 2011) $
|
||||
* </pre>
|
||||
*
|
||||
* Owner: Matt
|
||||
* @author $Author: mmecham $
|
||||
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/community/board/license.html
|
||||
* @license This is NULLED!
|
||||
* @package IP.Board
|
||||
* @link http://www.invisionpower.com
|
||||
* @link http://hatynka.in
|
||||
* @since 9th March 2005 11:03
|
||||
* @version $Revision: 6972 $
|
||||
* @version $Revision: 9619 $
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -39,7 +39,9 @@ class skinFunctions
|
||||
protected $request;
|
||||
protected $lang;
|
||||
protected $member;
|
||||
protected $memberData;
|
||||
protected $cache;
|
||||
protected $caches;
|
||||
/**#@-*/
|
||||
|
||||
/**
|
||||
@@ -54,26 +56,26 @@ class skinFunctions
|
||||
* Template count
|
||||
* Maintains an array: [skin_set_id][group_name][count]
|
||||
*
|
||||
* @access private
|
||||
* @access protected
|
||||
* @var array
|
||||
*/
|
||||
private $_templateCount;
|
||||
protected $_templateCount;
|
||||
|
||||
/**
|
||||
* Error handle
|
||||
*
|
||||
* @access private
|
||||
* @access protected
|
||||
* @var array
|
||||
*/
|
||||
private $_errorMsgs = array();
|
||||
protected $_errorMsgs = array();
|
||||
|
||||
/**
|
||||
* Message handle
|
||||
*
|
||||
* @access private
|
||||
* @access protected
|
||||
* @var array
|
||||
*/
|
||||
private $_generalMsgs = array();
|
||||
protected $_generalMsgs = array();
|
||||
|
||||
/**
|
||||
* IN_DEV remap data
|
||||
@@ -85,16 +87,16 @@ class skinFunctions
|
||||
|
||||
/**
|
||||
* Set cache
|
||||
* @var private
|
||||
* @var protected
|
||||
*/
|
||||
private $_seenSet = array();
|
||||
protected $_seenSet = array();
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @access public
|
||||
* @param object Registry object
|
||||
* @return void
|
||||
* @return @e void
|
||||
*/
|
||||
public function __construct( ipsRegistry $registry )
|
||||
{
|
||||
@@ -127,7 +129,7 @@ class skinFunctions
|
||||
// Load tier class and init it
|
||||
//-----------------------------------------
|
||||
|
||||
require_once( IPS_ROOT_PATH . 'sources/classes/tiers/recursiveTiers.php' );
|
||||
require_once( IPS_ROOT_PATH . 'sources/classes/tiers/recursiveTiers.php' );/*noLibHook*/
|
||||
|
||||
$this->recursiveTiers = new recursiveTiers( $registry, array( 'sqlPrimaryID' => 'set_id',
|
||||
'sqlParentID' => 'set_parent_id',
|
||||
@@ -148,6 +150,32 @@ class skinFunctions
|
||||
return $this->recursiveTiers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make this skin default
|
||||
* @param int $set_id
|
||||
*/
|
||||
public function makeDefault( $set_id )
|
||||
{
|
||||
$setData = $this->fetchSkinData( $set_id, true );
|
||||
|
||||
/* Make all others non default */
|
||||
$this->DB->update( 'skin_collections', array( 'set_is_default' => 0 ), 'set_id != ' . $set_id . ' AND set_output_format=\'' . $setData['set_output_format'] . '\'' );
|
||||
|
||||
/* Attempt to see if we have any other skin called 'default' */
|
||||
/* Not using this currently as it causes complications in other areas */
|
||||
/*
|
||||
$default = $this->DB->buildAndFetch( array( 'select' => 'set_id',
|
||||
'from' => 'skin_collections',
|
||||
'where' => 'set_key=\'default\' AND set_output_format=\'' . $setData['set_output_format'] . '\'' ) );
|
||||
if ( $set_id != $default['set_id'] )
|
||||
{
|
||||
$this->DB->update( 'skin_collections', array( 'set_key' => IPS_UNIX_TIME_NOW ), 'set_id = ' . $default['set_id'] );
|
||||
}
|
||||
*/
|
||||
/* Make this default */
|
||||
$this->DB->update( 'skin_collections', array( 'set_is_default' => 1/*, 'set_key' => 'default'*/ ), 'set_id = ' . $set_id . ' AND set_output_format=\'' . $setData['set_output_format'] . '\'' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch highest order
|
||||
*
|
||||
@@ -194,7 +222,7 @@ class skinFunctions
|
||||
else
|
||||
{
|
||||
$REMAP = array();
|
||||
require( DOC_IPS_ROOT_PATH . 'cache/skin_cache/masterMap.php' );
|
||||
require( DOC_IPS_ROOT_PATH . 'cache/skin_cache/masterMap.php' );/*noLibHook*/
|
||||
|
||||
if ( is_array($REMAP) && count($REMAP) )
|
||||
{
|
||||
@@ -207,13 +235,14 @@ class skinFunctions
|
||||
|
||||
/**
|
||||
* Returns a skin set ID based on a key
|
||||
* @param string $key
|
||||
* @param string $key
|
||||
* @param boolean $ignoreMasterKeys
|
||||
*/
|
||||
public function fetchSetIdByKey( $key )
|
||||
public function fetchSetIdByKey( $key, $ignoreMasterKeys=false )
|
||||
{
|
||||
$masterKeys = $this->fetchMasterKeys();
|
||||
|
||||
if ( in_array( $key, $masterKeys ) )
|
||||
if ( in_array( $key, $masterKeys ) && $ignoreMasterKeys === false )
|
||||
{
|
||||
/* Default master keys are always 0 */
|
||||
return 0;
|
||||
@@ -253,6 +282,19 @@ class skinFunctions
|
||||
return ( $this->_seenSet[ 'i-' . $id ]['set_key'] ) ? $this->_seenSet[ 'i-' . $id ]['set_key'] : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the skin set is a "master" set
|
||||
*
|
||||
* @param mixed $id Skin set key or skin set id
|
||||
* @return bool True if this is a master set, otherwise false
|
||||
*/
|
||||
public function isMasterSet( $id )
|
||||
{
|
||||
$key = is_numeric($id) ? $this->fetchSetKeyById( $id ) : $id;
|
||||
|
||||
return in_array( $key, $this->remapData['masterKeys'] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Search template bits
|
||||
*
|
||||
@@ -418,7 +460,7 @@ class skinFunctions
|
||||
* Reset error handle
|
||||
*
|
||||
* @access protected
|
||||
* @return void
|
||||
* @return @e void
|
||||
*/
|
||||
final protected function _resetErrorHandle()
|
||||
{
|
||||
@@ -428,9 +470,9 @@ class skinFunctions
|
||||
/**
|
||||
* Add an error message
|
||||
*
|
||||
* @access private
|
||||
* @access protected
|
||||
* @param string Error message to add
|
||||
* @return void
|
||||
* @return @e void
|
||||
*/
|
||||
final protected function _addErrorMessage( $error )
|
||||
{
|
||||
@@ -453,7 +495,7 @@ class skinFunctions
|
||||
* Reset error handle
|
||||
*
|
||||
* @access protected
|
||||
* @return void
|
||||
* @return @e void
|
||||
*/
|
||||
final protected function _resetMessageHandle()
|
||||
{
|
||||
@@ -465,7 +507,7 @@ class skinFunctions
|
||||
*
|
||||
* @access protected
|
||||
* @param string Error message to add
|
||||
* @return void
|
||||
* @return @e void
|
||||
*/
|
||||
final protected function _addMessage( $error )
|
||||
{
|
||||
@@ -489,7 +531,7 @@ class skinFunctions
|
||||
*
|
||||
* @access public
|
||||
* @param string Name of skin file
|
||||
* @return void Evals the skin to add the class in memory
|
||||
* @return @e void Evals the skin to add the class in memory
|
||||
*/
|
||||
public function loadMasterSkinTemplate( $name, $id )
|
||||
{
|
||||
@@ -502,7 +544,7 @@ class skinFunctions
|
||||
|
||||
$_dir = $this->remapData['templates'][ $_id ];
|
||||
|
||||
if( ! file_exists(IPS_CACHE_PATH."cache/skin_cache/" . $_dir . "/".$name.".php") )
|
||||
if( ! is_file(IPS_CACHE_PATH."cache/skin_cache/" . $_dir . "/".$name.".php") )
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -526,9 +568,9 @@ class skinFunctions
|
||||
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 );
|
||||
}
|
||||
}
|
||||
@@ -573,13 +615,14 @@ class skinFunctions
|
||||
*
|
||||
* @access public
|
||||
* @param int Skin set ID
|
||||
* @param bool Force, even if it is not removable
|
||||
* @return boolean (True OK to remove, false NOT OK to remove)
|
||||
*/
|
||||
public function removeSet( $setID )
|
||||
public function removeSet( $setID, $force=false )
|
||||
{
|
||||
$skinSetData = $this->fetchSkinData( $setID );
|
||||
|
||||
if ( $this->canRemoveSet( $setID ) !== TRUE )
|
||||
if ( $force !== TRUE AND $this->canRemoveSet( $setID ) !== TRUE )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
@@ -612,10 +655,13 @@ class skinFunctions
|
||||
$this->DB->delete( 'skin_url_mapping', 'map_skin_set_id=' . $setID );
|
||||
|
||||
/* Delete CSS Files */
|
||||
$this->registry->adminFunctions->removeDirectory( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_css/css_' . $setID );
|
||||
$classToLoad = IPSLib::loadLibrary( IPS_KERNEL_PATH . '/classFileManagement.php', 'classFileManagement' );
|
||||
$fileManagement = new $classToLoad();
|
||||
|
||||
$fileManagement->removeDirectory( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_css/css_' . $setID );
|
||||
|
||||
/* Delete PHP Cache Files */
|
||||
$this->registry->adminFunctions->removeDirectory( IPS_CACHE_PATH . 'cache/skin_cache/cacheid_' . $setID );
|
||||
$fileManagement->removeDirectory( IPS_CACHE_PATH . 'cache/skin_cache/cacheid_' . $setID );
|
||||
|
||||
/* Delete any diff/merge sessions */
|
||||
$this->DB->build( array( 'select' => '*',
|
||||
@@ -630,7 +676,23 @@ class skinFunctions
|
||||
$this->DB->delete('skin_merge_session', 'merge_id=' . $row['merge_id'] );
|
||||
$this->DB->delete('skin_merge_changes', 'change_session_id=' . $row['merge_id'] );
|
||||
}
|
||||
|
||||
/* Generator stuff */
|
||||
$this->DB->build( array( 'select' => '*',
|
||||
'from' => 'skin_generator_sessions',
|
||||
'where' => 'sg_skin_set_id=' . $setID ) );
|
||||
|
||||
$o = $this->DB->execute();
|
||||
|
||||
while( $row = $this->DB->fetch( $o ) )
|
||||
{
|
||||
/* Delete 'em */
|
||||
$this->DB->delete('skin_generator_sessions', 'sg_session_id=' . $row['sg_session_id'] );
|
||||
|
||||
IPSMember::save( $row['sg_member_id'], array( 'core' => array( 'bw_using_skin_gen' => 0 ) ) );
|
||||
}
|
||||
|
||||
|
||||
/* Rebuild Tree Information */
|
||||
$this->rebuildTreeInformation();
|
||||
|
||||
@@ -868,8 +930,8 @@ class skinFunctions
|
||||
//-----------------------------------------
|
||||
|
||||
$replacement = $this->DB->buildAndFetch( array( 'select' => '*',
|
||||
'from' => 'skin_replacements',
|
||||
'where' => 'replacement_id=' . $replacementID ) );
|
||||
'from' => 'skin_replacements',
|
||||
'where' => 'replacement_id=' . $replacementID ) );
|
||||
|
||||
if ( ! $replacement['replacement_id'] )
|
||||
{
|
||||
@@ -885,8 +947,8 @@ class skinFunctions
|
||||
if ( $replacement['replacement_key'] != $replacement_key )
|
||||
{
|
||||
$replacementTest = $this->DB->buildAndFetch( array( 'select' => '*',
|
||||
'from' => 'skin_replacements',
|
||||
'where' => 'replacement_set_id=' . $setID . ' AND replacement_key=\'' . $replacement_key . '\'' ) );
|
||||
'from' => 'skin_replacements',
|
||||
'where' => 'replacement_set_id=' . $setID . ' AND replacement_key=\'' . $replacement_key . '\'' ) );
|
||||
|
||||
if ( $replacementTest['replacement_id'] )
|
||||
{
|
||||
@@ -1033,8 +1095,8 @@ class skinFunctions
|
||||
//-----------------------------------------
|
||||
|
||||
$replacement = $this->DB->buildAndFetch( array( 'select' => '*',
|
||||
'from' => 'skin_replacements',
|
||||
'where' => 'replacement_id=' . $replacementID ) );
|
||||
'from' => 'skin_replacements',
|
||||
'where' => 'replacement_id=' . $replacementID ) );
|
||||
|
||||
if ( ! $replacement['replacement_id'] )
|
||||
{
|
||||
@@ -1123,7 +1185,8 @@ class skinFunctions
|
||||
}
|
||||
else
|
||||
{
|
||||
$skinSetData = $this->fetchSkinData( $setID );
|
||||
$skinSetData = $this->fetchSkinData( $setID );
|
||||
$skinSetData['_isMaster'] = $skinSetData['_isMaster'] ? $skinSetData['_isMaster'] : 0;
|
||||
}
|
||||
|
||||
/* Did we get a skin set? */
|
||||
@@ -1235,7 +1298,7 @@ class skinFunctions
|
||||
|
||||
$css['_actualSetID'] = $css['css_set_id'];
|
||||
$css['_belongsSetID'] = $setID;
|
||||
$css['_isMaster'] = ( $css['css_master_key'] ) ? true : false;
|
||||
$css['_isMaster'] = ( $css['css_master_key'] ) ? 1 : 0;
|
||||
//$css['_css_content'] = $css['css_content'];
|
||||
|
||||
//-----------------------------------------
|
||||
@@ -1280,7 +1343,13 @@ class skinFunctions
|
||||
$setID = intval( $setID );
|
||||
$css_group = str_replace( '.css', '', IPSText::alphanumericalClean( $css_group ) );
|
||||
$css_position = intval( $css_position );
|
||||
|
||||
|
||||
/* Make sure skingen is always on top */
|
||||
if ( $css_group != 'ipb_skingen' )
|
||||
{
|
||||
$css_position = ( $css_position >= 999 ) ? 998 : $css_position;
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Get skin data
|
||||
//-----------------------------------------
|
||||
@@ -1375,7 +1444,13 @@ class skinFunctions
|
||||
$css_group = str_replace( '.css', '', IPSText::alphanumericalClean( $css_group ) );
|
||||
$css_position = intval( $css_position );
|
||||
$_goClean = 0;
|
||||
|
||||
|
||||
/* Make sure skingen is always on top */
|
||||
if ( $css_group != 'ipb_skingen' )
|
||||
{
|
||||
$css_position = ( $css_position >= 999 ) ? 998 : $css_position;
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Fetch template data
|
||||
//-----------------------------------------
|
||||
@@ -1579,7 +1654,7 @@ class skinFunctions
|
||||
|
||||
return $cssData;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Fetch Templates from the tree
|
||||
*
|
||||
@@ -1623,7 +1698,8 @@ class skinFunctions
|
||||
}
|
||||
else
|
||||
{
|
||||
$skinSetData = $this->fetchSkinData( $setID );
|
||||
$skinSetData = $this->fetchSkinData( $setID );
|
||||
$skinSetData['_isMaster'] = $skinSetData['_isMaster'] ? $skinSetData['_isMaster'] : 0;
|
||||
}
|
||||
|
||||
/* Did we get a skin set? */
|
||||
@@ -1848,7 +1924,7 @@ class skinFunctions
|
||||
$template['_belongsSetID'] = $setID;
|
||||
$template['_template_content'] = $template['template_content'];
|
||||
$template['_template_data'] = $template['template_data'];
|
||||
$template['_isMaster'] = ( $template['template_master_key'] ) ? true : false;
|
||||
$template['_isMaster'] = ( $template['template_master_key'] ) ? 1 : 0;
|
||||
|
||||
//-----------------------------------------
|
||||
// Update content for editing
|
||||
@@ -2047,7 +2123,11 @@ class skinFunctions
|
||||
//-----------------------------------------
|
||||
// Same template set?
|
||||
//-----------------------------------------
|
||||
|
||||
|
||||
/* @todo - 'root' is almost certainly what we want but we *should* write a method that traverses up the tree
|
||||
* from this set ID and looks for the master key of the root set. Especially important if we add any future
|
||||
* output engines.
|
||||
*/
|
||||
$this->DB->insert( 'skin_templates', array( 'template_set_id' => 0,
|
||||
'template_group' => $template_group,
|
||||
'template_content' => $template_content,
|
||||
@@ -2057,7 +2137,8 @@ class skinFunctions
|
||||
'template_user_edited' => 1,
|
||||
'template_user_added' => 1,
|
||||
'template_removable' => 1,
|
||||
'template_updated' => time() ) );
|
||||
'template_updated' => time(),
|
||||
'template_master_key' => 'root' ) );
|
||||
|
||||
$template_id_new = $this->DB->getInsertId();
|
||||
|
||||
@@ -2169,6 +2250,12 @@ class skinFunctions
|
||||
# Update count
|
||||
$this->_templateCount[ $setID ][ $template['template_group'] ]['count']++;
|
||||
}
|
||||
|
||||
/* If this is a user-added template bit and we're editing it in the same skin, update master */
|
||||
if ( $template['template_id'] && $template['template_user_added'] && $template['template_added_to'] == $setID )
|
||||
{
|
||||
$this->DB->update( 'skin_templates', array( 'template_content' => $template_content ), "template_set_id=0 AND template_group='" . $template['template_group'] . "' AND template_name='" . $template['template_name'] . "'" );
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Recache
|
||||
@@ -2182,6 +2269,82 @@ class skinFunctions
|
||||
|
||||
return $template_id_new;
|
||||
}
|
||||
|
||||
/**
|
||||
* renames a template title
|
||||
* @param int $templateId
|
||||
* @param string $newName
|
||||
*/
|
||||
public function renameTemplateName( $templateId, $newName )
|
||||
{
|
||||
$template = $this->fetchTemplateBitForEdit( $templateId, 0 );
|
||||
$skinSet = $this->fetchSkinData( $template['template_set_id'] );
|
||||
$okToSave = true;
|
||||
$masterKey = 'root';
|
||||
|
||||
$update = array( 'template_name' => $newName );
|
||||
|
||||
if ( ( $template['template_set_id'] == $template['template_added_to'] ) )
|
||||
{
|
||||
$masterTemplates = $this->fetchTemplates( $masterKey, 'allNoContent', $template['template_group'] );
|
||||
|
||||
if ( isset( $masterTemplates[ $template['template_group'] ][ $newName ] ) )
|
||||
{
|
||||
/* Added by webdav, now attempting to rename */
|
||||
$update['template_added_to'] = 0;
|
||||
$update['template_master_key'] = $masterKey;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! $template['template_id'] OR $template['_isMaster'] )
|
||||
{
|
||||
$okToSave = false;
|
||||
}
|
||||
|
||||
if ( $okToSave )
|
||||
{
|
||||
$this->DB->update( 'skin_templates', $update, 'template_name=\'' . $this->DB->addSlashes( $template['template_name'] ) . '\' AND template_group=\'' . $this->DB->addSlashes( $template['template_group'] ) . '\'' );
|
||||
}
|
||||
|
||||
/* rebuild */
|
||||
$this->rebuildPHPTemplates( $template['template_set_id'], $template['template_group'] );
|
||||
}
|
||||
|
||||
/**
|
||||
* renames a css title
|
||||
* @param int $cssId
|
||||
* @param string $newName
|
||||
*/
|
||||
public function renameCssName( $cssId, $newName )
|
||||
{
|
||||
$template = $this->fetchCssForEdit( $cssId, 0 );
|
||||
$okToSave = true;
|
||||
$update = array( 'css_group' => $newName );
|
||||
|
||||
if ( ( $template['css_set_id'] == $template['css_added_to'] ) )
|
||||
{
|
||||
$masterCss = $this->fetchCSS( 'root', false );
|
||||
|
||||
if ( isset( $masterCss[ $newName ] ) )
|
||||
{
|
||||
/* Added by webdav, now attempting to rename */
|
||||
$update['css_added_to'] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! $template['css_id'] OR $template['_isMaster'] )
|
||||
{
|
||||
$okToSave = false;
|
||||
}
|
||||
|
||||
if ( $okToSave )
|
||||
{
|
||||
$this->DB->update( 'skin_css', $update, 'css_group=\'' . $this->DB->addSlashes( $template['css_group'] ) . '\'' );
|
||||
}
|
||||
|
||||
/* rebuild */
|
||||
$this->rebuildCSS( $template['css_set_id'] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch image directories from the file system
|
||||
@@ -2304,7 +2467,7 @@ class skinFunctions
|
||||
{
|
||||
if ( @mkdir( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_images/' . $dir ) )
|
||||
{
|
||||
@chmod( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_images/' . $dir, 0777 );
|
||||
@chmod( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_images/' . $dir, IPS_FOLDER_PERMISSION );
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
@@ -2357,13 +2520,13 @@ class skinFunctions
|
||||
continue;
|
||||
}
|
||||
|
||||
if( ! file_exists( $path . '/' . $_name . '/conf.php' ) )
|
||||
if( ! is_file( $path . '/' . $_name . '/conf.php' ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$config = array();
|
||||
require( $path . '/' . $_name . '/conf.php' );
|
||||
require( $path . '/' . $_name . '/conf.php' );/*noLibHook*/
|
||||
|
||||
$formats[ $_name ] = $config;
|
||||
}
|
||||
@@ -2413,7 +2576,7 @@ class skinFunctions
|
||||
foreach( $hooks as $tplHook )
|
||||
{
|
||||
/* Check for hook file */
|
||||
if( file_exists( DOC_IPS_ROOT_PATH . 'hooks/' . $tplHook['filename'] ) )
|
||||
if( is_file( IPS_HOOKS_PATH . $tplHook['filename'] ) )
|
||||
{
|
||||
$tplHook['_commentTag'] = $tplHook['type'] . '.' . $skinGroup . '.' . $tplHook['skinFunction'] . '.' . $tplHook['id'] . '.' . $tplHook['position'];
|
||||
$myHooks[ $skinGroup ][] = $tplHook;
|
||||
@@ -2550,19 +2713,19 @@ class skinFunctions
|
||||
$setId = intval( $setId );
|
||||
|
||||
/* Templates */
|
||||
if ( isset( $which['templates'] ) AND $which['templates'] )
|
||||
if ( !empty( $which['templates'] ) )
|
||||
{
|
||||
$this->DB->delete( 'skin_templates', 'template_set_id=' . $setId );
|
||||
}
|
||||
|
||||
/* CSS */
|
||||
if ( isset( $which['css'] ) AND $which['css'] )
|
||||
if ( !empty( $which['css'] ) )
|
||||
{
|
||||
$this->DB->delete( 'skin_css', 'css_set_id=' . $setId );
|
||||
}
|
||||
|
||||
/* Replacements */
|
||||
if ( isset( $which['replacements'] ) AND $which['replacements'] )
|
||||
if ( !empty( $which['replacements'] ) )
|
||||
{
|
||||
$this->DB->delete( 'skin_replacements', 'replacement_set_id=' . $setId );
|
||||
}
|
||||
@@ -2675,13 +2838,13 @@ class skinFunctions
|
||||
/* What to do? */
|
||||
if ( $type == 'css' )
|
||||
{
|
||||
require_once( IPS_PUBLIC_PATH . 'min/lib/Minify/CSS/Compressor.php' );
|
||||
require_once( IPS_PUBLIC_PATH . 'min/lib/Minify/CSS/Compressor.php' );/*noLibHook*/
|
||||
|
||||
$text = Minify_CSS_Compressor::process( $text );
|
||||
}
|
||||
else if ( $type == 'html' )
|
||||
{
|
||||
require_once( IPS_PUBLIC_PATH . 'min/lib/Minify/HTML.php' );
|
||||
require_once( IPS_PUBLIC_PATH . 'min/lib/Minify/HTML.php' );/*noLibHook*/
|
||||
|
||||
$text = Minify_HTML::minify( $text, array( 'xhtml' => 1 ) );
|
||||
}
|
||||
@@ -2753,12 +2916,68 @@ class skinFunctions
|
||||
$templates = $this->fetchTemplates( 0, 'groupTemplatesNoContent', $_group );
|
||||
|
||||
/* Clean out any template bits no longer part of this group */
|
||||
$this->DB->delete( 'skin_templates', "template_group='" . $_group . "' AND " . $this->DB->buildLower('template_name') . " NOT IN ('" . implode( "','", array_keys( $templates ) ) . "')" );
|
||||
$this->DB->delete( 'skin_templates', "template_group='" . $_group . "' AND template_user_added=0 AND " . $this->DB->buildLower('template_name') . " NOT IN ('" . implode( "','", array_keys( $templates ) ) . "')" );
|
||||
|
||||
$affected += intval( $this->DB->getAffectedRows() );
|
||||
}
|
||||
|
||||
return array( 'cached' => intval( $cached ), 'templates' => intval( $affected ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Rebuilds the mobile user agents from the skin set data
|
||||
*/
|
||||
public function rebuildMobileSkinUserAgentsFromSetDataXml()
|
||||
{
|
||||
/* Init */
|
||||
$mobileSkinSet = $this->fetchSkinData( $this->fetchSetIdByKey( 'mobile', true ), true );
|
||||
$xmlData = array();
|
||||
|
||||
/* Grab xml */
|
||||
require_once( IPS_KERNEL_PATH . 'classXML.php' );/*noLibHook*/
|
||||
$xml = new classXML( 'UTF-8' );
|
||||
|
||||
/* Skin Set Data */
|
||||
$xml->load( IPS_ROOT_PATH . 'setup/xml/skins/setsData.xml' );
|
||||
|
||||
foreach( $xml->fetchElements( 'set' ) as $xmlelement )
|
||||
{
|
||||
$data = $xml->fetchElementsFromRecord( $xmlelement );
|
||||
|
||||
if ( $data['set_key'] == 'mobile' )
|
||||
{
|
||||
$xmlData = $data;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Update */
|
||||
if ( $xmlData['set_key'] && IPSLib::isSerialized( $xmlData['set_locked_uagent'] ) && IPSLib::isSerialized( $mobileSkinSet['set_locked_uagent'] ) )
|
||||
{
|
||||
$new = unserialize( $xmlData['set_locked_uagent'] );
|
||||
$old = unserialize( $mobileSkinSet['set_locked_uagent'] );
|
||||
|
||||
/* Merge them */
|
||||
foreach( $new['groups'] as $group )
|
||||
{
|
||||
if ( ! in_array( $group, $old['groups'] ) )
|
||||
{
|
||||
$old['groups'][] = $group;
|
||||
}
|
||||
}
|
||||
|
||||
foreach( $new['uagents'] as $agent => $version )
|
||||
{
|
||||
if ( ! in_array( $agent, $new['uagents'] ) )
|
||||
{
|
||||
$old['uagents'][ $agent ] = $version;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( is_array( $old ) && count( $old ) )
|
||||
{
|
||||
$this->DB->update( 'skin_collections', array( 'set_locked_uagent' => serialize( $old ) ), "set_key='mobile'" );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,312 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* Invision Power Services
|
||||
* IP.Board v3.2.3
|
||||
* Skin Functions
|
||||
* Last Updated: $Date: 2011-05-05 12:03:47 +0100 (Thu, 05 May 2011) $
|
||||
* </pre>
|
||||
*
|
||||
* Owner: Matt
|
||||
* @author $Author: ips_terabyte $
|
||||
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
|
||||
* @license This is NULLED!
|
||||
* @package IP.Board
|
||||
* @link http://hatynka.in
|
||||
* @since 9th March 2005 11:03
|
||||
* @version $Revision: 8644 $
|
||||
*
|
||||
*/
|
||||
|
||||
if ( ! defined( 'IN_IPB' ) )
|
||||
{
|
||||
print "<h1>Incorrect access</h1>You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
|
||||
exit();
|
||||
}
|
||||
|
||||
class skinGenerator extends skinCaching
|
||||
{
|
||||
/**#@+
|
||||
* Registry objects
|
||||
*
|
||||
* @access protected
|
||||
* @var object
|
||||
*/
|
||||
protected $registry;
|
||||
protected $DB;
|
||||
protected $settings;
|
||||
protected $request;
|
||||
protected $lang;
|
||||
protected $member;
|
||||
protected $memberData;
|
||||
protected $cache;
|
||||
protected $caches;
|
||||
/**#@-*/
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @access public
|
||||
* @param object Registry object
|
||||
* @return @e void
|
||||
*/
|
||||
public function __construct( ipsRegistry $registry )
|
||||
{
|
||||
/* Make object */
|
||||
parent::__construct( $registry );
|
||||
}
|
||||
|
||||
/**
|
||||
* Return JSON payload URL
|
||||
* @return string Skin Generator URL
|
||||
*/
|
||||
public function getJsonUrl()
|
||||
{
|
||||
$inDev = ( IN_DEV ) ? 1 : 0;
|
||||
|
||||
return 'http://myipb.in/skingen.json.php?v=' . IPB_LONG_VERSION . '&k=' . urlencode( $this->settings['ipb_reg_number'] ) . '&i=' . $inDev;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a user's session
|
||||
* @param int $skinSetId
|
||||
*/
|
||||
public function convertToFull( $skinSetId )
|
||||
{
|
||||
/* Current session? */
|
||||
$session = $this->getSessionBySkinId( $skinSetId );
|
||||
|
||||
if ( $session['sg_member_id'] )
|
||||
{
|
||||
$this->deleteUserSession( $session['sg_member_id'] );
|
||||
}
|
||||
|
||||
/* Tweak skin */
|
||||
$this->DB->update( 'skin_collections', array( 'set_by_skin_gen' => 0 ), 'set_id=' . $skinSetId );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check to make sure we're GTG ...
|
||||
*/
|
||||
public function healthCheck()
|
||||
{
|
||||
$warnings = array();
|
||||
|
||||
/* Can write into images */
|
||||
if ( ! is_writable( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_images' ) )
|
||||
{
|
||||
$warnings[] = 'Cannot write to image directory';
|
||||
}
|
||||
|
||||
return ( count( $warnings ) ) ? $warnings : true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches the JSON from the remote server and writes it
|
||||
*/
|
||||
public function buildLocalJsonCache()
|
||||
{
|
||||
/* Now fetch JSON data from the server and write it */
|
||||
require_once( IPS_KERNEL_PATH . 'classFileManagement.php' );/*noLibHook*/
|
||||
$files = new classFileManagement();
|
||||
|
||||
$json = $files->getFileContents( $this->getJsonUrl() );
|
||||
|
||||
if ( $json )
|
||||
{
|
||||
$cacheFile = IPS_CACHE_PATH . 'cache/skinGenJsonCache.js';
|
||||
|
||||
if ( file_exists( $cacheFile ) )
|
||||
{
|
||||
@unlink( $cacheFile );
|
||||
}
|
||||
|
||||
file_put_contents( $cacheFile, $json );
|
||||
@chmod( $cacheFile, 0777 );
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception( "JSON_NOT_RETURNED");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the skin and that
|
||||
* @param array css, storedSettings, storedClasses
|
||||
* @param int Member Id
|
||||
*/
|
||||
public function save( array $data, $memberId )
|
||||
{
|
||||
$session = $this->getUserSession( $memberId );
|
||||
|
||||
if ( empty( $session['sg_session_id'] ) )
|
||||
{
|
||||
throw new Exception( 'NO_SESSION_FOUND' );
|
||||
}
|
||||
|
||||
/* Update session */
|
||||
$this->DB->update( 'skin_collections', array( 'set_skin_gen_data' => serialize( $data ) ), 'set_id=\'' . $session['sg_skin_set_id'] . '\'' );
|
||||
|
||||
/* Write CSS_EXISTS extras css */
|
||||
try
|
||||
{
|
||||
$this->saveCSSFromAdd( $session['sg_skin_set_id'], trim( $data['css'] ), 'ipb_skingen', 999, '', 'core' );
|
||||
}
|
||||
catch( Exception $e )
|
||||
{
|
||||
if ( $e->getMessage() == 'CSS_EXISTS' )
|
||||
{
|
||||
$css = $this->fetchCSS( $session['sg_skin_set_id'] );
|
||||
$this->saveCSSFromEdit( $css['ipb_skingen']['css_id'], $session['sg_skin_set_id'], trim( $data['css'] ), 'ipb_skingen', 999, '', 'core' );
|
||||
}
|
||||
}
|
||||
|
||||
/* Update replacements */
|
||||
$replacements = $this->fetchReplacements( $session['sg_skin_set_id'] );
|
||||
|
||||
/* Set transparent logo */
|
||||
$this->saveReplacementFromEdit( $replacements['logo_img']['replacement_id'], $session['sg_skin_set_id'], '{style_image_url}/logo_transparent.png', 'logo_img' );
|
||||
|
||||
/* Flag for rebuild */
|
||||
$this->flagSetForRecache( $session['sg_skin_set_id'] );
|
||||
|
||||
/* Delete session */
|
||||
$this->deleteUserSession( $memberId );
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the member's skin
|
||||
* @param int Member Id
|
||||
*/
|
||||
public function resetMemberAndSwitchSkin( $memberId )
|
||||
{
|
||||
$session = $this->getUserSession( $memberId );
|
||||
|
||||
if ( empty( $session['sg_session_id'] ) )
|
||||
{
|
||||
throw new Exception( 'NO_SESSION_FOUND' );
|
||||
}
|
||||
|
||||
IPSMember::save( $memberId, array( 'core' => array( 'bw_using_skin_gen' => 0, 'skin' => $session['sg_skin_set_id'] ) ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a user's session
|
||||
* @param int $memberId
|
||||
* @param array
|
||||
*/
|
||||
public function setUserSession( $memberId, $data )
|
||||
{
|
||||
if ( ! empty( $memberId ) AND ! empty( $data['skin_set_id'] ) )
|
||||
{
|
||||
$sessionKey = md5( uniqid() );
|
||||
|
||||
$this->deleteUserSession( $memberId );
|
||||
|
||||
if ( empty( $data['set_skin_gen_data'] ) )
|
||||
{
|
||||
$skin = $this->fetchSkinData( $data['skin_set_id'] );
|
||||
|
||||
$data['set_skin_gen_data'] = $skin['set_skin_gen_data'];
|
||||
}
|
||||
|
||||
$this->DB->insert( 'skin_generator_sessions', array( 'sg_session_id' => $sessionKey,
|
||||
'sg_member_id' => $memberId,
|
||||
'sg_skin_set_id' => $data['skin_set_id'],
|
||||
'sg_date_start' => IPS_UNIX_TIME_NOW,
|
||||
'sg_data' => ( is_array( $data ) ) ? serialize( $data ) : $data ) );
|
||||
|
||||
/* Flag user */
|
||||
IPSMember::save( $memberId, array( 'core' => array( 'bw_using_skin_gen' => 1 ) ) );
|
||||
|
||||
return $sessionKey;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a user's session
|
||||
* @param int $memberId
|
||||
* @param null
|
||||
*/
|
||||
public function deleteUserSession( $memberId )
|
||||
{
|
||||
$this->DB->delete( 'skin_generator_sessions', 'sg_member_id=' . intval( $memberId ) );
|
||||
|
||||
/* Flag user */
|
||||
IPSMember::save( $memberId, array( 'core' => array( 'bw_using_skin_gen' => 0 ) ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a user's session
|
||||
* @param int $memberId
|
||||
*/
|
||||
public function getUserSession( $memberId )
|
||||
{
|
||||
$session = $this->DB->buildAndFetch( array( 'select' => '*',
|
||||
'from' => 'skin_generator_sessions',
|
||||
'where' => 'sg_member_id=' . intval( $memberId ) ) );
|
||||
|
||||
if ( ! empty( $session['sg_session_id'] ) )
|
||||
{
|
||||
if ( IPSLib::isSerialized( $session['sg_data'] ) )
|
||||
{
|
||||
$session['sg_data_array'] = unserialize( $session['sg_data'] );
|
||||
|
||||
if ( IPSLib::isSerialized( $session['sg_data_array']['set_skin_gen_data'] ) )
|
||||
{
|
||||
$session['skin_gen_data'] = unserialize( $session['sg_data_array']['set_skin_gen_data'] );
|
||||
}
|
||||
}
|
||||
|
||||
return $session;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Prevent this from loading again */
|
||||
IPSMember::save( $memberId, array( 'core' => array( 'bw_using_skin_gen' => 0 ) ) );
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a user's session
|
||||
* @param int $skinSetId
|
||||
*/
|
||||
public function getSessionBySkinId( $skinSetId )
|
||||
{
|
||||
$session = $this->DB->buildAndFetch( array( 'select' => '*',
|
||||
'from' => 'skin_generator_sessions',
|
||||
'where' => 'sg_skin_set_id=' . intval( $skinSetId ) ) );
|
||||
|
||||
if ( ! empty( $session['sg_session_id'] ) )
|
||||
{
|
||||
if ( IPSLib::isSerialized( $session['sg_data'] ) )
|
||||
{
|
||||
$session['sg_data_array'] = unserialize( $session['sg_data'] );
|
||||
|
||||
if ( IPSLib::isSerialized( $session['sg_data_array']['set_skin_gen_data'] ) )
|
||||
{
|
||||
$session['skin_gen_data'] = unserialize( $session['sg_data_array']['set_skin_gen_data'] );
|
||||
}
|
||||
}
|
||||
|
||||
return $session;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -3,19 +3,19 @@
|
||||
/**
|
||||
* <pre>
|
||||
* Invision Power Services
|
||||
* IP.Board v3.1.4
|
||||
* IP.Board v3.2.3
|
||||
* Skin Functions
|
||||
* Last Updated: $Date: 2010-09-13 05:53:37 -0400 (Mon, 13 Sep 2010) $
|
||||
* Last Updated: $Date: 2011-05-05 07:03:47 -0400 (Thu, 05 May 2011) $
|
||||
* </pre>
|
||||
*
|
||||
* Owner: Matt
|
||||
* @author $Author: terabyte $
|
||||
* @author $Author: ips_terabyte $
|
||||
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/community/board/license.html
|
||||
* @license This is NULLED!
|
||||
* @package IP.Board
|
||||
* @link http://www.invisionpower.com
|
||||
* @link http://hatynka.in
|
||||
* @since 9th March 2005 11:03
|
||||
* @version $Revision: 6854 $
|
||||
* @version $Revision: 8644 $
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -39,7 +39,9 @@ class skinImportExport extends skinCaching
|
||||
protected $request;
|
||||
protected $lang;
|
||||
protected $member;
|
||||
protected $memberData;
|
||||
protected $cache;
|
||||
protected $caches;
|
||||
/**#@-*/
|
||||
|
||||
/**
|
||||
@@ -47,7 +49,7 @@ class skinImportExport extends skinCaching
|
||||
*
|
||||
* @access public
|
||||
* @param object Registry object
|
||||
* @return void
|
||||
* @return @e void
|
||||
*/
|
||||
public function __construct( ipsRegistry $registry )
|
||||
{
|
||||
@@ -164,7 +166,7 @@ class skinImportExport extends skinCaching
|
||||
// Grab the XMLArchive class
|
||||
//-----------------------------------------
|
||||
|
||||
require_once( IPS_KERNEL_PATH . 'classXMLArchive.php' );
|
||||
require_once( IPS_KERNEL_PATH . 'classXMLArchive.php' );/*noLibHook*/
|
||||
$xmlArchive = new classXMLArchive();
|
||||
|
||||
$xmlArchive->readXML( $content );
|
||||
@@ -296,7 +298,7 @@ class skinImportExport extends skinCaching
|
||||
// Grab the XMLArchive class
|
||||
//-----------------------------------------
|
||||
|
||||
require_once( IPS_KERNEL_PATH . 'classXMLArchive.php' );
|
||||
require_once( IPS_KERNEL_PATH . 'classXMLArchive.php' );/*noLibHook*/
|
||||
$xmlArchive = new classXMLArchive();
|
||||
|
||||
$xmlArchive->readXML( $content );
|
||||
@@ -409,14 +411,14 @@ class skinImportExport extends skinCaching
|
||||
'set_author_url' => $info['set_author_url'],
|
||||
'set_image_dir' => ( $imageDir ) ? $imageDir : $defaultSkin['set_image_dir'],
|
||||
'set_emo_dir' => $defaultSkin['set_emo_dir'],
|
||||
'set_css_inline' => 0,
|
||||
'set_css_inline' => 1,
|
||||
'set_output_format' => $info['set_output_format'],
|
||||
'set_css_groups' => '',
|
||||
'set_hide_from_list' => 1, // Per Rikki :P
|
||||
'set_order' => intval( $this->fetchHighestSetPosition() ) + 1,
|
||||
'set_master_key' => ( isset( $info['set_master_key'] ) ) ? $info['set_master_key'] : 'root',
|
||||
'set_updated' => time() );
|
||||
|
||||
|
||||
if ( $setID )
|
||||
{
|
||||
//-----------------------------------------
|
||||
@@ -669,7 +671,7 @@ class skinImportExport extends skinCaching
|
||||
// XML
|
||||
//-----------------------------------------
|
||||
|
||||
require_once( IPS_KERNEL_PATH.'classXML.php' );
|
||||
require_once( IPS_KERNEL_PATH.'classXML.php' );/*noLibHook*/
|
||||
$xml = new classXML( IPS_DOC_CHAR_SET );
|
||||
$return = array();
|
||||
|
||||
@@ -710,7 +712,7 @@ class skinImportExport extends skinCaching
|
||||
// XML
|
||||
//-----------------------------------------
|
||||
|
||||
require_once( IPS_KERNEL_PATH.'classXML.php' );
|
||||
require_once( IPS_KERNEL_PATH.'classXML.php' );/*noLibHook*/
|
||||
$xml = new classXML( IPS_DOC_CHAR_SET );
|
||||
$return = array();
|
||||
|
||||
@@ -751,7 +753,7 @@ class skinImportExport extends skinCaching
|
||||
// XML
|
||||
//-----------------------------------------
|
||||
|
||||
require_once( IPS_KERNEL_PATH.'classXML.php' );
|
||||
require_once( IPS_KERNEL_PATH.'classXML.php' );/*noLibHook*/
|
||||
$xml = new classXML( IPS_DOC_CHAR_SET );
|
||||
$return = array();
|
||||
|
||||
@@ -787,7 +789,7 @@ class skinImportExport extends skinCaching
|
||||
// XML
|
||||
//-----------------------------------------
|
||||
|
||||
require_once( IPS_KERNEL_PATH.'classXML.php' );
|
||||
require_once( IPS_KERNEL_PATH.'classXML.php' );/*noLibHook*/
|
||||
$xml = new classXML( IPS_DOC_CHAR_SET );
|
||||
|
||||
//-----------------------------------------
|
||||
@@ -834,7 +836,7 @@ class skinImportExport extends skinCaching
|
||||
// Create new XML archive...
|
||||
//-----------------------------------------
|
||||
|
||||
require_once( IPS_KERNEL_PATH . 'classXMLArchive.php' );
|
||||
require_once( IPS_KERNEL_PATH . 'classXMLArchive.php' );/*noLibHook*/
|
||||
$xmlArchive = new classXMLArchive();
|
||||
$xmlArchive->setStripPath( $this->fetchImageDirectoryPath( $imgDir ) );
|
||||
$xmlArchive->add( $this->fetchImageDirectoryPath( $imgDir ) );
|
||||
@@ -881,7 +883,7 @@ class skinImportExport extends skinCaching
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( isset( $data['app_enabled'] ) AND $data['app_enabled'] )
|
||||
if ( !empty( $data['app_enabled'] ) )
|
||||
{
|
||||
$templates[ $appDir ] = $this->generateTemplateXML( $appDir, $setID, $setOnly );
|
||||
$csss[ $appDir ] = $this->generateCSSXML( $appDir, $setID, $setOnly );
|
||||
@@ -921,7 +923,7 @@ class skinImportExport extends skinCaching
|
||||
// Create new XML archive...
|
||||
//-----------------------------------------
|
||||
|
||||
require_once( IPS_KERNEL_PATH . 'classXMLArchive.php' );
|
||||
require_once( IPS_KERNEL_PATH . 'classXMLArchive.php' );/*noLibHook*/
|
||||
$xmlArchive = new classXMLArchive();
|
||||
|
||||
/* Add in version numbers */
|
||||
@@ -955,7 +957,7 @@ class skinImportExport extends skinCaching
|
||||
* @access public
|
||||
* @param int [Set ID - 0/root if omitted]
|
||||
* @param bool Include root bits in any XML export. Default is true
|
||||
* @return void
|
||||
* @return @e void
|
||||
*/
|
||||
public function exportAllAppTemplates( $setID=0, $setOnly=TRUE )
|
||||
{
|
||||
@@ -1004,7 +1006,7 @@ class skinImportExport extends skinCaching
|
||||
*
|
||||
* @access public
|
||||
* @param int [Set ID - 0/root if omitted]
|
||||
* @return void
|
||||
* @return @e void
|
||||
*/
|
||||
public function exportAllAppCSS( $setID=0 )
|
||||
{
|
||||
@@ -1055,7 +1057,7 @@ class skinImportExport extends skinCaching
|
||||
*
|
||||
* @todo See Matt, this needs fixing!
|
||||
* @access public
|
||||
* @return void
|
||||
* @return @e void
|
||||
*/
|
||||
public function importAllAppTemplates()
|
||||
{
|
||||
@@ -1070,7 +1072,7 @@ class skinImportExport extends skinCaching
|
||||
{
|
||||
$file = IPSLib::getAppDir( $app_dir ) . '/xml/' . $app_dir . '_templates.xml';
|
||||
|
||||
if ( ! file_exists( $file ) )
|
||||
if ( ! is_file( $file ) )
|
||||
{
|
||||
$this->_addMessage( $app_dir . $this->lang->words['importnothingtoimport'] );
|
||||
continue;
|
||||
@@ -1136,7 +1138,7 @@ class skinImportExport extends skinCaching
|
||||
'set_permissions' => '*',
|
||||
'set_is_default' => 1,
|
||||
'set_author_name' => 'Invision Power Services, Inc',
|
||||
'set_author_url' => 'http://www.bestcms.ws',
|
||||
'set_author_url' => 'http://www.invisionpower.com',
|
||||
'set_image_dir' => 'master',
|
||||
'set_emo_dir' => 'default',
|
||||
'set_css_inline' => 1,
|
||||
@@ -1173,7 +1175,7 @@ class skinImportExport extends skinCaching
|
||||
'set_permissions' => '*',
|
||||
'set_is_default' => 1,
|
||||
'set_author_name' => 'Invision Power Services, Inc',
|
||||
'set_author_url' => 'http://www.bestcms.ws',
|
||||
'set_author_url' => 'http://www.invisionpower.com',
|
||||
'set_image_dir' => $remap[ $_id ]['set_image_dir'],
|
||||
'set_emo_dir' => 'default',
|
||||
'set_css_inline' => 1,
|
||||
@@ -1215,7 +1217,7 @@ class skinImportExport extends skinCaching
|
||||
// Grab the XML parser
|
||||
//-----------------------------------------
|
||||
|
||||
require_once( IPS_KERNEL_PATH.'classXML.php' );
|
||||
require_once( IPS_KERNEL_PATH.'classXML.php' );/*noLibHook*/
|
||||
$xml = new classXML( IPS_DOC_CHAR_SET );
|
||||
|
||||
//-----------------------------------------
|
||||
@@ -1283,7 +1285,7 @@ class skinImportExport extends skinCaching
|
||||
// Grab the XML parser
|
||||
//-----------------------------------------
|
||||
|
||||
require_once( IPS_KERNEL_PATH.'classXML.php' );
|
||||
require_once( IPS_KERNEL_PATH.'classXML.php' );/*noLibHook*/
|
||||
$xml = new classXML( IPS_DOC_CHAR_SET );
|
||||
|
||||
//-----------------------------------------
|
||||
@@ -1374,7 +1376,7 @@ class skinImportExport extends skinCaching
|
||||
// Grab the XML parser
|
||||
//-----------------------------------------
|
||||
|
||||
require_once( IPS_KERNEL_PATH . 'classXML.php' );
|
||||
require_once( IPS_KERNEL_PATH . 'classXML.php' );/*noLibHook*/
|
||||
$xml = new classXML( IPS_DOC_CHAR_SET );
|
||||
|
||||
//-----------------------------------------
|
||||
@@ -1436,13 +1438,13 @@ class skinImportExport extends skinCaching
|
||||
|
||||
$infoXML = IPSLib::getAppDir( $app ) . '/xml/information.xml';
|
||||
|
||||
if ( ! file_exists( $infoXML ) )
|
||||
if ( ! is_file( $infoXML ) )
|
||||
{
|
||||
$this->_addErrorMessage( $this->lang->words['couldnotlocate'] . $infoXML );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
require_once( IPS_KERNEL_PATH.'classXML.php' );
|
||||
require_once( IPS_KERNEL_PATH.'classXML.php' );/*noLibHook*/
|
||||
$xml = new classXML( IPS_DOC_CHAR_SET );
|
||||
|
||||
//-----------------------------------------
|
||||
@@ -1607,7 +1609,7 @@ class skinImportExport extends skinCaching
|
||||
// Grab the XML parser
|
||||
//-----------------------------------------
|
||||
|
||||
require_once( IPS_KERNEL_PATH.'classXML.php' );
|
||||
require_once( IPS_KERNEL_PATH.'classXML.php' );/*noLibHook*/
|
||||
$xml = new classXML( IPS_DOC_CHAR_SET );
|
||||
|
||||
//-----------------------------------------
|
||||
@@ -1653,7 +1655,7 @@ class skinImportExport extends skinCaching
|
||||
// File exists
|
||||
//-----------------------------------------
|
||||
|
||||
if ( ! file_exists( $fileXML ) )
|
||||
if ( ! is_file( $fileXML ) )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
@@ -1728,7 +1730,7 @@ class skinImportExport extends skinCaching
|
||||
* @access public
|
||||
* @param string App to export into
|
||||
* @param int Set ID (0 / root by default )
|
||||
* @return void
|
||||
* @return @e void
|
||||
*/
|
||||
public function exportCSSAppXML( $app_dir, $setID=0 )
|
||||
{
|
||||
@@ -1751,7 +1753,7 @@ class skinImportExport extends skinCaching
|
||||
|
||||
if ( $xml )
|
||||
{
|
||||
if ( file_exists( $file ) AND ! IPSLib::isWritable( $file ) )
|
||||
if ( is_file( $file ) AND ! IPSLib::isWritable( $file ) )
|
||||
{
|
||||
$this->_addErrorMessage( $file . $this->lang->words['css_isnotwritable'] );
|
||||
return FALSE;
|
||||
@@ -1770,7 +1772,7 @@ class skinImportExport extends skinCaching
|
||||
* @param string App to export into
|
||||
* @param int [Set ID (0/root if omitted)]
|
||||
* @param bool Include root bits in any XML export. Default is true
|
||||
* @return void
|
||||
* @return @e void
|
||||
*/
|
||||
public function exportTemplateAppXML( $app_dir, $setID=0, $setOnly=TRUE )
|
||||
{
|
||||
@@ -1793,7 +1795,7 @@ class skinImportExport extends skinCaching
|
||||
|
||||
if ( $xml )
|
||||
{
|
||||
if ( file_exists( $file ) AND ! IPSLib::isWritable( $file ) )
|
||||
if ( is_file( $file ) AND ! IPSLib::isWritable( $file ) )
|
||||
{
|
||||
$this->_addErrorMessage( $file . $this->lang->words['css_isnotwritable'] );
|
||||
return FALSE;
|
||||
@@ -1828,7 +1830,7 @@ class skinImportExport extends skinCaching
|
||||
$return = array( 'updateCount' => 0, 'insertCount' => 0, 'updateBits' => array(), 'insertBits' => array() );
|
||||
$masterKeys = $this->fetchMasterKeys();
|
||||
|
||||
if( ! file_exists($fileXML) )
|
||||
if( ! is_file($fileXML) )
|
||||
{
|
||||
return $return;
|
||||
}
|
||||
@@ -1861,7 +1863,7 @@ class skinImportExport extends skinCaching
|
||||
// XML
|
||||
//-----------------------------------------
|
||||
|
||||
require_once( IPS_KERNEL_PATH.'classXML.php' );
|
||||
require_once( IPS_KERNEL_PATH.'classXML.php' );/*noLibHook*/
|
||||
$xml = new classXML( IPS_DOC_CHAR_SET );
|
||||
|
||||
//-----------------------------------------
|
||||
|
||||
Reference in new issue
Block a user