你已经安装过该系统,如果想重新安装,请先删除站点install目录下的 install.lock 文件,然后再安装。 '; exit; } @set_time_limit(1000); if ('5.5.9' > phpversion()) { header("Content-type:text/html;charset=utf-8"); exit('您的php版本过低,不能安装本软件,请升级到5.5.9或更高版本再安装,谢谢!'); } define("CRMEB_VERSION", '20180601'); date_default_timezone_set('PRC'); error_reporting(E_ALL & ~E_NOTICE); header('Content-Type: text/html; charset=UTF-8'); define('SITEDIR', _dir_path(substr(dirname(__FILE__), 0, -8)));//入口文件目录 define('CRMEBDIR', _dir_path(substr(dirname(__FILE__), 0, -15)));//项目目录 //数据库 $sqlFile = 'zhishifufei.sql'; $configFile = 'config.php'; $databaseConfigFile = 'database_config.php'; if (!file_exists(SITEDIR . 'install/' . $sqlFile) || !file_exists(SITEDIR . 'install/' . $configFile) || !file_exists(SITEDIR . 'install/' . $databaseConfigFile)) { echo '缺少必要的安装文件!'; exit; } $Title = "CrmEb知识付费安装向导"; $Powered = "Powered by CrmEb"; $steps = array( '1' => '安装许可协议', '2' => '运行环境检测', '3' => '安装参数设置', '4' => '安装详细过程', '5' => '安装完成', ); $step = isset($_GET['step']) ? $_GET['step'] : 1; //地址 $scriptName = !empty($_SERVER["REQUEST_URI"]) ? $scriptName = $_SERVER["REQUEST_URI"] : $scriptName = $_SERVER["PHP_SELF"]; $rootpath = @preg_replace("/\/(I|i)nstall\/index\.php(.*)$/", "", $scriptName); $domain = empty($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME']; if ((int)$_SERVER['SERVER_PORT'] != 80) { $domain .= ":" . $_SERVER['SERVER_PORT']; } $domain = $domain . $rootpath; switch ($step) { case '1': include_once("./templates/step1.php"); exit(); case '2': if (phpversion() < 5.6) { die('本系统需要PHP5+MYSQL >=5.5.9环境,当前PHP版本为:' . phpversion()); } if (phpversion() == 7.1) { _copy(CRMEBDIR . 'help/zsff/71/AuthBasic.php', CRMEBDIR . 'extend/basic/AuthBasic.php'); } if (phpversion() == 7.2) { _copy(CRMEBDIR . 'help/zsff/72/AuthBasic.php', CRMEBDIR . 'extend/basic/AuthBasic.php'); } if (phpversion() == 7.3) { _copy(CRMEBDIR . 'help/zsff/73/AuthBasic.php', CRMEBDIR . 'extend/basic/AuthBasic.php'); } if (phpversion() == 7.4) { _copy(CRMEBDIR . 'help/zsff/74/AuthBasic.php', CRMEBDIR . 'extend/basic/AuthBasic.php'); } $phpv = @ phpversion(); $os = PHP_OS; //$os = php_uname(); $tmp = function_exists('gd_info') ? gd_info() : array(); $server = $_SERVER["SERVER_SOFTWARE"]; $host = (empty($_SERVER["SERVER_ADDR"]) ? $_SERVER["SERVER_HOST"] : $_SERVER["SERVER_ADDR"]); $name = $_SERVER["SERVER_NAME"]; $max_execution_time = ini_get('max_execution_time'); $allow_reference = (ini_get('allow_call_time_pass_reference') ? '[√]On' : '[×]Off'); $allow_url_fopen = (ini_get('allow_url_fopen') ? '[√]On' : '[×]Off'); $safe_mode = (ini_get('safe_mode') ? '[×]On' : '[√]Off'); $err = 0; if (empty($tmp['GD Version'])) { $gd = '[×]Off'; $err++; } else { $gd = '[√]On ' . $tmp['GD Version']; } if (function_exists('mysqli_connect')) { $mysql = ' 已安装'; } else { $mysql = ' 请安装mysqli扩展'; $err++; } if (extension_loaded('swoole_loader')) { $swoole = ' 已安装'; } else { $swoole = ' 点击查看帮助'; $err++; } if (extension_loaded('redis')) { $redisk = ' 已安装'; } else { $redisk = ' 点击查看帮助'; $err++; } if (extension_loaded('fileinfo')) { $fileinfo = ' 已安装'; } else { $fileinfo = ' 点击查看帮助'; $err++; } if (ini_get('file_uploads')) { $uploadSize = ' ' . ini_get('upload_max_filesize'); } else { $uploadSize = '禁止上传'; } if (function_exists('session_start')) { $session = ' 支持'; } else { $session = ' 不支持'; $err++; } if (function_exists('curl_init')) { $curl = '[√]支持 '; } else { $curl = '[×]不支持'; $err++; } if (function_exists('file_put_contents')) { $file_put_contents = '[√]支持 '; } else { $file_put_contents = '[×]不支持'; $err++; } if (function_exists('bcadd')) { $BC = '[√]支持 '; } else { $BC = '[×]不支持'; $err++; } if (function_exists('openssl_encrypt')) { $openssl = '[√]支持 '; } else { $openssl = '[×]不支持'; $err++; } $folder = array( 'public/install', 'public/uploads', 'runtime', 'runtime/cache', 'runtime/temp', 'runtime/log', 'runtime/schema', 'application/database.php', 'application/config.php', ); include_once("./templates/step2.php"); exit(); case '3': $dbName = strtolower(trim($_POST['dbName'])); $_POST['dbport'] = $_POST['dbport'] ? $_POST['dbport'] : '3306'; if ($_GET['testdbpwd']) { $dbHost = $_POST['dbHost']; $conn = @mysqli_connect($dbHost, $_POST['dbUser'], $_POST['dbPwd'], NULL, $_POST['dbport']); if (mysqli_connect_errno($conn)) { die(json_encode(0)); } else { $result = mysqli_query($conn, "SELECT @@global.sql_mode"); $result = $result->fetch_array(); $version = mysqli_get_server_info($conn); if ($version >= 5.7) { if (strstr($result[0], 'STRICT_TRANS_TABLES') || strstr($result[0], 'STRICT_ALL_TABLES') || strstr($result[0], 'TRADITIONAL') || strstr($result[0], 'ANSI')) exit(json_encode(-1)); } $result = mysqli_query($conn, "select count(table_name) as c from information_schema.`TABLES` where table_schema='$dbName'"); $result = $result->fetch_array(); if ($result['c'] > 0) exit(json_encode(-2)); exit(json_encode(1)); } } include_once("./templates/step3.php"); exit(); case '4': if (intval($_GET['install'])) { $n = intval($_GET['n']); if ($i == 999999) exit; $arr = array(); $dbHost = trim($_POST['dbhost']); $_POST['dbport'] = $_POST['dbport'] ? $_POST['dbport'] : '3306'; $dbName = strtolower(trim($_POST['dbname'])); $dbUser = trim($_POST['dbuser']); $dbPwd = trim($_POST['dbpw']); $dbPrefix = empty($_POST['dbprefix']) ? 'tc_' : trim($_POST['dbprefix']); $username = trim($_POST['manager']); $password = trim($_POST['manager_pwd']); $email = trim($_POST['manager_email']); if (!function_exists('mysqli_connect')) { $arr['msg'] = "请安装 mysqli 扩展!"; echo json_encode($arr); exit; } $conn = @mysqli_connect($dbHost, $dbUser, $dbPwd, NULL, $_POST['dbport']); if (mysqli_connect_errno($conn)) { $arr['msg'] = "连接数据库失败!" . mysqli_connect_error($conn); echo json_encode($arr); exit; } mysqli_set_charset($conn, "utf8mb4"); $version = mysqli_get_server_info($conn); if ($version < 5.1) { $arr['msg'] = '数据库版本太低! 必须5.1以上'; echo json_encode($arr); exit; } if (!mysqli_select_db($conn, $dbName)) { //创建数据时同时设置编码 if (!mysqli_query($conn, "CREATE DATABASE IF NOT EXISTS `" . $dbName . "` DEFAULT CHARACTER SET utf8mb4;")) { $arr['msg'] = '数据库 ' . $dbName . ' 不存在,也没权限创建新的数据库!'; echo json_encode($arr); exit; } if ($n == -1) { $arr['n'] = 0; $arr['msg'] = "成功创建数据库:{$dbName}
"; echo json_encode($arr); exit; } mysqli_select_db($conn, $dbName); $updateSql = "ALTER DATABASE" . $dbName . "CHARACTER SET utf8mb4 collate utf8mb4_unicode_ci"; mysqli_query($conn, $updateSql); } //读取数据文件 $sqldata = file_get_contents(SITEDIR . 'install/' . $sqlFile); $sqlFormat = sql_split($sqldata, $dbPrefix); //创建写入sql数据库文件到库中 结束 /** * 执行SQL语句 */ $counts = count($sqlFormat); for ($i = $n; $i < $counts; $i++) { $sql = trim($sqlFormat[$i]); if (strstr($sql, 'CREATE TABLE')) { preg_match('/CREATE TABLE `tc_([^ ]*)`/is', $sql, $matches); mysqli_query($conn, "DROP TABLE IF EXISTS `$matches[1]"); $sql = str_replace('`tc_', '`' . $dbPrefix, $sql);//替换表前缀 $ret = mysqli_query($conn, $sql); if ($ret) { $message = '
  • 创建数据表[' . $dbPrefix . $matches[1] . ']完成!' . date('Y-m-d H:i:s') . '
  • '; } else { $message = '
  • 创建数据表[' . $dbPrefix . $matches[1] . ']失败!' . date('Y-m-d H:i:s') . '
  • '; } $i++; $arr = array('n' => $i, 'msg' => $message); echo json_encode($arr); exit; } else { if (trim($sql) == '') continue; $sql = str_replace('`tc_', '`' . $dbPrefix, $sql);//替换表前缀 $ret = mysqli_query($conn, $sql); $message = ''; $arr = array('n' => $i, 'msg' => $message); } } // 清空测试数据 if (!$_POST['demo']) { $result = mysqli_query($conn, "show tables"); $tables = mysqli_fetch_all($result);//参数MYSQL_ASSOC、MYSQLI_NUM、MYSQLI_BOTH规定产生数组类型 $bl_table = array('tc_system_admin' , 'tc_system_role' , 'tc_system_config' , 'tc_system_config_tab' , 'tc_system_config_content' , 'tc_system_menus' , 'tc_system_file' , 'tc_express' , 'tc_system_group' , 'tc_system_group_data' , 'tc_member_ship' , 'tc_live_gift' , 'tc_recommend' , 'tc_wechat_template' , 'tc_routine_template'); foreach ($bl_table as $k => $v) { $bl_table[$k] = str_replace('tc_', $dbPrefix, $v); } foreach ($tables as $key => $val) { if (!in_array($val[0], $bl_table)) { mysqli_query($conn, "truncate table " . $val[0]); } } delFile(CRMEBDIR . '/public/uploads'); // 清空测试图片 } //读取配置文件,并替换真实配置数据1 $strConfig = file_get_contents(SITEDIR . 'install/' . $databaseConfigFile); $strConfig = str_replace('#DB_HOST#', $dbHost, $strConfig); $strConfig = str_replace('#DB_NAME#', $dbName, $strConfig); $strConfig = str_replace('#DB_USER#', $dbUser, $strConfig); $strConfig = str_replace('#DB_PWD#', $dbPwd, $strConfig); $strConfig = str_replace('#DB_PORT#', $_POST['dbport'], $strConfig); $strConfig = str_replace('#DB_PREFIX#', $dbPrefix, $strConfig); $strConfig = str_replace('#DB_CHARSET#', 'utf8mb4', $strConfig); @chmod(CRMEBDIR . '/application/database.php', 0777); //数据库配置文件的地址 @file_put_contents(CRMEBDIR . '/application/database.php', $strConfig); //数据库配置文件的地址 //redis数据库信息 $rbhost = $_POST['rbhost'] ? $_POST['rbhost'] : '127.0.0.1'; $rbport = $_POST['rbport'] ? $_POST['rbport'] : '6379'; $rbpw = $_POST['rbpw'] ? $_POST['rbpw'] : ''; $process_name = $_POST['process_name'] ? $_POST['process_name'] : ''; $external = $_POST['external'] ? $_POST['external'] : ''; $inside = $_POST['inside'] ? $_POST['inside'] : ''; $queue_name = $_POST['queue_name'] ? $_POST['queue_name'] : ''; $strConfig = file_get_contents(SITEDIR . 'install/' . $configFile); $strConfig = str_replace('#RB_HOST#', $rbhost, $strConfig); $strConfig = str_replace('#RB_PORT#', $rbport, $strConfig); $strConfig = str_replace('#RB_PWD#', $rbpw, $strConfig); $strConfig = str_replace('#PROCESS_NAME#', $process_name, $strConfig); $strConfig = str_replace('#EXTERNAL#', $external, $strConfig); $strConfig = str_replace('#INSIDE#', $inside, $strConfig); $strConfig = str_replace('#QUEUE_NAME#', $queue_name, $strConfig); $strConfig = str_replace("#APP_KEY#", create_uuid(), $strConfig); $strConfig = str_replace("#KEFU_KEY#", create_uuid(), $strConfig); @chmod(CRMEBDIR . '/application/config.php', 0777); //redis配置文件的地址 @file_put_contents(CRMEBDIR . '/application/config.php', $strConfig); //redis配置文件的地址 //更新网站配置信息2 //插入管理员表字段tp_admin表 $time = time(); $ip = get_client_ip(); $ip = empty($ip) ? "0.0.0.0" : $ip; $password = md5(trim($_POST['manager_pwd'])); mysqli_query($conn, "truncate table {$dbPrefix}system_admin"); $addadminsql = "INSERT INTO `{$dbPrefix}system_admin` (`id`, `account`, `pwd`, `real_name`, `roles`, `last_ip`, `last_time`, `add_time`, `login_count`, `level`, `status`, `is_del`) VALUES (1, '" . $username . "', '" . $password . "', 'admin', '1', '" . $ip . "',$time , $time, 0, 0, 1, 0)"; $res = mysqli_query($conn, $addadminsql); if (isset($_SERVER['SERVER_NAME'])) { $site_url = '\'"http://' . $_SERVER['SERVER_NAME'] . '"\''; $res2 = mysqli_query($conn, 'UPDATE `' . $dbPrefix . 'system_config` SET `value`=' . $site_url . ' WHERE `menu_name`="site_url"'); } if ($res) { $message = '成功添加管理员
    成功写入配置文件
    安装完成.'; $arr = array('n' => 999999, 'msg' => $message); echo json_encode($arr); exit; } else { $message = '添加管理员失败
    成功写入配置文件
    安装完成.'; $arr = array('n' => 999999, 'msg' => $message); echo json_encode($arr); exit; } } include_once("./templates/step4.php"); exit(); case '5': $ip = get_client_ip(); $host = $_SERVER['HTTP_HOST']; $curent_version = getazversion(); $time = time(); $mt_rand_str = sp_random_string(6); $str_constant = "