• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP ReCaptcha类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: logon

 public function logon()
 {
     require_once "../third_party/recaptchalib.php";
     // busca a biblioteca recaptcha
     $secret = "6LcgGhcTAAAAAHXSiMR1BT4pg183Ix6UEsoCBvgw";
     // sua chave secreta
     $response = null;
     // resposta vazia
     $reCaptcha = new ReCaptcha($secret);
     // verifique a chave secreta
     // se submetido, verifique a resposta
     if ($_POST["g-recaptcha-response"]) {
         $response = $reCaptcha->verifyResponse($_SERVER["REMOTE_ADDR"], $_POST["g-recaptcha-response"]);
     }
     if ($response != null && $response->success) {
         $this->load->model('Usuarios_model');
         $user = $this->Usuarios_model->searchByUser($this->input->post("user"));
         if ($user) {
             $pass = $this->input->post("pass");
             if (md5($pass) != $user['pass']) {
                 $this->session->set_flashdata('danger', 'Senha incorreta!');
             } else {
                 $this->session->set_userdata('logged', $user);
             }
         } else {
             $this->session->set_flashdata('danger', 'Usuário não encontrado!');
         }
     }
     redirect("/");
 }
开发者ID:Anpix,项目名称:DesbravaNet,代码行数:30,代码来源:login.php


示例2: testVerifyReturnsResponse

 public function testVerifyReturnsResponse()
 {
     $method = $this->getMock('\\ReCaptcha\\RequestMethod', array('submit'));
     $method->expects($this->once())->method('submit')->with($this->callback(function ($params) {
         return true;
     }))->will($this->returnValue('{"success": true}'));
     $rc = new ReCaptcha('secret', $method);
     $response = $rc->verify('response');
     $this->assertTrue($response->isSuccess());
 }
开发者ID:CuBoulder,项目名称:cu-express-drops-7,代码行数:10,代码来源:ReCaptchaTest.php


示例3: check

 /**
  * Check if a captcha value is valid
  *
  * @access  public
  * @return  bool    return validity of captcha value
  */
 function check()
 {
     $recaptcha = jaws()->request->fetch(array('recaptcha_challenge_field', 'recaptcha_response_field'), 'post');
     if ($recaptcha['recaptcha_response_field']) {
         $privatekey = $GLOBALS['app']->Registry->fetch('reCAPTCHA_private_key', 'Policy');
         $objReCaptcha = new ReCaptcha();
         $objReCaptcha->recaptcha_check_answer($privatekey, $_SERVER["REMOTE_ADDR"], $recaptcha['recaptcha_challenge_field'], $recaptcha['recaptcha_response_field']);
         return $objReCaptcha->is_valid;
     }
     return false;
 }
开发者ID:juniortux,项目名称:jaws,代码行数:17,代码来源:ReCaptcha.php


示例4: valid

 /**
  * Validates a reCaptcha response from a user.
  *
  * @param   string   reCaptcha response
  * @return  boolean
  */
 public function valid($response)
 {
     if (empty($response)) {
         return FALSE;
     }
     require_once Kohana::find_file('vendor', 'recaptchalib');
     $reCaptcha = new ReCaptcha(Captcha::$config['privateKey']);
     $responseCaptcha = $reCaptcha->verifyResponse($this->get_real_user_ip(), $response);
     if ($responseCaptcha == null || false == $responseCaptcha->success) {
         return FALSE;
     }
     return TRUE;
 }
开发者ID:paramonovav,项目名称:kohana2-modules,代码行数:19,代码来源:Recaptcha.php


示例5: validate_post

 /**
  * Check that the CAPTCHA was entered correctly. reCAPTCHA sets a long string in 'g-recaptcha-response'
  * when the CAPTCHA is completed; we check that with the reCAPTCHA API.
  */
 public function validate_post(&$error)
 {
     require_once $this->directory . 'recaptchalib.php';
     $recaptcha = new ReCaptcha(qa_opt('recaptcha_private_key'));
     $remoteIp = qa_remote_ip_address();
     $userResponse = qa_post_text('g-recaptcha-response');
     $recResponse = $recaptcha->verifyResponse($remoteIp, $userResponse);
     foreach ($recResponse->errorCodes as $code) {
         if (isset($this->errorCodeMessages[$code])) {
             $error .= $this->errorCodeMessages[$code] . "\n";
         }
     }
     return $recResponse->success;
 }
