'; $message = "$message(跳转中...)"; } show_header(); echo "
$message
"; show_footer(); exit(); } function show_header() { global $_K, $_SC; $ver=KEKE_VERSION; $ver_time = KEKE_RELEASE; $nowarr = array($_GET['step'] => ' class="current"'); echo ' 人才系统安装程序VIP6.03

安装

人才系统安装程序VIP6.03
'; } function show_footer() { echo '
'; } function check_db($dbhost, $dbuser, $dbpw, $dbname, $tablepre) { if(!function_exists('mysql_connect')) { show_msg($lang['advice_mysql_connect'], 0); } if(!@mysql_connect($dbhost, $dbuser, $dbpw)) { $errno = mysql_errno(); $error = mysql_error(); if($errno == 1045) { show_msg($lang['database_errno_1045'], 0); } elseif($errno == 2003) { show_msg($lang['database_errno_2003'], 0); } else { show_msg($lang['database_connect_error'], 0); } } else { if($query = @mysql_query("SHOW TABLES FROM $dbname")) { while($row = mysql_fetch_row($query)) { if(preg_match("/^$tablepre/", $row[0])) { return false; } } } } return true; } function dirfile_check(&$dirfile_items) { foreach($dirfile_items as $key => $item) { $item_path = $item['path']; if($item['type'] == 'dir') { if(!dir_writeable(S_ROOT.$item_path)) { if(is_dir(S_ROOT.$item_path)) { $dirfile_items[$key]['status'] = 0; $dirfile_items[$key]['current'] = '+r'; } else { $dirfile_items[$key]['status'] = -1; $dirfile_items[$key]['current'] = 'nodir'; } } else { $dirfile_items[$key]['status'] = 1; $dirfile_items[$key]['current'] = '+r+w'; } } else { if(file_exists(S_ROOT.$item_path)) { if(is_writable(S_ROOT.$item_path)) { $dirfile_items[$key]['status'] = 1; $dirfile_items[$key]['current'] = '+r+w'; } else { $dirfile_items[$key]['status'] = 0; $dirfile_items[$key]['current'] = '+r'; } } else { if(dir_writeable(dirname(S_ROOT.$item_path))) { $dirfile_items[$key]['status'] = 1; $dirfile_items[$key]['current'] = '+r+w'; } else { $dirfile_items[$key]['status'] = -1; $dirfile_items[$key]['current'] = 'nofile'; } } } } } function env_check(&$env_items) { foreach($env_items as $key => $item) { if($key == 'php') { $env_items[$key]['current'] = PHP_VERSION; } elseif($key == 'attachmentupload') { $env_items[$key]['current'] = @ini_get('file_uploads') ? ini_get('upload_max_filesize') : 'unknow'; } elseif($key == 'gdversion') { $tmp = function_exists('gd_info') ? gd_info() : array(); $env_items[$key]['current'] = empty($tmp['GD Version']) ? 'noext' : $tmp['GD Version']; unset($tmp); } elseif($key == 'diskspace') { if(function_exists('disk_free_space')) { $env_items[$key]['current'] = floor(disk_free_space(S_ROOT) / (1024*1024)).'M'; } else { $env_items[$key]['current'] = 'unknow'; } } elseif(isset($item['c'])) { $env_items[$key]['current'] = constant($item['c']); } $env_items[$key]['status'] = 1; if($item['r'] != 'notset' && strcmp($env_items[$key]['current'], $item['r']) < 0) { $env_items[$key]['status'] = 0; } } } function function_check(&$func_items) { global $lang; foreach($func_items as $item) { function_exists($item) or show_msg($lang["advice_".$item], 0); } } if(!function_exists('file_put_contents')) { function file_put_contents($filename, $s) { $fp = @fopen($filename, 'w'); @fwrite($fp, $s); @fclose($fp); return TRUE; } } function dir_writeable($dir) { $writeable = 0; if(!is_dir($dir)) { @mkdir($dir, 0777); } if(is_dir($dir)) { if($fp = @fopen("$dir/test.txt", 'w')) { @fclose($fp); @unlink("$dir/test.txt"); $writeable = 1; } else { $writeable = 0; } } return $writeable; } function dir_clear($dir) { global $lang; showjsmessage($lang['clear_dir'].' '.str_replace(S_ROOT, '', $dir)); if($directory = @dir($dir)) { while($entry = $directory->read()) { $filename = $dir.'/'.$entry; if(is_file($filename)) { @unlink($filename); } } $directory->close(); @touch($dir.'/index.htm'); } } function runquery($sql) { global $lang, $tablepre, $db; if(!isset($sql) || empty($sql)) return; $orig_tablepre = "keke_"; $sql = str_replace("\r", "\n", str_replace(' '.$orig_tablepre, ' '.$tablepre, $sql)); $sql = str_replace("\r", "\n", str_replace(' `'.$orig_tablepre, ' `'.$tablepre, $sql)); $ret = array(); $num = 0; foreach(explode(";\n", trim($sql)) as $query) { $ret[$num] = ''; $queries = explode("\n", trim($query)); foreach($queries as $query) { $ret[$num] .= (isset($query[0]) && $query[0] == '#') || (isset($query[1]) && isset($query[1]) && $query[0].$query[1] == '--') ? '' : $query; } $num++; } unset($sql); foreach($ret as $query) { $query = trim($query); if($query) { if(substr($query, 0, 12) == 'CREATE TABLE') { $name = preg_replace("/CREATE TABLE ([a-z0-9_]+) .*/is", "\\1", $query); $db->query(createtable($query)); } else { $db->query($query); } } } } function createtable($sql) { $type = strtoupper(preg_replace("/^\s*CREATE TABLE\s+.+\s+\(.+?\).*(ENGINE|TYPE)\s*=\s*([a-z]+?).*$/isU", "\\2", $sql)); $type = in_array($type, array('MYISAM', 'HEAP', 'MEMORY')) ? $type : 'MYISAM'; return preg_replace("/^\s*(CREATE TABLE\s+.+\s+\(.+?\)).*$/isU", "\\1", $sql). (mysql_get_server_info() > '4.1' ? " ENGINE=$type DEFAULT CHARSET=".DBCHARSET : " TYPE=$type"); } function random($length) { $hash = ''; $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz'; $max = strlen($chars) - 1; PHP_VERSION < '4.2.0' && mt_srand((double)microtime() * 1000000); for($i = 0; $i < $length; $i++) { $hash .= $chars[mt_rand(0, $max)]; } return $hash; } function show_error($error_no, $error_msg = 'ok', $success = 1, $quit = TRUE) { if(KEKE_OFF) { $error_code = $success ? 0 : constant(strtoupper($error_no)); $error_msg = empty($error_msg) ? $error_no : $error_msg; $error_msg = str_replace('"', '\"', $error_msg); $str = "\n"; $str .= "\t\n"; $str .= ""; echo $str; exit; } else { show_header(); global $step;$_K; $title = keke_lang($error_no); $comment = keke_lang($error_no.'_comment', false); $errormsg = ''; if($error_msg) { if(!empty($error_msg)) { foreach ((array)$error_msg as $k => $v) { if(is_numeric($k)) { $comment .= "
  • ".keke_lang($v)."
  • "; } } } } if($step) { echo "
    $title"; } else { echo "
    $title"; } if($quit) { echo '
             '.keke_lang('error_quit_msg').'


    '; } echo '



    '; echo '
    '; $quit && show_footer(); } } 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 || $item['r']<5.4)) { $status = 0; $error_code = ENV_ERROR; $item['r'] = "".$item['r']."(版本过低)"; } $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\n"; } else { $env_str .= "\n"; $env_str .= "".keke_lang($key)."\n"; $env_str .= "".keke_lang($item['r'])."\n"; $env_str .= "".keke_lang($item['b'])."\n"; $env_str .= "\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\n"; } else { $$variable .= "\n"; $$variable .= "$item[path]"; if(!is_dir($item[path])){ $$variable .= "".keke_lang('nodir')."\n"; $error_code=2; }else{ if(check_dir_iswritable($item[path])){ $$variable .= "".keke_lang('writeable')."\n"; }else{ $$variable .= "".keke_lang('unwriteable')."\n"; $error_code=2; } } $$variable .= "".keke_lang('writeable')."\n"; $$variable .= "\n"; } } if(KEKE_OFF) { $str = "\n"; $str .= "\t\n"; $str .= $env_str; $str .= "\t\n"; $str .= "\t\n"; $str .= "\t\t\n"; $str .= $dir_str; $str .= "\t\t\n"; $str .= "\t\t\n"; $str .= $file_str; $str .= "\t\t\n"; $str .= "\t\n"; $str .= "\t\n"; $str .= ""; echo $str; exit; } else { show_header(); echo '
    • 1检测环境
    • 2创建数据
    • 3完成安装
    '; echo ''; echo $env_str; echo '
    环境检测当前服务器PHPYUN. 最佳
    '; echo ''; echo $file_str; echo $dir_str; echo '
    目录、文件权限检查当前状态所需状态
    '; echo ''; foreach($func_items as $item) { $status = function_exists($item); $func_str .= "\n"; $func_str .= "\n"; if($status) { $func_str .= "\n"; $func_str .= "\n"; } else { $error_code = ENV_ERROR; $func_str .= "\n"; $func_str .= "\n"; } } echo $func_str; echo '
    函数名称检查结果建议
    $item()".keke_lang('supportted')."".keke_lang('supportted')."".keke_lang('unsupportted')."".keke_lang('advice_'.$item)."
    '; echo '
    '; echo ''; if($error_code==2){ echo ''; }else{ echo ''; } echo '
    '; show_footer(); } } function show_sql_result(){ show_header(); echo '
    • 1 检测环境
    • 2 创建数据
    • 3 完成安装
    '; show_footer(); } function show_tips($tip, $title = '', $comment = '', $style = 1) { global $lang; $title = empty($title) ? keke_lang($tip) : $title; $comment = empty($comment) ? keke_lang($tip.'_comment', FALSE) : $comment; if($style) { echo "
    $title"; } else { echo "
    $title
      "; } $comment && print('
      '.$comment); echo "
    "; } function keke_lang($lang_key, $force = true) { return isset($GLOBALS['lang'][$lang_key]) ? $GLOBALS['lang'][$lang_key] : ($force ? $lang_key : ''); }