示例#1
0
 public function captcha()
 {
     $captcha = new SimpleCaptcha();
     $captcha->resourcesPath = JPATH_ROOT . DS . 'components' . DS . 'com_hp_comment' . DS . 'helpers' . DS . 'simple_captcha' . DS . 'resources';
     $captcha->CreateImage();
     exit;
 }
 public static function yz_auth_getcaptcha()
 {
     include_once dirname(__FILE__) . '/captcha/captcha.php';
     session_start();
     $captcha = new SimpleCaptcha();
     $captcha->CreateImage();
     die;
 }
示例#3
0
 function access($ctx)
 {
     $this->layout = false;
     require_once APP_PATH . '/classes/captcha/SimpleCaptcha.php';
     $captcha = new SimpleCaptcha();
     $code = $captcha->getText();
     $token = SafeUtil::set_captcha($code, 300);
     $ret = array('img_url' => _action('', array('token' => $token)), 'field_name' => SafeUtil::CAPTCHA_FIELD_NAME, 'field_value' => $token);
     return $ret;
 }
 public function index()
 {
     $view = $this->getView();
     $req = $this->getPageRequest();
     // This will tell the system not to actually output anything.
     $view->record = false;
     $view->contenttype = 'image/png';
     $view->mode = View::MODE_NOOUTPUT;
     $captcha = new SimpleCaptcha();
     $captcha->createImage();
 }
 public static function showCaptcha()
 {
     $captcha = new SimpleCaptcha();
     $captcha->resourcesPath = app_path() . '/third_party/captcha/resources';
     $captcha->backgroundColor = [78, 93, 108];
     $captcha->width = 400;
     $captcha->height = 140;
     $captcha->fonts = array('Antykwa' => array('spacing' => -3, 'minSize' => 37, 'maxSize' => 40, 'font' => 'AntykwaBold.ttf'), 'VeraSans' => array('spacing' => -1, 'minSize' => 30, 'maxSize' => 38, 'font' => 'VeraSansBold.ttf'));
     $captcha->colors = [[235, 235, 235]];
     return Response::make($captcha->CreateImage(), 200, ['Content-Type' => 'image/jpeg']);
 }
    function getImage(){

            $captcha = new SimpleCaptcha();

            $captcha->wordsFile = 'words/es.php';

            $captcha->resourcesPath = "www/resourcesCaptcha";

            // Image generation
            $captcha->CreateImage($this->session);

    }
 static function _get_image()
 {
     if (STInput::get('st_get_captcha')) {
         $key = STInput::get('key');
         $captcha = new SimpleCaptcha();
         if ($key) {
             $captcha->session_var = $key;
         }
         $captcha->CreateImage();
         die;
     }
 }
示例#8
0
function generate_captcha($extra = '1234567890')
{
    global $config;
    $text = rand_string($config['captcha']['length'], $extra);
    $captcha = new SimpleCaptcha();
    $cookie = rand_string(20, "abcdefghijklmnopqrstuvwxyz");
    ob_start();
    $captcha->CreateImage($text);
    $image = ob_get_contents();
    ob_end_clean();
    $html = '<image src="data:image/png;base64,' . base64_encode($image) . '">';
    $query = prepare("INSERT INTO `captchas` (`cookie`, `extra`, `text`, `created_at`) VALUES (?, ?, ?, ?)");
    $query->execute([$cookie, $extra, $text, time()]);
    return array("cookie" => $cookie, "html" => $html);
}
示例#9
0
 public function action_captcha()
 {
     Session::instance();
     $path = Kohana::find_file('vendor', 'cool-php-captcha-0.3.1/captcha');
     require_once $path;
     $captcha = new SimpleCaptcha();
     // OPTIONAL Change configuration...
     $captcha->wordsFile = 'words/en.php';
     $captcha->session_var = 'captcha';
     $captcha->imageFormat = 'png';
     $captcha->lineWidth = 3;
     //$captcha->scale = 3; $captcha->blur = true;
     $captcha->resourcesPath = APPPATH . "vendor/cool-php-captcha-0.3.1/resources";
     // OPTIONAL Simple autodetect language example
     /*
     if (!empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
         $langs = array('en', 'es');
         $lang  = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
         if (in_array($lang, $langs)) {
             $captcha->wordsFile = "words/$lang.php";
         }
     }
     */
     // Image generation
     ob_start();
     $captcha->CreateImage();
     $content = ob_get_contents();
     ob_end_clean();
     $this->response->headers('Content-type', 'image/png');
     $this->response->send_headers();
     $this->response->body($content);
 }
 /**
  * Generates the captcha values 
  * 
  * @return array 
  */
 protected function _generate()
 {
     if ($this->captcha_generated === TRUE) {
         return;
     }
     # Choose the first number randomly between 6 and 10. This is to stop the answer being negative.
     $numberOne = mt_rand(6, 9);
     # Choose the second number randomly between 0 and 5.
     $numberTwo = mt_rand(1, 5);
     # Choose the operator randomly from the array.
     $captchaOperator = $this->captcha_operator_convert[mt_rand(0, count($this->captcha_operator_convert) - 1)];
     # Get the equation in textual form to show to the user.
     $this->captcha_text = $numberOne . ' ' . $captchaOperator . ' ' . $numberTwo;
     # Evaluate the equation and get the result.
     $this->captcha_result = $numberOne - $numberTwo;
     # Session-Way (only one form at a time) - must be a component then
     //$this->Session->write('Captcha.result', $result);
     # DB-Way (several forms possible, high security via IP-Based max limits)
     // the following should be done in a component and passed to the view/helper
     // $Captcha = ClassRegistry::init('Captcha');
     // $Captcha->new(); $Captcha->update(); etc
     # Timestamp-SessionID-Hash-Way (several forms possible, not as secure)
     $this->captcha_hash = SimpleCaptcha::buildHash(array('timestamp' => time(), 'result' => $this->captcha_result), $this->options);
     $this->captcha_generated = TRUE;
     return;
 }
