Exemplo n.º 1
0
 function apu_base_class()
 {
     global $sess_lang, $lang_str;
     $this->action = "";
     /* set instance id for identification this object when multiple instances is used */
     $this->opt['instance_id'] = get_class($this) . apu_base_class::get_Instance();
     $this->opt['form_submit'] = array('type' => 'image', 'text' => $lang_str['b_submit'], 'src' => get_path_to_buttons("btn_submit.gif", $sess_lang));
     $this->opt['form_cancel'] = array('type' => 'image', 'text' => $lang_str['b_cancel'], 'src' => get_path_to_buttons("btn_cancel.gif", $sess_lang));
 }
    function apu_base_class(){
        global $lang_str;
        $this->action="";
        /* set instance id for identification this object when multiple instances is used */
        $this->opt['instance_id']=get_class($this).apu_base_class::get_Instance();

        /* form */
        $this->opt['smarty_form'] =         'form';
        /* name of html form */
        $this->opt['form_name'] =           'data_form';
        
        $this->opt['form_submit']=array('type' => 'button',
                                        'text' => $lang_str['b_submit']);
    
        $this->opt['form_cancel']=array('type' => 'button',
                                        'text' => $lang_str['b_cancel']);
    }
 function init()
 {
     parent::init();
 }
Exemplo n.º 4
0
 /**
  *	this metod is called always at begining - initialize variables
  */
 function init()
 {
     parent::init();
     $session_name = empty($this->opt['sorter_name']) ? md5($_SERVER["PHP_SELF"]) : $this->opt['sorter_name'];
     if (!isset($_SESSION['apu_sorter'][$session_name])) {
         $_SESSION['apu_sorter'][$session_name] = array();
     }
     $this->session =& $_SESSION['apu_sorter'][$session_name];
     if (!isset($this->session['reverse_order'])) {
         $this->session['reverse_order'] = $this->opt['desc_order_by_default'];
     }
 }
Exemplo n.º 5
0
 function validate_form(&$errors)
 {
     if (false === parent::validate_form($errors)) {
         return false;
     }
     return true;
 }
Exemplo n.º 6
0
 /**
  *	create html form 
  *
  *	@param array $errors	array with error messages
  *	@return null			FALSE on failure
  */
 function create_html_form(&$errors)
 {
     parent::create_html_form($errors);
     $this->get_form_elements();
     $js_elements = array();
     foreach ($this->form_elements as $k => $v) {
         if (!isset($this->session['f_values'][$v['name']])) {
             if (isset($v['initial'])) {
                 $this->session['f_values'][$v['name']] = $v['initial'];
             } else {
                 $this->session['f_values'][$v['name']] = null;
             }
         }
         /* pre set the value */
         if ($v['type'] == "checkbox") {
             $v['checked'] = $this->session['f_values'][$v['name']];
             if (empty($v['value'])) {
                 $v['value'] = 1;
             }
             //if value is not set
         } else {
             $v['value'] = $this->session['f_values'][$v['name']];
         }
         $js_el = array();
         $js_el["name"] = $v['name'];
         $js_el["type"] = $v['type'];
         /* do specific actions for each type */
         switch ($v['type']) {
             case "text":
                 if (!isset($v['maxlength'])) {
                     $v['maxlength'] = 32;
                 }
                 if ($v['value']) {
                     $this->filter_applied = true;
                 }
                 break;
             case "checkbox":
                 /* add the hidden element in order to it not depend 
                    if checkbox is displayed by the template or not */
                 $this->f->add_element(array("name" => $v['name'] . "_hidden", "type" => "hidden", "value" => $v['checked'] ? 1 : 0));
                 $onclick = "if (this.checked) this.form." . $v['name'] . "_hidden" . ".value=1; else this.form." . $v['name'] . "_hidden" . ".value=0;";
                 if (!empty($v['3state'])) {
                     $js_el["three_state"] = true;
                     $v['disabled'] = empty($this->session['f_spec'][$v['name']]['enabled']);
                     /* add the chcekbox element enabling or disabling the first one */
                     $this->f->add_element(array("name" => $v['name'] . "_en", "type" => "checkbox", "value" => 1, "checked" => !$v['disabled'], "extrahtml" => "title='enable filtering by this flag' onclick='if (this.checked) this.form." . $v['name'] . ".disabled=false; else this.form." . $v['name'] . ".disabled=true;'"));
                     //					$onchange .= "if (this.checked) this.form.".$v['name'].".disable=false; else this.form.".$v['name'].".disable=true;";
                     if (!$v['disabled']) {
                         $this->filter_applied = true;
                     }
                 } else {
                     if ($v['checked']) {
                         $this->filter_applied = true;
                     }
                 }
                 if (empty($v['extrahtml'])) {
                     $v['extrahtml'] = "";
                 }
                 $v['extrahtml'] .= " onclick='" . $onclick . "'";
                 break;
         }
         $this->f->add_element($v);
         $this->form_elements[$k] = $v;
         if (isset($v['label'])) {
             $this->labels[$v['name']] = $v['label'];
         }
         $js_elements[] = $js_el;
     }
     $this->opt['form_clear']['extra_html'] = "onclick='filter_form_ctl.filter_clear(); return false;'";
     $this->f->add_extra_submit("f_clear", $this->opt['form_clear']);
     $onload_js = "\n\t\t\tfilter_form_ctl = new Filter_Form('" . $this->opt['form_name'] . "', " . my_JSON_encode($js_elements) . ");\n\t\t";
     $this->controler->set_onload_js($onload_js);
 }
 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;
 }
 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 
  *
  *  @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;
 }
