⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 install.php

📁 网络硬盘_支持1GB文件上传和续传_无错版
💻 PHP
📖 第 1 页 / 共 2 页
字号:
<?php/*+--------------------------------------------------------------------------|   Auto installer v1.0|   ========================================|   by Stephen Yabziz|   (c) 2005 YABSoft Services|   http://www.yabsoft.com|   ========================================|   Web: http://www.yabsoft.com|   Email: ywyhnchina@163.com+---------------------------------------------------------------------------||   > Script written by Stephen Yabziz|   > Date started: 7th Jan 2006+--------------------------------------------------------------------------*/class install {	var $config = array();    var $vars   = array();    var $lang   = array();    var $_begin = '##';    var $_end   = '##';    var $_begin2= '!#';    var $_end2  = '!#';    var $step   = 0;    var $class_hash = '9acb78c4ad37d315f572ed01ac6148b7';    var $debug  = true;    	function install( $ini='' )    {        if(!file_exists($ini)) exit("Fata error:Install config file $ini can not be found!");        $this->config = parse_ini_file($ini,1);        $info=$this->getSection('INSTALL');        $this->_begin  = $info['var_begin'];        $this->_end    = $info['var_end'];        $this->_begin2 = $info['lng_begin'];        $this->_end2   = $info['lng_end'];        $this->debug   = $info['debug'];                if(!is_file('lang/'.$info['lang'].'.php')) return '';        include_once( 'lang/'.$info['lang'].'.php' );        $this->lang    = $lang;	}    /**    * decide to extract the source file for the install or not    */    function checkAutoInstall()    {    global $input;        $info=$this->getSection('INSTALL');        $this->auto_install = intval($info[auto_install]==1&&!file_exists($info[install_dir].'/'.$info[check_file]));        if($this->auto_install==1&&$this->step!=-2) $this->step = -1;        elseif($this->step==-1)        {            if(isset($input['back'])) $this->step = -2;            if(isset($input['continue'])) $this->step = 0;        }        $this->install_data = $info[install_data];        $this->install_dir  = dirname(getcwd());//$info[install_dir];    }    /**    * dectect the envoiment before the install    */    function detectENV()    {        $vars=$this->getSection('REQUIRMENT');        foreach($vars as $var=>$val)        {            list($type,$num)=explode('.',$var);            $pos=strpos($val,':');            list($name,$okmsg,$warnmsg)=split(':',$val);            if($type=='module')            {                $ok=extension_loaded($name);            }            elseif($type=='dir')            {                $ok=is_writable($this->install_dir.'/'.$name);            }            elseif($type=='function')            {                $ok=function_exists($name);            }            else            {                $ok=0;            }            $msg=$ok?$this->evalLang($okmsg):$this->evalLang($warnmsg);            $this->results[$type][]=array('status'=>$ok,'name'=>($name),'descr'=>ucfirst($msg));        }    }    /**    * $result=array('status'=>$ok,'name'=>$name,'descr'=>$msg)    */    function addENVResult($type,$result)    {        if(!empty($type))$this->results[$type][]=$result;    }       /**    * write config file:eval the predefined value of file content    */    function writeConfig()    {        $vars=$this->getSection('CONFIG');        foreach($vars as $sfile => $dfile)        {            if(file_exists('config/'.$sfile))            {                $ok = 1;                $content=$this->evalValue(file_get_contents ('config/'.$sfile));                if(!$fp=@fopen($this->install_dir.'/'.$dfile,'wb')) $ok=0;                if(!@fputs($fp,$content)) $ok=0;                @fclose($fp);                $return[$this->install_dir.'/'.$dfile]=array($ok,$content);            }            elseif($sfile)            $this->debug("CONFIG File [config/$sfile] Lost");        }        return $return;    }    /**    * form display funtion    */    function printFormHeader()    {        echo "<form action='?' method=POST>";    }    function printFormFooter()    {        switch($this->step)        {        case '-3' :            $continue = "Continue";            break;        case '-2' :            $continue = $this->auto_install?"Extract the source":"Begin install";            break;        case '-1' :            $continue = "Continue";            break;        case '0' :            $continue = $this->can_install?"Continue":"Refresh";            break;        case '1' :            $continue = "Register";            break;        case '2' :            $continue = "Continue";            break;        case '3' :            $continue = "Install";            break;        case '4' :            $continue = "Finish";            break;        case '5' :            $continue = "Continue";            break;        }        echo "<input type=hidden name=step value='$this->step'>";        echo ($this->step==-1||$this->step==-2||$this->step==-3?'':"<input type=submit name=back value='back'>");        echo ($this->step==5?'':"<input type=submit name=".($this->step!=0||$this->can_install?'continue':'refresh')." value='$continue'>");        if($this->step==0&&!$this->can_install) echo "<input type=submit name='continue' value='Ignore'>";        echo "</form>";    }    function buildForm()    {        $this->loadCustom();        $vars=$this->getSection('SECTION');        foreach($this->fields as $group=>$fields)        {            printHeader($this->evalLang($vars[$group]));            foreach($fields as $name => $field)            {                $data=array('name'=>$this->evalLang($name),'descr'=>$this->evalLang($field[descr]),'value'=>!empty($this->vars[$name])&&$field[type]=='text'?$this->evalValue($this->vars[$name]):$this->evalValue($this->evalLang($field[value])),'type'=>$field[type]);                printRow($data);            }            printFooter();        }    }    function loadCustom()    {        $vars=$this->getSection('CUSTOM');        foreach($vars as $var=>$val)        {            list($group,$type,$name)=explode('.',$var);            $pos=strpos($val,':');            if($pos===false) $pos=strlen($val);            $this->fields[$group][$name]=array('value'=>substr($val,$pos+1),'descr'=>substr($val,0,$pos),'type'=>$type);        }    }    function buildHiddenFields()    {        $vars=$this->getSection('CUSTOM');        foreach($vars as $var=>$val)        {            list($group,$type,$name)=explode('.',$var);            if($type=='hidden') echo "<input type=hidden name=$name value=".$this->evalLang($val).">";        }    }    /**    * assign value from user input to the var defined in ini file    */    function assignVars($input)    {        $vars=$this->getSection('CUSTOM');        foreach($vars as $var=>$val)        {            list($group,$type,$name)=explode('.',$var);            $this->vars[$name]=$input[$name];        }        $vars=$this->getSection('MYSQL');        foreach($vars as $var=>$val)        {            $this->vars[$var]=$input[$var];        }        $this->vars=array_intersect($this->vars,$input);                if(dirname($_SERVER[PHP_SELF])!='/')        $guessurl=$baseWeb="http://".$_SERVER[HTTP_HOST].dirname($_SERVER[PHP_SELF]);        else        $guessurl=$baseWeb="http://".$_SERVER[HTTP_HOST];        $this->addVar('scriptUrl',dirname($guessurl));        $this->addVar('scriptDir',dirname(getcwd()));        $this->addVar('remotesqlhost',$_SERVER[HTTP_HOST]);        $this->addVar('scriptDomain',substr(dirname($guessurl),7));        $this->addVar('cgiUrl',substr(dirname($guessurl),7).'/cgi-bin');        $this->addVar('downloadDir',dirname(getcwd()).'/data/files/');        $this->addVar('backupDir',dirname(getcwd()).'/data/backup/');    }    /**    * add single var to $this->vars    */    function addVar($name,$value)    {        if(!empty($name))$this->vars[$name]=$value;    }    /**    * execute the custom query defined in ini file    */    function execSQLQuery()    {        $this->sqlQuery=$this->getSection('QUERY');        $return = array();        foreach($this->sqlQuery as $query)        {            $return[] = $this->evalValue($query);        }        return $return;    }    /**    * execute the external sql file in the directory "sql"    */    function execSQLFile()    {        $sqlfiles=$this->getSection('SQLFILE');        $SQL = $return = array();        foreach($sqlfiles as $sqlfile)        {            if(file_exists('sql/'.$sqlfile)&&strlen($sqlfile))            $SQL=array_merge($SQL,readSqlFile('sql/'.$sqlfile));            elseif($sqlfile)            $this->debug("SQL File [sql/$sqlfile] Lost");        }        foreach($SQL as $query)        {            $return[] = $this->evalValue($query);        }        return $return;    }    /**    * execute the custom script located in directory inc    */    function execINC($step,$location='start')    {        $incs=$this->getSection('INC');        $file=$incs['inc.'.$step.'.'.$location];        if(file_exists('inc/'.$file)&&strlen($file))        require_once('inc/'.$file);        elseif($file)        $this->debug("INC File [inc/$file] Lost");                return true;        foreach($incs as $inc=>$file)        {            list($inc,$step,$location)=explode('.',$var);            if(file_exists('inc/'.$file)&&strlen($file)&&$step==$install_step)            require_once('inc/'.$file);        }    }    function evalValue($str)    {        return preg_replace('/('.$this->_begin.')([a-zA-Z0-9\_]+)('.$this->_end.')/ieU','$this->vars[\\2]',$str);    }    function evalLang($str)    {        return preg_replace('/('.$this->_begin2.')([a-zA-Z0-9\_]+)('.$this->_end2.')/ieU','$this->lang[\\2]',$str);    }    function getSection($name)    {        return $this->config[$name];    }    function debug($text)    {        if($this->debug) echo $text;    }}function readSqlFile($sqlfile){global  $cfg,$table_prefix,$input;    $sql_query='';    $ext=strtolower(strrchr(basename($sqlfile),'.'));    if($ext=='.sql')    {        $sql_query = @fread(@fopen($sqlfile, 'r'), @filesize($sqlfile));    }    else    {        $zp = gzopen($sqlfile, "r");        if ($zp)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -