Version 2.1.7
This commit is contained in:
1 parent
0eecc172d9
commit
f73f8bff6d
941 files changed
+215301
-103093
No files matched your search
@@ -2,16 +2,28 @@
|
||||
|
||||
/*
|
||||
+--------------------------------------------------------------------------
|
||||
| Invision Power Board v2.0.0
|
||||
| Invision Power Board 2.1.7
|
||||
| =============================================
|
||||
| by Matthew Mecham
|
||||
| (c) 2001 - 2004 Invision Power Services, Inc.
|
||||
| (c) 2001 - 2005 Invision Power Services, Inc.
|
||||
| http://www.invisionpower.com
|
||||
| =============================================
|
||||
| Web: http://www.invisionboard.com
|
||||
| Time: Tue, 21 Sep 2004 16:34:28 GMT
|
||||
| Release: 150aa7a702c3c8b6f6eb90ad49305d2f
|
||||
| http://www.ibresource.ru/products/invisionpowerboard/
|
||||
| Time: Tuesday 18th of July 2006 05:56:00 PM
|
||||
| Release: 52f408a29988b02f45b5e6f4ba5af0ae
|
||||
| Licence Info: http://www.invisionboard.com/?license
|
||||
| http://www.ibresource.ru/license
|
||||
+---------------------------------------------------------------------------
|
||||
| INVISION POWER BOARD IS NOT FREE / OPEN SOURCE!
|
||||
+---------------------------------------------------------------------------
|
||||
| INVISION POWER BOARD ÍÅ ßÂËßÅÒÑß ÁÅÑÏËÀÒÍÛÌ ÏÐÎÃÐÀÌÌÍÛÌ ÎÁÅÑÏÅ×ÅÍÈÅÌ!
|
||||
| Ïðàâà íà ÏÎ ïðèíàäëåæàò Invision Power Services
|
||||
| Ïðàâà íà ïåðåâîä IBResource (http://www.ibresource.ru)
|
||||
+---------------------------------------------------------------------------
|
||||
| > $Date: 2005-10-10 14:03:20 +0100 (Mon, 10 Oct 2005) $
|
||||
| > $Revision: 22 $
|
||||
| > $Author: matt $
|
||||
+---------------------------------------------------------------------------
|
||||
|
|
||||
| > Template Engine module (KERNEL)
|
||||
@@ -22,31 +34,86 @@
|
||||
+--------------------------------------------------------------------------
|
||||
| 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>
|
||||
|
|
||||
+--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* IPS Kernel Pages: Template Engine
|
||||
*
|
||||
* This class contains all generic functions to handle
|
||||
* converting HTML logic to PHP code and vice-versa
|
||||
*
|
||||
* Example Usage:
|
||||
* <code>
|
||||
* <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>
|
||||
* </code>
|
||||
*
|
||||
* @package IPS_KERNEL
|
||||
* @author Matt Mecham
|
||||
* @copyright Invision Power Services, Inc.
|
||||
* @version 2.1
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Template Engine
|
||||
*
|
||||
* Methods and functions for handling file uploads
|
||||
*
|
||||
* @package IPS_KERNEL
|
||||
* @author Matt Mecham
|
||||
* @version 2.1
|
||||
*/
|
||||
class class_template
|
||||
{
|
||||
/**
|
||||
* Root path
|
||||
*
|
||||
* @var string File Path
|
||||
*/
|
||||
var $root_path = './';
|
||||
|
||||
/**
|
||||
* Cache directory
|
||||
*
|
||||
* @var string Directory
|
||||
*/
|
||||
var $cache_dir = 'skin_cache';
|
||||
|
||||
/**
|
||||
* Cache ID
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
var $cache_id = '1';
|
||||
|
||||
/**
|
||||
* Database ID
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
var $database_id = '1';
|
||||
|
||||
/**
|
||||
* Cache path
|
||||
*
|
||||
* @var string File Path
|
||||
*/
|
||||
var $cache_path = '';
|
||||
|
||||
function class_template()
|
||||
@@ -58,7 +125,17 @@ class class_template
|
||||
// Convert HTML to PHP cache file
|
||||
//===================================================
|
||||
|
||||
function convert_html_to_php($func_name, $func_data, $func_html)
|
||||
/**
|
||||
* Wrapper function to convert HTML logic to PHP code
|
||||
*
|
||||
* @param string Function name (eg: show_active_users)
|
||||
* @param string Function data (The input variables)
|
||||
* @param string Function HTML (The actual HTML)
|
||||
* @param string Function description (Not used in IPB)
|
||||
* @return string Converted HTML code as a PHP function
|
||||
*/
|
||||
|
||||
function convert_html_to_php($func_name, $func_data, $func_html, $func_desc="")
|
||||
{
|
||||
//-------------------------------
|
||||
// Make sure we have ="" on each
|
||||
@@ -68,10 +145,10 @@ class class_template
|
||||
$func_data = preg_replace( "#".'\$'."(\w+)(,|$)#i", "\$\\1=\"\"\\2", str_replace( " ", "", $func_data ) );
|
||||
|
||||
$top = "//===========================================================================\n".
|
||||
"// {$func_name}\n".
|
||||
"// <ips:{$func_name}:desc:{$func_desc}>\n".
|
||||
"//===========================================================================\n";
|
||||
|
||||
$start = "function {$func_name}($func_data) {\nglobal \$ibforums;\n\$IPBHTML = \"\";\n//--starthtml--//\n";
|
||||
$start = "function {$func_name}($func_data) {\n\$IPBHTML = \"\";\n//--starthtml--//\n";
|
||||
$middle = $this->build_section_html_to_php($func_html);
|
||||
$end = "\n//--endhtml--//\nreturn \$IPBHTML;\n}\n";
|
||||
|
||||
@@ -82,6 +159,12 @@ class class_template
|
||||
// Alias: Convert PHP to HTML
|
||||
//===================================================
|
||||
|
||||
/**
|
||||
* Wrapper function to convert PHP to HTML logic
|
||||
*
|
||||
* @param string PHP Code
|
||||
* @return string Converted PHP code as HTML code
|
||||
*/
|
||||
function convert_php_to_html($php)
|
||||
{
|
||||
return $this->_convert_php_to_html($php);
|
||||
@@ -102,6 +185,12 @@ class class_template
|
||||
// - Makes PHP cache of raw HTML
|
||||
//===================================================
|
||||
|
||||
/**
|
||||
* Work function to convert HTML logic to PHP code
|
||||
*
|
||||
* @param string HTML logic
|
||||
* @return string PHP code block
|
||||
*/
|
||||
function build_section_html_to_php($html="")
|
||||
{
|
||||
|
||||
@@ -123,7 +212,7 @@ class class_template
|
||||
// Non-logic from between?
|
||||
//----------------------------------------
|
||||
|
||||
$html = preg_replace( "#(}//endif|}//endelse)(.+?)(//startif|else)#ise", "\$this->_wrap_in_php('\\2', '\\3', '\\1');", $html );
|
||||
$html = preg_replace( "#(}//endif|}//endelse)(.+?)(//startif|//startelse|else if)#ise", "\$this->_wrap_in_php('\\2', '\\3', '\\1');", $html );
|
||||
|
||||
//$html = str_replace( "}//endif//startif", "}//endif\n//startif", $html );
|
||||
|
||||
@@ -150,6 +239,12 @@ class class_template
|
||||
$html = preg_replace( "#^(.*}//endif)(.+?)$#ise", "\$this->_wrap_in_php('\\2', '', '\\1');", $html );
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------
|
||||
// Clean up
|
||||
//----------------------------------------
|
||||
|
||||
$html = preg_replace( "#//startelse\s+?//startelse#is", "//startelse", $html );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -169,11 +264,22 @@ class class_template
|
||||
// Convert special tags into HTML safe versions
|
||||
//===================================================
|
||||
|
||||
/**
|
||||
* Convert PHP tags to HTML logic safe tags
|
||||
*
|
||||
* @param string HTML/PHP data
|
||||
* @return string Converted Data
|
||||
*/
|
||||
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 );
|
||||
$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 );
|
||||
|
||||
# IPB 2.1+ Kernel
|
||||
$t = preg_replace( "/{?\\\$this->ipsclass->base_url}?/" , "{ipb.script_url}" , $t );
|
||||
$t = preg_replace( "/{?\\\$this->ipsclass->session_id}?/" , "{ipb.session_id}" , $t );
|
||||
$t = preg_replace( "#\\\$this->ipsclass->(member|vars|skin|lang|input)#i" , "ipb.\\1", $t );
|
||||
|
||||
//----------------------------------------
|
||||
// Make some tags safe..
|
||||
@@ -188,6 +294,12 @@ class class_template
|
||||
// Uncovert them back again
|
||||
//===================================================
|
||||
|
||||
/**
|
||||
* Convert HTML tags to PHP tags
|
||||
*
|
||||
* @param string HTML/PHP data
|
||||
* @return string Converted Data
|
||||
*/
|
||||
function unconvert_tags($t="")
|
||||
{
|
||||
//----------------------------------------
|
||||
@@ -196,9 +308,10 @@ class class_template
|
||||
|
||||
$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 );
|
||||
# IPB 2.1+ Kernel
|
||||
$t = preg_replace( "/{ipb\.script_url}/i" , '{$this->ipsclass->base_url}' , $t);
|
||||
$t = preg_replace( "/{ipb\.session_id}/i" , '{$this->ipsclass->session_id}', $t);
|
||||
$t = preg_replace( "#ipb\.(member|vars|skin|lang|input)#i", '$this->ipsclass->\\1' , $t );
|
||||
|
||||
return $t;
|
||||
}
|
||||
@@ -207,6 +320,14 @@ class class_template
|
||||
// Wrap HTML into PHP
|
||||
//===================================================
|
||||
|
||||
/**
|
||||
* Wrap PHP code in HEREDOC tags
|
||||
*
|
||||
* @param string Main HTML code
|
||||
* @param string After Code
|
||||
* @param string Before Code
|
||||
* @return string Converted Data
|
||||
*/
|
||||
function _wrap_in_php( $html, $after="", $before="" )
|
||||
{
|
||||
$html = $this->_trim_newlines($this->_trim_slashes($html));
|
||||
@@ -232,12 +353,18 @@ class class_template
|
||||
// Convert: HTML Logic to PHP logic
|
||||
//===================================================
|
||||
|
||||
/**
|
||||
* Convert HTML tags to PHP tags
|
||||
*
|
||||
* @param string HTML/PHP data
|
||||
* @return string Converted Data
|
||||
*/
|
||||
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+?)?<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 );
|
||||
$html = preg_replace( "#(?:\s+?)?<else>(.+?)</else>#ise" , "\$this->_statement_else('\\1')" , $html );
|
||||
|
||||
return $html;
|
||||
}
|
||||
@@ -246,11 +373,17 @@ class class_template
|
||||
// Convert: PHP logic to HTML logic
|
||||
//===================================================
|
||||
|
||||
/**
|
||||
* Convert PHP tags to HTML tags
|
||||
*
|
||||
* @param string PHP data
|
||||
* @return string Converted Data
|
||||
*/
|
||||
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 );
|
||||
$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
|
||||
@@ -269,7 +402,8 @@ class class_template
|
||||
// Remove start ifs
|
||||
//----------------------------------------
|
||||
|
||||
$php = str_replace( "//startif\n", "\n", $php );
|
||||
$php = str_replace( "//startif\n" , "\n", $php );
|
||||
$php = str_replace( "//startelse\n", "\n", $php );
|
||||
|
||||
//----------------------------------------
|
||||
// Remove extra spaces
|
||||
@@ -290,6 +424,14 @@ class class_template
|
||||
// Reverse: PHP IF to HTML IF
|
||||
//===================================================
|
||||
|
||||
/**
|
||||
* Reverse the IF tag
|
||||
*
|
||||
* @param string PHP Variables / Operators
|
||||
* @param string PHP data
|
||||
* @param string Tag start
|
||||
* @return string Converted Data
|
||||
*/
|
||||
function _reverse_if( $code, $php, $start='if' )
|
||||
{
|
||||
$code = $this->_trim_slashes(trim($code));
|
||||
@@ -298,13 +440,18 @@ class class_template
|
||||
$php = $this->_reverse_ipbhtml($php);
|
||||
|
||||
return "<".$start."=\"".trim($code)."\">\n".$php."\n</if>\n";
|
||||
|
||||
}
|
||||
|
||||
//===================================================
|
||||
// Reverse: PHP else to HTML else
|
||||
//===================================================
|
||||
|
||||
/**
|
||||
* Reverse the ELSE tag
|
||||
*
|
||||
* @param string PHP Data
|
||||
* @return string Converted Data
|
||||
*/
|
||||
function _reverse_else( $php )
|
||||
{
|
||||
$php = $this->_trim_slashes(trim($php));
|
||||
@@ -312,13 +459,18 @@ class class_template
|
||||
$php = $this->_reverse_ipbhtml($php);
|
||||
|
||||
return "<else>\n".$php."\n</else>\n";
|
||||
|
||||
}
|
||||
|
||||
//===================================================
|
||||
// Reverse: $IPBHTML to normal $HTML
|
||||
//===================================================
|
||||
|
||||
/**
|
||||
* Reverse HEREDOC tags
|
||||
*
|
||||
* @param string Raw PHP Data
|
||||
* @return string Converted Data
|
||||
*/
|
||||
function _reverse_ipbhtml( $code )
|
||||
{
|
||||
$code = $this->_trim_slashes($code);
|
||||
@@ -335,13 +487,22 @@ class class_template
|
||||
// Reverse PHP IF code to HTML code
|
||||
//===================================================
|
||||
|
||||
/**
|
||||
* Prepare: Reverse PHP IF code to HTML safe code
|
||||
*
|
||||
* @param string
|
||||
* @param string
|
||||
* @param string
|
||||
* @param string
|
||||
* @return string Converted Data
|
||||
*/
|
||||
function _reverse_prep_left($left, $andor="", $fs="", $ls="")
|
||||
{
|
||||
$left = trim($this->_trim_slashes($left));
|
||||
|
||||
if ( preg_match( "/".'\$'."ibforums->/", $left ) )
|
||||
if ( preg_match( "/".'\$'."this->ipsclass->/", $left ) )
|
||||
{
|
||||
$left = preg_replace( "/".'\$'."ibforums->(.+?)$/", 'ipb.'."\\1", $left );
|
||||
$left = preg_replace( "/".'\$'."this->ipsclass->(.+?)$/", 'ipb.'."\\1", $left );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -355,6 +516,13 @@ class class_template
|
||||
// Statement: Return PHP 'IF' statement
|
||||
//===================================================
|
||||
|
||||
/**
|
||||
* Prepare: If code
|
||||
*
|
||||
* @param string If code
|
||||
* @param string HTML
|
||||
* @return string Converted Data
|
||||
*/
|
||||
function _statement_if( $code, $html )
|
||||
{
|
||||
$html = $this->_func_prep_html($html);
|
||||
@@ -367,6 +535,13 @@ class class_template
|
||||
// Statement: Return PHP 'ELSE IF' statement
|
||||
//===================================================
|
||||
|
||||
/**
|
||||
* Prepare: Else If code
|
||||
*
|
||||
* @param string Else If code
|
||||
* @param string HTML
|
||||
* @return string Converted Data
|
||||
*/
|
||||
function _statement_elseif( $code, $html )
|
||||
{
|
||||
$html = $this->_func_prep_html($html);
|
||||
@@ -379,11 +554,17 @@ class class_template
|
||||
// Statement: Return PHP 'ELSE' statement
|
||||
//===================================================
|
||||
|
||||
/**
|
||||
* Prepare: Else code
|
||||
*
|
||||
* @param string HTML
|
||||
* @return string Converted Data
|
||||
*/
|
||||
function _statement_else( $html )
|
||||
{
|
||||
$html = $this->_func_prep_html($html);
|
||||
|
||||
return "\nelse\n{\n\$IPBHTML .= <<<EOF\n$html\nEOF;\n}//endelse\n";
|
||||
return "\n//startelse\nelse\n{\n\$IPBHTML .= <<<EOF\n$html\nEOF;\n}//endelse\n";
|
||||
}
|
||||
|
||||
|
||||
@@ -410,7 +591,7 @@ class class_template
|
||||
|
||||
if ( preg_match( "/^ipb\./", $left ) )
|
||||
{
|
||||
$left = preg_replace( "/^ipb\.(.+?)$/", '$ibforums->'."\\1", $left );
|
||||
$left = preg_replace( "/^ipb\.(.+?)$/", '$this->ipsclass->'."\\1", $left );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user