Initial import from local backup (Documents-Playground/pakerpale)

This commit is contained in:
jeonghwa
2026-07-03 05:27:47 +09:00
commit d8dab43237
1460 changed files with 134466 additions and 0 deletions

View File

@@ -0,0 +1,209 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* A base controller for CodeIgniter with view autoloading, layout support,
* model loading, helper loading, asides/partials and per-controller 404
*
* @link http://github.com/jamierumbelow/codeigniter-base-controller
* @copyright Copyright (c) 2012, Jamie Rumbelow <http://jamierumbelow.net>
*/
class MY_Controller extends CI_Controller
{
/* --------------------------------------------------------------
* VARIABLES
* ------------------------------------------------------------ */
/**
* The current request's view. Automatically guessed
* from the name of the controller and action
*/
protected $view;
/**
* An array of variables to be passed through to the
* view, layout and any asides
*/
protected $data = array();
/**
* The name of the layout to wrap around the view.
*/
protected $layout;
/**
* An arbitrary list of asides/partials to be loaded into
* the layout. The key is the declared name, the value the file
*/
protected $asides = array();
/**
* A list of models to be autoloaded
*/
protected $models = array();
/**
* A formatting string for the model autoloading feature.
* The percent symbol (%) will be replaced with the model name.
*/
protected $model_string = '%_model';
/**
* A list of helpers to be autoloaded
*/
protected $helpers = array();
/* --------------------------------------------------------------
* GENERIC METHODS
* ------------------------------------------------------------ */
/**
* Initialise the controller, tie into the CodeIgniter superobject
* and try to autoload the models and helpers
*/
public function __construct()
{
parent::__construct();
if (config_item('chk_installed')) {
$database = $this->load->database('', true);
if (empty($database->conn_id)) {
redirect('install');
}
$connected = $database->initialize();
if ($connected) {
$this->load->database();
if ($this->db->table_exists('config') === false) {
redirect('install');
}
} else {
redirect('install');
}
} else {
$this->load->database();
}
$this->_load_models();
$this->_load_helpers();
// Place the driver calling code here
$this->load->driver('cache', config_item('cache_method'));
if (config_item('enable_profiler') === true) {
$this->output->enable_profiler(TRUE);
}
}
/* --------------------------------------------------------------
* VIEW RENDERING
* ------------------------------------------------------------ */
/**
* Override CodeIgniter's despatch mechanism and route the request
* through to the appropriate action. Support custom 404 methods and
* autoload the view into the layout.
*/
public function _remap($method)
{
if (method_exists($this, $method)) {
call_user_func_array(array($this, $method), array_slice($this->uri->rsegments, 2));
} else {
if (method_exists($this, '_404')) {
call_user_func_array(array($this, '_404'), array($method));
} else {
show_404(strtolower(get_class($this)) . '/' . $method);
}
}
$this->_load_view();
}
/**
* Automatically load the view, allowing the developer to override if
* he or she wishes, otherwise being conventional.
*/
protected function _load_view()
{
if ( ! isset($this->view)) {
$this->view = false;
}
// If $this->view === false, we don't want to load anything
if ($this->view !== false) {
// Load the view into $yield
if (is_array($this->view)) {
$data['yield'] = '';
foreach ($this->view as $val) {
$data['yield'] .= $this->load->view($val, $this->data, true);
}
} else {
$data['yield'] = $this->load->view($this->view, $this->data, true);
}
// Do we have any asides? Load them.
if ( ! empty($this->asides)) {
foreach ($this->asides as $name => $file) {
$data['yield_' . $name] = $this->load->view($file, $this->data, true);
}
}
// Load in our existing data with the asides and view
$data = array_merge($this->data, $data);
$layout = false;
// If we didn't specify the layout, try to guess it
if ( ! isset($this->layout)) {
$this->layout = false;
} elseif ($this->layout !== false) {
// If we did, use it
$layout = $this->layout;
}
// If $layout is false, we're not interested in loading a layout, so output the view directly
if ($layout === false) {
$this->output->set_output($data['yield']);
} else {
// Otherwise? Load away :)
$this->load->view($layout, $data);
}
}
}
/* --------------------------------------------------------------
* MODEL LOADING
* ------------------------------------------------------------ */
/**
* Load models based on the $this->models array
*/
private function _load_models()
{
foreach ($this->models as $model) {
$this->load->model($this->_model_name($model));
}
}
/**
* Returns the loadable model name based on
* the model formatting string
*/
protected function _model_name($model)
{
return str_replace('%', $model, $this->model_string);
}
/* --------------------------------------------------------------
* HELPER LOADING
* ------------------------------------------------------------ */
/**
* Load helpers based on the $this->helpers array
*/
private function _load_helpers()
{
foreach ($this->helpers as $helper) {
$this->load->helper($helper);
}
}
}

