Example #1
0
 public function validate()
 {
     Debug::show(Validate::email('*****@*****.**'));
     Debug::show(Validate::email('demo'));
     Debug::show(Validate::mobilephone('15555555555'));
     Debug::show(Validate::mobilephone('1555555555'));
 }
Example #2
0
 function validate($values)
 {
     $return = true;
     $validate = new Validate();
     if (!$validate->string($values['navn'], array('min_length' => 1))) {
         $return = false;
     }
     if (!$validate->string($values['adresse'], array('min_length' => 1))) {
         $return = false;
     }
     if (!$validate->number($values['postnr'], array('min' => 100))) {
         $return = false;
     }
     if (!$validate->string($values['postby'], array('min_length' => 1))) {
         $return = false;
     }
     if (!empty($values['email']) and !$validate->email($values['email'])) {
         $return = false;
     }
     /*
     if (isset($values['langekurser']) != "" && $values['langekurser'] != "1") $return = false;
     if (isset($values['kortekurser']) != "" && $values['kortekurser'] != "1") $return = false;
     if (isset($values['efterskole']) != "" && $values['efterskole'] != "1") $return = false;
     if (isset($values['kursuscenter']) != "" && $values['kursuscenter'] != "1") $return = false;
     */
     return $return;
 }
Example #3
0
 /**
  * Check for an API key, and throw an exception if it's not set
  *
  * @param array $args URL and POST params
  *
  * @return boolean continuation flag
  */
 function prepare($args)
 {
     GNUsocial::setApi(true);
     // reduce exception reports to aid in debugging
     parent::prepare($args);
     if (!common_config('globalapi', 'enabled')) {
         throw new ClientException(_('Global API not enabled.'), 403);
     }
     $apikey = $this->trimmed('apikey');
     if (empty($apikey)) {
         throw new ClientException(_('No API key.'), 403);
     }
     $expected = common_config('globalapi', 'key');
     if ($expected != $apikey) {
         // FIXME: increment a counter by IP address to prevent brute-force
         // attacks on the key.
         throw new ClientException(_('Bad API key.'), 403);
     }
     $email = common_canonical_email($this->trimmed('email'));
     if (empty($email)) {
         throw new ClientException(_('No email address.'));
     }
     if (!Validate::email($email, common_config('email', 'check_domain'))) {
         throw new ClientException(_('Invalid email address.'));
     }
     $this->email = $email;
     return true;
 }
Example #4
0
 public function __default()
 {
     if (count($_POST)) {
         $errors = array();
         if (Validate::email($_POST['email'])) {
             $sql = "SELECT *\n                          FROM fr_users\n                          WHERE email='" . $_POST['email'] . "'";
             $user = $this->db->getRow($sql);
             if (!PEAR::isError($result) && is_array($user)) {
                 if ($user['status'] == 'active') {
                     if ($user['password'] == $_POST['password']) {
                         if (isset($_GET['pg'])) {
                             $go = urldecode($_GET['pg']);
                         } elseif (isset($_POST['pg'])) {
                             $go = urldecode($_POST['pg']);
                         } else {
                             $go = '/';
                         }
                         $this->session->userID = $user['userID'];
                         header("Location: {$go}");
                         exit;
                     } else {
                         $errors[] = 'Your password is invalid';
                     }
                 } else {
                     $errors[] = 'Your account has been disabled';
                 }
             } else {
                 $errors[] = 'Email does not exist in database';
             }
             $this->set('errors', $errors);
         }
     }
 }
 public function action_index()
 {
     if ($_POST) {
         $message = html::chars((string) arr::get($_POST, 'message', ''));
         if ($message) {
             // Append user information
             if ($user = $this->auth->get_user()) {
                 $message .= '<h2>Användarinfo</h2>';
                 $message .= '<dl>';
                 foreach (array('id', 'username', 'email') as $field) {
                     $message .= sprintf('<dt>%s</dt><dd>%s</dd>', $field, html::chars($user->{$field}));
                 }
                 $message .= '</dl>';
             }
             $from = arr::extract($_POST, array('e-mail', 'name'));
             if (!Validate::email($from['e-mail'])) {
                 $from['name'] .= " ({$from['e-mail']})";
                 $from['e-mail'] = '*****@*****.**';
             }
             $sent = Email::send('*****@*****.**', array($from['e-mail'], $from['name']), '[Änglarna Stockholm] Meddelande från kontaktsidan', $message, TRUE);
             if ($sent >= 1) {
                 $this->message_add('Ditt meddelande har skickats till ' . html::mailto('*****@*****.**') . '!');
             } else {
                 $this->message_add('Något blev fel. Försök igen eller skicka ett vanligt mail till ' . html::mailto('*****@*****.**') . ' istället.', 'error');
             }
         } else {
             $this->message_add('Du måste ange ett meddelande.', 'error');
         }
         $this->request->reload();
     }
     $this->template->title = 'Kontakta Änglarna Stockholm';
     $this->template->content = View::factory('kontakt/index');
 }
