Version 2.0.0

This commit is contained in:
Neo committed 2025-12-19 00:19:56 -08:00
1 parent 5699abfc0e
commit 0eecc172d9
696 files changed
+120723 -77160

No files matched your search

+217
View File
@@ -0,0 +1,217 @@
<?php
/*
+--------------------------------------------------------------------------
| Invision Power Board v2.0.0
| =============================================
| by Matthew Mecham
| (c) 2001 - 2004 Invision Power Services, Inc.
| http://www.invisionpower.com
| =============================================
| Web: http://www.invisionboard.com
| Time: Tue, 21 Sep 2004 16:34:28 GMT
| Release: 150aa7a702c3c8b6f6eb90ad49305d2f
| Licence Info: http://www.invisionboard.com/?license
+---------------------------------------------------------------------------
|
| > Converge methods (KERNEL)
| > Module written by Matt Mecham
| > Date started: 15th March 2004
|
| > Module Version Number: 1.0.0
+--------------------------------------------------------------------------
*/
class class_converge
{
var $current_db = "";
var $member = array();
/*-------------------------------------------------------------------------*/
// CONSTRUCTOR
/*-------------------------------------------------------------------------*/
function class_converge(&$DB)
{
$this->current_db = $DB;
// Temp code!
$this->converge_db = $DB;
}
/*-------------------------------------------------------------------------*/
// Test for converge row
/*-------------------------------------------------------------------------*/
function converge_check_for_member_by_email( $email )
{
$test = $this->converge_db->simple_exec_query( array( 'select' => 'converge_id', 'from' => 'members_converge', 'where' => "converge_email='$email'" ) );
if ( $test['converge_id'] )
{
return TRUE;
}
else
{
return FALSE;
}
}
/*-------------------------------------------------------------------------*/
// Update converge row (password)
/*-------------------------------------------------------------------------*/
function converge_update_password( $new_md5_pass, $email )
{
if ( ! $email or ! $new_md5_pass )
{
return FALSE;
}
if ( $email != $this->member['converge_email'] )
{
$temp_member = $this->converge_db->simple_exec_query( array( 'select' => '*', 'from' => 'members_converge', 'where' => "converge_email='$email'" ) );
}
else
{
$temp_member = $this->member;
}
$new_pass = md5( md5( $temp_member['converge_pass_salt'] ) . $new_md5_pass );
$this->converge_db->do_update( 'members_converge', array( 'converge_pass_hash' => $new_pass ), 'converge_id='.$temp_member['converge_id'] );
}
/*-------------------------------------------------------------------------*/
// Update converge row
/*-------------------------------------------------------------------------*/
function converge_update_member($curr_email, $new_email)
{
if ( ! $curr_email or ! $new_email )
{
return FALSE;
}
if ( ! $this->member['converge_id'] )
{
$this->converge_load_member( $curr_email );
if ( ! $this->member['converge_id'] )
{
return FALSE;
}
}
$this->converge_db->do_update( 'members_converge', array( 'converge_email' => $new_email ), 'converge_id='.$this->member['converge_id'] );
return TRUE;
}
/*-------------------------------------------------------------------------*/
// Get converge row
/*-------------------------------------------------------------------------*/
function converge_load_member($email)
{
if ( ! $email )
{
$this->member = array();
}
else
{
$this->member = $this->converge_db->simple_exec_query( array( 'select' => '*', 'from' => 'members_converge', 'where' => "converge_email='$email'" ) );
}
}
/*-------------------------------------------------------------------------*/
// Get converge row (based on ID)
/*-------------------------------------------------------------------------*/
function converge_load_member_by_id($id)
{
$id = intval($id);
if ( ! $id )
{
$this->member = array();
}
else
{
$this->member = $this->converge_db->simple_exec_query( array( 'select' => '*', 'from' => 'members_converge', 'where' => "converge_id='$id'" ) );
}
}
/*-------------------------------------------------------------------------*/
// Authenticate password
/*-------------------------------------------------------------------------*/
function converge_authenticate_member( $md5_once_password )
{
if ( ! $this->member['converge_pass_hash'] )
{
return FALSE;
}
if ( $this->member['converge_pass_hash'] == $this->generate_compiled_passhash( $this->member['converge_pass_salt'], $md5_once_password ) )
{
return TRUE;
}
else
{
return FALSE;
}
}
/*-------------------------------------------------------------------------*/
// Generate password
/*-------------------------------------------------------------------------*/
function generate_compiled_passhash($salt, $md5_once_password)
{
return md5( md5( $salt ) . $md5_once_password );
}
/*-------------------------------------------------------------------------*/
// Generate SALT
/*-------------------------------------------------------------------------*/
function generate_password_salt($len=5)
{
$salt = '';
srand( (double)microtime() * 1000000 );
for ( $i = 0; $i < $len; $i++ )
{
$num = rand(33, 126);
if ( $num == '92' )
{
$num = 93;
}
$salt .= chr( $num );
}
return $salt;
}
/*-------------------------------------------------------------------------*/
// Generate auto log in key (MD5 hash of random 60 char string
/*-------------------------------------------------------------------------*/
function generate_auto_log_in_key($len=60)
{
$pass = $this->generate_password_salt( 60 );
return md5($pass);
}
}
?>
File diff suppressed because it is too large. Load diff
+457
View File
@@ -0,0 +1,457 @@
<?php
/*
+--------------------------------------------------------------------------
| Invision Power Board v2.0.0
| =============================================
| by Matthew Mecham
| (c) 2001 - 2004 Invision Power Services, Inc.
| http://www.invisionpower.com
| =============================================
| Web: http://www.invisionboard.com
| Time: Tue, 21 Sep 2004 16:34:28 GMT
| Release: 150aa7a702c3c8b6f6eb90ad49305d2f
| Licence Info: http://www.invisionboard.com/?license
+---------------------------------------------------------------------------
|
| > GD / IMAGE handling methods (KERNEL)
| > Module written by Matt Mecham
| > Date started: 2nd Feb. 2004
|
| > Module Version Number: 1.0.0
+--------------------------------------------------------------------------
*/
class class_image
{
var $in_type = 'file';
var $out_type = 'file';
var $out_file_name = '';
var $out_file_dir = '';
var $in_file_dir = '.';
var $in_file_name = '';
var $in_file_complete = '';
var $desired_width = 0;
var $desired_height = 0;
var $gd_version = 2;
var $image_type = '';
var $file_extension = '';
/*-------------------------------------------------------------------------*/
// CONSTRUCTOR
/*-------------------------------------------------------------------------*/
function class_image()
{
//-----------------------------------
// Full path?
//-----------------------------------
}
/*-------------------------------------------------------------------------*/
// Clean paths
/*-------------------------------------------------------------------------*/
function clean_paths()
{
$this->in_file_dir = preg_replace( "#/$#", "", $this->in_file_dir );
$this->out_file_dir = preg_replace( "#/$#", "", $this->out_file_dir );
if ( $this->in_file_dir and $this->in_file_name )
{
$this->in_file_complete = $this->in_file_dir.'/'.$this->in_file_name;
}
else
{
$this->in_file_complete = $this->in_file_name;
}
if ( ! $this->out_file_dir )
{
$this->out_file_dir = $this->in_file_dir;
}
}
/*-------------------------------------------------------------------------*/
// GENERATE THUMBNAIL
/*-------------------------------------------------------------------------*/
function generate_thumbnail()
{
$return = array();
$image = "";
$thumb = "";
//-----------------------------------
// Set up paths
//-----------------------------------
$this->clean_paths();
$remap = array( 1 => 'GIF', 2 => 'JPG', 3 => 'PNG', 4 => 'SWF', 5 => 'PSD', 6 => 'BMP' );
if ( $this->desired_width and $this->desired_height )
{
//----------------------------------------------------
// Tom Thumb!
//----------------------------------------------------
$img_size = array();
if ( $this->in_type == 'file' )
{
$img_size = @GetImageSize( $this->in_file_complete );
}
if ( $img_size[0] < 1 and $img_size[1] < 1 )
{
$img_size = array();
$img_size[0] = $this->desired_width;
$img_size[1] = $this->desired_height;
$return['thumb_width'] = $this->desired_width;
$return['thumb_height'] = $this->desired_height;
if ( $this->out_type == 'file' )
{
$return['thumb_location'] = $this->in_file_name;
return $return;
}
else
{
//----------------------------------------------------
// Show image
//----------------------------------------------------
$this->show_non_gd();
}
}
//----------------------------------------------------
// Do we need to scale?
//----------------------------------------------------
if ( ( $img_size[0] > $this->desired_width ) OR ( $img_size[1] > $this->desired_height ) )
{
$im = $this->scale_image( array(
'max_width' => $this->desired_width,
'max_height' => $this->desired_height,
'cur_width' => $img_size[0],
'cur_height' => $img_size[1]
) );
$return['thumb_width'] = $im['img_width'];
$return['thumb_height'] = $im['img_height'];
//-----------------------------------------------
// May as well scale properly.
//-----------------------------------------------
if ( $im['img_width'] )
{
$this->desired_width = $im['img_width'];
}
if ( $im['img_height'] )
{
$this->desired_height = $im['img_height'];
}
//-----------------------------------------------
// GD functions available?
//-----------------------------------------------
if ( $remap[ $img_size[2] ] == 'GIF' )
{
if ( function_exists( 'imagecreatefromgif') )
{
if ( $image = @imagecreatefromgif( $this->in_file_complete ) )
{
$this->image_type = 'gif';
}
else
{
if ( $this->out_type == 'file' )
{
$return['thumb_width'] = $this->desired_width;
$return['thumb_height'] = $this->desired_height;
$return['thumb_location'] = $this->in_file_name;
}
else
{
//-----------------------------------------------
// Show Image..
//-----------------------------------------------
$this->show_non_gd();
}
}
}
}
else if ( $remap[ $img_size[2] ] == 'PNG' )
{
if ( function_exists( 'imagecreatefrompng') )
{
if ( $image = @imagecreatefrompng( $this->in_file_complete ) )
{
$this->image_type = 'png';
}
else
{
if ( $this->out_type == 'file' )
{
$return['thumb_width'] = $this->desired_width;
$return['thumb_height'] = $this->desired_height;
$return['thumb_location'] = $this->in_file_name;
}
else
{
//-----------------------------------------------
// Show Image..
//-----------------------------------------------
$this->show_non_gd();
}
}
}
}
else if ( $remap[ $img_size[2] ] == 'JPG' )
{
if ( function_exists( 'imagecreatefromjpeg') )
{
if ( $image = @imagecreatefromjpeg( $this->in_file_complete ) )
{
$this->image_type = 'jpg';
}
else
{
if ( $this->out_type == 'file' )
{
$return['thumb_width'] = $this->desired_width;
$return['thumb_height'] = $this->desired_height;
$return['thumb_location'] = $this->in_file_name;
}
else
{
//-----------------------------------------------
// Show Image..
//-----------------------------------------------
$this->show_non_gd();
}
}
}
}
//----------------------------------------------------
// Did we get a return from imagecreatefrom?
//----------------------------------------------------
if ( $image )
{
if ( $this->gd_version == 1 )
{
$thumb = @imagecreate( $im['img_width'], $im['img_height'] );
@imagecopyresized( $thumb, $image, 0, 0, 0, 0, $im['img_width'], $im['img_height'], $img_size[0], $img_size[1] );
}
else
{
$thumb = @imagecreatetruecolor( $im['img_width'], $im['img_height'] );
@imagecopyresampled($thumb, $image, 0, 0, 0, 0, $im['img_width'], $im['img_height'], $img_size[0], $img_size[1] );
}
//-----------------------------------------------
// Saving?
//-----------------------------------------------
if ( $this->out_type == 'file' )
{
if ( ! $this->out_file_name )
{
//-----------------------------------------------
// Remove file extension...
//-----------------------------------------------
$this->out_file_name = preg_replace( "/^(.*)\..+?$/", "\\1", $this->in_file_name ) . '_thumb';
}
if ( function_exists( 'imagejpeg' ) )
{
$this->file_extension = 'jpg';
@imagejpeg( $thumb, $this->out_file_dir."/".$this->out_file_name.'.jpg' );
@chmod( $this->out_file_dir."/".$this->out_file_name.'.jpg', 0777 );
@imagedestroy( $thumb );
@imagedestroy( $image );
$return['thumb_location'] = $this->out_file_name.'.jpg';
return $return;
}
else if ( function_exists( 'imagepng' ) )
{
$this->file_extension = 'png';
@imagepng( $thumb, $this->out_file_dir."/".$this->out_file_name.'.png' );
@chmod( $this->out_file_dir."/".$this->out_file_name.'.png', 0777 );
@imagedestroy( $thumb );
@imagedestroy( $image );
$return['thumb_location'] = $this->out_file_name.'.png';
return $return;
}
else
{
//--------------------------------------
// Can't save...
//--------------------------------------
$return['thumb_width'] = $this->desired_width;
$return['thumb_height'] = $this->desired_height;
$return['thumb_location'] = $this->in_file_name;
return $return;
}
}
else
{
//-----------------------------------------------
// Show image
//-----------------------------------------------
$this->show_image( $thumb, $this->image_type );
}
}
else
{
//----------------------------------------------------
// Could not GD, return..
//----------------------------------------------------
if ( $this->out_type == 'file' )
{
$return['thumb_width'] = $this->desired_width;
$return['thumb_height'] = $this->desired_height;
$return['thumb_location'] = $this->in_file_name;
}
else
{
//-----------------------------------------------
// Show Image..
//-----------------------------------------------
$this->show_non_gd();
}
return $return;
}
}
//----------------------------------------------------
// No need to scale..
//----------------------------------------------------
else
{
if ( $this->out_type == 'file' )
{
$return['thumb_width'] = $img_size[0];
$return['thumb_height'] = $img_size[1];
return $return;
}
else
{
//-----------------------------------------------
// Show Image..
//-----------------------------------------------
$this->show_non_gd();
}
}
}
}
/*-------------------------------------------------------------------------*/
// Show GD image
/*-------------------------------------------------------------------------*/
function show_image( $thumb, $type )
{
flush();
if ( $type == 'gif' )
{
@header('Content-type: image/gif');
}
else if ( $type == 'png' )
{
@header('Content-Type: image/png' );
}
else
{
@header('Content-Type: image/jpeg' );
}
print $data;
exit();
}
/*-------------------------------------------------------------------------*/
// Show non GD image
/*-------------------------------------------------------------------------*/
function show_non_gd()
{
$file_extension = preg_replace( ".*\.(\w+)$", "\\1", $this->in_file_name );
$file_extension = strtolower( $file_extension );
$file_extension = $file_extension == 'jpeg' ? 'jpg' : $file_extension;
if ( strstr( ' gif jpg png ', ' '.$file_extension.' ' ) )
{
if ( $data = @file_get_contents( $this->in_file_complete ) )
{
$this->show_thumbnail( $data, $file_extension );
}
}
}
/*-------------------------------------------------------------------------*/
// Return scaled down image
/*-------------------------------------------------------------------------*/
function scale_image($arg)
{
// max_width, max_height, cur_width, cur_height
$ret = array(
'img_width' => $arg['cur_width'],
'img_height' => $arg['cur_height']
);
if ( $arg['cur_width'] > $arg['max_width'] )
{
$ret['img_width'] = $arg['max_width'];
$ret['img_height'] = ceil( ( $arg['cur_height'] * ( ( $arg['max_width'] * 100 ) / $arg['cur_width'] ) ) / 100 );
$arg['cur_height'] = $ret['img_height'];
$arg['cur_width'] = $ret['img_width'];
}
if ( $arg['cur_height'] > $arg['max_height'] )
{
$ret['img_height'] = $arg['max_height'];
$ret['img_width'] = ceil( ( $arg['cur_width'] * ( ( $arg['max_height'] * 100 ) / $arg['cur_height'] ) ) / 100 );
}
return $ret;
}
}
?>
+465
View File
@@ -0,0 +1,465 @@
<?php
/*
+--------------------------------------------------------------------------
| Invision Power Board v2.0.0
| =============================================
| by Matthew Mecham
| (c) 2001 - 2004 Invision Power Services, Inc.
| http://www.invisionpower.com
| =============================================
| Web: http://www.invisionboard.com
| Time: Tue, 21 Sep 2004 16:34:28 GMT
| Release: 150aa7a702c3c8b6f6eb90ad49305d2f
| Licence Info: http://www.invisionboard.com/?license
+---------------------------------------------------------------------------
|
| > Template Engine module (KERNEL)
| > Module written by Matt Mecham
| > Date started: 5th January 2004
|
| > Module Version Number: 1.0.0
+--------------------------------------------------------------------------
| New template module to build, rebuild and generate caches of templates
| which include the new IPB HTML Logic system.
| Example:
|
| <if="ibf.vars['threaded_per_page'] == 10">
| html here
| </if>
| <else if="ibf.vars['threaded_per_page'] >= 100 or some_var == 'this'">
| html here
| </if>
| <else if="show['this'] > 100">
| html here
| </if>
| <else>
| html here
| </else>
|
+--------------------------------------------------------------------------
*/
class class_template
{
var $root_path = './';
var $cache_dir = 'skin_cache';
var $cache_id = '1';
var $database_id = '1';
var $cache_path = '';
function class_template()
{
$this->cache_path = $this->root_path . $this->cache_dir . '/cacheid_' . $this->cache_id;
}
//===================================================
// Convert HTML to PHP cache file
//===================================================
function convert_html_to_php($func_name, $func_data, $func_html)
{
//-------------------------------
// Make sure we have ="" on each
// func data
//-------------------------------
$func_data = preg_replace( "#".'\$'."(\w+)(,|$)#i", "\$\\1=\"\"\\2", str_replace( " ", "", $func_data ) );
$top = "//===========================================================================\n".
"// {$func_name}\n".
"//===========================================================================\n";
$start = "function {$func_name}($func_data) {\nglobal \$ibforums;\n\$IPBHTML = \"\";\n//--starthtml--//\n";
$middle = $this->build_section_html_to_php($func_html);
$end = "\n//--endhtml--//\nreturn \$IPBHTML;\n}\n";
return $top.$start.$middle.$end;
}
//===================================================
// Alias: Convert PHP to HTML
//===================================================
function convert_php_to_html($php)
{
return $this->_convert_php_to_html($php);
}
//===================================================
// Build Section: PHP to HTML
// - Updates HTML database with PHP cache file
//===================================================
function build_section_php_to_html($php="")
{
}
//===================================================
// Build Section: HTML to PHP
// - Makes PHP cache of raw HTML
//===================================================
function build_section_html_to_php($html="")
{
if ( preg_match( "#<if=[\"'].+?[\"']>#si", $html ) )
{
//----------------------------------------
// Does it have logic sections?
//----------------------------------------
$html = $this->_convert_html_to_php($html);
//----------------------------------------
// Non-logic from top?
//----------------------------------------
$html = preg_replace( "#^(.+?)(//startif)#ise", "\$this->_wrap_in_php('\\1', '\\2');", $html );
//----------------------------------------
// Non-logic from between?
//----------------------------------------
$html = preg_replace( "#(}//endif|}//endelse)(.+?)(//startif|else)#ise", "\$this->_wrap_in_php('\\2', '\\3', '\\1');", $html );
//$html = str_replace( "}//endif//startif", "}//endif\n//startif", $html );
//----------------------------------------
// Non-logic from after? ENDELSE
//----------------------------------------
if ( preg_match( "#^(.*)(}//endelse)(.+?)$#is", $html, $match ) )
{
if ( $match[1] and $match[2] and ( ! strstr( $match[3], "<<<EOF\n" ) ) )
{
$html = preg_replace( "#^(.*}//endelse)(.+?)$#ise", "\$this->_wrap_in_php('\\2', '', '\\1');", $html );
}
}
//----------------------------------------
// Non-logic from after? ENDIF
//----------------------------------------
if ( preg_match( "#^(.*)(}//endif)(.+?)$#is", $html, $match ) )
{
if ( $match[1] and $match[2] and ( ! strstr( $match[3], "<<<EOF\n" ) ) )
{
$html = preg_replace( "#^(.*}//endif)(.+?)$#ise", "\$this->_wrap_in_php('\\2', '', '\\1');", $html );
}
}
}
else
{
$html = $this->_wrap_in_php( $html );
}
//----------------------------------------
// Unconvert special tags
//----------------------------------------
$html = $this->unconvert_tags($html);
return $html;
}
//===================================================
// Convert special tags into HTML safe versions
//===================================================
function convert_tags($t="")
{
$t = preg_replace( "/{?\\\$ibforums->base_url}?/" , "{ipb.script_url}" , $t );
$t = preg_replace( "/{?\\\$ibforums->session_id}?/" , "{ipb.session_id}" , $t );
$t = preg_replace( "#\\\$ibforums->(member|vars|skin|lang|input)#i" , "ipb.\\1" , $t );
//----------------------------------------
// Make some tags safe..
//----------------------------------------
$t = preg_replace( "/\{ipb\.vars\[(['\"])?(sql_driver|sql_host|sql_database|sql_pass|sql_user|sql_port|sql_tbl_prefix|smtp_host|smtp_port|smtp_user|smtp_pass|html_dir|base_dir|upload_dir)(['\"])?\]\}/", "" , $t );
return $t;
}
//===================================================
// Uncovert them back again
//===================================================
function unconvert_tags($t="")
{
//----------------------------------------
// Make some tags safe..
//----------------------------------------
$t = preg_replace( "/\{ipb\.vars\[(['\"])?(sql_driver|sql_host|sql_database|sql_pass|sql_user|sql_port|sql_tbl_prefix|smtp_host|smtp_port|smtp_user|smtp_pass|html_dir|base_dir|upload_dir)(['\"])?\]\}/", "" , $t );
$t = preg_replace( "/{ipb\.script_url}/i" , '{$ibforums->base_url}' , $t);
$t = preg_replace( "/{ipb\.session_id}/i" , '{$ibforums->session_id}', $t);
$t = preg_replace( "#ipb\.(member|vars|skin|lang|input)#i", '$ibforums->\\1' , $t );
return $t;
}
//===================================================
// Wrap HTML into PHP
//===================================================
function _wrap_in_php( $html, $after="", $before="" )
{
$html = $this->_trim_newlines($this->_trim_slashes($html));
$before = $this->_trim_slashes($before);
$after = $this->_trim_slashes($after);
if ( ! strstr( $before, "\n" ) )
{
$before .= "\n";
}
if ( ! trim($html) )
{
return $before.$html.$after;
}
return $before."\n\$IPBHTML .= <<<EOF\n$html\nEOF;\n".$after;
}
//===================================================
// Convert: HTML Logic to PHP logic
//===================================================
function _convert_html_to_php($html)
{
$html = $this->_trim_slashes($html);
$html = preg_replace( "#(?:\s+?)?<if=[\"'](.+?)[\"']>(.+?)</if>#ise", "\$this->_statement_if('\\1', '\\2')", $html );
$html = preg_replace( "#(?:\s+?)?<else if=[\"'](.+?)[\"']>(.+?)</if>#ise", "\$this->_statement_elseif('\\1', '\\2')", $html );
$html = preg_replace( "#(?:\s+?)?<else>(.+?)</else>#ise", "\$this->_statement_else('\\1')", $html );
return $html;
}
//===================================================
// Convert: PHP logic to HTML logic
//===================================================
function _convert_php_to_html($php)
{
$php = preg_replace( "#else if\s+?\((.+?)\)\s+?{(.+?)}//endif(\n)?#ise", "\$this->_reverse_if('\\1', '\\2', 'else if')", $php );
$php = preg_replace( "#//startif\nif\s+?\((.+?)\)\s+?{(.+?)}//endif(\n)?#ise", "\$this->_reverse_if('\\1', '\\2', 'if')", $php );
$php = preg_replace( "#else\s+?{(.+?)}//endelse(\n)?#ise", "\$this->_reverse_else( '\\1' )", $php );
//----------------------------------------
// Parse raw sections
//----------------------------------------
$php = $this->_reverse_ipbhtml($php);
//----------------------------------------
// Convert ipb-htmllogic tags
//----------------------------------------
//$php = preg_replace( "#//start-htmllogic#i" , "<ipb-htmllogic>", $php );
//$php = preg_replace( "#//end-htmllogic#i", "</ipb-htmllogic>" , $php );
//----------------------------------------
// Remove start ifs
//----------------------------------------
$php = str_replace( "//startif\n", "\n", $php );
//----------------------------------------
// Remove extra spaces
//----------------------------------------
$php = preg_replace( "#(</if>|</else>)\s+?(<if|<else)#is", "\\1\n\\2", $php );
//----------------------------------------
// Make safe special $Ibforums vars
//----------------------------------------
$php = $this->convert_tags($php);
return $php;
}
//===================================================
// Reverse: PHP IF to HTML IF
//===================================================
function _reverse_if( $code, $php, $start='if' )
{
$code = $this->_trim_slashes(trim($code));
$code = preg_replace( "/(^|and|or)(\s+)(.+?)(\s|$)/ise", "\$this->_reverse_prep_left('\\3', '\\1', '\\2', '\\4')", ' '.$code );
$php = $this->_reverse_ipbhtml($php);
return "<".$start."=\"".trim($code)."\">\n".$php."\n</if>\n";
}
//===================================================
// Reverse: PHP else to HTML else
//===================================================
function _reverse_else( $php )
{
$php = $this->_trim_slashes(trim($php));
$php = $this->_reverse_ipbhtml($php);
return "<else>\n".$php."\n</else>\n";
}
//===================================================
// Reverse: $IPBHTML to normal $HTML
//===================================================
function _reverse_ipbhtml( $code )
{
$code = $this->_trim_slashes($code);
$code = preg_replace("/".'\$'."IPBHTML\s+?\.?=\s+?<<<EOF(.+?)EOF;\s?/si", "\\1", $code );
$code = trim($code);
$code = $this->_trim_newlines($code);
return $code;
}
//===================================================
// Reverse PHP IF code to HTML code
//===================================================
function _reverse_prep_left($left, $andor="", $fs="", $ls="")
{
$left = trim($this->_trim_slashes($left));
if ( preg_match( "/".'\$'."ibforums->/", $left ) )
{
$left = preg_replace( "/".'\$'."ibforums->(.+?)$/", 'ipb.'."\\1", $left );
}
else
{
$left = str_replace( '$', '', $left );
}
return $andor.$fs.$left.$ls;
}
//===================================================
// Statement: Return PHP 'IF' statement
//===================================================
function _statement_if( $code, $html )
{
$html = $this->_func_prep_html($html);
$code = $this->_func_prep_if($code);
return "\n//startif\nif ( $code )\n{\n\$IPBHTML .= <<<EOF\n$html\nEOF;\n}//endif\n";
}
//===================================================
// Statement: Return PHP 'ELSE IF' statement
//===================================================
function _statement_elseif( $code, $html )
{
$html = $this->_func_prep_html($html);
$code = $this->_func_prep_if($code);
return "\nelse if ( $code )\n{\n\$IPBHTML .= <<<EOF\n$html\nEOF;\n}//endif\n";
}
//===================================================
// Statement: Return PHP 'ELSE' statement
//===================================================
function _statement_else( $html )
{
$html = $this->_func_prep_html($html);
return "\nelse\n{\n\$IPBHTML .= <<<EOF\n$html\nEOF;\n}//endelse\n";
}
//===================================================
// Strip leading newlines, etc
//===================================================
function _func_prep_html($html)
{
$html = trim($this->_trim_slashes($html));
//$html = preg_replace( '/"/', '\\"', $html );
return $html;
}
//===================================================
// Sort out left bit of comparison
//===================================================
function _func_prep_left($left, $andor="", $fs="", $ls="")
{
$left = trim($this->_trim_slashes($left));
if ( preg_match( "/^ipb\./", $left ) )
{
$left = preg_replace( "/^ipb\.(.+?)$/", '$ibforums->'."\\1", $left );
}
else
{
$left = '$'.$left;
}
return $andor.$fs.$left.$ls;
}
//===================================================
// Statement: Prep AND OR, etc
//===================================================
function _func_prep_if( $code )
{
$code = $this->_trim_slashes($code);
$code = preg_replace( "/(^|and|or)(\s+)(.+?)(\s|$)/ise", "\$this->_func_prep_left('\\3', '\\1', '\\2', '\\4')", ' '.$code );
return trim($code);
}
//===================================================
// Remove leading and trailing newlines
//===================================================
function _trim_newlines($code)
{
$code = preg_replace("/^\n{1,}/s", "", $code );
$code = preg_replace("/\n{1,}$/s", "", $code );
return $code;
}
//===================================================
// Remove preg_replace/e slashes
//===================================================
function _trim_slashes($code)
{
$code = str_replace( '\"' , '"', $code );
$code = str_replace( "\\'", "'", $code );
return $code;
}
}
?>
+270
View File
@@ -0,0 +1,270 @@
<?php
/*
+--------------------------------------------------------------------------
| Invision Power Board v2.0.0
| =============================================
| by Matthew Mecham
| (c) 2001 - 2004 Invision Power Services, Inc.
| http://www.invisionpower.com
| =============================================
| Web: http://www.invisionboard.com
| Time: Tue, 21 Sep 2004 16:34:28 GMT
| Release: 150aa7a702c3c8b6f6eb90ad49305d2f
| Licence Info: http://www.invisionboard.com/?license
+---------------------------------------------------------------------------
|
| > UPLOAD handling methods (KERNEL)
| > Module written by Matt Mecham
| > Date started: 15th March 2004
|
| > Module Version Number: 1.0.0
+--------------------------------------------------------------------------
| ERRORS:
| 1: No upload
| 2: Not valid upload type
| 3: Upload exceeds $max_file_size
| 4: Could not move uploaded file, upload deleted
+--------------------------------------------------------------------------
*/
class class_upload
{
// name of upload form field
var $upload_form_field = 'FILE_UPLOAD';
// Out filename *without* extension
// (Leave blank to retain user filename)
var $out_file_name = '';
// Out dir (./upload) - no trailing slash
var $out_file_dir = './';
// maximum file size of this upload
var $max_file_size = 0;
// Forces PHP, CGI, etc to text
var $make_script_safe = 1;
// Force non-img file extenstion (leave blank if not) (ex: 'ibf'a makes upload.doc => upload.ibf)
var $force_data_ext = '';
// Allowed file extensions array( 'gif', 'jpg', 'jpeg'..)
var $allowed_file_ext = array();
// Array of IMAGE file extensions
var $image_ext = array( 'gif', 'jpeg', 'jpg', 'png' );
// Returns current file extension
var $file_extension = '';
// If force_data_ext == 1, this will return the 'real' extension
// and $file_extension will return the 'force_data_ext'
var $real_file_extension = '';
// Returns error number
var $error_no = 0;
// Returns if upload is img or not
var $is_image = 0;
// Returns file name as was uploaded by user
var $original_file_name = "";
// Returns final file name as is saved on disk. (no path info)
var $parsed_file_name = "";
// Returns final file name with path info
var $saved_upload_name = "";
/*-------------------------------------------------------------------------*/
// CONSTRUCTOR
/*-------------------------------------------------------------------------*/
function class_upload()
{
}
/*-------------------------------------------------------------------------*/
// PROCESS THE UPLOAD
/*-------------------------------------------------------------------------*/
function upload_process()
{
$this->_clean_paths();
//-------------------------------------------------
// Set up some variables to stop carpals developing
//-------------------------------------------------
$FILE_NAME = $_FILES[ $this->upload_form_field ]['name'];
$FILE_SIZE = $_FILES[ $this->upload_form_field ]['size'];
$FILE_TYPE = $_FILES[ $this->upload_form_field ]['type'];
//-------------------------------------------------
// Naughty Opera adds the filename on the end of the
// mime type - we don't want this.
//-------------------------------------------------
$FILE_TYPE = preg_replace( "/^(.+?);.*$/", "\\1", $FILE_TYPE );
//-------------------------------------------------
// Naughty Mozilla likes to use "none" to indicate an empty upload field.
// I love universal languages that aren't universal.
//-------------------------------------------------
if ($_FILES[ $this->upload_form_field ]['name'] == ""
or !$_FILES[ $this->upload_form_field ]['name']
or !$_FILES[ $this->upload_form_field ]['size']
or ($_FILES[ $this->upload_form_field ]['name'] == "none") )
{
$this->error_no = 1;
return;
}
//-------------------------------------------------
// De we have allowed file_extensions?
//-------------------------------------------------
if ( ! is_array( $this->allowed_file_ext ) or ! count( $this->allowed_file_ext ) )
{
$this->error_no = 2;
return;
}
//-------------------------------------------------
// Get file extension
//-------------------------------------------------
$this->file_extension = $this->_get_file_extension( $FILE_NAME );
if ( ! $this->file_extension )
{
$this->error_no = 2;
return;
}
$this->real_file_extension = $this->file_extension;
//-------------------------------------------------
// Valid extension?
//-------------------------------------------------
if ( ! in_array( $this->file_extension, $this->allowed_file_ext ) )
{
$this->error_no = 2;
return;
}
//-------------------------------------------------
// Check the file size
//-------------------------------------------------
if ( ( $this->max_file_size ) and ( $FILE_SIZE > $this->max_file_size ) )
{
$this->error_no = 3;
return;
}
//-------------------------------------------------
// Make the uploaded file safe
//-------------------------------------------------
$FILE_NAME = preg_replace( "/[^\w\.]/", "_", $FILE_NAME );
$this->original_file_name = $FILE_NAME;
//-------------------------------------------------
// Is it an image?
//-------------------------------------------------
if ( is_array( $this->image_ext ) and count( $this->image_ext ) )
{
if ( in_array( $this->file_extension, $this->image_ext ) )
{
$this->is_image = 1;
}
}
//-------------------------------------------------
// Convert file name?
// In any case, file name is WITHOUT extension
//-------------------------------------------------
if ( $this->out_file_name )
{
$this->parsed_file_name = $this->out_file_name;
}
else
{
$this->parsed_file_name = str_replace( '.'.$this->file_extension, "", $FILE_NAME );
}
//-------------------------------------------------
// Make safe?
//-------------------------------------------------
if ( $this->make_script_safe )
{
if ( preg_match( "/\.(cgi|pl|js|asp|php|html|htm|jsp|jar)/", $FILE_NAME ) )
{
$FILE_TYPE = 'text/plain';
$this->file_extension = 'txt';
}
}
//-------------------------------------------------
// Add on the extension...
//-------------------------------------------------
if ( $this->force_data_ext and ! $this->is_image )
{
$this->file_extension = str_replace( ".", "", $this->force_data_ext );
}
$this->parsed_file_name .= '.'.$this->file_extension;
//-------------------------------------------------
// Copy the upload to the uploads directory
//-------------------------------------------------
$this->saved_upload_name = $this->out_file_dir.'/'.$this->parsed_file_name;
if ( ! @move_uploaded_file( $_FILES[ $this->upload_form_field ]['tmp_name'], $this->saved_upload_name) )
{
$this->error_no = 4;
return;
}
else
{
@chmod( $this->saved_upload_name, 0777 );
}
}
/*-------------------------------------------------------------------------*/
// INTERNAL: Get file extension
/*-------------------------------------------------------------------------*/
function _get_file_extension($file)
{
return strtolower( str_replace( ".", "", substr( $file, strrpos( $file, '.' ) ) ) );
}
/*-------------------------------------------------------------------------*/
// INTERNAL: Clean paths
/*-------------------------------------------------------------------------*/
function _clean_paths()
{
$this->out_file_dir = preg_replace( "#/$#", "", $this->out_file_dir );
}
}
?>
+400
View File
@@ -0,0 +1,400 @@
<?php
/*
+--------------------------------------------------------------------------
| Invision Power Board v2.0.0
| =============================================
| by Matthew Mecham
| (c) 2001 - 2004 Invision Power Services, Inc.
| http://www.invisionpower.com
| =============================================
| Web: http://www.invisionboard.com
| Time: Tue, 21 Sep 2004 16:34:28 GMT
| Release: 150aa7a702c3c8b6f6eb90ad49305d2f
| Licence Info: http://www.invisionboard.com/?license
+---------------------------------------------------------------------------
|
| > XML handling methods (KERNEL)
| > Module written by Matt Mecham
| > Date started: 25th February
|
| > Module Version Number: 1.0.0
+--------------------------------------------------------------------------
<productlist name="myname" version="1.0">
<productgroup name="thisgroup">
<product id="1.0">
<description>This is a descrption</description>
<title>Baked Beans</title>
<room store="1">103</room>
</product>
</productgroup>
</productlist>
# Set the root tag
$xml->xml_set_root( 'productlist', array( 'name' => 'myname', 'version' => '1.0' ) );
# Add a group
$xml->xml_add_group( 'productgroup', array( 'name' => 'thisgroup' ) );
# Build entry content
$content[] = $xml->xml_build_simple_tag( 'description', "This is a descrption" );
$content[] = $xml->xml_build_simple_tag( 'title' , "Baked Beans" );
$content[] = $xml->xml_build_simple_tag( 'room' , '103' , array( 'store' => 1 ) );
# Build entry
$entry[] = $xml->xml_build_entry( 'product', $content, array( 'id' => '1.0' ) );
# Add to group 'productlist'
$xml->xml_add_entry_to_group( 'productgroup', $entry );
# Format..
$xml->xml_format_document();
# Get XML document
$filecontents = $xml->xml_document;
# Parse XML document
$xml->xml_parse_document( $filecontents );
# Show XML array
print_r( $xml->xml_array );
# print "Baked Beans";
print $xml->xml_array['productlist']['productgroup']['product'][0]['title']['VALUE'];
# print "1";
print $xml->xml_array['productlist']['productgroup']['product'][0]['room']['ATTRIBUTES']['store'];
*/
class class_xml
{
var $header = '<?xml version="1.0" encoding="ISO-8859-1"?>';
var $root_tag = '';
var $root_attributes = "";
var $entries = array();
var $xml_document = "";
var $depth = 0;
var $tmp_doc = "";
var $groups = "";
var $index_numeric = 0;
var $collapse_dups = 1;
var $xml_array = array();
var $collapse_newlines = 1;
/*-------------------------------------------------------------------------*/
// CONSTRUCTOR
/*-------------------------------------------------------------------------*/
function class_xml()
{
}
/*-------------------------------------------------------------------------*/
// Parse an XML document into arrays
/*-------------------------------------------------------------------------*/
function xml_parse_document( $xml )
{
$parser = xml_parser_create();
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE , 0);
xml_parse_into_struct($parser, $xml, $vals, $index);
xml_parser_free($parser);
$i = -1;
$this->xml_array = $this->_xml_get_children($vals, $i);
}
/*-------------------------------------------------------------------------*/
// Format the XML document
/*-------------------------------------------------------------------------*/
function xml_format_document( $entry=array() )
{
$this->xml_document = $this->header ? $this->header."\n" : '';
$this->xml_document .= "<".$this->root_tag.$this->root_attributes.">\n";
$this->xml_document .= $this->tmp_doc;
$this->xml_document .= "\n</".$this->root_tag.">";
$this->tmp_doc = "";
}
/*-------------------------------------------------------------------------*/
// Set the root tags
/*-------------------------------------------------------------------------*/
function xml_set_root($tag, $attributes=array() )
{
$this->root_tag = $tag;
$this->root_attributes = $this->_xml_build_attribute_string( $attributes );
}
/*-------------------------------------------------------------------------*/
// Add entries to the group
/*-------------------------------------------------------------------------*/
function xml_add_entry_to_group($tag, $entry=array() )
{
$this->tmp_doc .= "\t".$this->groups[ $tag ];
if ( is_array( $entry ) and count( $entry ) )
{
foreach( $entry as $e )
{
$this->tmp_doc .= "\n\t\t".$e."\n";
}
}
$this->tmp_doc .= "\t</".$tag.">\n";
}
/*-------------------------------------------------------------------------*/
// Builds an entry
/*-------------------------------------------------------------------------*/
function xml_build_entry( $tag, $content=array(), $attributes=array() )
{
$entry = "<" . $tag . $this->_xml_build_attribute_string($attributes) . ">\n";
if ( is_array( $content ) and count( $content ) )
{
foreach( $content as $c )
{
$entry .= "\t\t\t".$c."\n";
}
}
$entry .= "\t\t</" . $tag . ">";
return $entry;
}
/*-------------------------------------------------------------------------*/
// Add a group
/*-------------------------------------------------------------------------*/
function xml_add_group( $tag, $attributes=array() )
{
$this->groups[ $tag ] = "<" . $tag . $this->_xml_build_attribute_string($attributes) . ">";
}
/*-------------------------------------------------------------------------*/
// Builds a simple <tag [key="value"]>content</tag> structure
/*-------------------------------------------------------------------------*/
function xml_build_simple_tag( $tag, $description="", $attributes=array() )
{
return "<" . $tag . $this->_xml_build_attribute_string($attributes) . ">" . $this->_xml_encode_string($description) . "</" . $tag . ">";
}
/*-------------------------------------------------------------------------*/
// INTERNAL: Build tree node
// Based on code found at http://php.net/manual/en/function.xml-parse-into-struct.php
// And http://eric.pollmann.net/work/public_domain/
/*-------------------------------------------------------------------------*/
function _xml_build_tag( $thisvals, $vals, &$i, $type )
{
$tag = array();
if ( isset($thisvals['attributes']) )
{
$tag['ATTRIBUTES'] = $this->_xml_decode_attribute($thisvals['attributes']);
}
if ( $type === 'complete' )
{
$tag['VALUE'] = $thisvals['value'];
}
else
{
$tag = array_merge( $tag, $this->_xml_get_children($vals, $i) );
}
return $tag;
}
/*-------------------------------------------------------------------------*/
// INTERNAL: Build a nested array of children
// Based on code found at http://php.net/manual/en/function.xml-parse-into-struct.php
// And http://eric.pollmann.net/work/public_domain/
/*-------------------------------------------------------------------------*/
function _xml_get_children($vals, &$i)
{
$children = array();
//-----------------------------------
// CDATA before children
//-----------------------------------
if ( $i > -1 && isset( $vals[$i]['value'] ) )
{
$children['VALUE'] = $vals[$i]['value'];
}
//-----------------------------------
// Loopy loo
//-----------------------------------
while( ++$i < count( $vals ) )
{
$type = $vals[$i]['type'];
//-----------------------------------
// CDATA after children
//-----------------------------------
if ($type === 'cdata')
{
$children['VALUE'] .= $vals[$i]['value'];
}
//-----------------------------------
// COMPLETE: At end of current branch
// OPEN: Node has children, recurse
//-----------------------------------
else if ( $type === 'complete' OR $type === 'open' )
{
$tag = $this->_xml_build_tag( $vals[$i], $vals, $i, $type );
if ( $this->index_numeric )
{
$tag['TAG'] = $vals[$i]['tag'];
$children[] = $tag;
}
else
{
$children[$vals[$i]['tag']][] = $tag;
}
}
//-----------------------------------
// End of node?
//-----------------------------------
else if ($type === 'close')
{
break;
}
}
if ( $this->collapse_dups )
{
foreach( $children as $key => $value )
{
if ( is_array($value) && (count($value) == 1) )
{
$children[$key] = $value[0];
}
}
}
return $children;
}
/*-------------------------------------------------------------------------*/
// INTERNAL: Builds attribute string
/*-------------------------------------------------------------------------*/
function _xml_build_attribute_string( $array = array() )
{
if ( is_array( $array ) and count( $array ) )
{
$string = array();
foreach( $array as $k => $v )
{
$v = trim( $this->_xml_encode_attribute($v) );
$string[] = $k.'="'.$v.'"';
}
return ' ' . implode( " ", $string );
}
}
/*-------------------------------------------------------------------------*/
// INTERNAL: Encodes an attribute string
/*-------------------------------------------------------------------------*/
function _xml_encode_attribute( $t )
{
$t = preg_replace("/&(?!#[0-9]+;)/s", '&amp;', $t );
$t = str_replace( "<", "&lt;" , $t );
$t = str_replace( ">", "&gt;" , $t );
$t = str_replace( '"', "&quot;", $t );
$t = str_replace( "'", '&#039;', $t );
return $t;
}
/*-------------------------------------------------------------------------*/
// INTERNAL: Encodes an attribute string
/*-------------------------------------------------------------------------*/
function _xml_decode_attribute( $t )
{
$t = str_replace( "&amp;" , "&", $t );
$t = str_replace( "&lt;" , "<", $t );
$t = str_replace( "&gt;" , ">", $t );
$t = str_replace( "&quot;", '"', $t );
$t = str_replace( "&#039;", "'", $t );
return $t;
}
/*-------------------------------------------------------------------------*/
// INTERNAL: Encodes a string to make it safe (uses cdata)
/*-------------------------------------------------------------------------*/
function _xml_encode_string( $v )
{
if ( preg_match( "/['\"\[\]<>&]/", $v ) )
{
$v = "<![CDATA[" . $this->_xml_convert_safecdata($v) . "]]>";
}
if ( $this->collapse_newlines )
{
$v = str_replace( "\r\n", "\n", $v );
}
return $v;
}
/*-------------------------------------------------------------------------*/
// INTERNAL: Ensures no embedding of cdata
/*-------------------------------------------------------------------------*/
function _xml_convert_safecdata( $v )
{
$v = str_replace( "<![CDATA[", "<!¢|CDATA|", $v );
$v = str_replace( "]]>" , "|¢]>" , $v );
return $v;
}
/*-------------------------------------------------------------------------*/
// INTERNAL: Uncoverts safe embedding
/*-------------------------------------------------------------------------*/
function _xml_unconvert_safecdata( $v )
{
$v = str_replace( "<!¢|CDATA|", "<![CDATA[", $v );
$v = str_replace( "|¢]>" , "]]>" , $v );
return $v;
}
}
?>
+431
View File
@@ -0,0 +1,431 @@
<?php
/*
+--------------------------------------------------------------------------
| Invision Power Board v2.0.0
| =============================================
| by Matthew Mecham
| (c) 2001 - 2004 Invision Power Services, Inc.
| http://www.invisionpower.com
| =============================================
| Web: http://www.invisionboard.com
| Time: Tue, 21 Sep 2004 16:34:28 GMT
| Release: 150aa7a702c3c8b6f6eb90ad49305d2f
| Licence Info: http://www.invisionboard.com/?license
+---------------------------------------------------------------------------
|
| > XML ARCHIVE CLASS: Handling methods (KERNEL)
| > Module written by Matt Mecham
| > Date started: 25th February
|
| > Module Version Number: 1.0.0
+--------------------------------------------------------------------------
USAGE:
$xmlarchive = new class_xmlarchive();
$xmlarchive->xml_add_file( 'some/dir/filename.html' );
$xmlarchive->xml_add_file_contents( $data, 'some/dir/filename.html' );
$xmlarchive->xml_add_file( 'some/dir/filename.html', array( 'custom_tag' => $value ) );
$xmlarchive->xml_add_file_contents( $data, 'some/dir/filename.html', array( 'custom_tag' => $value ) );
$xmlarchive->xml_add_directory( 'some/dir' );
$xmlarchive->xml_create_archive();
$xmlarchive->xml_save( 'filename.xml' );
$xmlarchive->xml_save_gzip( 'filename.xml.gz' );
$contents = $xmlarchive->xml_get_contents();
$xmlarchive->xml_read_archive( 'filename.xml' );
$xmlarchive->xml_read_archive_data( $xml_data );
ERROR NUMBERS:
--------------
001: No such directory or file
002: Not a directory
003: Could not write archive to disk
004: No XML document to save
005: Could not load xml data
*/
class class_xmlarchive
{
var $xml = "";
var $file_array = array();
var $error_number = 0;
var $error_message = "";
var $workfiles = array();
var $non_binary = 'txt htm html xml css js cgi php php3';
var $strip_path = "";
/*-------------------------------------------------------------------------*/
// CONSTRUCTOR
/*-------------------------------------------------------------------------*/
function class_xmlarchive()
{
$tmp = "";
//-----------------------------------
// Get the XML class
//-----------------------------------
require_once( 'class_xml.php' );
$this->xml = new class_xml();
$this->error_number = 0;
}
/*-------------------------------------------------------------------------*/
// READ Archive from disk
/*-------------------------------------------------------------------------*/
function xml_read_archive( $filename )
{
if ( file_exists( $filename ) )
{
if ( strstr( $filename, '.gz' ) )
{
if ( $FH = @gzopen( $filename, 'r' ) )
{
$data = @gzread( $FH, $filename );
@gzclose( $FH );
}
else
{
$this->error_number = '005';
}
}
else
{
if ( $FH = @fopen( $filename, 'r' ) )
{
$data = @fread( $FH, filesize( $filename ) );
@fclose( $FH );
}
else
{
$this->error_number = '005';
}
}
$this->xml_read_archive_data( $data );
}
else
{
$this->error_number = '001';
}
}
/*-------------------------------------------------------------------------*/
// READ Archive from data
/*-------------------------------------------------------------------------*/
function xml_read_archive_data( $data )
{
if ( $data )
{
$this->xml->xml_parse_document( $data );
if ( is_array( $this->xml->xml_array ) )
{
$this->file_array = array();
foreach( $this->xml->xml_array['xmlarchive']['fileset']['file'] as $idx => $entry )
{
$this_array = array();
foreach ( $entry as $k => $v )
{
if ( $k == 'content' )
{
$v['VALUE'] = base64_decode( preg_replace( "/\s/", "", $entry['content']['VALUE'] ) );
}
$this_array[ $k ] = $v['VALUE'];
}
$this->file_array[] = $this_array;
}
}
}
}
/*-------------------------------------------------------------------------*/
// SAVE XML to disk
/*-------------------------------------------------------------------------*/
function xml_save_gzip( $filename )
{
if ( $this->xml->xml_document )
{
if ( $FH = @gzopen( $filename, 'wb' ) )
{
@gzwrite( $FH, $this->xml->xml_document, strlen( $this->xml->xml_document ) );
@gzclose( $FH );
}
else
{
$this->error_number = '003';
}
}
else
{
$this->error_number = '004';
}
}
/*-------------------------------------------------------------------------*/
// SAVE XML to disk
/*-------------------------------------------------------------------------*/
function xml_save( $filename )
{
if ( $this->xml->xml_document )
{
if ( $FH = @fopen( $filename, 'wb' ) )
{
@fwrite( $FH, $this->xml->xml_document, strlen( $this->xml->xml_document ) );
@fclose( $FH );
}
else
{
$this->error_number = '003';
}
}
else
{
$this->error_number = '004';
}
}
/*-------------------------------------------------------------------------*/
// XML get contents
/*-------------------------------------------------------------------------*/
function xml_get_contents()
{
return $this->xml->xml_document;
}
/*-------------------------------------------------------------------------*/
// Create the XML archive
/*-------------------------------------------------------------------------*/
function xml_create_archive()
{
$this->xml->xml_set_root( 'xmlarchive', array( 'generator' => 'IPB', 'created' => time() ) );
$this->xml->xml_add_group( 'fileset' );
$entry = array();
foreach( $this->file_array as $f )
{
$content = array();
foreach ( $f as $k => $v )
{
if ( $k == 'content' )
{
$v = chunk_split(base64_encode($v));
}
$content[] = $this->xml->xml_build_simple_tag( $k, $v );
}
$entry[] = $this->xml->xml_build_entry( 'file', $content );
}
$this->xml->xml_add_entry_to_group( 'fileset', $entry );
$this->xml->xml_format_document();
}
/*-------------------------------------------------------------------------*/
// Add directory contents
/*-------------------------------------------------------------------------*/
function xml_add_directory( $dir )
{
$this->error_number = "";
//-----------------------------------
// Got dir?
//-----------------------------------
if ( ! is_dir($dir) )
{
$this->error_number = '001';
return FALSE;
}
//-----------------------------------
// Populate this->workfiles
//-----------------------------------
$this->workfiles = array();
$this->_xml_get_dir_contents( $dir );
//-----------------------------------
// Add them into the file array
//-----------------------------------
foreach ( $this->workfiles as $f )
{
$this->xml_add_file( $f );
}
$this->workfiles = array();
}
/*-------------------------------------------------------------------------*/
// Add File (interface to file_contents)
/*-------------------------------------------------------------------------*/
function xml_add_file( $filename, $extra_tags=array() )
{
//-----------------------------------
// Kill OS X hidden files
//-----------------------------------
if ( preg_match( "/\.ds_store/i", $filename ) )
{
return;
}
if ( file_exists( $filename ) )
{
if ( $FH = @fopen( $filename, 'rb' ) )
{
$data = @fread( $FH, filesize( $filename ) );
@fclose( $FH );
}
$this->xml_add_file_contents( $data, $filename, $extra_tags );
}
else
{
$this->error_number = '001';
}
}
/*-------------------------------------------------------------------------*/
// Add File Contents
/*-------------------------------------------------------------------------*/
function xml_add_file_contents( $data, $filename, $extra_tags=array() )
{
$ext = preg_replace( "/.*\.(.+?)$/", "\\1", $filename );
$binary = 1;
//-----------------------------------
// ASCII?
//-----------------------------------
if ( strstr( ' '.$this->non_binary.' ', ' '.$ext.' ' ) )
{
$binary = 0;
}
//-----------------------------------
// Get dir / filename
//-----------------------------------
$dir_path = array();
$dir_path = explode( "/", $filename );
if ( count( $dir_path ) )
{
$real_filename = array_pop( $dir_path );
}
$real_filename = $real_filename ? $real_filename : $filename;
$path = implode( "/", $dir_path );
if ( $this->strip_path )
{
$path = preg_replace( "#". preg_quote($this->strip_path, '#')."/?#", "", $path );
}
$this_array = array(
'filename' => $real_filename,
'content' => $data,
'path' => $path,
'binary' => $binary
);
foreach( $extra_tags as $k => $v )
{
if ( $k and ! in_array( $k, array_keys($this_array) ) )
{
$this_array[ $k ] = $v;
}
}
$this->file_array[] = $this_array;
}
/*-------------------------------------------------------------------------*/
// INTERNAL: Get directory contents
/*-------------------------------------------------------------------------*/
function _xml_get_dir_contents( $dir )
{
$dir = preg_replace( "#/$#", "", $dir );
if ( file_exists($dir) )
{
if ( is_dir($dir) )
{
$handle = opendir($dir);
while (($filename = readdir($handle)) !== false)
{
if (($filename != ".") && ($filename != ".."))
{
if ( is_dir( $dir."/".$filename ) )
{
//-----------------------------------
// Recurse
//-----------------------------------
$this->_xml_get_dir_contents($dir."/".$filename);
}
else
{
//-----------------------------------
// Add file to list
//-----------------------------------
$this->workfiles[] = $dir."/".$filename;
}
}
}
closedir($handle);
}
else
{
$this->error_number = '002';
return FALSE;
}
}
else
{
$this->error_number = '001';
return;
}
}
}
?>
+1
View File
@@ -0,0 +1 @@
<html>␍<head><title>Invision Power Board - Bulletin Board System</title></head>␍<body>␍<h1>403: Invision Power Board -> Forbidden</h1>␍<hr>␍You have reached this Page in error, please use␍your back button to return to Invision Board.␍<hr>␍<a href="http://www.invisionboard.com/">Invision Power Board</a>␍</body>␍</html>␍