Fix Skin Functions
| > Module written by Matt Mecham
| > Date started: 21st September 2003
|
| > Module Version Number: 1.0.0
+--------------------------------------------------------------------------
*/
if ( ! defined( 'IN_ACP' ) )
{
print "
Incorrect access
You cannot access this file directly. If you have recently upgraded, make sure you upgraded 'admin.php'.";
exit();
}
$idx = new ad_skinfix();
class ad_skinfix {
var $base_url;
var $db_html_files = "";
var $ff_html_files = "";
var $skin_id = "";
var $ff_fixes = array();
var $log = array();
function ad_skinfix()
{
global $IN, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
$ADMIN->page_detail = "This will allow you to update any old skins with the very latest skin files from the latest IPB release to ensure compatibility.
Simply download the latest skin lists from our master server to your install and then run these lists to compare and update any skins you have installed.";
$ADMIN->page_title = "Skin Version Control";
//---------------------------------------
// Kill globals - globals bad, Homer good.
//---------------------------------------
$tmp_in = array_merge( $_GET, $_POST, $_COOKIE );
foreach ( $tmp_in as $k => $v )
{
unset($$k);
}
//---------------------------------------
switch($IN['code'])
{
case 'importurl':
$this->import_ipb_file();
break;
case 'runtool':
$this->run_tool();
break;
case 'delete':
$this->delete_list();
break;
//-------------------------
default:
$this->list_current();
break;
}
}
//-------------------------------------------------------------
// Delete local list-y-poooos
//-------------------------------------------------------------
function delete_list()
{
global $IN, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
if ( ! $IN['id'] )
{
$this->list_current("No ID passed, no deletion completed");
}
if ( @unlink( ROOT_PATH . 'cache/'. $IN['id'] ) )
{
$this->list_current("Cache file removed");
}
else
{
$this->list_current("Cache file could not be removed. Insufficient write permissions");
}
}
//-------------------------------------------------------------
// RUN THE TOOL:UPDATE MINOR: Update all bug fixes, etc
//-------------------------------------------------------------
function tool_update_updates()
{
global $IN, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
//------------------------------
// Find missing template bits
//------------------------------
$affected = array();
foreach( $this->ff_fixes as $skin_file => $data )
{
foreach( $this->ff_fixes[ $skin_file ] as $section => $desc )
{
if ( $desc['isnew'] == 1 )
{
//------------------------------
// Check to see if it's still missing...
//------------------------------
if ( $this->db_html_files[ $skin_file ][ $section ] )
{
//------------------------------
// It's not, so fu.. continue
//------------------------------
continue;
}
}
$data = $this->ff_html_files[ $skin_file ][ $section ][ 'func_data' ];
$content = $this->ff_html_files[ $skin_file ][ $section ][ 'section_content' ];
$this->_update_section($skin_file, $section, $data, $content);
$affected[$skin_file] = $skin_file;
}
}
if ( count($affected) < 1 )
{
$this->log[] = "Could not update the template files, no updates taken place";
}
else
{
foreach( $affected as $sk )
{
$this->_update_php_file($sk);
}
}
$this->write_log("Results of updating all bug fixed sections");
}
//-------------------------------------------------------------
// RUN THE TOOL:UPDATE MAJOR: Update all missing templates
//-------------------------------------------------------------
function tool_updatemajor()
{
global $IN, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
//------------------------------
// Find missing template bits
//------------------------------
$affected = array();
foreach( $this->ff_html_files as $skin_file => $data )
{
foreach( $this->ff_html_files[ $skin_file ] as $id => $ndata )
{
if ( ! $this->db_html_files[ $skin_file ][ $ndata['func_name'] ] )
{
$this->_update_section($skin_file, $ndata['func_name'], $ndata['func_data'], $ndata['section_content']);
$affected[$skin_file] = $skin_file;
}
}
}
if ( count($affected) < 1 )
{
$this->log[] = "Could not update the template files, no updates taken place";
}
else
{
foreach( $affected as $sk )
{
$this->_update_php_file($sk);
}
}
$this->write_log("Results of updating all missing sections");
}
//-------------------------------------------------------------
// RUN THE TOOL:VIEW CODE, View the code changes
//-------------------------------------------------------------
function tool_view_code()
{
global $IN, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
$code = $this->ff_html_files[ $IN['skinfile'] ][ $IN['func'] ]['section_content'];
if ( $code == "" )
{
$ADMIN->error("No code to show, please check the skin file, function name and skin ID");
}
$code = str_replace( "\n\n", "\n", str_replace( "\r", "\n", $code ) );
if ( $IN['type'] == 'php' )
{
$code = 'function '.$IN['func'].'('.$this->ff_html_files[ $IN['skinfile'] ][ $IN['func'] ]['func_data'].') {'."\rglobal \$ibforums;\r".'return <<convert_tags($code);
}
if ( phpversion() >= '4.2.0' )
{
@error_reporting(0);
$buffer = highlight_string( "", TRUE );
$buffer = preg_replace( "#(?:<|<)\?php\r?(.*)\r?\?(?:>|>)#s", "\\1", $buffer );
}
else
{
$buffer = htmlentities($code);
}
$SKIN->td_header[] = array( " ", "100%" );
$ADMIN->html .= $SKIN->start_table( "{$IN['skinfile']} -> {$IN['func']}" );
$ADMIN->html .= $SKIN->add_td_basic( "
".$buffer."
", "left");
$ADMIN->html .= $SKIN->end_table();
$ADMIN->print_popup();
}
//-------------------------------------------------------------
// RUN THE TOOL:COMPARE, Show changes - do nothing
//-------------------------------------------------------------
function tool_compare()
{
global $IN, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
$ADMIN->page_detail .= "
Please note: Updating template bits WILL overwrite your current template bits completely. If you have a heavily modified skin you may wish to use manually
update the template bit to ensure that the changes integrate with your skin. If you have a heavily customized skin, export a copy first for safety.";
$ADMIN->page_detail .= "
There are $cnt missing sections, this could mean a very out of date template set and updating it may not be successful.";
}
$SKIN->td_header[] = array( "Skin Name" , "25%" );
$SKIN->td_header[] = array( "Function" , "30%" );
$SKIN->td_header[] = array( "Reason" , "20%" );
$SKIN->td_header[] = array( "View Code" , "25%" );
$ADMIN->html .= $SKIN->start_table( "Missing sections in {$this->db_skin['skname']}" );
if ( count($changes) > 0 )
{
foreach( $changes as $skin_file => $data )
{
foreach( $changes[ $skin_file ] as $fun )
{
$ADMIN->html .= $SKIN->add_td_row( array( "{$skin_file}",
$fun,
"Missing in local template",
"