View File

@@ -0,0 +1,206 @@
<?php
/**
* CodeIgniter
*
* An open source application development framework for PHP
*
* This content is released under the MIT License (MIT)
*
* Copyright (c) 2014 - 2015, British Columbia Institute of Technology
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* @package CodeIgniter
* @author EllisLab Dev Team
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/)
* @copyright Copyright (c) 2014 - 2015, British Columbia Institute of Technology (http://bcit.ca/)
* @license http://opensource.org/licenses/MIT MIT License
* @link http://codeigniter.com
* @since Version 1.0.0
* @filesource
*/
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Input Class
*
* Pre-processes global input data for security
*
* @package CodeIgniter
* @subpackage Libraries
* @category Input
* @author EllisLab Dev Team
* @link http://codeigniter.com/user_guide/libraries/input.html
*/
class MY_Input extends CI_Input
{
/**
* Fetch from array
*
* Internal method used to retrieve values from global arrays.
*
* @param array &$array $_GET, $_POST, $_COOKIE, $_SERVER, etc.
* @param mixed $index Index for item to be fetched from $array
* @param bool $xss_clean Whether to apply XSS filtering
* @return mixed
*/
protected function _fetch_from_array(&$array, $index = NULL, $xss_clean = NULL, $default_value =NULL)
{
is_bool($xss_clean) OR $xss_clean = $this->_enable_xss;
// If $index is NULL, it means that the whole $array is requested
isset($index) OR $index = array_keys($array);
// allow fetching multiple keys at once
if (is_array($index))
{
$output = array();
foreach ($index as $key)
{
$output[$key] = $this->_fetch_from_array($array, $key, $xss_clean);
}
return $output;
}
if (isset($array[$index]))
{
$value = $array[$index];
}
elseif (($count = preg_match_all('/(?:^[^\[]+)|\[[^]]*\]/', $index, $matches)) > 1) // Does the index contain array notation
{
$value = $array;
for ($i = 0; $i < $count; $i++)
{
$key = trim($matches[0][$i], '[]');
if ($key === '') // Empty notation will return the value as array
{
break;
}
if (isset($value[$key]))
{
$value = $value[$key];
}
else
{
return $default_value;
}
}
}
else
{
return $default_value;
}
return ($xss_clean === TRUE)
? $this->security->xss_clean($value)
: $value;
}
// --------------------------------------------------------------------
/**
* Fetch an item from the GET array
*
* @param mixed $index Index for item to be fetched from $_GET
* @param bool $xss_clean Whether to apply XSS filtering
* @return mixed
*/
public function get($index = NULL, $xss_clean = NULL, $default_value = NULL)
{
return $this->_fetch_from_array($_GET, $index, $xss_clean, $default_value);
}
// --------------------------------------------------------------------
/**
* Fetch an item from the POST array
*
* @param mixed $index Index for item to be fetched from $_POST
* @param bool $xss_clean Whether to apply XSS filtering
* @return mixed
*/
public function post($index = NULL, $xss_clean = NULL, $default_value = NULL)
{
return $this->_fetch_from_array($_POST, $index, $xss_clean, $default_value);
}
// --------------------------------------------------------------------
/**
* Fetch an item from POST data with fallback to GET
*
* @param string $index Index for item to be fetched from $_POST or $_GET
* @param bool $xss_clean Whether to apply XSS filtering
* @return mixed
*/
public function post_get($index, $xss_clean = NULL, $default_value = NULL)
{
return isset($_POST[$index])
? $this->post($index, $xss_clean, $default_value)
: $this->get($index, $xss_clean, $default_value);
}
// --------------------------------------------------------------------
/**
* Fetch an item from GET data with fallback to POST
*
* @param string $index Index for item to be fetched from $_GET or $_POST
* @param bool $xss_clean Whether to apply XSS filtering
* @return mixed
*/
public function get_post($index, $xss_clean = NULL, $default_value = NULL)
{
return isset($_GET[$index])
? $this->get($index, $xss_clean, $default_value)
: $this->post($index, $xss_clean, $default_value);
}
// --------------------------------------------------------------------
/**
* Fetch an item from the COOKIE array
*
* @param mixed $index Index for item to be fetched from $_COOKIE
* @param bool $xss_clean Whether to apply XSS filtering
* @return mixed
*/
public function cookie($index = NULL, $xss_clean = NULL, $default_value = NULL)
{
return $this->_fetch_from_array($_COOKIE, $index, $xss_clean, $default_value);
}
// --------------------------------------------------------------------
/**
* Fetch an item from the SERVER array
*
* @param mixed $index Index for item to be fetched from $_SERVER
* @param bool $xss_clean Whether to apply XSS filtering
* @return mixed
*/
public function server($index, $xss_clean = NULL, $default_value = NULL)
{
return $this->_fetch_from_array($_SERVER, $index, $xss_clean, $default_value);
}
}

