[Owp-cvs] owp config.php,NONE,1.1
Status: Inactive
Brought to you by:
scader
From: <owp...@li...> - 2006-04-14 00:49:55
|
Update of /cvsroot/owp/owp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16187 Added Files: config.php Log Message: added config routines --- NEW FILE: config.php --- <?php /* Copyright (c) 2006, 2realities Group All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of the 2realities Group nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /**Configuration routines * @author Artem Sidorenko <sc...@us...> * @version $Id: config.php,v 1.1 2006/04/14 00:49:42 scader Exp $ * @package owp * @copyright (c) 2004-2006 2realities Group (www.2realities.com) */ //some constants /**dir with config files*/ define('dirs_config','config'); /**include configs dir, in the config dir*/ define('dirs_config_includes','includes'); /**extension of config files*/ define('files_ext_config','ini'); /**name of main config file*/ define('files_main_config','config'); /**default separator in paths and other things*/ define('separator',':'); #processing our config files //making list of config files $config_files[]=dirs_config."/".files_main_config.".".files_ext_config;//main config $path_config_includes = dirs_config."/".dirs_config_includes."/";//path to the includes dir //reading dir $dir_config_includes_descr = opendir($path_config_includes); //looking for config files while($element = readdir($dir_config_includes_descr)){ $path = $path_config_includes.$element; if(!is_file($path)) continue; $data = pathinfo($path); if(files_ext_config!=$data['extension']) continue; $config_files[]=$path;//adding to the list of config files unset($data,$path);//cleaning }//\\while closedir($dir_config_includes_descr);//closing dir //cleaning unset($path_config_includes,$dir_config_includes_descr,$element); //processing our config files foreach($config_files as $v){ $config_file = parse_ini_file($v,true); //processing php settings if(isset($config_file['php'])){ foreach($config_file['php'] as $key=>$value){ switch($key){ case 'include_path'://adding new include paths //old paths $old = ini_get('include_path'); //splitting to array $t_array = split(PATH_SEPARATOR,$old); //converting to realpaths and cleaning foreach($t_array as $t_k=>$t_v){ if(trim($t_v)==''){ unset($t_array[$t_k]); continue; }//\\if $t_v = realpath($t_v); if(trim($t_v)=='') unset($t_array[$t_k]); else $t_array[$t_k]=$t_v; }//\\foreach //splitting new paths $t_arrayn = split(separator,$value); //converting to realpaths and cleaning foreach($t_arrayn as $t_k=>$t_v){ if(trim($t_v)==''){ unset($t_arrayn[$t_k]); continue; }//\\if $t_v = realpath($t_v); if(trim($t_v)=='') unset($t_arrayn[$t_k]); else $t_arrayn[$t_k]=$t_v; }//\\foreach //joining paths $t_arrayr = array_merge($t_array,$t_arrayn); //converting to string $new = join(PATH_SEPARATOR,$t_arrayr); //setting new var ini_set($key,$new); //cleaning temp vars unset($t_array,$t_arrayn,$t_arrayr,$old,$new,$t_k,$t_v); break; default: ini_set($key,$value); break; }//\\switch }//\\foreach unset($config_file['php']);//deleting our php part }//\\if(processing php settings) //processing our settings foreach($config_file as $part=>$options) foreach($options as $key=>$value) /** @ignore*/ define($part."_".$key,$value); unset($config_file);//cleaning }//\\foreach //cleaning unset($v,$config_files); //defining some standard settings /**dir with template sources*/ @ define('dirs_templates','tpl/templates'); /**dir for compiled templates*/ @ define('dirs_templates_compiled','tpl/compiled'); ?> |