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: main.php - Stikked
From Skaja, 12 Years ago, written in PHP.
This paste is a reply to main.php from Claude - view diff
Embed
  1. TEST THIS SERVICE
  2.  
  3. <?php
  4. /**
  5.  * Class and Function List:
  6.  * Function list:
  7.  * - __construct()
  8.  * - _form_prep()
  9.  * - index()
  10.  * - raw()
  11.  * - download()
  12.  * - lists()
  13.  * - view()
  14.  * - _view_options_prep()
  15.  * - view_options()
  16.  * - cron()
  17.  * - about()
  18.  * - _valid_lang()
  19.  * Classes list:
  20.  * - Main extends CI_Controller
  21.  */
  22.  
  23. class Main extends CI_Controller
  24. {
  25.        
  26.         function __construct()
  27.         {
  28.                 parent::__construct();
  29.                 $this->load->model('languages');
  30.                
  31.                 if (!$this->db->table_exists('ci_sessions'))
  32.                 {
  33.                         $this->load->dbforge();
  34.                         $fields = array(
  35.                                 'session_id' => array(
  36.                                         'type' => 'VARCHAR',
  37.                                         'constraint' => 40,
  38.                                         'default' => 0,
  39.                                 ) ,
  40.                                 'ip_address' => array(
  41.                                         'type' => 'VARCHAR',
  42.                                         'constraint' => 16,
  43.                                         'default' => 0,
  44.                                 ) ,
  45.                                 'user_agent' => array(
  46.                                         'type' => 'VARCHAR',
  47.                                         'constraint' => 50,
  48.                                 ) ,
  49.                                 'last_activity' => array(
  50.                                         'type' => 'INT',
  51.                                         'constraint' => 10,
  52.                                         'unsigned' => TRUE,
  53.                                         'default' => 0,
  54.                                 ) ,
  55.                                 'session_data' => array(
  56.                                         'type' => 'TEXT',
  57.                                 ) ,
  58.                         );
  59.                         $this->dbforge->add_field($fields);
  60.                         $this->dbforge->add_key('session_id', true);
  61.                         $this->dbforge->create_table('ci_sessions', true);
  62.                 }
  63.                
  64.                 if (!$this->db->table_exists('pastes'))
  65.                 {
  66.                         $this->load->dbforge();
  67.                         $fields = array(
  68.                                 'id' => array(
  69.                                         'type' => 'INT',
  70.                                         'constraint' => 10,
  71.                                         'auto_increment' => TRUE,
  72.                                 ) ,
  73.                                 'pid' => array(
  74.                                         'type' => 'VARCHAR',
  75.                                         'constraint' => 8,
  76.                                 ) ,
  77.                                 'title' => array(
  78.                                         'type' => 'VARCHAR',
  79.                                         'constraint' => 32,
  80.                                 ) ,
  81.                                 'name' => array(
  82.                                         'type' => 'VARCHAR',
  83.                                         'constraint' => 32,
  84.                                 ) ,
  85.                                 'lang' => array(
  86.                                         'type' => 'VARCHAR',
  87.                                         'constraint' => 32,
  88.                                 ) ,
  89.                                 'private' => array(
  90.                                         'type' => 'TINYINT',
  91.                                         'constraint' => 1,
  92.                                 ) ,
  93.                                 'paste' => array(
  94.                                         'type' => 'LONGTEXT',
  95.                                 ) ,
  96.                                 'raw' => array(
  97.                                         'type' => 'LONGTEXT',
  98.                                 ) ,
  99.                                 'created' => array(
  100.                                         'type' => 'INT',
  101.                                         'constraint' => 10,
  102.                                 ) ,
  103.                                 'expire' => array(
  104.                                         'type' => 'INT',
  105.                                         'constraint' => 10,
  106.                                         'default' => 0,
  107.                                 ) ,
  108.                                 'toexpire' => array(
  109.                                         'type' => 'TINYINT',
  110.                                         'constraint' => 1,
  111.                                         'unsigned' => TRUE,
  112.                                 ) ,
  113.                                 'snipurl' => array(
  114.                                         'type' => 'VARCHAR',
  115.                                         'constraint' => 64,
  116.                                         'default' => 0,
  117.                                 ) ,
  118.                                 'replyto' => array(
  119.                                         'type' => 'VARCHAR',
  120.                                         'constraint' => 8,
  121.                                 ) ,
  122.                         );
  123.                         $this->dbforge->add_field($fields);
  124.                         $this->dbforge->add_key('id', true);
  125.                         $this->dbforge->create_table('pastes', true);
  126.                 }
  127.         }
  128.        
  129.         function _form_prep($lang = 'php', $title = '', $paste = '', $reply = false)
  130.         {
  131.                 $this->load->model('languages');
  132.                 $this->load->helper('form');
  133.                 $data['languages'] = $this->languages->get_languages();
  134.                
  135.                 if (!$this->input->post('submit'))
  136.                 {
  137.                        
  138.                         if ($this->db_session->flashdata('settings_changed'))
  139.                         {
  140.                                 $data['status_message'] = 'Settings successfully changed';
  141.                         }
  142.                         $data['name_set'] = $this->db_session->userdata('name');
  143.                         $data['expire_set'] = $this->db_session->userdata('expire');
  144.                         $data['acopy_set'] = $this->db_session->userdata('acopy');
  145.                         $data['private_set'] = $this->db_session->userdata('private');
  146.                         $data['snipurl_set'] = $this->db_session->userdata('snipurl');
  147.                         $data['remember_set'] = $this->db_session->userdata('remember');
  148.                         $data['paste_set'] = $paste;
  149.                         $data['title_set'] = $title;
  150.                         $data['reply'] = $reply;
  151.                        
  152.                         if ($lang != 'php' or ($lang == 'php' and $this->db_session->userdata('lang') == false))
  153.                         {
  154.                                 $data['lang_set'] = $lang;
  155.                         }
  156.                         elseif ($this->db_session->userdata('lang'))
  157.                         {
  158.                                 $data['lang_set'] = $this->db_session->userdata('lang');
  159.                         }
  160.                 }
  161.                 else
  162.                 {
  163.                         $data['name_set'] = $this->input->post('name');
  164.                         $data['expire_set'] = $this->input->post('expire');
  165.                         $data['acopy_set'] = $this->input->post('acopy');
  166.                         $data['private_set'] = $this->input->post('private');
  167.                         $data['snipurl_set'] = $this->input->post('snipurl');
  168.                         $data['remember_set'] = $this->input->post('remember');
  169.                         $data['paste_set'] = $this->input->post('paste');
  170.                         $data['title_set'] = $this->input->post('title');
  171.                         $data['reply'] = $this->input->post('reply');
  172.                         $data['lang_set'] = $this->input->post('lang');
  173.                 }
  174.                 return $data;
  175.         }
  176.        
  177.         function index()
  178.         {
  179.                
  180.                 if (!$this->input->post('submit'))
  181.                 {
  182.                         $data = $this->_form_prep();
  183.                         $this->load->view('home', $data);
  184.                 }
  185.                 else
  186.                 {
  187.                         $this->load->model('pastes');
  188.                         $this->load->library('form_validation');
  189.  
  190.                         //rules
  191.                         $rules = array(
  192.                                 array(
  193.                                         'field' => 'code',
  194.                                         'label' => 'Main Paste',
  195.                                         'rules' => 'required',
  196.                                 ) ,
  197.                                 array(
  198.                                         'field' => 'lang',
  199.                                         'label' => 'Language',
  200.                                         'rules' => 'min_length[1]|required|callback__valid_lang',
  201.                                 ) ,
  202.                         );
  203.  
  204.                         //form validation
  205.                         $this->form_validation->set_rules($rules);
  206.                         $this->form_validation->set_message('min_length', 'The %s field can not be empty');
  207.                         $this->form_validation->set_error_delimiters('<div class="message error"><div class="container">', '</div></div>');
  208.                        
  209.                         if ($this->form_validation->run() == FALSE)
  210.                         {
  211.                                 $data = $this->_form_prep();
  212.                                 $this->load->view('home', $data);
  213.                         }
  214.                         else
  215.                         {
  216.                                
  217.                                 if ($this->input->post('acopy'))
  218.                                 {
  219.                                         $this->db_session->set_flashdata('acopy', 'true');
  220.                                 }
  221.                                
  222.                                 if ($this->input->post('remember') and $this->input->post('reply') == false)
  223.                                 {
  224.                                         $user_data = array(
  225.                                                 'name' => $this->input->post('name') ,
  226.                                                 'lang' => $this->input->post('lang') ,
  227.                                                 'expire' => $this->input->post('expire') ,
  228.                                                 'acopy' => $this->input->post('acopy') ,
  229.                                                 'snipurl' => $this->input->post('snipurl') ,
  230.                                                 'private' => $this->input->post('private') ,
  231.                                                 'remember' => $this->input->post('remember')
  232.                                         );
  233.                                         $this->db_session->set_userdata($user_data);
  234.                                 }
  235.                                
  236.                                 if ($this->input->post('remember') == false and $this->db_session->userdata("remember") == 1)
  237.                                 {
  238.                                         $user_data = array(
  239.                                                 'name' => '',
  240.                                                 'lang' => 'php',
  241.                                                 'expire' => '0',
  242.                                                 'acopy' => '0',
  243.                                                 'snipurl' => '0',
  244.                                                 'private' => '0',
  245.                                                 'remember' => '0'
  246.                                         );
  247.                                         $this->db_session->unset_userdata($user_data);
  248.                                 }
  249.                                 redirect($this->pastes->createPaste());
  250.                         }
  251.                 }
  252.         }
  253.        
  254.         function raw()
  255.         {
  256.                 $this->load->model('pastes');
  257.                 $check = $this->pastes->checkPaste(3);
  258.                
  259.                 if ($check)
  260.                 {
  261.                         $data = $this->pastes->getPaste(3);
  262.                         $this->load->view('view/raw', $data);
  263.                 }
  264.                 else
  265.                 {
  266.                         show_404();
  267.                 }
  268.         }
  269.        
  270.         function download()
  271.         {
  272.                 $this->load->model('pastes');
  273.                 $check = $this->pastes->checkPaste(3);
  274.                
  275.                 if ($check)
  276.                 {
  277.                         $data = $this->pastes->getPaste(3);
  278.                         $this->load->view('view/download', $data);
  279.                 }
  280.                 else
  281.                 {
  282.                         show_404();
  283.                 }
  284.         }
  285.        
  286.         function lists()
  287.         {
  288.                 $this->load->model('pastes');
  289.                 $data = $this->pastes->getLists();
  290.                 $this->load->view('list', $data);
  291.         }
  292.        
  293.         function view()
  294.         {
  295.                 $this->load->model('pastes');
  296.                 $check = $this->pastes->checkPaste(2);
  297.                
  298.                 if ($check)
  299.                 {
  300.                        
  301.                         if ($this->db_session->userdata('view_raw'))
  302.                         {
  303.                                 $this->db_session->keep_flashdata('acopy');
  304.                                 redirect('view/raw/' . $this->uri->segment(2));
  305.                         }
  306.                         $data = $this->pastes->getPaste(2, true);
  307.                         $data['reply_form'] = $this->_form_prep($data['lang_code'], "RE: " . $data['title'], $data['raw'], $data['pid']);
  308.                        
  309.                         if ($this->db_session->userdata('full_width'))
  310.                         {
  311.                                 $data['full_width'] = true;
  312.                         }
  313.                         else
  314.                         {
  315.                                 $data['full_width'] = false;
  316.                         }
  317.                         $this->load->view('view/view', $data);
  318.                 }
  319.                 else
  320.                 {
  321.                         show_404();
  322.                 }
  323.         }
  324.        
  325.         function _view_options_prep()
  326.         {
  327.                 $this->load->helper('form');
  328.                
  329.                 if ($this->db_session->userdata('remember_view') > 0)
  330.                 {
  331.                         $data['full_width_set'] = $this->db_session->userdata('full_width');
  332.                         $data['view_raw_set'] = $this->db_session->userdata('view_raw');
  333.                 }
  334.                 else
  335.                 {
  336.                         $data['full_width_set'] = false;
  337.                         $data['view_raw_set'] = false;
  338.                 }
  339.                 return $data;
  340.         }
  341.        
  342.         function view_options()
  343.         {
  344.                
  345.                 if (!$this->input->post('submit'))
  346.                 {
  347.                         $data = $this->_view_options_prep();
  348.                         $this->load->view('view/view_options', $data);
  349.                 }
  350.                 else
  351.                 {
  352.                         $this->load->library('form_validation');
  353.                         $rules = array(
  354.                                 array(
  355.                                         'field' => 'full_width',
  356.                                         'label' => 'full_width',
  357.                                         'rules' => 'max_length[1]',
  358.                                 ) ,
  359.                                 array(
  360.                                         'field' => 'view_raw',
  361.                                         'label' => 'view_raw',
  362.                                         'rules' => 'max_length[1]',
  363.                                 ) ,
  364.                         );
  365.                         $this->form_validation->set_rules($rules);
  366.                        
  367.                         if ($this->form_validation->run() == false)
  368.                         {
  369.                                 exit('Ugh, stupid skiddie.');
  370.                         }
  371.                         else
  372.                         {
  373.                                 $user_data = array(
  374.                                         'full_width' => $this->input->post('full_width') ,
  375.                                         'view_raw' => $this->input->post('view_raw') ,
  376.                                         'remember_view' => true
  377.                                 );
  378.                                 $this->db_session->set_userdata($user_data);
  379.                                 $this->db_session->set_flashdata('settings_changed', 'true');
  380.                                 redirect();
  381.                         }
  382.                 }
  383.         }
  384.        
  385.         function cron()
  386.         {
  387.                 $this->load->model('pastes');
  388.                 $key = $this->uri->segment(2);
  389.                
  390.                 if ($key != $this->config->item('cron_key'))
  391.                 {
  392.                         show_404();
  393.                 }
  394.                 else
  395.                 {
  396.                         $this->pastes->cron();
  397.                         return 0;
  398.                 }
  399.         }
  400.        
  401.         function about()
  402.         {
  403.                 $this->load->view('about');
  404.         }
  405.        
  406.         function _valid_lang($lang)
  407.         {
  408.                 $this->load->model('languages');
  409.                 $this->form_validation->set_message('_valid_lang', 'Please select your language');
  410.                 return $this->languages->valid_language($lang);
  411.         }
  412. }
  413.