View File

@@ -0,0 +1,188 @@
<?php
/**
* CodeIgniter
*
* An open source application development framework for PHP
*
* This content is released under the MIT License (MIT)
*
* Copyright (c) 2014 - 2015, British Columbia Institute of Technology
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* @package CodeIgniter
* @author EllisLab Dev Team
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/)
* @copyright Copyright (c) 2014 - 2015, British Columbia Institute of Technology (http://bcit.ca/)
* @license http://opensource.org/licenses/MIT MIT License
* @link http://codeigniter.com
* @since Version 1.0.0
* @filesource
*/
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Loader Class
*
* Loads framework components.
*
* @package CodeIgniter
* @subpackage Libraries
* @category Loader
* @author EllisLab Dev Team
* @link http://codeigniter.com/user_guide/libraries/loader.html
*/
class MY_Loader extends CI_Loader {
protected $_ci_events_paths = array();
public function __construct() {
parent::__construct();
$this->_ci_events_paths = array(APPPATH);
}
/** Load a events module * */
public function event($event = '', $params = NULL, $object_name = NULL)
{
if (is_array($event))
{
foreach ($event as $class)
{
$this->library($class, $params);
}
return;
}
if ($event == '' OR isset($this->_base_classes[$event]))
{
return FALSE;
}
if ( ! is_null($params) && ! is_array($params))
{
$params = NULL;
}
$this->_ci_events_class($event, $params, $object_name);
}
/** Load an array of events * */
public function events($event = '', $params = NULL, $object_name = NULL)
{
if (is_array($event))
{
foreach ($event as $class)
{
$this->library($class, $params);
}
}
return;
}
/**
* Load Events
*
* This function loads the requested class.
*
* @param string the item that is being loaded
* @param mixed any additional parameters
* @param string an optional object name
* @return void
*/
protected function _ci_events_class($class, $params = NULL, $object_name = NULL) {
// Get the class name, and while we're at it trim any slashes.
// The directory path can be included as part of the class name,
// but we don't want a leading slash
$class = str_replace('.php', '', trim($class, '/'));
// Was the path included with the class name?
// We look for a slash to determine this
if (($last_slash = strrpos($class, '/')) !== FALSE)
{
// Extract the path
$subdir = substr($class, 0, ++$last_slash);
// Get the filename from the path
$class = substr($class, $last_slash);
}
else
{
$subdir = '';
}
$class = ucfirst($class);
// Is this a stock library? There are a few special conditions if so ...
if (file_exists(BASEPATH.'events/'.$subdir.$class.'.php'))
{
return $this->_ci_load_stock_library($class, $subdir, $params, $object_name);
}
// Let's search for the requested library file and load it.
foreach ($this->_ci_library_paths as $path)
{
// BASEPATH has already been checked for
if ($path === BASEPATH)
{
continue;
}
$filepath = $path.'events/'.$subdir.$class.'.php';
// Safety: Was the class already loaded by a previous call?
if (class_exists($class, FALSE))
{
// Before we deem this to be a duplicate request, let's see
// if a custom object name is being supplied. If so, we'll
// return a new instance of the object
if ($object_name !== NULL)
{
$CI =& get_instance();
if ( ! isset($CI->$object_name))
{
return $this->_ci_init_library($class, '', $params, $object_name);
}
}
log_message('debug', $class.' class already loaded. Second attempt ignored.');
return;
}
// Does the file exist? No? Bummer...
elseif ( ! file_exists($filepath))
{
continue;
}
include_once($filepath);
return $this->_ci_init_library($class, '', $params, $object_name);
}
// One last attempt. Maybe the library is in a subdirectory, but it wasn't specified?
if ($subdir === '')
{
return $this->_ci_events_class($class.'/'.$class, $params, $object_name);
}
return;
}
}

