当前位置: 首页>>代码示例>>PHP>>正文


PHP ValidateCaptcha函数代码示例

本文整理汇总了PHP中ValidateCaptcha函数的典型用法代码示例。如果您正苦于以下问题:PHP ValidateCaptcha函数的具体用法?PHP ValidateCaptcha怎么用?PHP ValidateCaptcha使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了ValidateCaptcha函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: InsertForBasic

 /**
  * 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;
 }
开发者ID:TiGR,项目名称:Garden,代码行数:48,代码来源:class.usermodel.php

示例2: InsertForBasic

 /**
  * 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;
 }
开发者ID:statico,项目名称:openshift-origin-vanillaforums,代码行数:67,代码来源:class.usermodel.php

示例3: insertForApproval

 /**
  * 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;
 }
开发者ID:RodSloan,项目名称:vanilla,代码行数:60,代码来源:class.usermodel.php

示例4: ordinal

<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) {
开发者ID:newmight2015,项目名称:cannacoin-faucet,代码行数:31,代码来源:submitted.php


注:本文中的ValidateCaptcha函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。