示例#11
0
 function index($ctx)
 {
     $this->is_ajax = false;
     $this->layout = false;
     require_once APP_PATH . '/classes/captcha/SimpleCaptcha.php';
     $captcha = new SimpleCaptcha();
     $captcha->width = 140;
     $captcha->height = 60;
     $captcha->scale = 4;
     $captcha->blur = true;
     // OPTIONAL Change configuration...
     //$captcha->imageFormat = 'png';
     //$captcha->resourcesPath = "/var/cool-php-captcha/resources";
     $code = $captcha->getText();
     session_start();
     $_SESSION['verify_code'] = $code;
     $captcha->CreateImage();
 }
 public function actionRenderImages()
 {
     $sc = new SimpleCaptcha();
     if (isset($_REQUEST['lang'])) {
         $sc->setSelectedLanguage($_REQUEST['lang']);
     } else {
         $sc->setSelectedLanguage = 'ru';
     }
     try {
         if (isset($_REQUEST['hash'])) {
             // Just getting one image file by it's hash
             $sc->getImageByHash($_REQUEST['hash']);
         } else {
             // Getting all image data and hashes
             $sc->resetSessionData();
             $imageData = $sc->getAllImageData();
             // Finish up by writing data to the session and the ouput buffer
             $sc->writeSessionData();
             header("Content-Type: application/json");
             echo json_encode($imageData);
         }
     } catch (InvalidArgumentException $iae) {
         $code = $iae->getCode();
         if (!$code) {
             $code = 400;
         }
         header(SimpleCaptcha::getProtocol() . " {$code} " . $iae->getMessage());
         echo $iae->getMessage();
     } catch (Exception $e) {
         $code = $e->getCode();
         if (!$code) {
             $code = 500;
         }
         header(SimpleCaptcha::getProtocol() . " {$code} " . $e->getMessage());
         echo $e->getMessage();
     }
     exit;
     // make sure we stop the script
 }
示例#13
0
<?php