View File

@@ -0,0 +1,362 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* MY_Model class
*/
class MY_Model extends CI_Model
{
/* --------------------------------------------------------------
* VARIABLES
* ------------------------------------------------------------ */
/**
* 테이블명
*/
protected $_table;
/**
* 프라이머리키
*/
protected $primary_key;
/**
* 실제 어떤 식으로든 검색이 가능한 필드
*/
public $allow_search_field = array();
/**
* 실제 어떤 식으로든 정렬이 가능한 필드
*/
public $allow_order_field = array();
/**
* = 검색 필드, like 검색이 아님
*/
public $search_field_equal = array();
/* --------------------------------------------------------------
* GENERIC METHODS
* ------------------------------------------------------------ */
/**
* Initialise the model, tie into the CodeIgniter superobject and
* try our best to guess the table name.
*/
public function __construct()
{
parent::__construct();
}
public function get($primary_value = '', $select = '', $where = '', $limit = '', $offset = 0, $findex = '', $forder = '')
{
$result = $this->_get($primary_value, $select, $where, $limit, $offset, $findex, $forder);
return $result->result_array();
}
public function get_one($primary_value = '', $select = '', $where = '')
{
$result = $this->_get($primary_value, $select, $where, 1);
return $result->row_array();
}
public function _get($primary_value = '', $select = '', $where = '', $limit = '', $offset = 0, $findex = '', $forder = '')
{
if ($select) {
$this->db->select($select);
}
$this->db->from($this->_table);
if ($primary_value) {
$this->db->where($this->primary_key, $primary_value);
}
if ($where) {
$this->db->where($where);
}
if ($findex) {
if (strtoupper($forder) === 'RANDOM') {
$forder = 'RANDOM';
} elseif (strtoupper($forder) === 'DESC') {
$forder = 'DESC';
} else {
$forder = 'ASC';
}
$this->db->order_by($findex, $forder);
}
if (is_numeric($limit) && is_numeric($offset)) {
$this->db->limit($limit, $offset);
}
$result = $this->db->get();
return $result;
}
public function _get_list_common($select = '', $join = '', $limit = '', $offset = '', $where = '', $like = '', $findex = '', $forder = '', $sfield = '', $skeyword = '', $sop = 'OR')
{
if (empty($findex) OR ! in_array($findex, $this->allow_order_field)) {
$findex = $this->primary_key;
}
$forder = (strtoupper($forder) === 'ASC') ? 'ASC' : 'DESC';
$sop = (strtoupper($sop) === 'AND') ? 'AND' : 'OR';
$count_by_where = array();
$search_where = array();
$search_like = array();
$search_or_like = array();
if ($sfield && is_array($sfield)) {
foreach ($sfield as $skey => $sval) {
$ssf = $sval;
if ($skeyword && $ssf && in_array($ssf, $this->allow_search_field)) {
if (in_array($ssf, $this->search_field_equal)) {
$search_where[$ssf] = $skeyword;
} else {
$swordarray = explode(' ', $skeyword);
foreach ($swordarray as $str) {
if (empty($ssf)) {
continue;
}
if ($sop === 'AND') {
$search_like[] = array($ssf => $str);
} else {
$search_or_like[] = array($ssf => $str);
}
}
}
}
}
} else {
$ssf = $sfield;
if ($skeyword && $ssf && in_array($ssf, $this->allow_search_field)) {
if (in_array($ssf, $this->search_field_equal)) {
$search_where[$ssf] = $skeyword;
} else {
$swordarray = explode(' ', $skeyword);
foreach ($swordarray as $str) {
if (empty($ssf)) {
continue;
}
if ($sop === 'AND') {
$search_like[] = array($ssf => $str);
} else {
$search_or_like[] = array($ssf => $str);
}
}
}
}
}
if ($select) {
$this->db->select($select);
}
$this->db->from($this->_table);
if ( ! empty($join['table']) && ! empty($join['on'])) {
if (empty($join['type'])) {
$join['type'] = 'left';
}
$this->db->join($join['table'], $join['on'], $join['type']);
} elseif (is_array($join)) {
foreach ($join as $jkey => $jval) {
if ( ! empty($jval['table']) && ! empty($jval['on'])) {
if (empty($jval['type'])) {
$jval['type'] = 'left';
}
$this->db->join($jval['table'], $jval['on'], $jval['type']);
}
}
}
if ($where) {
$this->db->where($where);
}
if ($search_where) {
$this->db->where($search_where);
}
if ($like) {
$this->db->like($like);
}
if ($search_like) {
foreach ($search_like as $item) {
foreach ($item as $skey => $sval) {
$this->db->like($skey, $sval);
}
}
}
if ($search_or_like) {
$this->db->group_start();
foreach ($search_or_like as $item) {
foreach ($item as $skey => $sval) {
$this->db->or_like($skey, $sval);
}
}
$this->db->group_end();
}
if ($count_by_where) {
$this->db->where($count_by_where);
}
$this->db->order_by($findex, $forder);
if ($limit) {
$this->db->limit($limit, $offset);
}
$qry = $this->db->get();
$result['list'] = $qry->result_array();
$this->db->select('count(*) as rownum');
$this->db->from($this->_table);
if ( ! empty($join['table']) && ! empty($join['on'])) {
if (empty($join['type'])) {
$join['type'] = 'left';
}
$this->db->join($join['table'], $join['on'], $join['type']);
} elseif (is_array($join)) {
foreach ($join as $jkey => $jval) {
if ( ! empty($jval['table']) && ! empty($jval['on'])) {
if (empty($jval['type'])) {
$jval['type'] = 'left';
}
$this->db->join($jval['table'], $jval['on'], $jval['type']);
}
}
}
if ($where) {
$this->db->where($where);
}
if ($search_where) {
$this->db->where($search_where);
}
if ($like) {
$this->db->like($like);
}
if ($search_like) {
foreach ($search_like as $item) {
foreach ($item as $skey => $sval) {
$this->db->like($skey, $sval);
}
}
}
if ($search_or_like) {
$this->db->group_start();
foreach ($search_or_like as $item) {
foreach ($item as $skey => $sval) {
$this->db->or_like($skey, $sval);
}
}
$this->db->group_end();
}
if ($count_by_where) {
$this->db->where($count_by_where);
}
$qry = $this->db->get();
$rows = $qry->row_array();
$result['total_rows'] = $rows['rownum'];
return $result;
}
public function delete($primary_value = '', $where = '')
{
if ($primary_value) {
$this->db->where($this->primary_key, $primary_value);
}
if ($where) {
$this->db->where($where);
}
$result = $this->db->delete($this->_table);
return $result;
}
public function delete_where($where = '')
{
if (empty($where)) {
return;
}
$this->db->where($where);
$result = $this->db->delete($this->_table);
return $result;
}
public function update($primary_value = '', $updatedata = '', $where = '')
{
if ( ! empty($updatedata)) {
if ( ! empty($primary_value)) {
$this->db->where($this->primary_key, $primary_value);
}
if ( ! empty($where)) {
$this->db->where($where);
}
$this->db->set($updatedata);
$result = $this->db->update($this->_table);
return $result;
} else {
return false;
}
}
public function insert($data)
{
if ( ! empty($data)) {
$this->db->insert($this->_table, $data);
$insert_id = $this->db->insert_id();
return $insert_id;
} else {
return false;
}
}
public function replace($data = '')
{
if ( ! empty($data)) {
$this->db->replace($this->_table, $data);
return true;
} else {
return false;
}
}
public function count_by($where = '', $like = '')
{
if ($where) {
$this->db->where($where);
}
if ($like) {
$this->db->like($like);
}
return $this->db->count_all_results($this->_table);
}
public function update_plus($primary_value = '', $field = '', $count = '')
{
if (empty($primary_value) OR empty($field) OR empty($count)) {
return false;
}
$this->db->where($this->primary_key, $primary_value);
if ($count > 0) {
$this->db->set($field, $field . '+' . $count, false);
} else {
$this->db->set($field, $field . $count, false);
}
$result = $this->db->update($this->_table);
return $result;
}
}

