當前位置: 首頁>>代碼示例>>PHP>>正文


PHP captcha::create方法代碼示例

本文整理匯總了PHP中captcha::create方法的典型用法代碼示例。如果您正苦於以下問題:PHP captcha::create方法的具體用法?PHP captcha::create怎麽用?PHP captcha::create使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在captcha的用法示例。


在下文中一共展示了captcha::create方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: captcha

 public function captcha()
 {
     $captcha = new captcha();
     $config = config('captcha');
     // 		debug($config);
     $captcha->setConfig($config);
     // 		$captcha = load('captcha');
     $captcha->create();
     // 		debug($captcha);
 }
開發者ID:im286er,項目名稱:SimplePHP,代碼行數:10,代碼來源:indexController.php

示例2: run

 function run()
 {
     global $_out;
     $ns = $this->query('form');
     foreach ($ns as $form) {
         if (!$form->getAttribute('action')) {
             $form->setAttribute('action', $_SERVER['REQUEST_URI']);
         }
         if ($this->isSent($form)) {
             //форму отправили
             $xml = new xml($form);
             if (!$this->check($form) && ($res = $this->getSentData($form))) {
                 $resultSQL = $resultMail = true;
                 if (count($res['mysql'])) {
                     $resultSQL = $this->insertDB($res['mysql'], $form);
                 }
                 if ($res['xml']) {
                     $resultMail = $this->sendEmail($res['xml'], $form);
                 }
                 $form->appendChild($xml->createElement('message', array('type' => $resultSQL && $resultMail ? 'success' : 'fail'), xml::getElementText($this->query($resultSQL && $resultMail ? 'form/good' : 'form/fail')->item(0))));
             } else {
                 // Ошибка - заполняем форму
                 $this->fillForm($form);
             }
         }
         if ($form->hasAttribute('appendTo')) {
             $_out->elementIncludeTo($form, $form->getAttribute('appendTo'));
         } elseif (!$this->getSection()) {
             $_out->elementIncludeTo($form, $_out->de());
         } else {
             $_out->addSectionContent($form);
         }
         if ($this->hasCaptcha($form)) {
             $captcha = new captcha();
             $captcha->setLanguage($_out->getLang());
             $captcha->setParamName('captcha');
             $captcha->create('userfiles/cptch.jpg');
         }
     }
 }
開發者ID:PapaKot,項目名稱:Horowitz,代碼行數:40,代碼來源:feedback.php

示例3: run

 function run()
 {
     global $_out;
     $captcha = new captcha();
     $captcha->setParamName('captcha');
     if ($form = $this->query('form')->item(0)) {
         //нашли форму
         if (!$form->getAttribute('action')) {
             $form->setAttribute('action', $_SERVER['REQUEST_URI']);
         }
         if ($this->isSent($form)) {
             //форму отправили
             if (!$this->check($form) && ($res = $this->getSentData($form))) {
                 $e = $this->getSection()->getXML()->createElement('final', null);
                 $resultSQL = $resultMail = true;
                 if (count($res['mysql'])) {
                     $resultSQL = $this->insertDB($res['mysql'], $form);
                 }
                 if ($res['xml']) {
                     $resultMail = $this->sendEmail($res['xml'], $form);
                 }
                 if ($resultSQL && $resultMail) {
                     xml::setElementText($e, xml::getElementText($this->getSection()->getXML()->query('good', $form)->item(0)));
                 } else {
                     xml::setElementText($e, xml::getElementText($this->getSection()->getXML()->query('fail', $form)->item(0)));
                 }
                 $form->appendChild($e);
             } else {
                 // Ошибка - заполняем форму
                 $this->fillForm($form);
             }
         }
         $_out->addSectionContent($form);
         $captcha->setLanguage('en');
         $captcha->create('userfiles/cptch.jpg');
     }
 }
開發者ID:PapaKot,項目名稱:Horowitz,代碼行數:37,代碼來源:feedback.php

示例4: generateRandomString

        imagefilledrectangle($im, 0, 0, 100, 30, $white);
        $line_color = imagecolorallocate($im, 64, 64, 64);
        for ($i = 0; $i < 10; $i++) {
            imageline($im, 0, rand(0, 30), 100, rand(0, 30), $line_color);
        }
        $pixel_color = imagecolorallocate($im, 0, 0, 255);
        for ($i = 0; $i < 1000; $i++) {
            imagesetpixel($im, rand() % 200, rand() % 50, $pixel_color);
        }
        $text = $this->generateRandomString();
        $_SESSION['captcha'] = $text;
        $font = './arial.ttf';
        imagettftext($im, 20, 0, 11, 21, $grey, $font, $text);
        imagettftext($im, 20, 0, 9, 19, $black, $font, $text);
        imagepng($im);
        imagedestroy($im);
    }
    public function generateRandomString($length = 5)
    {
        $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
        $charactersLength = strlen($characters);
        $randomString = '';
        for ($i = 0; $i < $length; $i++) {
            $randomString .= $characters[rand(0, $charactersLength - 1)];
        }
        return $randomString;
    }
}
$captcha = new captcha();
$captcha->create();
開發者ID:saksham-arora,項目名稱:captcha,代碼行數:30,代碼來源:captcha.php

示例5: phpversion

        $email_message .= "Name: " . $uname . "\n";
        $email_message .= "Email: " . $email . "\n";
        $email_message .= "Phone: " . $phone . "\n";
        $email_message .= "Company: " . $company . "\n";
        $email_message .= "Message: " . $message . "\n";
        // create email headers
        $headers = 'From: ' . $email_from . "\r\n" . 'Reply-To: ' . $email_from . "\r\n" . 'X-Mailer: PHP/' . phpversion();
        @mail($email_to, $email_subject, $email_message, $headers);
        print "<p class='details'><strong>Your message has been sent to Ted's Book Store<br>\n\t\t\t\t\t\tWe will get back to you as soon as possible.</strong></p>";
    }
}
//Create a new captcha
$_SESSION['captcha'] = rand(100, 10000);
unset($captcha);
$captcha = new captcha();
$captcha->create($_SESSION['captcha']);
print "<div class='contact_form'>\n                 <div class='form_subtitle'>all fields are required</div>";
if ($iserror) {
    print "<br /><p>Fields with * need to be filled in properly.</p>";
}
// end if
print "<!-- post form data to contact.php -->\n\t\t\t\t\t<form method='post' action='contact.php'>\n\n\t\t\t\t\t<!-- create text boxes for user input -->";
print "<div class='form_row'>\n                    <label class='contact'><strong>Name:</strong></label>\n                    <input type='text' class='contact_input' name='uname' value = '" . $uname . "' />\n                    </div>";
if ($formerrors["unameerror"] == true) {
    print "<span>*</span>";
}
print "<div class='form_row'>\n                    <label class='contact'><strong>Email:</strong></label>\n                    <input type='text' class='contact_input' name='email' value = '" . $email . "'/>\n                    </div> ";
if ($formerrors["emailerror"] == true) {
    print "<span>*</span>\n\t\t\t\t\t   \t\t\t<div class='form_row'>e.g abc@email.com</div>";
}
print "<div class='form_row'>\n                    <label class='contact'><strong>Phone:</strong></label>\n                    <input type='text' class='contact_input' name='phone' value = '" . $phone . "'/>\n                    </div> ";
開發者ID:esselcordova,項目名稱:BookStore,代碼行數:31,代碼來源:contact.php


注:本文中的captcha::create方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。