Version 3.1.4

This commit is contained in:
Neo committed 2025-12-19 00:32:22 -08:00
1 parent 1d4720f3e2
commit ae5c01cc78
2563 files changed
+283048 -240689

No files matched your search

+326 -108
View File
@@ -1,19 +1,21 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.0.5
* IP.Board v3.1.4
* Skin Caching Functions
* Last Updated: $Date: 2009-10-01 10:02:08 -0400 (Thu, 01 Oct 2009) $
* Last Updated: $Date: 2010-10-14 06:42:56 -0400 (Thu, 14 Oct 2010) $
* </pre>
*
* Owner: Matt
* @author $Author: bfarber $
* @author $Author: mmecham $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @package Invision Power Board
* @link http://www.iinvisionpower.com
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @link http://www.invisionpower.com
* @since 9th July 2008
* @version $Revision: 5190 $
* @version $Revision: 6975 $
*
*/
@@ -91,7 +93,14 @@ class skinCaching extends skinFunctions
// Push the current skin set ID onto the beginnging
//-----------------------------------------
array_unshift( $skinSetData['_childTree'], $setID );
if ( is_numeric( $setID ) )
{
array_unshift( $skinSetData['_childTree'], $setID );
}
else
{
array_unshift( $skinSetData['_childTree'], 0 );
}
//-----------------------------------------
// Remove current caches
@@ -105,6 +114,13 @@ class skinCaching extends skinFunctions
foreach( $skinSetData['_childTree'] as $_setID )
{
/* Bit of a fiddle here... */
if ( ! is_numeric( $setID ) AND $_setID == 0 )
{
/* We mean a master set, then */
$_setID = $setID;
}
$__replacements = $this->fetchReplacements( $_setID );
$_replacements = array();
@@ -119,6 +135,8 @@ class skinCaching extends skinFunctions
'cache_set_id' => $_setID,
'cache_type' => 'replacements',
'cache_content' => serialize( $_replacements ) ) );
$this->cache->putWithCacheLib( 'Skin_Store_' . $_setID, array(), 1 );
}
return TRUE;
@@ -140,6 +158,12 @@ class skinCaching extends skinFunctions
$skinSetData = $this->fetchSkinData( $setID );
$skinSetData['set_image_dir'] = ( $skinSetData['set_image_dir'] ) ? $skinSetData['set_image_dir'] : 'master';
/* These are not always set up correctly */
$this->settings['img_url'] = ( $this->settings['img_url'] ) ? $this->settings['img_url'] : $this->settings['_original_base_url'] . '/' . PUBLIC_DIRECTORY . '/style_images/' . $skinSetData['set_image_dir'];
$this->settings['img_url_no_dir'] = ( $this->settings['img_url_no_dir'] ) ? $this->settings['img_url_no_dir'] : $this->settings['_original_base_url'] . '/' . PUBLIC_DIRECTORY . '/style_images/';
/* Remove dead template caches */
$this->removeDeadPHPCaches( $setID );
@@ -165,8 +189,15 @@ class skinCaching extends skinFunctions
$groupTitles = $this->fetchTemplates( $_setID, 'groupNames' );
$allHooks = $this->fetchSkinHooks();
/* Update DB row */
$this->DB->update( 'skin_collections', array( 'set_updated' => time() ), 'set_id=' . intval( $_setID ) );
foreach ( $groupTitles as $name => $group )
{
/* Separated $out into two variables, needed to build the sections independently to fix bug #21574 */
$fileHead = '';
$fileBody = '';
//-----------------------------------------
// Skip if we're only updating one group..
//-----------------------------------------
@@ -179,8 +210,8 @@ class skinCaching extends skinFunctions
}
}
$out = "class {$group['template_group']}_{$_setID} {\n\n";
$out .= <<<EOF
$fileHead = "class {$group['template_group']}_{$_setID} {\n\n";
$fileHead .= <<<EOF
/**
* Construct
*/
@@ -196,21 +227,37 @@ function __construct( ipsRegistry \$registry )
\$this->memberData =& \$this->registry->member()->fetchMemberData();
\$this->cache = \$this->registry->cache();
\$this->caches =& \$this->registry->cache()->fetchCaches();
}
EOF;
$templates = $this->fetchTemplates( $_setID, 'groupTemplates', $group['template_group'] );
foreach ($templates as $func_name => $data )
{
$this->registry->templateEngine->setWorkingGroup( $group['template_group'] );
$out .= $this->registry->templateEngine->convertHtmlToPhp( $data['template_name'], $data['template_data'], $data['template_content'] ) ."\n";
$fileBody .= $this->registry->templateEngine->convertHtmlToPhp( $data['template_name'], $data['template_data'], $data['template_content'] ) ."\n";
}
$out .= "\n\n}";
//-----------------------------------------
// Function Hooks
//------------------------------------------
$funcHooks = '$this->_funcHooks = array();' . "\n";
if( is_array( $this->registry->templateEngine->_hookIds[ $group['template_group'] ] ) )
{
foreach( $this->registry->templateEngine->_hookIds[ $group['template_group'] ] as $func_name => $hookIds )
{
if( is_array( $hookIds ) && count( $hookIds ) )
{
$funcHooks .= "\$this->_funcHooks['{$func_name}'] = array(".implode( ',', $hookIds ).");\n";
}
}
}
$fileHead .= "\n\n{$funcHooks}\n\n}\n\n";
$out = $fileHead . $fileBody . "\n}\n";
/* This would be better off within the templateEngine really cos $out now contains the entire class */
$out = $this->stripUnneededHooks( $out, $allHooks[ $group['template_group'] ] );
@@ -226,6 +273,7 @@ EOF;
'cache_key_1' => 'group',
'cache_value_1' => $group['template_group'],
'cache_content' => $out ) );
//-----------------------------------------
// Write to the flatfile
@@ -235,7 +283,7 @@ EOF;
$start .= "/*--------------------------------------------------*/\n";
$start .= "/* FILE GENERATED BY INVISION POWER BOARD 3 */\n";
$start .= "/* CACHE FILE: Skin set id: {$_setID} */\n";
$start .= "/* CACHE FILE: Generated: ".gmdate( "D, d M Y H:i:s \G\M\T" )." */\n";
$start .= "/* CACHE FILE: Generated: ".gmdate( 'D, d M Y H:i:s \G\M\T' )." */\n";
$start .= "/* DO NOT EDIT DIRECTLY - THE CHANGES WILL NOT BE */\n";
$start .= "/* WRITTEN TO THE DATABASE AUTOMATICALLY */\n";
$start .= "/*--------------------------------------------------*/\n\n";
@@ -249,11 +297,16 @@ EOF;
{
$this->_writePHPTemplate( $_setID, $group['template_group'], $start.$out.$end );
}
$this->cache->putWithCacheLib( 'Skin_Store_' . $_setID, array(), 1 );
}
$this->_addMessage( "HTML шаблоны обновлены... (Стиль: $_setID)" );
$this->_addMessage( sprintf( $this->lang->words['finishedcachinghtml'], $_setID ) );
}
/* Rebuild skin cache */
$this->rebuildSkinSetsCache();
return TRUE;
}
@@ -273,7 +326,7 @@ EOF;
$phpKeep = array();
$phpThrow = array();
$phpUnlink = array();
//-----------------------------------------
// Get skin set data
//-----------------------------------------
@@ -310,8 +363,7 @@ EOF;
$this->DB->build( array( 'select' => '*',
'from' => 'skin_cache',
'where' => 'cache_type=\'phptemplate\'',
'order' => 'cache_set_id ASC' ) );
'where' => "cache_type='phptemplate' AND cache_set_id IN (" . implode( ",", $tree ) . ")" ) );
$this->DB->execute();
@@ -338,7 +390,7 @@ EOF;
foreach( $phpKeep as $_setID => $data )
{
$_path = IPS_CACHE_PATH.'cache/skin_cache/cacheid_' . $_setID;
$_path = IPS_CACHE_PATH . 'cache/skin_cache/cacheid_' . $_setID;
if ( is_dir( $_path ) )
{
@@ -433,8 +485,7 @@ EOF;
$this->DB->build( array( 'select' => '*',
'from' => 'skin_cache',
'where' => 'cache_type=\'css\'',
'order' => 'cache_set_id ASC' ) );
'where' => "cache_type='css' AND cache_set_id IN (" . implode( ",", $tree ) . ")" ) );
$this->DB->execute();
@@ -486,6 +537,8 @@ EOF;
}
} catch ( Exception $e ) {}
}
$this->cache->putWithCacheLib( 'Skin_Store_' . $_setID, array(), 1 );
}
//-----------------------------------------
@@ -546,7 +599,10 @@ EOF;
// Push the current skin set ID onto the beginnging
//-----------------------------------------
array_unshift( $skinSetData['_childTree'], $setID );
if ( is_numeric( $setID ) )
{
array_unshift( $skinSetData['_childTree'], $setID );
}
//-----------------------------------------
// Fetch CSS that needs to be rebuilt
@@ -639,7 +695,10 @@ EOF;
// Push the current skin set ID onto the beginnging
//-----------------------------------------
array_unshift( $skinSetData['_childTree'], $setID );
if ( is_numeric( $setID ) )
{
array_unshift( $skinSetData['_childTree'], $setID );
}
//-----------------------------------------
// Fetch CSS that needs to be rebuilt
@@ -655,7 +714,8 @@ EOF;
foreach( array_keys( $needToRebuild ) as $_setID )
{
$_css = $this->fetchCSS( $_setID );
$_css = $this->fetchCSS( $_setID );
$_skinSetData = $this->fetchSkinData( $_setID );
foreach( $_css as $name => $css )
{
@@ -685,8 +745,12 @@ EOF;
'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 ) ) );
'cache_content' => $this->_CSS_fromDBtoFile( $css['css_content'], $_skinSetData )
//'cache_content' => $css['css_content']
) ) ;
}
$this->cache->putWithCacheLib( 'Skin_Store_' . $_setID, array(), 1 );
}
//-----------------------------------------
@@ -725,6 +789,8 @@ EOF;
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 );
}
}
@@ -740,13 +806,18 @@ EOF;
* @access public
* @return bool
*/
public function rebuildMasterReplacements()
public function rebuildMasterReplacements( $setId=0 )
{
/* Set directory */
$setId = is_numeric( $setId ) ? intval( $setId ) : trim( $setId );
$dir = IPS_CACHE_PATH . 'cache/skin_cache/' . $this->remapData['templates'][ $setId ];
$messages = array();
//-----------------------------------------
// Master file exists?
//-----------------------------------------
if ( ! file_exists( IPS_CACHE_PATH . 'cache/skin_cache/master_skin/_replacements.inc' ) )
if ( ! file_exists( $dir . '/_replacements.inc' ) )
{
return FALSE;
}
@@ -755,15 +826,19 @@ EOF;
// Remove current CSS
//-----------------------------------------
$this->DB->delete( 'skin_replacements', "replacement_set_id=0" );
if ( ! is_numeric( $setId ) )
{
$this->DB->delete( 'skin_replacements', "replacement_master_key='" . $setId . "'" );
}
//-----------------------------------------
// Grab file
//-----------------------------------------
require( IPS_CACHE_PATH . 'cache/skin_cache/master_skin/_replacements.inc' );
$replacements = array();
require( $dir . '/_replacements.inc' );
if ( ! count( $replacements ) )
if ( !is_array($replacements) || !count($replacements) )
{
return FALSE;
}
@@ -771,13 +846,18 @@ EOF;
/* Insert... */
foreach( $replacements as $k => $v )
{
$this->DB->insert( 'skin_replacements', array( 'replacement_key' => $k,
'replacement_content' => $v,
'replacement_set_id' => 0,
'replacement_added_to' => 0 ) );
$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_added_to' => 0 ) );
}
return TRUE;
$this->cache->putWithCacheLib( 'Skin_Store_' . $setId, array(), 1 );
return $messages;
}
/**
@@ -793,6 +873,7 @@ EOF;
public function rebuildMasterCSS( $setId=0 )
{
/* Set directory */
$setId = is_numeric( $setId ) ? intval( $setId ) : trim( $setId );
$cssDir = DOC_IPS_ROOT_PATH . 'public/style_css/' . $this->remapData['css'][ $setId ];
$messages = array();
$css = array();
@@ -813,18 +894,22 @@ EOF;
throw new Exception( "CANNOT_READ" );
}
/* Fetch all CSS bits. NOW */
if ( $setId > 0 )
/* Remove current CSS... */
if ( is_numeric( $setId ) )
{
$this->DB->delete( 'skin_css', 'css_set_id=' . $setId );
}
else
{
$this->DB->delete( 'skin_css', 'css_master_key=\'' . $setId . '\'' );
}
/* Fetch all template bits. NOW */
if ( is_numeric( $setId ) AND $setId > 0 )
{
$css = $this->fetchCSS( $setId );
}
//-----------------------------------------
// Remove current CSS
//-----------------------------------------
$this->DB->delete( 'skin_css', "css_set_id=" . $setId );
//-----------------------------------------
// Recurse over the directory
//-----------------------------------------
@@ -845,8 +930,8 @@ EOF;
/* Encode */
$cssContent = IPSText::encodeForXml( $cssContent );
$messages[] = "Imported " . $cssName;
$messages[] = $this->lang->words['basicimportedpre'] . $cssName;
$cssData = $this->_CSS_fetchImportBlock( $cssContent );
$cssContent = $this->_CSS_fromFileToDB( $cssContent );
@@ -858,13 +943,14 @@ EOF;
}
$this->DB->insert( 'skin_css', array( 'css_updated' => time(),
'css_set_id' => $setId,
'css_added_to' => $_css_added_to,
'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 ) );
}
@@ -873,10 +959,12 @@ EOF;
} catch ( Exception $e ) {}
/* Recache */
if ( $setId )
if ( is_numeric( $setId ) AND $setId )
{
$this->rebuildCSS( $setId );
$this->removeDeadCSSCaches( $setId );
$this->cache->putWithCacheLib( 'Skin_Store_' . $setId, array(), 1 );
}
return $messages;
@@ -901,7 +989,7 @@ EOF;
// INIT
//-----------------------------------------
$setId = intval( $setId );
$setId = is_numeric( $setId ) ? intval( $setId ) : trim( $setId );
$script_token = 0;
$script_jump = 0;
$skin_dir = IPS_CACHE_PATH . "cache/skin_cache/" . $this->remapData['templates'][ $setId ];
@@ -926,10 +1014,17 @@ EOF;
}
/* Remove current templates... */
$this->DB->delete( 'skin_templates', 'template_set_id=' . $setId );
if ( is_numeric( $setId ) )
{
$this->DB->delete( 'skin_templates', 'template_set_id=' . $setId );
}
else
{
$this->DB->delete( 'skin_templates', 'template_master_key=\'' . $setId . '\'' );
}
/* Fetch all template bits. NOW */
if ( $setId > 0 )
if ( is_numeric( $setId ) AND $setId > 0 )
{
$templates = $this->fetchTemplates( $setId, 'allTemplates' );
}
@@ -937,7 +1032,7 @@ EOF;
/* Loop through the directory */
try
{
foreach( new DirectoryIterator( $skin_dir ) as $file )
foreach( new DirectoryIterator( $skin_dir ) as $file )
{
if ( ! $file->isDot() AND ! $file->isDir() )
{
@@ -950,7 +1045,7 @@ EOF;
if ( ! $fdata )
{
$messages[] = "Не удалось открыть файл $_name, пропускаем...";
$messages[] = sprintf( $this->lang->words['couldnotopenfile'], $_name );
continue;
}
@@ -959,7 +1054,7 @@ EOF;
if ( ! preg_match( "/\n/", $fdata ) )
{
$messages[] = "Не удалось найти содержимое в файле $_name, пропускаем...";
$messages[] = sprintf( $this->lang->words['couldnotfindlineeol'], $_name );
continue;
}
@@ -992,7 +1087,7 @@ EOF;
if ( $script_token AND $script_jump == 0 )
{
if ( preg_match( "#<if test=[\'\"]#", $f ) )
if ( preg_match( '#<if test=[\'\"]#', $f ) )
{
$script_jump = 1;
$script_token = 0;
@@ -1014,7 +1109,7 @@ EOF;
if ( ! $script_token )
{
if ( preg_match( "/^function\s*([\w\_]+)\s*\((.*)\)/i", $f, $matches ) )
if ( preg_match( '/^function\s*([\w\_]+)\s*\((.*)\)/i', $f, $matches ) )
{
$functions[ $matches[1] ] = '';
$config[ $matches[1] ] = $matches[2];
@@ -1028,9 +1123,9 @@ EOF;
else
{
# Make JS safe (UBE - Ugly, but effective)
$f = preg_replace( "#if\s+?\(#is" , "i~f~(~" , $f );
$f = str_ireplace( "else" , "e~lse~" , $f );
$f = preg_replace( "#else\s+?if#is", "e~lse~i~f", $f );
$f = preg_replace( '#if\s+?\(#is' , "i~f~(~" , $f );
$f = str_ireplace( 'else' , "e~lse~" , $f );
$f = preg_replace( '#else\s+?if#is', "e~lse~i~f", $f );
}
if ( $flag )
@@ -1061,14 +1156,15 @@ EOF;
$content = IPSText::encodeForXml( $content );
/* Build array */
$array = array( 'template_set_id' => $setId,
'template_group' => $name,
'template_content' => $content,
'template_name' => $fname,
'template_data' => trim($config[$fname]),
'template_updated' => time(),
'template_removable' => ( $setId ) ? 1 : 0,
'template_added_to' => $setId );
$array = array( 'template_set_id' => $setId,
'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 ) );
if ( ! $setId OR ! $templates[ $name ][ strtolower( $fname ) ] )
{
@@ -1090,25 +1186,51 @@ EOF;
}
}
$messages[] = "$name добавлен (Шаблонов добавлено " . $added . "; обновлено " . $updated . ")";
$messages[] = sprintf( $this->lang->words['tplbitimported'], $name, $added, $updated );
$functions = array();
}
}
}
} catch ( Exception $e ) {}
/* Recache */
if ( $setId )
if ( is_numeric( $setId ) AND $setId )
{
$this->rebuildPHPTemplates( $setId );
$this->removeDeadPHPCaches( $setId );
$this->cache->putWithCacheLib( 'Skin_Store_' . $setId, array(), 1 );
}
/* Return */
$messages[] = "Завершено обновление шаблонов из PHP кеша.";
$messages[] = $this->lang->words['cpltrebuildfromcaches'];
return $messages;
}
/**
* Flag skin as needing recache
*
* @access public
* @return boolean
*/
public function flagSetForRecache( $setId=null )
{
/* Update DB row */
if ( $setId !== null )
{
$this->DB->update( 'skin_collections', array( 'set_updated' => -1 ), 'set_id=' . intval( $setId ) );
}
else
{
$this->DB->update( 'skin_collections', array( 'set_updated' => -1 ) );
}
/* Build cache */
$this->rebuildSkinSetsCache();
return TRUE;
}
/**
* Rebuild skinsets cache in the cache_store table
*
@@ -1129,7 +1251,7 @@ EOF;
$this->DB->build( array( 'select' => '*',
'from' => 'skin_collections',
'order' => 'set_parent_id, set_id' ) );
'order' => 'set_order' ) );
$this->DB->execute();
while( $row = $this->DB->fetch() )
@@ -1235,7 +1357,7 @@ EOF;
$cssContent = str_replace( array( "\r\n", "\r" ), "\n", $cssContent );
$messages[] = "Импортирован " . $cssName;
$messages[] = $this->lang->words['basicimportedpre'] . $cssName;
$cssData = $this->_CSS_fetchImportBlock( $cssContent );
$cssContent = $this->_CSS_fromFileToDB( $cssContent );
@@ -1280,6 +1402,11 @@ EOF;
throw new Exception( 'IN_DEV_OFF' );
}
if ( ! is_numeric( $id ) )
{
$id = $this->fetchSetIdByKey( $id );
}
$setData = $this->fetchSkinData( $id );
$path = DOC_IPS_ROOT_PATH . 'public/style_css/' . $dir;
@@ -1312,11 +1439,11 @@ EOF;
if ( @file_put_contents( $path . '/' . $data['css_group'] . '.css', $_block . $this->_CSS_fromDBtoFile( $data['css_content'], $setData ) ) )
{
$msgs[] = "Записан: " . $data['css_group'] . '.css';
$msgs[] = $this->lang->words['basicwrittenpre'] . $data['css_group'] . '.css';
}
else
{
$msgs[] = "Ошибка: Не удалось записать " . $data['css_group'] . '.css';
$msgs[] = $this->lang->words['basiccouldnotwrite'] . $data['css_group'] . '.css';
}
}
}
@@ -1324,6 +1451,81 @@ EOF;
return $msgs;
}
/**
* Write out replacements in the master format
* IN_DEV tool, currently.
*
* @access public
* @param int Skin ID to write out
* @param string Directory to write into. Directory must be in /public/style_css/
* @return array Array of messages
* Exception Codes:
* IN_DEV_OFF IN_DEV constant is not enabled
* NO_SUCH_SKIN_SET Skin set of $id does not exist
* DIR_DOES_NOT_EXIST Directory does not exist in /cache/skin_cache
* CANNOT_WRITE_DIR Directory cannot be written into
*/
public function writeMasterSkinReplacements( $id, $dir )
{
/* Checkin' */
if ( ! IN_DEV )
{
throw new Exception( 'IN_DEV_OFF' );
}
if ( ! is_numeric( $id ) )
{
$id = $this->fetchSetIdByKey( $id );
}
$setData = $this->fetchSkinData( $id );
$path = IPS_CACHE_PATH . 'cache/skin_cache/' . $dir;
$msgs = array();
if ( ! isset( $setData['set_id'] ) )
{
throw new Exception( 'NO_SUCH_SKIN_SET' );
}
if ( ! is_dir( $path ) )
{
throw new Exception( 'DIR_DOES_NOT_EXIST' );
}
if ( ! is_writeable( $path ) )
{
throw new Exception( 'CANNOT_WRITE_DIR' );
}
/* Fetch Replacements */
$replacements = $this->fetchReplacements( $id );
/* Write it.. */
if ( is_array( $replacements ) )
{
$content = "<" . "?php\n\n\$replacements = array(\n\n";
foreach( $replacements as $k => $data )
{
$content .= "\n'" . $k . "' => \"" . str_replace( '"', '\\"', $data['replacement_content'] ) . '",';
}
$content .= "\n);\n\n?>";
if ( @file_put_contents( $path . '/_replacements.inc', $content ) )
{
$msgs[] = $this->lang->words['basicwrittenpre'] . $path . '/_replacements.inc';
}
else
{
$msgs[] = $this->lang->words['basiccouldnotwrite'] . $path . '/_replacements.inc';
}
}
return $msgs;
}
/**
* Write out skin templates in the master format
* IN_DEV tool, currently.
@@ -1346,6 +1548,11 @@ EOF;
throw new Exception( 'IN_DEV_OFF' );
}
if ( ! is_numeric( $id ) )
{
$id = $this->fetchSetIdByKey( $id );
}
$setData = $this->fetchSkinData( $id );
$path = IPS_CACHE_PATH . 'cache/skin_cache/' . $dir;
@@ -1386,17 +1593,17 @@ EOF;
if ( ! @file_put_contents( $path . '/' . $_file, $_content ) )
{
$msgs[] = "Ошибка: Не удалось записать: " . $path . '/' . $_file;
$msgs[] = $this->lang->words['basiccouldnotwrite'] . $path . '/' . $_file;
}
else
{
@chmod( $path . '/' . $_file, 0777 );
$msgs[] = "Записан: " . $path . '/' . $_file;
$msgs[] = $this->lang->words['basicwrittenpre'] . $path . '/' . $_file;
}
}
else
{
$msgs[] = "Ошибка: нечего записывать в файл " . $path . '/' . $_file;
$msgs[] = $this->lang->words['basicnothingtowritepre'] . $path . '/' . $_file;
}
}
@@ -1424,6 +1631,11 @@ EOF;
$block[] = "<css_app>" . $data['css_app'] . "</css_app>";
}
if ( isset( $data['css_modules'] ) )
{
$block[] = "<css_modules>" . $data['css_modules'] . "</css_modules>";
}
if ( isset( $data['css_app_hide'] ) )
{
$block[] = "<css_app_hide>" . $data['css_app_hide'] . "</css_app_hide>";
@@ -1526,36 +1738,36 @@ EOF;
{
$good_to_go = 1;
if ( is_writeable( IPS_CACHE_PATH . PUBLIC_DIRECTORY . '/style_css/' ) === TRUE )
if ( is_writeable( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_css/' ) === TRUE )
{
$good_to_go = 1;
if ( ! is_dir( IPS_CACHE_PATH . PUBLIC_DIRECTORY . '/style_css/css_'.$setID ) )
if ( ! is_dir( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_css/css_' . $setID ) )
{
if ( ! @ mkdir( IPS_CACHE_PATH . PUBLIC_DIRECTORY . '/style_css/css_'.$setID, 0777 ) )
if ( ! @ mkdir( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_css/css_' . $setID, 0777 ) )
{
$this->_addErrorMessage( "Ошибка! не удалось создать: public/style_css/css_{$setID}/" );
$this->_addErrorMessage( sprintf( $this->lang->words['couldnotcreatecssdir'], $setID ) );
return $this->_errorMsgs;
}
else
{
@file_put_contents( IPS_CACHE_PATH . PUBLIC_DIRECTORY . '/style_css/css_' . $setID . '/index.html', '' );
@chmod( IPS_CACHE_PATH . PUBLIC_DIRECTORY . '/style_css/css_'.$setID, 0777 );
@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 );
$good_to_go = 1;
}
}
else
{
if ( is_writable( IPS_CACHE_PATH . PUBLIC_DIRECTORY . '/style_css/css_'.$setID ) !== TRUE )
if ( is_writable( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_css/css_' . $setID ) !== TRUE )
{
$this->_addErrorMessage( "public/style_css/css_{$setID}/ not writeable" );
$this->_addErrorMessage( sprintf( $this->lang->words['cssdirnotwritaaaable'], $setID ) );
$good_to_go = 0;
}
else if ( file_exists( IPS_CACHE_PATH . PUBLIC_DIRECTORY . '/style_css/css_'.$setID.'/'.$css_group.'.css' ) )
else if ( file_exists( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_css/css_'.$setID.'/'.$css_group.'.css' ) )
{
if ( is_writable( IPS_CACHE_PATH . PUBLIC_DIRECTORY . '/style_css/css_'.$setID.'/'.$css_group.'.css' ) !== TRUE )
if ( is_writable( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_css/css_'.$setID.'/'.$css_group.'.css' ) !== TRUE )
{
$this->_addErrorMessage( "public/style_css/css_{$setID}/{$css_group}.css нет прав на запись" );
$this->_addErrorMessage( sprintf( $this->lang->words['cssfilenotwriteable'], $setID, $css_group ) );
$good_to_go = 0;
}
else
@@ -1571,13 +1783,13 @@ EOF;
}
else
{
$this->_addErrorMessage( "Ошибка! " . IPS_CACHE_PATH . PUBLIC_DIRECTORY . "/style_css нет прав на запись - измените права записи на директорию или переключите стили в безопасный режим" );
$this->_addErrorMessage( sprintf( $this->lang->words['fatalnotwreite'], DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY ) );
$good_to_go = 0;
}
}
else
{
$this->_addErrorMessage( "Безопасный режим: Пропускаем создание CSS кешей" );
$this->_addErrorMessage( $this->lang->words['safemodeenablednow'] );
$good_to_go = 0;
}
@@ -1587,17 +1799,17 @@ EOF;
if ( $good_to_go )
{
if ( $FH = @fopen( IPS_CACHE_PATH . PUBLIC_DIRECTORY . '/style_css/css_'.$setID.'/'.$css_group.'.css', 'w' ) )
if ( $FH = @fopen( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_css/css_'.$setID.'/'.$css_group.'.css', 'w' ) )
{
fwrite( $FH, $css_content, strlen($css_content) );
fclose( $FH );
@chmod( IPS_CACHE_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', 0777 );
$this->_addMessage( "Записан skin_cache/css_{$setID}/{$css_group}.css" );
$this->_addMessage( $this->lang->words['basicwrittenpre']. "skin_cache/css_{$setID}/{$css_group}.css" );
}
else
{
$this->_addErrorMessage( "style_css/css_{$setID}/{$css_group}.css нет прав на запись" );
$this->_addErrorMessage( sprintf( $this->lang->words['cssfilenotwriteable'], $setID, $css_group ) );
}
}
}
@@ -1632,7 +1844,7 @@ EOF;
{
if ( ! @ mkdir( IPS_CACHE_PATH.'cache/skin_cache/cacheid_'.$setID, 0777 ) )
{
$this->_addErrorMessage( "Ошибка! не удалось создать: cache/skin_cache/cacheid_{$setID}/" );
$this->_addErrorMessage( sprintf( $this->lang->words['fatalnotemplatew'], $setID ) );
return;
}
else
@@ -1648,7 +1860,7 @@ EOF;
{
if ( IPSLib::isWritable( IPS_CACHE_PATH.'cache/skin_cache/cacheid_'.$setID.'/'.$groupName.'.php' ) !== TRUE )
{
$this->_addErrorMessage( "cache/skin_cache/cacheid_{$setID}/{$groupName}.php нет прав на запись" );
$this->_addErrorMessage( sprintf( $this->lang->words['templatefilenowrite'], $setID, $groupName ) );
$good_to_go = 0;
}
else
@@ -1664,7 +1876,7 @@ EOF;
}
else
{
$this->_addErrorMessage( "Ошибка! " . IPS_CACHE_PATH . "cache/skin_cache нет прав на запись - измените права записи на директорию или переключите стили в безопасный режим" );
$this->_addErrorMessage( sprintf( $this->lang->words['fatalnotemplsafe'], IPS_CACHE_PATH ) );
}
}
@@ -1680,11 +1892,11 @@ EOF;
fclose( $FH );
@chmod( IPS_CACHE_PATH.'cache/skin_cache/cacheid_'.$setID.'/'.$groupName.'.php', 0777 );
$this->_addMessage( "Записан skin_cache/cacheid_{$setID}/{$groupName}.php" );
$this->_addMessage( $this->lang->words['basicwrittenpre'] . "skin_cache/cacheid_{$setID}/{$groupName}.php" );
}
else
{
$this->_addErrorMessage( "cache/skin_cache/cacheid_{$setID}/{$groupName}.php нет прав на запись" );
$this->_addErrorMessage( sprintf( $this->lang->words['templatefilenowrite'], $setID, $groupName ) );
}
}
}
@@ -1711,7 +1923,7 @@ EOF;
}
/* Remove all hooks */
$html = preg_replace( "#<!--hook\.([^\>]+?)-->#", '', $html );
$html = preg_replace( '#<!--hook\.([^\>]+?)-->#', '', $html );
/* Restore saved hooks */
foreach( $hooks as $hook )
@@ -1725,7 +1937,7 @@ EOF;
else
{
/* No hooks, so remove all */
$html = preg_replace( "#<!--hook\.([^\>]+?)-->#", '', $html );
$html = preg_replace( '#<!--hook\.([^\>]+?)-->#', '', $html );
}
return $html;
@@ -1752,7 +1964,7 @@ EOF;
/* Fetch the data block */
if ( strstr( $cssContent, '<IPS_IMPORT_BLOCK>' ) )
{
preg_match( "#/\*<IPS_IMPORT_BLOCK>(.+?)</IPS_IMPORT_BLOCK>\*/#is", $cssContent, $match );
preg_match( '#/\*<IPS_IMPORT_BLOCK>(.+?)</IPS_IMPORT_BLOCK>\*/#is', $cssContent, $match );
if ( $match[0] )
{
@@ -1788,7 +2000,7 @@ EOF;
/* Fetch the data block */
if ( strstr( $cssContent, '<IPS_IMPORT_BLOCK>' ) )
{
preg_match( "#/\*<IPS_IMPORT_BLOCK>(.+?)</IPS_IMPORT_BLOCK>\*/#is", $cssContent, $match );
preg_match( '#/\*<IPS_IMPORT_BLOCK>(.+?)</IPS_IMPORT_BLOCK>\*/#is', $cssContent, $match );
if ( $match[0] )
{
@@ -1797,8 +2009,8 @@ EOF;
}
}
$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 );
$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 );
return $cssContent;
}
@@ -1814,6 +2026,10 @@ EOF;
{
$skinData['set_image_dir'] = ( $skinData['set_image_dir'] ) ? $skinData['set_image_dir'] : 'master';
/* These are not always set up correctly */
$this->settings['img_url'] = ( $this->settings['img_url'] ) ? $this->settings['img_url'] : $this->settings['_original_base_url'] . '/' . PUBLIC_DIRECTORY . '/style_images/' . $skinData['set_image_dir'];
$this->settings['img_url_no_dir'] = ( $this->settings['img_url_no_dir'] ) ? $this->settings['img_url_no_dir'] : $this->settings['_original_base_url'] . '/' . PUBLIC_DIRECTORY . '/style_images/';
//-----------------------------------------
// Fix up style images stuff
//-----------------------------------------
@@ -1832,7 +2048,7 @@ EOF;
$this->settings['ipb_img_url'] .= '/';
}
$cssContent = preg_replace( "#url\(('|\")?\.\./\.\./style_images/#", "url(\\1{$this->settings['ipb_img_url']}/style_images/", $cssContent );
$cssContent = preg_replace( '#url\((\'|\")?\.\./\.\./style_images/#', "url(\\1" . $this->settings['ipb_img_url'] . "/style_images/", $cssContent );
}
//-----------------------------------------
@@ -1867,7 +2083,9 @@ EOF;
return $this->_cssNeedToRebuildArray[ $setID ];
}
$needToRebuild = array();
$cachedCSS = array();
$thisCSS = array();
$needToRebuild = array();
//-----------------------------------------
// Fetch cached CSS data