View File

@@ -0,0 +1,103 @@
<?php
/**
* CodeIgniter
*
* An open source application development framework for PHP
*
* This content is released under the MIT License (MIT)
*
* Copyright (c) 2014 - 2015, British Columbia Institute of Technology
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* @package CodeIgniter
* @author EllisLab Dev Team
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/)
* @copyright Copyright (c) 2014 - 2015, British Columbia Institute of Technology (http://bcit.ca/)
* @license http://opensource.org/licenses/MIT MIT License
* @link http://codeigniter.com
* @since Version 1.0.0
* @filesource
*/
defined('BASEPATH') OR exit('No direct script access allowed');
class MY_Security extends CI_Security
{
public function csrf_verify()
{
// If it's not a POST request we will set the CSRF cookie
if (strtoupper($_SERVER['REQUEST_METHOD']) !== 'POST')
{
return $this->csrf_set_cookie();
}
// Check if URI has been whitelisted from CSRF checks
if ($exclude_uris = config_item('csrf_exclude_uris'))
{
$uri = load_class('URI', 'core');
// assumes /controller/method in your url. adjust as needed.
$parts = explode("/",$uri->uri_string());
if (count($parts) >= 2) {
$class=$parts[0];
$method=$parts[1];
foreach ($exclude_uris as $exclude_url_data) {
if (@$exclude_url_data['controller'] == $class
&& @$exclude_url_data['method'] == $method) {
return $this;
}
}
}
}
// Do the tokens exist in both the _POST and _COOKIE arrays?
if ( ! isset($_POST[$this->_csrf_token_name], $_COOKIE[$this->_csrf_cookie_name])
OR $_POST[$this->_csrf_token_name] !== $_COOKIE[$this->_csrf_cookie_name]) // Do the tokens match?
{
$this->csrf_show_error();
}
// We kill this since we're done and we don't want to polute the _POST array
unset($_POST[$this->_csrf_token_name]);
// Regenerate on every submission?
if (config_item('csrf_regenerate'))
{
// Nothing should last forever
unset($_COOKIE[$this->_csrf_cookie_name]);
$this->_csrf_hash = NULL;
}
$this->_csrf_set_hash();
$this->csrf_set_cookie();
log_message('info', 'CSRF token verified');
return $this;
}
}

View File

@@ -0,0 +1,10 @@
<html>
<head>
<title>403 Forbidden</title>
</head>
<body>
<p>Directory access is forbidden.</p>
</body>
</html>