Esempio n. 1
0
 public function run($a = null, $b = null)
 {
     $this->assign('a', $a);
     $this->assign('b', $b);
     //检测缓存目录
     $runtime = F('runtimeauth');
     if (empty($runtime)) {
         $runtime = check_dir_iswritable(RUNTIME_PATH);
         F('runtimeauth', $runtime);
     }
     $this->assign('runtimestatus', $runtime);
     //		$download = F('downloadauth');
     //		if (empty($download)) {
     //			$download = check_dir_iswritable(C('DOWNLOAD_UPLOAD.rootPath'));
     //			F('downloadauth', $download);
     //		}
     //		$this->assign('downloadstatus', $download);
     $picture = F('pictureauth');
     if (empty($picture)) {
         $picture = check_dir_iswritable('.' . C('FILE_UPLOAD.rootPath') . '/');
         F('pictureauth', $picture);
     }
     $this->assign('picturestatus', $picture);
     $edit = F('editauth');
     if (empty($edit)) {
         $edit = check_dir_iswritable(C('EDITOR_UPLOAD.rootPath'));
         F('editauth', $edit);
     }
     $this->assign('editstatus', $edit);
     //取缓存目录大小
     $dirsize = F('dirsize');
     if (empty($dirsize)) {
         $dirsize = get_dir_size($rutimepath = str_replace(MODULE_NAME . '/', '', RUNTIME_PATH)) / 1000 . 'k';
         F('dirsize', $dirsize);
     }
     $runsize = F('runtimecachesize');
     if (empty($runsize)) {
         $runsize = '';
     }
     $this->assign('runsize', $runsize);
     //取上传目录大小
     $data = F('uploadssizecache');
     if (empty($data)) {
         $data = '';
     }
     $this->assign('uploadssize', $data);
     $this->display('content');
 }