Exemplo n.º 10
0
 function create_html_form(&$errors)
 {
     global $sess_acc_filter;
     parent::create_html_form($errors);
     if ($this->opt['use_filter']) {
         $opt = array(array('label' => $this->opt['filter_labels']['all'], 'value' => 'all'), array('label' => $this->opt['filter_labels']['incoming'], 'value' => 'incoming'), array('label' => $this->opt['filter_labels']['outgoing'], 'value' => 'outgoing'));
         $this->f->add_element(array("type" => "select", "name" => "filter", "size" => 1, "value" => $sess_acc_filter, "options" => $opt));
     }
 }
Exemplo n.º 11
0
 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;
 }
Exemplo n.º 12
0
 /**
  *	this metod is called always at begining - initialize variables
  */
 function init()
 {
     global $sess;
     parent::init();
     $session_name = !is_null($this->opt['sess_seed']) ? $this->opt['sess_seed'] : $this->opt['instance_id'];
     if (!isset($_SESSION['apu_subscribers'][$session_name])) {
         $_SESSION['apu_subscribers'][$session_name] = array();
     }
     $this->session =& $_SESSION['apu_subscribers'][$session_name];
     if (is_a($this->sorter, "apu_base_class")) {
         /* register callback called on sorter change */
         $this->sorter->set_opt('on_change_callback', array(&$this, 'sorter_changed'));
         $this->sorter->set_base_apu($this);
     }
     if (is_a($this->filter, "apu_base_class")) {
         $this->filter->set_base_apu($this);
     }
 }
Exemplo n.º 13
0
 /**
  *  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;
 }
Exemplo n.º 14
0
 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;
 }
Exemplo n.º 15
0
 function create_html_form(&$errors)
 {
     global $data, $config;
     parent::create_html_form($errors);
     $this->f->add_element(array("type" => "file", "name" => "vm_greeting", "size" => $this->opt['max_file_size'], "value" => ""));
     /* if should be used radio button */
     if ($this->opt['use_radio_button']) {
         /* get state of the button */
         if ($data->is_greeting_existent($this->user_id, $errors)) {
             $which_greeting_value = 'customized';
         } else {
             $which_greeting_value = 'standard';
         }
         /* add it to form */
         $this->f->add_element(array("type" => "radio", "name" => "which_greeting", "options" => array(array('label' => 'standard greeting', 'value' => 'standard'), array('label' => 'customized greeting', 'value' => 'customized')), "value" => $which_greeting_value));
         $this->f->add_element(array("type" => "hidden", "name" => "_hidden_customized_greeting_exists", "value" => $which_greeting_value == 'customized' ? '1' : '0'));
     }
 }
Exemplo n.º 16
0
 function init()
 {
     global $sess, $sess_lcr_act_row;
     parent::init();
     if (!$sess->is_registered('sess_lcr_act_row')) {
         $sess->register('sess_lcr_act_row');
     }
     if (!isset($sess_lcr_act_row)) {
         $sess_lcr_act_row = 0;
     }
     if (isset($_GET['act_row'])) {
         $sess_lcr_act_row = $_GET['act_row'];
     }
 }
Exemplo n.º 17
0
 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;
 }
Exemplo n.º 18
0
 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;
 }
Exemplo n.º 19
0
 /**
  *	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;
 }
Exemplo n.º 20
0
 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;
 }
Exemplo n.º 21
0
 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;
 }
Exemplo n.º 22
0
 /**
  *  create html form 
  *
  *  @param array $errors    array with error messages
  *  @return null            FALSE on failure
  */
 function create_html_form(&$errors)
 {
     parent::create_html_form($errors);
     $f_options = $this->f->array_to_opt($this->opt['timeouts']);
     $this->f->add_element(array("type" => "select", "name" => "refresh_timeout", "value" => $this->session['timeout'], "size" => 1, "options" => $f_options, "extra_html" => "onchange='this.form.submit();'"));
     $this->f->add_element(array("type" => "hidden", "name" => "refresh_updated", "value" => 1));
     if (is_numeric($this->session['timeout']) and (int) $this->session['timeout'] > 0) {
         $onload_js = "\n                setTimeout('location.reload(true);', " . 1000 * (int) $this->session['timeout'] . ");\n            ";
         $this->controler->set_onload_js($onload_js);
     }
 }
Exemplo n.º 23
0
 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 
  *
  *  @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;
 }
 /**
  *  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;
 }
Exemplo n.º 26
0
 /**
  *	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;
 }
Exemplo n.º 27
0
 /**
  *	this metod is called always at begining - initialize variables
  */
 function init()
 {
     global $sess;
     parent::init();
     if (is_a($this->filter, "apu_base_class")) {
         $this->filter->set_base_apu($this);
     }
 }
Exemplo n.º 28
0
 /**
  *	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;
 }
Exemplo n.º 29
0
 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;
 }
Exemplo n.º 30
0
 /**
  *	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;
 }