[ Index ]

PHP Cross Reference of phpBB-3.3.2-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 $user, $template, $phpbb_log, $request;
  57          global $config;
  58  
  59          $user->add_lang('acp/board');
  60  
  61          $module->tpl_name = 'captcha_gd_acp';
  62          $module->page_title = 'ACP_VC_SETTINGS';
  63          $form_key = 'acp_captcha';
  64          add_form_key($form_key);
  65  
  66          $submit = $request->variable('submit', '');
  67  
  68          if ($submit && check_form_key($form_key))
  69          {
  70              $captcha_vars = array_keys($this->captcha_vars);
  71              foreach ($captcha_vars as $captcha_var)
  72              {
  73                  $value = $request->variable($captcha_var, 0);
  74                  if ($value >= 0)
  75                  {
  76                      $config->set($captcha_var, $value);
  77                  }
  78              }
  79  
  80              $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_CONFIG_VISUAL');
  81              trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($module->u_action));
  82          }
  83          else if ($submit)
  84          {
  85              trigger_error($user->lang['FORM_INVALID'] . adm_back_link($module->u_action));
  86          }
  87          else
  88          {
  89              foreach ($this->captcha_vars as $captcha_var => $template_var)
  90              {
  91                  $var = (isset($_REQUEST[$captcha_var])) ? $request->variable($captcha_var, 0) : $config[$captcha_var];
  92                  $template->assign_var($template_var, $var);
  93              }
  94  
  95              $template->assign_vars(array(
  96                  'CAPTCHA_PREVIEW'    => $this->get_demo_template($id),
  97                  'CAPTCHA_NAME'        => $this->get_service_name(),
  98                  'U_ACTION'            => $module->u_action,
  99              ));
 100          }
 101      }
 102  
 103  	function execute_demo()
 104      {
 105          global $config, $request;
 106  
 107          $config_old = $config;
 108  
 109          $config = new \phpbb\config\config(array());
 110          foreach ($config_old as $key => $value)
 111          {
 112              $config->set($key, $value);
 113          }
 114  
 115          foreach ($this->captcha_vars as $captcha_var => $template_var)
 116          {
 117              $config->set($captcha_var, $request->variable($captcha_var, (int) $config[$captcha_var]));
 118          }
 119          parent::execute_demo();
 120          $config = $config_old;
 121      }
 122  
 123  }


Generated: Wed Nov 11 20:28:18 2020 Cross-referenced by PHPXref 0.7.1