Route::get('/captcha', function () {
    return SimpleCaptcha::create(Input::has('id') ? Input::get('id') : null);
});
示例#14
0
文件: PostAdd.php 项目: congtt/pj.ntk
 function execute()
 {
     global $ts_config;
     $_Title = 'Forum - Quản lý Bài đăng';
     $_msg = null;
     $captcha = new SimpleCaptcha();
     $formmode = $_POST["formmode"];
     $mode_inpvl = __post('mode_inpvl');
     $captchatxt = __post('captcha');
     $captchaForm = __post('captchaForm');
     $idchk = $_POST["chk"];
     $flagCaptcha = $captcha->CaptchaValidate($captchatxt);
     $flagCaptchaForm = $captcha->CaptchaValidate($captchaForm);
     $Id = __post("Id");
     if ($Id > 0) {
         if ($token != $this->md5sum('edit' . $Id)) {
             die('Do not have permission to access page!');
         }
     }
     if ($mode_inpvl == 'ADD') {
         $menu_id = __post("menu_id");
         $title_vi = __post("title_vi");
         $title_en = __post("title_en");
         $short_vi = __post("short_vi");
         $short_en = __post("short_en");
         $content_vi = __post("content_vi");
         $content_en = __post("content_en");
         $keyword_vi = __post("keyword_vi");
         $keyword_en = __post("keyword_en");
         $status = (int) __post("status");
         $show_index = (int) __post("show_index");
         $result_id = $this->form_add($id, $menu_id, $title_vi, $title_en, $short_vi, $short_en, $content_vi, $content_en, $keyword_vi, $keyword_en, $status, $show_index);
         if ((int) $id <= 0) {
             $id = $result_id;
         }
         if ($result_id > 0) {
             $_msg['result'] = 1;
         } else {
             $_msg['result'] = -20;
         }
     }
     $list_form = new XTemplate('Config/PostAdd.html');
     $left_menu = $this->rmenu();
     $list_form->assign('slide_bar', $this->slide_bar($left_menu));
     $list_form->assign('tabs', $this->set_tabs());
     $list_form->assign('dialog_title', 'thành viên');
     $CaptchaText = $captcha->CreateText();
     if ((int) $Id > 0) {
         $token = __post("token");
         $data = $this->getDetail($Id);
         foreach ($data as $key => $value) {
             ${$key} = $value;
         }
         /*
         			$sSQL = "select * from ntk_forum_posts where id = ".(int)$Id;
         			$result = $this->db->query($sSQL, true, "Query failed");	
         			while ($aR = $this->db->fetchByAssoc($result)){
         				$list_form->assign('file',$aR);
         				$list_form->parse('main.file');
         			}*/
     }
     $class_input = 'ckeditor';
     $arr_info_menu_id = $this->getListPostCategories();
     $Attr_menu_id = array('rel' => '{Require:\'R\',Alert:\'Vui lòng chọn danh mục \'}', 'style' => 'width:400px;');
     $txt_menu_id = addSelectList2('menu_id', $arr_info_menu_id, NULL, $Attr_menu_id, $list_form, $menu_id);
     $arr_info_status = array(1 => 'Active', 0 => 'InActive');
     $Attr_status = array('rel' => '{Require:\'R\',Alert:\'Vui lòng chọn trạng thái \'}', 'style' => '');
     $txt_status = addSelectList2('status', $arr_info_status, NULL, $Attr_status, $list_form, $status);
     $Attr_psttitle_vi = array('rel' => '{Require:\'R\',Alert:\'Vui lòng nhập tên bệnh viện \'}', 'style' => 'width:400px;');
     $txt_psttitle_vi = addInput('text', 'title_vi', $title_vi, $Attr_psttitle_vi, $list_form);
     $Attr_psttitle_en = array('rel' => '{Require:\'R\',Alert:\'Vui lòng nhập tên bệnh viện \'}', 'style' => 'width:400px;');
     $txt_psttitle_en = addInput('text', 'title_en', $title_en, $Attr_psttitle_en, $list_form);
     $Attr_short_vi = array('class' => $class_input, 'rel1' => '{Require:\'R\',Alert:\'Vui lòng nhập role_name  \'}', 'style' => 'width:400px;');
     $txt_short_vi = addTextarea('short_vi', 3, 30, $short_vi, $Attr_short_vi, $list_form);
     $Attr_short_en = array('class' => $class_input, 'rel1' => '{Require:\'R\',Alert:\'Vui lòng nhập role_name  \'}', 'style' => 'width:400px;');
     $txt_short_en = addTextarea('short_en', 3, 30, $short_en, $Attr_short_en, $list_form);
     $Attr_content_vi = array('class' => $class_input, 'rel1' => '{Require:\'R\',Alert:\'Vui lòng nhập role_name  \'}', 'style' => 'width:400px;');
     $txt_content_vi = addTextarea('content_vi', 3, 30, $content_vi, $Attr_content_vi, $list_form);
     $Attr_content_en = array('class' => $class_input, 'rel1' => '{Require:\'R\',Alert:\'Vui lòng nhập role_name  \'}', 'style' => 'width:400px;');
     $txt_content_en = addTextarea('content_en', 3, 30, $content_en, $Attr_content_en, $list_form);
     $Attr_pstkeyword_vi = array('rel' => '{Require:\'R\',Alert:\'Vui lòng nhập tên bệnh viện \'}', 'style' => 'width:400px;');
     $txt_pstkeyword_vi = addInput('text', 'keyword_vi', $keyword_vi, $Attr_pstkeyword_vi, $list_form);
     $Attr_pstkeyword_en = array('rel' => '{Require:\'R\',Alert:\'Vui lòng nhập tên bệnh viện \'}', 'style' => 'width:400px;');
     $txt_pstkeyword_en = addInput('text', 'keyword_en', $keyword_en, $Attr_pstkeyword_en, $list_form);
     $arr_info_show_index = array(1 => 'Hiển thị trang chủ', 0 => 'Không hiển thị trang chủ');
     $Attr_show_index = array('rel1' => '{Require:\'R\',Alert:\'Vui lòng chọn trạng thái \'}', 'style' => '');
     $txt_show_index = addSelectList2('show_index', $arr_info_show_index, NULL, $Attr_show_index, $list_form, $show_index);
     if ($this->acl_per(2)) {
         $arr_attr_btnadd = array('style' => 'color:blue;', 'onclick' => 'add()');
         $inp_btnadd = addInput2('button', 'btnadd', $btnadd, $arr_attr_btnadd, $list_form, 'LƯU');
     }
     setMessage($list_form, $_msg);
     $list_form->assign('title', $_Title);
     $list_form->assign('_error_', $error);
     $list_form->assign('gridview', $gridview);
     $list_form->assign('Id', $Id);
     $list_form->assign('token', $token);
     $list_form->parse('main');
     $html = $list_form->out_return('main');
     echo $html;
 }