Example #6
0
File: Index.php Project: vih/vih.dk
 function postForm()
 {
     if ($this->getForm()->validate()) {
         $bestilling = new VIH_Model_MaterialeBestilling();
         if (!$bestilling->save($this->body())) {
             throw new Exception('Det gik ikke ret godt. Vores webmaster skammer sig sikkert.');
         }
         if (defined('EMAIL_STATUS') && EMAIL_STATUS == 'online') {
             if (Validate::email($this->body('email')) and trim($this->body('email')) != '') {
                 $error = '';
                 if (!defined('VIH_KONTAKTANSVARLIG_EMAIL') || VIH_KONTAKTANSVARLIG_EMAIL == '') {
                     throw new Exception('Konstanten VIH_KONTAKTANSVARLIG_EMAIL er ikke sat eller udfyldt');
                 } elseif (trim($this->body('besked')) != '') {
                     $body = "Besked sendt i forbindelse med bestilling af materiale:\n\n" . $this->body('besked') . "\n\n Sendt af " . $this->body('navn') . "\n\nSend gerne videre til fagansvarlig lærer.";
                     $mailer = new VIH_Email();
                     $mailer->setSubject('Fra hjemmesiden');
                     $mailer->setFrom($this->body('email'), $this->body('navn'));
                     $mailer->setBody($body);
                     // i sommerperioden sendes e-mailen andetsteds hen.
                     if ((int) $this->body('langekurser') == 1 and (date('Y-m-d') < date('y') . '-06-25' or date('Y-m-d') > date('y') . '-08-01')) {
                         $mailer->addAddress(VIH_KONTAKTANSVARLIG_EMAIL, VIH_KONTAKTANSVARLIG);
                     } elseif ((int) $this->body('kursuscenter') == 1) {
                         $mailer->addAddress('*****@*****.**', 'Kursuscenteret');
                     } else {
                         $mailer->addAddress('*****@*****.**', 'Vejle Idrætshøjskole');
                     }
                     if (!$mailer->send()) {
                         throw new Exception("Der er opstået en fejl i email-senderen i forbindelse bestilling af materiale. E-mail til VIH_KONTAKTANSVARLIG er ikke sendt. Det drejer sig om en forespørgsel fra " . $this->body('navn'));
                     }
                 }
                 if (trim($this->body('email')) != '') {
                     $body = "Kære " . $this->body('navn') . "\n\nVi har modtaget din bestilling af materiale, og vi sender det så hurtigt som muligt.\n\nHvis du har nogen spørgsmål, er du meget velkommen til at ringe til os på 7582 0811.\n\nMed venlig hilsen\nVejle Idrætshøjskole";
                     $mailer = new VIH_Email();
                     $mailer->setSubject("Bestilling af materiale fra VIH");
                     $mailer->addAddress($this->body('email'), $this->body('navn'));
                     $mailer->setBody($body);
                     if (!$mailer->send()) {
                         throw new Exception("Der er opstået en fejl i email-senderen i forbindelse bestilling af materiale. Der er ikke sendt en bekræftelse til " . $this->body('navn'));
                         $error = "<p>Det var ikke muligt at sende dig en bekræftelse på din bestilling, men bare rolig vi har modtaget den, og sender hurtigst muligt materialet. Imens hænger vi webmasteren op i flagstangen, indtil han siger undskyld.";
                     }
                 }
             }
         }
         $data = array('content' => '<h1>Tak for din bestilling</h1>
                 <p>Vi vil skynde os at pakke noget materiale til dig, og vi sender det så hurtigt som muligt. Du skulle gerne have det i løbet af 2-3 arbejdsdage alt efter hvor hurtigt postvæsenet arbejder.</p>
                 <h2>Nyhedsbrev</h2>
                 <p>Hvis det har nogen interesse, kan du <a href="' . $this->url('/nyhedsbrev/') . '">tilmelde dig vores nyhedsbrev</a>.</p>
                 ' . $error);
         $tpl = $this->template->create('wrapper');
         return $tpl->render($this, $data);
     } else {
         $form = $this->getForm();
         $tpl = $this->template->create('Materialebestilling/index');
         $content = $tpl->render($this, array('text' => 'Der var fejl i formularen.', 'form' => $this->getRenderer()->toHtml()));
         $data = array('content' => $content, 'content_sub' => $this->getSubContent());
         $tpl = $this->template->create('sidebar-wrapper');
         return $tpl->render($this, $data);
     }
 }
 /**
  * Set the To Address.
  *
  * Validates and sets who the email should be sent to.
  *
  * @param string $email
  * @return bool
  */
 public function to($email)
 {
     if (Validate::email($email)) {
         $this->to = $email;
         return true;
     }
     return false;
 }
Example #8
0
 /**
  * Get unique key based on value
  * @param mixed $value	Kay value for match
  * @return string		Unique key name to attempt to match against
  */
 public function unique_key($value)
 {
     if (Validate::email($value)) {
         return 'email';
     } elseif (is_string($value)) {
         return 'username';
     }
     return 'id';
 }
Example #9
0
 public function testEmail()
 {
     $this->assertTrue(Validate::email('*****@*****.**'));
     $this->assertTrue(Validate::email('*****@*****.**'));
     $this->assertTrue(Validate::email('*****@*****.**'));
     $this->assertTrue(Validate::email('*****@*****.**'));
     $this->assertFalse(Validate::email('t123@163.cn.'));
     $this->assertFalse(Validate::email('@163.cn'));
     $this->assertFalse(Validate::email('t123@163'));
 }
Example #10
0
 public function execute()
 {
     $this->checkDefaultApp($this->aid);
     if (isset($this->email) && !Validate::email($this->email)) {
         throw new OpenFBAPIException('Email address "' . $this->email . '" not valid.');
     }
     if (isset($this->phone) && !Validate_US::phoneNumber($this->phone)) {
         throw new OpenFBAPIException('Phone number "' . $this->phone . '" not valid.');
     }
     $result = Api_Bo_Subscriptions::createAppSubscription($this->uid, $this->nid, $this->aid, $this->planid, $this->ccn, $this->cctype, $this->expdate, $this->firstname, $this->lastname, $this->email, $this->phone);
     return $result;
 }
 protected function prepare(array $args = array())
 {
     parent::prepare($args);
     $this->email = $this->trimmed('email');
     if (!Validate::email($this->email, common_config('email', 'check_domain'))) {
         $this->clientError('Not a valid email address.', 400);
     }
     if (common_config('site', 'private')) {
         $this->clientError(_('This site is private.'), 403);
     }
     return true;
 }
Example #12
0
 /**
  * Validates login information from an array, and optionally redirects
  * after a successful login.
  *
  * @param  array    values to check
  * @param  string   URI or URL to redirect to
  * @return boolean
  */
 public function login(array &$array, $redirect = FALSE)
 {
     // This is what core Auth does to allow both email and username logins
     $fieldname = Validate::email($array['username']) ? 'email' : 'username';
     $array = Validate::factory($array)->label('username', $this->_labels[$fieldname])->label('password', $this->_labels['password'])->filter(TRUE, 'trim')->rules('username', $this->_rules[$fieldname])->rules('password', $this->_rules['password']);
     // Login starts out invalid
     $status = FALSE;
     if ($array->check()) {
         // Attempt to load the user
         $this->where($fieldname, '=', $array['username'])->find();
         /* Note: failed_login_count and last_failed_login do not exist in the default schema, so it is disabled here. failed_login_count is a int field, and last_failed_login is a datetime field.
          *
                  // if there are too many recent failed logins, fail now
                  if (($this->failed_login_count > 5) && (strtotime($this->last_failed_login) > strtotime("-5 minutes") )) {
                     // do nothing, and fail (too many failed logins within 5 minutes).
                     return FALSE;
                  }
         */
         // if you want to allow 5 logins again after 5 minutes, then set the failed login count to zero here, if it is too high.
         if ($this->loaded() and Auth::instance()->login($this, $array['password'])) {
             // Login is successful
             $status = TRUE;
             // set the number of failed logins to 0
             //            $this->failed_login_count = 0;
             if (is_numeric($this->id) && $this->id != 0) {
                 // only save if the user already exists
                 $this->save();
             }
             if (is_string($redirect)) {
                 // Redirect after a successful login
                 Request::instance()->redirect($redirect);
             }
         } else {
             /*
                         // login failed: update failed login count
                         $this->failed_login_count = $this->failed_login_count+1;
                         $this->last_failed_login = date('Y-m-d H:i:s');
                         if(is_numeric($this->id) && ($this->id != 0) ) {
                            // only save if the user already exists
                            $this->save();
                         }
             */
             // set error status
             $array->error('username', 'invalid');
         }
     }
     return $status;
 }
Example #13
0
 function isValid()
 {
     if (strlen($this->value)) {
         if (Validate::email($this->value)) {
             return true;
         }
         $this->errors[] = 'Email ' . $this->value . ' appears to be invalid!';
         return false;
     } else {
         if ($this->required) {
             $this->errors[] = 'Email is a required field!';
             return false;
         }
     }
     return true;
 }
Example #14
0
 public function action_signin()
 {
     if (!empty($_POST['usermail']) and Validate::email($_POST['usermail'])) {
         $user = array('uid' => $_SERVER['REQUEST_TIME'], 'mail' => $_POST['usermail']);
         Cookie::set('user', json_encode($user));
         Session::instance()->set('user', $user);
         $this->request->redirect('server/index');
     } elseif ($user = Cookie::get('user')) {
         Session::instance()->set('user', json_decode($user, TRUE));
         $this->request->redirect('server/index');
     }
     $template = new View('oauth');
     $view = new View('oauth-server-signin');
     $template->content = $view->render();
     $this->request->response = $template;
 }
Example #15
0
 /**
  * add new regular user
  * @param string $email     user email.
  * @param string $firstname user first name.
  * @param string $lastname  user lasname.
  * @param string $password  user password.
  * @return array success
  */
 public function addRegUser($email, $firstname, $lastname, $password)
 {
     if (Validate::email($email) && Validate::password($password)) {
         $arr = $this->escapeString(array($email, $firstname, $lastname, $password));
         $e = $arr[0];
         $f = $arr[1];
         $l = $arr[2];
         $p = md5($arr[3]);
         $query = "INSERT INTO users (`user_email`, `user_password`, `user_firstname`, `user_lastname`) \n\t\t\t\t\t\tVALUES ('{$e}', '{$p}', '{$f}', '{$l}')";
         if ($this->_db->query($query)) {
             return $this->loginReg($email, $password);
         }
         $this->_db->close();
         apiConf::$ERROR = 'facebook registration failed';
     }
     apiConf::$ERROR = 'validation failed';
 }
Example #16
0
 public function execute()
 {
     $this->checkDefaultApp($this->aid);
     if (isset($this->email) && !Validate::email($this->email)) {
         throw new OpenFBAPIException('Email address "' . $this->email . '" not valid.');
     }
     if (isset($this->phone) && !Validate_US::phoneNumber($this->phone)) {
         throw new OpenFBAPIException('Phone number "' . $this->phone . '" not valid.');
     }
     $friends = array();
     $friendUids = split(',', $this->friends);
     foreach ($friendUids as $friendUid) {
         $friends[] = array('uid' => $friendUid, 'nid' => $this->nid);
         //TODO: Support case where friend is not a user in the deployed network (i.e. in the users table)
     }
     $result = Api_Bo_Subscriptions::createFriendsAppSubscription($this->uid, $this->nid, $this->aid, $this->planid, $this->ccn, $this->cctype, $this->expdate, $friends, $this->firstname, $this->lastname, $this->email, $this->phone);
     return $result;
 }
Example #17
0
 public function action_new()
 {
     if ($_POST) {
         if (Validate::email($_POST['email'])) {
             $email = ORM::factory('email')->where('email', '=', $_POST['email'])->find();
             if (!$email->loaded()) {
                 $email->email = $_POST['email'];
                 $email->save();
             }
             $response['success'] = TRUE;
         } else {
             $response['success'] = FALSE;
         }
     } else {
         throw new ReflectionException();
     }
     $this->request->headers['Content-Type'] = 'application/json';
     $this->request->response = json_encode($response);
 }
Example #18
0
 function sendInvitations()
 {
     # CSRF protection
     $token = $this->trimmed('token');
     if (!$token || $token != common_session_token()) {
         $this->showForm(_('There was a problem with your session token. Try again, please.'));
         return;
     }
     $user = common_current_user();
     $profile = $user->getProfile();
     $bestname = $profile->getBestName();
     $sitename = common_config('site', 'name');
     $personal = $this->trimmed('personal');
     $addresses = explode("\n", $this->trimmed('addresses'));
     foreach ($addresses as $email) {
         $email = trim($email);
         if (!Validate::email($email, common_config('email', 'check_domain'))) {
             // TRANS: Form validation message when providing an e-mail address that does not validate.
             // TRANS: %s is an invalid e-mail address.
             $this->showForm(sprintf(_('Invalid email address: %s.'), $email));
             return;
         }
     }
     $this->already = array();
     $this->subbed = array();
     foreach ($addresses as $email) {
         $email = common_canonical_email($email);
         $other = User::staticGet('email', $email);
         if ($other) {
             if ($user->isSubscribed($other)) {
                 $this->already[] = $other;
             } else {
                 subs_subscribe_to($user, $other);
                 $this->subbed[] = $other;
             }
         } else {
             $this->sent[] = $email;
             $this->sendInvitation($email, $user, $personal);
         }
     }
     $this->mode = 'sent';
     $this->showPage();
 }
Example #19
0
 function sendInvitations()
 {
     # CSRF protection
     $token = $this->trimmed('token');
     if (!$token || $token != common_session_token()) {
         $this->showForm(_('表单错误,请重试'));
         return;
     }
     $user = common_current_user();
     $profile = $user->getProfile();
     $bestname = $profile->getBestName();
     $sitename = common_config('site', 'name');
     $personal = $this->trimmed('personal');
     $addresses = explode("\n", $this->trimmed('addresses'));
     foreach ($addresses as $email) {
         $email = trim($email);
         if (!Validate::email($email, common_config('email', 'check_domain'))) {
             $this->showForm(sprintf(_('邮件地址格式错误: %s'), $email));
             return;
         }
     }
     $this->already = array();
     $this->subbed = array();
     foreach ($addresses as $email) {
         $email = common_canonical_email($email);
         $other = User::staticGet('email', $email);
         if ($other) {
             if ($user->isSubscribed($other)) {
                 $this->already[] = $other;
             } else {
                 subs_subscribe_to($user, $other);
                 $this->subbed[] = $other;
             }
         } else {
             $this->sent[] = $email;
             $this->sendInvitation($email, $user, $personal);
         }
     }
     $this->mode = 'sent';
     $this->showPage();
 }
Example #20
0
 public function action_index()
 {
     $this->template->title = '2do : feedback';
     $data = Validate::factory($_POST)->filter('message', 'trim')->filter('message', 'Security::xss_clean')->filter('message', 'strip_tags')->rule('message', 'not_empty');
     if ($data->check()) {
         $transport = Swift_MailTransport::newInstance();
         $mailer = Swift_Mailer::newInstance($transport);
         if (!Validate::email($this->user->email)) {
             $this->user->email = '*****@*****.**';
         }
         $message = Swift_Message::newInstance("2do.me.uk feedback")->setFrom(array($this->user->email => '2do.me.uk'))->setTo(array('*****@*****.**' => 'Richard Willis'))->addPart($data['message'], 'text/plain');
         if ($mailer->send($message)) {
             // Redirect to avoid issues with refresh after POST
             $this->request->redirect(Request::instance()->uri . '?status=sent');
         }
     } else {
         $_POST = $data->as_array();
         $this->template->set_global('errors', $data->errors('contact'));
     }
     $this->template->content = View::factory('page/feedback');
 }
Example #21
0
 function exeInsert()
 {
     if (Request::post('submit') != null) {
         $fullname = Request::post('fullname');
         $email = Request::post('email');
         $content = Request::post('content');
         $captcha = Request::post('captcha');
         $error = '';
         if ($fullname == null) {
             $error .= 'Bạn chưa nhập họ tên. <br />';
         }
         if ($email == null) {
             $error .= 'Bạn chưa nhập email.<br />';
         } elseif (Validate::email($email) != true) {
             $error .= 'Email của bạn  không đúng.<br />';
         }
         if (strlen($content) < 50) {
             $error .= 'Nội dung phải lớn hơn 50 ký tự.<br />';
         }
         if ($captcha != Session::get('captcha')) {
             $error .= 'Bạn nhập mã bảo vệ không đúng. <br />';
         }
         if ($error == '') {
             $this->model->add($fullname, $email, $content);
             $data['error'] = $data['content'] = $data['email'] = $data['fullname'] = '';
             $data['success'] = '<p class="success">Cảm ơn bạn đã gửi ý kiến.</p>';
             Session::set('feedback', $data);
         } else {
             $data = $_POST;
             $data['error'] = '<p class="error">' . $error . '</p>';
             $data['success'] = '';
             Session::set('feedback', $data);
         }
     }
     Until::redirectTo('feedback');
 }
Example #22
0
 /**
  * Add the address passed in by the user
  *
  * @return void
  */
 function addAddress()
 {
     $user = common_current_user();
     $email = $this->trimmed('email');
     // Some validation
     if (!$email) {
         $this->showForm(_('未填写邮箱地址'));
         return;
     }
     $email = common_canonical_email($email);
     if (!$email) {
         $this->showForm(_('邮件地址格式错误'));
         return;
     }
     if (!Validate::email($email, common_config('email', 'check_domain'))) {
         $this->showForm(_('邮件地址格式错误'));
         return;
     } else {
         if ($user->email == $email) {
             $this->showForm(_('新邮件地址与原邮件地址相同'));
             return;
         } else {
             if ($this->emailExists($email)) {
                 $this->showForm(_('此邮件地址属于其他用户'));
                 return;
             }
         }
     }
     $confirm = new Confirm_address();
     $confirm->address = $email;
     $confirm->address_type = 'email';
     $confirm->user_id = $user->id;
     $confirm->code = common_confirmation_code(64);
     $result = $confirm->insert();
     if ($result === false) {
         common_log_db_error($confirm, 'INSERT', __FILE__);
         $this->serverError(_('生成验证邮件失败,请返回重试'));
         return;
     }
     mail_confirm_address($user, $confirm->code, $user->nickname, $email);
     $msg = _('验证邮件已经发送,请稍候查看邮箱以确认验证信息');
     $this->showForm($msg, true);
 }
Example #23
0
 /**
  * Allows a model use both email and username as unique identifiers for login
  *
  * @param   string  unique value
  * @return  string  field name
  */
 public function unique_key($value)
 {
     return Validate::email($value) ? 'email' : 'username';
 }
Example #24
0
 function validate(&$values)
 {
     // Validate site name
     if (empty($values['site']['name'])) {
         $this->clientError(_('Site name must have non-zero length.'));
     }
     // Validate email
     $values['site']['email'] = common_canonical_email($values['site']['email']);
     if (empty($values['site']['email'])) {
         $this->clientError(_('You must have a valid contact email address.'));
     }
     if (!Validate::email($values['site']['email'], common_config('email', 'check_domain'))) {
         $this->clientError(_('Not a valid email address.'));
     }
     // Validate timezone
     if (is_null($values['site']['timezone']) || !in_array($values['site']['timezone'], DateTimeZone::listIdentifiers())) {
         $this->clientError(_('Timezone not selected.'));
         return;
     }
     // Validate language
     if (!is_null($values['site']['language']) && !in_array($values['site']['language'], array_keys(get_nice_language_list()))) {
         $this->clientError(sprintf(_('Unknown language "%s".'), $values['site']['language']));
     }
     // Validate text limit
     if (!Validate::number($values['site']['textlimit'], array('min' => 0))) {
         $this->clientError(_("Minimum text limit is 0 (unlimited)."));
     }
     // Validate dupe limit
     if (!Validate::number($values['site']['dupelimit'], array('min' => 1))) {
         $this->clientError(_("Dupe limit must be one or more seconds."));
     }
 }
Example #25
0
page_nav();
get_topright_form();
if (!isset($_SESSION["loggedUser"]) || $_SESSION["loggedUser"] == null) {
    dieWithError("err-not-logged-in");
}
if (get_class($_SESSION["loggedUser"]) != "Administrator") {
    dieWithError("err-edit-accounts-rights");
}
$val = new Validate();
$edit = new EditJury();
$udaje = daj_udaje_rozhodcu($_GET['id']);
$_SESSION['email'] = $udaje["mail"];
if (isset($_POST["email"]) && $val->validate_mail($_POST["email"])) {
    if ($_SESSION['email'] != $_POST["email"]) {
        if ($val->validate_pass($_POST["pass"], $_POST["pass2"])) {
            if ($val->email($_POST["email"])) {
                $edit->editujJury($_POST["email"], $_POST["pass"]);
            }
        }
    } else {
        if ($val->validate_pass($_POST["pass"], $_POST["pass2"])) {
            $edit->editujJury($_POST["email"], $_POST["pass"]);
        }
    }
}
?>

</br>
<form method="post">
  <table align="center" width="60%" border="0" id="display">
  <tr>
Example #26
0
// for the Login page
$fields->addField('password');
switch ($action) {
    case 'view_login':
        // Clear login data
        $email = '';
        $password = '';
        $password_message = '';
        include 'account_login.php';
        break;
    case 'login':
        // Get username/password
        $email = filter_input(INPUT_POST, 'email');
        $password = filter_input(INPUT_POST, 'password');
        // Validate user data
        $validate->email('email', $email);
        $validate->text('password', $password, true, 6, 30);
        // If validation errors, redisplay Login page and exit controller
        if ($fields->hasErrors()) {
            include 'admin/account/account_login.php';
            break;
        }
        // Check database - if valid username/password, log in
        if (is_valid_admin_login($email, $password)) {
            $_SESSION['admin'] = get_admin_by_email($email);
        } else {
            $password_message = 'Login failed. Invalid email or password.';
            include 'admin/account/account_login.php';
            break;
        }
        // Display Admin Menu page
Example #27
0
function common_valid_tag($tag)
{
    if (preg_match('/^tag:(.*?),(\\d{4}(-\\d{2}(-\\d{2})?)?):(.*)$/u', $tag, $matches)) {
        return Validate::email($matches[1]) || preg_match('/^([\\w-\\.]+)$/u', $matches[1]);
    }
    return false;
}
Example #28
0
 function VerifyVariableTypes($type, $value)
 {
     $message = '';
     switch ($type) {
         case 'string':
             return is_string($value);
             break;
         case 'number':
             return is_numeric($value);
             break;
         case 'email address':
             include_once OBJECTS_PATH . '/external/Validate.php';
             return Validate::email($value);
             break;
         case 'boolean':
             return (bool) $value;
             break;
         case 'password':
             return strlen($value) >= $this->mMinPasswordLength;
             break;
         case 'folder':
             return is_dir($value);
             break;
         default:
             return true;
             break;
     }
 }
Example #29
0
 function createNewUser()
 {
     # FIXME: save invite code before redirect, and check here
     if (common_config('site', 'closed')) {
         // TRANS: OpenID plugin message. No new user registration is allowed on the site.
         $this->clientError(_m('Registration not allowed.'));
         return;
     }
     $invite = null;
     if (common_config('site', 'inviteonly')) {
         $code = $_SESSION['invitecode'];
         if (empty($code)) {
             // TRANS: OpenID plugin message. No new user registration is allowed on the site without an invitation code, and none was provided.
             $this->clientError(_m('Registration not allowed.'));
             return;
         }
         $invite = Invitation::staticGet($code);
         if (empty($invite)) {
             // TRANS: OpenID plugin message. No new user registration is allowed on the site without an invitation code, and the one provided was not valid.
             $this->clientError(_m('Not a valid invitation code.'));
             return;
         }
     }
     $nickname = $this->trimmed('newname');
     if (!Validate::string($nickname, array('min_length' => 1, 'max_length' => 64, 'format' => NICKNAME_FMT))) {
         // TRANS: OpenID plugin message. The entered new user name did not conform to the requirements.
         $this->showForm(_m('Nickname must have only lowercase letters and numbers and no spaces.'));
         return;
     }
     if (!User::allowed_nickname($nickname)) {
         // TRANS: OpenID plugin message. The entered new user name is blacklisted.
         $this->showForm(_m('Nickname not allowed.'));
         return;
     }
     if (User::staticGet('nickname', $nickname)) {
         // TRANS: OpenID plugin message. The entered new user name is already used.
         $this->showForm(_m('Nickname already in use. Try another one.'));
         return;
     }
     list($display, $canonical, $sreg) = $this->getSavedValues();
     if (!$display || !$canonical) {
         // TRANS: OpenID plugin server error. A stored OpenID cannot be retrieved.
         $this->serverError(_m('Stored OpenID not found.'));
         return;
     }
     # Possible race condition... let's be paranoid
     $other = oid_get_user($canonical);
     if ($other) {
         // TRANS: OpenID plugin server error.
         $this->serverError(_m('Creating new account for OpenID that already has a user.'));
         return;
     }
     Event::handle('StartOpenIDCreateNewUser', array($canonical, &$sreg));
     $location = '';
     if (!empty($sreg['country'])) {
         if ($sreg['postcode']) {
             # XXX: use postcode to get city and region
             # XXX: also, store postcode somewhere -- it's valuable!
             $location = $sreg['postcode'] . ', ' . $sreg['country'];
         } else {
             $location = $sreg['country'];
         }
     }
     if (!empty($sreg['fullname']) && mb_strlen($sreg['fullname']) <= 255) {
         $fullname = $sreg['fullname'];
     } else {
         $fullname = '';
     }
     if (!empty($sreg['email']) && Validate::email($sreg['email'], common_config('email', 'check_domain'))) {
         $email = $sreg['email'];
     } else {
         $email = '';
     }
     # XXX: add language
     # XXX: add timezone
     $args = array('nickname' => $nickname, 'email' => $email, 'fullname' => $fullname, 'location' => $location);
     if (!empty($invite)) {
         $args['code'] = $invite->code;
     }
     $user = User::register($args);
     $result = oid_link_user($user->id, $canonical, $display);
     Event::handle('EndOpenIDCreateNewUser', array($user, $canonical, $sreg));
     oid_set_last($display);
     common_set_user($user);
     common_real_login(true);
     if (isset($_SESSION['openid_rememberme']) && $_SESSION['openid_rememberme']) {
         common_rememberme($user);
     }
     unset($_SESSION['openid_rememberme']);
     common_redirect(common_local_url('showstream', array('nickname' => $user->nickname)), 303);
 }
Example #30
0
 /**
  * Pull data for a remote profile and check if it's valid.
  * Fills out error UI string in $this->error
  * Fills out $this->oprofile on success.
  *
  * @return boolean
  */
 function pullRemoteProfile()
 {
     $this->profile_uri = $this->trimmed('profile');
     try {
         if (Validate::email($this->profile_uri)) {
             $this->oprofile = Ostatus_profile::ensureWebfinger($this->profile_uri);
         } else {
             if (Validate::uri($this->profile_uri)) {
                 $this->oprofile = Ostatus_profile::ensureProfileURL($this->profile_uri);
             } else {
                 // TRANS: Error message in OStatus plugin. Do not translate the domain names example.com
                 // TRANS: and example.net, as these are official standard domain names for use in examples.
                 $this->error = _m("Sorry, we could not reach that address. Please make sure that the OStatus address is like nickname@example.com or http://example.net/nickname.");
                 common_debug('Invalid address format.', __FILE__);
                 return false;
             }
         }
         return true;
     } catch (FeedSubBadURLException $e) {
         // TRANS: Error message in OStatus plugin. Do not translate the domain names example.com
         // TRANS: and example.net, as these are official standard domain names for use in examples.
         $this->error = _m('Sorry, we could not reach that address. Please make sure that the OStatus address is like nickname@example.com or http://example.net/nickname.');
         common_debug('Invalid URL or could not reach server.', __FILE__);
     } catch (FeedSubBadResponseException $e) {
         // TRANS: Error text.
         $this->error = _m('Sorry, we could not reach that feed. Please try that OStatus address again later.');
         common_debug('Cannot read feed; server returned error.', __FILE__);
     } catch (FeedSubEmptyException $e) {
         // TRANS: Error text.
         $this->error = _m('Sorry, we could not reach that feed. Please try that OStatus address again later.');
         common_debug('Cannot read feed; server returned an empty page.', __FILE__);
     } catch (FeedSubBadHTMLException $e) {
         // TRANS: Error text.
         $this->error = _m('Sorry, we could not reach that feed. Please try that OStatus address again later.');
         common_debug('Bad HTML, could not find feed link.', __FILE__);
     } catch (FeedSubNoFeedException $e) {
         // TRANS: Error text.
         $this->error = _m("Sorry, we could not reach that feed. Please try that OStatus address again later.");
         common_debug('Could not find a feed linked from this URL.', __FILE__);
     } catch (FeedSubUnrecognizedTypeException $e) {
         // TRANS: Error text.
         $this->error = _m("Sorry, we could not reach that feed. Please try that OStatus address again later.");
         common_debug('Not a recognized feed type.', __FILE__);
     } catch (Exception $e) {
         // Any new ones we forgot about
         // TRANS: Error message in OStatus plugin. Do not translate the domain names example.com
         // TRANS: and example.net, as these are official standard domain names for use in examples.
         $this->error = _m("Sorry, we could not reach that address. Please make sure that the OStatus address is like nickname@example.com or http://example.net/nickname.");
         common_debug(sprintf('Bad feed URL: %s %s', get_class($e), $e->getMessage()), __FILE__);
     }
     return false;
 }