$ucconfig = dfopen($ucapi . '/index.php', 500, $postdata, '', 1, $ucip); if (empty($ucconfig)) { //ucenter 验证失败 $result['error'] = 1; $result['message'] = '验证失败'; } elseif ($ucconfig == '-1') { //管理员密码无效 $result['error'] = 1; $result['message'] = '创始人密码错误'; } else { list($appauthkey, $appid) = explode('|', $ucconfig); if (empty($appauthkey) || empty($appid)) { //ucenter 安装数据错误 $result['error'] = 1; $result['message'] = '安装数据错误'; } elseif ($succeed = save_uc_config($ucconfig . "|{$ucapi}|{$ucip}")) { $result['error'] = 0; $result['message'] = 'OK'; } else { //config文件写入错误 $result['error'] = 1; $result['message'] = '配置文件写入错误'; } } die($json->encode($result)); break; /* 会员数据合并界面 */ /* 会员数据合并界面 */ case 'usersmerge': include ROOT_PATH . 'data/config.php'; if (UC_CHARSET != EC_CHARSET) {
show_msg('uc_dbcharset_incorrect', '', 0); } $postdata = "m=app&a=add&ucfounder=&ucfounderpw=" . urlencode($ucpw) . "&apptype=" . urlencode($app_type) . "&appname=" . urlencode($app_name) . "&appurl=" . urlencode($app_url) . "&appip=&appcharset=" . CHARSET . '&appdbcharset=' . DBCHARSET . '&' . $app_tagtemplates . '&release=' . UC_CLIENT_RELEASE; $ucconfig = dfopen($ucapi . '/index.php', 500, $postdata, '', 1, $ucip); if (empty($ucconfig)) { show_msg('uc_api_add_app_error', $ucapi, 0); } elseif ($ucconfig == '-1') { show_msg('uc_admin_invalid', '', 0); } else { list($appauthkey, $appid) = explode('|', $ucconfig); $ucconfig_array = explode('|', $ucconfig); $ucconfig_array[] = $ucapi; $ucconfig_array[] = $ucip; if (empty($appauthkey) || empty($appid)) { show_msg('uc_data_invalid', '', 0); } elseif ($succeed = save_uc_config($ucconfig_array, ROOT_PATH . CONFIG_UC)) { if (VIEW_OFF) { show_msg('app_reg_success'); } else { $step = $step + 1; header("Location: index.php?step={$step}"); exit; } } else { show_msg('config_unwriteable', '', 0); } } } } if (VIEW_OFF) { show_msg('missing_parameter', '', 0);
function install_uc_server() { global $db, $dbhost, $dbuser, $dbpw, $dbname, $tablepre, $username, $password, $email; $ucsql = file_get_contents(ROOT_PATH . './uc_server/install/uc.sql'); $uctablepre = $tablepre . 'ucenter_'; $ucsql = str_replace(' uc_', ' ' . $uctablepre, $ucsql); $ucsql && runucquery($ucsql, $uctablepre); $appauthkey = _generate_key(); $ucdbhost = $dbhost; $ucdbname = $dbname; $ucdbuser = $dbuser; $ucdbpw = $dbpw; $ucdbcharset = DBCHARSET; $uccharset = CHARSET; $pathinfo = pathinfo($_SERVER['PHP_SELF']); $pathinfo['dirname'] = substr($pathinfo['dirname'], 0, -8); $appurl = 'http://' . preg_replace("/\\:\\d+/", '', $_SERVER['HTTP_HOST']) . ($_SERVER['SERVER_PORT'] && $_SERVER['SERVER_PORT'] != 80 ? ':' . $_SERVER['SERVER_PORT'] : '') . $pathinfo['dirname']; $ucapi = $appurl . '/uc_server'; $ucip = ''; $app_tagtemplates = 'apptagtemplates[template]=' . urlencode('<a href="{url}" target="_blank">{subject}</a>') . '&' . 'apptagtemplates[fields][subject]=' . urlencode($lang['tagtemplates_subject']) . '&' . 'apptagtemplates[fields][uid]=' . urlencode($lang['tagtemplates_uid']) . '&' . 'apptagtemplates[fields][username]=' . urlencode($lang['tagtemplates_username']) . '&' . 'apptagtemplates[fields][dateline]=' . urlencode($lang['tagtemplates_dateline']) . '&' . 'apptagtemplates[fields][url]=' . urlencode($lang['tagtemplates_url']); $db->query("INSERT INTO {$uctablepre}applications SET name='Discuz! Board', url='{$appurl}', ip='{$ucip}', authkey='{$appauthkey}', synlogin='******', charset='{$charset}', dbcharset='{$dbcharset}', type='DISCUZX', recvnote='1', tagtemplates='{$apptagtemplates}'", $link); $appid = $db->insert_id($link); $db->query("ALTER TABLE {$uctablepre}notelist ADD COLUMN app{$appid} tinyint NOT NULL"); $config = array($appauthkey, $appid, $ucdbhost, $ucdbname, $ucdbuser, $ucdbpw, $ucdbcharset, $uctablepre, $uccharset, $ucapi, $ucip); save_uc_config($config, ROOT_PATH . './config/config_ucenter.php'); $salt = substr(uniqid(rand()), -6); $passwordmd5 = md5(md5($password) . $salt); $db->query("INSERT INTO {$uctablepre}members SET {$sqladd} username='******', password='******', email='{$email}', regip='hidden', regdate='" . time() . "', salt='{$salt}'"); $uid = $db->insert_id(); $db->query("INSERT INTO {$uctablepre}memberfields SET uid='{$uid}'"); $db->query("INSERT INTO {$uctablepre}admins SET\r\n\t\tuid='{$uid}',\r\n\t\tusername='******',\r\n\t\tallowadminsetting='1',\r\n\t\tallowadminapp='1',\r\n\t\tallowadminuser='******',\r\n\t\tallowadminbadword='1',\r\n\t\tallowadmincredits='1',\r\n\t\tallowadmintag='1',\r\n\t\tallowadminpm='1',\r\n\t\tallowadmindomain='1',\r\n\t\tallowadmindb='1',\r\n\t\tallowadminnote='1',\r\n\t\tallowadmincache='1',\r\n\t\tallowadminlog='1'"); uc_write_config($config, ROOT_PATH . './uc_server/data/config.inc.php', $password); //vot @unlink(ROOT_PATH.'./uc_server/install/index.php'); @unlink(ROOT_PATH . './uc_server/data/cache/settings.php'); @touch(ROOT_PATH . './uc_server/data/upgrade.lock'); @touch(ROOT_PATH . './uc_server/data/install.lock'); dir_clear(ROOT_PATH . './uc_server/data/cache'); dir_clear(ROOT_PATH . './uc_server/data/view'); }
//更新到UCenter数据库 $newapp_appkey = daddslashes($newapp_appkey); //echo $newcu_mykey;exit; $ucdb = new db_mysql(); $ucdblink = $ucdb->_dbconnect(UC_DBHOST, UC_DBUSER, UC_DBPW, UC_DBCHARSET, UC_DBNAME); $apptablename = UC_DBTABLEPRE . 'applications'; // $a = $ucdb->query("SELECT appid,authkey FROM $apptablename"); // $apparray = array(); // while($data = $ucdb->fetch_array($a)){ // $apparray[] = $data; // } //echo UC_DBTABLEPRE;exit; $uc_dbtablepre = UC_DBTABLEPRE; $ucconfig = array($newapp_authkey, UC_APPID, UC_DBHOST, UC_DBNAME, UC_DBUSER, UC_DBPW, UC_DBCHARSET, $uc_dbtablepre, UC_CHARSET, UC_API, UC_IP); $ucconfig = @implode('|', $ucconfig); save_uc_config($ucconfig, DISCUZ_ROOT . './config/config_ucenter.php'); $ucdb->query("UPDATE {$apptablename} SET authkey = '{$newapp_appkey}' WHERE appid = " . UC_APPID); //note } else { $cpmessage .= $toolslang['nlocaluc']; } // $authkey = substr(md5($_SERVER['SERVER_ADDR'].$_SERVER['HTTP_USER_AGENT'].$dbhost.$dbuser.$dbpw.$dbname.$username.$password.$pconnect.substr($timestamp, 0, 6)), 8, 6).random(10); } elseif ($value == 'config_authkey') { $default_config = $_config; $authkey = substr(md5($_SERVER['SERVER_ADDR'] . $_SERVER['HTTP_USER_AGENT'] . $dbhost . $dbuser . $dbpw . $dbname . $username . $password . $pconnect . substr($timestamp, 0, 8)), 8, 6) . random(10); $_config['security']['authkey'] = $authkey; $cpmessage .= $toolslang['resetauthkey']; save_config_file('./config/config_global.php', $_config, $default_config); } elseif ($value == 'setting_authkey') { $authkey = substr(md5($_SERVER['SERVER_ADDR'] . $_SERVER['HTTP_USER_AGENT'] . $dbhost . $dbuser . $dbpw . $dbname . $username . $password . $pconnect . substr($timestamp, 0, 8)), 8, 6) . random(10); DB::update('common_setting', array('svalue' => $authkey), "skey = 'authkey'");
elseif($ucconfig == '-1') { //管理员密码无效 $result['error'] = 1; $result['message'] = $_LANG['ucenter_creator_wrong_password']; } else { list($appauthkey, $appid) = explode('|', $ucconfig); if(empty($appauthkey) || empty($appid)) { //ucenter 安装数据错误 $result['error'] = 1; $result['message'] = $_LANG['ucenter_data_error']; } elseif(($succeed = save_uc_config($ucconfig."|$ucapi|$ucip"))) { $result['error'] = 0; $result['message'] = 'OK'; } else { //config文件写入错误 $result['error'] = 1; $result['message'] = $_LANG['ucenter_config_error']; } } die($json->encode($result)); break;
show_msg('uc_version_incorrect', $ucversion, 0); } elseif($dbcharset && $ucdbcharset != $dbcharset) { show_msg('uc_dbcharset_incorrect', '', 0); } $postdata = "m=app&a=add&ucfounder=&ucfounderpw=".urlencode($ucpw)."&apptype=".urlencode($app_type)."&appname=".urlencode($app_name)."&appurl=".urlencode($app_url)."&appip=&appcharset=".CHARSET.'&appdbcharset='.DBCHARSET.'&'.$app_tagtemplates.'&release='.UC_CLIENT_RELEASE; $ucconfig = dfopen($ucapi.'/index.php', 500, $postdata, '', 1, $ucip); if(empty($ucconfig)) { show_msg('uc_api_add_app_error', $ucapi, 0); } elseif($ucconfig == '-1') { show_msg('uc_admin_invalid', '', 0); } else { list($appauthkey, $appid) = explode('|', $ucconfig); if(empty($appauthkey) || empty($appid)) { show_msg('uc_data_invalid', '', 0); } elseif($succeed = save_uc_config($ucconfig."|$ucapi|$ucip", CONFIG)) { if(VIEW_OFF) { show_msg('app_reg_success'); } else { $step = $step + 1; header("Location: index.php?step=$step"); exit; } } else { show_msg('config_unwriteable', '', 0); } } } } if(VIEW_OFF) {
if (UC_CLIENT_VERSION > $ucversion) { show_msg('uc_version_incorrect', $ucversion, 0); } elseif ($dbcharset && $ucdbcharset != $dbcharset) { show_msg('uc_dbcharset_incorrect', '', 0); } $postdata = "m=app&a=add&ucfounder=&ucfounderpw=" . urlencode($ucpw) . "&apptype=" . urlencode($app_type) . "&appname=" . urlencode($app_name) . "&appurl=" . urlencode($app_url) . "&appip=&appcharset=" . CHARSET . '&appdbcharset=' . DBCHARSET . '&' . $app_tagtemplates . '&release=' . UC_CLIENT_RELEASE; $ucconfig = dfopen($ucapi . '/index.php', 500, $postdata, '', 1, $ucip); if (empty($ucconfig)) { show_msg('uc_api_add_app_error', $ucapi, 0); } elseif ($ucconfig == '-1') { show_msg('uc_admin_invalid', '', 0); } else { list($appauthkey, $appid) = explode('|', $ucconfig); if (empty($appauthkey) || empty($appid)) { show_msg('uc_data_invalid', '', 0); } elseif ($succeed = save_uc_config($ucconfig . "|{$ucapi}|{$ucip}", ROOT_PATH . CONFIG_UC)) { if (VIEW_OFF) { show_msg('app_reg_success'); } else { $step = $step + 1; header("Location: index.php?step={$step}"); exit; } } else { show_msg('config_unwriteable', '', 0); } } } } if (VIEW_OFF) { show_msg('missing_parameter', '', 0);
$ucdbcharset = $dbcharset; $uccharset = $charset; $pathinfo = pathinfo($_SERVER['PHP_SELF']); $pathinfo['dirname'] = substr($pathinfo['dirname'], 0, -8); $appurl = 'http://' . preg_replace("/\\:\\d+/", '', $_SERVER['HTTP_HOST']) . ($_SERVER['SERVER_PORT'] && $_SERVER['SERVER_PORT'] != 80 ? ':' . $_SERVER['SERVER_PORT'] : '') . $pathinfo['dirname']; $ucapi = $appurl . '/uc_server'; $ucip = '127.0.0.1'; $app_tagtemplates = 'apptagtemplates[template]=' . urlencode('<a href="{url}" target="_blank">{subject}</a>') . '&' . 'apptagtemplates[fields][subject]=' . urlencode($lang['tagtemplates_subject']) . '&' . 'apptagtemplates[fields][uid]=' . urlencode($lang['tagtemplates_uid']) . '&' . 'apptagtemplates[fields][username]=' . urlencode($lang['tagtemplates_username']) . '&' . 'apptagtemplates[fields][dateline]=' . urlencode($lang['tagtemplates_dateline']) . '&' . 'apptagtemplates[fields][url]=' . urlencode($lang['tagtemplates_url']); $db->query("INSERT INTO {$uctablepre}applications SET name='Discuz! Board', url='{$appurl}', ip='{$ucip}', authkey='{$appauthkey}', synlogin='******', charset='{$charset}', dbcharset='{$dbcharset}', type='DISCUZ', recvnote='1', tagtemplates='{$apptagtemplates}'", $link); $appid = $db->insert_id($link); if ($appid < 1) { instmsg('reg_app_to_ucenter_fail'); } $db->query("ALTER TABLE {$uctablepre}notelist ADD COLUMN app{$appid} tinyint NOT NULL"); $config = "{$appauthkey}|{$appid}|{$ucdbhost}|{$ucdbname}|{$ucdbuser}|{$ucdbpw}|{$ucdbcharset}|{$uctablepre}|{$uccharset}|{$ucapi}|{$ucip}"; save_uc_config($config, DISCUZ_ROOT . './config.inc.php'); $username = getgpc('username', 'p'); $email = getgpc('email', 'p'); $password1 = getgpc('password1', 'p'); $password2 = getgpc('password2', 'p'); $uid = 0; if ($username && $email && $password1 && $password2) { if ($password1 != $password2) { $error_admin['password2'] = 'admin_password_invalid'; } elseif (strlen($username) > 15 || preg_match("/^\$|^c:\\con\\con\$|║║|[,\"\\s\t\\<\\>&]|^сн©м|^Guest/is", $username)) { $error_admin['username'] = '******'; } elseif (!strstr($email, '@') || $email != stripslashes($email) || $email != htmlspecialchars($email)) { $error_admin['email'] = 'admin_email_invalid'; } else { $salt = substr(uniqid(rand()), -6); $password = md5(md5($password1) . $salt);