예제 #1
1
 /**
  * To be used for basic registration, and captcha registration
  */
 public function InsertForBasic($FormPostValues)
 {
     $UserID = FALSE;
     // Define the primary key in this model's table.
     $this->DefineSchema();
     // Add & apply any extra validation rules:
     $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');
     }
     $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 = ArrayValue('Name', $Fields);
         $Email = ArrayValue('Email', $Fields);
         $Fields = $this->Validation->SchemaValidationFields();
         // Only fields that are present in the schema
         $Fields = RemoveKeyFromArray($Fields, $this->PrimaryKey);
         $Fields['Password'] = array('md5' => $Fields['Password']);
         // If in Captcha registration mode, check the captcha value
         if (Gdn::Config('Garden.Registration.Method') == 'Captcha') {
             $CaptchaPublicKey = ArrayValue('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;
         }
         // Define the other required fields:
         $Fields['Email'] = $Email;
         // And insert the new user
         $UserID = $this->_Insert($Fields);
         AddActivity($UserID, 'Join', T('Welcome Aboard!'));
         // Now update the role settings if necessary
         $RoleIDs = Gdn::Config('Garden.Registration.DefaultRoles', array(8));
         $this->SaveRoles($UserID, $RoleIDs, FALSE);
     }
     return $UserID;
 }
 /**
  * To be used for basic registration, and captcha registration
  */
 public function InsertForBasic($FormPostValues, $CheckCaptcha = TRUE, $Options = array())
 {
     $RoleIDs = Gdn::Config('Garden.Registration.DefaultRoles');
     if (!is_array($RoleIDs) || count($RoleIDs) == 0) {
         throw new Exception(T('The default role has not been configured.'), 400);
     }
     if (GetValue('SaveRoles', $Options)) {
         $RoleIDs = GetValue('RoleID', $FormPostValues);
     }
     $UserID = FALSE;
     // Define the primary key in this model's table.
     $this->DefineSchema();
     // Add & apply any extra validation rules.
     if (GetValue('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 = ArrayValue('Name', $Fields);
         $Email = ArrayValue('Email', $Fields);
         $Fields = $this->Validation->SchemaValidationFields();
         // Only fields that are present in the schema
         $Fields['Roles'] = $RoleIDs;
         $Fields = RemoveKeyFromArray($Fields, $this->PrimaryKey);
         // If in Captcha registration mode, check the captcha value
         if ($CheckCaptcha && Gdn::Config('Garden.Registration.Method') == 'Captcha') {
             $CaptchaPublicKey = ArrayValue('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 (GetValue('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 && !GetValue('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;
 }
예제 #3
0
 /**
  * To be used for approval registration.
  *
  * @param array $FormPostValues
  * @param array $Options
  * @return int UserID.
  */
 public function insertForApproval($FormPostValues, $Options = array())
 {
     $RoleIDs = RoleModel::getDefaultRoles(RoleModel::TYPE_APPLICANT);
     if (empty($RoleIDs)) {
         throw new Exception(t('The default role has not been configured.'), 400);
     }
     // Define the primary key in this model's table.
     $this->defineSchema();
     // Add & apply any extra validation rules:
     $this->Validation->applyRule('Email', 'Email');
     // 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)) {
         // Check for spam.
         $Spam = SpamModel::isSpam('Registration', $FormPostValues);
         if ($Spam) {
             $this->Validation->addValidationResult('Spam', 'You are not allowed to register at this time.');
             return;
         }
         $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
         unset($Fields[$this->PrimaryKey]);
         if (!$this->validateUniqueFields($Username, $Email)) {
             return false;
         }
         // If in Captcha registration mode, check the captcha value.
         if (val('CheckCaptcha', $Options, true)) {
             $CaptchaValid = ValidateCaptcha();
             if ($CaptchaValid !== true) {
                 $this->Validation->addValidationResult('Garden.Registration.CaptchaPublicKey', 'The reCAPTCHA value was not entered correctly. Please try again.');
                 return false;
             }
         }
         // Define the other required fields:
         $Fields['Email'] = $Email;
         $Fields['Roles'] = (array) $RoleIDs;
         // And insert the new user
         $UserID = $this->_insert($Fields, $Options);
     } else {
         $UserID = false;
     }
     return $UserID;
 }
예제 #4
0
<div class="span10">
<center>
<br />
<?php 
$ip = $_SERVER['REMOTE_ADDR'];
$challengeValue = $_POST['adscaptcha_challenge_field'];
$responseValue = $_POST['adscaptcha_response_field'];
$remoteAddress = $_SERVER["REMOTE_ADDR"];
function ordinal($a)
{
    $b = abs($a);
    $c = $b % 10;
    $e = $b % 100 < 21 && $b % 100 > 4 ? 'th' : ($c < 4 ? $c < 3 ? $c < 2 ? $c < 1 ? 'th' : 'st' : 'nd' : 'rd' : 'th');
    return $a . $e;
}
if (strtolower(ValidateCaptcha($adscaptchaID, $adsprivkey, $challengeValue, $responseValue, $remoteAddress)) == "true") {
    $isvalid = $btclient->validateaddress($_POST['BTC']);
    if ($isvalid['isvalid'] != '1') {
        echo "Invalid Address: {$_POST['BTC']}";
        echo "</center></div>";
        include 'templates/sidebar.php';
        include 'templates/footer.php';
        die;
    } else {
        $ltcaddress = $_POST['BTC'];
        mysql_query("INSERT INTO subtotal (ltcaddress, ip) VALUES('{$ltcaddress}', '{$ip}' ) ") or die(mysql_error());
        $command = "SELECT * FROM dailyltc";
        $q = mysql_query($command);
        $rows = mysql_num_rows($q);
        $entries_needed = 25;
        if ($rows > $entries_needed) {