示例#15
0
文件: NewsAdd.php 项目: congtt/pj.ntk
 function execute()
 {
     global $ts_config;
     $_Title = 'Quản lý Bài viết';
     $_msg = null;
     $captcha = new SimpleCaptcha();
     $formmode = $_POST["formmode"];
     $mode_inpvl = __post('mode_inpvl');
     $captchatxt = __post('captcha');
     $captchaForm = __post('captchaForm');
     $idchk = $_POST["chk"];
     $flagCaptcha = $captcha->CaptchaValidate($captchatxt);
     $flagCaptchaForm = $captcha->CaptchaValidate($captchaForm);
     $Id = __post2("Id");
     $token = __post2("token");
     if ($Id > 0) {
         if ($token != $this->md5sum('edit' . $Id)) {
             die('Do not have permission to access page!');
         }
     }
     $list_form = new XTemplate('Config/NewsAdd.html');
     if ($mode_inpvl == 'ADD') {
         $menu_id = __post("menu_id");
         $title_vi = __post("title_vi");
         $title_en = __post("title_en");
         $short_vi = __post("short_vi");
         $short_en = __post("short_en");
         $content_vi = __post("content_vi");
         $content_en = __post("content_en");
         $keyword_vi = __post("keyword_vi");
         $keyword_en = __post("keyword_en");
         $status = (int) __post("status");
         $result_id = $this->form_add($Id, $menu_id, $title_vi, $title_en, $short_vi, $short_en, $content_vi, $content_en, $keyword_vi, $keyword_en, $status);
         if ((int) $Id <= 0) {
             $Id = $result_id;
         }
         $result = UpLoadMultiFile($ts_config['upload_dir'], 'filenew', false, '', $max_size = 9048576);
         $file_type_id = 7;
         foreach ($result as $k => $va) {
             if ($va['result'] == 1) {
                 $sSQL = "insert into ntk_new_files(new_id,file_name,file_path,file_type_id,require_login)\n\t\t\t\t\t\tvalues(" . $Id . ",'" . $va['name'] . "','" . $va['file_name'] . "'," . $file_type_id . ",1)\n\t\t\t\t\t";
                 $re = $this->db->query($sSQL, true, "Query failed");
             }
         }
         if ($result_id > 0) {
             $_msg['result'] = 1;
         } else {
             $_msg['result'] = -20;
         }
     }
     if ((int) $Id > 0) {
         $data = $this->getDetail($Id);
         foreach ($data as $key => $value) {
             ${$key} = $value;
         }
         $sSQL = "select * from ntk_new_files where new_id = " . (int) $Id;
         $result = $this->db->query($sSQL, true, "Query failed");
         while ($aR = $this->db->fetchByAssoc($result)) {
             $list_form->assign('file', $aR);
             $list_form->parse('main.file');
         }
     }
     $left_menu = $this->rmenu();
     $list_form->assign('slide_bar', $this->slide_bar($left_menu));
     $list_form->assign('tabs', $this->set_tabs());
     $list_form->assign('dialog_title', 'thành viên');
     $CaptchaText = $captcha->CreateText();
     $arr_info_menu_id = $this->getListNewsCategories();
     $Attr_menu_id = array('rel' => '{Require:\'R\',Alert:\'Vui lòng chọn danh mục \'}', 'style' => 'width:400px;');
     $txt_menu_id = addSelectList2('menu_id', $arr_info_menu_id, NULL, $Attr_menu_id, $list_form, $cid);
     $arr_info_status = array(1 => 'Active', 0 => 'InActive');
     $Attr_status = array('rel' => '{Require:\'R\',Alert:\'Vui lòng chọn trạng thái \'}', 'style' => '');
     $txt_status = addSelectList2('status', $arr_info_status, NULL, $Attr_status, $list_form, $status);
     $Attr_psttitle_vi = array('rel' => '{Require:\'R\',Alert:\'Vui lòng nhập tiêu đề tiếng việt \'}', 'style' => 'width:400px;');
     $txt_psttitle_vi = addInput('text', 'title_vi', $title_vi, $Attr_psttitle_vi, $list_form);
     $Attr_psttitle_en = array('rel1' => '{Require:\'R\',Alert:\'Vui lòng nhập tiêu đề tiếng anh \'}', 'style' => 'width:400px;');
     $txt_psttitle_en = addInput('text', 'title_en', $title_en, $Attr_psttitle_en, $list_form);
     $class_input = 'ckeditor';
     $Attr_short_vi = array('class' => $class_input, 'rel' => '{Require:\'R\',Alert:\'Vui lòng nhập mô tả ngắn tiếng việt  \'}', 'style' => 'width:400px;');
     $txt_short_vi = addTextarea('short_vi', 3, 30, $short_vi, $Attr_short_vi, $list_form);
     $Attr_short_en = array('class' => $class_input, 'rel1' => '{Require:\'R\',Alert:\'Vui lòng nhập role_name  \'}', 'style' => 'width:400px;');
     $txt_short_en = addTextarea('short_en', 3, 30, $short_en, $Attr_short_en, $list_form);
     $Attr_content_vi = array('class' => $class_input, 'rel' => '{Require:\'R\',Alert:\'Vui lòng nhập Nội dung tiếng việt  \'}', 'style' => 'width:400px;');
     $txt_content_vi = addTextarea('content_vi', 3, 30, $content_vi, $Attr_content_vi, $list_form);
     $Attr_content_en = array('class' => $class_input, 'rel1' => '{Require:\'R\',Alert:\'Vui lòng nhập Nội dung tiếng anh  \'}', 'style' => 'width:400px;');
     $txt_content_en = addTextarea('content_en', 3, 30, $content_en, $Attr_content_en, $list_form);
     $Attr_pstkeyword_vi = array('rel' => '{Require:\'R\',Alert:\'Vui lòng nhập từ khóa tiếng việt \'}', 'style' => 'width:400px;');
     $txt_pstkeyword_vi = addInput('text', 'keyword_vi', $keyword_vi, $Attr_pstkeyword_vi, $list_form);
     $Attr_pstkeyword_en = array('rel1' => '{Require:\'R\',Alert:\'Vui lòng nhập từ khóa tiếng anh\'}', 'style' => 'width:400px;');
     $txt_pstkeyword_en = addInput('text', 'keyword_en', $keyword_en, $Attr_pstkeyword_en, $list_form);
     if ($this->acl_per(2)) {
         //$arr_attr_btnadd = array('style'=>'color:blue;','onclick'=>'sbm_form(2,\''.$CaptchaText.'\')');
         $arr_attr_btnadd = array('style' => 'color:blue;', 'onclick' => 'add()');
         $inp_btnadd = addInput2('button', 'btnadd', $btnadd, $arr_attr_btnadd, $list_form, 'LƯU');
     }
     $list_form->assign('Id', $Id);
     $list_form->assign('token', $token);
     //$list_form->parse('main');
     //	$html = $list_form->out_return('main');
     $list_form->assign('title', $_Title);
     $list_form->assign('_error_', $error);
     $list_form->assign('gridview', $gridview);
     $list_form->parse('main');
     $this->html = $list_form->out_return('main');
     echo $this->html;
 }
示例#16
0
<?php