Esempio n. 2
0
function show_env_result(&$env_items, &$dirfile_items, &$func_items)
{
    $env_str = $file_str = $dir_str = $func_str = '';
    $error_code = 0;
    foreach ($env_items as $key => $item) {
        if ($key == 'php' && strcmp($item['current'], $item['r']) < 0) {
            show_msg($lang['php_version_too_low'], 0);
        }
        $status = 1;
        if ($item['r'] != 'notset') {
            if (intval($item['current']) && intval($item['r'])) {
                if (intval($item['current']) < intval($item['r'])) {
                    $status = 0;
                    $error_code = ENV_ERROR;
                }
            } else {
                if (strcmp($item['current'], $item['r']) < 0) {
                    $status = 0;
                    $error_code = ENV_ERROR;
                }
            }
        }
        if (KEKE_OFF) {
            $env_str .= "\t\t<runCondition name=\"{$key}\" status=\"{$status}\" Require=\"{$item['r']}\" Best=\"{$item['b']}\" Current=\"{$item['current']}\"/>\n";
        } else {
            $env_str .= "<tr>\n";
            $env_str .= "<td>" . keke_lang($key) . "</td>\n";
            $env_str .= "<td class=\"padleft\">" . keke_lang($item['r']) . "</td>\n";
            $env_str .= "<td class=\"padleft\">" . keke_lang($item['b']) . "</td>\n";
            $env_str .= "</tr>\n";
        }
    }
    foreach ($dirfile_items as $key => $item) {
        $tagname = $item['type'] == 'file' ? 'File' : 'Dir';
        $variable = $item['type'] . '_str';
        if (KEKE_OFF) {
            if ($item['status'] == 0) {
                $error_code = ENV_ERROR;
            }
            ${$variable} .= "\t\t\t<File name=\"{$item['path']}\" status=\"{$item['status']}\" requirePermisson=\"+r+w\" currentPermisson=\"{$item['current']}\" />\n";
        } else {
            ${$variable} .= "<tr>\n";
            ${$variable} .= "<td>{$item['path']}</td>";
            if (!is_dir($item[path])) {
                ${$variable} .= "<td class=\"nw pdleft1\">" . keke_lang('nodir') . "</td>\n";
                $error_code = 2;
            } else {
                if (check_dir_iswritable($item[path])) {
                    ${$variable} .= "<td class=\"w pdleft1\">" . keke_lang('writeable') . "</td>\n";
                } else {
                    ${$variable} .= "<td class=\"nw pdleft1\">" . keke_lang('unwriteable') . "</td>\n";
                    $error_code = 2;
                }
            }
            ${$variable} .= "<td class=\"w pdleft1\">" . keke_lang('writeable') . "</td>\n";
            ${$variable} .= "</tr>\n";
        }
    }
    if (KEKE_OFF) {
        $str = "<root>\n";
        $str .= "\t<runConditions>\n";
        $str .= $env_str;
        $str .= "\t</runConditions>\n";
        $str .= "\t<FileDirs>\n";
        $str .= "\t\t<Dirs>\n";
        $str .= $dir_str;
        $str .= "\t\t</Dirs>\n";
        $str .= "\t\t<Files>\n";
        $str .= $file_str;
        $str .= "\t\t</Files>\n";
        $str .= "\t</FileDirs>\n";
        $str .= "\t<error errorCode=\"{$error_code}\" errorMessage=\"\" />\n";
        $str .= "</root>";
        echo $str;
        exit;
    } else {
        show_header();
        echo '<div class="step"><ul><li class="current"><em><strong>1</strong></em>检测环境</li><li><em>2</em>创建数据</li><li><em>3</em>完成安装</li></ul><div class="server">';
        echo '<table width="100%"><tbody><tr><td class="td1"width="161px">环境检测</td><td class="td1" width="161px">当前服务器</td><td class="td1" width="161px">PHPYUN. 最佳</td></tr>';
        echo $env_str;
        echo '</tbody></table>';
        echo '<table width="100%"><tbody><tr><td class="td1">目录、文件权限检查</td><td class="td1" width="25%">当前状态</td><td class="td1" width="25%">所需状态</td></tr>';
        echo $file_str;
        echo $dir_str;
        echo '</tbody></table>';
        echo '<table width="100%"><tbody><tr><td class="td1">函数名称</td><td class="td1" width="25%">检查结果</td><td class="td1" width="25%">建议</td></tr>';
        foreach ($func_items as $item) {
            $status = function_exists($item);
            $func_str .= "<tr>\n";
            $func_str .= "<td>{$item}()</td>\n";
            if ($status) {
                $func_str .= "<td class=\"w pdleft1\">" . keke_lang('supportted') . "</td>\n";
                $func_str .= "<td class=\"padleft\">" . keke_lang('supportted') . "</td>\n";
            } else {
                $error_code = ENV_ERROR;
                $func_str .= "<td class=\"nw pdleft1\">" . keke_lang('unsupportted') . "</td>\n";
                $func_str .= "<td><font color=\"red\">" . keke_lang('advice_' . $item) . "</font></td>\n";
            }
        }
        echo $func_str;
        echo '</tbody></table>';
        echo '</div></div><div class="bottom">';
        echo '<input type="button" value="重新检测" onclick="location.href=\'index.php?step=checkset\'" class="submit">';
        if ($error_code == 2) {
            echo '<input type="button" value="检查出错,安装无法继续" onclick="window.close();" class="submit_az">';
        } else {
            echo '<input type="button" value="下一步" onclick="location.href=\'index.php?step=sql\'" class="submit">';
        }
        echo '</div>';
        show_footer();
    }
}
Esempio n. 3
0
 public function index()
 {
     if (file_exists(CONF_PATH . "install.lock")) {
         $this->error("请勿重复安装!");
     }
     if (!file_exists(getcwd() . "/Public/sql/5khrm.sql")) {
         $this->error("缺少必要的数据库文件!");
     }
     if ($_POST['submit']) {
         @set_time_limit(1000);
         $db_config['DB_TYPE'] = 'mysql';
         $db_config['DB_HOST'] = $_POST['DB_HOST'];
         $db_config['DB_PORT'] = $_POST['DB_PORT'];
         $db_config['DB_NAME'] = $_POST['DB_NAME'];
         $db_config['DB_USER'] = $_POST['DB_USER'];
         $db_config['DB_PWD'] = $_POST['DB_PWD'];
         $db_config['DB_PREFIX'] = $_POST['DB_PREFIX'];
         $name = $_POST['name'];
         $password = $_POST['password'];
         $warnings = array();
         if (empty($db_config['DB_HOST'])) {
             $warnings[] = '请填写数据库主机';
         }
         if (empty($db_config['DB_PORT'])) {
             $warnings[] = '请填写数据库端口';
         }
         if (preg_match('/[^0-9]/', $db_config['DB_PORT'])) {
             $warnings[] = '数据库端口只能是数字';
         }
         if (empty($db_config['DB_NAME'])) {
             $warnings[] = '请填写数据库名';
         }
         if (empty($db_config['DB_USER'])) {
             $warnings[] = '请填写数据库用户名';
         }
         if (empty($db_config['DB_PREFIX'])) {
             $warnings[] = '请填写表前缀';
         }
         if (preg_match('/[^a-z0-9_]/i', $db_config['DB_PREFIX'])) {
             $warnings[] = '表前缀只能包含数字、字母和下划线';
         }
         if (empty($name)) {
             $warnings[] = '请填写管理员用户名';
         }
         if (empty($password)) {
             $warnings[] = '请填写管理员密码';
         }
         if (empty($warnings)) {
             $connect = mysql_connect($db_config['DB_HOST'] . ":" . $db_config['DB_PORT'], $db_config['DB_USER'], $db_config['DB_PWD']);
             if (!$connect) {
                 $warnings[] = '数据库连接失败,请检查配置!';
             } else {
                 if (!mysql_select_db($db_config['DB_NAME'])) {
                     if (!mysql_query("create database " . $db_config['DB_NAME'] . " DEFAULT CHARACTER SET utf8")) {
                         $warnings[] = '没有找到您填写的数据库名且无法创建!请检查连接账号是否有创建数据库的权限!';
                     }
                 }
             }
             if (!check_dir_iswritable(APP_PATH . 'Runtime')) {
                 $warnings[] = APP_PATH . 'Runtime 文件夹要求有写权限!';
             }
             if (!check_dir_iswritable(CONF_PATH)) {
                 $warnings[] = CONF_PATH . '文件夹要求有写权限!';
             }
         }
         if (empty($warnings)) {
             $db_config_str = "<?php\r\n";
             $db_config_str .= "return array(\r\n";
             foreach ($db_config as $k => $v) {
                 $db_config_str .= "'" . $k . "'=>'" . $v . "',\r\n";
                 C($k, $v);
             }
             $db_config_str .= ");";
             if (file_put_contents(CONF_PATH . "db.php", $db_config_str)) {
                 $sql = file_get_contents(getcwd() . "/Public/sql/5khrm.sql");
                 $db = M();
                 $sql = str_replace("\r\n", "", $sql);
                 $sql = str_replace("hr_", C('DB_PREFIX'), $sql);
                 $queries = explode(";\n", $sql);
                 foreach ($queries as $val) {
                     if (trim($val)) {
                         $db->query($val);
                     }
                 }
                 $salt = substr(md5(time()), 0, 4);
                 $password = md5(md5(trim($password)) . $salt);
                 $db->query('insert into ' . C('DB_PREFIX') . 'user (user_id, category_id, position_id, status, name, password, salt, reg_ip, reg_time) values (1, 1, 1, 1, "' . $name . '", "' . $password . '", "' . $salt . '", "' . get_client_ip() . '", ' . time() . ')');
                 touch(CONF_PATH . "install.lock");
             }
             $this->display('install');
         } else {
             $this->assign('warnings', $warnings);
             $this->display();
         }
     } else {
         $this->assign('errors', $this->checkEnv());
         $this->display();
     }
 }
