Version 1.3.0

This commit is contained in:
Neo committed 2025-12-19 00:17:06 -08:00
1 parent 7ef3d1712a
commit f87d29ba65
290 files changed
+50206 -17930

No files matched your search

+592 -130
View File
@@ -2,15 +2,17 @@
/*
+--------------------------------------------------------------------------
| Invision Board v1.1
| Invision Power Board v1.3 Final
| ========================================
| by Matthew Mecham
| (c) 2001,2002 Invision Power Services
| http://www.ibforums.com
| (c) 2001 - 2003 Invision Power Services
| http://www.invisionpower.com
| ========================================
| Web: http://www.ibforums.com
| Email: phpboards@ibforums.com
| Licence Info: phpib-licence@ibforums.com
| Web: http://www.invisionboard.com
| Time: Sun, 04 Jan 2004 00:30:16 GMT
| Release: 28e7bfb25f08ac72a789cb1b172fa185
| Email: matt@invisionpower.com
| Licence Info: http://www.invisionboard.com/?license
+---------------------------------------------------------------------------
|
| > CSS management functions
@@ -21,6 +23,11 @@
+--------------------------------------------------------------------------
*/
if ( ! defined( 'IN_ACP' ) )
{
print "<h1>Incorrect access</h1>You cannot access this file directly. If you have recently upgraded, make sure you upgraded 'admin.php'.";
exit();
}
$idx = new ad_settings();
@@ -30,7 +37,20 @@ class ad_settings {
var $base_url;
function ad_settings() {
global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
global $IN, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
//---------------------------------------
// Kill globals - globals bad, Homer good.
//---------------------------------------
$tmp_in = array_merge( $_GET, $_POST, $_COOKIE );
foreach ( $tmp_in as $k => $v )
{
unset($$k);
}
//---------------------------------------
switch($IN['code'])
{
@@ -80,12 +100,16 @@ class ad_settings {
$this->easy_edit();
break;
case 'editcomments':
$this->edit_comments();
case 'doresync':
$this->do_resynch();
break;
case 'colouredit':
$this->colouredit();
break;
case 'doeditcomments':
$this->do_edit_comments();
case 'docolour':
$this->do_colouredit();
break;
//-------------------------
@@ -98,13 +122,9 @@ class ad_settings {
//+-------------------------------
//+-------------------------------
function do_edit_comments()
function do_resynch()
{
global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP, $HTTP_POST_VARS;
global $IN, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP, $HTTP_POST_VARS;
//+-------------------------------
@@ -122,61 +142,110 @@ class ad_settings {
$ADMIN->error("Could not query the CSS details from the database");
}
$DB->query("UPDATE ibf_css SET css_comments='{$IN['comments']}' WHERE cssid='".$IN['id']."'");
if ( $IN['favour'] == 'cache' )
{
$cache_file = ROOT_PATH."cache/css_".$IN['id'].".css";
if ( file_exists( $cache_file ) )
{
$FH = fopen( $cache_file, 'r' );
$cache_data = fread( $FH, filesize($cache_file) );
fclose($FH);
}
else
{
$ADMIN->error("Could not locate cached CSS file @ $cache_file");
}
$dbr = $DB->compile_db_update_string( array( 'css_text' => $cache_data ) );
$DB->query("UPDATE ibf_css SET $dbr WHERE cssid='".$IN['id']."'");
}
else
{
$cache_file = ROOT_PATH."cache/css_".$IN['id'].".css";
$FH = fopen( $cache_file, 'w' );
fputs( $FH, $cssinfo['css_text'], strlen($cssinfo['css_text']) );
fclose($FH);
}
$ADMIN->done_screen("Comments Updated", "Manage Style Sheets", "act=style" );
if ( $IN['return'] != 'colouredit' )
{
$this->do_form('edit');
}
else
{
$this->colouredit();
}
}
//+-------------------------------
function edit_comments()
function resync_splash($db_length, $cache_length, $cache_mtime, $db_mtime, $id, $return="")
{
global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
//+-------------------------------
if ($IN['id'] == "")
{
$ADMIN->error("You must specify an existing wrapper ID, go back and try again");
}
//+-------------------------------
$DB->query("SELECT cssid, css_text, css_name, css_comments FROM ibf_css WHERE cssid='".$IN['id']."'");
if ( ! $cssinfo = $DB->fetch_row() )
{
$ADMIN->error("Could not query the CSS details from the database");
}
global $IN, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
//+-------------------------------
$ADMIN->page_detail = "Please enter or edit the comments below";
$ADMIN->page_title = "Edit Comments for Style Sheet '{$cssinfo['css_name']}'";
$ADMIN->page_detail = "A mismatch has been found between the cached style sheet and the style sheet stored in the database";
$ADMIN->page_title = "Resynchronise Style Sheet";
//+-------------------------------
$SKIN->td_header[] = array( "CSS" , "40%" );
$SKIN->td_header[] = array( "Comment" , "60%" );
$SKIN->td_header[] = array( "&nbsp;" , "50%" );
$SKIN->td_header[] = array( "&nbsp;" , "50%" );
//+-------------------------------
$ADMIN->html .= $SKIN->start_form( array( 1 => array( 'code' , 'doeditcomments' ),
2 => array( 'act' , 'style' ),
3 => array( 'id' , $IN['id'] ),
$ADMIN->html .= $SKIN->start_form( array( 1 => array( 'code' , 'doresync' ),
2 => array( 'act' , 'style' ),
3 => array( 'id' , $id ),
4 => array( 'return', $return ),
) );
$favour = 'db';
$ADMIN->html .= $SKIN->start_table( "Edit Comments" );
$ADMIN->html .= $SKIN->start_table( "Resynch CSS before editing..." );
if ( intval($cache_mtime) > intval($db_mtime) )
{
$ADMIN->html .= $SKIN->add_td_row( array(
"<b>CSS in database last updated:</b> ".$ADMIN->get_date($db_mtime, 'LONG'),
"<b>CSS in database, # characters:</b> $db_length",
) );
$ADMIN->html .= $SKIN->add_td_row( array(
"<span style='color:red'><b>CSS in CACHE last updated:</b> ".$ADMIN->get_date($cache_mtime, 'LONG')."</span>",
"<span style='color:red'><b>CSS in CACHE, # characters:</b> $cache_length</span>",
) );
$favour = 'cache';
}
else
{
$ADMIN->html .= $SKIN->add_td_row( array(
"<span style='color:red'><b>CSS in database last updated:</b> ".$ADMIN->get_date($db_mtime, 'LONG')."</span>",
"<span style='color:red'><b>CSS in database, # characters:</b> $db_length</span>",
) );
$ADMIN->html .= $SKIN->add_td_row( array(
"<b>CSS in CACHE last updated:</b> ".$ADMIN->get_date($cache_mtime, 'LONG'),
"<b>CSS in CACHE, # characters:</b> $cache_length",
) );
}
$ADMIN->html .= $SKIN->add_td_row( array(
"<b>Edit the comments for this stylesheet",
$SKIN->form_textarea( "comments", str_replace("<br>", "\n", $cssinfo['comments']) )
) );
$ADMIN->html .= $SKIN->add_td_basic("Back to: <a href='".$SKIN->base_url."&act=style'>Manage Style Sheets</a> -&gt; <a href='".$SKIN->base_url."&act=style&code=edit&id={$IN['id']}'>Edit Options</a>", "center", "title");
"<b>Resynchronise using....</b>",
$SKIN->form_dropdown( 'favour', array(
0 => array( 'cache', 'Overwrite database version with cached version'),
1 => array( 'db' , 'Update cached version from the database' ),
), $favour ),
) );
$ADMIN->html .= $SKIN->end_form("Edit the comments");
$ADMIN->html .= $SKIN->end_form("Resynchronise");
$ADMIN->html .= $SKIN->end_table();
@@ -191,73 +260,12 @@ class ad_settings {
// ADD / EDIT WRAPPERS
//-------------------------------------------------------------
function edit_splash()
{
global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
//+-------------------------------
if ($IN['id'] == "")
{
$ADMIN->error("You must specify an existing wrapper ID, go back and try again");
}
//+-------------------------------
$DB->query("SELECT cssid, css_text, css_name FROM ibf_css WHERE cssid='".$IN['id']."'");
if ( ! $cssinfo = $DB->fetch_row() )
{
$ADMIN->error("Could not query the CSS details from the database");
}
//+-------------------------------
$ADMIN->page_detail = "Please select your editing option.";
$ADMIN->page_title = "Edit Style Sheet '{$cssinfo['css_name']}'";
//+-------------------------------
$SKIN->td_header[] = array( "Option" , "40%" );
$SKIN->td_header[] = array( "Description" , "60%" );
//+-------------------------------
$ADMIN->html .= $SKIN->start_table( "Choose an option" );
$ADMIN->html .= $SKIN->add_td_row( array(
"<a href='".$SKIN->base_url."&act=style&code=edit2&id={$IN['id']}'>CSS Editing</a>",
"Edit the stylesheet as a complete resource in a similar environment as a text editor",
) );
$ADMIN->html .= $SKIN->add_td_row( array(
"<a href='".$SKIN->base_url."&act=style&code=editupload&id={$IN['id']}'>Upload a stylesheet</a>",
"Upload a stylesheet from your hard drive to replace the one stored in the database",
) );
$ADMIN->html .= $SKIN->add_td_row( array(
"<a href='".$SKIN->base_url."&act=style&code=editcomments&id={$IN['id']}'>Edit Comments</a>",
"Edit the comments that indicate where the CSS definitions are used in the templates",
) );
$ADMIN->html .= $SKIN->add_td_basic("Back to: <a href='".$SKIN->base_url."&act=style'>Manage Style Sheets</a>", "center", "title");
$ADMIN->html .= $SKIN->end_table();
//+-------------------------------
//+-------------------------------
$ADMIN->output();
}
function css_upload($type='new')
{
global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP, $HTTP_POST_FILES;
global $IN, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP, $HTTP_POST_FILES;
$FILE_NAME = $HTTP_POST_FILES['FILE_UPLOAD']['name'];
$FILE_SIZE = $HTTP_POST_FILES['FILE_UPLOAD']['size'];
@@ -319,9 +327,24 @@ class ad_settings {
'css_name' => $real_name,
'css_text' => $css,
'css_comments' => $comments,
'updated' => time(),
) );
$DB->query("INSERT INTO ibf_css (".$dbs['FIELD_NAMES'].") VALUES(".$dbs['FIELD_VALUES'].")");
$new_id = $DB->get_insert_id();
if ( file_exists( ROOT_PATH."cache" ) )
{
if ( is_writeable( ROOT_PATH."cache" ) )
{
$FH = fopen( ROOT_PATH."cache/css_".$new_id.".css", 'w' );
fputs( $FH, $css, strlen($css) );
fclose($FH);
}
}
$ADMIN->done_screen("Stylesheet uploaded", "Manage Style Sheets", "act=style" );
}
@@ -333,7 +356,7 @@ class ad_settings {
function optimize()
{
global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
global $IN, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
if ($IN['id'] == "")
{
@@ -377,7 +400,7 @@ class ad_settings {
if ( count($parsed) < 1)
{
$ADMIN->error("The stylesheet is in a format that Invision Board cannot understand, no optimization done.");
$ADMIN->error("The stylesheet is in a format that Invision Power Board cannot understand, no optimization done.");
}
// Clean them up
@@ -414,7 +437,7 @@ class ad_settings {
if ($final_size < 1000)
{
$ADMIN->error("The stylesheet is in a format that Invision Board cannot understand, no optimization done.");
$ADMIN->error("The stylesheet is in a format that Invision Power Board cannot understand, no optimization done.");
}
// Update the DB
@@ -431,7 +454,7 @@ class ad_settings {
$pc_saved = sprintf( "%.2f", ($saved / $orig_size) * 100);
}
$ADMIN->done_screen("Stylesheet updated<br>Characters Saved: $saved ($pc_saved %)", "Manage Style Sheets", "act=style" );
$ADMIN->done_screen("Stylesheet updated: Characters Saved: $saved ($pc_saved %)", "Manage Style Sheets", "act=style" );
@@ -442,7 +465,7 @@ class ad_settings {
function export()
{
global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
global $IN, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
if ($IN['id'] == "")
{
@@ -478,7 +501,7 @@ class ad_settings {
function remove()
{
global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP, $HTTP_POST_VARS;
global $IN, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP, $HTTP_POST_VARS;
//+-------------------------------
@@ -490,6 +513,11 @@ class ad_settings {
$DB->query("DELETE FROM ibf_css WHERE cssid='".$IN['id']."'");
if ( file_exists( ROOT_PATH."cache/css_".$IN['id'].".css" ) )
{
@unlink( ROOT_PATH."cache/css_".$IN['id'].".css" );
}
$std->boink_it($SKIN->base_url."&act=style");
exit();
@@ -505,7 +533,7 @@ class ad_settings {
function save_wrapper( $type='add' )
{
global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP, $HTTP_POST_VARS;
global $IN, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP, $HTTP_POST_VARS;
//+-------------------------------
@@ -532,6 +560,7 @@ class ad_settings {
$barney = array( 'css_name' => stripslashes($HTTP_POST_VARS['name']),
'css_text' => $css,
'updated' => time(),
);
if ($type == 'add')
@@ -542,6 +571,21 @@ class ad_settings {
$new_id = $DB->get_insert_id();
//--------------------------------------------
// Update cache?
//--------------------------------------------
if ( file_exists( ROOT_PATH."cache" ) )
{
if ( is_writeable( ROOT_PATH."cache" ) )
{
$FH = fopen( ROOT_PATH."cache/css_".$new_id.".css", 'w' );
fputs( $FH, $css, strlen($css) );
fclose($FH);
}
}
$std->boink_it($SKIN->base_url."&act=style");
exit();
@@ -553,10 +597,40 @@ class ad_settings {
$DB->query("UPDATE ibf_css SET $db_string WHERE cssid='".$IN['id']."'");
//--------------------------------------------
// Update cache?
//--------------------------------------------
$extra = "<b>Cache file updated</b>";
if ( file_exists( ROOT_PATH."cache" ) )
{
if ( is_writeable( ROOT_PATH."cache" ) )
{
if ( $FH = @fopen( ROOT_PATH."cache/css_".$IN['id'].".css", 'w' ) )
{
@fputs( $FH, $css, strlen($css) );
@fclose($FH);
}
else
{
$extra = "<b>Cache file not updated. Check CHMOD permissions on ./cache and ./cache/css_".$IN['id'].".css</b>";
}
}
else
{
$extra = "<b>Cache file not updated. Check CHMOD permissions on ./cache and ./cache/css_".$IN['id'].".css</b>";
}
}
else
{
$extra = "<b>Cache file not updated. Cache folder not present</b>";
}
$ADMIN->nav[] = array( 'act=style' ,'Style Sheet Control Home' );
$ADMIN->nav[] = array( "act=style&code=edit2&id={$IN['id']}" ,"Edit Sheet Again" );
$ADMIN->done_screen("Stylesheet updated", "Manage Style Sheets", "act=style" );
$ADMIN->done_screen("Stylesheet updated : $extra", "Manage Style Sheets", "act=style" );
}
@@ -564,13 +638,10 @@ class ad_settings {
}
//-------------------------------------------------------------
// ADD / EDIT WRAPPERS
//-------------------------------------------------------------
function do_form( $type='add' )
{
global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
global $IN, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
//+-------------------------------
@@ -581,7 +652,7 @@ class ad_settings {
//+-------------------------------
$DB->query("SELECT cssid, css_text, css_name FROM ibf_css WHERE cssid='".$IN['id']."'");
$DB->query("SELECT cssid, css_text, css_name, updated FROM ibf_css WHERE cssid='".$IN['id']."'");
if ( ! $cssinfo = $DB->fetch_row() )
{
@@ -602,10 +673,40 @@ class ad_settings {
{
$code = 'doedit';
$button = 'Edit Stylesheet';
//+-------------------------------
// DB same as cache version?
//+-------------------------------
$cache_file = ROOT_PATH."cache/css_".$IN['id'].".css";
if ( file_exists( $cache_file ) )
{
$FH = fopen( $cache_file, 'r' );
$cache_data = fread( $FH, filesize($cache_file) );
fclose($FH);
$db_length = strlen( trim($css) );
$cache_length = strlen(trim($cache_data));
if ($db_length != $cache_length)
{
// We've got ourselves a mismatch!
// Get mtime of cache file
$stat = stat( $cache_file );
$cache_mtime = $stat[9];
$db_mtime = $cssinfo['updated'];
$this->resync_splash($db_length, $cache_length, $cache_mtime, $db_mtime, $IN['id']);
}
}
}
//+-------------------------------
// Start the CSS matcher thingy
// COLURS!ooO!
//+-------------------------------
//.class { definitions }
@@ -708,9 +809,16 @@ class ad_settings {
$SKIN->form_input('name', $cssinfo['css_name']),
) );
$ADMIN->html .= $SKIN->end_table();
$SKIN->td_header[] = array( "{none}" , "100%" );
//+-------------------------------
$ADMIN->html .= $SKIN->start_table( "Contents" );
$ADMIN->html .= $SKIN->add_td_row( array(
"Content<br><br>(<a href='html/sys-img/css.html' target='_blank'>Launch Style Maker</a>)",
$SKIN->form_textarea('css', $css, "70", "30"),
"<center>".$SKIN->form_textarea('css', $css, $INFO['tx'], $INFO['ty'])."<br /><a href='html/sys-img/css.html' target='_blank'>Launch Style Maker</a></center>",
) );
$ADMIN->html .= $SKIN->end_form($button);
@@ -723,6 +831,360 @@ class ad_settings {
$ADMIN->output();
}
//-------------------------------------------------------------
// EDIT COLOURS START
//-------------------------------------------------------------
function colouredit()
{
global $IN, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
//+-------------------------------
if ($IN['id'] == "")
{
$ADMIN->error("You must specify an existing wrapper ID, go back and try again");
}
//+-------------------------------
$DB->query("SELECT cssid, css_text, css_name, updated FROM ibf_css WHERE cssid='".$IN['id']."'");
if ( ! $cssinfo = $DB->fetch_row() )
{
$ADMIN->error("Could not query the CSS details from the database");
}
$css = $cssinfo['css_text'];
//+-------------------------------
// DB same as cache version?
//+-------------------------------
$cache_file = ROOT_PATH."cache/css_".$IN['id'].".css";
if ( file_exists( $cache_file ) )
{
$FH = fopen( $cache_file, 'r' );
$cache_data = fread( $FH, filesize($cache_file) );
fclose($FH);
$db_length = strlen( $css );
$cache_length = strlen($cache_data);
if ($db_length != $cache_length)
{
// We've got ourselves a mismatch!
// Get mtime of cache file
$stat = stat( $cache_file );
$cache_mtime = $stat[9];
$db_mtime = $cssinfo['updated'];
if ( $cache_mtime != $db_mtime and ( $db_length - $cache_length > 3 ))
{
$this->resync_splash($db_length, $cache_length, $cache_mtime, $db_mtime, $IN['id'], 'colouredit');
}
}
}
//+-------------------------------
// Start the CSS matcher thingy
//+-------------------------------
//.class { definitions }
//#id { definitions }
$colours = array();
// Make http:// safe..
//
preg_match_all( "/([\:\.\#\w\s,]+)\{(.+?)\}/s", $css, $match );
for ($i=0; $i < count($match[0]); $i++)
{
$name = trim($match[1][$i]);
$content = trim($match[2][$i]);
$defs = explode( ';', $content );
if ( count( $defs ) > 0 )
{
foreach( $defs as $a )
{
$a = trim($a);
if ( $a != "" )
{
list( $property, $value ) = explode( ":", $a, 2 );
$property = trim($property);
$value = trim($value);
if ( $property and $value )
{
if ( $property == 'color' or $property == 'background-color' or $property == 'border' or $property == 'background-image' )
{
$colours[ $name ][$property] = $value;
}
}
}
}
}
}
if ( count($colours) < 1 )
{
$ADMIN->error("CSS all gone wonky! No colours to edit");
}
//+-------------------------------
// Get $skin_names stuff
require './sources/Admin/skin_info.php';
$ADMIN->page_detail = "You edit the existing colours below. <strong><a href='html/sys-img/colours.html' target='_blank'>Launch Colour Picker</a></center></strong>";
$ADMIN->page_title = "Manage Style Sheets [ Colours ]";
$ADMIN->html .= $SKIN->start_form( array( 1 => array( 'code' , 'docolour' ),
2 => array( 'act' , 'style' ),
3 => array( 'id' , $IN['id'] ),
) );
//+-------------------------------
$SKIN->td_header[] = array( "Property" , "25%" );
$SKIN->td_header[] = array( "&nbsp;" , "75%" );
//+-------------------------------
$ADMIN->html .= $SKIN->start_table( "CSS Colours" );
foreach ( $colours as $prop => $val )
{
$tbl_colour = "";
$tbl_bg = "";
$tbl_html = "";
$desc = $css_names[ $prop ];
if ( $desc == "" )
{
$desc = 'None available';
}
$name = $prop;
$md5 = md5($name);
if ( strlen($name) > 30 )
{
$name = substr( $name, 0, 30 ) .'...';
}
$ADMIN->html .= $SKIN->add_td_row( array(
"<strong>".$name."</strong><br />($desc)",
"<table width='100%' border='0' cellpadding='4' cellspacing='0'>
<tr>
<td width='20%'>Font Colour</td><td width='30%'>".
$SKIN->form_simple_input('frm_'.$md5.'_color' , $val['color'], "8")."&nbsp;&nbsp;<input type='text' size='6' style='border:1px solid black;background-color:{$val['color']}' readonly='readonly'>"
."</td>
<td width='20%'>Background Colour</td><td width='30%'>".
$SKIN->form_simple_input('frm_'.$md5.'_background-color', $val['background-color'], "8")."&nbsp;&nbsp;<input type='text' size='6' style='border:1px solid black;background-color:{$val['background-color']}' readonly='readonly'>"
."</td>
</tr>
<tr>
<td>Border</td><td width='30%'>".
$SKIN->form_simple_input('frm_'.$md5.'_border' , $val['border'], "20")
."</td>
<td>Background-image</td><td width='30%'>".
$SKIN->form_simple_input('frm_'.$md5.'_background-image', $val['background-image'], "30")
."</td></tr></table>"
) );
}
$ADMIN->html .= $SKIN->end_form("Edit");
$ADMIN->html .= $SKIN->end_table();
//+-------------------------------
//+-------------------------------
$ADMIN->output();
}
//-------------------------------------------------------------
// EDIT COLOURS START
//-------------------------------------------------------------
function do_colouredit()
{
global $IN, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP, $HTTP_POST_VARS;
//+-------------------------------
if ($IN['id'] == "")
{
$ADMIN->error("You must specify an existing wrapper ID, go back and try again");
}
//+-------------------------------
$DB->query("SELECT cssid, css_text, css_name, updated FROM ibf_css WHERE cssid='".$IN['id']."'");
if ( ! $cssinfo = $DB->fetch_row() )
{
$ADMIN->error("Could not query the CSS details from the database");
}
$css = $cssinfo['css_text'];
//+-------------------------------
// Start the CSS matcher thingy
//+-------------------------------
$colours = array();
preg_match_all( "/([\:\.\#\w\s,]+)\{(.+?)\}/s", $css, $match );
for ($i=0; $i < count($match[0]); $i++)
{
$name = trim($match[1][$i]);
$content = trim($match[2][$i]);
$md5 = md5($name);
$defs = explode( ';', $content );
if ( count( $defs ) > 0 )
{
foreach( $defs as $a )
{
$a = trim($a);
if ( $a != "" )
{
list( $property, $value ) = explode( ":", $a, 2 );
$property = trim($property);
$value = trim($value);
if ( $property and $value )
{
if ( $property != 'color' and $property != 'background-color' and $property != 'border' and $property != 'background-image' )
{
$colours[ $name ][$property] = $value;
}
}
}
}
}
foreach( array( 'color', 'background-color', 'border', 'background-image' ) as $prop )
{
if ( isset($HTTP_POST_VARS['frm_'.$md5.'_'.$prop]) )
{
$colours[ $name ][$prop] = stripslashes($HTTP_POST_VARS['frm_'.$md5.'_'.$prop]);
}
}
}
if ( count($colours) < 1 )
{
$ADMIN->error("CSS all gone wonky! No colours to edit");
}
//+-------------------------------
unset($name);
unset($property);
$final = "";
foreach( $colours as $name => $property )
{
$final .= $name." { ";
if ( is_array($property) and count($property) > 0 )
{
foreach( $property as $key => $value )
{
if ( $key AND $value )
{
$final .= $key.": ".$value.";";
}
}
}
$final .= " }\n";
}
$barney = array(
'css_text' => $final,
'updated' => time(),
);
$db_string = $DB->compile_db_update_string( $barney );
$DB->query("UPDATE ibf_css SET $db_string WHERE cssid='".$IN['id']."'");
//--------------------------------------------
// Update cache?
//--------------------------------------------
$extra = "<b>Cache file updated</b>";
if ( file_exists( ROOT_PATH."cache" ) )
{
if ( is_writeable( ROOT_PATH."cache" ) )
{
if ( $FH = @fopen( ROOT_PATH."cache/css_".$IN['id'].".css", 'w' ) )
{
@fputs( $FH, $css, strlen($css) );
@fclose($FH);
}
else
{
$extra = "<b>Cache file not updated. Check CHMOD permissions on ./cache and ./cache/css_".$IN['id'].".css</b>";
}
}
else
{
$extra = "<b>Cache file not updated. Check CHMOD permissions on ./cache and ./cache/css_".$IN['id'].".css</b>";
}
}
else
{
$extra = "<b>Cache file not updated. Cache folder not present</b>";
}
$ADMIN->nav[] = array( 'act=style' ,'Style Sheet Control Home' );
$ADMIN->nav[] = array( "act=style&code=edit2&id={$IN['id']}" ,"Edit Sheet Again (Advanced)" );
$ADMIN->nav[] = array( "act=style&code=colouredit&id={$IN['id']}" ,"Edit Colours Again?" );
$ADMIN->done_screen("Stylesheet updated : $extra", "Manage Style Sheets", "act=style" );
}
//-------------------------------------------------------------
@@ -731,7 +1193,7 @@ class ad_settings {
function list_sheets()
{
global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
global $IN, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
$form_array = array();
$show_array = array();