include 'SimpleCaptcha.php';
session_start();
$captcha = new SimpleCaptcha();
$captcha->width = 140;
$captcha->height = 60;
$captcha->scale = 3;
$captcha->blur = true;
// OPTIONAL Change configuration...
//$captcha->wordsFile = 'words/es.php';
//$captcha->session_var = 'secretword';
//$captcha->imageFormat = 'png';
//$captcha->resourcesPath = "/var/cool-php-captcha/resources";
// Image generation
$text = $captcha->CreateImage();
示例#17
0
 function execute()
 {
     $_Title = 'Quản lý Bệnh viện';
     $_msg = null;
     $captcha = new SimpleCaptcha();
     $formmode = $_POST["formmode"];
     $mode_inpvl = __post('mode_inpvl');
     $captchatxt = __post('captcha');
     $captchaForm = __post('captchaForm');
     $idchk = $_POST["chk"];
     $flagCaptcha = $captcha->CaptchaValidate($captchatxt);
     $flagCaptchaForm = $captcha->CaptchaValidate($captchaForm);
     $id = __post('Id');
     /*===================================*/
     if ($formmode != '') {
         $name = __post("name");
         $province_id = __post("province_id");
         $status = (int) __post("status");
         $order = (int) __post("order");
         $_msg = $this->form_add($id, $province_id, $name, $status, $order);
         if (!isset($_msg)) {
             $_msg['result'] = -20;
         }
     }
     $list_form = new XTemplate('Config/Hospital.html');
     $left_menu = $this->rmenu();
     $list_form->assign('slide_bar', $this->slide_bar($left_menu));
     $list_form->assign('tabs', $this->set_tabs());
     $list_form->assign('dialog_title', 'thành viên');
     $CaptchaText = $captcha->CreateText();
     /****** Delete (8) - Export (16) ***********************************/
     $arr_attr_btnmdelete = array('style' => '', 'onclick' => 'sbm_form(8,\'' . $CaptchaText . '\')');
     $inp_btnmdelete = addInput2('button', 'btndelete', $btnmdelete, $arr_attr_btnmdelete, $list_form, 'Xóa');
     if ($mode_inpvl == 'DELETE') {
         $idList = '0';
         foreach ($idchk as $ind => $delvl) {
             $idArr = explode('|', $delvl);
             if ($idArr[1] == $this->md5sum($this->prefix['delete'] . $idArr[0])) {
                 $idList .= ',' . $idArr[0];
             }
         }
         if ($idList != '0') {
             $_msg = $this->form_delete($idList);
         }
     }
     /****** Delete (8) - Export (16) ***********************************/
     if ($this->acl_per(16)) {
         $arr_attr_btnexport = array('style' => '', 'onclick' => 'sbm_form(16,\'' . $CaptchaText . '\')');
         $inp_btnexport = addInput2('button', 'btnexport', $btnexport, $arr_attr_btnexport, $list_form, 'Xuất Excel');
     }
     /*************************************
      *****************/
     $keyword = __post("keyword");
     $selectkeyword = __post("selectkeyword");
     $Attr_keyword = array('rel1' => '{Require:\'R\',Alert:\'Vui lòng nhập Keyword  \'}', 'style' => '');
     $txt_keyword = addInput('text', 'keyword', $keyword, $Attr_keyword, $list_form);
     $infosk[0] = array('t1.name' => 'Tên bệnh viện');
     $vlkey = array_keys($infosk[$selectkeyword]);
     //list($vlkey, $vlval) = each();
     $Attr_selectkeyword = array('style' => '');
     $txt_selectkeyword = addSelectList5('selectkeyword', $infosk, NULL, $Attr_selectkeyword, $list_form, $selectkeyword);
     if ($keyword != '' && $vlkey[0] != '') {
         $filter = ' and ' . $vlkey[0] . " like N'%{$keyword}%'";
     }
     $s_province_id = (int) __post('s_province_id');
     $s_status = __post('s_status');
     if ($s_province_id > 0) {
         $filter = ' and t1.province_id = ' . $s_province_id;
     }
     if ($s_status != "") {
         $filter = ' and t1.status = ' . (int) $s_status;
     }
     //-----------------------------------------//
     $gridview = '';
     $gridview .= $this->PageHeader();
     $gridview .= $this->_AddPageHeader();
     $exportGrid = $this->setHeader();
     $DBList = $this->setList($CaptchaText, $filter, $conpany_list);
     $exportGrid .= $DBList[0];
     $gridview .= $exportGrid;
     $gridview .= $this->setFooter();
     $gridview .= $this->setPaging();
     $arr_info_province_id = $this->getListProvince();
     $Attr_province_id = array('style' => '');
     $txt_province_id = addSelectList2('s_province_id', $arr_info_province_id, "-- Tất cả --", $Attr_province_id, $list_form, $s_province_id);
     $arr_info_status = array(1 => 'Active', 0 => 'InActive');
     $Attr_status = array('style' => '');
     $txt_status = addSelectList2('s_status', $arr_info_status, "-- Tất cả --", $Attr_status, $list_form, $s_status);
     if ($mode_inpvl === 'EXPORT' && $this->acl_per(16)) {
         $this->ExportToExcel(fnStrConvert($_Title), strip_tags($exportGrid, '<table><tr><td><th>'));
         die;
     }
     //-----------------------------------------//
     setMessage($list_form, $_msg);
     $list_form->assign('title', $_Title);
     $list_form->assign('_error_', $error);
     $list_form->assign('gridview', $gridview);
     $list_form->parse('main');
     $this->html = $list_form->out_return('main');
     echo $this->html;
 }
 * Script para la generación de CAPTCHAS
 *
 * @author  Jose Rodriguez <*****@*****.**>
 * @license GPLv3
 * @link    http://code.google.com/p/cool-php-captcha
 * @package captcha
 * @version 0.3
 *
 */