开发者ID:bafio89,项目名称:qea-u,代码行数:18,代码来源:qa-recaptcha-captcha.php


示例6: index

 public function index()
 {
     //Google reCaptcha
     //updated to Google noCaptcha 1/15
     require_once CORE_LIB_PATH . '/recaptcha/recaptchalib.php';
     $this->set('sitekey', RECAPTCHA_PUBLIC_KEY);
     $this->set('lang', 'en');
     if ($this->post->submit) {
         if (Auth::LoggedIn() == false) {
             # Make sure they entered an email address
             if (trim($this->post->name) == '' || trim($this->post->email) == '') {
                 $this->set('message', 'You must enter a name and email!');
                 $this->render('core_error.tpl');
                 return;
             }
         }
         //Google reCaptcha
         //updated to Google noCaptcha 1/15
         $resp = null;
         $reCaptcha = new ReCaptcha(RECAPTCHA_PRIVATE_KEY);
         // Was there a reCAPTCHA response?
         if ($_POST["g-recaptcha-response"]) {
             $resp = $reCaptcha->verifyResponse($_SERVER["REMOTE_ADDR"], $_POST["g-recaptcha-response"]);
         }
         //check if reCaptcha response was valid
         if ($resp == null) {
             $this->set('captcha_error', 'reCaptcha Validation Error');
             $this->render('contact_form.tpl');
             return;
         }
         //end Google reCaptcha
         if ($this->post->subject == '' || trim($this->post->message) == '') {
             $this->set('message', 'You must enter a subject and message!');
             $this->render('core_error.tpl');
             return;
         }
         $subject = 'New message from ' . $this->post->name . ' - "' . $this->post->subject . '"';
         $message = DB::escape($this->post->message) . PHP_EOL . PHP_EOL;
         foreach ($_POST as $field => $value) {
             $message .= "-{$field} = {$value}" . PHP_EOL;
         }
         $message = nl2br($message);
         $message = utf8_encode($message);
         Util::SendEmail(ADMIN_EMAIL, $subject, $message);
         $this->render('contact_sent.tpl');
         return;
     }
     $this->render('contact_form.tpl');
 }
开发者ID:phpmods,项目名称:phpvms_5.5.x,代码行数:49,代码来源:Contact.php


示例7: check_captcha_validation

 public function check_captcha_validation($errors)
 {
     $options = WPPlugin::retrieve_options('recaptcha_options');
     if (empty($_POST['g-recaptcha-response']) || $_POST['g-recaptcha-response'] == '') {
         $errors->add('blank_captcha', $options['no_response_error']);
         return $errors;
     }
     $reCaptchaLib = new ReCaptcha($options['secret']);
     $response = $reCaptchaLib->verifyResponse($_SERVER['REMOTE_ADDR'], $_POST['g-recaptcha-response']);
     // response is bad, add incorrect response error
     if (!$response->success) {
         $errors->add('captcha_wrong', $response->error);
     }
     return $errors;
 }
开发者ID:nayabbukhari,项目名称:circulocristiano,代码行数:15,代码来源:class-ms-addon-wprecaptcha.php


示例8: validateUserInput

 public function validateUserInput()
 {
     if (Str::nullOrEmpty($this->name)) {
         $this->addError("generic.error.missingRequiredField", array('field' => 'name'), 'name');
     }
     if (Str::nullOrEmpty($this->contents)) {
         $this->addError("generic.error.missingRequiredField", array('field' => 'contents'), 'contents');
     }
     if (Str::nullOrEmpty($this->blogId)) {
         $this->addError("generic.error.missingRequiredField", array('field' => 'blogId'));
     }
     // check captcha
     if (!Str::nullOrEmpty($this->captchaChallenge)) {
         $resp = ReCaptcha::recaptcha_check_answer(self::CAPTCHA_PRIVATE_KEY, $_SERVER["REMOTE_ADDR"], $this->captchaChallenge, $this->captchaResponse);
         if ($resp->is_valid) {
             // DAY is in milliseconds, convert to seconds and multiply by 14 for 2 weeks
             $expireTime = time() + GlobalConstants::DAY / 10 * 14;
             setcookie(self::CAPTCHA_COOKIE_NAME, true, $expireTime, '/');
         } else {
             $this->addError($resp->error);
         }
     } elseif (!isset($_COOKIE[self::CAPTCHA_COOKIE_NAME])) {
         $this->addError("Captcha does not appear to be functioning properly, please contact site administrator.");
     }
 }
