本文整理汇总了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);
}
示例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');
}
}
}
示例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');
}
}
示例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();
示例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> ";