$folder_name = $_GET['folder'];
$amount = (int) $_GET['amount'];
// The pictures will be saved to this folder
$folder = '../temp/' . $folder_name . '/';
$numberOfTrainImagesToGenerate = $amount;
$logAfterEveryNumberOfCaptchas = 1000;
$captcha = new SimpleCaptcha();
$captcha->folderTrain = $folder;
$captcha->minWordLength = 6;
$captcha->maxWordLength = 6;
//empty the folder first
echo "Deleting old files...\n";
flush();
ob_flush();
flush();
exec("rm -rf {$folder}");
exec("mkdir {$folder}");
for ($j = 0; $j < $numberOfTrainImagesToGenerate; $j++) {
    // Image generation
    $captcha->CreateTrainImage();
    if ($j % $logAfterEveryNumberOfCaptchas == 0) {
        echo $j . " Training Samples have been created...(" . $captcha->skippedDuplicates . " skipped duplicates)\n";
示例#19
0
        $db = new gbook_sql();
        $db->connect();
        $db->query("DELETE FROM {$GB_TBL["cap"]} WHERE timestamp < {$expired}");
        $res = $db->query("SELECT * FROM {$GB_TBL["cap"]} WHERE session_id='{$id}' LIMIT 1");
        $result = $db->fetch_array($res);
        if (isset($result['validate_key'])) {
            $imageType = "";
            if (extension_loaded("gd")) {
                $img = new SimpleCaptcha();
                $img->setFontSizeRange(14, 18);
                reset($img->supportedImagesTypes);
                $imageType = key($img->supportedImagesTypes);
                $img->setText($result['validate_key']);
            } else {
                require_once $include_path . "/lib/bitmapimagetext.class.php";
                $img = new BitmapImageText();
                $img->setText(strtoupper($result['validate_key']));
            }
            $img->setBackgroundColors(array("EEEEEE", "F2F3D3", "F5EAEA", "E4F3EE", "EEE4F3", "FFE6E6"));
            $img->setTextColors(array("000000", "FD130A", "0A1BFD", "149703", "486C66", "870DC3", "D78406", "105243"));
            if (!empty($imageType)) {
                $img->getImage($imageType);
            } else {
                $img->getImage();
            }
            exit;
        }
    }
}
SimpleCaptcha::createPixel();
示例#20
0
<?php

