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