示例#1
0
     $error = $check_email;
 } elseif (!empty($check_pass)) {
     $error = $check_pass;
 } elseif ($array_data['nv_password'] != $array_data['re_password']) {
     $error = sprintf($lang_global['passwordsincorrect'], $array_data['nv_password'], $array_data['re_password']);
 } elseif (empty($array_data['question'])) {
     $error = $lang_module['your_question_empty'];
 } elseif (empty($array_data['answer_question'])) {
     $error = $lang_module['answer_empty'];
 } elseif (empty($error)) {
     $password = $crypt->hash_password($array_data['nv_password'], $global_config['hashprefix']);
     define('NV_CONFIG_GLOBALTABLE', $db_config['prefix'] . '_config');
     $userid = 1;
     $db->query('TRUNCATE TABLE ' . $db_config['prefix'] . '_users');
     $db->query('TRUNCATE TABLE ' . $db_config['prefix'] . '_authors');
     $sth = $db->prepare("INSERT INTO " . $db_config['prefix'] . "_users\n\t\t\t\t(userid, username, md5username, password, email, first_name, last_name, gender, photo, birthday, sig,\tregdate, question, answer, passlostkey, view_mail, remember, in_groups, active, checknum, last_login, last_ip, last_agent, last_openid, idsite)\n\t\t\t\tVALUES(" . $userid . ", :username, :md5username, :password, :email, :first_name, '', '', '', 0, '', " . NV_CURRENTTIME . ", :question, :answer_question, '', 0, 1, '', 1, '', " . NV_CURRENTTIME . ", '', '', '', 0)");
     $sth->bindParam(':username', $array_data['nv_login'], PDO::PARAM_STR);
     $sth->bindValue(':md5username', nv_md5safe($array_data['nv_login']), PDO::PARAM_STR);
     $sth->bindParam(':password', $password, PDO::PARAM_STR);
     $sth->bindParam(':email', $array_data['nv_email'], PDO::PARAM_STR);
     $sth->bindParam(':first_name', $array_data['nv_login'], PDO::PARAM_STR);
     $sth->bindParam(':question', $array_data['question'], PDO::PARAM_STR);
     $sth->bindParam(':answer_question', $array_data['answer_question'], PDO::PARAM_STR);
     $ok1 = $sth->execute();
     $ok2 = $db->exec("INSERT INTO " . $db_config['prefix'] . "_authors (admin_id, editor, lev, files_level, position, addtime, edittime, is_suspend, susp_reason, check_num, last_login, last_ip, last_agent) VALUES(" . $userid . ", 'ckeditor', 1, 'adobe,application,archives,audio,documents,flash,images,real,video|1|1|1', 'Administrator', 0, 0, 0, '', '', 0, '', '')");
     if ($ok1 and $ok2) {
         try {
             $db->query('INSERT INTO ' . $db_config['prefix'] . '_users_info (userid) VALUES (' . $userid . ')');
             $db->query("INSERT INTO " . $db_config['prefix'] . "_groups_users (group_id, userid, data) VALUES(1, " . $userid . ", '0')");
             $db->query("INSERT INTO " . NV_CONFIG_GLOBALTABLE . " (lang, module, config_name, config_value) VALUES ('sys', 'site', 'statistics_timezone', " . $db->quote(NV_SITE_TIMEZONE_NAME) . ")");
             $db->query("INSERT INTO " . NV_CONFIG_GLOBALTABLE . " (lang, module, config_name, config_value) VALUES ('sys', 'site', 'site_email', " . $db->quote($global_config['site_email']) . ")");