本文整理汇总了PHP中captcha类的典型用法代码示例。如果您正苦于以下问题:PHP captcha类的具体用法?PHP captcha怎么用?PHP captcha使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了captcha类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: main
function main($id, $mode)
{
global $db, $user, $auth, $template;
global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
$user->add_lang('acp/board');
$captcha_vars = array('captcha_gd_x_grid' => 'CAPTCHA_GD_X_GRID', 'captcha_gd_y_grid' => 'CAPTCHA_GD_Y_GRID', 'captcha_gd_foreground_noise' => 'CAPTCHA_GD_FOREGROUND_NOISE', 'captcha_gd' => 'CAPTCHA_GD_PREVIEWED', 'captcha_gd_wave' => 'CAPTCHA_GD_WAVE', 'captcha_gd_3d_noise' => 'CAPTCHA_GD_3D_NOISE', 'captcha_gd_fonts' => 'CAPTCHA_GD_FONTS');
if (isset($_GET['demo'])) {
$captcha_vars = array_keys($captcha_vars);
foreach ($captcha_vars as $captcha_var) {
$config[$captcha_var] = isset($_REQUEST[$captcha_var]) ? request_var($captcha_var, 0) : $config[$captcha_var];
}
if ($config['captcha_gd']) {
include $phpbb_root_path . 'includes/captcha/captcha_gd.' . $phpEx;
} else {
include $phpbb_root_path . 'includes/captcha/captcha_non_gd.' . $phpEx;
}
$captcha = new captcha();
$captcha->execute(gen_rand_string(mt_rand(CAPTCHA_MIN_CHARS, CAPTCHA_MAX_CHARS)), time());
exit;
}
$config_vars = array('enable_confirm' => 'REG_ENABLE', 'enable_post_confirm' => 'POST_ENABLE', 'confirm_refresh' => 'CONFIRM_REFRESH', 'captcha_gd' => 'CAPTCHA_GD');
$this->tpl_name = 'acp_captcha';
$this->page_title = 'ACP_VC_SETTINGS';
$form_key = 'acp_captcha';
add_form_key($form_key);
$submit = request_var('submit', '');
if ($submit && check_form_key($form_key)) {
$config_vars = array_keys($config_vars);
foreach ($config_vars as $config_var) {
set_config($config_var, request_var($config_var, ''));
}
$captcha_vars = array_keys($captcha_vars);
foreach ($captcha_vars as $captcha_var) {
$value = request_var($captcha_var, 0);
if ($value >= 0) {
set_config($captcha_var, $value);
}
}
add_log('admin', 'LOG_CONFIG_VISUAL');
trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($this->u_action));
} else {
if ($submit) {
trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action));
} else {
$preview_image_src = append_sid(append_sid("{$phpbb_admin_path}index.{$phpEx}", "i={$id}&demo=demo"));
if (@extension_loaded('gd')) {
$template->assign_var('GD', true);
}
foreach ($config_vars as $config_var => $template_var) {
$template->assign_var($template_var, isset($_REQUEST[$config_var]) ? request_var($config_var, '') : $config[$config_var]);
}
foreach ($captcha_vars as $captcha_var => $template_var) {
$var = isset($_REQUEST[$captcha_var]) ? request_var($captcha_var, 0) : $config[$captcha_var];
$template->assign_var($template_var, $var);
$preview_image_src .= "&{$captcha_var}=" . $var;
}
$template->assign_vars(array('CAPTCHA_PREVIEW' => $preview_image_src, 'PREVIEW' => isset($_POST['preview'])));
}
}
}
示例2: genCaptcha
function genCaptcha()
{
//Create a CAPTCHA
$captcha = new captcha();
$_SESSION['CAPTCHA'] = $captcha->getCaptcha();
exit;
}
示例3: main
function main($id, $mode)
{
global $db, $user, $phpbb_root_path, $config, $phpEx;
// Do we have an id? No, then just exit
$confirm_id = request_var('id', '');
$type = request_var('type', 0);
if (!$confirm_id || !$type) {
exit;
}
// Try and grab code for this id and session
$sql = 'SELECT code, seed
FROM ' . CONFIRM_TABLE . "\n\t\t\tWHERE session_id = '" . $db->sql_escape($user->session_id) . "'\n\t\t\t\tAND confirm_id = '" . $db->sql_escape($confirm_id) . "'\n\t\t\t\tAND confirm_type = {$type}";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
// If we have a row then grab data else create a new id
if (!$row) {
exit;
}
if ($config['captcha_gd']) {
include $phpbb_root_path . 'includes/captcha/captcha_gd.' . $phpEx;
} else {
include $phpbb_root_path . 'includes/captcha/captcha_non_gd.' . $phpEx;
}
$captcha = new captcha();
$captcha->execute($row['code'], $row['seed']);
garbage_collection();
exit_handler();
}
示例4: execute
public function execute()
{
$captcha = new captcha();
if ($captcha->created == false) {
exit;
}
$captcha->to_output();
$this->output->disable();
}
示例5: action_image
public function action_image()
{
$token = $this->request->param('id');
//removig the & we add to refresh the image.
if (($amp_pos = strpos($token, '&')) > 1) {
$token = substr($token, 0, $amp_pos);
}
$captcha = new captcha();
die($captcha->image($token));
}
示例6: captcha
public function captcha()
{
$captcha = new captcha();
$config = config('captcha');
// debug($config);
$captcha->setConfig($config);
// $captcha = load('captcha');
$captcha->create();
// debug($captcha);
}
示例7: createCaptcha
public function createCaptcha()
{
if (!$this->checkRequest()) {
return false;
}
require_once 'lib/form/captcha.php';
$captcha = new \captcha();
$this->response->addHeader('Content-Type: application/json');
$this->response->setOutput(json_encode(['src' => $captcha->png(), 'code' => $captcha->getCode()]));
}
示例8: execute
function execute()
{
if (empty($this->code)) {
if (!$this->load_code()) {
// invalid request, bail out
return false;
}
}
$captcha = new captcha();
define('IMAGE_OUTPUT', 1);
$captcha->execute($this->code, $this->seed);
}
示例9: action_index
public function action_index()
{
//template header
$this->template->title = __('Contact Us');
$this->template->meta_description = __('Contact') . ' ' . core::config('general.site_name');
Breadcrumbs::add(Breadcrumb::factory()->set_title(__('Home'))->set_url(Route::url('default')));
Breadcrumbs::add(Breadcrumb::factory()->set_title(__('Contact Us')));
if ($this->request->post()) {
//captcha check
if (captcha::check('contact')) {
//check if user is loged in
if (Auth::instance()->logged_in()) {
$email_from = Auth::instance()->get_user()->email;
$name_from = Auth::instance()->get_user()->name;
} else {
$email_from = core::post('email');
$name_from = core::post('name');
}
//akismet spam filter
if (!core::akismet($name_from, $email_from, core::post('message'))) {
$replace = array('[EMAIL.BODY]' => core::post('message'), '[EMAIL.SENDER]' => $name_from, '[EMAIL.FROM]' => $email_from);
if (Email::content(core::config('email.notify_email'), core::config('general.site_name'), $email_from, $name_from, 'contact-admin', $replace)) {
Alert::set(Alert::SUCCESS, __('Your message has been sent'));
} else {
Alert::set(Alert::ERROR, __('Message not sent'));
}
} else {
Alert::set(Alert::WARNING, __('This email has been considered as spam! We are sorry but we can not send this email.'));
}
} else {
Alert::set(Alert::ERROR, __('Wrong captcha'));
}
}
$this->template->content = View::factory('pages/contact');
}
示例10: execute
public function execute()
{
$this->output->title = "Captcha demo";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$valid = captcha::valid_code($_POST["code"]);
$this->output->add_tag("valid", show_boolean($valid));
}
}
示例11: perform
/**
* Validate capcha public key/turing key
*
* @param array $data
*/
public function perform($data = FALSE)
{
// Captcha privat key!!!
$captcha_privat_key = md5(implode('', file($data['configPath'] . 'dbConnect.php')));
// The ttf font to create turing chars images
$captcha_ttf_font = JAPA_BASE_DIR . 'modules/common/includes/ttf_font/activa.ttf';
// Relative folder of captcha pictures
$captcha_pictures_folder = JAPA_PUBLIC_DIR . 'data/common/captcha';
// Type of turing chars
$captcha_char_type = 'num';
// or 'hex'
$captcha = new captcha($captcha_privat_key, JAPA_BASE_DIR, $captcha_ttf_font, $captcha_pictures_folder, $captcha_char_type);
if (FALSE == $captcha->check_captcha($data['public_key'], $data['turing_key'])) {
return FALSE;
}
return TRUE;
}
示例12: check
function check($value, $idhash, $seccheck, $fromjs, $modid) {
global $_G;
if(!$_G['setting']['my_siteid']) {
return false;
}
$sig = $_G['cookie']['dcaptchasig'];
$data = captcha::validate($value, $sig, $fromjs, $modid);
return $data == '{"errCode":0}';
}
示例13: gorusKaydet
function gorusKaydet()
{
captcha::check("index.php?option=com_yeterlilik_taslak&view=gorus_bildir&standartId=" . JRequest::getVar("standartId"));
$db =& JFactory::getOracleDBO();
$model = $this->getModel('gorus_kaydet');
$post = JRequest::get('post');
$message = $model->gorusKaydet($db, $post);
$this->setRedirect('index.php', $message);
}
示例14: perform
/**
* Create capcha picture and public key
*
* @param array $data
*/
public function perform($data = FALSE)
{
// Captcha privat key!!!
$captcha_privat_key = md5(implode('', file($data['configPath'] . 'dbConnect.php')));
// The ttf font to create turing chars images
$captcha_ttf_font = SMART_BASE_DIR . 'modules/common/includes/ttf_font/activa.ttf';
// Relative folder of captcha pictures
$captcha_pictures_folder = SMART_RELATIVE_PATH . 'data/common/captcha';
// Type of turing chars
$captcha_char_type = 'num';
// or 'hex'
$captcha = new captcha($captcha_privat_key, SMART_BASE_DIR, $captcha_ttf_font, $captcha_pictures_folder, $captcha_char_type);
$captcha->captcha_picture_expire = 300;
$captcha->width = 120;
$captcha->string_len = 5;
$captcha->shadow = FALSE;
$data['captcha_pic'] = $captcha->make_captcha();
//@chmod(SMART_BASE_DIR . $_captcha_pic, 0775);
$data['public_key'] = $captcha->public_key;
return TRUE;
}
示例15: main
function main($id, $mode)
{
global $db, $user, $phpbb_root_path, $config, $phpEx;
// Do we have an id? No, then just exit
$confirm_id = request_var('id', '');
$type = request_var('type', 0);
if (!$confirm_id || !$type) {
exit;
}
// Try and grab code for this id and session
$sql = 'SELECT code
FROM ' . CONFIRM_TABLE . " \n\t\t\tWHERE session_id = '" . $db->sql_escape($user->session_id) . "' \n\t\t\t\tAND confirm_id = '" . $db->sql_escape($confirm_id) . "'\n\t\t\t\tAND confirm_type = {$type}";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
// If we have a row then grab data else create a new id
if (!$row) {
exit;
}
// Some people might want the olde style CAPTCHA even if they have GD enabled, this also saves us from people who have GD but no TTF
$policy_modules = array('policy_entropy', 'policy_3dbitmap');
if (function_exists('imagettfbbox') && function_exists('imagettftext')) {
$policy_modules += array('policy_overlap', 'policy_shape', 'policy_cells', 'policy_stencil', 'policy_composite');
}
foreach ($policy_modules as $key => $name) {
if ($config[$name] === '0') {
unset($policy_modules[$key]);
}
}
$policy = '';
if (@extension_loaded('gd') && sizeof($policy_modules)) {
include $phpbb_root_path . 'includes/captcha/captcha_gd.' . $phpEx;
$policy = $policy_modules[array_rand($policy_modules)];
} else {
include $phpbb_root_path . 'includes/captcha/captcha_non_gd.' . $phpEx;
}
$captcha = new captcha();
$captcha->execute($row['code'], $policy);
exit;
}