[ Index ]

PHP Cross Reference of phpBB-3.1.12-deutsch

title

Body

[close]

/phpbb/captcha/plugins/ -> gd.php (source)

   1  <?php
   2  /**
   3  *
   4  * This file is part of the phpBB Forum Software package.
   5  *
   6  * @copyright (c) phpBB Limited <https://www.phpbb.com>
   7  * @license GNU General Public License, version 2 (GPL-2.0)
   8  *
   9  * For full copyright and license information, please see
  10  * the docs/CREDITS.txt file.
  11  *
  12  */
  13  
  14  namespace phpbb\captcha\plugins;
  15  
  16  class gd extends captcha_abstract
  17  {
  18      var $captcha_vars = array(
  19          'captcha_gd_x_grid'                => 'CAPTCHA_GD_X_GRID',
  20          'captcha_gd_y_grid'                => 'CAPTCHA_GD_Y_GRID',
  21          'captcha_gd_foreground_noise'    => 'CAPTCHA_GD_FOREGROUND_NOISE',
  22  //        'captcha_gd'                    => 'CAPTCHA_GD_PREVIEWED',
  23          'captcha_gd_wave'                => 'CAPTCHA_GD_WAVE',
  24          'captcha_gd_3d_noise'            => 'CAPTCHA_GD_3D_NOISE',
  25          'captcha_gd_fonts'                => 'CAPTCHA_GD_FONTS',
  26      );
  27  
  28  	public function is_available()
  29      {
  30          return @extension_loaded('gd');
  31      }
  32  
  33      /**
  34      * @return string the name of the class used to generate the captcha
  35      */
  36  	function get_generator_class()
  37      {
  38          return '\\phpbb\\captcha\\gd';
  39      }
  40  
  41      /**
  42      *  API function
  43      */
  44  	function has_config()
  45      {
  46          return true;
  47      }
  48  
  49  	public function get_name()
  50      {
  51          return 'CAPTCHA_GD';
  52      }
  53  
  54  	function acp_page($id, &$module)
  55      {
  56          global $db, $user, $auth, $template;
  57          global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
  58  
  59          $user->add_lang('acp/board');
  60  
  61          $config_vars = array(
  62              'enable_confirm'        => 'REG_ENABLE',
  63              'enable_post_confirm'    => 'POST_ENABLE',
  64              'confirm_refresh'        => 'CONFIRM_REFRESH',
  65              'captcha_gd'            => 'CAPTCHA_GD',
  66          );
  67  
  68          $module->tpl_name = 'captcha_gd_acp';
  69          $module->page_title = 'ACP_VC_SETTINGS';
  70          $form_key = 'acp_captcha';
  71          add_form_key($form_key);
  72  
  73          $submit = request_var('submit', '');
  74  
  75          if ($submit && check_form_key($form_key))
  76          {
  77              $captcha_vars = array_keys($this->captcha_vars);
  78              foreach ($captcha_vars as $captcha_var)
  79              {
  80                  $value = request_var($captcha_var, 0);
  81                  if ($value >= 0)
  82                  {
  83                      set_config($captcha_var, $value);
  84                  }
  85              }
  86  
  87              add_log('admin', 'LOG_CONFIG_VISUAL');
  88              trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($module->u_action));
  89          }
  90          else if ($submit)
  91          {
  92              trigger_error($user->lang['FORM_INVALID'] . adm_back_link($module->u_action));
  93          }
  94          else
  95          {
  96              foreach ($this->captcha_vars as $captcha_var => $template_var)
  97              {
  98                  $var = (isset($_REQUEST[$captcha_var])) ? request_var($captcha_var, 0) : $config[$captcha_var];
  99                  $template->assign_var($template_var, $var);
 100              }
 101  
 102              $template->assign_vars(array(
 103                  'CAPTCHA_PREVIEW'    => $this->get_demo_template($id),
 104                  'CAPTCHA_NAME'        => $this->get_service_name(),
 105                  'U_ACTION'            => $module->u_action,
 106              ));
 107          }
 108      }
 109  
 110  	function execute_demo()
 111      {
 112          global $config;
 113  
 114          $config_old = $config;
 115  
 116          $config = new \phpbb\config\config(array());
 117          foreach ($config_old as $key => $value)
 118          {
 119              $config->set($key, $value);
 120          }
 121  
 122          foreach ($this->captcha_vars as $captcha_var => $template_var)
 123          {
 124              $config->set($captcha_var, request_var($captcha_var, (int) $config[$captcha_var]));
 125          }
 126          parent::execute_demo();
 127          $config = $config_old;
 128      }
 129  
 130  }


Generated: Thu Jan 11 00:25:41 2018 Cross-referenced by PHPXref 0.7.1