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

dddddddd - Stikked
  1. <?php
  2.  
  3. /**
  4.  * @file BBCodeConverter.php
  5.  * @brief This file contains the BBCodeConverter class.
  6.  * @details
  7.  * @author Filippo F. Fadda
  8.  */
  9.  
  10.  
  11.  
  12. /**
  13.  * @brief A rudimental converter that takes as input a BBCode formatted text and converts it to Markdown.
  14.  */
  15. class BBCodeConverter extends Converter {
  16.  
  17.  
  18.   /**
  19.    * @brief Removes BBCode size.
  20.    */
  21.   protected function removeSize() {
  22.  
  23.     $this->text = preg_replace_callback('%\[size=\d*\]([\W\D\w\s]*?)\[/size\]%iu',
  24.  
  25.       function ($matches) {
  26.         return $matches[1];
  27.       },
  28.  
  29.       $this->text
  30.     );
  31.  
  32.   }
  33.  
  34.  
  35.   /**
  36.    * @brief Removes BBCode center.
  37.    */
  38.   protected function removeCenter() {
  39.  
  40.     $this->text = preg_replace_callback('%\[center\]([\W\D\w\s]*?)\[/center\]%iu',
  41.  
  42.       function ($matches) {
  43.         return $matches[1];
  44.       },
  45.  
  46.       $this->text
  47.     );
  48.  
  49.   }
  50.  
  51.  
  52.   /**
  53.    * @brief Replaces BBCode bold.
  54.    */
  55.   protected function replaceBold() {
  56.  
  57.     $this->text = preg_replace_callback('%\[b\]([\W\D\w\s]*?)\[/b\]%iu',
  58.  
  59.       function ($matches) {
  60.         return "**".trim($matches[1], " ")."**";
  61.       },
  62.  
  63.       $this->text
  64.     );
  65.  
  66.   }
  67.  
  68.  
  69.   /**
  70.    * @brief Replaces BBCode italic.
  71.    */
  72.   protected function replaceItalic() {
  73.  
  74.     $this->text = preg_replace_callback('%\[i\]([\W\D\w\s]*?)\[/i\]%iu',
  75.  
  76.       function ($matches) {
  77.         return "*".trim($matches[1], " ")."*";
  78.       },
  79.  
  80.       $this->text
  81.     );
  82.  
  83.   }
  84.  
  85.  
  86.   /**
  87.    * @brief Replaces BBCode underline. Hoedown support underline.
  88.    */
  89.   protected function replaceUnderline() {
  90.  
  91.     $this->text = preg_replace_callback('%\[u\]([\W\D\w\s]*?)\[/u\]%iu',
  92.  
  93.       function ($matches) {
  94.         return "_".trim($matches[1], " ")."_";
  95.       },
  96.  
  97.       $this->text
  98.     );
  99.    
  100.   }
  101.  
  102.  
  103.   /**
  104.    * @brief Replaces BBCode strikethrough.
  105.    */
  106.   protected function replaceStrikethrough() {
  107.  
  108.     $this->text = preg_replace_callback('%\[s\]([\W\D\w\s]*?)\[/s\]%iu',
  109.  
  110.       function ($matches) {
  111.         return "~~".trim($matches[1], " ")."~~";
  112.       },
  113.  
  114.       $this->text
  115.     );
  116.  
  117.   }
  118.  
  119.  
  120.   /**
  121.    * @brief Replaces BBCode lists.
  122.    */
  123.   protected function replaceLists() {
  124.  
  125.     $this->text = preg_replace_callback('%\[list(?P<type>=1)?\](?P<items>[\W\D\w\s]*?)\[/list\]%iu',
  126.  
  127.       function ($matches) {
  128.         $buffer = "";
  129.  
  130.         $list = preg_replace('/\s*$|^\s*/mu', '', $matches['items']);
  131.         if (is_null($list))
  132.           throw new \RuntimeException(sprintf("Text identified by '%d' has malformed BBCode lists", $this->id));
  133.  
  134.         $items = preg_split('/\[\*\]/u', $list);
  135.  
  136.         $counter = count($items);
  137.  
  138.         if (isset($matches['type']) && $matches['type'] == '=1') { // ordered list
  139.           // We start from 1 to discard the first string, in fact, it's empty.
  140.           for ($i = 1; $i < $counter; $i++)
  141.             if (!empty($items[$i]))
  142.               $buffer .= (string)($i).'. '.trim($items[$i]).PHP_EOL;
  143.         }
  144.         else { // unordered list
  145.           // We start from 1 to discard the first string, in fact, it's empty.
  146.           for ($i = 1; $i < $counter; $i++)
  147.             if (!empty($items[$i]))
  148.               $buffer .= '- '.trim($items[$i]).PHP_EOL;
  149.         }
  150.  
  151.         // We need a like break above the list and another one below.
  152.         if (!empty($buffer))
  153.           $buffer = PHP_EOL.$buffer.PHP_EOL;
  154.  
  155.         return $buffer;
  156.       },
  157.  
  158.       $this->text
  159.     );
  160.  
  161.   }
  162.  
  163.  
  164.   /**
  165.    * @brief Replaces BBCode urls.
  166.    */
  167.   protected function replaceUrls() {
  168.    
  169.     $this->text = preg_replace_callback('%\[url\s*=\s*("(?:[^"]*")|\A[^\']*\Z|(?:[^\'">\]\s]+))\s*(?:[^]\s]*)\]([\W\D\w\s]*?)\[/url\]%iu',
  170.  
  171.       function ($matches) {
  172.         if (isset($matches[1]) && isset($matches[2]))
  173.           return "[".$matches[2]."](".$matches[1].")";
  174.         else
  175.           throw new \RuntimeException(sprintf("Text identified by '%d' has malformed BBCode urls", $this->id));
  176.       },
  177.  
  178.       $this->text
  179.     );
  180.  
  181.   }
  182.  
  183.  
  184.   /**
  185.    * @brief Replaces BBCode images.
  186.    */
  187.   protected function replaceImages() {
  188.  
  189.     $this->text = preg_replace_callback('%\[img\s*\]\s*("(?:[^"]*")|\A[^\']*\Z|(?:[^\'">\]\s]+))\s*(?:[^]\s]*)\[/img\]%iu',
  190.  
  191.       function ($matches) {
  192.         if (isset($matches[1]))
  193.           return PHP_EOL."![]"."(".$matches[1].")".PHP_EOL;
  194.         else
  195.           throw new \RuntimeException(sprintf("Text identified by '%d' have malformed BBCode images", $this->id));
  196.       },
  197.  
  198.       $this->text
  199.     );
  200.  
  201.   }
  202.  
  203.  
  204.   /**
  205.    * @brief Replaces BBCode quotes.
  206.    * @details Thanks to Casimir et Hippolyte for helping me with this regex.
  207.    */
  208.   protected function replaceQuotes() {
  209.     // Removes the inner quotes, leaving just one level.
  210.     $this->text = preg_replace('~\G(?<!^)(?>(\[quote\b[^]]*](?>[^[]++|\[(?!/?quote)|(?1))*\[/quote])|(?<!\[)(?>[^[]++|\[(?!/?quote))+\K)|\[quote\b[^]]*]\K~', '', $this->text);
  211.  
  212.     // Replaces all the remaining quotes with '> ' characters.
  213.     $this->text = preg_replace_callback('%\[quote\b[^]]*\]((?>[^[]++|\[(?!/?quote))*)\[/quote\]%i',
  214.  
  215.       function($matches) {
  216.         $quote = preg_replace('/^\s*/mu', '', trim($matches[1]));
  217.         return "> ".$quote.PHP_EOL.PHP_EOL;
  218.       },
  219.  
  220.       $this->text
  221.     );
  222.   }
  223.  
  224.  
  225.   /**
  226.    * @brief Replaces BBCode snippets.
  227.    */
  228.   protected function replaceSnippets() {
  229.  
  230.     $this->text = preg_replace_callback('%\[code\s*=?(?P<language>\w*)\](?P<snippet>[\W\D\w\s]*?)\[\/code\]%iu',
  231.  
  232.       function ($matches) {
  233.         if (isset($matches['snippet'])) {
  234.           $language = strtolower($matches['language']);
  235.  
  236.           if ($language == 'html4strict' or $language == 'div')
  237.             $language = 'html';
  238.           elseif ($language == 'shell' or $language == 'dos' or $language == 'batch')
  239.             $language = 'sh';
  240.           elseif ($language == 'xul' or $language == 'wpf')
  241.             $language = 'xml';
  242.           elseif ($language == 'asm')
  243.             $language = 'nasm';
  244.           elseif ($language == 'vb' or $language == 'visualbasic' or $language == 'vba')
  245.             $language = 'vb.net';
  246.           elseif ($language == 'asp')
  247.             $language = 'aspx-vb';
  248.           elseif ($language == 'xaml')
  249.             $language = 'xml';
  250.           elseif ($language == 'cplusplus')
  251.             $language = 'cpp';
  252.           elseif ($language == 'txt' or $language == 'gettext')
  253.             $language = 'text';
  254.           elseif ($language == 'basic')
  255.             $language = 'cbmbas';
  256.           elseif ($language == 'lisp')
  257.             $language = 'clojure';
  258.           elseif ($language == 'aspnet')
  259.             $language = 'aspx-vb';
  260.  
  261.           return PHP_EOL."```".$language.PHP_EOL.trim($matches['snippet']).PHP_EOL."```".PHP_EOL;
  262.         }
  263.         else
  264.           throw new \RuntimeException(sprintf("Text identified by '%d' has malformed BBCode snippet.", $this->id));
  265.       },
  266.  
  267.       $this->text
  268.     );
  269.  
  270.   }
  271.  
  272.  
  273.   /**
  274.    * @brief Converts the provided BBCode text to an equivalent Markdown text.
  275.    */
  276.   public function toMarkdown() {
  277.     $this->removeCenter();
  278.     $this->removeSize();
  279.     $this->replaceBold();
  280.     $this->replaceItalic();
  281.     $this->replaceUnderline();
  282.     $this->replaceStrikethrough();
  283.     $this->replaceLists();
  284.     $this->replaceUrls();
  285.     $this->replaceImages();
  286.     $this->replaceQuotes();
  287.     $this->replaceSnippets();
  288.  
  289.     return $this->text;
  290.   }
  291.  
  292. }

Replies to dddddddd rss

Title Name Language When
Re: dddddddd aaa python 10 Years ago.