error_reporting(E_ALL);
ini_set('display_errors', 1);
require 'Captcha.php';
$captcha = new SimpleCaptcha();
$captcha->createImage();
示例#21
0
文件: Post.php 项目: congtt/pj.ntk
 function execute()
 {
     global $ts_config;
     $_Title = 'Forum - Quản lý Bài đăng';
     $_msg = null;
     $captcha = new SimpleCaptcha();
     $formmode = $_POST["formmode"];
     $mode_inpvl = __post('mode_inpvl');
     $captchatxt = __post('captcha');
     $captchaForm = __post('captchaForm');
     $idchk = $_POST["chk"];
     $flagCaptcha = $captcha->CaptchaValidate($captchatxt);
     $flagCaptchaForm = $captcha->CaptchaValidate($captchaForm);
     $id = __post('Id');
     /*===================================*/
     if ($formmode != '') {
         $menu_id = __post("menu_id");
         $title_vi = __post("title_vi");
         $title_en = __post("title_en");
         $short_vi = __post("short_vi");
         $short_en = __post("short_en");
         $content_vi = __post("content_vi");
         $content_en = __post("content_en");
         $keyword_vi = __post("keyword_vi");
         $keyword_en = __post("keyword_en");
         $status = (int) __post("status");
         $show_index = (int) __post("show_index");
         $result_id = $this->form_add($id, $menu_id, $title_vi, $title_en, $short_vi, $short_en, $content_vi, $content_en, $keyword_vi, $keyword_en, $status, $show_index);
         if ((int) $id <= 0) {
             $id = $result_id;
         }
         /*
         			$result = UpLoadMultiFile($ts_config['upload_dir'],'filenew',$gen_name = false,$title='',$max_size=9048576);
         			$file_type_id = 7;
         			foreach($result as $k=>$va){
         				$sSQL = "insert into ntk_new_files(new_id,file_name,file_path,file_type_id,require_login)
         						values(".$id.",'".$va['name']."','".$va['file_name']."',".$file_type_id.",1)
         				";
         				$re = $this->db->query($sSQL, true, "Query failed");
         			}*/
         if ($result_id > 0) {
             $_msg['result'] = 1;
         } else {
             $_msg['result'] = -20;
         }
     }
     $list_form = new XTemplate('Config/Post.html');
     $left_menu = $this->rmenu();
     $list_form->assign('slide_bar', $this->slide_bar($left_menu));
     $list_form->assign('tabs', $this->set_tabs());
     $list_form->assign('dialog_title', 'thành viên');
     $CaptchaText = $captcha->CreateText();
     /****** Delete (8) - Export (16) ***********************************/
     $arr_attr_btnmdelete = array('style' => '', 'onclick' => 'sbm_form(8,\'' . $CaptchaText . '\')');
     $inp_btnmdelete = addInput2('button', 'btndelete', $btnmdelete, $arr_attr_btnmdelete, $list_form, 'Xóa');
     if ($mode_inpvl == 'DELETE') {
         $idList = '0';
         foreach ($idchk as $ind => $delvl) {
             $idArr = explode('|', $delvl);
             if ($idArr[1] == $this->md5sum($this->prefix['delete'] . $idArr[0])) {
                 $idList .= ',' . $idArr[0];
             }
         }
         if ($idList != '0') {
             $_msg = $this->form_delete($idList);
         }
     }
     /****** Delete (8) - Export (16) ***********************************/
     if ($this->acl_per(16)) {
         $arr_attr_btnexport = array('style' => '', 'onclick' => 'sbm_form(16,\'' . $CaptchaText . '\')');
         $inp_btnexport = addInput2('button', 'btnexport', $btnexport, $arr_attr_btnexport, $list_form, 'Xuất Excel');
     }
     /*************************************
      *****************/
     $keyword = __post("keyword");
     $selectkeyword = __post("selectkeyword");
     $Attr_keyword = array('rel1' => '{Require:\'R\',Alert:\'Vui lòng nhập Keyword  \'}', 'style' => '');
     $txt_keyword = addInput('text', 'keyword', $keyword, $Attr_keyword, $list_form);
     $infosk[0] = array('t1.title_vi' => 'Tên bài đăng(vi)');
     $infosk[1] = array('t1.title_en' => 'Tên bài đăng(en)');
     $vlkey = array_keys($infosk[$selectkeyword]);
     //list($vlkey, $vlval) = each();
     $Attr_selectkeyword = array('style' => '');
     $txt_selectkeyword = addSelectList5('selectkeyword', $infosk, NULL, $Attr_selectkeyword, $list_form, $selectkeyword);
     if ($keyword != '' && $vlkey[0] != '') {
         $filter .= ' and ' . $vlkey[0] . " like N'%{$keyword}%'";
     }
     $category_id = (int) __post('category_id');
     $status = __post('status');
     $show_index = __post('show_index');
     //echo $filter;
     if ($category_id > 0) {
         $filter .= ' and t1.cid = ' . $category_id;
     }
     if ($status != "") {
         $filter .= ' and t1.status = ' . (int) $status;
     }
     if ($show_index != "") {
         $filter .= ' and t1.show_index = ' . (int) $show_index;
     }
     //-----------------------------------------//
     $gridview = '';
     $gridview .= $this->PageHeader();
     $gridview .= $this->_AddPageHeader();
     $exportGrid = $this->setHeader();
     $DBList = $this->setList($CaptchaText, $filter, $conpany_list);
     $exportGrid .= $DBList[0];
     $gridview .= $exportGrid;
     $gridview .= $this->setFooter();
     $gridview .= $this->setPaging();
     $arr_info_show_index = array(1 => 'Hiển thị trang chủ', 0 => 'Không hiển thị trang chủ');
     $Attr_show_index = array('rel1' => '{Require:\'R\',Alert:\'Vui lòng chọn trạng thái \'}', 'style' => '');
     $txt_show_index = addSelectList2('show_index', $arr_info_show_index, '-- Trang chủ --', $Attr_show_index, $list_form, $show_index);
     $arr_info_category_id = $this->getListPostCategories();
     $Attr_category_id = array('rel1' => '{Require:\'R\',Alert:\'Vui lòng chọn danh mục \'}', 'style' => 'width:400px;');
     $txt_category_id = addSelectList2('category_id', $arr_info_category_id, '-- Danh mục --', $Attr_category_id, $list_form, $category_id);
     $arr_info_status = array(1 => 'Active', 0 => 'InActive');
     $Attr_status = array('rel1' => '{Require:\'R\',Alert:\'Vui lòng chọn trạng thái \'}', 'style' => '');
     $txt_status = addSelectList2('status', $arr_info_status, '-- Trạng thái --', $Attr_status, $list_form, $status);
     if ($mode_inpvl === 'EXPORT' && $this->acl_per(16)) {
         $this->ExportToExcel(fnStrConvert($_Title), strip_tags($exportGrid, '<table><tr><td><th>'));
         die;
     }
     //-----------------------------------------//
     setMessage($list_form, $_msg);
     $list_form->assign('title', $_Title);
     $list_form->assign('_error_', $error);
     $list_form->assign('gridview', $gridview);
     $list_form->parse('main');
     $this->html = $list_form->out_return('main');
     echo $this->html;
 }
 /**
  * handle ConfirmEdit captcha, only for CreatePage, which will be treated a bit differently (edits in special page)
  * this function is based on Bartek's solution for CreateAPage done in t:r6990 [RT#21902] - Marooned
  * @param SimpleCaptcha $captcha
  * @param $editPage
  * @param $newtext
  * @param $section
  * @param $merged
  * @param $result
  * @return bool
  */
 public function wfCreatePageOnConfirmEdit(&$captcha, &$editPage, $newtext, $section, $merged, &$result)
 {
     global $wgTitle;
     $canonspname = array_shift(SpecialPageFactory::resolveAlias($wgTitle->getDBkey()));
     if ($canonspname != 'CreatePage') {
         return true;
     }
     if ($captcha->shouldCheck($editPage, $newtext, $section, $merged)) {
         if ($captcha->passCaptcha()) {
             $result = true;
             return false;
         } else {
             global $wgHooks, $wgCreatePageCaptchaTriggered;
             $wgCreatePageCaptchaTriggered = true;
             $wgHooks['EditPage::showEditForm:beforeToolbar'][] = array($this, 'renderFormHeaderWrapper');
             $result = false;
             return true;
         }
     } else {
         return true;
     }
 }
