diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..e43b0f9
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+.DS_Store
diff --git a/htdocs/application/config/stikked.php b/htdocs/application/config/stikked.php
new file mode 100755
index 0000000..6027471
--- /dev/null
+++ b/htdocs/application/config/stikked.php
@@ -0,0 +1,93 @@
+
\ No newline at end of file
diff --git a/htdocs/application/controllers/index.html b/htdocs/application/controllers/index.html
old mode 100644
new mode 100755
index c942a79..5a1f5d6
--- a/htdocs/application/controllers/index.html
+++ b/htdocs/application/controllers/index.html
@@ -1,10 +1,15 @@
-
-
- 403 Forbidden
-
-
-
-Directory access is forbidden.
-
-
+
+
+
+
+403 Forbidden
+
+
+
+
+
+Directory access is forbidden.
+
+
+
\ No newline at end of file
diff --git a/htdocs/application/controllers/iphone.php b/htdocs/application/controllers/iphone.php
new file mode 100755
index 0000000..08fdb7a
--- /dev/null
+++ b/htdocs/application/controllers/iphone.php
@@ -0,0 +1,69 @@
+
+* @copyright Ben McRedmond
+* @package Stikked
+*
+*/
+
+/**
+* iPhone controller class for stikked.
+*
+* @author Ben McRedmond
+* @version 0.5.1
+* @access public
+* @copyright Ben McRedmond
+* @package Stikked
+* @subpackage Controllers
+*
+*/
+
+class Iphone extends CI_Controller
+{
+
+ /**
+ * Class Constructor
+ *
+ * @return void
+ */
+
+ function __construct()
+ {
+ parent::__construct();
+ }
+
+
+ /**
+ * Displays recent pastes in an iPhone optimized version.
+ *
+ * @return void
+ * @access public
+ */
+
+ function index()
+ {
+ $this->load->model('pastes');
+ $data = $this->pastes->getLists('iphone/');
+ $this->load->view('iphone/recent', $data);
+ }
+
+
+ /**
+ * Displays an individual paste in an iPhone optimized version.
+ *
+ * @return void
+ * @access public
+ */
+
+ function view()
+ {
+ $this->load->model('pastes');
+ $data = $this->pastes->getPaste(3);
+ $this->load->view('iphone/view', $data);
+ }
+}
+
+?>
diff --git a/htdocs/application/controllers/main.php b/htdocs/application/controllers/main.php
new file mode 100755
index 0000000..8928970
--- /dev/null
+++ b/htdocs/application/controllers/main.php
@@ -0,0 +1,414 @@
+
+* @copyright Ben McRedmond
+* @package Stikked
+*
+*/
+
+/**
+* Main controller class for stikked.
+*
+* @author Ben McRedmond
+* @version 0.5.1
+* @access public
+* @copyright Ben McRedmond
+* @package Stikked
+* @subpackage Controllers
+*
+*/
+
+class Main extends CI_Controller
+{
+
+ /**
+ * Class Constructor, loads languages model which is inherited in the pastes model.
+ *
+ * @return void
+ */
+
+ function __construct()
+ {
+ parent::__construct();
+ $this->load->model('languages');
+ }
+
+
+ /**
+ * Sets all the fields in a paste form, depending on whether the form is being repopulated or items need to be loaded from session data.
+ *
+ * @param string $lang Paste language
+ * @param string $title Paste title
+ * @param string $paste Paste body
+ * @param bool|string $reply Is this paste a reply? Bool if not, otherwise it's the id of the paste.
+ * @return Array
+ * @access private
+ * @see index()
+ * @see view()
+ */
+
+ function _form_prep($lang='php', $title = '', $paste='', $reply=false)
+ {
+ $this->load->model('languages');
+ $this->load->helper("form");
+
+ $data['languages'] = $this->languages->get_languages();
+ $data['scripts'] = array('jquery.js', 'jquery.timers.js');
+
+ if(!$this->input->post('submit'))
+ {
+ if($this->db_session->flashdata('settings_changed'))
+ {
+ $data['status_message'] = 'Settings successfully changed';
+ }
+
+ $data['name_set'] = $this->db_session->userdata('name');
+ $data['expire_set'] = $this->db_session->userdata('expire');
+ $data['acopy_set'] = $this->db_session->userdata('acopy');
+ $data['private_set'] = $this->db_session->userdata('private');
+ $data['snipurl_set'] = $this->db_session->userdata('snipurl');
+ $data['remember_set'] = $this->db_session->userdata('remember');
+ $data['paste_set'] = $paste;
+ $data['title_set'] = $title;
+ $data['reply'] = $reply;
+
+ if($lang != 'php' or ($lang == 'php' and $this->db_session->userdata('lang') == false))
+ {
+ $data['lang_set'] = $lang;
+ }
+ elseif($this->db_session->userdata('lang'))
+ {
+ $data['lang_set'] = $this->db_session->userdata('lang');
+ }
+ }
+ else
+ {
+ $data['name_set'] = $this->input->post('name');
+ $data['expire_set'] = $this->input->post('expire');
+ $data['acopy_set'] = $this->input->post('acopy');
+ $data['private_set'] = $this->input->post('private');
+ $data['snipurl_set'] = $this->input->post('snipurl');
+ $data['remember_set'] = $this->input->post('remember');
+ $data['paste_set'] = $this->input->post('paste');
+ $data['title_set'] = $this->input->post('title');
+ $data['reply'] = $this->input->post('reply');
+ $data['lang_set'] = $this->input->post('lang');
+ }
+ return $data;
+ }
+
+
+ /**
+ * Controller method to load front page.
+ *
+ * @return void
+ * @access public
+ * @see _form_prep()
+ * @see _valid_lang()
+ */
+
+ function index()
+ {
+ if(!isset($_POST['submit']))
+ {
+ $data = $this->_form_prep();
+ $this->load->view('home', $data);
+ }
+ else
+ {
+ $this->load->model('pastes');
+ $this->load->library('validation');
+
+ $rules['code'] = 'required';
+ $rules['lang'] = 'min_length[1]|required|callback__valid_lang';
+
+ $fields['code'] = 'Main Paste';
+ $fields['lang'] = 'Language';
+
+ $this->validation->set_rules($rules);
+ $this->validation->set_fields($fields);
+ $this->validation->set_message('min_length', 'The %s field can not be empty');
+ $this->validation->set_error_delimiters('');
+
+ if ($this->validation->run() == FALSE)
+ {
+ $data = $this->_form_prep();
+ $this->load->view('home', $data);
+ }
+ else
+ {
+ if(isset($_POST['acopy']) and $_POST['acopy'] > 0)
+ {
+ $this->db_session->set_flashdata('acopy', 'true');
+ }
+
+ if($this->input->post('remember') and $this->input->post('reply') == false )
+ {
+ $user_data = array(
+ 'name' => $this->input->post('name'),
+ 'lang' => $this->input->post('lang'),
+ 'expire' => $this->input->post('expire'),
+ 'acopy' => $this->input->post('acopy'),
+ 'snipurl' => $this->input->post('snipurl'),
+ 'private' => $this->input->post('private'),
+ 'remember' => $this->input->post('remember')
+ );
+ $this->db_session->set_userdata($user_data);
+ }
+
+ if($this->input->post('remember') == false and $this->db_session->userdata("remember") == 1)
+ {
+ $user_data = array(
+ 'name' => '',
+ 'lang' => 'php',
+ 'expire' => '0',
+ 'acopy' => '0',
+ 'snipurl' => '0',
+ 'private' => '0',
+ 'remember' => '0'
+ );
+ $this->db_session->unset_userdata($user_data);
+ }
+
+ redirect($this->pastes->createPaste());
+ }
+ }
+ }
+
+
+ /**
+ * Controller method to load raw pastes.
+ *
+ * @return void
+ * @access public
+ *
+ */
+
+ function raw()
+ {
+ $this->load->model('pastes');
+ $check = $this->pastes->checkPaste(3);
+ if($check)
+ {
+
+ $data = $this->pastes->getPaste(3);
+ $this->load->view('view/raw', $data);
+ }
+ else
+ {
+ show_404();
+ }
+ }
+
+
+ /**
+ * Controller method to download pastes.
+ *
+ * @return void
+ * @access public
+ *
+ */
+
+ function download()
+ {
+ $this->load->model('pastes');
+ $check = $this->pastes->checkPaste(3);
+ if($check)
+ {
+ $data = $this->pastes->getPaste(3);
+ $this->load->view('view/download', $data);
+ }
+ else
+ {
+ show_404();
+ }
+
+ }
+
+
+ /**
+ * Controller method to show recent pastes.
+ *
+ * @return void
+ * @access public
+ *
+ */
+
+ function lists()
+ {
+ $this->load->model('pastes');
+ $data = $this->pastes->getLists();
+ $this->load->view('list', $data);
+ }
+
+
+ /**
+ * Controller method to show a paste.
+ *
+ * @return void
+ * @access public
+ *
+ */
+
+ function view()
+ {
+ $this->load->model('pastes');
+
+ $check = $this->pastes->checkPaste(2);
+
+ if($check)
+ {
+
+ if($this->db_session->userdata('view_raw'))
+ {
+ $this->db_session->keep_flashdata('acopy');
+ redirect('view/raw/'.$this->uri->segment(2));
+ }
+
+ $data = $this->pastes->getPaste(2, true);
+ $data['reply_form'] = $this->_form_prep($data['lang_code'], "RE: ".$data['title'], $data['raw'], $data['pid']);
+
+ if($this->db_session->userdata('full_width'))
+ {
+ $data['full_width'] = true;
+ }
+ else
+ {
+ $data['full_width'] = false;
+ }
+
+ $this->load->view('view/view', $data);
+ }
+ else
+ {
+ show_404();
+ }
+ }
+
+
+ /**
+ * Loads data for view_options from session data or not if not set.
+ *
+ * @return array
+ * @access private
+ *
+ */
+
+ function _view_options_prep()
+ {
+ $this->load->helper('form');
+ if($this->db_session->userdata('remember_view') > 0)
+ {
+ $data['full_width_set'] = $this->db_session->userdata('full_width');
+ $data['view_raw_set'] = $this->db_session->userdata('view_raw');
+ }
+ else
+ {
+ $data['full_width_set'] = false;
+ $data['view_raw_set'] = false;
+ }
+ return $data;
+ }
+
+
+ /**
+ * Displays the page where a user can change their paste viewing settings which are saved to session data.
+ *
+ * @return void
+ * @access public
+ *
+ */
+
+ function view_options()
+ {
+ if(!isset($_POST['submit']))
+ {
+ $data = $this->_view_options_prep();
+ $this->load->view('view/view_options', $data);
+ }
+ else
+ {
+ $this->load->library('validation');
+
+ $rules['full_width'] = 'max_length[1]';
+ $rules['view_raw'] = 'max_length[1]';
+
+ $this->validation->set_rules($rules);
+
+ if($this->validation->run() == false)
+ {
+ exit('Ugh, stupid skiddie.');
+ }
+ else
+ {
+ $user_data = array(
+ 'full_width' => $this->input->post('full_width'),
+ 'view_raw' => $this->input->post('view_raw'),
+ 'remember_view' => true
+ );
+ $this->db_session->set_userdata($user_data);
+ $this->db_session->set_flashdata('settings_changed', 'true');
+ redirect();
+ }
+ }
+ }
+
+
+ /**
+ * Controller method to run the cron. Requires a valid cron key supplied as an argument in the url.
+ *
+ * @return void;
+ * @access public
+ *
+ */
+
+ function cron()
+ {
+ $this->load->model('pastes');
+ $key = $this->uri->segment(2);
+ if($key != $this->config->item('cron_key'))
+ {
+ show_404();
+ }
+ else
+ {
+ $this->pastes->cron();
+ return 0;
+ }
+ }
+
+
+ /**
+ * Controller method to load about view.
+ *
+ * @return void
+ * @access public
+ *
+ */
+
+ function about()
+ {
+ $this->load->view('about');
+ }
+
+
+ /**
+ * Validation callback method to validate whether the paste language is valid.
+ *
+ * @return bool
+ * @access private
+ * @see index()
+ *
+ */
+
+ function _valid_lang($lang)
+ {
+ $this->load->model('languages');
+ $this->validation->set_message('_valid_lang', 'Please select your language');
+ return $this->languages->valid_language($lang);
+ }
+}
+?>
diff --git a/htdocs/application/controllers/welcome.php b/htdocs/application/controllers/welcome.php
deleted file mode 100644
index 21bef43..0000000
--- a/htdocs/application/controllers/welcome.php
+++ /dev/null
@@ -1,27 +0,0 @@
-
- * @see http://codeigniter.com/user_guide/general/urls.html
- */
- public function index()
- {
- $this->load->view('welcome_message');
- }
-}
-
-/* End of file welcome.php */
-/* Location: ./application/controllers/welcome.php */
\ No newline at end of file
diff --git a/htdocs/application/errors/error_404.php b/htdocs/application/errors/error_404.php
old mode 100644
new mode 100755
index 792726a..cc87728
--- a/htdocs/application/errors/error_404.php
+++ b/htdocs/application/errors/error_404.php
@@ -1,62 +1,51 @@
-
-
-
-404 Page Not Found
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
=$heading?>
+
+ =$message?>
+
Woops! We can't find that page, Go Home
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/htdocs/application/errors/error_db.php b/htdocs/application/errors/error_db.php
old mode 100644
new mode 100755
index b396cda..72d332f
--- a/htdocs/application/errors/error_db.php
+++ b/htdocs/application/errors/error_db.php
@@ -1,62 +1,51 @@
-
-
-
-Database Error
-
-
-
-
-
-
-
-
+
+
+
\ No newline at end of file
diff --git a/htdocs/application/errors/error_general.php b/htdocs/application/errors/error_general.php
old mode 100644
new mode 100755
index fd63ce2..9f26d99
--- a/htdocs/application/errors/error_general.php
+++ b/htdocs/application/errors/error_general.php
@@ -1,62 +1,50 @@
-
-
-
-Error
-
-
-
-
-
-
-
-
+
+
+
\ No newline at end of file
diff --git a/htdocs/application/errors/error_php.php b/htdocs/application/errors/error_php.php
old mode 100644
new mode 100755
diff --git a/htdocs/application/errors/index.html b/htdocs/application/errors/index.html
old mode 100644
new mode 100755
index c942a79..5a1f5d6
--- a/htdocs/application/errors/index.html
+++ b/htdocs/application/errors/index.html
@@ -1,10 +1,15 @@
-
-
- 403 Forbidden
-
-
-
-Directory access is forbidden.
-
-
+
+
+
+
+403 Forbidden
+
+
+
+
+
+Directory access is forbidden.
+
+
+
\ No newline at end of file
diff --git a/htdocs/application/libraries/db_session.php b/htdocs/application/libraries/db_session.php
new file mode 100644
index 0000000..81fbcaa
--- /dev/null
+++ b/htdocs/application/libraries/db_session.php
@@ -0,0 +1,509 @@
+object =& get_instance();
+
+ log_message('debug', "Session Class Initialized (db)");
+ $this->sess_run();
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Run the session routines
+ *
+ * @access public
+ * @return void
+ */
+ function sess_run()
+ {
+
+ // We MUST use a database !
+ if ($this->object->config->item('sess_use_database') === TRUE AND $this->object->config->item('sess_table_name') != '')
+ {
+ $this->use_database = TRUE;
+ $this->session_table = $this->object->config->item('sess_table_name');
+ $this->object->load->database();
+ } else {
+ log_message('error',__CLASS__.': sessions requires a database');
+ return FALSE;
+ }
+
+
+ /*
+ * Set the "now" time
+ *
+// * It can either set to GMT or time(). The pref
+ * is set in the config file. If the developer
+ * is doing any sort of time localization they
+ * might want to set the session time to GMT so
+ * they can offset the "last_activity" and
+ * "last_visit" times based on each user's locale.
+ *
+ */
+ if (strtolower($this->object->config->item('time_reference')) == 'gmt')
+ {
+ $now = time();
+ $this->now = mktime(gmdate("H", $now), gmdate("i", $now), gmdate("s", $now), gmdate("m", $now), gmdate("d", $now), gmdate("Y", $now));
+
+ if (strlen($this->now) < 10)
+ {
+ $this->now = time();
+ log_message('error', 'The session class could not set a proper GMT timestamp so the local time() value was used.');
+ }
+ }
+ else
+ {
+ $this->now = time();
+ }
+
+ /*
+ * Set the session length
+ *
+ * If the session expiration is set to zero in
+ * the config file we'll set the expiration
+ * two years from now.
+ *
+ */
+ $expiration = $this->object->config->item('sess_expiration');
+
+ if (is_numeric($expiration))
+ {
+ if ($expiration > 0)
+ {
+ $this->sess_length = $this->object->config->item('sess_expiration');
+ }
+ else
+ {
+ $this->sess_length = (60*60*24*365*2);
+ }
+ }
+
+ // Set the cookie name
+ if ($this->object->config->item('sess_cookie_name') != FALSE)
+ {
+ $this->sess_cookie = $this->object->config->item('cookie_prefix').$this->object->config->item('sess_cookie_name');
+ }
+
+ /*
+ * Fetch the current session
+ *
+ * If a session doesn't exist we'll create
+ * a new one. If it does, we'll update it.
+ *
+ */
+ if ( ! $this->sess_read())
+ {
+ $this->sess_create();
+ }
+ else
+ {
+ // We only update the session every five minutes
+ if (($this->userdata['last_activity'] + 300) < $this->now)
+ {
+ $this->sess_update();
+ }
+ }
+
+ // Delete expired sessions if necessary
+ $this->sess_gc();
+ // delete old flashdata (from last request)
+ $this->_flashdata_sweep();
+
+ // mark all new flashdata as old (data will be deleted before next request)
+ $this->_flashdata_mark();
+ }
+ // END sess_run()
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Fetch the current session data if it exists
+ *
+ * @access public
+ * @return void
+ */
+ function sess_read()
+ {
+ // Fetch the cookie
+ $session_id = $this->object->input->cookie($this->sess_cookie);
+
+ if ($session_id === FALSE)
+ {
+ log_message('debug', 'A session cookie was not found.');
+ return FALSE;
+ }
+
+ // Is there a corresponding session in the DB?
+ $this->object->db->where('session_id', $session_id);
+ // session should not have expired
+ $this->object->db->where('last_activity >', ($this->now - $this->sess_length) );
+ // matching IP ?
+ if ($this->object->config->item('sess_match_ip') == TRUE)
+ {
+ $this->object->db->where('ip_address', $this->object->input->ip_address());
+ }
+ // matching user agent ?
+ if ($this->object->config->item('sess_match_useragent') == TRUE)
+ {
+ $this->object->db->where('user_agent', substr($this->object->input->user_agent(), 0, 50));
+ }
+
+ $query = $this->object->db->get($this->session_table);
+
+ if ($query->num_rows() == 0)
+ {
+ $this->sess_destroy();
+ return FALSE;
+ }
+ else
+ {
+ $row = $query->row();
+ if (($row->last_activity + $this->sess_length) < $this->now)
+ {
+ $this->object->db->where('session_id', $session_id);
+ $this->object->db->delete($this->session_table);
+ $this->sess_destroy();
+ return FALSE;
+ } else {
+ $session = @unserialize($row->session_data);
+ if ( ! is_array($session) ) {
+ $session = array();
+ }
+ $session['session_id'] = $session_id;
+ $session['ip_address'] = $row->ip_address;
+ $session['user_agent'] = $row->user_agent;
+ $session['last_activity'] = $row->last_activity;
+ }
+ }
+
+
+ // Session is valid!
+ $this->userdata = $session;
+ unset($session);
+
+ return TRUE;
+ }
+ // END sess_read()
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Write the session cookie
+ *
+ * @access public
+ * @param boolean true if we want to send cookie even if a cookie has already been sent
+ * @return void
+ */
+ function sess_send_cookie($force = FALSE)
+ {
+ if ( !$force && $this->cookie_sent ) return;
+ log_message('debug','sending session cookie');
+ setcookie(
+ $this->sess_cookie,
+ $this->userdata['session_id'],
+ $this->sess_length + $this->now,
+ $this->object->config->item('cookie_path'),
+ $this->object->config->item('cookie_domain'),
+ 0
+ );
+ $this->cookie_sent = TRUE;
+ }
+ // END sess_send_cookie()
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Create a new session
+ *
+ * @access public
+ * @return void
+ */
+ function sess_create()
+ {
+ $sessid = '';
+ while (strlen($sessid) < 32)
+ {
+ $sessid .= mt_rand(0, mt_getrandmax());
+ }
+
+ $this->userdata = array(
+ 'session_id' => md5(uniqid($sessid, TRUE)),
+ 'ip_address' => $this->object->input->ip_address(),
+ 'user_agent' => substr($this->object->input->user_agent(), 0, 50),
+ 'last_activity' => $this->now
+ );
+
+ $this->object->db->query($this->object->db->insert_string($this->session_table, $this->userdata));
+
+ // Write the cookie
+ $this->sess_send_cookie();
+ }
+ // END sess_create()
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Update an existing session
+ *
+ * @access public
+ * @return void
+ */
+ function sess_update()
+ {
+ $this->userdata['last_activity'] = $this->now;
+ // format query array to update database
+ $ud = $this->userdata;
+ $query_array = array( 'last_activity' => $ud['last_activity'],
+ 'user_agent' => $ud['user_agent'],
+ 'ip_address' => $ud['ip_address'] );
+ unset($ud['session_id']);
+ unset($ud['last_activity']);
+ unset($ud['user_agent']);
+ unset($ud['ip_address']);
+ $query_array['session_data'] = serialize($ud);
+ $this->object->db->query($this->object->db->update_string($this->session_table, $query_array, array('session_id' => $this->userdata['session_id'])));
+
+ // Write the cookie
+ $this->sess_send_cookie();
+ }
+ // END sess_update()
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Destroy the current session
+ *
+ * @access public
+ * @return void
+ */
+ function sess_destroy()
+ {
+ setcookie(
+ $this->sess_cookie,
+ '',
+ ($this->now - 31500000),
+ $this->object->config->item('cookie_path'),
+ $this->object->config->item('cookie_domain'),
+ 0
+ );
+ }
+ // END sess_destroy()
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Garbage collection
+ *
+ * This deletes expired session rows from database
+ * if the probability percentage is met
+ *
+ * @access public
+ * @return void
+ */
+ function sess_gc()
+ {
+ srand(time());
+ if ((rand() % 100) < $this->gc_probability)
+ {
+ $expire = $this->now - $this->sess_length;
+
+ $this->object->db->where("last_activity < {$expire}");
+ $this->object->db->delete($this->session_table);
+
+ log_message('debug', 'Session garbage collection performed.');
+ }
+ }
+ // END sess_gc()
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Fetch a specific item form the session array
+ *
+ * @access public
+ * @param string
+ * @return string
+ */
+ function userdata($item = '')
+ {
+ if ( ! strlen($item) ) return $this->userdata;
+ return ( ! isset($this->userdata[$item])) ? FALSE : $this->userdata[$item];
+ }
+ // END userdata()
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Add or change data in the "userdata" array
+ *
+ * @access public
+ * @param mixed
+ * @param string
+ * @return void
+ */
+ function set_userdata($newdata = array(), $newval = '')
+ {
+ if (is_string($newdata))
+ {
+ $newdata = array($newdata => $newval);
+ }
+
+ if (count($newdata) > 0)
+ {
+ foreach ($newdata as $key => $val)
+ {
+ $this->userdata[$key] = $val;
+ }
+ }
+
+ $this->sess_update();
+ }
+ // END set_userdata()
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Delete a session variable from the "userdata" array
+ *
+ * @access array
+ * @return void
+ */
+ function unset_userdata($newdata = array())
+ {
+ if (is_string($newdata))
+ {
+ $newdata = array($newdata => '');
+ }
+
+ if (count($newdata) > 0)
+ {
+ foreach ($newdata as $key => $val)
+ {
+ unset($this->userdata[$key]);
+ }
+ }
+
+ $this->sess_update();
+ }
+ // END unset_userdata()
+
+
+ /**
+ * Sets "flash" data which will be available only in next request (then it will
+ * be deleted from session). You can use it to implement "Save succeeded" messages
+ * after redirect.
+ */
+ function set_flashdata($key, $value)
+ {
+ $flash_key = $this->flash_key.':new:'.$key;
+ $this->set_userdata($flash_key, $value);
+ }
+
+ /**
+ * Keeps existing "flash" data available to next request.
+ */
+ function keep_flashdata($key)
+ {
+ $old_flash_key = $this->flash_key.':old:'.$key;
+ $value = $this->userdata($old_flash_key);
+
+ $new_flash_key = $this->flash_key.':new:'.$key;
+ $this->set_userdata($new_flash_key, $value);
+ }
+
+ /**
+ * Returns "flash" data for the given key.
+ */
+ function flashdata($key)
+ {
+ $flash_key = $this->flash_key.':old:'.$key;
+ return $this->userdata($flash_key);
+ }
+
+ /**
+ * PRIVATE: Internal method - marks "flash" session attributes as 'old'
+ */
+ function _flashdata_mark()
+ {
+ $userdata = $this->userdata();
+ foreach ($userdata as $name => $value)
+ {
+ $parts = explode(':new:', $name);
+ if (is_array($parts) && count($parts) == 2)
+ {
+ $new_name = $this->flash_key.':old:'.$parts[1];
+ $this->set_userdata($new_name, $value);
+ $this->unset_userdata($name);
+ }
+ }
+ }
+
+ /**
+ * PRIVATE: Internal method - removes "flash" session marked as 'old'
+ */
+ function _flashdata_sweep()
+ {
+ $userdata = $this->userdata();
+ foreach ($userdata as $name => $value)
+ {
+ $parts = explode(':old:', $name);
+ if (is_array($parts) && count($parts) == 2 && $parts[0] == $this->flash_key)
+ {
+ $this->unset_userdata($name);
+ }
+ }
+ }
+
+
+ // --------------------------------------------------------------------
+}
+// END DB_Session Class
+
+/*
+CREATE TABLE IF NOT EXISTS `ci_sessions` (
+session_id varchar(40) DEFAULT '0' NOT NULL,
+ip_address varchar(16) DEFAULT '0' NOT NULL,
+user_agent varchar(50) NOT NULL,
+last_activity int(10) unsigned DEFAULT 0 NOT NULL,
+session_data text default '' not null,
+PRIMARY KEY (session_id)
+);
+*/
+
+?>
\ No newline at end of file
diff --git a/htdocs/application/libraries/geshi/contrib/aliased.php b/htdocs/application/libraries/geshi/contrib/aliased.php
new file mode 100755
index 0000000..32bec92
--- /dev/null
+++ b/htdocs/application/libraries/geshi/contrib/aliased.php
@@ -0,0 +1,124 @@
+
+ * @version $Id: aliased.php 785 2006-07-19 10:09:45Z oracleshinoda $
+ */
+
+// Your config here
+define("SOURCE_ROOT", "/var/www/your/source/root/");
+
+// Assume you've put geshi in the include_path already
+require_once("geshi.php");
+
+// Get path info
+$path = SOURCE_ROOT.$_SERVER['PATH_INFO'];
+
+// Check for dickheads trying to use '../' to get to sensitive areas
+$base_path_len = strlen(SOURCE_ROOT);
+$real_path = realpath($path);
+if(strncmp($real_path, SOURCE_ROOT, $base_path_len)) {
+ exit("Stop that.");
+}
+
+// Check file exists
+if(!file_exists($path)) {
+ exit("File not found ($path).");
+}
+
+// Gather contents
+$contents = file_get_contents($path);
+
+// Prepare GeSHi instance
+$geshi =& new GeSHi($contents, "PHP");
+$geshi->set_header_type(GESHI_HEADER_PRE);
+$geshi->enable_classes();
+$geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS, 10);
+$geshi->set_overall_style('color: #000066; border: 1px solid #d0d0d0; background-color: #f0f0f0;', true);
+$geshi->set_line_style('font: normal normal 95% \'Courier New\', Courier, monospace; color: #003030;', 'font-weight: bold; color: #006060;', true);
+$geshi->set_code_style('color: #000020;', 'color: #000020;');
+$geshi->set_link_styles(GESHI_LINK, 'color: #000060;');
+$geshi->set_link_styles(GESHI_HOVER, 'background-color: #f0f000;');
+$geshi->set_header_content('Source code viewer');
+$geshi->set_header_content_style('font-family: Verdana, Arial, sans-serif; color: #808080; font-size: 70%; font-weight: bold; background-color: #f0f0ff; border-bottom: 1px solid #d0d0d0; padding: 2px;');
+$geshi->set_footer_content('Parsed in