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

dict.cc.py - Stikked
From raaapha, 12 Years ago, written in Python.
Embed
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3.  
  4. import urllib2, urllib
  5. import re
  6. import sys
  7.  
  8. # Edit here for default number of results
  9. MAX_RESULTS = 20
  10.  
  11. class Dict:
  12.         def __init__(self):
  13.                 self.Eng = []
  14.                 self.De = []
  15.  
  16.         def getResponse(self, word):
  17.                 # Trick to avoid dict.cc from denying the request: change User-agent to firefox's
  18.                 req = urllib2.Request("http://www.dict.cc/?s="+word, None, {'User-agent': 'Mozilla/5.0'})
  19.                 f = urllib2.urlopen(req)
  20.                 self.Response = f.read()
  21.        
  22.         # Find 'var c1Arr' and 'var c2Arr'
  23.         def parseResponse(self):
  24.                
  25.                 self.engWords = []
  26.                 self.deWords = []
  27.  
  28.                 engLine = deLine = ""
  29.  
  30.                 # Split lines
  31.                 lines = self.Response.split("\n")
  32.  
  33.                 for l in lines:
  34.                         if l.find("var c1Arr") >= 0:
  35.                                 engLine =  l
  36.                         elif l.find("var c2Arr") >= 0:
  37.                                 deLine = l
  38.  
  39.                 if not engLine or not deLine:
  40.                         return False
  41.  
  42.                 else:
  43.                         # Regex
  44.                         # pattern = "\"[A-Za-z \.()\-\?ßäöüÄÖÜéáíçÇâêî\']*\""
  45.                         pattern = "\"[^,]+\""
  46.  
  47.                         # Return list of matching strings
  48.                         self.engWords = re.findall(pattern, engLine)
  49.                         self.deWords = re.findall(pattern, deLine)
  50.  
  51.         def printResults(self):
  52.                 if not self.engWords or not self.deWords:
  53.                         print "No results."
  54.  
  55.                 else:
  56.                         # Get minumum number of both eng and de
  57.                         minWords = len(self.engWords) if len(self.engWords) <= len(self.deWords) else len(self.deWords)
  58.  
  59.                         # Is it more than MAX_RESULTS?
  60.                         minWords = minWords if minWords <= MAX_RESULTS else MAX_RESULTS
  61.  
  62.                         # Find biggest word in first col
  63.                         length = 0
  64.                         for w in self.engWords[:minWords]:
  65.                                 length = length if length > len(w) else len(w)
  66.  
  67.                        
  68.                         # Nice output
  69.                         print "English" + " "*(length - len("English") + 15) + "Deutsch"
  70.                         print "=======" + " "*(length - len("English") + 15) + "=======\n"
  71.                         for i in range(0,minWords):
  72.                                 if self.engWords[i] == "\"\"": continue
  73.                                 print self.engWords[i].strip("\"") + "."*(length - len(self.engWords[i].strip("\"")) + 15) + self.deWords[i].strip("\"")
  74.  
  75.  
  76. if __name__ == "__main__":
  77.  
  78.         print "dict.cc.py:\n"
  79.  
  80.         if len(sys.argv) < 2:
  81.                 print "USAGE:\n$ dict.cc.py \"word\" (without the \"s)"
  82.         else:
  83.                 # Concat all arguments into one word (urlencoded space)
  84.                 expression = ""
  85.                 for index in range(1, len(sys.argv)):
  86.                         expression += sys.argv[index] + " "
  87.  
  88.                 print "Interpreted input: " + expression + "\n"
  89.                
  90.                 # Urlencode input
  91.                 expression = urllib.quote(expression)
  92.  
  93.                 myDict = Dict()
  94.                 myDict.getResponse(expression)
  95.                 myDict.parseResponse()
  96.                 myDict.printResults()