Esempio n. 4
0
function check_dir_iswritable($dir_path)
{
    $dir_path = str_replace('\\', '/', $dir_path);
    $is_writale = 1;
    if (!is_dir($dir_path)) {
        $is_writale = 0;
        return $is_writale;
    } else {
        $file_hd = @fopen($dir_path . '/test.txt', 'w');
        if (!$file_hd) {
            $is_writale = 0;
            return $is_writale;
        } else {
            @fclose($file_hd);
            @unlink($dir_path . '/test.txt');
        }
        $dir_hd = opendir($dir_path);
        while (false !== ($file = readdir($dir_hd))) {
            if ($file != "." && $file != "..") {
                if (is_file($dir_path . '/' . $file)) {
                    //文件不可写,直接返回
                    if (!is_writable($dir_path . '/' . $file)) {
                        return 0;
                    }
                } else {
                    $file_hd2 = @fopen($dir_path . '/' . $file . '/test.txt', 'w');
                    if (!$file_hd2) {
                        @fclose($file_hd2);
                        $is_writale = 0;
                        return $is_writale;
                    } else {
                        @fclose($file_hd);
                        @unlink($dir_path . '/test.txt');
                    }
                    //递归
                    $is_writale = check_dir_iswritable($dir_path . '/' . $file);
                }
            }
        }
    }
    return $is_writale;
}
 public function step4()
 {
     if (file_exists(CONF_PATH . "install.lock")) {
         $this->error(L('PLEASE_DO_NOT_REPEAT_INSTALLATION'), U('Install/step3'));
     }
     if (!file_exists(getcwd() . "/Public/sql/5kcrm.sql")) {
         $this->error(L('LACK_THE_NECESSARY_DATABASE_FILES'), U('Install/step3'));
     }
     if ($this->isPost()) {
         $db_config['DB_TYPE'] = 'mysql';
         $db_config['DB_HOST'] = $_POST['DB_HOST'];
         $db_config['DB_PORT'] = $_POST['DB_PORT'];
         $db_config['DB_NAME'] = $_POST['DB_NAME'];
         $db_config['DB_USER'] = $_POST['DB_USER'];
         $db_config['DB_PWD'] = $_POST['DB_PWD'];
         $db_config['DB_PREFIX'] = $_POST['DB_PREFIX'];
         $name = $_POST['name'];
         $password = $_POST['password'];
         $warnings = array();
         if (empty($db_config['DB_HOST'])) {
             $this->error(L('PLEASE_FILL_IN_THE_DATABASE host'), U('Install/step3'));
         }
         if (empty($db_config['DB_PORT'])) {
             $this->error(L('PLEASE_FILL_OUT_THE_DATABASE_PORT host'), U('Install/step3'));
         }
         if (preg_match('/[^0-9]/', $db_config['DB_PORT'])) {
             $this->error(L('DATABASE_PORT_ONLY_NUMBERS'), U('Install/step3'));
         }
         if (empty($db_config['DB_NAME'])) {
             $this->error(L('PLEASE_FILL_IN_THE_DATABASE_NAME'), U('Install/step3'));
         }
         if (empty($db_config['DB_USER'])) {
             $this->error(L('PLEASE_FILL_IN_THE_DATABASE_USER_NAME'), U('Install/step3'));
         }
         if (empty($db_config['DB_PREFIX'])) {
             $this->error(L('PLEASE_FILL_IN_THE_TABLE_PREFIX'), U('Install/step3'));
         }
         if (preg_match('/[^a-z0-9_]/i', $db_config['DB_PREFIX'])) {
             $this->error(L('THE_TABLE_PREFIX_CAN_CONTAIN_ONLY_NUMBERS_LETTERS_AND_UNDERSCORES'), U('Install/step3'));
         }
         if (empty($name)) {
             $this->error(L('PLEASE_FILL_IN_THE_ADMINISTRATOR_USER_NAME'), U('Install/step3'));
         }
         if (empty($password)) {
             $this->error(L('PLEASE_FILL_IN_THE_ADMINISTRATOR_PASSWORD'), U('Install/step3'));
         }
         if (empty($warnings)) {
             $connect = mysql_connect($db_config['DB_HOST'] . ":" . $db_config['DB_PORT'], $db_config['DB_USER'], $db_config['DB_PWD']);
             if (!$connect) {
                 $this->error(L("THE_DATABASE_CONNECTION_FAILED_PLEASE_CHECK_THE_CONFIGURATION"), U('Install/step3'));
             } else {
                 if (!mysql_select_db($db_config['DB_NAME'])) {
                     if (!mysql_query("create database " . $db_config['DB_NAME'] . " DEFAULT CHARACTER SET utf8")) {
                         $this->error(L("DO_NOT_FIND_YOU_FILL_OUT_THE_DATABASE_NAME_AND_CANNOT_BE_CREATED"), U('Install/step3'));
                     }
                 }
             }
             if (!check_dir_iswritable(APP_PATH . 'Runtime')) {
                 $this->error(L("RUNTIME_FOLDER_REQUIRES_WRITE_ACCES", array(APP_PATH)), U('Install/step3'));
             }
             if (!check_dir_iswritable(CONF_PATH)) {
                 $this->error(L("CONF_FOLDER_REQUIRES_WRITE_ACCES", array(CONF_PATH)), U('Install/step3'));
             }
         }
         if (empty($warnings)) {
             $db_config_str = "<?php\r\n";
             $db_config_str .= "return array(\r\n";
             foreach ($db_config as $k => $v) {
                 $db_config_str .= "'" . $k . "'=>'" . $v . "',\r\n";
                 C($k, $v);
             }
             $db_config_str .= ");";
             if (file_put_contents(CONF_PATH . "db.php", $db_config_str)) {
                 $db = M();
                 $sql = file_get_contents(getcwd() . "/Public/sql/5kcrm.sql");
                 $sql = str_replace("5kcrm_", C('DB_PREFIX'), $sql);
                 $sql = str_replace("http://demo.5kcrm.com", __ROOT__, $sql);
                 $sql = str_replace("\r\n", "", $sql);
                 $queries = explode(";\n", $sql);
                 foreach ($queries as $val) {
                     if (trim($val)) {
                         $db->query($val);
                     }
                 }
                 $salt = substr(md5(time()), 0, 4);
                 $password = md5(md5(trim($password)) . $salt);
                 $db->query('insert into ' . C('DB_PREFIX') . 'user (role_id, category_id, status, name, password, salt, reg_ip, reg_time) values (1, 1, 1, "' . $name . '", "' . $password . '", "' . $salt . '", "' . get_client_ip() . '", ' . time() . ')');
                 touch(CONF_PATH . "install.lock");
             }
             $this->display('step4');
         }
     } else {
         $this->error('参数不正确', U('Install/step3'));
     }
 }
} else {
    ?>
<span class="error_span">&radic;</span><?php 
}
?>
</td></tr><tr><td>/App/Runtime</td><td>可写、读</td><td><?php 
if (check_dir_iswritable('./App/Runtime')) {
    ?>
<span class="correct_span">&radic;</span><?php 
} else {
    ?>
<span class="error_span">&radic;</span><?php 
}
?>
</td></tr><tr><td>/App/Conf</td><td>可写、读</td><td><?php 
if (check_dir_iswritable('./App/Conf')) {
    ?>
<span class="correct_span">&radic;</span><?php 
} else {
    ?>
<span class="error_span">&radic;</span><?php 
}
?>
</td></tr></table></div><div class="bottom tac"><a href="javascript:history.go(-1)" class="btn">上一步</a><a id="jump" href="<?php 
echo U('install/step3');
?>
" class="btn">下一步</a></div></section></div><div class="footer">  2013 - 2014 <a href="http://www.inuoer.com" target="_blank">? 2012 - 2015 悟空CRM & 卡卡罗特软件科技有限公司 豫ICP备13004021号</a></div></body><script>	$(function(){
		$("#jump").click(function(){
			if($(".error_span").length > 0){
				alert('当前环境无法顺利安装,请调整环境参数后重试!');
				return false;