function create_html_form(&$errors) { global $lang_str, $data, $config; parent::create_html_form($errors); if (is_null($this->opt['register_in_domain']) and false === $this->add_domain_to_form()) { return false; } if (false === $this->add_attrs_to_form()) { return false; } if ($this->opt['terms_file']) { /* read txt files */ $t = read_lang_txt_file($this->opt['terms_file'], "txt", $_SESSION['lang'], array(array("domain", $config->domain))); if ($t !== false) { $terms = $t['body']; } $this->f->add_element(array("type" => "textarea", "name" => "terms", "value" => $terms, "rows" => 8, "cols" => 38, "wrap" => "soft")); $this->f->add_element(array("type" => "checkbox", "name" => "accept", "value" => 1)); $this->js_after .= "\n\t\t\t\t\t\tif (!f.accept.checked){\n\t\t\t\t\t\t\talert('" . addslashes($lang_str['fe_not_accepted_terms']) . "');\n\t\t\t\t\t\t\tf.accept.focus();\n\t\t\t\t\t\t\treturn (false);\n\t\t\t\t\t\t}"; } $did = null; if (!is_null($this->opt['register_in_domain'])) { $did = $this->opt['register_in_domain']; } elseif (isset($_POST['domain'])) { $did = $_POST['domain']; } if (false === ($this->uname_assign_mode = $this->get_uname_assign_mode($did))) { return false; } $this->f->add_element(array("type" => "text", "name" => "uname", "size" => 23, "maxlength" => 50, "value" => "", "minlength" => $this->uname_assign_mode == "email" ? 0 : 1, "length_e" => $lang_str['fe_not_filled_username'], "valid_regex" => $this->uname_assign_mode == "email" ? ".*" : $config->username_regex, "valid_e" => $lang_str['fe_uname_not_follow_conventions'], "extrahtml" => "autocomplete='off'")); if ($this->opt['choose_passw']) { $this->f->add_element(array("type" => "text", "name" => "passwd", "value" => "", "size" => 23, "maxlength" => 25, "pass" => 1, "minlength" => 1, "length_e" => $lang_str['fe_not_filled_password'])); $this->f->add_element(array("type" => "text", "name" => "passwd_r", "value" => "", "size" => 23, "maxlength" => 25, "pass" => 1)); $this->js_after .= "\n\t\t\t\t\t\tif (f.passwd.value!=f.passwd_r.value){\n\t\t\t\t\t\t\talert('" . addslashes($lang_str['fe_passwords_not_match']) . "');\n\t\t\t\t\t\t\tf.passwd.focus();\n\t\t\t\t\t\t\treturn (false);\n\t\t\t\t\t\t}"; } }
function action_send_pass(&$errors) { global $data, $config, $lang_str; if (isset($_GET['pr'])) { $proxy = base64_decode($_GET['pr']); if ($proxy and isModuleLoaded('xxl')) { if (false === $data->set_home_proxy($proxy)) { return false; } } } if (isModuleLoaded('xxl') and !$proxy) { $errors[] = $lang_str['err_reg_conf_not_exists_conf_num']; return false; } if (empty($_GET['u'])) { $errors[] = $lang_str['err_reg_conf_not_exists_conf_num']; return false; } $an =& $config->attr_names; /* get uid */ $o = array('name' => $an['confirmation'], 'value' => $this->nr); if (false === ($attrs = $data->get_attr_by_val("user", $o))) { return false; } if (empty($attrs[0]['id'])) { ErrorHandler::add_error($lang_str['err_reg_conf_not_exists_conf_num']); return false; } $uid = $attrs[0]['id']; /* recreate instance of SerwebUser class from get param */ $serweb_user =& SerwebUser::recreate_from_get_param($_GET['u']); /* and compare if uid obtained from user_attrs match to uid inside $serweb_user object */ if ($uid != $serweb_user->get_uid()) { ErrorHandler::add_error($lang_str['err_reg_conf_not_exists_conf_num']); return false; } /* get email address of user */ $user_attrs =& User_Attrs::singleton($uid); if (false === ($email = $user_attrs->get_attribute($an['email']))) { return false; } /* generate new password */ $password = substr(md5(uniqid('')), 0, 5); if (false === $data->set_password_to_user($serweb_user, $password, $errors)) { return false; } $mail = read_lang_txt_file($this->opt['mail_file_pass'], "txt", $_SESSION['lang'], array(array("domain", $this->opt['domain']), array("password", $password))); if ($mail === false) { /* needn't write message to log. It's written by function read_lang_txt_file */ $errors[] = $lang_str['err_sending_mail']; return false; } if (false === $this->set_from_header($mail['headers'])) { return false; } if (!send_mail($email, $mail['body'], $mail['headers'])) { $errors[] = $lang_str['err_sending_mail']; return false; } /* unset attribute confirmation */ if (false === $user_attrs->unset_attribute($an['confirmation'])) { return false; } return array("m_fp_pass_sended=" . RawURLEncode($this->opt['instance_id'])); }