function validate_form(&$errors) { global $lang_str; if (false === parent::validate_form($errors)) { return false; } if ($_POST['pu_passwd'] and $_POST['pu_passwd'] != $_POST['pu_passwd_r']) { $errors[] = $lang_str['fe_passwords_not_match']; break; } return true; }
/** * validate html form * * @param array $errors array with error messages * @return bool TRUE if given values of form are OK, FALSE otherwise */ function validate_form(&$errors) { if (false === parent::validate_form($errors)) { return false; } /* check syntax of inifile */ if (!empty($this->fileinfo['ini']) and $this->opt['tmp_file']) { $fp = fopen($this->opt['tmp_file'], "w"); fwrite($fp, $_POST['dl_content']); fclose($fp); $this->error_in_ini_file = false; set_error_handler(array(&$this, "ini_file_error_handler")); parse_ini_file($this->opt['tmp_file']); restore_error_handler(); unlink($this->opt['tmp_file']); if ($this->error_in_ini_file) { if ($_POST['dl_kind_of_file'] == 'text') { $this->smarty_action = "edit_text"; } else { $this->smarty_action = "edit_layout"; } $errors[] = $this->error_in_ini_file; return false; } } return true; }
function validate_form(&$errors) { global $lang_str, $data; if (false === parent::validate_form($errors)) { return false; } if ($this->opt['use_radio_button']) { //if action is delete, nothing for validate if ($this->action['action'] == 'delete') { return true; } /* action upload */ /* if greeting should be customized and action is not given */ if ($_POST['which_greeting'] == 'customized' and $_FILES['vm_greeting']['error'] == UPLOAD_ERR_NO_FILE) { /* if file exists, is it ok and we don't have to do nothing */ if ($data->is_greeting_existent($this->user_id, $errors)) { $this->action_upload_do_nothing = true; return true; } else { $errors[] = $lang_str['fe_no_greeeting_file']; return false; } } /* in other cases check if file was successfuly uploaded */ return $this->validate_form_check_greeting_file($errors); } return $this->validate_form_check_greeting_file($errors); }
function validate_form(&$errors) { global $lang_str; if (false === parent::validate_form($errors)) { return false; } //check values of attributes and format its foreach ($this->opt['attributes'] as $att) { if (!$this->access_to_change($att)) { continue; } //if attribute cannot be changed, do not validate it if (!$this->attr_types[$att]->check_value($_POST[$att])) { // value of attribute is wrong // if is set error message for this attribute, add it to $errors array // otherwise add to $errors array default message: $lang_str['fe_invalid_value_of_attribute'] if (isset($this->opt['error_messages'][$att])) { $errors[] = $this->opt['error_messages'][$att]; } elseif (!is_null($this->attr_types[$att]->get_err_msg())) { $errors[] = $this->attr_types[$att]->get_err_msg(); } else { $errors[] = $lang_str['fe_invalid_value_of_attribute'] . " " . $this->attr_types[$att]->get_description(); } return false; } } //value of attributes seems to be ok, try to call user checking function yet if (!empty($this->opt['validate_funct']) and !call_user_func_array($this->opt['validate_funct'], array(&$_POST, $this->opt['error_messages'], &$errors))) { //user checking function returned false -> value of attribute is wrong return false; } return true; }
function validate_form(&$errors) { if (false === parent::validate_form($errors)) { return false; } return true; }
/** * validate html form * * @param array $errors array with error messages * @return bool TRUE if given values of form are OK, FALSE otherwise */ function validate_form(&$errors) { global $lang_str, $config; if (false === parent::validate_form($errors)) { return false; } if (!$config->clear_text_pw and !empty($_POST['cr_e_un']) and $_POST['cr_e_did'] != $_POST['cr_domain'] and empty($_POST['cr_passw'])) { $errors[] = $lang_str['err_credential_changed_domain']; return false; } return true; }
function validate_form(&$errors) { global $config, $lang_str; $uid = null; $did = null; $realm = null; $perms = null; // don't display logout mesage in case that form was submited if (isset($_GET['logout'])) { unset($_GET['logout']); } if (isset($_GET["redir_id"]) and isModuleLoaded('xxl') and $this->opt['xxl_redirect_after_login']) { $this->username = $_GET['uname']; $domain = $_GET['realm']; $this->password = $_GET['pass']; } else { if (false === parent::validate_form($errors)) { return false; } $this->password = $_POST['passw']; sw_log("User login: values from login form: username: "******", password: "******"^([^@]+)@(.+)", $_POST['uname'], $regs)) { $this->username = $regs[1]; $domain = $regs[2]; } else { sw_log("User login: authentication failed: unsuported format of username. Can't parse username and realm part", PEAR_LOG_INFO); $errors[] = $lang_str['bad_username']; return false; } } else { $this->username = $_POST['uname']; $domain = $config->domain; } } sw_log("User login: looking for did of domain: " . $domain, PEAR_LOG_DEBUG); /* get did */ $opt = array(); $did = call_user_func_array(array($this->opt['auth_class'], 'find_out_did'), array($domain, &$opt)); if (false === $did) { return false; } if (is_null($did)) { sw_log("User login: did not found for domain name: " . $domain, PEAR_LOG_DEBUG); ErrorHandler::add_error($lang_str['domain_not_found']); return false; } sw_log("User login: checking password of user with username: "******", did: " . $did, PEAR_LOG_DEBUG); /* validate credentials */ $opt = array(); $uid = call_user_func_array(array($this->opt['auth_class'], 'validate_credentials'), array($this->username, $did, $this->password, &$opt)); if (false === $uid) { return false; } if (isset($opt['realm'])) { $realm = $opt['realm']; } /* set_permissions */ $perms = call_user_func_array(array($this->opt['auth_class'], 'find_out_perms'), array($uid, array())); if (false === $perms) { return false; } if ($this->opt['check_admin_privilege']) { if (!in_array('admin', $perms)) { $errors[] = $lang_str['bad_username']; sw_log("User login: authentication failed: user hasn't admin privileges", PEAR_LOG_INFO); return false; } } $this->uid = $uid; $this->did = $did; $this->realm = $realm; $this->perms = $perms; sw_log("User login: authentication succeeded, uid: " . $this->uid, PEAR_LOG_DEBUG); return true; }
function validate_form(&$errors) { global $lang_str, $data, $config; if (false === parent::validate_form($errors)) { return false; } $an =& $config->attr_names; $d_h =& Domains::singleton(); if (is_null($this->opt['register_in_domain']) and is_null($this->opt['create_new_domain'])) { if (!isset($_POST['domain']) or $_POST['domain'] === "") { $errors[] = $lang_str['fe_domain_not_selected']; return false; } $this->did = $_POST['domain']; if (!isset($this->domain_names[$this->did])) { $errors[] = "You haven't access to domain which you selected: " . $d_h->get_domain_name($this->did); return false; } } elseif (!is_null($this->opt['register_in_domain'])) { $this->did = $this->opt['register_in_domain']; } else { $this->did = null; } /* vhen user do not have admin privilege, check username assignment mode */ if (!$this->opt['admin_priv']) { if (false === ($this->uname_assign_mode = $this->get_uname_assign_mode($this->did))) { return false; } switch ($this->uname_assign_mode) { case "adminonly": $errors[] = "Only admins could register users in this domain"; return false; break; case "email": //email verification $email_parts = explode("@", $_POST['email'], 2); $email_username = $email_parts[0]; $email_domain = $email_parts[1]; //set username by the email username $_POST['uname'] = $email_username; if ($this->opt['create_new_domain'] and $email_domain != $this->opt['create_new_domain']) { $errors[] = $lang_str["err_domain_of_email_not_match"]; return false; } else { if (false === ($domain_names = $d_h->get_domain_names($this->did))) { return false; } if (!in_array($email_domain, $domain_names)) { $errors[] = $lang_str["err_domain_of_email_not_match"]; return false; } } /* confirmation of registration is always required in this case */ $this->opt['require_confirmation'] = true; break; case "fcfs": //first come first served break; default: ErrorHandler::log_errors(PEAR::raiseError("Unknown value of username assignment mode: '" . $this->uname_assign_mode . "'")); return false; } } if (is_null($this->opt['create_new_domain'])) { if (0 === ($user_exists = $data->is_user_exists($_POST['uname'], $this->did))) { return false; } if ($user_exists < 0) { $errors[] = $lang_str['fe_uname_already_choosen_1'] . " '" . $_POST['uname'] . "' " . $lang_str['fe_uname_already_choosen_2']; return false; } } if ($this->opt['choose_passw'] and $_POST['passwd'] != $_POST['passwd_r']) { $errors[] = $lang_str['fe_passwords_not_match']; return false; } if ($this->opt['terms_file'] and empty($_POST['accept'])) { $errors[] = $lang_str['fe_not_accepted_terms']; return false; } //check values of attributes $opt = array(); if (false === Attributes::validate_form_attrs($this->attributes, $opt, $errors)) { return false; } /* Check email for the case somebody makes the attribute optional. * We need it. */ if (!$_POST[$an['email']]) { $errors[] = $lang_str['fe_not_valid_email']; return false; } return true; }
/** * validate html form * * @return bool TRUE if given values of form are OK, FALSE otherwise */ function validate_form() { $form_ok = true; if (false === parent::validate_form()) { $form_ok = false; } if (empty($_POST['hello_world_name'])) { ErrorHandler::add_error("The name can't be empty"); $form_ok = false; } return $form_ok; }
function validate_form(&$errors) { if (false === parent::validate_form($errors)) { $this->load_default_select_entries(); return false; } if (!$this->validate_select_entries($errors)) { $this->load_default_select_entries(); return false; } return true; }
function validate_form(&$errors) { if (false === parent::validate_form($errors)) { $this->smarty_action = "edit"; //if there was errors in submited form, set smarty action to edit return false; } if ($this->opt['blacklist']) { //perform regex check against entered URIs $sip_uri = $_POST['sip_uri']; /* if we are using phonenumbers, convert it to strict form */ if ($this->opt['username_in_target_only'] and $this->opt['numerical_target_only']) { $sip_uri = $this->reg->convert_phonenumber_to_strict($sip_uri); } /* check against blacklist */ if (ereg($this->opt['blacklist'], $sip_uri)) { $errors[] = $this->opt['blacklist_e']; $this->smarty_action = "edit"; //if there was errors in submited form, set smarty action to edit return false; } } return true; }
/** * validate html form * * @param array $errors array with error messages * @return bool TRUE if given values of form are OK, FALSE otherwise */ function validate_form(&$errors) { global $lang_str, $data, $config; if ($this->action['action'] == "insert") { if (!$this->validate_number_of_entries($errors)) { return false; } return true; } if ($this->action['action'] == 'create') { if (!$this->validate_number_of_entries($errors)) { return false; } } if ($this->action['action'] == 'edit' or $this->action['action'] == 'update' or $this->action['action'] == 'delete') { if (!$this->is_edit_allowed($this->edit['un'], $this->edit['did'])) { $errors[] = $lang_str['err_uri_modify_not_permited']; return false; } } if ($this->action['action'] == 'edit' or $this->action['action'] == 'delete') { return true; } $form_ok = true; if (false === parent::validate_form($errors)) { $form_ok = false; } if (!isset($_POST['uri_is_canon'])) { $_POST['uri_is_canon'] = 0; } if (!$this->check_did($_POST['uri_did'])) { $d =& Domain::singleton(); $errors[] = "Operation failed: You haven't access to domain: " . $d->get_domain_name($did); return false; } if ($_POST['uri_is_canon']) { if (!$this->check_canon_flag()) { return false; } } /* Check wheteher URI is unique */ $opt = array(); $opt['filter']['username'] = new Filter("username", $_POST['uri_un'], "=", false, false); $opt['filter']['did'] = new Filter("did", $_POST['uri_did'], "=", false, false); $opt['filter']['scheme'] = new Filter("scheme", "sip", "=", false, false); if (false === ($dups = $data->get_uris(null, $opt))) { return false; } if ($dups) { $dup = reset($dups); if ($this->action['action'] == "update" and count($dups) == 1 and $dup->username == $this->edit_uri->username and $dup->did == $this->edit_uri->did and $dup->scheme == $this->edit_uri->scheme and $dup->uid == $this->edit_uri->uid) { } else { $errors[] = $lang_str['err_ri_dup']; $form_ok = false; } } return $form_ok; }
function validate_form(&$errors) { if (false === parent::validate_form($errors)) { return false; } if ($this->opt['blacklist']) { //perform regex check against entered URIs foreach ($this->speed_dials as $key => $val) { $new_uri = $_POST['new_uri_' . $val['index']]; /* skip empty fields */ if (!empty($new_uri)) { /* if we are using phonenumbers, convert it to strict form */ if ($this->opt['username_in_target_only'] and $this->opt['numerical_target_only']) { $new_uri = $this->reg->convert_phonenumber_to_strict($new_uri); } /* check against blacklist */ if (ereg($this->opt['blacklist'], $new_uri)) { $errors[] = $this->opt['blacklist_e']; return false; } } } } //try to call user checking function yet if (!empty($this->opt['validate_funct'])) { foreach ($this->speed_dials as $key => $val) { if (!call_user_func_array($this->opt['validate_funct'], array(&$_POST['new_uri_' . $val['index']], &$errors))) { //user checking function returned false -> number is wrong return false; } } } return true; }
function validate_form(&$errors) { global $config, $perm, $lang_str; if (false === parent::validate_form($errors)) { return false; } if (is_array($config->denny_reg) and !$perm->have_perm("admin")) { foreach ($config->denny_reg as $val) { if (Ereg($val->reg, $_POST['ul_sip_address'])) { $errors[] = $lang_str[$val->label]; return false; } } } return true; }
/** * validate html form * * @param array $errors array with error messages * @return bool TRUE if given values of form are OK, FALSE otherwise */ function validate_form(&$errors) { global $lang_str; if (false === parent::validate_form($errors)) { return false; } if ($_FILES['at_file']['error'] == UPLOAD_ERR_FORM_SIZE or $_FILES['at_file']['error'] == UPLOAD_ERR_INI_SIZE) { $errors[] = $lang_str['fe_file_too_big']; return false; } if (!is_uploaded_file($_FILES['at_file']['tmp_name'])) { $errors[] = $lang_str['fe_at_no_xml_file']; return false; } if (filesize($_FILES['at_file']['tmp_name']) == 0) { $errors[] = $lang_str['fe_at_invalid_sml_file']; return false; } if ($_FILES['at_file']['type'] != "text/xml") { $errors[] = $lang_str['fe_at_xml_file_type']; return false; } return true; }
function validate_form(&$errors) { global $config, $data, $lang_str; if (false === parent::validate_form($errors)) { return false; } //if fully quantified username is given if ($this->opt['fully_qualified_name']) { // parse username and domain from it if (ereg("^([^@]+)@(.+)", $_POST['fp_uname'], $regs)) { $username = $regs[1]; $domain = $regs[2]; } else { sw_log("Get password failed: unsuported format of username. Can't parse username and domain part", PEAR_LOG_INFO); $errors[] = $lang_str['err_no_user']; return false; } } else { $username = $_POST['fp_uname']; $domain = $this->opt['domain']; } $data->set_xxl_user_id('sip:' . $username . '@' . $domain); $data->expect_user_id_may_not_exists(); /* get did */ $opt = array(); $did = call_user_func_array(array($this->opt['auth_class'], 'find_out_did'), array($domain, &$opt)); if (false === $did) { return false; } if (is_null($did)) { sw_log("Forgotten password: did not found for domain name: " . $domain, PEAR_LOG_DEBUG); ErrorHandler::add_error($lang_str['domain_not_found']); return false; } $o = array("did" => $did); if (false === ($realm = Attributes::get_attribute($config->attr_names['digest_realm'], $o))) { return false; } /* validate credentials */ $o = array('check_pw' => false); $uid = call_user_func_array(array($this->opt['auth_class'], 'validate_credentials'), array($username, $did, null, &$o)); if (false === $uid) { return false; } $this->sip_user['uname'] = $username; $this->sip_user['realm'] = isset($o['realm']) ? $o['realm'] : ""; $this->sip_user['uid'] = $uid; $this->sip_user['did'] = $did; $this->did = $did; return true; }
/** * validate html form * * @param array $errors array with error messages * @return bool TRUE if given values of form are OK, FALSE otherwise */ function validate_form(&$errors) { global $lang_str; if ($this->action['action'] == "rename_group") { if (!isset($_GET['old_group_name'])) { $_GET['old_group_name'] = null; sw_log("Attribute types: 'rename group' action ivoked without group name given. URL broken??", PEAR_LOG_INFO); } if (empty($_GET['new_group_name'])) { $errors[] = $lang_str['err_at_new_grp_empty']; return false; } return true; } if (false === parent::validate_form($errors)) { return false; } if ($_POST['attr_group'] == '__new__') { if (empty($_POST['attr_new_group'])) { $errors[] = $lang_str['err_at_grp_empty']; return false; } } else { $_POST['attr_new_group'] = null; } return true; }
/** * validate html form * * @param array $errors array with error messages * @return bool TRUE if given values of form are OK, FALSE otherwise */ function validate_form(&$errors) { global $lang_str, $config, $data; if (false === parent::validate_form($errors)) { return false; } /* Check if the domain name is not prohibited */ if (!empty($_POST['domainname']) and in_array($_POST['domainname'], $this->opt['prohibited_domain_names'])) { $errors[] = $lang_str['prohibited_domain_name']; return false; } /* Check if domain name does not already exists */ $o = array('check_deleted_flag' => false, 'filter' => array('name' => $_POST['domainname'])); $data->add_method('get_domain'); if (false === ($domains = $data->get_domain($o))) { return false; } if (count($domains)) { $errors[] = $lang_str['err_domain_already_hosted']; return false; } // create DNS resolver object $ndr = new Net_DNS_Resolver(); // query for SRV record $dns_lookup = "_sip._udp." . $_POST['domainname']; $dns_answer = $ndr->rawQuery($dns_lookup, "SRV"); if (!$dns_answer) { ErrorHandler::log_errors(PEAR::raiseError($lang_str['err_dns_lookup'], null, null, null, $ndr->errorstring)); return false; } if (!$dns_answer->answer) { $errors[] = str_replace("<hostname>", $dns_lookup, $lang_str['err_no_srv_record']); return false; } $srv_ok = false; $srv_false_rec = array(); foreach ($dns_answer->answer as $v) { if ($v->port == $config->srv_sip_proxy_port and $v->target == $config->srv_sip_proxy_hostname) { $srv_ok = true; break; } $srv_false_rec[] = array("host" => $v->target, "port" => $v->port); } if ($srv_ok) { return true; } $err = $lang_str['err_wrong_srv_record'] . "\n"; foreach ($srv_false_rec as $v) { $err .= "host: " . $v['host'] . ", port: " . $v['port'] . "\n"; } $errors[] = $err; return false; }
/** * validate html form * * @param array $errors array with error messages * @return bool TRUE if given values of form are OK, FALSE otherwise */ function validate_form(&$errors) { global $lang_str; if ($this->action['action'] == "delete_domain") { if ($this->id == $_SESSION['auth']->serweb_auth->get_did()) { $errors[] = $lang_str['err_cannot_delete_own_domain']; return false; } } elseif ($this->action['action'] == "enable_domain") { if (!isset($_GET['enable']) and $this->id == $_SESSION['auth']->serweb_auth->get_did()) { $errors[] = $lang_str['err_cannot_disable_own_domain']; return false; } } if (false === parent::validate_form($errors)) { return false; } if ($this->action['action'] == "update" and !count($this->dom_names) and empty($_POST['do_new_name'])) { $errors[] = $this->opt['no_domain_name_e']; return false; } if ($this->action['action'] == "add_alias" and empty($_POST['do_new_name'])) { $errors[] = $this->opt['no_domain_name_e']; return false; } if (!empty($_POST['do_new_name']) and in_array($_POST['do_new_name'], $this->opt['prohibited_domain_names'])) { $errors[] = $lang_str['prohibited_domain_name']; return false; } return true; }
function validate_form(&$errors) { global $lang_str; // don't display mesage in case that form was submited if (isset($_GET['m_im_sended']) and $_GET['m_im_sended'] == $this->opt['instance_id']) { unset($_GET['m_im_sended']); } if (false === parent::validate_form($errors)) { return false; } if (!$_POST['im_instant_message']) { $errors[] = $lang_str['fe_no_im']; return false; } if (strlen($_POST['im_instant_message']) > $this->opt['im_length']) { $errors[] = $lang_str['fe_im_too_long']; return false; } return true; }
function validate_form(&$errors) { global $lang_str, $data; if (false === parent::validate_form($errors)) { return false; } $did = $_POST['al_domain']; if (!$this->check_did($did)) { $d =& Domain::singleton(); $errors[] = "You haven't access to domain which you selected: " . $d->get_domain_name($did); return false; } // check if admin has parmission to changed URI and if has not, return flase if ($_POST['al_id_d'] != "" and !$this->check_did($_POST['al_id_d'])) { $errors[] = "Can not update, you have not access to this URI"; return false; } if (!empty($_POST['al_is_canon'])) { // chenck if cannonical flag in other URI may be cleared $uri_handler =& URIs::singleton($this->user_id->get_uid()); if (false === ($uris = $uri_handler->get_URIs())) { return false; } foreach ($uris as $k => $v) { if ($v->is_canonical() and !$this->check_did($v->get_did())) { $errors[] = $lang_str['err_canon_uri_exists']; return false; } } } return true; }