示例#23
0
function cn_modify_comm_captcha($e)
{
    $ID = 'cn_comm_captcha_' . $e['id'];
    $cpath = getoption('http_script_dir') . '/captcha.php';
    if (getoption('hide_captcha') && function_exists('imagecreatetruecolor')) {
        // Create obfuscated captcha
        $captcha = new SimpleCaptcha();
        $captcha->imageFormat = 'png';
        $captcha->session_var = 'CSW';
        $captcha->scale = 2;
        $captcha->blur = true;
        $captcha->resourcesPath = SERVDIR . '/core/captcha/resources';
        // Image generation
        ob_start();
        $captcha->CreateImage(true);
        $captcha_text = ob_get_clean();
        $echo = '<div class="cn_comm_captcha"><img src="data:image/png;base64,' . base64_encode($captcha_text) . '" /></div>';
    } else {
        $echo = '<div class="cn_comm_captcha"><a href="#" onclick="cn_get_id(\'' . $ID . '\').src = \'' . $cpath . '?r=\' + Math.random(); return false;"><img src="' . $cpath . '" alt="CAPTCHA, click to refresh" id="' . $ID . '"/></a>';
    }
    $echo .= '<div class="cn_comm_cinput"><input type="text" name="cm_captcha" value=""/></div>';
    return $echo;
}
示例#24
0
 /**
  * Delete a solved captcha image, if $wgCaptchaDeleteOnSolve is true.
  */
 function passCaptcha()
 {
     global $wgCaptchaDeleteOnSolve;
     $info = $this->retrieveCaptcha();
     // get the captcha info before it gets deleted
     $pass = parent::passCaptcha();
     if ($pass && $wgCaptchaDeleteOnSolve) {
         $filename = $this->imagePath($info['salt'], $info['hash']);
         if (file_exists($filename)) {
             unlink($filename);
         }
     }
     return $pass;
 }
        if (isset($_SESSION['simpleCaptchaAnswer'])) {
            $this->answer = $_SESSION['simpleCaptchaAnswer'];
        }
    }
    // Static helper methods
    public static function getProtocol()
    {
        $protocol = "HTTP/1.1";
        if (isset($_SERVER['SERVER_PROTOCOL'])) {
            $protocol = $_SERVER['SERVER_PROTOCOL'];
        }
        return $protocol;
    }
}
// ------------------- Handle Incoming Requests ------------------- //
$sc = new SimpleCaptcha();
try {
    if (isset($_REQUEST['hash'])) {
        // Just getting one image file by it's hash
        $sc->getImageByHash($_REQUEST['hash']);
    } else {
        // Getting all image data and hashes
        $sc->resetSessionData();
        $imageData = $sc->getAllImageData();
        // Finish up by writing data to the session and the ouput buffer
        $sc->writeSessionData();
        header("Content-Type: application/json");
        echo json_encode($imageData);
    }
} catch (InvalidArgumentException $iae) {
    $code = $iae->getCode();
 /**
  * Delete a solved captcha image, if $wgCaptchaDeleteOnSolve is true.
  */
 function passCaptcha()
 {
     global $wgCaptchaDeleteOnSolve;
     $info = $this->retrieveCaptcha();
     // get the captcha info before it gets deleted
     $pass = parent::passCaptcha();
     if ($pass && $wgCaptchaDeleteOnSolve) {
         $this->getBackend()->quickDelete(array('src' => $this->imagePath($info['salt'], $info['hash'])));
     }
     return $pass;
 }
 /**
  * Validates captcha calculation 
  * 
  * flood protection by false fields and math code
  * TODO: build in floodProtection (max Trials etc)
  * TODO: SESSION based one as alternative
  *
  * @param array $data
  * @return bool 
  */
 protected function _validateCaptcha($data)
 {
     if (!isset($data['captcha'])) {
         # form inputs missing? SPAM!
         return $this->error('Captcha content missing');
     }
     $captcha_params = array('timestamp' => $data['captcha_time'], 'result' => $data['captcha']);
     $hash = SimpleCaptcha::buildHash($captcha_params, $this->settings[$this->Model->alias]);
     if ($data['captcha_hash'] == $hash) {
         return true;
     }
     # wrong captcha content or session expired
     return $this->error('Captcha incorrect', 'SubmittedResult = \'' . $data['captcha'] . '\'');
 }
示例#28
0
<?php

/**
 * Script para la generación de CAPTCHAS
 *
 * @author  Jose Rodriguez <*****@*****.**>
 * @license GPLv3
 * @link    http://code.google.com/p/cool-php-captcha
 * @package captcha
 * @version 0.3
 *
 */
session_start();
$captcha = new SimpleCaptcha();
// OPTIONAL Change configuration...
//$captcha->wordsFile = 'words/es.php';
//$captcha->session_var = 'secretword';
//$captcha->imageFormat = 'png';
//$captcha->lineWidth = 3;
//$captcha->scale = 3; $captcha->blur = true;
$captcha->resourcesPath = dirname(__FILE__) . "/resources";
$captcha->colors = array(array(0, 138, 201));
// OPTIONAL Simple autodetect language example
/*
if (!empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
    $langs = array('en', 'es');
    $lang  = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
    if (in_array($lang, $langs)) {
        $captcha->wordsFile = "words/$lang.php";
    }
}
示例#29
0
<?php

session_start();
date_default_timezone_set('UTC');
$width = !empty($_GET['width']) && $_GET['width'] <= 1000 && $_GET['width'] > 0 ? $_GET['width'] : 300;
$height = !empty($_GET['height']) && $_GET['height'] <= 1000 && $_GET['height'] > 0 ? $_GET['height'] : 80;
$captcha = new SimpleCaptcha($width, $height);
$captcha->output();
class SimpleCaptcha
{
    private $image;
    private $width;
    private $height;
    private $chars_count = 5;
    private $chars_set = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ12345689';
    private $colors = array('880000', '008800', '000088', '888800', '880088', '008888', '000000');
    private $lines_count = 8;
    private $bg_color = 'ffffff';
    private $session_key = 'simple_captcha';
    public function __construct($width, $height)
    {
        $this->width = intval($width);
        $this->height = intval($height);
    }
    public function output()
    {
        $this->initImage();
        $this->drawPoints();
        $this->drawLines();
        $text = $this->drawText();
        $this->setSession($text);