开发者ID:Rkandel23,项目名称:ubar,代码行数:25,代码来源:PostBlogComment.php


示例9: verify

 public static function verify()
 {
     $siteKey = "6LfLpgETAAAAALJh3IVzXccKgCXG-yTlNYaLTL26";
     $secret = "6LfLpgETAAAAAG7XXCVIbvqR1QClWiJ86D0bsnTs";
     // reCAPTCHA supported 40+ languages listed here: https://developers.google.com/recaptcha/docs/language
     $lang = "en";
     // The response from reCAPTCHA
     $resp = null;
     // The error code from reCAPTCHA, if any
     $error = null;
     $reCaptcha = new ReCaptcha($secret);
     // Was there a reCAPTCHA response?
     if ($_POST["g-recaptcha-response"]) {
         $resp = $reCaptcha->verifyResponse($_SERVER["REMOTE_ADDR"], $_POST["g-recaptcha-response"]);
     }
 }
开发者ID:mbtamuli,项目名称:quiz,代码行数:16,代码来源:Captcha.Extension.php


示例10: the_alias_works

    /**
     *  @test
     */
    public function the_alias_works()
    {
        $rendered = \ReCaptcha::render();
        $expected = '<script src="https://www.google.com/recaptcha/api.js" async defer></script>
<div class="g-recaptcha" data-sitekey=""></div>
';
        $this->assertEquals($expected, $rendered);
    }
开发者ID:Waavi,项目名称:recaptcha,代码行数:11,代码来源:ReCaptchaTest.php


示例11: validate_re_captcha

 /**
  * reCaptcha Validation
  *
  * @return void
  */
 function validate_re_captcha($no_captcha = '')
 {
     $private_key = wpuf_get_option('recaptcha_private', 'wpuf_general');
     if ($no_captcha == 1) {
         $response = null;
         $reCaptcha = new ReCaptcha($private_key);
         $resp = $reCaptcha->verifyResponse($_SERVER["REMOTE_ADDR"], $_POST["g-recaptcha-response"]);
         if (!$resp->success) {
             $this->send_error(__('reCAPTCHA validation failed', 'wpuf'));
         }
     } elseif ($no_captcha == 0) {
         $recap_challenge = isset($_POST['recaptcha_challenge_field']) ? $_POST['recaptcha_challenge_field'] : '';
         $recap_response = isset($_POST['recaptcha_response_field']) ? $_POST['recaptcha_response_field'] : '';
         $resp = recaptcha_check_answer($private_key, $_SERVER["REMOTE_ADDR"], $recap_challenge, $recap_response);
         if (!$resp->is_valid) {
             $this->send_error(__('reCAPTCHA validation failed', 'wpuf'));
         }
     }
 }
开发者ID:qhuit,项目名称:UrbanPekor,代码行数:24,代码来源:render-form.php


