[ Index ] |
|
Code source de XOOPS 2.0.17.1 |
1 <?php 2 // ------------------------------------------------------------------------ // 3 // XOOPS - PHP Content Management System // 4 // Copyright (c) 2000 XOOPS.org // 5 // <http://www.xoops.org/> // 6 // ------------------------------------------------------------------------ // 7 // This program is free software; you can redistribute it and/or modify // 8 // it under the terms of the GNU General Public License as published by // 9 // the Free Software Foundation; either version 2 of the License, or // 10 // (at your option) any later version. // 11 // // 12 // You may not change or alter any portion of this comment or credits // 13 // of supporting developers from this source code or any supporting // 14 // source code which is considered copyrighted (c) material of the // 15 // original comment or credit authors. // 16 // // 17 // This program is distributed in the hope that it will be useful, // 18 // but WITHOUT ANY WARRANTY; without even the implied warranty of // 19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 20 // GNU General Public License for more details. // 21 // // 22 // You should have received a copy of the GNU General Public License // 23 // along with this program; if not, write to the Free Software // 24 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // 25 // ------------------------------------------------------------------------ // 26 27 /** 28 * mainfile manager for XOOPS installer 29 * 30 * @author Haruki Setoyama <haruki@planewave.org> 31 * @version $Id: mainfilemanager.php 766 2006-10-11 04:43:52Z skalpa $ 32 * @access public 33 **/ 34 class mainfile_manager { 35 36 var $path = '../mainfile.php'; 37 var $distfile = '../mainfile.dist.php'; 38 var $rewrite = array(); 39 40 var $report = ''; 41 var $error = false; 42 43 function mainfile_manager(){ 44 // 45 } 46 47 function setRewrite($def, $val){ 48 $this->rewrite[$def] = $val; 49 } 50 51 function copyDistFile(){ 52 if ( ! copy($this->distfile, $this->path) ) { 53 $this->report .= _NGIMG.sprintf(_INSTALL_L126, "<b>".$this->path."</b>")."<br />\n"; 54 $this->error = true; 55 return false; 56 } 57 $this->report .= _OKIMG.sprintf(_INSTALL_L125, "<b>".$this->path."</b>", "<b>".$this->distfile."</b>")."<br />\n"; 58 return true; 59 } 60 61 function doRewrite(){ 62 clearstatcache(); 63 if ( ! $file = fopen($this->path,"r") ) { 64 $this->error = true; 65 return false; 66 } 67 $content = fread($file, filesize($this->path) ); 68 fclose($file); 69 70 foreach($this->rewrite as $key => $val){ 71 if(is_int($val) && 72 preg_match("/(define\()([\"'])(".$key.")\\2,\s*([0-9]+)\s*\)/",$content)){ 73 74 $content = preg_replace("/(define\()([\"'])(".$key.")\\2,\s*([0-9]+)\s*\)/" 75 , "define('".$key."', ".$val.")" 76 , $content); 77 $this->report .= _OKIMG.sprintf(_INSTALL_L121, "<b>$key</b>", $val)."<br />\n"; 78 } 79 elseif(preg_match("/(define\()([\"'])(".$key.")\\2,\s*([\"'])(.*?)\\4\s*\)/",$content)){ 80 $content = preg_replace("/(define\()([\"'])(".$key.")\\2,\s*([\"'])(.*?)\\4\s*\)/" 81 , "define('".$key."', '". str_replace( '$', '\$', addslashes( $val ) ) ."')" 82 , $content); 83 $this->report .= _OKIMG.sprintf(_INSTALL_L121, "<b>$key</b>", $val)."<br />\n"; 84 }else{ 85 $this->error = true; 86 $this->report .= _NGIMG.sprintf(_INSTALL_L122, "<b>$val</b>")."<br />\n"; 87 } 88 } 89 90 if ( !$file = fopen($this->path,"w") ) { 91 $this->error = true; 92 return false; 93 } 94 95 if ( fwrite($file,$content) == -1 ) { 96 fclose($file); 97 $this->error = true; 98 return false; 99 } 100 101 fclose($file); 102 103 return true; 104 } 105 106 function report(){ 107 $content = "<table align='center'><tr><td align='left'>\n"; 108 $content .= $this->report; 109 $content .= "</td></tr></table>\n"; 110 return $content; 111 } 112 113 function error(){ 114 return $this->error; 115 } 116 } 117 118 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Nov 25 11:44:32 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |