From 95e58530ba9bfc913bd90f6dd4ebae0db8d28084 Mon Sep 17 00:00:00 2001 From: zyx0814 Date: Thu, 4 Jan 2024 17:48:21 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=80=E4=BA=9B=E5=AE=89?= =?UTF-8?q?=E5=85=A8=E6=80=A7=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin/appmarket/index.php | 151 +- dzz/market/index.php | 177 +- install/include/install_function.php | 2296 +++++++++++++------------- install/include/install_var.php | 280 ++-- 4 files changed, 1455 insertions(+), 1449 deletions(-) diff --git a/admin/appmarket/index.php b/admin/appmarket/index.php index 7cfd9fc..f3d1338 100644 --- a/admin/appmarket/index.php +++ b/admin/appmarket/index.php @@ -1,74 +1,77 @@ - $value) { - if (!in_array($key, $dels)) - C::t('app_market') -> update($key, array('disp' => $value)); - } - //删除应用 - if ($dels) { - C::t('app_market') -> delete_by_appid($dels); - } - showmessage('do_success', dreferer()); -} -//获取所有标签top50; -$tags = DB::fetch_all("SELECT * FROM %t WHERE hot>0 ORDER BY HOT DESC limit 50", array('app_tag'),'tagid'); - -$keyword = trim($_GET['keyword']); -$tagid = intval($_GET['tagid']); -$group = intval($_GET['group']); -$page = empty($_GET['page']) ? 1 : intval($_GET['page']); -$perpage = 20; -$gets = array('mod' => 'appmarket', 'keyword' => $keyword, 'tagid' => $tagid, 'group' => $group); -$theurl = BASESCRIPT . "?" . url_implode($gets); -$refer = urlencode($theurl . '&page=' . $page); - -$order = ' ORDER BY disp'; -$start = ($page - 1) * $perpage; -$apps = array(); -$string = " 1 "; -if ($keyword) { - $string .= " and appname like '%$keyword%' or vendor like '%$keyword%'"; -} -if ($tagid) { - $appids = C::t('app_relative') -> fetch_appids_by_tagid($tagid); - $string .= " and appid IN (" . dimplode($appids) . ")"; -} -if ($group) { - $sql = " and `group` = '{$group}'"; - $string .= " and `group` = '{$group}'"; -} -if ($count = DB::result_first("SELECT COUNT(*) FROM " . DB::table('app_market') . " WHERE ".$string)) { - $apps = DB::fetch_all("SELECT * FROM " . DB::table('app_market') . " WHERE ".$string." $order limit $start,$perpage"); - $multi = multi($count, $perpage, $page, $theurl, 'pull-right'); -} - -$list = array(); -$grouptitle = array('0' => lang('all'), '-1' => lang('visitors_visible'), '1' => lang('members_available'), '2' => lang('section_administrators_available'), '3' => lang('system_administrators_available')); -foreach ($apps as $value) { - $value['tags'] = C::t('app_relative') -> fetch_all_by_appid($value['appid']); - if ($value['appico'] != 'dzz/images/default/icodefault.png' && !preg_match("/^(http|ftp|https|mms)\:\/\/(.+?)/i", $value['appico'])) { - $value['appico'] = $_G['setting']['attachurl'] . $value['appico']; - } - $value['appurl'] = replace_canshu($value['appurl']); - $value['appadminurl'] = replace_canshu($value['appadminurl']); - $value['grouptitle'] = $grouptitle[$value['group']]; - $value['department'] = getDepartmentByAppid($value['appid']); - $list[] = $value; -} -include template('index'); -?> + $value) { + if (!in_array($key, $dels)) + C::t('app_market') -> update($key, array('disp' => $value)); + } + //删除应用 + if ($dels) { + C::t('app_market') -> delete_by_appid($dels); + } + showmessage('do_success', dreferer()); +} +//获取所有标签top50; +$tags = DB::fetch_all("SELECT * FROM %t WHERE hot>0 ORDER BY HOT DESC limit 50", array('app_tag'),'tagid'); + +$keyword = trim($_GET['keyword']); +$tagid = intval($_GET['tagid']); +$group = intval($_GET['group']); +$page = empty($_GET['page']) ? 1 : intval($_GET['page']); +$perpage = 20; +$gets = array('mod' => 'appmarket', 'keyword' => $keyword, 'tagid' => $tagid, 'group' => $group); +$theurl = BASESCRIPT . "?" . url_implode($gets); +$refer = urlencode($theurl . '&page=' . $page); + +$order = ' ORDER BY disp'; +$start = ($page - 1) * $perpage; +$apps = array(); +$string = " 1 "; +$param=array(); +if ($keyword) { + $string .= " and appname like %s or vendor like %s"; + $param[]='%'.$keyword.'%'; + $param[]='%'.$keyword.'%'; +} +if ($tagid) { + $appids = C::t('app_relative') -> fetch_appids_by_tagid($tagid); + $string .= " and appid IN (" . dimplode($appids) . ")"; +} +if ($group) { + $sql = " and `group` = '{$group}'"; + $string .= " and `group` = '{$group}'"; +} +if ($count = DB::result_first("SELECT COUNT(*) FROM %t WHERE ".$string,$param)) { + $apps = DB::fetch_all("SELECT * FROM %t WHERE ".$string." $order limit $start,$perpage",$param); + $multi = multi($count, $perpage, $page, $theurl, 'pull-right'); +} + +$list = array(); +$grouptitle = array('0' => lang('all'), '-1' => lang('visitors_visible'), '1' => lang('members_available'), '2' => lang('section_administrators_available'), '3' => lang('system_administrators_available')); +foreach ($apps as $value) { + $value['tags'] = C::t('app_relative') -> fetch_all_by_appid($value['appid']); + if ($value['appico'] != 'dzz/images/default/icodefault.png' && !preg_match("/^(http|ftp|https|mms)\:\/\/(.+?)/i", $value['appico'])) { + $value['appico'] = $_G['setting']['attachurl'] . $value['appico']; + } + $value['appurl'] = replace_canshu($value['appurl']); + $value['appadminurl'] = replace_canshu($value['appadminurl']); + $value['grouptitle'] = $grouptitle[$value['group']]; + $value['department'] = getDepartmentByAppid($value['appid']); + $list[] = $value; +} +include template('index'); +?> diff --git a/dzz/market/index.php b/dzz/market/index.php index abcbdda..337d90f 100644 --- a/dzz/market/index.php +++ b/dzz/market/index.php @@ -1,87 +1,90 @@ - insert_by_uid($_G['uid'], $appid); - if (C::t('user_field') -> update($_G['uid'], array('applist' => implode(',', $applist)))) { - echo json_encode(array('msg' => 'success')); - exit(); - } else { - echo json_encode(array('error' => lang('app_installa_failed'))); - exit(); - } -} -//获取所有标签top10; -$tags = DB::fetch_all("SELECT * FROM %t WHERE hot>0 ORDER BY HOT DESC limit 100", array('app_tag')); -$keyword = trim($_GET['keyword']); -$tagid = intval($_GET['tagid']); -$page = empty($_GET['page']) ? 1 : intval($_GET['page']); -$perpage = 20; -$gets = array('mod' => 'market', 'keyword' => $keyword, 'tagid' => $tagid, ); -$theurl = DZZSCRIPT . "?" . url_implode($gets); -$refer = urlencode($theurl . '&page=' . $page); - -$order = 'ORDER BY disp'; -$start = ($page - 1) * $perpage; -$apps = array(); -//system=2代表系统自带安装应用不能卸载 notdelete=1表示不能删除的,不能删除的直接不可见 -$sql = 'system!=2 and available>0 and hideInMarket<1 and notdelete<1'; -if ($keyword) { - $sql .= " and (appname like '%$keyword%' or vendor like '%$keyword%')"; -} elseif ($tagid) { - $appids = C::t('app_relative') -> fetch_appids_by_tagid($tagid); - $sql .= " and appid IN (" . dimplode($appids) . ")"; -} -//获取用户所在组的应用 -if (!$_G['uid']) {//游客 - $sql .= " and (`group`='-1' OR `group`='0')"; -} elseif ($_G['adminid'] == 1) {//系统管理员 -} elseif ($_G['groupid'] == 2) {//部门管理员 - $l = " (`group` = '1')"; - if ($notappids = C::t('app_organization') -> fetch_notin_appids_by_uid($_G['uid'])) { - $l .= " and appid NOT IN (" . dimplode($notappids) . ") "; - } - $sql .= " and (`group` = '2' OR `group`='0' OR (" . $l . "))"; -} else {//普通成员 - $l = " (`group` = '1')"; - if ($notappids = C::t('app_organization') -> fetch_notin_appids_by_uid($_G['uid'])) { - $l .= " and appid NOT IN (" . dimplode($notappids) . ") "; - } - $sql .= " and (`group`='0' OR (" . $l . "))"; -} -if ($count = DB::result_first("SELECT COUNT(*) FROM " . DB::table('app_market') . " WHERE $sql ")) { - $apps = DB::fetch_all("SELECT * FROM " . DB::table('app_market') . " WHERE $sql $order limit $start,$perpage"); - $multi = multi($count, $perpage, $page, $theurl, 'pull-right'); -} -$list = array(); -//$grouptitle=array('0'=>'全部','-1'=>'仅游客可用','1'=>'成员可用','2'=>'部门管理员可用','3'=>'仅系统管理员可用'); -foreach ($apps as $value) { - if ($value['isshow'] < 1) - continue; - $value['tags'] = C::t('app_relative') -> fetch_all_by_appid($value['appid']); - if ($value['appico'] != 'dzz/images/default/icodefault.png' && !preg_match("/^(http|ftp|https|mms)\:\/\/(.+?)/i", $value['appico'])) { - $value['appico'] = $_G['setting']['attachurl'] . $value['appico']; - } - $value['url'] = replace_canshu($value['appurl']); - if (in_array($value['appid'], $applist)) - $value['isinstall'] = true; - $list[$value['appid']] = $value; -} -$jsondata = json_encode($list); - -include template('market'); -?> + insert_by_uid($_G['uid'], $appid); + if (C::t('user_field') -> update($_G['uid'], array('applist' => implode(',', $applist)))) { + echo json_encode(array('msg' => 'success')); + exit(); + } else { + echo json_encode(array('error' => lang('app_installa_failed'))); + exit(); + } +} +//获取所有标签top10; +$tags = DB::fetch_all("SELECT * FROM %t WHERE hot>0 ORDER BY HOT DESC limit 100", array('app_tag')); +$keyword = trim($_GET['keyword']); +$tagid = intval($_GET['tagid']); +$page = empty($_GET['page']) ? 1 : intval($_GET['page']); +$perpage = 20; +$gets = array('mod' => 'market', 'keyword' => $keyword, 'tagid' => $tagid, ); +$theurl = DZZSCRIPT . "?" . url_implode($gets); +$refer = urlencode($theurl . '&page=' . $page); + +$order = 'ORDER BY disp'; +$start = ($page - 1) * $perpage; +$apps = array(); +//system=2代表系统自带安装应用不能卸载 notdelete=1表示不能删除的,不能删除的直接不可见 +$sql = 'system!=2 and available>0 and hideInMarket<1 and notdelete<1'; +$param=array('app_market'); +if ($keyword) { + $sql .= " and (appname like %s or vendor like %s)"; + $param[]='%'.$keyword.'%'; + $param[]='%'.$keyword.'%'; +} elseif ($tagid) { + $appids = C::t('app_relative') -> fetch_appids_by_tagid($tagid); + $sql .= " and appid IN (" . dimplode($appids) . ")"; +} +//获取用户所在组的应用 +if (!$_G['uid']) {//游客 + $sql .= " and (`group`='-1' OR `group`='0')"; +} elseif ($_G['adminid'] == 1) {//系统管理员 +} elseif ($_G['groupid'] == 2) {//部门管理员 + $l = " (`group` = '1')"; + if ($notappids = C::t('app_organization') -> fetch_notin_appids_by_uid($_G['uid'])) { + $l .= " and appid NOT IN (" . dimplode($notappids) . ") "; + } + $sql .= " and (`group` = '2' OR `group`='0' OR (" . $l . "))"; +} else {//普通成员 + $l = " (`group` = '1')"; + if ($notappids = C::t('app_organization') -> fetch_notin_appids_by_uid($_G['uid'])) { + $l .= " and appid NOT IN (" . dimplode($notappids) . ") "; + } + $sql .= " and (`group`='0' OR (" . $l . "))"; +} +if ($count = DB::result_first("SELECT COUNT(*) FROM %t WHERE $sql ",$param)) { + $apps = DB::fetch_all("SELECT * FROM %t WHERE $sql $order limit $start,$perpage",$param); + $multi = multi($count, $perpage, $page, $theurl, 'pull-right'); +} +$list = array(); +//$grouptitle=array('0'=>'全部','-1'=>'仅游客可用','1'=>'成员可用','2'=>'部门管理员可用','3'=>'仅系统管理员可用'); +foreach ($apps as $value) { + if ($value['isshow'] < 1) + continue; + $value['tags'] = C::t('app_relative') -> fetch_all_by_appid($value['appid']); + if ($value['appico'] != 'dzz/images/default/icodefault.png' && !preg_match("/^(http|ftp|https|mms)\:\/\/(.+?)/i", $value['appico'])) { + $value['appico'] = $_G['setting']['attachurl'] . $value['appico']; + } + $value['url'] = replace_canshu($value['appurl']); + if (in_array($value['appid'], $applist)) + $value['isinstall'] = true; + $list[$value['appid']] = $value; +} +$jsondata = json_encode($list); + +include template('market'); +?> diff --git a/install/include/install_function.php b/install/include/install_function.php index de4bce8..5de0c10 100644 --- a/install/include/install_function.php +++ b/install/include/install_function.php @@ -1,1148 +1,1148 @@ -list_bucket(); - if(!$response->isOK()){ - return array(); - } - $bucket=$response->getBody(); - foreach($bucket['ListAllMyBucketsResult']['Buckets']['Bucket'] as $value){ - $re[]=$value['Name']; - } - return $re; - } -function show_msg($error_no, $error_msg = 'ok', $success = 1, $quit = TRUE) { - - show_header(); - global $step; - $title = lang($error_no); - $comment = 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 .= "
  • ".lang($v)."
  • "; - } - } - } - } - $back = lang('to_back'); - echo << - -
    - - -

    $title

    - - -
    - -EOT; - show_footer($quit); -} - -function check_db($dbhost, $dbuser, $dbpw, $dbname, $tablepre) { - if(!function_exists('mysql_connect') && !function_exists('mysqli_connect')) { - show_msg('undefine_func', 'mysql_connect | mysqli_connect', 0); - } - $mysqlmode = function_exists('mysqli_connect') ? 'mysqli' : 'mysql'; - if($mysqlmode=='mysqli'){ - //兼容支持域名直接带有端口的情况 - if(strpos($dbhost,':')!==false){ - list($dbhost,$port)=explode(':',$dbhost); - - }elseif(strpos($dbhost,'.sock')!==false){//地址直接是socket地址 - $unix_socket=$dbhost; - $dbhost='localhost'; - } - if(empty($port)) $port='3306'; - $link = new mysqli($dbhost, $dbuser, $dbpw, '', $port, $unix_socket); - $errno = $link->connect_errno; - $error = $link->connect_error; - }else{ - $link = @mysql_connect($dbhost, $dbuser, $dbpw); - $errno = mysql_errno(); - $error = mysql_error(); - } - if($errno) { - if($errno == 1045) { - show_msg('database_errno_1045', $error, 0); - } elseif($errno == 2003 || $errno==2002) { - show_msg('database_errno_2003', $error, 0); - } else { - show_msg('database_connect_error', $error, 0); - } - } else { - if($query = (($mysqlmode == 'mysql') ? @mysql_query("SHOW databases") : $link->query("SHOW databases"))) { - if(!$query) { - return false; - } - while($row = (($mysqlmode == 'mysql') ? mysql_fetch_row($query) : $query->fetch_row())) { - if($dbname==$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(ROOT_PATH.$item_path)) { - if(is_dir(ROOT_PATH.$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(ROOT_PATH.$item_path)) { - if(is_writable(ROOT_PATH.$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(ROOT_PATH.$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 == 'allow_url_fopen') { - $env_items[$key]['current'] = @ini_get('allow_url_fopen') ? ini_get('allow_url_fopen') : '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(ROOT_PATH) / (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) { - foreach($func_items as $item) { - function_exists($item) or show_msg('undefine_func', $item, 0); - } -} - -function show_env_result(&$env_items, &$func_items, &$filesock_items) { - - $env_str = $file_str = $func_str = ''; - $error_code = 0; - foreach($env_items as $key => $item) { - if($key == 'php' && strcmp($item['current'], $item['r']) < 0) { - show_msg('php_version_too_low', $item['current'], 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_CHECK_ERROR; - } - } else { - if(strcmp($item['current'], $item['r']) < 0) { - $status = 0; - $error_code = ENV_CHECK_ERROR; - } - } - } - if(VIEW_OFF) { - $env_str .= "\t\t\n"; - } else { - $env_str .= "\n"; - $env_str .= "".lang($key)."\n"; - $env_str .= "".lang($item['r'])."\n"; - $env_str .= "".lang($item['b'])."\n"; - $env_str .= ($status ? "" : "").$item['current']."\n"; - $env_str .= "\n"; - } - } - show_header(); - if($env_str){ - echo "

    ".lang('env_check')."

    \n"; - echo "\n"; - echo "\n"; - echo "\t\n"; - echo "\t\n"; - echo "\t\n"; - echo "\t\n"; - echo "\n"; - echo $env_str; - echo "
    ".lang('project')."".lang('dzzoffice_required')."".lang('dzzoffice_best')."".lang('curr_server')."
    \n"; - } - - foreach($func_items as $item) { - $status = function_exists($item); - $func_str .= "\n"; - $func_str .= "$item()\n"; - if($status) { - $func_str .= "".lang('supportted')."\n"; - $func_str .= "".lang('none')."\n"; - } else { - $error_code = ENV_CHECK_ERROR; - $func_str .= "".lang('unsupportted')."\n"; - $func_str .= "".lang('advice_'.$item)."\n"; - } - } - $func_strextra = ''; - $filesock_disabled = 0; - foreach($filesock_items as $item) { - $status = function_exists($item); - $func_strextra .= "\n"; - $func_strextra .= "$item()\n"; - if($status) { - $func_strextra .= "".lang('supportted')."\n"; - $func_strextra .= "".lang('none')."\n"; - break; - } else { - $filesock_disabled++; - $func_strextra .= "".lang('unsupportted')."\n"; - $func_strextra .= "".lang('advice_'.$item)."\n"; - } - } - if($filesock_disabled == count($filesock_items)) { - $error_code = ENV_CHECK_ERROR; - } - if($func_str || $func_strextra){ - echo "

    ".lang('func_depend')."

    \n"; - echo "\n"; - echo "\n"; - echo "\t\n"; - echo "\t\n"; - - echo "\n"; - echo $func_str.$func_strextra; - echo "
    ".lang('func_name')."".lang('check_result')."
    \n"; - } - show_next_step(2,$error_code); - show_footer(); -} -function show_dirfile_result(&$dirfile_items) { - - $file_str = ''; - $dir_str = ''; - $error_code = 0; - - foreach($dirfile_items as $key => $item) { - $tagname = $item['type'] == 'file' ? 'file' : 'dir'; - $variable = $item['type'].'_str'; - if(empty($$variable)) $$variable=''; - $$variable .= "\n"; - $$variable .= "$item[path]".lang('writeable')."\n"; - if($item['status'] == 1) { - $$variable .= "".lang('writeable')."\n"; - } elseif($item['status'] == -1) { - $error_code = ENV_CHECK_ERROR; - $$variable .= "".lang('nodir')."\n"; - } else { - $error_code = ENV_CHECK_ERROR; - $$variable .= "".lang('unwriteable')."\n"; - } - $$variable .= "\n"; - - } - show_header(); - if($file_str || $dir_str){ - echo "

    ".lang('priv_check')."

    \n"; - echo "\n"; - echo "\t\n"; - echo "\t\n"; - echo "\t\n"; - echo "\t\n"; - echo "\n"; - echo $file_str; - echo $dir_str; - echo "
    ".lang('step1_file')."".lang('step1_need_status')."".lang('step1_status')."
    \n"; - } - show_next_step(3,$error_code); - show_footer(); -} -function show_next_step($step, $error_code) { - global $uchidden; - echo "
    \n"; - echo ""; - if($error_code == 0) { - $nextstep = "\n"; - } else { - $nextstep = "\n"; - } - echo '
    '.$nextstep.'
    '; - echo "
    \n"; -} -function show_form(&$form_items, $error_msg) { - global $step; - - if(empty($form_items) || !is_array($form_items)) { - return; - } - show_header(); - show_setting('start'); - show_setting('hidden', 'step', $step); - $is_first = 1; - echo '

    '; - foreach($form_items as $key => $items) { - global ${'error_'.$key}; - if($is_first == 0) { - echo ''; - } - if(!${'error_'.$key}) { - show_tips('tips_'.$key); - } else { - show_error('tips_admin_config', ${'error_'.$key}); - } - - echo ''; - foreach($items as $k => $v) { - $value = ''; - if(!empty($error_msg)) { - $value = isset($_POST[$key][$k]) ? $_POST[$key][$k] : ''; - } - if(empty($value)) { - if(isset($v['value']) && is_array($v['value'])) { - if($v['value']['type'] == 'constant') { - $value = defined($v['value']['var']) ? constant($v['value']['var']) : $v['value']['var']; - }elseif($v['value']['type'] == 'array') { - $value = $v['value']['var']; - } else { - $value = !empty($GLOBALS[$v['value']['var']])?$GLOBALS[$v['value']['var']]:''; - } - } else { - $value = ''; - } - } - show_setting($k, $key.'['.$k.']', $value, $v['type'], isset($error_msg[$key][$k]) ? $key.'_'.$k.'_invalid' : ''); - } - if($is_first) { - $is_first = 0; - } - } - echo '
    '; - echo '
    '; - echo ''; - show_setting('', 'submitname', 'new_step', ($step == 2 ? 'submit|oldbtn' : 'submit' )); - show_setting('end'); - show_footer(); -} - -function show_license() { - global $self, $step; - $next = $step + 1; - show_header(); - $title = lang('step_env_check_title'); - $version='DzzOffice'.CORE_VERSION.'    '.INSTALL_LANG.' '.CORE_RELEASE; - $release = CORE_RELEASE; - $install_lang = lang(INSTALL_LANG); - echo << - body{background:#2d3137} - -
    - -
    -

    -
    -

    $install_lang

    -

    $version

    -
    - -
    -
    - -EOT; -show_footer(); -} -if(!function_exists('file_put_contents')) { - function file_put_contents($filename, $s) { - $fp = @fopen($filename, 'w'); - @fwrite($fp, $s); - @fclose($fp); - return TRUE; - } -} - -function createtable($sql, $dbver) { - - $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','INNODB')) ? $type : 'MyISAM'; - return preg_replace("/^\s*(CREATE TABLE\s+.+\s+\(.+?\)).*$/isU", "\\1", $sql). - (" ENGINE=$type DEFAULT CHARSET=".DBCHARSET); -} - -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(ROOT_PATH, '', $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 show_header() { - define('SHOW_HEADER', TRUE); - global $step; - $version = CORE_VERSION; - $release = CORE_RELEASE; - $install_lang = lang(INSTALL_LANG); - $title = lang('title_install'); - $charset = CHARSET; - echo << - - - -$title - - - - -
    - -EOT; -} -function show_footer($quit = true) { - echo << -
    - - -EOT; - $quit && exit(); -} - -function loginit($logfile) { - global $lang; - showjsmessage($lang['init_log'].' '.$logfile); - if($fp = @fopen('./forumdata/logs/'.$logfile.'.php', 'w')) { - fwrite($fp, '<'.'?PHP exit(); ?'.">\n"); - fclose($fp); - } -} -function showjsmessage($message) { - if(VIEW_OFF) return; - echo ''."\r\n"; - flush(); - ob_flush(); -} -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 redirect($url) { - - echo ""; - exit(); - -} - -function get_onlineip() { - $onlineip = ''; - if(getenv('HTTP_CLIENT_IP') && strcasecmp(getenv('HTTP_CLIENT_IP'), 'unknown')) { - $onlineip = getenv('HTTP_CLIENT_IP'); - } elseif(getenv('HTTP_X_FORWARDED_FOR') && strcasecmp(getenv('HTTP_X_FORWARDED_FOR'), 'unknown')) { - $onlineip = getenv('HTTP_X_FORWARDED_FOR'); - } elseif(getenv('REMOTE_ADDR') && strcasecmp(getenv('REMOTE_ADDR'), 'unknown')) { - $onlineip = getenv('REMOTE_ADDR'); - } elseif(isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] && strcasecmp($_SERVER['REMOTE_ADDR'], 'unknown')) { - $onlineip = $_SERVER['REMOTE_ADDR']; - } - return $onlineip; -} -function timezone_set($timeoffset = 8) { - if(function_exists('date_default_timezone_set')) { - @date_default_timezone_set('Etc/GMT'.($timeoffset > 0 ? '-' : '+').(abs($timeoffset))); - } -} -function save_config_file($filename, $config, $default) { - - $config = setdefault($config, $default); - $date = gmdate("Y-m-d H:i:s", time() + 3600 * 8); - $content = << $config)); - $content .= "\r\n// ".str_pad(' THE END ', 50, '-', STR_PAD_BOTH)."\r\n return \$_config;"; - file_put_contents($filename, $content); -} - -function setdefault($var, $default) { - foreach ($default as $k => $v) { - if(!isset($var[$k])) { - $var[$k] = $default[$k]; - } elseif(is_array($v)) { - $var[$k] = setdefault($var[$k], $default[$k]); - } - } - return $var; -} - -function authcode($string, $operation = 'DECODE', $key = '', $expiry = 0) { - $ckey_length = 4; - $key = md5($key ? $key : UC_KEY); - $keya = md5(substr($key, 0, 16)); - $keyb = md5(substr($key, 16, 16)); - $keyc = $ckey_length ? ($operation == 'DECODE' ? substr($string, 0, $ckey_length): substr(md5(microtime()), -$ckey_length)) : ''; - - $cryptkey = $keya.md5($keya.$keyc); - $key_length = strlen($cryptkey); - - $string = $operation == 'DECODE' ? base64_decode(substr($string, $ckey_length)) : sprintf('%010d', $expiry ? $expiry + time() : 0).substr(md5($string.$keyb), 0, 16).$string; - $string_length = strlen($string); - $result = ''; - $box = range(0, 255); - $rndkey = array(); - for($i = 0; $i <= 255; $i++) { - $rndkey[$i] = ord($cryptkey[$i % $key_length]); - } - for($j = $i = 0; $i < 256; $i++) { - $j = ($j + $box[$i] + $rndkey[$i]) % 256; - $tmp = $box[$i]; - $box[$i] = $box[$j]; - $box[$j] = $tmp; - } - for($a = $j = $i = 0; $i < $string_length; $i++) { - $a = ($a + 1) % 256; - $j = ($j + $box[$a]) % 256; - $tmp = $box[$a]; - $box[$a] = $box[$j]; - $box[$j] = $tmp; - $result .= chr(ord($string[$i]) ^ ($box[($box[$a] + $box[$j]) % 256])); - } - if($operation == 'DECODE') { - if((substr($result, 0, 10) == 0 || substr($result, 0, 10) - time() > 0) && substr($result, 10, 16) == substr(md5(substr($result, 26).$keyb), 0, 16)) { - return substr($result, 26); - } else { - return ''; - } - } else { - return $keyc.str_replace('=', '', base64_encode($result)); - } - -} - -function generate_key() { - $random = random(32); - $info = md5($_SERVER['SERVER_SOFTWARE'].$_SERVER['SERVER_NAME'].$_SERVER['SERVER_ADDR'].$_SERVER['SERVER_PORT'].$_SERVER['HTTP_USER_AGENT'].time()); - $return = ''; - for($i=0; $i<64; $i++) { - $p = intval($i/2); - $return[$i] = $i % 2 ? $random[$p] : $info[$p]; - } - return implode('', $return); -} - -function show_install() { - if(VIEW_OFF) return; -?> - -

    -
    -
    - -
    - -
    - -
    -query(createtable($query, $db->version())); - showjsmessage(lang('create_table').' '.$name.' ... '.lang('succeed')); - } else { - $db->query($query); - } - - } - } -} - -function charcovert($string) { - if(!get_magic_quotes_gpc()) { - $string = str_replace('\'', '\\\'', $string); - } else { - $string = str_replace('\"', '"', $string); - } - return $string; -} - -function insertconfig($s, $find, $replace) { - if(preg_match($find, $s)) { - $s = preg_replace($find, $replace, $s); - } else { - $s .= "\r\n".$replace; - } - return $s; -} - -function getgpc($k, $t='GP') { - $t = strtoupper($t); - switch($t) { - case 'GP' : isset($_POST[$k]) ? $var = &$_POST : $var = &$_GET; break; - case 'G': $var = &$_GET; break; - case 'P': $var = &$_POST; break; - case 'C': $var = &$_COOKIE; break; - case 'R': $var = &$_REQUEST; break; - } - return isset($var[$k]) ? $var[$k] : null; -} - -function var_to_hidden($k, $v) { - return "\n"; -} - -function fsocketopen($hostname, $port = 80, &$errno, &$errstr, $timeout = 15) { - $fp = ''; - if(function_exists('fsockopen')) { - $fp = @fsockopen($hostname, $port, $errno, $errstr, $timeout); - } elseif(function_exists('pfsockopen')) { - $fp = @pfsockopen($hostname, $port, $errno, $errstr, $timeout); - } elseif(function_exists('stream_socket_client')) { - $fp = @stream_socket_client($hostname.':'.$port, $errno, $errstr, $timeout); - } - return $fp; -} - -function dfopen($url, $limit = 0, $post = '', $cookie = '', $bysocket = FALSE, $ip = '', $timeout = 15, $block = TRUE, $encodetype = 'URLENCODE', $allowcurl = TRUE) { - $return = ''; - $matches = parse_url($url); - $scheme = $matches['scheme']; - $host = $matches['host']; - $path = $matches['path'] ? $matches['path'].($matches['query'] ? '?'.$matches['query'] : '') : '/'; - $port = !empty($matches['port']) ? $matches['port'] : 80; - - if(function_exists('curl_init') && $allowcurl) { - $ch = curl_init(); - $ip && curl_setopt($ch, CURLOPT_HTTPHEADER, array("Host: ".$host)); - curl_setopt($ch, CURLOPT_URL, $scheme.'://'.($ip ? $ip : $host).':'.$port.$path); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); - if($post) { - curl_setopt($ch, CURLOPT_POST, 1); - if($encodetype == 'URLENCODE') { - curl_setopt($ch, CURLOPT_POSTFIELDS, $post); - } else { - parse_str($post, $postarray); - curl_setopt($ch, CURLOPT_POSTFIELDS, $postarray); - } - } - if($cookie) { - curl_setopt($ch, CURLOPT_COOKIE, $cookie); - } - curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); - $data = curl_exec($ch); - $status = curl_getinfo($ch); - $errno = curl_errno($ch); - curl_close($ch); - if($errno || $status['http_code'] != 200) { - return; - } else { - return !$limit ? $data : substr($data, 0, $limit); - } - } - - if($post) { - $out = "POST $path HTTP/1.0\r\n"; - $header = "Accept: */*\r\n"; - $header .= "Accept-Language: zh-cn\r\n"; - $boundary = $encodetype == 'URLENCODE' ? '' : '; boundary='.trim(substr(trim($post), 2, strpos(trim($post), "\n") - 2)); - $header .= $encodetype == 'URLENCODE' ? "Content-Type: application/x-www-form-urlencoded\r\n" : "Content-Type: multipart/form-data$boundary\r\n"; - $header .= "User-Agent: $_SERVER[HTTP_USER_AGENT]\r\n"; - $header .= "Host: $host:$port\r\n"; - $header .= 'Content-Length: '.strlen($post)."\r\n"; - $header .= "Connection: Close\r\n"; - $header .= "Cache-Control: no-cache\r\n"; - $header .= "Cookie: $cookie\r\n\r\n"; - $out .= $header.$post; - } else { - $out = "GET $path HTTP/1.0\r\n"; - $header = "Accept: */*\r\n"; - $header .= "Accept-Language: zh-cn\r\n"; - $header .= "User-Agent: $_SERVER[HTTP_USER_AGENT]\r\n"; - $header .= "Host: $host:$port\r\n"; - $header .= "Connection: Close\r\n"; - $header .= "Cookie: $cookie\r\n\r\n"; - $out .= $header; - } - - $fpflag = 0; - if(!$fp = @fsocketopen(($ip ? $ip : $host), $port, $errno, $errstr, $timeout)) { - $context = array( - 'http' => array( - 'method' => $post ? 'POST' : 'GET', - 'header' => $header, - 'content' => $post, - 'timeout' => $timeout, - ), - ); - $context = stream_context_create($context); - $fp = @fopen($scheme.'://'.($ip ? $ip : $host).':'.$port.$path, 'b', false, $context); - $fpflag = 1; - } - - if(!$fp) { - return ''; - } else { - stream_set_blocking($fp, $block); - stream_set_timeout($fp, $timeout); - @fwrite($fp, $out); - $status = stream_get_meta_data($fp); - if(!$status['timed_out']) { - while (!feof($fp) && !$fpflag) { - if(($header = @fgets($fp)) && ($header == "\r\n" || $header == "\n")) { - break; - } - } - - $stop = false; - while(!feof($fp) && !$stop) { - $data = fread($fp, ($limit == 0 || $limit > 8192 ? 8192 : $limit)); - $return .= $data; - if($limit) { - $limit -= strlen($data); - $stop = $limit <= 0; - } - } - } - @fclose($fp); - return $return; - } -} - -function check_env() { - - global $lang, $attachdir; - - $errors = array('quit' => false); - $quit = false; - - if(!function_exists('mysql_connect') && !function_exists('mysqli_connect')) { - $errors[] = 'mysql_unsupport'; - $quit = true; - } - - if(PHP_VERSION < '4.3') { - $errors[] = 'php_version_430'; - $quit = true; - } - - if(!file_exists(ROOT_PATH.'./config/config.php')) { - $errors[] = lang('config_nonexistence'); - $quit = true; - } elseif(!is_writeable(ROOT_PATH.'./config/config.php')) { - $errors[] = lang('config_unwriteable'); - $quit = true; - } - - $checkdirarray = array( - 'attach' => $attachdir, - ); - - foreach($checkdirarray as $key => $dir) { - if(!dir_writeable(ROOT_PATH.$dir)) { - $langkey = $key.'_unwriteable'; - $errors[] = $key.'_unwriteable'; - if(!in_array($key, array('ftemplate'))) { - $quit = TRUE; - } - } - } - $errors['quit'] = $quit; - return $errors; -} - -function show_error($type, $errors = '', $quit = false) { - - global $lang, $step,$runqueryerror; - $title = lang($type); - $comment = lang($type.'_comment', false); - $errormsg = ''; - if($errors) { - if(!empty($errors)) { - foreach ((array)$errors as $k => $v) { - if(is_numeric($k)) { - $comment .= "
  • ".lang($v)."
  • "; - } - } - } - } - if($step > 0) { - echo "
    $title
      $comment
    "; - } else { - echo "
    $title
      $comment
    "; - } - - if($quit) { - echo '
    '.$lang['error_quit_msg'].'





    '; - } - - echo '
    '; - $runqueryerror++; - show_footer($quit); -} - -function show_tips($tip, $title = '', $comment = '', $style = 1) { - global $lang; - $title = empty($title) ? lang($tip) : $title; - $comment = empty($comment) ? lang($tip.'_comment', FALSE) : $comment; - if($style) { - echo "

    $title

    "; - } - $comment && print($comment); - echo ""; -} - -function show_setting($setname, $varname = '', $value = '', $type = 'text|password|checkbox', $error = '') { - if($setname == 'start') { - echo "
    \n"; - return; - } elseif($setname == 'end') { - echo "\n\n
    \n"; - return; - } elseif($setname == 'hidden') { - echo "\n"; - return; - } - if(strpos($type, 'submit') !== FALSE) { - echo '
    '; - if(strpos($type, 'oldbtn') !== FALSE) { - echo "\n"; - } - $value = empty($value) ? 'next_step' : $value; - echo "\n"; - echo '
    '; - return true; - } - - echo "\n".' '.(empty($setname) ? '' : lang($setname).':')."\n"; - if($type == 'text' || $type == 'password') { - $value = dhtmlspecialchars($value); - echo ""; - - } elseif($type == 'checkbox') { - if(!is_array($varname) && !is_array($value)) { - echo ""; - echo "\n"; - } - }elseif($type=='select'){ - echo ""; - - } else { - echo $value; - } - - echo "\n"; - if($error) { - $comment = ''.(is_string($error) ? lang($error) : lang($setname.'_error')).''; - } else { - $comment = lang($setname.'_comment', false); - } - echo "$comment\n\n"; - - return true; -} - -function show_step($step) { - - global $method; - - $laststep = 4; - $title = lang('step_'.$method.'_title'); - $comment = lang('step_'.$method.'_desc'); - $step_title_1 = lang('step_title_1'); - $step_title_2 = lang('step_title_2'); - $step_title_3 = lang('step_title_3'); - $step_title_4 = lang('step_title_4'); - - $stepclass = array(); - for($i = 1; $i <= $laststep; $i++) { - $stepclass[$i] = $i == $step ? 'current' : ($i < $step ? '' : 'unactivated'); - } - $stepclass[$laststep] .= ' last'; - - echo << -

    $title

    -

    $comment

    - -
    -
      -
    • $step_title_1
    • -
    • $step_title_2
    • -
    • $step_title_3
    • -
    • $step_title_4
    • -
    -
    -
    - -
    -EOT; - -} - -function lang($lang_key, $force = true) { - return isset($GLOBALS['lang'][$lang_key]) ? $GLOBALS['lang'][$lang_key] : ($force ? $lang_key : ''); -} - - -function _generate_key() { - $random = random(32); - $info = md5($_SERVER['SERVER_SOFTWARE'].$_SERVER['SERVER_NAME'].$_SERVER['SERVER_ADDR'].$_SERVER['SERVER_PORT'].$_SERVER['HTTP_USER_AGENT'].time()); - $return = array(); - for($i=0; $i<32; $i++) { - $return[$i] = $random[$i].$info[$i]; - } - return implode('', $return); -} - -function install_districtdata() { - global $_G, $db, $tablepre; - showjsmessage(lang('install_test_data')." ... ".lang('succeed')); - - $sqlfile = ROOT_PATH.'./install/data/common_district_{#id}.sql'; - for($i = 1; $i < 4; $i++) { - $sqlfileid = str_replace('{#id}', $i, $sqlfile); - if(file_exists($sqlfileid)) { - $sql = file_get_contents($sqlfileid); - $sql = str_replace("\r\n", "\n", $sql); - runquery($sql); - } - } -} - -function getvars($data, $type = 'VAR') { - $evaluate = ''; - foreach($data as $key => $val) { - if(!preg_match("/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/", $key)) { - continue; - } - if(is_array($val)) { - $evaluate .= buildarray($val, 0, "\${$key}")."\r\n"; - } else { - $val = addcslashes($val, '\'\\'); - $evaluate .= $type == 'VAR' ? "\$$key = '$val';\n" : "define('".strtoupper($key)."', '$val');\n"; - } - } - return $evaluate; -} - -function buildarray($array, $level = 0, $pre = '$_config') { - static $ks; - if($level == 0) { - $ks = array(); - $return = ''; - } - - foreach ($array as $key => $val) { - if($level == 0) { - $newline = str_pad(' CONFIG '.strtoupper($key).' ', 70, '-', STR_PAD_BOTH); - $return .= "\r\n// $newline //\r\n"; - if($key == 'admincp') { - $newline = str_pad(' Founders: $_config[\'admincp\'][\'founder\'] = \'1,2,3\'; ', 70, '-', STR_PAD_BOTH); - $return .= "// $newline //\r\n"; - } - } - - $ks[$level] = $ks[$level - 1]."['$key']"; - if(is_array($val)) { - $ks[$level] = $ks[$level - 1]."['$key']"; - $return .= buildarray($val, $level + 1, $pre); - } else { - $val = is_string($val) || strlen($val) > 12 || !preg_match("/^\-?[1-9]\d*$/", $val) ? '\''.addcslashes($val, '\'\\').'\'' : $val; - $return .= $pre.$ks[$level - 1]."['$key']"." = $val;\r\n"; - } - } - return $return; -} - -function dimplode($array) { - if(!empty($array)) { - return "'".implode("','", is_array($array) ? $array : array($array))."'"; - } else { - return ''; - } -} -function implode_field_value($array, $glue = ',') { - $sql = $comma = ''; - foreach ($array as $k => $v) { - $sql .= $comma."`$k`='$v'"; - $comma = $glue; - } - return $sql; -} - -function daddslashes($string, $force = 1) { - if(is_array($string)) { - foreach($string as $key => $val) { - $string[$key] = daddslashes($val, $force); - } - } else { - $string = addslashes($string); - } - return $string; -} -function dstripslashes($string) { - if(is_array($string)) { - foreach($string as $key => $val) { - $string[$key] = dstripslashes($val); - } - } else { - $string = stripslashes($string); - } - return $string; -} -function dmkdir($dir, $mode = 0777){ - if(!is_dir($dir)) { - dmkdir(dirname($dir), $mode); - @mkdir($dir, $mode); - @touch($dir.'/index.htm'); @chmod($dir.'/index.htm', 0777); - } - return true; -} -function dhtmlspecialchars($string) { - if(is_array($string)) { - foreach($string as $key => $val) { - $string[$key] = dhtmlspecialchars($val); - } - } else { - $string = str_replace(array('&', '"', '<', '>'), array('&', '"', '<', '>'), $string); - if(strpos($string, '&#') !== false) { - $string = preg_replace('/&((#(\d{3,5}|x[a-fA-F0-9]{4}));)/', '&\\1', $string); - } - } - return $string; -} +list_bucket(); + if(!$response->isOK()){ + return array(); + } + $bucket=$response->getBody(); + foreach($bucket['ListAllMyBucketsResult']['Buckets']['Bucket'] as $value){ + $re[]=$value['Name']; + } + return $re; + } +function show_msg($error_no, $error_msg = 'ok', $success = 1, $quit = TRUE) { + + show_header(); + global $step; + $title = lang($error_no); + $comment = 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 .= "
  • ".lang($v)."
  • "; + } + } + } + } + $back = lang('to_back'); + echo << + +
    + + +

    $title

    +
      $comment
    + +
    +
    +EOT; + show_footer($quit); +} + +function check_db($dbhost, $dbuser, $dbpw, $dbname, $tablepre) { + if(!function_exists('mysql_connect') && !function_exists('mysqli_connect')) { + show_msg('undefine_func', 'mysql_connect | mysqli_connect', 0); + } + $mysqlmode = function_exists('mysqli_connect') ? 'mysqli' : 'mysql'; + if($mysqlmode=='mysqli'){ + //兼容支持域名直接带有端口的情况 + if(strpos($dbhost,':')!==false){ + list($dbhost,$port)=explode(':',$dbhost); + + }elseif(strpos($dbhost,'.sock')!==false){//地址直接是socket地址 + $unix_socket=$dbhost; + $dbhost='localhost'; + } + if(empty($port)) $port='3306'; + $link = new mysqli($dbhost, $dbuser, $dbpw, '', $port, $unix_socket); + $errno = $link->connect_errno; + $error = $link->connect_error; + }else{ + $link = @mysql_connect($dbhost, $dbuser, $dbpw); + $errno = mysql_errno(); + $error = mysql_error(); + } + if($errno) { + if($errno == 1045) { + show_msg('database_errno_1045', $error, 0); + } elseif($errno == 2003 || $errno==2002) { + show_msg('database_errno_2003', $error, 0); + } else { + show_msg('database_connect_error', $error, 0); + } + } else { + if($query = (($mysqlmode == 'mysql') ? @mysql_query("SHOW databases") : $link->query("SHOW databases"))) { + if(!$query) { + return false; + } + while($row = (($mysqlmode == 'mysql') ? mysql_fetch_row($query) : $query->fetch_row())) { + if($dbname==$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(ROOT_PATH.$item_path)) { + if(is_dir(ROOT_PATH.$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(ROOT_PATH.$item_path)) { + if(is_writable(ROOT_PATH.$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(ROOT_PATH.$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 == 'allow_url_fopen') { + $env_items[$key]['current'] = @ini_get('allow_url_fopen') ? ini_get('allow_url_fopen') : '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(ROOT_PATH) / (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) { + foreach($func_items as $item) { + function_exists($item) or show_msg('undefine_func', $item, 0); + } +} + +function show_env_result(&$env_items, &$func_items, &$filesock_items) { + + $env_str = $file_str = $func_str = ''; + $error_code = 0; + foreach($env_items as $key => $item) { + if($key == 'php' && strcmp($item['current'], $item['r']) < 0) { + show_msg('php_version_too_low', $item['current'], 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_CHECK_ERROR; + } + } else { + if(strcmp($item['current'], $item['r']) < 0) { + $status = 0; + $error_code = ENV_CHECK_ERROR; + } + } + } + if(VIEW_OFF) { + $env_str .= "\t\t\n"; + } else { + $env_str .= "\n"; + $env_str .= "".lang($key)."\n"; + $env_str .= "".lang($item['r'])."\n"; + $env_str .= "".lang($item['b'])."\n"; + $env_str .= ($status ? "" : "").$item['current']."\n"; + $env_str .= "\n"; + } + } + show_header(); + if($env_str){ + echo "

    ".lang('env_check')."

    \n"; + echo "\n"; + echo "\n"; + echo "\t\n"; + echo "\t\n"; + echo "\t\n"; + echo "\t\n"; + echo "\n"; + echo $env_str; + echo "
    ".lang('project')."".lang('dzzoffice_required')."".lang('dzzoffice_best')."".lang('curr_server')."
    \n"; + } + + foreach($func_items as $item) { + $status = function_exists($item); + $func_str .= "\n"; + $func_str .= "$item()\n"; + if($status) { + $func_str .= "".lang('supportted')."\n"; + $func_str .= "".lang('none')."\n"; + } else { + $error_code = ENV_CHECK_ERROR; + $func_str .= "".lang('unsupportted')."\n"; + $func_str .= "".lang('advice_'.$item)."\n"; + } + } + $func_strextra = ''; + $filesock_disabled = 0; + foreach($filesock_items as $item) { + $status = function_exists($item); + $func_strextra .= "\n"; + $func_strextra .= "$item()\n"; + if($status) { + $func_strextra .= "".lang('supportted')."\n"; + $func_strextra .= "".lang('none')."\n"; + break; + } else { + $filesock_disabled++; + $func_strextra .= "".lang('unsupportted')."\n"; + $func_strextra .= "".lang('advice_'.$item)."\n"; + } + } + if($filesock_disabled == count($filesock_items)) { + $error_code = ENV_CHECK_ERROR; + } + if($func_str || $func_strextra){ + echo "

    ".lang('func_depend')."

    \n"; + echo "\n"; + echo "\n"; + echo "\t\n"; + echo "\t\n"; + + echo "\n"; + echo $func_str.$func_strextra; + echo "
    ".lang('func_name')."".lang('check_result')."
    \n"; + } + show_next_step(2,$error_code); + show_footer(); +} +function show_dirfile_result(&$dirfile_items) { + + $file_str = ''; + $dir_str = ''; + $error_code = 0; + + foreach($dirfile_items as $key => $item) { + $tagname = $item['type'] == 'file' ? 'file' : 'dir'; + $variable = $item['type'].'_str'; + if(empty($$variable)) $$variable=''; + $$variable .= "\n"; + $$variable .= "$item[path]".lang('writeable')."\n"; + if($item['status'] == 1) { + $$variable .= "".lang('writeable')."\n"; + } elseif($item['status'] == -1) { + $error_code = ENV_CHECK_ERROR; + $$variable .= "".lang('nodir')."\n"; + } else { + $error_code = ENV_CHECK_ERROR; + $$variable .= "".lang('unwriteable')."\n"; + } + $$variable .= "\n"; + + } + show_header(); + if($file_str || $dir_str){ + echo "

    ".lang('priv_check')."

    \n"; + echo "\n"; + echo "\t\n"; + echo "\t\n"; + echo "\t\n"; + echo "\t\n"; + echo "\n"; + echo $file_str; + echo $dir_str; + echo "
    ".lang('step1_file')."".lang('step1_need_status')."".lang('step1_status')."
    \n"; + } + show_next_step(3,$error_code); + show_footer(); +} +function show_next_step($step, $error_code) { + global $uchidden; + echo "
    \n"; + echo ""; + if($error_code == 0) { + $nextstep = "\n"; + } else { + $nextstep = "\n"; + } + echo '
    '.$nextstep.'
    '; + echo "
    \n"; +} +function show_form(&$form_items, $error_msg) { + global $step; + + if(empty($form_items) || !is_array($form_items)) { + return; + } + show_header(); + show_setting('start'); + show_setting('hidden', 'step', $step); + $is_first = 1; + echo '

    '; + foreach($form_items as $key => $items) { + global ${'error_'.$key}; + if($is_first == 0) { + echo ''; + } + if(!${'error_'.$key}) { + show_tips('tips_'.$key); + } else { + show_error('tips_admin_config', ${'error_'.$key}); + } + + echo ''; + foreach($items as $k => $v) { + $value = ''; + if(!empty($error_msg)) { + $value = isset($_POST[$key][$k]) ? $_POST[$key][$k] : ''; + } + if(empty($value)) { + if(isset($v['value']) && is_array($v['value'])) { + if($v['value']['type'] == 'constant') { + $value = defined($v['value']['var']) ? constant($v['value']['var']) : $v['value']['var']; + }elseif($v['value']['type'] == 'array') { + $value = $v['value']['var']; + } else { + $value = !empty($GLOBALS[$v['value']['var']])?$GLOBALS[$v['value']['var']]:''; + } + } else { + $value = ''; + } + } + show_setting($k, $key.'['.$k.']', $value, $v['type'], isset($error_msg[$key][$k]) ? $key.'_'.$k.'_invalid' : ''); + } + if($is_first) { + $is_first = 0; + } + } + echo '
    '; + echo '
    '; + echo ''; + show_setting('', 'submitname', 'new_step', ($step == 2 ? 'submit|oldbtn' : 'submit' )); + show_setting('end'); + show_footer(); +} + +function show_license() { + global $self, $step; + $next = $step + 1; + show_header(); + $title = lang('step_env_check_title'); + $version='DzzOffice'.CORE_VERSION.'    '.INSTALL_LANG.' '.CORE_RELEASE; + $release = CORE_RELEASE; + $install_lang = lang(INSTALL_LANG); + echo << + body{background:#2d3137} + +
    + +
    +

    +
    +

    $install_lang

    +

    $version

    +
    + +
    +
    + +EOT; +show_footer(); +} +if(!function_exists('file_put_contents')) { + function file_put_contents($filename, $s) { + $fp = @fopen($filename, 'w'); + @fwrite($fp, $s); + @fclose($fp); + return TRUE; + } +} + +function createtable($sql, $dbver) { + + $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','INNODB')) ? $type : 'MyISAM'; + return preg_replace("/^\s*(CREATE TABLE\s+.+\s+\(.+?\)).*$/isU", "\\1", $sql). + (" ENGINE=$type DEFAULT CHARSET=".DBCHARSET); +} + +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(ROOT_PATH, '', $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 show_header() { + define('SHOW_HEADER', TRUE); + global $step; + $version = CORE_VERSION; + $release = CORE_RELEASE; + $install_lang = lang(INSTALL_LANG); + $title = lang('title_install'); + $charset = CHARSET; + echo << + + + +$title + + + + +
    + +EOT; +} +function show_footer($quit = true) { + echo << +
    + + +EOT; + $quit && exit(); +} + +function loginit($logfile) { + global $lang; + showjsmessage($lang['init_log'].' '.$logfile); + if($fp = @fopen('./forumdata/logs/'.$logfile.'.php', 'w')) { + fwrite($fp, '<'.'?PHP exit(); ?'.">\n"); + fclose($fp); + } +} +function showjsmessage($message) { + if(VIEW_OFF) return; + echo ''."\r\n"; + flush(); + ob_flush(); +} +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[random_int(0, $max)]; + } + return $hash; +} +function redirect($url) { + + echo ""; + exit(); + +} + +function get_onlineip() { + $onlineip = ''; + if(getenv('HTTP_CLIENT_IP') && strcasecmp(getenv('HTTP_CLIENT_IP'), 'unknown')) { + $onlineip = getenv('HTTP_CLIENT_IP'); + } elseif(getenv('HTTP_X_FORWARDED_FOR') && strcasecmp(getenv('HTTP_X_FORWARDED_FOR'), 'unknown')) { + $onlineip = getenv('HTTP_X_FORWARDED_FOR'); + } elseif(getenv('REMOTE_ADDR') && strcasecmp(getenv('REMOTE_ADDR'), 'unknown')) { + $onlineip = getenv('REMOTE_ADDR'); + } elseif(isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] && strcasecmp($_SERVER['REMOTE_ADDR'], 'unknown')) { + $onlineip = $_SERVER['REMOTE_ADDR']; + } + return $onlineip; +} +function timezone_set($timeoffset = 8) { + if(function_exists('date_default_timezone_set')) { + @date_default_timezone_set('Etc/GMT'.($timeoffset > 0 ? '-' : '+').(abs($timeoffset))); + } +} +function save_config_file($filename, $config, $default) { + + $config = setdefault($config, $default); + $date = gmdate("Y-m-d H:i:s", time() + 3600 * 8); + $content = << $config)); + $content .= "\r\n// ".str_pad(' THE END ', 50, '-', STR_PAD_BOTH)."\r\n return \$_config;"; + file_put_contents($filename, $content); +} + +function setdefault($var, $default) { + foreach ($default as $k => $v) { + if(!isset($var[$k])) { + $var[$k] = $default[$k]; + } elseif(is_array($v)) { + $var[$k] = setdefault($var[$k], $default[$k]); + } + } + return $var; +} + +function authcode($string, $operation = 'DECODE', $key = '', $expiry = 0) { + $ckey_length = 4; + $key = md5($key ? $key : UC_KEY); + $keya = md5(substr($key, 0, 16)); + $keyb = md5(substr($key, 16, 16)); + $keyc = $ckey_length ? ($operation == 'DECODE' ? substr($string, 0, $ckey_length): substr(md5(microtime()), -$ckey_length)) : ''; + + $cryptkey = $keya.md5($keya.$keyc); + $key_length = strlen($cryptkey); + + $string = $operation == 'DECODE' ? base64_decode(substr($string, $ckey_length)) : sprintf('%010d', $expiry ? $expiry + time() : 0).substr(md5($string.$keyb), 0, 16).$string; + $string_length = strlen($string); + $result = ''; + $box = range(0, 255); + $rndkey = array(); + for($i = 0; $i <= 255; $i++) { + $rndkey[$i] = ord($cryptkey[$i % $key_length]); + } + for($j = $i = 0; $i < 256; $i++) { + $j = ($j + $box[$i] + $rndkey[$i]) % 256; + $tmp = $box[$i]; + $box[$i] = $box[$j]; + $box[$j] = $tmp; + } + for($a = $j = $i = 0; $i < $string_length; $i++) { + $a = ($a + 1) % 256; + $j = ($j + $box[$a]) % 256; + $tmp = $box[$a]; + $box[$a] = $box[$j]; + $box[$j] = $tmp; + $result .= chr(ord($string[$i]) ^ ($box[($box[$a] + $box[$j]) % 256])); + } + if($operation == 'DECODE') { + if((substr($result, 0, 10) == 0 || substr($result, 0, 10) - time() > 0) && substr($result, 10, 16) == substr(md5(substr($result, 26).$keyb), 0, 16)) { + return substr($result, 26); + } else { + return ''; + } + } else { + return $keyc.str_replace('=', '', base64_encode($result)); + } + +} + +function generate_key() { + $random = random(32); + $info = md5($_SERVER['SERVER_SOFTWARE'].$_SERVER['SERVER_NAME'].$_SERVER['SERVER_ADDR'].$_SERVER['SERVER_PORT'].$_SERVER['HTTP_USER_AGENT'].time()); + $return = ''; + for($i=0; $i<64; $i++) { + $p = intval($i/2); + $return[$i] = $i % 2 ? $random[$p] : $info[$p]; + } + return implode('', $return); +} + +function show_install() { + if(VIEW_OFF) return; +?> + +

    +
    +
    + +
    + +
    + +
    +query(createtable($query, $db->version())); + showjsmessage(lang('create_table').' '.$name.' ... '.lang('succeed')); + } else { + $db->query($query); + } + + } + } +} + +function charcovert($string) { + if(!get_magic_quotes_gpc()) { + $string = str_replace('\'', '\\\'', $string); + } else { + $string = str_replace('\"', '"', $string); + } + return $string; +} + +function insertconfig($s, $find, $replace) { + if(preg_match($find, $s)) { + $s = preg_replace($find, $replace, $s); + } else { + $s .= "\r\n".$replace; + } + return $s; +} + +function getgpc($k, $t='GP') { + $t = strtoupper($t); + switch($t) { + case 'GP' : isset($_POST[$k]) ? $var = &$_POST : $var = &$_GET; break; + case 'G': $var = &$_GET; break; + case 'P': $var = &$_POST; break; + case 'C': $var = &$_COOKIE; break; + case 'R': $var = &$_REQUEST; break; + } + return isset($var[$k]) ? $var[$k] : null; +} + +function var_to_hidden($k, $v) { + return "\n"; +} + +function fsocketopen($hostname, $port = 80, &$errno, &$errstr, $timeout = 15) { + $fp = ''; + if(function_exists('fsockopen')) { + $fp = @fsockopen($hostname, $port, $errno, $errstr, $timeout); + } elseif(function_exists('pfsockopen')) { + $fp = @pfsockopen($hostname, $port, $errno, $errstr, $timeout); + } elseif(function_exists('stream_socket_client')) { + $fp = @stream_socket_client($hostname.':'.$port, $errno, $errstr, $timeout); + } + return $fp; +} + +function dfopen($url, $limit = 0, $post = '', $cookie = '', $bysocket = FALSE, $ip = '', $timeout = 15, $block = TRUE, $encodetype = 'URLENCODE', $allowcurl = TRUE) { + $return = ''; + $matches = parse_url($url); + $scheme = $matches['scheme']; + $host = $matches['host']; + $path = $matches['path'] ? $matches['path'].($matches['query'] ? '?'.$matches['query'] : '') : '/'; + $port = !empty($matches['port']) ? $matches['port'] : 80; + + if(function_exists('curl_init') && $allowcurl) { + $ch = curl_init(); + $ip && curl_setopt($ch, CURLOPT_HTTPHEADER, array("Host: ".$host)); + curl_setopt($ch, CURLOPT_URL, $scheme.'://'.($ip ? $ip : $host).':'.$port.$path); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + if($post) { + curl_setopt($ch, CURLOPT_POST, 1); + if($encodetype == 'URLENCODE') { + curl_setopt($ch, CURLOPT_POSTFIELDS, $post); + } else { + parse_str($post, $postarray); + curl_setopt($ch, CURLOPT_POSTFIELDS, $postarray); + } + } + if($cookie) { + curl_setopt($ch, CURLOPT_COOKIE, $cookie); + } + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); + $data = curl_exec($ch); + $status = curl_getinfo($ch); + $errno = curl_errno($ch); + curl_close($ch); + if($errno || $status['http_code'] != 200) { + return; + } else { + return !$limit ? $data : substr($data, 0, $limit); + } + } + + if($post) { + $out = "POST $path HTTP/1.0\r\n"; + $header = "Accept: */*\r\n"; + $header .= "Accept-Language: zh-cn\r\n"; + $boundary = $encodetype == 'URLENCODE' ? '' : '; boundary='.trim(substr(trim($post), 2, strpos(trim($post), "\n") - 2)); + $header .= $encodetype == 'URLENCODE' ? "Content-Type: application/x-www-form-urlencoded\r\n" : "Content-Type: multipart/form-data$boundary\r\n"; + $header .= "User-Agent: $_SERVER[HTTP_USER_AGENT]\r\n"; + $header .= "Host: $host:$port\r\n"; + $header .= 'Content-Length: '.strlen($post)."\r\n"; + $header .= "Connection: Close\r\n"; + $header .= "Cache-Control: no-cache\r\n"; + $header .= "Cookie: $cookie\r\n\r\n"; + $out .= $header.$post; + } else { + $out = "GET $path HTTP/1.0\r\n"; + $header = "Accept: */*\r\n"; + $header .= "Accept-Language: zh-cn\r\n"; + $header .= "User-Agent: $_SERVER[HTTP_USER_AGENT]\r\n"; + $header .= "Host: $host:$port\r\n"; + $header .= "Connection: Close\r\n"; + $header .= "Cookie: $cookie\r\n\r\n"; + $out .= $header; + } + + $fpflag = 0; + if(!$fp = @fsocketopen(($ip ? $ip : $host), $port, $errno, $errstr, $timeout)) { + $context = array( + 'http' => array( + 'method' => $post ? 'POST' : 'GET', + 'header' => $header, + 'content' => $post, + 'timeout' => $timeout, + ), + ); + $context = stream_context_create($context); + $fp = @fopen($scheme.'://'.($ip ? $ip : $host).':'.$port.$path, 'b', false, $context); + $fpflag = 1; + } + + if(!$fp) { + return ''; + } else { + stream_set_blocking($fp, $block); + stream_set_timeout($fp, $timeout); + @fwrite($fp, $out); + $status = stream_get_meta_data($fp); + if(!$status['timed_out']) { + while (!feof($fp) && !$fpflag) { + if(($header = @fgets($fp)) && ($header == "\r\n" || $header == "\n")) { + break; + } + } + + $stop = false; + while(!feof($fp) && !$stop) { + $data = fread($fp, ($limit == 0 || $limit > 8192 ? 8192 : $limit)); + $return .= $data; + if($limit) { + $limit -= strlen($data); + $stop = $limit <= 0; + } + } + } + @fclose($fp); + return $return; + } +} + +function check_env() { + + global $lang, $attachdir; + + $errors = array('quit' => false); + $quit = false; + + if(!function_exists('mysql_connect') && !function_exists('mysqli_connect')) { + $errors[] = 'mysql_unsupport'; + $quit = true; + } + + if(PHP_VERSION < '4.3') { + $errors[] = 'php_version_430'; + $quit = true; + } + + if(!file_exists(ROOT_PATH.'./config/config.php')) { + $errors[] = lang('config_nonexistence'); + $quit = true; + } elseif(!is_writeable(ROOT_PATH.'./config/config.php')) { + $errors[] = lang('config_unwriteable'); + $quit = true; + } + + $checkdirarray = array( + 'attach' => $attachdir, + ); + + foreach($checkdirarray as $key => $dir) { + if(!dir_writeable(ROOT_PATH.$dir)) { + $langkey = $key.'_unwriteable'; + $errors[] = $key.'_unwriteable'; + if(!in_array($key, array('ftemplate'))) { + $quit = TRUE; + } + } + } + $errors['quit'] = $quit; + return $errors; +} + +function show_error($type, $errors = '', $quit = false) { + + global $lang, $step,$runqueryerror; + $title = lang($type); + $comment = lang($type.'_comment', false); + $errormsg = ''; + if($errors) { + if(!empty($errors)) { + foreach ((array)$errors as $k => $v) { + if(is_numeric($k)) { + $comment .= "
  • ".lang($v)."
  • "; + } + } + } + } + if($step > 0) { + echo "
    $title
      $comment
    "; + } else { + echo "
    $title
      $comment
    "; + } + + if($quit) { + echo '
    '.$lang['error_quit_msg'].'





    '; + } + + echo '
    '; + $runqueryerror++; + show_footer($quit); +} + +function show_tips($tip, $title = '', $comment = '', $style = 1) { + global $lang; + $title = empty($title) ? lang($tip) : $title; + $comment = empty($comment) ? lang($tip.'_comment', FALSE) : $comment; + if($style) { + echo "

    $title

    "; + } + $comment && print($comment); + echo ""; +} + +function show_setting($setname, $varname = '', $value = '', $type = 'text|password|checkbox', $error = '') { + if($setname == 'start') { + echo "
    \n"; + return; + } elseif($setname == 'end') { + echo "\n\n
    \n"; + return; + } elseif($setname == 'hidden') { + echo "\n"; + return; + } + if(strpos($type, 'submit') !== FALSE) { + echo '
    '; + if(strpos($type, 'oldbtn') !== FALSE) { + echo "\n"; + } + $value = empty($value) ? 'next_step' : $value; + echo "\n"; + echo '
    '; + return true; + } + + echo "\n".' '.(empty($setname) ? '' : lang($setname).':')."\n"; + if($type == 'text' || $type == 'password') { + $value = dhtmlspecialchars($value); + echo ""; + + } elseif($type == 'checkbox') { + if(!is_array($varname) && !is_array($value)) { + echo ""; + echo "\n"; + } + }elseif($type=='select'){ + echo ""; + + } else { + echo $value; + } + + echo "\n"; + if($error) { + $comment = ''.(is_string($error) ? lang($error) : lang($setname.'_error')).''; + } else { + $comment = lang($setname.'_comment', false); + } + echo "$comment\n\n"; + + return true; +} + +function show_step($step) { + + global $method; + + $laststep = 4; + $title = lang('step_'.$method.'_title'); + $comment = lang('step_'.$method.'_desc'); + $step_title_1 = lang('step_title_1'); + $step_title_2 = lang('step_title_2'); + $step_title_3 = lang('step_title_3'); + $step_title_4 = lang('step_title_4'); + + $stepclass = array(); + for($i = 1; $i <= $laststep; $i++) { + $stepclass[$i] = $i == $step ? 'current' : ($i < $step ? '' : 'unactivated'); + } + $stepclass[$laststep] .= ' last'; + + echo << +

    $title

    +

    $comment

    + +
    +
      +
    • $step_title_1
    • +
    • $step_title_2
    • +
    • $step_title_3
    • +
    • $step_title_4
    • +
    +
    +
    + +
    +EOT; + +} + +function lang($lang_key, $force = true) { + return isset($GLOBALS['lang'][$lang_key]) ? $GLOBALS['lang'][$lang_key] : ($force ? $lang_key : ''); +} + + +function _generate_key() { + $random = random(32); + $info = md5($_SERVER['SERVER_SOFTWARE'].$_SERVER['SERVER_NAME'].$_SERVER['SERVER_ADDR'].$_SERVER['SERVER_PORT'].$_SERVER['HTTP_USER_AGENT'].time()); + $return = array(); + for($i=0; $i<32; $i++) { + $return[$i] = $random[$i].$info[$i]; + } + return implode('', $return); +} + +function install_districtdata() { + global $_G, $db, $tablepre; + showjsmessage(lang('install_test_data')." ... ".lang('succeed')); + + $sqlfile = ROOT_PATH.'./install/data/common_district_{#id}.sql'; + for($i = 1; $i < 4; $i++) { + $sqlfileid = str_replace('{#id}', $i, $sqlfile); + if(file_exists($sqlfileid)) { + $sql = file_get_contents($sqlfileid); + $sql = str_replace("\r\n", "\n", $sql); + runquery($sql); + } + } +} + +function getvars($data, $type = 'VAR') { + $evaluate = ''; + foreach($data as $key => $val) { + if(!preg_match("/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/", $key)) { + continue; + } + if(is_array($val)) { + $evaluate .= buildarray($val, 0, "\${$key}")."\r\n"; + } else { + $val = addcslashes($val, '\'\\'); + $evaluate .= $type == 'VAR' ? "\$$key = '$val';\n" : "define('".strtoupper($key)."', '$val');\n"; + } + } + return $evaluate; +} + +function buildarray($array, $level = 0, $pre = '$_config') { + static $ks; + if($level == 0) { + $ks = array(); + $return = ''; + } + + foreach ($array as $key => $val) { + if($level == 0) { + $newline = str_pad(' CONFIG '.strtoupper($key).' ', 70, '-', STR_PAD_BOTH); + $return .= "\r\n// $newline //\r\n"; + if($key == 'admincp') { + $newline = str_pad(' Founders: $_config[\'admincp\'][\'founder\'] = \'1,2,3\'; ', 70, '-', STR_PAD_BOTH); + $return .= "// $newline //\r\n"; + } + } + + $ks[$level] = $ks[$level - 1]."['$key']"; + if(is_array($val)) { + $ks[$level] = $ks[$level - 1]."['$key']"; + $return .= buildarray($val, $level + 1, $pre); + } else { + $val = is_string($val) || strlen($val) > 12 || !preg_match("/^\-?[1-9]\d*$/", $val) ? '\''.addcslashes($val, '\'\\').'\'' : $val; + $return .= $pre.$ks[$level - 1]."['$key']"." = $val;\r\n"; + } + } + return $return; +} + +function dimplode($array) { + if(!empty($array)) { + return "'".implode("','", is_array($array) ? $array : array($array))."'"; + } else { + return ''; + } +} +function implode_field_value($array, $glue = ',') { + $sql = $comma = ''; + foreach ($array as $k => $v) { + $sql .= $comma."`$k`='$v'"; + $comma = $glue; + } + return $sql; +} + +function daddslashes($string, $force = 1) { + if(is_array($string)) { + foreach($string as $key => $val) { + $string[$key] = daddslashes($val, $force); + } + } else { + $string = addslashes($string); + } + return $string; +} +function dstripslashes($string) { + if(is_array($string)) { + foreach($string as $key => $val) { + $string[$key] = dstripslashes($val); + } + } else { + $string = stripslashes($string); + } + return $string; +} +function dmkdir($dir, $mode = 0777){ + if(!is_dir($dir)) { + dmkdir(dirname($dir), $mode); + @mkdir($dir, $mode); + @touch($dir.'/index.htm'); @chmod($dir.'/index.htm', 0777); + } + return true; +} +function dhtmlspecialchars($string) { + if(is_array($string)) { + foreach($string as $key => $val) { + $string[$key] = dhtmlspecialchars($val); + } + } else { + $string = str_replace(array('&', '"', '<', '>'), array('&', '"', '<', '>'), $string); + if(strpos($string, '&#') !== false) { + $string = preg_replace('/&((#(\d{3,5}|x[a-fA-F0-9]{4}));)/', '&\\1', $string); + } + } + return $string; +} diff --git a/install/include/install_var.php b/install/include/install_var.php index 1ab02e7..ab0ec8d 100644 --- a/install/include/install_var.php +++ b/install/include/install_var.php @@ -1,140 +1,140 @@ - array('c' => 'PHP_OS', 'r' => 'notset', 'b' => 'Linux'), - 'php' => array('c' => 'PHP_VERSION', 'r' => '5.3+', 'b' => 'php7+'), - 'attachmentupload' => array('r' => 'notset', 'b' => '50M'), - 'gdversion' => array('r' => '1.0', 'b' => '2.0'), - 'diskspace' => array('r' => '50M', 'b' => '10G以上'), - -); - -$dirfile_items = array -( - - //'config' => array('type' => 'file', 'path' => CONFIG), - 'config_dir' => array('type' => 'dir', 'path' => './config'), - //'data' => array('type' => 'dir', 'path' => './data'), - 'cache' => array('type' => 'dir', 'path' => './data/cache'), - 'avatar' => array('type' => 'dir', 'path' => './data/avatar'), - 'ftemplates' => array('type' => 'dir', 'path' => './data/template'), - 'attach' => array('type' => 'dir', 'path' => './data/attachment'), - 'attach_dzz' => array('type' => 'dir', 'path' => './data/attachment/dzz'), - 'attach_icon' => array('type' => 'dir', 'path' => './data/attachment/icon'), - 'attach_appico' => array('type' => 'dir', 'path' => './data/attachment/appico'), - 'attach_appimg' => array('type' => 'dir', 'path' => './data/attachment/appimg'), - 'attach_cache' => array('type' => 'dir', 'path' => './data/attachment/cache'), - 'attach_imgcache' => array('type' => 'dir', 'path' => './data/attachment/imgcache'), - 'attach_qrcode' => array('type' => 'dir', 'path' => './data/attachment/qrcode'), - 'logs' => array('type' => 'dir', 'path' => './data/log'), -); - - -$form_app_reg_items = array -( - - 'siteinfo' => array - ( - 'sitename' => array('type' => 'text', 'required' => 1, 'reg' => '/^.*$/', 'value' => array('type' => 'constant', 'var' => 'SOFT_NAME')), - 'siteurl' => array('type' => 'text', 'required' => 1, 'reg' => '/^https?:\/\//', 'value' => array('type' => 'var', 'var' => 'default_appurl')) - ) -); - -$form_db_init_items = array -( - 'dbinfo' => array - ( - 'company' => array('type' => 'text', 'required' => 0, 'reg' => '/^.+$/', 'value' => array('type' => 'var', 'var' => 'company')), - 'dbhost' => array('type' => 'text', 'required' => 1, 'reg' => '/^.+$/', 'value' => array('type' => 'var', 'var' => 'dbhost')), - 'dbname' => array('type' => 'text', 'required' => 1, 'reg' => '/^.+$/', 'value' => array('type' => 'var', 'var' => 'dbname')), - 'dbuser' => array('type' => 'text', 'required' => 0, 'reg' => '/^.*$/', 'value' => array('type' => 'var', 'var' => 'dbuser')), - 'dbpw' => array('type' => 'text', 'required' => 0, 'reg' => '/^.*$/', 'value' => array('type' => 'var', 'var' => 'dbpw')), - 'tablepre' => array('type' => 'text', 'required' => 0, 'reg' => '/^.*+/', 'value' => array('type' => 'var', 'var' => 'tablepre')), - 'adminemail' => array('type' => 'text', 'required' => 1, 'reg' => '/@/', 'value' => array('type' => 'var', 'var' => 'adminemail')), - ), - -); -$form_admin_init_items = array -( - - 'admininfo' => array - ( - 'email' => array('type' => 'text', 'required' => 1, 'reg' => '/@/', 'value' => array('type' => 'var', 'var' => 'adminemail')), - 'username' => array('type' => 'text', 'required' => 1, 'reg' => '/^.*$/', 'value' => array('type' => 'constant', 'var' => 'admin')), - 'password' => array('type' => 'password', 'required' => 1, 'reg' => '/^.*$/'), - 'password2' => array('type' => 'password', 'required' => 1, 'reg' => '/^.*$/'), - - ) -); - -$serialize_sql_setting = array (); - -?> + array('c' => 'PHP_OS', 'r' => 'notset', 'b' => 'Linux'), + 'php' => array('c' => 'PHP_VERSION', 'r' => '7+', 'b' => 'php7+'), + 'attachmentupload' => array('r' => 'notset', 'b' => '50M'), + 'gdversion' => array('r' => '1.0', 'b' => '2.0'), + 'diskspace' => array('r' => '50M', 'b' => '10G以上'), + +); + +$dirfile_items = array +( + + //'config' => array('type' => 'file', 'path' => CONFIG), + 'config_dir' => array('type' => 'dir', 'path' => './config'), + //'data' => array('type' => 'dir', 'path' => './data'), + 'cache' => array('type' => 'dir', 'path' => './data/cache'), + 'avatar' => array('type' => 'dir', 'path' => './data/avatar'), + 'ftemplates' => array('type' => 'dir', 'path' => './data/template'), + 'attach' => array('type' => 'dir', 'path' => './data/attachment'), + 'attach_dzz' => array('type' => 'dir', 'path' => './data/attachment/dzz'), + 'attach_icon' => array('type' => 'dir', 'path' => './data/attachment/icon'), + 'attach_appico' => array('type' => 'dir', 'path' => './data/attachment/appico'), + 'attach_appimg' => array('type' => 'dir', 'path' => './data/attachment/appimg'), + 'attach_cache' => array('type' => 'dir', 'path' => './data/attachment/cache'), + 'attach_imgcache' => array('type' => 'dir', 'path' => './data/attachment/imgcache'), + 'attach_qrcode' => array('type' => 'dir', 'path' => './data/attachment/qrcode'), + 'logs' => array('type' => 'dir', 'path' => './data/log'), +); + + +$form_app_reg_items = array +( + + 'siteinfo' => array + ( + 'sitename' => array('type' => 'text', 'required' => 1, 'reg' => '/^.*$/', 'value' => array('type' => 'constant', 'var' => 'SOFT_NAME')), + 'siteurl' => array('type' => 'text', 'required' => 1, 'reg' => '/^https?:\/\//', 'value' => array('type' => 'var', 'var' => 'default_appurl')) + ) +); + +$form_db_init_items = array +( + 'dbinfo' => array + ( + 'company' => array('type' => 'text', 'required' => 0, 'reg' => '/^.+$/', 'value' => array('type' => 'var', 'var' => 'company')), + 'dbhost' => array('type' => 'text', 'required' => 1, 'reg' => '/^.+$/', 'value' => array('type' => 'var', 'var' => 'dbhost')), + 'dbname' => array('type' => 'text', 'required' => 1, 'reg' => '/^.+$/', 'value' => array('type' => 'var', 'var' => 'dbname')), + 'dbuser' => array('type' => 'text', 'required' => 0, 'reg' => '/^.*$/', 'value' => array('type' => 'var', 'var' => 'dbuser')), + 'dbpw' => array('type' => 'text', 'required' => 0, 'reg' => '/^.*$/', 'value' => array('type' => 'var', 'var' => 'dbpw')), + 'tablepre' => array('type' => 'text', 'required' => 0, 'reg' => '/^.*+/', 'value' => array('type' => 'var', 'var' => 'tablepre')), + 'adminemail' => array('type' => 'text', 'required' => 1, 'reg' => '/@/', 'value' => array('type' => 'var', 'var' => 'adminemail')), + ), + +); +$form_admin_init_items = array +( + + 'admininfo' => array + ( + 'email' => array('type' => 'text', 'required' => 1, 'reg' => '/@/', 'value' => array('type' => 'var', 'var' => 'adminemail')), + 'username' => array('type' => 'text', 'required' => 1, 'reg' => '/^.*$/', 'value' => array('type' => 'constant', 'var' => 'admin')), + 'password' => array('type' => 'password', 'required' => 1, 'reg' => '/^.*$/'), + 'password2' => array('type' => 'password', 'required' => 1, 'reg' => '/^.*$/'), + + ) +); + +$serialize_sql_setting = array (); + +?>