示例#1
0
 public function showstep()
 {
     if ($this->step == 0) {
         //默认系统显示
         include "templates/index.tpl";
     }
     if ($this->step == 1) {
         //第一步安装,首先清空指定目录下的文件
         $this->clearcontent('safe', true);
         $this->clearcontent('caches', false);
         $this->clearcontent('admin_safe_ims/logs', false);
         $this->clearcontent('templates/templates_compile/', false);
         include "templates/step1.tpl";
     }
     if ($this->step == 2) {
         $host = trim($_POST["dhost"]);
         $database = trim($_POST["dname"]);
         $user = trim($_POST["duname"]);
         $passwd = trim($_POST["dpasswd"]);
         $prefix = trim($_POST["dprefix"]);
         //往配置文件里写入数据库信息
         $conffile = file_get_contents(MSGROOT . "config.simple.php");
         $pattern = array("/(cfg\\[\"dbhost\"\\]=)([^;]+);/i", "/(cfg\\[\"dbuser\"\\]=)([^;]+);/i", "/(cfg\\[\"dbpassword\"\\]=)([^;]+);/i", "/(cfg\\[\"dbname\"\\]=)([^;]+);/i", "/(cfg\\[\"prefix\"\\]=)([^;]+);/i");
         $replace = array("\$1 " . "\"" . $host . "\";", "\$1 " . "\"" . $user . "\";", "\$1 " . "\"" . $passwd . "\";", "\$1 " . "\"" . $database . "\";", "\$1 " . "\"" . $prefix . "\";");
         $conffile = preg_replace($pattern, $replace, $conffile);
         //创建数据库
         $sql = trim(file_get_contents(MSGROOT . "install/install.sql"));
         $sql_arr = explode("Create table ims_", $sql);
         array_shift($sql_arr);
         require MSGROOT . "include/db.class.php";
         $mysql = new Mysql($host, $user, $passwd, $database, $prefix);
         foreach ($sql_arr as $sql) {
             $sql = "Create table ims_" . $sql;
             $mysql->setQuery($sql);
             $mysql->query();
         }
         $error1 = $mysql->get_error();
         //获取要创建的用户名和密码
         $admin = trim($_POST['uname']);
         $name = trim($_POST['trname']);
         $upasswd = sha1(trim($_POST['upasswd']));
         $createuser = "******"{$admin}\",\"{$upasswd}\",1,\"{$name}\")";
         $mysql->setQuery($createuser);
         $mysql->query();
         $error2 = $mysql->get_error();
         if ($error1 > 0 || $error2 > 0) {
             echo "安装过程中似乎哪里出错了,请检查或者手动编辑根目录下的config.simple.php并改名为config.php文件";
         } else {
             echo "系统安装成功,正在转向管理后台!";
             //写入安装锁定文件
             file_put_contents(MSGROOT . "install/install.lock", "If you want to reinstall the system,please remove this file!");
             //写入新的配置文件
             file_put_contents(MSGROOT . "config.php", $conffile);
             echo "<script>setTimeout(function(){window.location.href=\"../admin_safe_ims/\";},1500);</script>";
         }
     }
 }
示例#2
0
文件: post.php 项目: hitoy/domai-ims
//把留言内容拼接成数组,并添加到留言对象当中
$maindata = array("name" => $name, "email" => $email, "message" => $message, "tel" => $tel, "company" => $company, "product" => $product, "country" => $country, "url" => $url, "lang" => $lang);
$msg_ins->setmaindata($maindata);
//获取sql语言,如果返回结果为数字,则是因为必填项不合法
$sql = $msg_ins->getsql();
//如果$sql为整数,则用户输入出现错误,否则,则提交数据库
if (gettype($sql) == "integer") {
    $errorcode = $sql;
    showui($errorcode);
    //goto view;
    exit;
} else {
    //加载数据库类,并实例化
    require_once MSGROOT . "include/db.class.php";
    $mysql = new Mysql($sysconf->dbhost, $sysconf->dbuser, $sysconf->dbpassword, $sysconf->dbname, $sysconf->prefix, $sysconf->lang);
    $mysql->setQuery($sql);
    $mysql->query();
    //获取mysql的执行错误代码
    $errorcode = $mysql->get_error();
    showui($errorcode);
    exit;
}
//其它未知错误
$errorcode = 8;
showui($errorcode);
//当检查到错误代码出现时,直接程序直接跳转到这里
//执行结果展示
//PHP5.2以上版本
function showui($errorcode)
{
    $cachefile = MSGROOT . "caches/caches_" . $lang . "_" . $errorcode . ".html";
示例#3
0
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
//初始化后台路径
define("ADMINROOT", str_replace("\\", "/", dirname(__FILE__)) . "/");
//系统的安装目录
define("MSGROOT", dirname(ADMINROOT) . "/");
//加载系统配置,并实例化
require_once ADMINROOT . "../include/conf.class.php";
$sysconf = Conf::getIns();
//加载数据库类
require_once ADMINROOT . "../include/db.class.php";
$mysql = new Mysql($sysconf->dbhost, $sysconf->dbuser, $sysconf->dbpassword, $sysconf->dbname, $sysconf->prefix, $sysconf->lang);
//加载日志类
require_once ADMINROOT . "/log.class.php";
$accesslog = new Logs();
if ($_POST) {
    $username = trim(htmlentities($_POST["username"]), ENT_QUOTES);
    $password = sha1(trim(htmlentities($_POST["password"]), ENT_QUOTES));
    $mysql->setQuery("update ims_user set current_stat=\"offline\" where username=\"{$username}\" and password=\"{$password}\"");
    $mysql->query();
    @$accesslog->setlog($username . "标记自己的状态为离线!");
}
?>
<form action="" method="POST">
<input type="username" name="username"><br/>
<input type="password" name="password"><br/>
<input type="submit" value="SUBMIT"/>
</form>