A PHP Error was encountered

Severity: 8192

Message: Function create_function() is deprecated

Filename: geshi/geshi.php

Line Number: 4698

Backtrace:

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 4698
Function: _error_handler

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 4621
Function: _optimize_regexp_list_tokens_to_string

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 1655
Function: optimize_regexp_list

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 2029
Function: optimize_keyword_group

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 2168
Function: build_parse_cache

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/Process.php
Line: 45
Function: parse_code

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/models/Pastes.php
Line: 517
Function: syntax

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/controllers/Main.php
Line: 693
Function: getPaste

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/index.php
Line: 315
Function: require_once

Re: Untitled - Stikked
From Reliable Pig, 12 Years ago, written in PHP.
This paste is a reply to Untitled from Denim Eider - view diff
Embed
  1. <?php
  2. /***************************************************************
  3. *  Copyright notice
  4. *
  5. *  (c) 2008 Alex Kellner <alexander.kellner@einpraegsam.net>
  6. *  All rights reserved
  7. *
  8. *  This script is part of the TYPO3 project. The TYPO3 project is
  9. *  free software; you can redistribute it and/or modify
  10. *  it under the terms of the GNU General Public License as published by
  11. *  the Free Software Foundation; either version 2 of the License, or
  12. *  (at your option) any later version.
  13. *
  14. *  The GNU General Public License can be found at
  15. *  http://www.gnu.org/copyleft/gpl.html.
  16. *
  17. *  This script is distributed in the hope that it will be useful,
  18. *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20. *  GNU General Public License for more details.
  21. *
  22. *  This copyright notice MUST APPEAR in all copies of the script!
  23. ***************************************************************/
  24.  
  25. class tx_wtcalculatingcaptcha {
  26.  
  27.         public $extKey = 'wt_calculating_captcha'; // Extension Key
  28.         public $captchaimage = 'EXT:wt_calculating_captcha/captcha.png'; // Path to captcha image
  29.        
  30.         private $configuration = array();
  31.         private $img = '';
  32.         private $number1 = '';
  33.         private $number2 = '';
  34.         private $subfolder = '';
  35.        
  36.        
  37.         /**
  38.          * Function generateCaptcha() generate a new captcha image and save the result to the session
  39.          *
  40.          * @return      string          HTML code for captcha image
  41.          */
  42.         function generateCaptcha() {
  43.                 // config
  44.                 $this->conf = $GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_wtcalculatingcaptcha.']; // Typoscript configuration
  45.                 $this->subfolder = '';
  46.                 if (t3lib_div::getIndpEnv('TYPO3_REQUEST_HOST') . '/' != t3lib_div::getIndpEnv('TYPO3_SITE_URL')) { // if request_host is different to site_url (TYPO3 runs in a subfolder)
  47.                     $this->subfolder = str_replace(t3lib_div::getIndpEnv('TYPO3_REQUEST_HOST') . '/', '', t3lib_div::getIndpEnv('TYPO3_SITE_URL')); // get the folder (like "subfolder/")
  48.                 }
  49.                 $this->startimage = t3lib_div::getIndpEnv('TYPO3_DOCUMENT_ROOT') . '/' . $this->subfolder . $GLOBALS['TSFE']->tmpl->getFileName($this->conf['background.']['image']); // background image
  50.                 if ($this->conf['debug']) t3lib_div::debug($this->conf, $this->extKey . ': Typoscript configuration'); // debug output
  51.                
  52.                 // 1. Get random numbers
  53.                 $this->no1 = t3lib_div::trimExplode(',', $this->conf['number1.']['minmax'], 1); // give me the min and the max of number 1
  54.                 $this->no2 = t3lib_div::trimExplode(',', $this->conf['number2.']['minmax'], 1); // give me the min and the max of number 2
  55.                 $op = mt_rand(0, $this->conf['operation.']['number']); // operator (should be 0 or 1 or 2 or 3)
  56.                
  57.                 for ($i=0; $i<100; $i++) { // loop max. 100 times
  58.                         $this->number1 = mt_rand($this->no1[0], $this->no1[1]); // random number 1
  59.                         $this->number2 = mt_rand($this->no2[0], $this->no2[1]); // random number 2
  60.                         if ($op != 1 || $this->number1 > $this->number2 || $this->conf['number.']['notNegative'] != 1) break; // stop loop IF operator is not "-" OR if first is greater than second number OR if plugin don't care about negative numbers (function to disable negative numbers)
  61.                 }
  62.                 switch ($op) { // give me the operator
  63.                         case 0:
  64.                                 $this->operator = '+'; // operator
  65.                                 $this->result = $this->number1 + $this->number2; // result
  66.                                 break;
  67.                         case 1:
  68.                                 $this->operator = '-';
  69.                                 $this->result = $this->number1 - $this->number2; // result
  70.                                 break;
  71.                         case 2:
  72.                                 $this->operator = 'x';
  73.                                 $this->result = $this->number1 * $this->number2; // result
  74.                                 break;
  75.                         case 3:
  76.                                 $this->operator = ':';
  77.                                 $this->result = $this->number1 / $this->number2; // result
  78.                                 break;
  79.                 }
  80.                 $this->content = $this->number1 . ' ' . $this->operator . ' ' . $this->number2;
  81.                
  82.                 // 2. Save result to session
  83.                 $GLOBALS['TSFE']->fe_user->setKey('ses', $this->extKey . '_value', $this->result); // Generate Session with result
  84.                 $GLOBALS['TSFE']->storeSessionData(); // Save session
  85.                        
  86.                 // 3. generate captcha
  87.                 if (is_file($this->startimage)) { // if file is correct
  88.                        
  89.                         $this->configuration['color_rgb'] = sscanf($this->conf['font.']['color'], '#%2x%2x%2x'); // change HEX color to RGB
  90.                         $this->img = ImageCreateFromPNG($this->startimage); // Backgroundimage
  91.                         $this->configuration['color'] = ImageColorAllocate($this->img, $this->configuration['color_rgb'][0], $this->configuration['color_rgb'][1], $this->configuration['color_rgb'][2]); // Font color
  92.                         $this->configuration['font'] = t3lib_div::getIndpEnv('TYPO3_DOCUMENT_ROOT') . '/' . $this->subfolder . $GLOBALS['TSFE']->tmpl->getFileName($this->conf['font.']['path']); // fontfile
  93.                         $this->configuration['fontsize'] = $this->conf['font.']['size']; // Fontsize
  94.                         $this->configuration['angle'] = t3lib_div::trimExplode(',', $this->conf['font.']['angle'], 1); // give me the angles for the font
  95.                         $this->configuration['fontangle'] = mt_rand($this->configuration['angle'][0], $this->configuration['angle'][1]); // random angle
  96.                         $this->configuration['distance_hor'] = t3lib_div::trimExplode(',', $this->conf['font.']['distance_hor'], 1); // give me the horizontal distances
  97.                         $this->configuration['fontdistance_hor'] = mt_rand($this->configuration['distance_hor'][0], $this->configuration['distance_hor'][1]); // random distance
  98.                         $this->configuration['distance_vert'] = t3lib_div::trimExplode(',', $this->conf['font.']['distance_vert'], 1); // give me the vertical distances
  99.                         $this->configuration['fontdistance_vert'] = mt_rand($this->configuration['distance_vert'][0], $this->configuration['distance_vert'][1]); // random distance
  100.                         if ($this->conf['debug']) t3lib_div::debug($this->configuration, $this->extKey . ': Image configuration'); // debug output
  101.                         imagettftext($this->img, $this->configuration['fontsize'], $this->configuration['fontangle'], $this->configuration['fontdistance_hor'], $this->configuration['fontdistance_vert'], $this->configuration['color'], $this->configuration['font'], $this->content); // add text to image
  102.                         imagepng($this->img, t3lib_div::getIndpEnv('TYPO3_DOCUMENT_ROOT') . '/' . $this->subfolder . $GLOBALS['TSFE']->tmpl->getFileName($this->captchaimage)); // save image file
  103.                         imagedestroy($this->img); // delete temp image
  104.                        
  105.                 // 4. return
  106.                         if ($this->conf['debug']) t3lib_div::debug($this->content, $this->extKey . ': Image content'); // debug output
  107.                         if ($this->conf['debug']) t3lib_div::debug($this->result, $this->extKey . ': Result'); // debug output
  108.                         return '<img src="' . $GLOBALS['TSFE']->tmpl->getFileName($this->captchaimage) . '?hash=' . time() . '" alt="captcha" class="wtcalculatingcaptcha" id="wtcalculatingcaptcha" />';
  109.                
  110.                 } else { // Path to the background image is wrong
  111.                        
  112.                         if (!$this->conf['debug']) return '<strong>wt_calculating_captcha ERROR:</strong> Please check the path to the background image file: "' . $GLOBALS['TSFE']->tmpl->getFileName($this->conf['background.']['image']) . '"';
  113.                         else return '<strong>wt_calculating_captcha ERROR:</strong> Path to image is wrong: ' . $this->startimage;
  114.                
  115.                 }
  116.         }
  117.        
  118.        
  119.         /**
  120.          * Function correctCode() returns true or false if the given code is right
  121.          *
  122.          * @param       string          $code: captcha code from input field
  123.          * @return      boolean         True/False for correct or incorrect code
  124.          */
  125.         function correctCode($code) {
  126.                 if (!empty($GLOBALS['TSFE']->fe_user->sesData[$this->extKey . '_value'])) { // if there is a value in session
  127.                         // config
  128.                         $this->conf = $GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_wtcalculatingcaptcha.']; // Typoscript configuration
  129.                        
  130.                         // let's go
  131.                         if (intval($code) == $GLOBALS['TSFE']->fe_user->sesData[$this->extKey . '_value'] && !empty($code)) { // if code is set and equal to session value
  132.                                 if ($this->conf['debug']) t3lib_div::debug('Yes, captcha code is correct!', $this->extKey . ': captcha code'); // debug output
  133.                                 return true; // correct code
  134.                         } else {
  135.                                 if ($this->conf['debug']) t3lib_div::debug('No, captcha code is NOT correct!', $this->extKey . ': captcha code'); // debug output
  136.                                 return false; // wrong code
  137.                         }
  138.                 } return false; // false per default
  139.         }
  140. }
  141.  
  142.  
  143. if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/wt_calculating_captcha/class.tx_wtcalculatingcaptcha.php'])    {
  144.         include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/wt_calculating_captcha/class.tx_wtcalculatingcaptcha.php']);
  145. }
  146.