Beispiel #1
0
if ($pass1 == "" && $pass2 == "" && $mail == "" && $user == "" && $captcha == "") {
	echo "<p style='color:red; text-align:center;'>Debe llenar todos los campos.</p>";
}else{
	if(!validatePassword1($_POST['password1'])){		
		$password1 = "error";
	}
	if(!validatePassword2($_POST['password1'], $_POST['password2'])){
		$password2 = "error";
	}
	if(!validateEmail($_POST['email'])){
		$email = "error";
	}
	if(!validateusuario($_POST['usuario'])){
		$usuario = "error";
	}
	if(!validateCaptcha($_POST['captcha'])){
		$codCaptcha = "error";
		echo "<p style='color:red; text-align:center;'>No ha ingresado el codigo correcto</p>";
	}

	//Guardamos valores para que no tenga que reescribirlos	
	$emailValue = $_POST['email'];

		if($password1 != "error" && $password2 != "error" && $email != "error" && $usuario != "error" && $codCaptcha != "error"){
			$status = 1;
			$password_encriptada=md5($pass1);
		    $num=0;
		    $num2=0;
			$nombre=$user;

		    $miconexion->consulta("select email, pass, user from usuarios where user='******'");
 // Add datetime
 date_default_timezone_set('Europe/Berlin');
 $form['date'] = date("F j, Y, g:i a");
 // Check for empty fields
 foreach ($form as $key => $value) {
     if (!$value) {
         $errorMsg .= 'The field "' . $key . '" may not be empty.<br>';
     }
 }
 if (!validateEmail($form['email'])) {
     $errorMsg .= "Please check your email address entered.<br>";
 }
 if (!validatePassword($form['password'], $form['confirmPassword'])) {
     $errorMsg .= "Passwords does not match.<br>";
 }
 if (!validateCaptcha($form['captchaValue'], $form['captchaId'])) {
     $errorMsg .= "Please check captcha.<br>";
 }
 // Remember selectbox
 for ($i == 1; $i < 4; $i++) {
     if ($form['subject'] == $i) {
         $formHelper['select' . $i] = "selected=selected";
     }
 }
 ## Store if validation was successful
 if (!$errorMsg) {
     // Save in textfile for demo reasons only.
     // Passwords are not filtered and stored in plaintext, hash function with salt and pepper must be used!
     appendToFile("storage", $form);
     $errorMsg = "<div style='color:#24a544'>Form was sent.</div><br>";
     $form = array();
Beispiel #3
0
 /**
  * To be used for basic registration, and captcha registration.
  *
  * @param $FormPostValues
  * @param bool $CheckCaptcha
  * @param array $Options
  * @return bool|int|string
  * @throws Exception
  */
 public function insertForBasic($FormPostValues, $CheckCaptcha = true, $Options = array())
 {
     $RoleIDs = RoleModel::getDefaultRoles(RoleModel::TYPE_MEMBER);
     if (!is_array($RoleIDs) || count($RoleIDs) == 0) {
         throw new Exception(t('The default role has not been configured.'), 400);
     }
     if (val('SaveRoles', $Options)) {
         $RoleIDs = val('RoleID', $FormPostValues);
     }
     $UserID = false;
     // Define the primary key in this model's table.
     $this->defineSchema();
     // Add & apply any extra validation rules.
     if (val('ValidateEmail', $Options, true)) {
         $this->Validation->applyRule('Email', 'Email');
     }
     // TODO: DO I NEED THIS?!
     // Make sure that the checkbox val for email is saved as the appropriate enum
     if (array_key_exists('ShowEmail', $FormPostValues)) {
         $FormPostValues['ShowEmail'] = ForceBool($FormPostValues['ShowEmail'], '0', '1', '0');
     }
     if (array_key_exists('Banned', $FormPostValues)) {
         $FormPostValues['Banned'] = ForceBool($FormPostValues['Banned'], '0', '1', '0');
     }
     $this->addInsertFields($FormPostValues);
     if ($this->validate($FormPostValues, true) === true) {
         $Fields = $this->Validation->validationFields();
         // All fields on the form that need to be validated (including non-schema field rules defined above)
         $Username = val('Name', $Fields);
         $Email = val('Email', $Fields);
         $Fields = $this->Validation->schemaValidationFields();
         // Only fields that are present in the schema
         $Fields['Roles'] = $RoleIDs;
         unset($Fields[$this->PrimaryKey]);
         // If in Captcha registration mode, check the captcha value
         if ($CheckCaptcha && Gdn::config('Garden.Registration.Method') == 'Captcha') {
             $CaptchaPublicKey = val('Garden.Registration.CaptchaPublicKey', $FormPostValues, '');
             $CaptchaValid = validateCaptcha($CaptchaPublicKey);
             if ($CaptchaValid !== true) {
                 $this->Validation->addValidationResult('Garden.Registration.CaptchaPublicKey', 'The reCAPTCHA value was not entered correctly. Please try again.');
                 return false;
             }
         }
         if (!$this->validateUniqueFields($Username, $Email)) {
             return false;
         }
         // Check for spam.
         if (val('ValidateSpam', $Options, true)) {
             $ValidateSpam = $this->validateSpamRegistration($FormPostValues);
             if ($ValidateSpam !== true) {
                 return $ValidateSpam;
             }
         }
         // Define the other required fields:
         $Fields['Email'] = $Email;
         // And insert the new user
         $UserID = $this->_insert($Fields, $Options);
         if ($UserID && !val('NoActivity', $Options)) {
             $ActivityModel = new ActivityModel();
             $ActivityModel->save(array('ActivityUserID' => $UserID, 'ActivityType' => 'Registration', 'HeadlineFormat' => t('HeadlineFormat.Registration', '{ActivityUserID,You} joined.'), 'Story' => t('Welcome Aboard!')), false, array('GroupBy' => 'ActivityTypeID'));
         }
     }
     return $UserID;
 }
    $testArr = array("encoded" => $_REQUEST["test"], "decoded" => $test, "written" => $test_sanitized, "read_back" => $test_desanitized);
} catch (Exception $e) {
    $testArr = array();
}
switch ($do) {
    case 'upload':
        # Set access-control header
        header('Access-Control-Allow-Origin: amphibiandisease.org');
    case 'fetch':
        doCartoSqlApiPush($_REQUEST);
        break;
    case 'validate':
        doAWebValidate($_REQUEST);
        break;
    case 'is_human':
        validateCaptcha($_REQUEST);
        break;
    case 'search_projects':
    case 'search_project':
        searchProject($_REQUEST);
        break;
    case 'search_users':
    case 'search_user':
        searchUsers($_REQUEST);
        break;
        // case 'advanced_project_search':
        //   advancedSearchProject($_REQUEST);
        //   break;
    // case 'advanced_project_search':
    //   advancedSearchProject($_REQUEST);
    //   break;