[UseBook-Checkins] UseBook/sources core.php,1.4,1.5 db_mysql.php,1.3,1.4 db_mysqli.php,1.3,1.4 funct
Status: Inactive
Brought to you by:
pc_freak
|
From: Vandamme S. <kid...@us...> - 2005-07-28 10:16:35
|
Update of /cvsroot/usebook/UseBook/sources In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13141/sources Modified Files: core.php db_mysql.php db_mysqli.php functions.php page_foot.php page_head.php template.php Log Message: UseBook 0.3 RC Index: functions.php =================================================================== RCS file: /cvsroot/usebook/UseBook/sources/functions.php,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** functions.php 7 Jul 2005 16:40:42 -0000 1.4 --- functions.php 28 Jul 2005 10:16:19 -0000 1.5 *************** *** 30,33 **** --- 30,46 ---- exit(); + + // + // Replacement for htmlspecialchars() + // Doesn't mess up Cyrillic (and other) characters + // which are sent in entities by a browser + // + function unhtml($string) { + + return preg_replace(array('#&#', '#&\#([0-9]+)#', '#&\#(160|173|8192|8193|8194|8195|8196|8197|8198|8199|8120|8201|8202|8203|8204|8205|8206|8207)#', '#<#', '#>#', '#"#'), array('&', '&#\\1', '&#\\1', '<', '>', '"'), $string); + + } + + class functions { // *************** *** 396,400 **** function make_url($filename, $vars=array(), $html=true) { - if ( $this->get_config('friendly_urls') && $filename != 'admin.php' ) { --- 409,412 ---- Index: page_head.php =================================================================== RCS file: /cvsroot/usebook/UseBook/sources/page_head.php,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** page_head.php 3 Jun 2005 15:32:10 -0000 1.3 --- page_head.php 28 Jul 2005 10:16:19 -0000 1.4 *************** *** 37,42 **** 'character_encoding' => $character_encoding, 'language_code' => ( !empty($lang['language_code']) ) ? $lang['language_code'] : 'en', ! 'css_url' => 'css.php', 'gb_name' => $functions->get_config('gb_name'), 'gb_descr' => $functions->get_config('gb_descr') )); --- 37,43 ---- 'character_encoding' => $character_encoding, 'language_code' => ( !empty($lang['language_code']) ) ? $lang['language_code'] : 'en', ! 'css_url' => ROOT_PATH.'css.php', 'gb_name' => $functions->get_config('gb_name'), + 'gb_url' => $functions->make_url(ROOT_PATH.'index.php'), 'gb_descr' => $functions->get_config('gb_descr') )); Index: db_mysql.php =================================================================== RCS file: /cvsroot/usebook/UseBook/sources/db_mysql.php,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** db_mysql.php 3 Jun 2005 15:32:10 -0000 1.3 --- db_mysql.php 28 Jul 2005 10:16:19 -0000 1.4 *************** *** 2,18 **** /* ! Copyright (C) 2005 UseBook Team ! http://usebook.sourceforge.net $Header$ ! This file is part of UseBook. ! UseBook is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. ! UseBook is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- 2,18 ---- /* ! Copyright (C) 2003-2005 UseBB Team ! http://www.usebb.net $Header$ ! This file is part of UseBB. ! UseBB is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. ! UseBB is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *************** *** 20,24 **** You should have received a copy of the GNU General Public License ! along with UseBook; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ --- 20,24 ---- You should have received a copy of the GNU General Public License ! along with UseBB; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ *************** *** 33,36 **** --- 33,38 ---- trigger_error('Unable to load module for database server "mysql": PHP mysql extension not available!'); + @ini_set('mysql.trace_mode', '0'); + // // Create the MySQL handlers *************** *** 43,47 **** var $connection; var $queries = array(); - var $results = array(); // --- 45,48 ---- *************** *** 65,76 **** // Execute database queries // ! function query($query) { global $functions; $this->queries[] = preg_replace('#\s+#', ' ', $query); ! $result = @mysql_query($query, $this->connection) or trigger_error('SQL: '.mysql_error()); ! if ( $functions->get_config('auto_free_sql_results') && is_resource($result) ) ! $this->results[] = $result; return $result; --- 66,83 ---- // Execute database queries // ! function query($query, $return_error=false) { global $functions; $this->queries[] = preg_replace('#\s+#', ' ', $query); ! $result = @mysql_query($query, $this->connection) or $error = mysql_error(); ! if ( isset($error) ) { ! ! if ( $return_error ) ! return $error; ! else ! trigger_error('SQL: '.$error); ! ! } return $result; *************** *** 114,129 **** // ! // Disconnect the database connection // ! function disconnect() { ! global $functions; ! if ( $functions->get_config('auto_free_sql_results') ) { ! ! foreach ( $this->results as $result ) ! @mysql_free_result($result); ! ! } @mysql_close($this->connection); --- 121,139 ---- // ! // Get server version info // ! function get_server_info() { ! return array( ! 'MySQL', ! mysql_get_server_info($this->connection) ! ); ! } ! ! // ! // Disconnect the database connection ! // ! function disconnect() { @mysql_close($this->connection); Index: template.php =================================================================== RCS file: /cvsroot/usebook/UseBook/sources/template.php,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** template.php 3 Jun 2005 15:32:11 -0000 1.3 --- template.php 28 Jul 2005 10:16:19 -0000 1.4 *************** *** 2,18 **** /* ! Copyright (C) 2005 UseBook Team ! http://usebook.sourceforge.net $Header$ ! This file is part of UseBook. ! UseBook is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. ! UseBook is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- 2,18 ---- /* ! Copyright (C) 2003-2005 UseBB Team ! http://www.usebb.net $Header$ ! This file is part of UseBB. ! UseBB is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. ! UseBB is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *************** *** 20,24 **** You should have received a copy of the GNU General Public License ! along with UseBook; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ --- 20,24 ---- You should have received a copy of the GNU General Public License ! along with UseBB; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ *************** *** 38,47 **** // Variables // var $parse_special_templates_only = false; ! var $loaded_sections=array(); ! var $templates=array(); ! var $requests=array(); ! var $global_vars=array(); ! var $body=''; // --- 38,62 ---- // Variables // + var $content_type = ''; + var $character_encoding = ''; var $parse_special_templates_only = false; ! var $loaded_sections = array(); ! var $templates = array(); ! var $requests = array(); ! var $global_vars = array(); ! var $raw_contents = array(); ! var $body = ''; ! ! // ! // Activate gzip compression if needed, BEFORE doing a session_start() ! // ! function template() { ! ! global $functions; ! ! if ( !defined('NO_GZIP') && ( $functions->get_config('output_compression') === 2 || $functions->get_config('output_compression') === 3 ) && !@ini_get('zlib.output_compression') ) ! ob_start('ob_gzhandler'); ! ! } // *************** *** 75,84 **** global $functions; - // - // Load the template set - // $this->load_section('global'); ! if ( isset($this->templates['global']['config'][$setting]) ) return $this->templates['global']['config'][$setting]; elseif ( !$functions->get_config('hide_undefined_template_setting_warnings') ) --- 90,96 ---- global $functions; $this->load_section('global'); ! if ( array_key_exists($setting, $this->templates['global']['config']) ) return $this->templates['global']['config'][$setting]; elseif ( !$functions->get_config('hide_undefined_template_setting_warnings') ) *************** *** 106,110 **** if ( !array_key_exists($name, $this->templates[$section]) ) { ! if ( !$config['hide_undefined_template_warnings'] ) trigger_error('Unable to load "'.$name.'" template in '.$section.' templates file for set "'.$functions->get_config('template').'"!'); else --- 118,122 ---- if ( !array_key_exists($name, $this->templates[$section]) ) { ! if ( !$functions->get_config('hide_undefined_template_warnings') ) trigger_error('Unable to load "'.$name.'" template in '.$section.' templates file for set "'.$functions->get_config('template').'"!'); else *************** *** 124,132 **** // Add global template variables // ! function add_global_vars($variables) { foreach ( $variables as $key => $val ) { ! if ( !array_key_exists($key, $this->global_vars) ) $this->global_vars[$key] = $val; --- 136,144 ---- // Add global template variables // ! function add_global_vars($variables, $override=false) { foreach ( $variables as $key => $val ) { ! if ( $override || !array_key_exists($key, $this->global_vars) ) $this->global_vars[$key] = $val; *************** *** 145,149 **** 'page_title' => strip_tags($page_title), 'location_bar' => '<a href="'.$functions->make_url('index.php').'">'.unhtml($functions->get_config('board_name')).'</a>'.$this->get_config('locationbar_item_delimiter').$page_title ! )); } --- 157,186 ---- 'page_title' => strip_tags($page_title), 'location_bar' => '<a href="'.$functions->make_url('index.php').'">'.unhtml($functions->get_config('board_name')).'</a>'.$this->get_config('locationbar_item_delimiter').$page_title ! ), true); ! ! } ! ! // ! // Add raw content, used for the ACP ! // ! function add_raw_content($content) { ! ! $this->requests[] = array( ! 'raw' => true, ! 'num' => count($this->raw_contents) ! ); ! ! $this->raw_contents[] = $content; ! ! } ! ! // ! // Set the Javascript onload statement ! // ! function set_js_onload($statement) { ! ! $this->add_global_vars(array( ! 'js_onload' => ' onload="javascript:'.$statement.'"' ! ), true); } *************** *** 152,163 **** // Output the page body // ! function body($enable_debugmessages=true) { ! global $db, $functions, $timer, $lang; // // Debug features // ! if ( $functions->get_config('debug') && $enable_debugmessages ) { // --- 189,214 ---- // Output the page body // ! function body() { ! global $db, $functions, $timer, $lang, $session; ! ! // ! // Eventually set the content type and charset ! // ! $content_type = $this->get_config('content_type'); ! if ( empty($this->content_type) ) ! $this->content_type = ( !empty($content_type) ) ? $content_type : 'text/html'; ! if ( empty($this->character_encoding) ) ! $this->character_encoding = $lang['character_encoding']; ! ! // ! // Set content type and charset ! // ! header('Content-Type: '.$this->content_type.'; charset='.$this->character_encoding); // // Debug features // ! if ( $functions->get_config('debug') ) { // *************** *** 166,170 **** $timer['end'] = explode(' ', microtime()); $timer['end'] = (float)$timer['end'][1] + (float)$timer['end'][0]; ! $parsetime = round($timer['end'] - $timer['begin'], 2); $debug_info = array(); --- 217,221 ---- $timer['end'] = explode(' ', microtime()); $timer['end'] = (float)$timer['end'][1] + (float)$timer['end'][0]; ! $parsetime = round($timer['end'] - $timer['begin'], 4); $debug_info = array(); *************** *** 189,193 **** // $debug_info_small = ''; ! $debug_info_large = sprintf($this->get_config('debug_info_large'), '<div><strong>'.$lang['DebugMode'].'</strong>'.$this->get_config('item_delimiter').join($this->get_config('item_delimiter'), $debug_info).':</div><textarea rows="10" cols="50" readonly="readonly">'.join("\n\n", $db->get_used_queries()).'</textarea>'); } --- 240,244 ---- // $debug_info_small = ''; ! $debug_info_large = sprintf($this->get_config('debug_info_large'), '<div><strong>'.$lang['DebugMode'].'</strong>'.$this->get_config('item_delimiter').join($this->get_config('item_delimiter'), $debug_info).':</div><textarea rows="10" cols="50" readonly="readonly">'.unhtml(join("\n\n", $db->get_used_queries())).'</textarea>'); } *************** *** 205,214 **** --- 256,287 ---- // + // Add some global template variables such as content type and charset + // + $this->add_global_vars(array( + 'content_type' => $this->content_type, + 'character_encoding' => $this->character_encoding, + 'language_code' => ( !empty($lang['language_code']) ) ? $lang['language_code'] : 'en', + 'text_direction' => ( !empty($lang['text_direction']) ) ? $lang['text_direction'] : 'ltr', + 'img_dir' => ROOT_PATH.'templates/'.$functions->get_config('template').'/gfx/', + 'css_url' => ROOT_PATH.'templates/'.$functions->get_config('template').'/styles.css', + 'acp_css_head_link' => ( $session->sess_info['location'] == 'admin' ) ? '<link rel="stylesheet" type="text/css" href="'.ROOT_PATH.'templates/'.$functions->get_config('template').'/admin.css" />' : '', + 'js_onload' => '' + )); + + // // Parse all templates // foreach ( $this->requests as $request ) { + if ( isset($request['raw']) ) { + + $this->body .= "\n".$this->raw_contents[$request['num']]."\n"; + continue; + + } + $current_template = $this->templates[$request['section']][$request['template_name']]; $finds = $replaces = array(); + if ( preg_match('#\{l_[a-zA-Z]+\}#', $current_template) ) { *************** *** 225,230 **** } ! $request['variables']['img_dir'] = ROOT_PATH.'templates/'.$functions->get_config('template').'/gfx/'; $request['variables'] = array_merge($this->global_vars, $request['variables']); foreach ( $request['variables'] as $key => $val ) { --- 298,304 ---- } ! $request['variables'] = array_merge($this->global_vars, $request['variables']); + foreach ( $request['variables'] as $key => $val ) { *************** *** 233,241 **** } ! foreach ( $replaces as $key => $val ) { ! $replaces[$key] = preg_replace(array('#\{#', '#\}#'), array('{', '}'), $val); ! ! } $current_template = preg_replace($finds, $replaces, $current_template); $this->body .= $current_template; --- 307,314 ---- } ! ! foreach ( $replaces as $key => $val ) $replaces[$key] = preg_replace(array('#\{#', '#\}#'), array('{', '}'), $val); ! $current_template = preg_replace($finds, $replaces, $current_template); $this->body .= $current_template; Index: db_mysqli.php =================================================================== RCS file: /cvsroot/usebook/UseBook/sources/db_mysqli.php,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** db_mysqli.php 3 Jun 2005 15:32:10 -0000 1.3 --- db_mysqli.php 28 Jul 2005 10:16:19 -0000 1.4 *************** *** 2,18 **** /* ! Copyright (C) 2005 UseBook Team ! http://usebook.sourceforge.net $Header$ ! This file is part of UseBook. ! UseBook is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. ! UseBook is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- 2,18 ---- /* ! Copyright (C) 2003-2005 UseBB Team ! http://www.usebb.net $Header$ ! This file is part of UseBB. ! UseBB is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. ! UseBB is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *************** *** 20,24 **** You should have received a copy of the GNU General Public License ! along with UseBook; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ --- 20,24 ---- You should have received a copy of the GNU General Public License ! along with UseBB; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ *************** *** 33,36 **** --- 33,38 ---- trigger_error('Unable to load module for database server "mysqli": PHP mysqli extension not available!'); + @ini_set('mysql.trace_mode', '0'); + // // Create the MySQL handlers *************** *** 43,47 **** var $connection; var $queries = array(); - var $results = array(); // --- 45,48 ---- *************** *** 65,76 **** // Execute database queries // ! function query($query) { global $functions; $this->queries[] = preg_replace('#\s+#', ' ', $query); ! $result = @mysqli_query($query, $this->connection) or trigger_error('SQL: '.mysqli_error()); ! if ( $functions->get_config('auto_free_sql_results') && is_resource($result) ) ! $this->results[] = $result; return $result; --- 66,83 ---- // Execute database queries // ! function query($query, $return_error=false) { global $functions; $this->queries[] = preg_replace('#\s+#', ' ', $query); ! $result = @mysqli_query($query, $this->connection) or $error = mysqli_error(); ! if ( isset($error) ) { ! ! if ( $return_error ) ! return $error; ! else ! trigger_error('SQL: '.$error); ! ! } return $result; *************** *** 114,129 **** // ! // Disconnect the database connection // ! function disconnect() { ! global $functions; ! if ( $functions->get_config('auto_free_sql_results') ) { ! ! foreach ( $this->results as $result ) ! @mysqli_free_result($result); ! ! } @mysqli_close($this->connection); --- 121,139 ---- // ! // Get server version info // ! function get_server_info() { ! return array( ! 'MySQL (mysqli)', ! mysqli_get_server_info($this->connection) ! ); ! } ! ! // ! // Disconnect the database connection ! // ! function disconnect() { @mysqli_close($this->connection); Index: core.php =================================================================== RCS file: /cvsroot/usebook/UseBook/sources/core.php,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** core.php 7 Jul 2005 16:40:42 -0000 1.4 --- core.php 28 Jul 2005 10:16:19 -0000 1.5 *************** *** 76,81 **** // Create objects // - $template = new template(); $functions = new functions(); // --- 76,81 ---- // Create objects // $functions = new functions(); + $template = new template(); // Index: page_foot.php =================================================================== RCS file: /cvsroot/usebook/UseBook/sources/page_foot.php,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** page_foot.php 3 Jun 2005 15:32:10 -0000 1.3 --- page_foot.php 28 Jul 2005 10:16:19 -0000 1.4 *************** *** 33,37 **** // Footer // ! $template->parse('normal_footer', 'global'); // --- 33,40 ---- // Footer // ! $template->parse('normal_footer', 'global', array( ! 'url_admin' => $functions->make_url(ROOT_PATH.'admin/admin.php'), ! 'url_stats' => $functions->make_url(ROOT_PATH.'stats.php') ! )); // |