示例12: captcha

 function captcha()
 {
     $par = JComponentHelper::getParams('com_djclassifieds');
     $app = JFactory::getApplication();
     $token = JRequest::getCMD('token', '');
     $token_link = $token ? '&token=' . $token : '';
     if ($par->get('captcha_type', 'recaptcha') == 'nocaptcha') {
         require_once JPATH_COMPONENT . DS . 'assets' . DS . 'nocaptchalib.php';
     } else {
         require_once JPATH_COMPONENT . DS . 'assets' . DS . 'recaptchalib.php';
     }
     $privatekey = $par->get('captcha_privatekey', "6LfzhgkAAAAAAOJNzAjPz3vXlX-Bw0l-sqDgipgs");
     $is_valid = false;
     if ($par->get('captcha_type', 'recaptcha') == 'nocaptcha') {
         $response = null;
         $reCaptcha = new ReCaptcha($privatekey);
         if ($_POST["g-recaptcha-response"]) {
             $response = $reCaptcha->verifyResponse($_SERVER["REMOTE_ADDR"], $_POST["g-recaptcha-response"]);
             if ($response != null && $response->success) {
                 $is_valid = true;
             }
         }
     } else {
         $resp = recaptcha_check_answer($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
         $is_valid = $resp->is_valid;
     }
     if ($is_valid) {
         $session =& JFactory::getSession();
         $session->set('captcha_sta', '1');
         $message = '';
     } else {
         $message = JText::_("COM_DJCLASSIFIEDS_INVALID_CODE");
     }
     $menus = JSite::getMenu();
     $menu_newad_itemid = $menus->getItems('link', 'index.php?option=com_djclassifieds&view=additem', 1);
     $new_ad_link = 'index.php?option=com_djclassifieds&view=additem';
     if ($menu_newad_itemid) {
         $new_ad_link .= '&Itemid=' . $menu_newad_itemid->id;
     }
     $new_ad_link = JRoute::_($new_ad_link . $token_link);
     $app->redirect($new_ad_link, $message, 'error');
 }
开发者ID:kidaa30,项目名称:lojinha,代码行数:42,代码来源:additem.php


示例13: frontend_validate

 /**
  * {@inheritdoc}
  */
 public function frontend_validate(array $item, $input_value)
 {
     $mesages = array('not-configured' => __('Could not validate the form', 'fw'), 'not-human' => __('Please fill the recaptcha', 'fw'));
     $keys = fw_ext('forms')->get_db_settings_option('recaptcha-keys');
     if (empty($keys)) {
         return $mesages['not-configured'];
     }
     $recaptcha = new ReCaptcha($keys['secret-key']);
     $gRecaptchaResponse = FW_Request::POST('g-recaptcha-response');
     if (empty($gRecaptchaResponse)) {
         return $mesages['not-human'];
     }
     $resp = $recaptcha->verify($gRecaptchaResponse);
     if ($resp->isSuccess()) {
         return false;
     } else {
         $errors = $resp->getErrorCodes();
         return $mesages['not-human'];
     }
 }
开发者ID:HilderH,项目名称:emprendamos,代码行数:23,代码来源:class-fw-option-type-form-builder-item-recaptcha.php


示例14: validate

	public function validate($retType)
	{
		parent::validate($retType);

		copyArray($_POST, $fv, 'name', 'email', 'msg');

		if (trim($fv['name']) == '') {
			$rets[] = array('msg' => 'Please enter your name!', 'field' => 'name');
		}
		if (filter_var($fv['email'], FILTER_VALIDATE_EMAIL) === FALSE) {
    		$rets[] = array('msg' => 'Invalid email!', 'field' => 'email');
        }
        if (trim($fv['msg']) == '') {
			$rets[] = array('msg' => 'Please enter your message!', 'field' => 'msg');
		}
        if (ReCaptcha::checkAnswer() == false && isset($retType) && $retType == RT_JSON) {
        	$rets[] = array('msg' => 'The reCAPTCHA wasn\'t entered correctly!', 'field' => 'recaptcha');
        }

		if (isset($retType) && $retType == RT_JSON && isset($rets)) return outputJson($rets);
        return $rets;
	}
开发者ID:ngduc,项目名称:Thin-PHP-Framework,代码行数:22,代码来源:ContactUs.php


示例15: get_errors

 /**
  * 
  * Get different possible errors before registering an user
  * @return Array errors
  */
 public function get_errors()
 {
     $constraints = new \CODOF\Constraints\User();
     $constraints->username($this->username);
     $constraints->password($this->password);
     $constraints->mail($this->mail);
     $errors = $constraints->get_errors();
     if (\CODOF\Util::get_opt('captcha') == "enabled") {
         require_once ABSPATH . 'sys/Ext/recaptcha/recaptchalib.php';
         $privatekey = \CODOF\Util::get_opt("captcha_private_key");
         // your secret key
         $secret = $privatekey;
         // empty response
         $response = null;
         // check secret key
         $reCaptcha = new \ReCaptcha($secret);
         if ($_POST["g-recaptcha-response"]) {
             $response = $reCaptcha->verifyResponse($_SERVER["REMOTE_ADDR"], $_POST["g-recaptcha-response"]);
         }
         if (!($response != null && $response->success)) {
             $errors[] = _t("capcha entered was wrong");
         }
     }
     return $errors;
 }
开发者ID:kertkulp,项目名称:php-ruhmatoo-projekt,代码行数:30,代码来源:Register.php


示例16: recaptcha_check_answer

if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    // Verify security image
    if ($hesk_settings['secimg_use']) {
        // Using ReCaptcha?
        if ($hesk_settings['recaptcha_use'] == 1) {
            require_once HESK_PATH . 'inc/recaptcha/recaptchalib.php';
            $resp = recaptcha_check_answer($hesk_settings['recaptcha_private_key'], $_SERVER['REMOTE_ADDR'], hesk_POST('recaptcha_challenge_field', ''), hesk_POST('recaptcha_response_field', ''));
            if ($resp->is_valid) {
                //$_SESSION['img_a_verified']=true;
            } else {
                $hesk_error_buffer['mysecnum'] = $hesklang['recaptcha_error'];
            }
        } elseif ($hesk_settings['recaptcha_use'] == 2) {
            require HESK_PATH . 'inc/recaptcha/recaptchalib_v2.php';
            $resp = null;
            $reCaptcha = new ReCaptcha($hesk_settings['recaptcha_private_key']);
            // Was there a reCAPTCHA response?
            if (isset($_POST["g-recaptcha-response"])) {
                $resp = $reCaptcha->verifyResponse($_SERVER["REMOTE_ADDR"], hesk_POST("g-recaptcha-response"));
            }
            if ($resp != null && $resp->success) {
                //$_SESSION['img_a_verified']=true;
            } else {
                $hesk_error_buffer['mysecnum'] = $hesklang['recaptcha_error'];
            }
        } else {
            $mysecnum = intval(hesk_POST('mysecnum', 0));
            if (empty($mysecnum)) {
                $hesk_error_buffer['mysecnum'] = $hesklang['sec_miss'];
            } else {
                require HESK_PATH . 'inc/secimg.inc.php';
开发者ID:Eximagen,项目名称:helpdesk,代码行数:31,代码来源:password.php


示例17: ReCaptcha

 if ($config['create_catalog']) {
     $catalog_url = $db->safesql(dle_substr(htmlspecialchars(strip_tags(stripslashes(trim($title))), ENT_QUOTES, $config['charset']), 0, 1, $config['charset']));
 } else {
     $catalog_url = "";
 }
 if ($user_group[$member_id['user_group']]['disable_news_captcha'] and $member_id['news_num'] >= $user_group[$member_id['user_group']]['disable_news_captcha']) {
     $user_group[$member_id['user_group']]['news_question'] = false;
     $user_group[$member_id['user_group']]['news_sec_code'] = false;
 }
 if ($user_group[$member_id['user_group']]['news_sec_code']) {
     if ($config['allow_recaptcha']) {
         require_once ENGINE_DIR . '/classes/recaptcha.php';
         $sec_code = 1;
         $sec_code_session = false;
         if ($_POST['g-recaptcha-response']) {
             $reCaptcha = new ReCaptcha($config['recaptcha_private_key']);
             $resp = $reCaptcha->verifyResponse(get_ip(), $_POST['g-recaptcha-response']);
             if ($resp === null or !$resp->success) {
                 $stop .= "<li>" . $lang['news_err_30'] . "</li>";
             }
         } else {
             $stop .= "<li>" . $lang['news_err_30'] . "</li>";
         }
     } elseif ($_REQUEST['sec_code'] != $_SESSION['sec_code_session'] or !$_SESSION['sec_code_session']) {
         $stop .= "<li>" . $lang['news_err_30'] . "</li>";
     }
 }
 if ($user_group[$member_id['user_group']]['news_question']) {
     if (intval($_SESSION['question'])) {
         $answer = $db->super_query("SELECT id, answer FROM " . PREFIX . "_question WHERE id='" . intval($_SESSION['question']) . "'");
         $answers = explode("\n", $answer['answer']);
开发者ID:Gordondalos,项目名称:union,代码行数:31,代码来源:addnews.php


示例18: save

 function save()
 {
     $configs = $this->_model->getConfigs();
     $configs->show = explode(";", $configs->show);
     if (isset($configs->show) && in_array('captcha', $configs->show)) {
         $g_recaptcha_response = JRequest::getVar("g-recaptcha-response", "");
         $plugin = JPluginHelper::getPlugin('captcha', 'recaptcha');
         $params = new JRegistry($plugin->params);
         $secret_key = $params->get('private_key', '');
         $ip = $this->iJoomlaGetRealIpAddr();
         include_once JPATH_SITE . DS . "components" . DS . "com_adagency" . DS . "helpers" . DS . "recaptchalib.php";
         $reCaptcha = new ReCaptcha($secret_key);
         $response = $reCaptcha->verifyResponse($ip, $g_recaptcha_response);
         if ($response != null && $response->success) {
             // is not a spam
         } else {
             $data = JRequest::get('post');
             $_SESSION['ad_company'] = $data['company'];
             $_SESSION['ad_description'] = $data['description'];
             $_SESSION['ad_approved'] = $data['approved'];
             $_SESSION['ad_enabled'] = $data['enabled'];
             $_SESSION['ad_username'] = $data['username'];
             $_SESSION['ad_email'] = $data['email'];
             $_SESSION['ad_name'] = $data['name'];
             $_SESSION['ad_website'] = $data['website'];
             $_SESSION['ad_address'] = $data['address'];
             $_SESSION['ad_country'] = $data['country'];
             $_SESSION['ad_state'] = $data['state'];
             $_SESSION['ad_city'] = $data['city'];
             $_SESSION['ad_zip'] = $data['zip'];
             $_SESSION['ad_telephone'] = $data['telephone'];
             $Itemid = JRequest::getVar("Itemid", "0");
             $app = JFactory::getApplication();
             $link = JRoute::_('index.php?option=com_adagency&controller=adagencyAdvertisers&task=edit&cid[]=0&Itemid=' . intval($Itemid));
             $msg = JText::_("ADAG_DSC_CAPTCHA");
             $app->redirect($link, $msg);
             return false;
         }
     }
     $db = JFactory::getDBO();
     $data = JRequest::get('post');
     $item_id = JRequest::getInt('Itemid', '0');
     $Itemid = "";
     if ($item_id != 0) {
         $Itemid = "&Itemid=" . intval($item_id);
     }
     $error = "";
     $the_aid = JRequest::getVar("aid");
     if ($this->_model->store($error)) {
         $msg = JText::_('ADVSAVED');
     } else {
         $msg = JText::_('ADVSAVEFAILED');
         $msg .= $error;
     }
     // if user updated his profile -> ... , else if he just registered
     if ($the_aid != 0) {
         $msg = JText::_('ADAG_PROFILE_SUCC_UPDATE');
     }
     //$link = "index.php?option=com_adagency&controller=adagencyCPanel".$Itemid;
     $link = JRoute::_("index.php?option=com_adagency" . $Itemid, false);
     $msg2 = JRequest::getVar("msgafterreg");
     if (isset($msg2) && $msg2 != '') {
         $msg = $msg2;
     }
     if ($the_aid == 0) {
         $sql = "SELECT `show` FROM `#__ad_agency_settings` WHERE `show` LIKE '%wizzard%' LIMIT 1";
         $db->setQuery($sql);
         $isWizzard = $db->loadResult();
         $usr = $this->_model->getLastAdvertiser();
         if (isset($usr->approved) && $usr->approved == 'Y') {
             $msg = JText::_('ADVSAVED2');
         } else {
             if ($isWizzard) {
                 $sql = 'SELECT u.block,a.approved FROM `#__users` AS u, `#__ad_agency_advertis` AS a WHERE u.username = "' . addslashes(trim($data['username'])) . '" AND u.id = a.user_id';
                 $db->setQuery($sql);
                 $result = $db->loadObject();
                 if ($result->block == '0' && $result->approved == 'Y') {
                     $this->login($data['username'], $data['password'], NULL, 1);
                     $link = JRoute::_("index.php?option=com_adagency&controller=adagencyAds&task=addbanners" . $Itemid, false);
                     $msg = NULL;
                 }
             } elseif (!$isWizzard) {
                 $_SESSION["register_but_not_wizzard"] = "ok";
             }
         }
     }
     $this->setRedirect($link, $msg);
 }
开发者ID:politik86,项目名称:test2,代码行数:88,代码来源:adagencyAdvertisers.php


示例19: authCheck

 /**
  * Gets advanced authentication settings
  *
  * this function DOES NOT check authentication - it just checks/provides
  * authentication credentials required to connect to the MySQL server
  * usually with $GLOBALS['dbi']->connect()
  *
  * it returns false if something is missing - which usually leads to
  * auth() which displays login form
  *
  * it returns true if all seems ok which usually leads to auth_set_user()
  *
  * it directly switches to authFails() if user inactivity timeout is reached
  *
  * @return boolean   whether we get authentication settings or not
  */
 public function authCheck()
 {
     global $conn_error;
     // Initialization
     /**
      * @global $GLOBALS['pma_auth_server'] the user provided server to
      * connect to
      */
     $GLOBALS['pma_auth_server'] = '';
     $GLOBALS['PHP_AUTH_USER'] = $GLOBALS['PHP_AUTH_PW'] = '';
     $GLOBALS['from_cookie'] = false;
     // BEGIN Swekey Integration
     if (!Swekey_Auth_check()) {
         return false;
     }
     // END Swekey Integration
     if (defined('PMA_CLEAR_COOKIES')) {
         foreach ($GLOBALS['cfg']['Servers'] as $key => $val) {
             $GLOBALS['PMA_Config']->removeCookie('pmaPass-' . $key);
             $GLOBALS['PMA_Config']->removeCookie('pmaServer-' . $key);
             $GLOBALS['PMA_Config']->removeCookie('pmaUser-' . $key);
         }
         return false;
     }
     if (!empty($_REQUEST['old_usr'])) {
         // The user wants to be logged out
         // -> delete his choices that were stored in session
         // according to the PHP manual we should do this before the destroy:
         //$_SESSION = array();
         if (!defined('TESTSUITE')) {
             session_destroy();
             // $_SESSION array is not immediately emptied
             $_SESSION['last_valid_captcha'] = false;
         }
         // -> delete password cookie(s)
         if ($GLOBALS['cfg']['LoginCookieDeleteAll']) {
             foreach ($GLOBALS['cfg']['Servers'] as $key => $val) {
                 $GLOBALS['PMA_Config']->removeCookie('pmaPass-' . $key);
                 if (isset($_COOKIE['pmaPass-' . $key])) {
                     unset($_COOKIE['pmaPass-' . $key]);
                 }
             }
         } else {
             $GLOBALS['PMA_Config']->removeCookie('pmaPass-' . $GLOBALS['server']);
             if (isset($_COOKIE['pmaPass-' . $GLOBALS['server']])) {
                 unset($_COOKIE['pmaPass-' . $GLOBALS['server']]);
             }
         }
     }
     if (!empty($_REQUEST['pma_username'])) {
         // We already have one correct captcha.
         $skip = false;
         if (isset($_SESSION['last_valid_captcha']) && $_SESSION['last_valid_captcha']) {
             $skip = true;
         }
         // Verify Captcha if it is required.
         if (!empty($GLOBALS['cfg']['CaptchaLoginPrivateKey']) && !empty($GLOBALS['cfg']['CaptchaLoginPublicKey']) && !$skip) {
             if (!empty($_POST["g-recaptcha-response"])) {
                 include_once 'libraries/plugins/auth/recaptcha/recaptchalib.php';
                 $reCaptcha = new ReCaptcha($GLOBALS['cfg']['CaptchaLoginPrivateKey']);
                 // verify captcha status.
                 $resp = $reCaptcha->verifyResponse($_SERVER["REMOTE_ADDR"], $_POST["g-recaptcha-response"]);
                 // Check if the captcha entered is valid, if not stop the login.
                 if ($resp == null || !$resp->success) {
                     $conn_error = __('Entered captcha is wrong, try again!');
                     $_SESSION['last_valid_captcha'] = false;
                     return false;
                 } else {
                     $_SESSION['last_valid_captcha'] = true;
                 }
             } else {
                 if (!isset($_SESSION['last_valid_captcha']) || !$_SESSION['last_valid_captcha']) {
                     $conn_error = __('Please enter correct captcha!');
                     return false;
                 }
             }
         }
         // The user just logged in
         $GLOBALS['PHP_AUTH_USER'] = $_REQUEST['pma_username'];
         $GLOBALS['PHP_AUTH_PW'] = empty($_REQUEST['pma_password']) ? '' : $_REQUEST['pma_password'];
         if ($GLOBALS['cfg']['AllowArbitraryServer'] && isset($_REQUEST['pma_servername'])) {
             if ($GLOBALS['cfg']['ArbitraryServerRegexp']) {
                 $parts = explode(' ', $_REQUEST['pma_servername']);
                 if (count($parts) == 2) {
//.........这里部分代码省略.........
开发者ID:siddhantsomani,项目名称:phpmyadmin,代码行数:101,代码来源:AuthenticationCookie.class.php


示例20: webnus_contactform_shortcode

function webnus_contactform_shortcode($attributes, $content)
{
    extract(shortcode_atts(array('type' => '1'), $attributes));
    global $webnus_options;
    $recaptcha_desire = false;
    if ($webnus_options->webnus_recaptcha_site_key() && $webnus_options->webnus_recaptcha_secret_key()) {
        require_once get_template_directory() . '/inc/helpers/recaptchalib.php';
        // Register API keys at https://www.google.com/recaptcha/admin
        $siteKey = $webnus_options->webnus_recaptcha_site_key();
        $secret = $webnus_options->webnus_recaptcha_secret_key();
        // reCAPTCHA supported 40+ languages listed here: https://developers.google.com/recaptcha/docs/language
        $lang = get_bloginfo('language');
        // The response from reCAPTCHA
        $resp = null;
        // The error code from reCAPTCHA, if any
        $error = null;
        $reCaptcha = new ReCaptcha($secret);
        $recaptcha_desire = true;
    }
    $errors = array();
    $isError = false;
    $errorName = __('Please enter your name.', 'WEBNUS_TEXT_DOMAIN');
    $errorEmail = __('Please enter a valid email address.', 'WEBNUS_TEXT_DOMAIN');
    $errorMessage = __('Please enter the message.', 'WEBNUS_TEXT_DOMAIN');
    if ($recaptcha_desire) {
        $errorreCaptcha = __('Please enter the valid captcha.', 'WEBNUS_TEXT_DOMAIN');
    }
    // Get the posted variables and validate them.
    if (isset($_POST['is-submitted'])) {
        $name = $_POST['cName'];
        $email = $_POST['cEmail'];
        $subject = $_POST['cSubject'];
        $message = $_POST['cMessage'];
        // Check the name
        if (!webnus_validate_length($name, 2)) {
            $isError = true;
            $errors['errorName'] = $errorName;
        }
        // Check the email
        if (!is_email($email)) {
            $isError = true;
            $errors['errorEmail'] = $errorEmail;
        }
        // Check the message
        if (!webnus_validate_length($message, 2)) {
            $isError = true;
            $errors['errorMessage'] = $errorMessage;
        }
        if ($recaptcha_desire) {
            $recaptcha = $_POST["g-recaptcha-response"];
            // Check the recaptcha
            if (!webnus_validate_length($recaptcha, 2)) {
                $isError = true;
                $errors['errorreCaptcha'] = $errorreCaptcha;
            }
            // Was there a reCAPTCHA response?
            if ($_POST["g-recaptcha-response"]) {
                $resp = $reCaptcha->verifyResponse($_SERVER["REMOTE_ADDR"], $_POST["g-recaptcha-response"]);
            }
        }
        // If there's no error, send email
        if (!$isError) {
            // Get admin email
            $emailReceiver = get_option('admin_email');
            $emailSubject = sprintf(__('You have been contacted by %s', 'WEBNUS_TEXT_DOMAIN'), $name);
            $emailBody = sprintf(__('Subject: %1$s', 'WEBNUS_TEXT_DOMAIN'), $subject) . PHP_EOL . PHP_EOL;
            $emailBody .= sprintf(__('You have been contacted by %1$s. Their message is:', 'WEBNUS_TEXT_DOMAIN'), $name) . PHP_EOL . PHP_EOL;
            $emailBody .= $message . PHP_EOL . PHP_EOL;
            $emailBody .= sprintf(__('You can contact %1$s via email at %2$s', 'WEBNUS_TEXT_DOMAIN'), $name, $email);
            $emailBody .= PHP_EOL . PHP_EOL;
            $emailHeaders[] = "Reply-To: {$email}" . PHP_EOL;
            add_filter('wp_mail_from_name', 'custom_wp_mail_from_name');
            function custom_wp_mail_from_name($name)
            {
                return 'Webnus Contact form';
            }
            $emailIsSent = wp_mail($emailReceiver, $emailSubject, $emailBody, $emailHeaders);
        }
    }
    ob_start();
    ?>

<div class="contact-form">
	<form action="<?php 
    the_permalink();
    ?>
" method="POST" id="contact-form" class="frmContact container" role="form" novalidate>
		<?php 
    if ($type == 2) {
        echo '<div class="col-md-6">';
    }
    ?>
			
			<input type="text" name="cName" id="txtName" placeholder="<?php 
    esc_html_e('Name', 'WEBNUS_TEXT_DOMAIN');
    ?>
" value="<?php 
    if (isset($_POST['cName'])) {
        echo esc_html($_POST['cName']);
    }
//.........这里部分代码省略.........
开发者ID:bhuvanaurora,项目名称:wordpress-wed,代码行数:101,代码来源:contactform.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Read类代码示例发布时间:2022-05-23
下一篇:
PHP Rating类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap