mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-05-24 16:28:40 -04:00
Initial commit of release 1.0.
~ Tom git-svn-id: svn+ssh://jekkos@svn.code.sf.net/p/opensourcepos/code/@11 c3eb156b-1dc0-44e1-88ae-e38439141b53
This commit is contained in:
10
system/cache/index.html
vendored
Normal file
10
system/cache/index.html
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
69
system/codeigniter/Base4.php
Normal file
69
system/codeigniter/Base4.php
Normal file
@@ -0,0 +1,69 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP 4.3.2 or newer
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2010, EllisLab, Inc.
|
||||
* @license http://codeigniter.com/user_guide/license.html
|
||||
* @link http://codeigniter.com
|
||||
* @since Version 1.3
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* CI_BASE - For PHP 4
|
||||
*
|
||||
* This file is used only when CodeIgniter is being run under PHP 4.
|
||||
*
|
||||
* In order to allow CI to work under PHP 4 we had to make the Loader class
|
||||
* the parent of the Controller Base class. It's the only way we can
|
||||
* enable functions like $this->load->library('email') to instantiate
|
||||
* classes that can then be used within controllers as $this->email->send()
|
||||
*
|
||||
* PHP 4 also has trouble referencing the CI super object within application
|
||||
* constructors since objects do not exist until the class is fully
|
||||
* instantiated. Basically PHP 4 sucks...
|
||||
*
|
||||
* Since PHP 5 doesn't suffer from this problem so we load one of
|
||||
* two files based on the version of PHP being run.
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @subpackage codeigniter
|
||||
* @category front-controller
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @link http://codeigniter.com/user_guide/
|
||||
*/
|
||||
class CI_Base extends CI_Loader {
|
||||
|
||||
function CI_Base()
|
||||
{
|
||||
// This allows syntax like $this->load->foo() to work
|
||||
parent::CI_Loader();
|
||||
$this->load =& $this;
|
||||
|
||||
// This allows resources used within controller constructors to work
|
||||
global $OBJ;
|
||||
$OBJ = $this->load; // Do NOT use a reference.
|
||||
}
|
||||
}
|
||||
|
||||
function &get_instance()
|
||||
{
|
||||
global $CI, $OBJ;
|
||||
|
||||
if (is_object($CI))
|
||||
{
|
||||
return $CI;
|
||||
}
|
||||
|
||||
return $OBJ->load;
|
||||
}
|
||||
|
||||
|
||||
/* End of file Base4.php */
|
||||
/* Location: ./system/codeigniter/Base4.php */
|
||||
56
system/codeigniter/Base5.php
Normal file
56
system/codeigniter/Base5.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP 4.3.2 or newer
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2010, EllisLab, Inc.
|
||||
* @license http://codeigniter.com/user_guide/license.html
|
||||
* @link http://codeigniter.com
|
||||
* @since Version 1.3
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* CI_BASE - For PHP 5
|
||||
*
|
||||
* This file contains some code used only when CodeIgniter is being
|
||||
* run under PHP 5. It allows us to manage the CI super object more
|
||||
* gracefully than what is possible with PHP 4.
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @subpackage codeigniter
|
||||
* @category front-controller
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @link http://codeigniter.com/user_guide/
|
||||
*/
|
||||
|
||||
class CI_Base {
|
||||
|
||||
private static $instance;
|
||||
|
||||
public function CI_Base()
|
||||
{
|
||||
self::$instance =& $this;
|
||||
}
|
||||
|
||||
public static function &get_instance()
|
||||
{
|
||||
return self::$instance;
|
||||
}
|
||||
}
|
||||
|
||||
function &get_instance()
|
||||
{
|
||||
return CI_Base::get_instance();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* End of file Base5.php */
|
||||
/* Location: ./system/codeigniter/Base5.php */
|
||||
280
system/codeigniter/CodeIgniter.php
Normal file
280
system/codeigniter/CodeIgniter.php
Normal file
@@ -0,0 +1,280 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP 4.3.2 or newer
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2010, EllisLab, Inc.
|
||||
* @license http://codeigniter.com/user_guide/license.html
|
||||
* @link http://codeigniter.com
|
||||
* @since Version 1.0
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* System Front Controller
|
||||
*
|
||||
* Loads the base classes and executes the request.
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @subpackage codeigniter
|
||||
* @category Front-controller
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @link http://codeigniter.com/user_guide/
|
||||
*/
|
||||
|
||||
// CI Version
|
||||
define('CI_VERSION', '1.7.3');
|
||||
|
||||
/*
|
||||
* ------------------------------------------------------
|
||||
* Load the global functions
|
||||
* ------------------------------------------------------
|
||||
*/
|
||||
require(BASEPATH.'codeigniter/Common'.EXT);
|
||||
|
||||
/*
|
||||
* ------------------------------------------------------
|
||||
* Load the compatibility override functions
|
||||
* ------------------------------------------------------
|
||||
*/
|
||||
require(BASEPATH.'codeigniter/Compat'.EXT);
|
||||
|
||||
/*
|
||||
* ------------------------------------------------------
|
||||
* Load the framework constants
|
||||
* ------------------------------------------------------
|
||||
*/
|
||||
require(APPPATH.'config/constants'.EXT);
|
||||
|
||||
/*
|
||||
* ------------------------------------------------------
|
||||
* Define a custom error handler so we can log PHP errors
|
||||
* ------------------------------------------------------
|
||||
*/
|
||||
set_error_handler('_exception_handler');
|
||||
|
||||
if ( ! is_php('5.3'))
|
||||
{
|
||||
@set_magic_quotes_runtime(0); // Kill magic quotes
|
||||
}
|
||||
|
||||
/*
|
||||
* ------------------------------------------------------
|
||||
* Start the timer... tick tock tick tock...
|
||||
* ------------------------------------------------------
|
||||
*/
|
||||
|
||||
$BM =& load_class('Benchmark');
|
||||
$BM->mark('total_execution_time_start');
|
||||
$BM->mark('loading_time_base_classes_start');
|
||||
|
||||
/*
|
||||
* ------------------------------------------------------
|
||||
* Instantiate the hooks class
|
||||
* ------------------------------------------------------
|
||||
*/
|
||||
|
||||
$EXT =& load_class('Hooks');
|
||||
|
||||
/*
|
||||
* ------------------------------------------------------
|
||||
* Is there a "pre_system" hook?
|
||||
* ------------------------------------------------------
|
||||
*/
|
||||
$EXT->_call_hook('pre_system');
|
||||
|
||||
/*
|
||||
* ------------------------------------------------------
|
||||
* Instantiate the base classes
|
||||
* ------------------------------------------------------
|
||||
*/
|
||||
|
||||
$CFG =& load_class('Config');
|
||||
$URI =& load_class('URI');
|
||||
$RTR =& load_class('Router');
|
||||
$OUT =& load_class('Output');
|
||||
|
||||
/*
|
||||
* ------------------------------------------------------
|
||||
* Is there a valid cache file? If so, we're done...
|
||||
* ------------------------------------------------------
|
||||
*/
|
||||
|
||||
if ($EXT->_call_hook('cache_override') === FALSE)
|
||||
{
|
||||
if ($OUT->_display_cache($CFG, $URI) == TRUE)
|
||||
{
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* ------------------------------------------------------
|
||||
* Load the remaining base classes
|
||||
* ------------------------------------------------------
|
||||
*/
|
||||
|
||||
$IN =& load_class('Input');
|
||||
$LANG =& load_class('Language');
|
||||
|
||||
/*
|
||||
* ------------------------------------------------------
|
||||
* Load the app controller and local controller
|
||||
* ------------------------------------------------------
|
||||
*
|
||||
* Note: Due to the poor object handling in PHP 4 we'll
|
||||
* conditionally load different versions of the base
|
||||
* class. Retaining PHP 4 compatibility requires a bit of a hack.
|
||||
*
|
||||
* Note: The Loader class needs to be included first
|
||||
*
|
||||
*/
|
||||
if ( ! is_php('5.0.0'))
|
||||
{
|
||||
load_class('Loader', FALSE);
|
||||
require(BASEPATH.'codeigniter/Base4'.EXT);
|
||||
}
|
||||
else
|
||||
{
|
||||
require(BASEPATH.'codeigniter/Base5'.EXT);
|
||||
}
|
||||
|
||||
// Load the base controller class
|
||||
load_class('Controller', FALSE);
|
||||
|
||||
// Load the local application controller
|
||||
// Note: The Router class automatically validates the controller path. If this include fails it
|
||||
// means that the default controller in the Routes.php file is not resolving to something valid.
|
||||
if ( ! file_exists(APPPATH.'controllers/'.$RTR->fetch_directory().$RTR->fetch_class().EXT))
|
||||
{
|
||||
show_error('Unable to load your default controller. Please make sure the controller specified in your Routes.php file is valid.');
|
||||
}
|
||||
|
||||
include(APPPATH.'controllers/'.$RTR->fetch_directory().$RTR->fetch_class().EXT);
|
||||
|
||||
// Set a mark point for benchmarking
|
||||
$BM->mark('loading_time_base_classes_end');
|
||||
|
||||
|
||||
/*
|
||||
* ------------------------------------------------------
|
||||
* Security check
|
||||
* ------------------------------------------------------
|
||||
*
|
||||
* None of the functions in the app controller or the
|
||||
* loader class can be called via the URI, nor can
|
||||
* controller functions that begin with an underscore
|
||||
*/
|
||||
$class = $RTR->fetch_class();
|
||||
$method = $RTR->fetch_method();
|
||||
|
||||
if ( ! class_exists($class)
|
||||
OR $method == 'controller'
|
||||
OR strncmp($method, '_', 1) == 0
|
||||
OR in_array(strtolower($method), array_map('strtolower', get_class_methods('Controller')))
|
||||
)
|
||||
{
|
||||
show_404("{$class}/{$method}");
|
||||
}
|
||||
|
||||
/*
|
||||
* ------------------------------------------------------
|
||||
* Is there a "pre_controller" hook?
|
||||
* ------------------------------------------------------
|
||||
*/
|
||||
$EXT->_call_hook('pre_controller');
|
||||
|
||||
/*
|
||||
* ------------------------------------------------------
|
||||
* Instantiate the controller and call requested method
|
||||
* ------------------------------------------------------
|
||||
*/
|
||||
|
||||
// Mark a start point so we can benchmark the controller
|
||||
$BM->mark('controller_execution_time_( '.$class.' / '.$method.' )_start');
|
||||
|
||||
$CI = new $class();
|
||||
|
||||
// Is this a scaffolding request?
|
||||
if ($RTR->scaffolding_request === TRUE)
|
||||
{
|
||||
if ($EXT->_call_hook('scaffolding_override') === FALSE)
|
||||
{
|
||||
$CI->_ci_scaffolding();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
* ------------------------------------------------------
|
||||
* Is there a "post_controller_constructor" hook?
|
||||
* ------------------------------------------------------
|
||||
*/
|
||||
$EXT->_call_hook('post_controller_constructor');
|
||||
|
||||
// Is there a "remap" function?
|
||||
if (method_exists($CI, '_remap'))
|
||||
{
|
||||
$CI->_remap($method);
|
||||
}
|
||||
else
|
||||
{
|
||||
// is_callable() returns TRUE on some versions of PHP 5 for private and protected
|
||||
// methods, so we'll use this workaround for consistent behavior
|
||||
if ( ! in_array(strtolower($method), array_map('strtolower', get_class_methods($CI))))
|
||||
{
|
||||
show_404("{$class}/{$method}");
|
||||
}
|
||||
|
||||
// Call the requested method.
|
||||
// Any URI segments present (besides the class/function) will be passed to the method for convenience
|
||||
call_user_func_array(array(&$CI, $method), array_slice($URI->rsegments, 2));
|
||||
}
|
||||
}
|
||||
|
||||
// Mark a benchmark end point
|
||||
$BM->mark('controller_execution_time_( '.$class.' / '.$method.' )_end');
|
||||
|
||||
/*
|
||||
* ------------------------------------------------------
|
||||
* Is there a "post_controller" hook?
|
||||
* ------------------------------------------------------
|
||||
*/
|
||||
$EXT->_call_hook('post_controller');
|
||||
|
||||
/*
|
||||
* ------------------------------------------------------
|
||||
* Send the final rendered output to the browser
|
||||
* ------------------------------------------------------
|
||||
*/
|
||||
|
||||
if ($EXT->_call_hook('display_override') === FALSE)
|
||||
{
|
||||
$OUT->_display();
|
||||
}
|
||||
|
||||
/*
|
||||
* ------------------------------------------------------
|
||||
* Is there a "post_system" hook?
|
||||
* ------------------------------------------------------
|
||||
*/
|
||||
$EXT->_call_hook('post_system');
|
||||
|
||||
/*
|
||||
* ------------------------------------------------------
|
||||
* Close the DB connection if one exists
|
||||
* ------------------------------------------------------
|
||||
*/
|
||||
if (class_exists('CI_DB') AND isset($CI->db))
|
||||
{
|
||||
$CI->db->close();
|
||||
}
|
||||
|
||||
|
||||
/* End of file CodeIgniter.php */
|
||||
/* Location: ./system/codeigniter/CodeIgniter.php */
|
||||
421
system/codeigniter/Common.php
Normal file
421
system/codeigniter/Common.php
Normal file
@@ -0,0 +1,421 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP 4.3.2 or newer
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2010, EllisLab, Inc.
|
||||
* @license http://codeigniter.com/user_guide/license.html
|
||||
* @link http://codeigniter.com
|
||||
* @since Version 1.0
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Determines if the current version of PHP is greater then the supplied value
|
||||
*
|
||||
* Since there are a few places where we conditionally test for PHP > 5
|
||||
* we'll set a static variable.
|
||||
*
|
||||
* @access public
|
||||
* @param string
|
||||
* @return bool
|
||||
*/
|
||||
function is_php($version = '5.0.0')
|
||||
{
|
||||
static $_is_php;
|
||||
$version = (string)$version;
|
||||
|
||||
if ( ! isset($_is_php[$version]))
|
||||
{
|
||||
$_is_php[$version] = (version_compare(PHP_VERSION, $version) < 0) ? FALSE : TRUE;
|
||||
}
|
||||
|
||||
return $_is_php[$version];
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Tests for file writability
|
||||
*
|
||||
* is_writable() returns TRUE on Windows servers when you really can't write to
|
||||
* the file, based on the read-only attribute. is_writable() is also unreliable
|
||||
* on Unix servers if safe_mode is on.
|
||||
*
|
||||
* @access private
|
||||
* @return void
|
||||
*/
|
||||
function is_really_writable($file)
|
||||
{
|
||||
// If we're on a Unix server with safe_mode off we call is_writable
|
||||
if (DIRECTORY_SEPARATOR == '/' AND @ini_get("safe_mode") == FALSE)
|
||||
{
|
||||
return is_writable($file);
|
||||
}
|
||||
|
||||
// For windows servers and safe_mode "on" installations we'll actually
|
||||
// write a file then read it. Bah...
|
||||
if (is_dir($file))
|
||||
{
|
||||
$file = rtrim($file, '/').'/'.md5(rand(1,100));
|
||||
|
||||
if (($fp = @fopen($file, FOPEN_WRITE_CREATE)) === FALSE)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
fclose($fp);
|
||||
@chmod($file, DIR_WRITE_MODE);
|
||||
@unlink($file);
|
||||
return TRUE;
|
||||
}
|
||||
elseif (($fp = @fopen($file, FOPEN_WRITE_CREATE)) === FALSE)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
fclose($fp);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Class registry
|
||||
*
|
||||
* This function acts as a singleton. If the requested class does not
|
||||
* exist it is instantiated and set to a static variable. If it has
|
||||
* previously been instantiated the variable is returned.
|
||||
*
|
||||
* @access public
|
||||
* @param string the class name being requested
|
||||
* @param bool optional flag that lets classes get loaded but not instantiated
|
||||
* @return object
|
||||
*/
|
||||
function &load_class($class, $instantiate = TRUE)
|
||||
{
|
||||
static $objects = array();
|
||||
|
||||
// Does the class exist? If so, we're done...
|
||||
if (isset($objects[$class]))
|
||||
{
|
||||
return $objects[$class];
|
||||
}
|
||||
|
||||
// If the requested class does not exist in the application/libraries
|
||||
// folder we'll load the native class from the system/libraries folder.
|
||||
if (file_exists(APPPATH.'libraries/'.config_item('subclass_prefix').$class.EXT))
|
||||
{
|
||||
require(BASEPATH.'libraries/'.$class.EXT);
|
||||
require(APPPATH.'libraries/'.config_item('subclass_prefix').$class.EXT);
|
||||
$is_subclass = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (file_exists(APPPATH.'libraries/'.$class.EXT))
|
||||
{
|
||||
require(APPPATH.'libraries/'.$class.EXT);
|
||||
$is_subclass = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
require(BASEPATH.'libraries/'.$class.EXT);
|
||||
$is_subclass = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if ($instantiate == FALSE)
|
||||
{
|
||||
$objects[$class] = TRUE;
|
||||
return $objects[$class];
|
||||
}
|
||||
|
||||
if ($is_subclass == TRUE)
|
||||
{
|
||||
$name = config_item('subclass_prefix').$class;
|
||||
|
||||
$objects[$class] =& instantiate_class(new $name());
|
||||
return $objects[$class];
|
||||
}
|
||||
|
||||
$name = ($class != 'Controller') ? 'CI_'.$class : $class;
|
||||
|
||||
$objects[$class] =& instantiate_class(new $name());
|
||||
return $objects[$class];
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiate Class
|
||||
*
|
||||
* Returns a new class object by reference, used by load_class() and the DB class.
|
||||
* Required to retain PHP 4 compatibility and also not make PHP 5.3 cry.
|
||||
*
|
||||
* Use: $obj =& instantiate_class(new Foo());
|
||||
*
|
||||
* @access public
|
||||
* @param object
|
||||
* @return object
|
||||
*/
|
||||
function &instantiate_class(&$class_object)
|
||||
{
|
||||
return $class_object;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the main config.php file
|
||||
*
|
||||
* @access private
|
||||
* @return array
|
||||
*/
|
||||
function &get_config()
|
||||
{
|
||||
static $main_conf;
|
||||
|
||||
if ( ! isset($main_conf))
|
||||
{
|
||||
if ( ! file_exists(APPPATH.'config/config'.EXT))
|
||||
{
|
||||
exit('The configuration file config'.EXT.' does not exist.');
|
||||
}
|
||||
|
||||
require(APPPATH.'config/config'.EXT);
|
||||
|
||||
if ( ! isset($config) OR ! is_array($config))
|
||||
{
|
||||
exit('Your config file does not appear to be formatted correctly.');
|
||||
}
|
||||
|
||||
$main_conf[0] =& $config;
|
||||
}
|
||||
return $main_conf[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a config item
|
||||
*
|
||||
* @access public
|
||||
* @return mixed
|
||||
*/
|
||||
function config_item($item)
|
||||
{
|
||||
static $config_item = array();
|
||||
|
||||
if ( ! isset($config_item[$item]))
|
||||
{
|
||||
$config =& get_config();
|
||||
|
||||
if ( ! isset($config[$item]))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
$config_item[$item] = $config[$item];
|
||||
}
|
||||
|
||||
return $config_item[$item];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Error Handler
|
||||
*
|
||||
* This function lets us invoke the exception class and
|
||||
* display errors using the standard error template located
|
||||
* in application/errors/errors.php
|
||||
* This function will send the error page directly to the
|
||||
* browser and exit.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function show_error($message, $status_code = 500)
|
||||
{
|
||||
$error =& load_class('Exceptions');
|
||||
echo $error->show_error('An Error Was Encountered', $message, 'error_general', $status_code);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 404 Page Handler
|
||||
*
|
||||
* This function is similar to the show_error() function above
|
||||
* However, instead of the standard error template it displays
|
||||
* 404 errors.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function show_404($page = '')
|
||||
{
|
||||
$error =& load_class('Exceptions');
|
||||
$error->show_404($page);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Error Logging Interface
|
||||
*
|
||||
* We use this as a simple mechanism to access the logging
|
||||
* class and send messages to be logged.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function log_message($level = 'error', $message, $php_error = FALSE)
|
||||
{
|
||||
static $LOG;
|
||||
|
||||
$config =& get_config();
|
||||
if ($config['log_threshold'] == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$LOG =& load_class('Log');
|
||||
$LOG->write_log($level, $message, $php_error);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set HTTP Status Header
|
||||
*
|
||||
* @access public
|
||||
* @param int the status code
|
||||
* @param string
|
||||
* @return void
|
||||
*/
|
||||
function set_status_header($code = 200, $text = '')
|
||||
{
|
||||
$stati = array(
|
||||
200 => 'OK',
|
||||
201 => 'Created',
|
||||
202 => 'Accepted',
|
||||
203 => 'Non-Authoritative Information',
|
||||
204 => 'No Content',
|
||||
205 => 'Reset Content',
|
||||
206 => 'Partial Content',
|
||||
|
||||
300 => 'Multiple Choices',
|
||||
301 => 'Moved Permanently',
|
||||
302 => 'Found',
|
||||
304 => 'Not Modified',
|
||||
305 => 'Use Proxy',
|
||||
307 => 'Temporary Redirect',
|
||||
|
||||
400 => 'Bad Request',
|
||||
401 => 'Unauthorized',
|
||||
403 => 'Forbidden',
|
||||
404 => 'Not Found',
|
||||
405 => 'Method Not Allowed',
|
||||
406 => 'Not Acceptable',
|
||||
407 => 'Proxy Authentication Required',
|
||||
408 => 'Request Timeout',
|
||||
409 => 'Conflict',
|
||||
410 => 'Gone',
|
||||
411 => 'Length Required',
|
||||
412 => 'Precondition Failed',
|
||||
413 => 'Request Entity Too Large',
|
||||
414 => 'Request-URI Too Long',
|
||||
415 => 'Unsupported Media Type',
|
||||
416 => 'Requested Range Not Satisfiable',
|
||||
417 => 'Expectation Failed',
|
||||
|
||||
500 => 'Internal Server Error',
|
||||
501 => 'Not Implemented',
|
||||
502 => 'Bad Gateway',
|
||||
503 => 'Service Unavailable',
|
||||
504 => 'Gateway Timeout',
|
||||
505 => 'HTTP Version Not Supported'
|
||||
);
|
||||
|
||||
if ($code == '' OR ! is_numeric($code))
|
||||
{
|
||||
show_error('Status codes must be numeric', 500);
|
||||
}
|
||||
|
||||
if (isset($stati[$code]) AND $text == '')
|
||||
{
|
||||
$text = $stati[$code];
|
||||
}
|
||||
|
||||
if ($text == '')
|
||||
{
|
||||
show_error('No status text available. Please check your status code number or supply your own message text.', 500);
|
||||
}
|
||||
|
||||
$server_protocol = (isset($_SERVER['SERVER_PROTOCOL'])) ? $_SERVER['SERVER_PROTOCOL'] : FALSE;
|
||||
|
||||
if (substr(php_sapi_name(), 0, 3) == 'cgi')
|
||||
{
|
||||
header("Status: {$code} {$text}", TRUE);
|
||||
}
|
||||
elseif ($server_protocol == 'HTTP/1.1' OR $server_protocol == 'HTTP/1.0')
|
||||
{
|
||||
header($server_protocol." {$code} {$text}", TRUE, $code);
|
||||
}
|
||||
else
|
||||
{
|
||||
header("HTTP/1.1 {$code} {$text}", TRUE, $code);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Exception Handler
|
||||
*
|
||||
* This is the custom exception handler that is declaired at the top
|
||||
* of Codeigniter.php. The main reason we use this is permit
|
||||
* PHP errors to be logged in our own log files since we may
|
||||
* not have access to server logs. Since this function
|
||||
* effectively intercepts PHP errors, however, we also need
|
||||
* to display errors based on the current error_reporting level.
|
||||
* We do that with the use of a PHP error template.
|
||||
*
|
||||
* @access private
|
||||
* @return void
|
||||
*/
|
||||
function _exception_handler($severity, $message, $filepath, $line)
|
||||
{
|
||||
// We don't bother with "strict" notices since they will fill up
|
||||
// the log file with information that isn't normally very
|
||||
// helpful. For example, if you are running PHP 5 and you
|
||||
// use version 4 style class functions (without prefixes
|
||||
// like "public", "private", etc.) you'll get notices telling
|
||||
// you that these have been deprecated.
|
||||
|
||||
if ($severity == E_STRICT)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$error =& load_class('Exceptions');
|
||||
|
||||
// Should we display the error?
|
||||
// We'll get the current error_reporting level and add its bits
|
||||
// with the severity bits to find out.
|
||||
|
||||
if (($severity & error_reporting()) == $severity)
|
||||
{
|
||||
$error->show_php_error($severity, $message, $filepath, $line);
|
||||
}
|
||||
|
||||
// Should we log the error? No? We're done...
|
||||
$config =& get_config();
|
||||
if ($config['log_threshold'] == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$error->log_exception($severity, $message, $filepath, $line);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* End of file Common.php */
|
||||
/* Location: ./system/codeigniter/Common.php */
|
||||
93
system/codeigniter/Compat.php
Normal file
93
system/codeigniter/Compat.php
Normal file
@@ -0,0 +1,93 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP 4.3.2 or newer
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2010, EllisLab, Inc.
|
||||
* @license http://codeigniter.com/user_guide/license.html
|
||||
* @link http://codeigniter.com
|
||||
* @since Version 1.0
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Compatibility Functions
|
||||
*
|
||||
* Function overrides for older versions of PHP or PHP environments missing
|
||||
* certain extensions / libraries
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @subpackage codeigniter
|
||||
* @category Compatibility Functions
|
||||
* @author ExpressionEngine Development Team
|
||||
* @link http://codeigniter.com/user_guide/
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/*
|
||||
* PHP versions prior to 5.0 don't support the E_STRICT constant
|
||||
* so we need to explicitly define it otherwise the Exception class
|
||||
* will generate errors when running under PHP 4
|
||||
*
|
||||
*/
|
||||
if ( ! defined('E_STRICT'))
|
||||
{
|
||||
define('E_STRICT', 2048);
|
||||
}
|
||||
|
||||
/**
|
||||
* ctype_digit()
|
||||
*
|
||||
* Determines if a string is comprised only of digits
|
||||
* http://us.php.net/manual/en/function.ctype_digit.php
|
||||
*
|
||||
* @access public
|
||||
* @param string
|
||||
* @return bool
|
||||
*/
|
||||
if ( ! function_exists('ctype_digit'))
|
||||
{
|
||||
function ctype_digit($str)
|
||||
{
|
||||
if ( ! is_string($str) OR $str == '')
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return ! preg_match('/[^0-9]/', $str);
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* ctype_alnum()
|
||||
*
|
||||
* Determines if a string is comprised of only alphanumeric characters
|
||||
* http://us.php.net/manual/en/function.ctype-alnum.php
|
||||
*
|
||||
* @access public
|
||||
* @param string
|
||||
* @return bool
|
||||
*/
|
||||
if ( ! function_exists('ctype_alnum'))
|
||||
{
|
||||
function ctype_alnum($str)
|
||||
{
|
||||
if ( ! is_string($str) OR $str == '')
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return ! preg_match('/[^0-9a-z]/i', $str);
|
||||
}
|
||||
}
|
||||
|
||||
/* End of file Compat.php */
|
||||
/* Location: ./system/codeigniter/Compat.php */
|
||||
10
system/codeigniter/index.html
Normal file
10
system/codeigniter/index.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
146
system/database/DB.php
Normal file
146
system/database/DB.php
Normal file
@@ -0,0 +1,146 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP 4.3.2 or newer
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2010, EllisLab, Inc.
|
||||
* @license http://codeigniter.com/user_guide/license.html
|
||||
* @link http://codeigniter.com
|
||||
* @since Version 1.0
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Initialize the database
|
||||
*
|
||||
* @category Database
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @link http://codeigniter.com/user_guide/database/
|
||||
*/
|
||||
function &DB($params = '', $active_record_override = FALSE)
|
||||
{
|
||||
// Load the DB config file if a DSN string wasn't passed
|
||||
if (is_string($params) AND strpos($params, '://') === FALSE)
|
||||
{
|
||||
include(APPPATH.'config/database'.EXT);
|
||||
|
||||
if ( ! isset($db) OR count($db) == 0)
|
||||
{
|
||||
show_error('No database connection settings were found in the database config file.');
|
||||
}
|
||||
|
||||
if ($params != '')
|
||||
{
|
||||
$active_group = $params;
|
||||
}
|
||||
|
||||
if ( ! isset($active_group) OR ! isset($db[$active_group]))
|
||||
{
|
||||
show_error('You have specified an invalid database connection group.');
|
||||
}
|
||||
|
||||
$params = $db[$active_group];
|
||||
}
|
||||
elseif (is_string($params))
|
||||
{
|
||||
|
||||
/* parse the URL from the DSN string
|
||||
* Database settings can be passed as discreet
|
||||
* parameters or as a data source name in the first
|
||||
* parameter. DSNs must have this prototype:
|
||||
* $dsn = 'driver://username:password@hostname/database';
|
||||
*/
|
||||
|
||||
if (($dns = @parse_url($params)) === FALSE)
|
||||
{
|
||||
show_error('Invalid DB Connection String');
|
||||
}
|
||||
|
||||
$params = array(
|
||||
'dbdriver' => $dns['scheme'],
|
||||
'hostname' => (isset($dns['host'])) ? rawurldecode($dns['host']) : '',
|
||||
'username' => (isset($dns['user'])) ? rawurldecode($dns['user']) : '',
|
||||
'password' => (isset($dns['pass'])) ? rawurldecode($dns['pass']) : '',
|
||||
'database' => (isset($dns['path'])) ? rawurldecode(substr($dns['path'], 1)) : ''
|
||||
);
|
||||
|
||||
// were additional config items set?
|
||||
if (isset($dns['query']))
|
||||
{
|
||||
parse_str($dns['query'], $extra);
|
||||
|
||||
foreach($extra as $key => $val)
|
||||
{
|
||||
// booleans please
|
||||
if (strtoupper($val) == "TRUE")
|
||||
{
|
||||
$val = TRUE;
|
||||
}
|
||||
elseif (strtoupper($val) == "FALSE")
|
||||
{
|
||||
$val = FALSE;
|
||||
}
|
||||
|
||||
$params[$key] = $val;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// No DB specified yet? Beat them senseless...
|
||||
if ( ! isset($params['dbdriver']) OR $params['dbdriver'] == '')
|
||||
{
|
||||
show_error('You have not selected a database type to connect to.');
|
||||
}
|
||||
|
||||
// Load the DB classes. Note: Since the active record class is optional
|
||||
// we need to dynamically create a class that extends proper parent class
|
||||
// based on whether we're using the active record class or not.
|
||||
// Kudos to Paul for discovering this clever use of eval()
|
||||
|
||||
if ($active_record_override == TRUE)
|
||||
{
|
||||
$active_record = TRUE;
|
||||
}
|
||||
|
||||
require_once(BASEPATH.'database/DB_driver'.EXT);
|
||||
|
||||
if ( ! isset($active_record) OR $active_record == TRUE)
|
||||
{
|
||||
require_once(BASEPATH.'database/DB_active_rec'.EXT);
|
||||
|
||||
if ( ! class_exists('CI_DB'))
|
||||
{
|
||||
eval('class CI_DB extends CI_DB_active_record { }');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( ! class_exists('CI_DB'))
|
||||
{
|
||||
eval('class CI_DB extends CI_DB_driver { }');
|
||||
}
|
||||
}
|
||||
|
||||
require_once(BASEPATH.'database/drivers/'.$params['dbdriver'].'/'.$params['dbdriver'].'_driver'.EXT);
|
||||
|
||||
// Instantiate the DB adapter
|
||||
$driver = 'CI_DB_'.$params['dbdriver'].'_driver';
|
||||
$DB =& instantiate_class(new $driver($params));
|
||||
|
||||
if ($DB->autoinit == TRUE)
|
||||
{
|
||||
$DB->initialize();
|
||||
}
|
||||
|
||||
return $DB;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* End of file DB.php */
|
||||
/* Location: ./system/database/DB.php */
|
||||
1820
system/database/DB_active_rec.php
Normal file
1820
system/database/DB_active_rec.php
Normal file
File diff suppressed because it is too large
Load Diff
195
system/database/DB_cache.php
Normal file
195
system/database/DB_cache.php
Normal file
@@ -0,0 +1,195 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP 4.3.2 or newer
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2010, EllisLab, Inc.
|
||||
* @license http://codeigniter.com/user_guide/license.html
|
||||
* @link http://codeigniter.com
|
||||
* @since Version 1.0
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Database Cache Class
|
||||
*
|
||||
* @category Database
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @link http://codeigniter.com/user_guide/database/
|
||||
*/
|
||||
class CI_DB_Cache {
|
||||
|
||||
var $CI;
|
||||
var $db; // allows passing of db object so that multiple database connections and returned db objects can be supported
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* Grabs the CI super object instance so we can access it.
|
||||
*
|
||||
*/
|
||||
function CI_DB_Cache(&$db)
|
||||
{
|
||||
// Assign the main CI object to $this->CI
|
||||
// and load the file helper since we use it a lot
|
||||
$this->CI =& get_instance();
|
||||
$this->db =& $db;
|
||||
$this->CI->load->helper('file');
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Set Cache Directory Path
|
||||
*
|
||||
* @access public
|
||||
* @param string the path to the cache directory
|
||||
* @return bool
|
||||
*/
|
||||
function check_path($path = '')
|
||||
{
|
||||
if ($path == '')
|
||||
{
|
||||
if ($this->db->cachedir == '')
|
||||
{
|
||||
return $this->db->cache_off();
|
||||
}
|
||||
|
||||
$path = $this->db->cachedir;
|
||||
}
|
||||
|
||||
// Add a trailing slash to the path if needed
|
||||
$path = preg_replace("/(.+?)\/*$/", "\\1/", $path);
|
||||
|
||||
if ( ! is_dir($path) OR ! is_really_writable($path))
|
||||
{
|
||||
// If the path is wrong we'll turn off caching
|
||||
return $this->db->cache_off();
|
||||
}
|
||||
|
||||
$this->db->cachedir = $path;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Retrieve a cached query
|
||||
*
|
||||
* The URI being requested will become the name of the cache sub-folder.
|
||||
* An MD5 hash of the SQL statement will become the cache file name
|
||||
*
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
function read($sql)
|
||||
{
|
||||
if ( ! $this->check_path())
|
||||
{
|
||||
return $this->db->cache_off();
|
||||
}
|
||||
|
||||
$segment_one = ($this->CI->uri->segment(1) == FALSE) ? 'default' : $this->CI->uri->segment(1);
|
||||
|
||||
$segment_two = ($this->CI->uri->segment(2) == FALSE) ? 'index' : $this->CI->uri->segment(2);
|
||||
|
||||
$filepath = $this->db->cachedir.$segment_one.'+'.$segment_two.'/'.md5($sql);
|
||||
|
||||
if (FALSE === ($cachedata = read_file($filepath)))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return unserialize($cachedata);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Write a query to a cache file
|
||||
*
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
function write($sql, $object)
|
||||
{
|
||||
if ( ! $this->check_path())
|
||||
{
|
||||
return $this->db->cache_off();
|
||||
}
|
||||
|
||||
$segment_one = ($this->CI->uri->segment(1) == FALSE) ? 'default' : $this->CI->uri->segment(1);
|
||||
|
||||
$segment_two = ($this->CI->uri->segment(2) == FALSE) ? 'index' : $this->CI->uri->segment(2);
|
||||
|
||||
$dir_path = $this->db->cachedir.$segment_one.'+'.$segment_two.'/';
|
||||
|
||||
$filename = md5($sql);
|
||||
|
||||
if ( ! @is_dir($dir_path))
|
||||
{
|
||||
if ( ! @mkdir($dir_path, DIR_WRITE_MODE))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@chmod($dir_path, DIR_WRITE_MODE);
|
||||
}
|
||||
|
||||
if (write_file($dir_path.$filename, serialize($object)) === FALSE)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@chmod($dir_path.$filename, DIR_WRITE_MODE);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Delete cache files within a particular directory
|
||||
*
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
function delete($segment_one = '', $segment_two = '')
|
||||
{
|
||||
if ($segment_one == '')
|
||||
{
|
||||
$segment_one = ($this->CI->uri->segment(1) == FALSE) ? 'default' : $this->CI->uri->segment(1);
|
||||
}
|
||||
|
||||
if ($segment_two == '')
|
||||
{
|
||||
$segment_two = ($this->CI->uri->segment(2) == FALSE) ? 'index' : $this->CI->uri->segment(2);
|
||||
}
|
||||
|
||||
$dir_path = $this->db->cachedir.$segment_one.'+'.$segment_two.'/';
|
||||
|
||||
delete_files($dir_path, TRUE);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Delete all existing cache files
|
||||
*
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
function delete_all()
|
||||
{
|
||||
delete_files($this->db->cachedir, TRUE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* End of file DB_cache.php */
|
||||
/* Location: ./system/database/DB_cache.php */
|
||||
1366
system/database/DB_driver.php
Normal file
1366
system/database/DB_driver.php
Normal file
File diff suppressed because it is too large
Load Diff
375
system/database/DB_forge.php
Normal file
375
system/database/DB_forge.php
Normal file
@@ -0,0 +1,375 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/**
|
||||
* Code Igniter
|
||||
*
|
||||
* An open source application development framework for PHP 4.3.2 or newer
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2010, EllisLab, Inc.
|
||||
* @license http://codeigniter.com/user_guide/license.html
|
||||
* @link http://codeigniter.com
|
||||
* @since Version 1.0
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Database Utility Class
|
||||
*
|
||||
* @category Database
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @link http://codeigniter.com/user_guide/database/
|
||||
*/
|
||||
class CI_DB_forge {
|
||||
|
||||
var $fields = array();
|
||||
var $keys = array();
|
||||
var $primary_keys = array();
|
||||
var $db_char_set = '';
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* Grabs the CI super object instance so we can access it.
|
||||
*
|
||||
*/
|
||||
function CI_DB_forge()
|
||||
{
|
||||
// Assign the main database object to $this->db
|
||||
$CI =& get_instance();
|
||||
$this->db =& $CI->db;
|
||||
log_message('debug', "Database Forge Class Initialized");
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Create database
|
||||
*
|
||||
* @access public
|
||||
* @param string the database name
|
||||
* @return bool
|
||||
*/
|
||||
function create_database($db_name)
|
||||
{
|
||||
$sql = $this->_create_database($db_name);
|
||||
|
||||
if (is_bool($sql))
|
||||
{
|
||||
return $sql;
|
||||
}
|
||||
|
||||
return $this->db->query($sql);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Drop database
|
||||
*
|
||||
* @access public
|
||||
* @param string the database name
|
||||
* @return bool
|
||||
*/
|
||||
function drop_database($db_name)
|
||||
{
|
||||
$sql = $this->_drop_database($db_name);
|
||||
|
||||
if (is_bool($sql))
|
||||
{
|
||||
return $sql;
|
||||
}
|
||||
|
||||
return $this->db->query($sql);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Add Key
|
||||
*
|
||||
* @access public
|
||||
* @param string key
|
||||
* @param string type
|
||||
* @return void
|
||||
*/
|
||||
function add_key($key = '', $primary = FALSE)
|
||||
{
|
||||
if (is_array($key))
|
||||
{
|
||||
foreach($key as $one)
|
||||
{
|
||||
$this->add_key($one, $primary);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ($key == '')
|
||||
{
|
||||
show_error('Key information is required for that operation.');
|
||||
}
|
||||
|
||||
if ($primary === TRUE)
|
||||
{
|
||||
$this->primary_keys[] = $key;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->keys[] = $key;
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Add Field
|
||||
*
|
||||
* @access public
|
||||
* @param string collation
|
||||
* @return void
|
||||
*/
|
||||
function add_field($field = '')
|
||||
{
|
||||
if ($field == '')
|
||||
{
|
||||
show_error('Field information is required.');
|
||||
}
|
||||
|
||||
if (is_string($field))
|
||||
{
|
||||
if ($field == 'id')
|
||||
{
|
||||
$this->add_field(array(
|
||||
'id' => array(
|
||||
'type' => 'INT',
|
||||
'constraint' => 9,
|
||||
'auto_increment' => TRUE
|
||||
)
|
||||
));
|
||||
$this->add_key('id', TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (strpos($field, ' ') === FALSE)
|
||||
{
|
||||
show_error('Field information is required for that operation.');
|
||||
}
|
||||
|
||||
$this->fields[] = $field;
|
||||
}
|
||||
}
|
||||
|
||||
if (is_array($field))
|
||||
{
|
||||
$this->fields = array_merge($this->fields, $field);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Create Table
|
||||
*
|
||||
* @access public
|
||||
* @param string the table name
|
||||
* @return bool
|
||||
*/
|
||||
function create_table($table = '', $if_not_exists = FALSE)
|
||||
{
|
||||
if ($table == '')
|
||||
{
|
||||
show_error('A table name is required for that operation.');
|
||||
}
|
||||
|
||||
if (count($this->fields) == 0)
|
||||
{
|
||||
show_error('Field information is required.');
|
||||
}
|
||||
|
||||
$sql = $this->_create_table($this->db->dbprefix.$table, $this->fields, $this->primary_keys, $this->keys, $if_not_exists);
|
||||
|
||||
$this->_reset();
|
||||
return $this->db->query($sql);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Drop Table
|
||||
*
|
||||
* @access public
|
||||
* @param string the table name
|
||||
* @return bool
|
||||
*/
|
||||
function drop_table($table_name)
|
||||
{
|
||||
$sql = $this->_drop_table($this->db->dbprefix.$table_name);
|
||||
|
||||
if (is_bool($sql))
|
||||
{
|
||||
return $sql;
|
||||
}
|
||||
|
||||
return $this->db->query($sql);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Rename Table
|
||||
*
|
||||
* @access public
|
||||
* @param string the old table name
|
||||
* @param string the new table name
|
||||
* @return bool
|
||||
*/
|
||||
function rename_table($table_name, $new_table_name)
|
||||
{
|
||||
if ($table_name == '' OR $new_table_name == '')
|
||||
{
|
||||
show_error('A table name is required for that operation.');
|
||||
}
|
||||
|
||||
$sql = $this->_rename_table($table_name, $new_table_name);
|
||||
return $this->db->query($sql);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Column Add
|
||||
*
|
||||
* @access public
|
||||
* @param string the table name
|
||||
* @param string the column name
|
||||
* @param string the column definition
|
||||
* @return bool
|
||||
*/
|
||||
function add_column($table = '', $field = array(), $after_field = '')
|
||||
{
|
||||
if ($table == '')
|
||||
{
|
||||
show_error('A table name is required for that operation.');
|
||||
}
|
||||
|
||||
// add field info into field array, but we can only do one at a time
|
||||
// so we cycle through
|
||||
|
||||
foreach ($field as $k => $v)
|
||||
{
|
||||
$this->add_field(array($k => $field[$k]));
|
||||
|
||||
if (count($this->fields) == 0)
|
||||
{
|
||||
show_error('Field information is required.');
|
||||
}
|
||||
|
||||
$sql = $this->_alter_table('ADD', $this->db->dbprefix.$table, $this->fields, $after_field);
|
||||
|
||||
$this->_reset();
|
||||
|
||||
if ($this->db->query($sql) === FALSE)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Column Drop
|
||||
*
|
||||
* @access public
|
||||
* @param string the table name
|
||||
* @param string the column name
|
||||
* @return bool
|
||||
*/
|
||||
function drop_column($table = '', $column_name = '')
|
||||
{
|
||||
|
||||
if ($table == '')
|
||||
{
|
||||
show_error('A table name is required for that operation.');
|
||||
}
|
||||
|
||||
if ($column_name == '')
|
||||
{
|
||||
show_error('A column name is required for that operation.');
|
||||
}
|
||||
|
||||
$sql = $this->_alter_table('DROP', $this->db->dbprefix.$table, $column_name);
|
||||
|
||||
return $this->db->query($sql);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Column Modify
|
||||
*
|
||||
* @access public
|
||||
* @param string the table name
|
||||
* @param string the column name
|
||||
* @param string the column definition
|
||||
* @return bool
|
||||
*/
|
||||
function modify_column($table = '', $field = array())
|
||||
{
|
||||
if ($table == '')
|
||||
{
|
||||
show_error('A table name is required for that operation.');
|
||||
}
|
||||
|
||||
// add field info into field array, but we can only do one at a time
|
||||
// so we cycle through
|
||||
|
||||
foreach ($field as $k => $v)
|
||||
{
|
||||
$this->add_field(array($k => $field[$k]));
|
||||
|
||||
if (count($this->fields) == 0)
|
||||
{
|
||||
show_error('Field information is required.');
|
||||
}
|
||||
|
||||
$sql = $this->_alter_table('CHANGE', $this->db->dbprefix.$table, $this->fields);
|
||||
|
||||
$this->_reset();
|
||||
|
||||
if ($this->db->query($sql) === FALSE)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Reset
|
||||
*
|
||||
* Resets table creation vars
|
||||
*
|
||||
* @access private
|
||||
* @return void
|
||||
*/
|
||||
function _reset()
|
||||
{
|
||||
$this->fields = array();
|
||||
$this->keys = array();
|
||||
$this->primary_keys = array();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* End of file DB_forge.php */
|
||||
/* Location: ./system/database/DB_forge.php */
|
||||
342
system/database/DB_result.php
Normal file
342
system/database/DB_result.php
Normal file
@@ -0,0 +1,342 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP 4.3.2 or newer
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2010, EllisLab, Inc.
|
||||
* @license http://codeigniter.com/user_guide/license.html
|
||||
* @link http://codeigniter.com
|
||||
* @since Version 1.0
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Database Result Class
|
||||
*
|
||||
* This is the platform-independent result class.
|
||||
* This class will not be called directly. Rather, the adapter
|
||||
* class for the specific database will extend and instantiate it.
|
||||
*
|
||||
* @category Database
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @link http://codeigniter.com/user_guide/database/
|
||||
*/
|
||||
class CI_DB_result {
|
||||
|
||||
var $conn_id = NULL;
|
||||
var $result_id = NULL;
|
||||
var $result_array = array();
|
||||
var $result_object = array();
|
||||
var $current_row = 0;
|
||||
var $num_rows = 0;
|
||||
var $row_data = NULL;
|
||||
|
||||
|
||||
/**
|
||||
* Query result. Acts as a wrapper function for the following functions.
|
||||
*
|
||||
* @access public
|
||||
* @param string can be "object" or "array"
|
||||
* @return mixed either a result object or array
|
||||
*/
|
||||
function result($type = 'object')
|
||||
{
|
||||
return ($type == 'object') ? $this->result_object() : $this->result_array();
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Query result. "object" version.
|
||||
*
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
function result_object()
|
||||
{
|
||||
if (count($this->result_object) > 0)
|
||||
{
|
||||
return $this->result_object;
|
||||
}
|
||||
|
||||
// In the event that query caching is on the result_id variable
|
||||
// will return FALSE since there isn't a valid SQL resource so
|
||||
// we'll simply return an empty array.
|
||||
if ($this->result_id === FALSE OR $this->num_rows() == 0)
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
$this->_data_seek(0);
|
||||
while ($row = $this->_fetch_object())
|
||||
{
|
||||
$this->result_object[] = $row;
|
||||
}
|
||||
|
||||
return $this->result_object;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Query result. "array" version.
|
||||
*
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
function result_array()
|
||||
{
|
||||
if (count($this->result_array) > 0)
|
||||
{
|
||||
return $this->result_array;
|
||||
}
|
||||
|
||||
// In the event that query caching is on the result_id variable
|
||||
// will return FALSE since there isn't a valid SQL resource so
|
||||
// we'll simply return an empty array.
|
||||
if ($this->result_id === FALSE OR $this->num_rows() == 0)
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
$this->_data_seek(0);
|
||||
while ($row = $this->_fetch_assoc())
|
||||
{
|
||||
$this->result_array[] = $row;
|
||||
}
|
||||
|
||||
return $this->result_array;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Query result. Acts as a wrapper function for the following functions.
|
||||
*
|
||||
* @access public
|
||||
* @param string
|
||||
* @param string can be "object" or "array"
|
||||
* @return mixed either a result object or array
|
||||
*/
|
||||
function row($n = 0, $type = 'object')
|
||||
{
|
||||
if ( ! is_numeric($n))
|
||||
{
|
||||
// We cache the row data for subsequent uses
|
||||
if ( ! is_array($this->row_data))
|
||||
{
|
||||
$this->row_data = $this->row_array(0);
|
||||
}
|
||||
|
||||
// array_key_exists() instead of isset() to allow for MySQL NULL values
|
||||
if (array_key_exists($n, $this->row_data))
|
||||
{
|
||||
return $this->row_data[$n];
|
||||
}
|
||||
// reset the $n variable if the result was not achieved
|
||||
$n = 0;
|
||||
}
|
||||
|
||||
return ($type == 'object') ? $this->row_object($n) : $this->row_array($n);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Assigns an item into a particular column slot
|
||||
*
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
function set_row($key, $value = NULL)
|
||||
{
|
||||
// We cache the row data for subsequent uses
|
||||
if ( ! is_array($this->row_data))
|
||||
{
|
||||
$this->row_data = $this->row_array(0);
|
||||
}
|
||||
|
||||
if (is_array($key))
|
||||
{
|
||||
foreach ($key as $k => $v)
|
||||
{
|
||||
$this->row_data[$k] = $v;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ($key != '' AND ! is_null($value))
|
||||
{
|
||||
$this->row_data[$key] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns a single result row - object version
|
||||
*
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
function row_object($n = 0)
|
||||
{
|
||||
$result = $this->result_object();
|
||||
|
||||
if (count($result) == 0)
|
||||
{
|
||||
return $result;
|
||||
}
|
||||
|
||||
if ($n != $this->current_row AND isset($result[$n]))
|
||||
{
|
||||
$this->current_row = $n;
|
||||
}
|
||||
|
||||
return $result[$this->current_row];
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns a single result row - array version
|
||||
*
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
function row_array($n = 0)
|
||||
{
|
||||
$result = $this->result_array();
|
||||
|
||||
if (count($result) == 0)
|
||||
{
|
||||
return $result;
|
||||
}
|
||||
|
||||
if ($n != $this->current_row AND isset($result[$n]))
|
||||
{
|
||||
$this->current_row = $n;
|
||||
}
|
||||
|
||||
return $result[$this->current_row];
|
||||
}
|
||||
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns the "first" row
|
||||
*
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
function first_row($type = 'object')
|
||||
{
|
||||
$result = $this->result($type);
|
||||
|
||||
if (count($result) == 0)
|
||||
{
|
||||
return $result;
|
||||
}
|
||||
return $result[0];
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns the "last" row
|
||||
*
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
function last_row($type = 'object')
|
||||
{
|
||||
$result = $this->result($type);
|
||||
|
||||
if (count($result) == 0)
|
||||
{
|
||||
return $result;
|
||||
}
|
||||
return $result[count($result) -1];
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns the "next" row
|
||||
*
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
function next_row($type = 'object')
|
||||
{
|
||||
$result = $this->result($type);
|
||||
|
||||
if (count($result) == 0)
|
||||
{
|
||||
return $result;
|
||||
}
|
||||
|
||||
if (isset($result[$this->current_row + 1]))
|
||||
{
|
||||
++$this->current_row;
|
||||
}
|
||||
|
||||
return $result[$this->current_row];
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns the "previous" row
|
||||
*
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
function previous_row($type = 'object')
|
||||
{
|
||||
$result = $this->result($type);
|
||||
|
||||
if (count($result) == 0)
|
||||
{
|
||||
return $result;
|
||||
}
|
||||
|
||||
if (isset($result[$this->current_row - 1]))
|
||||
{
|
||||
--$this->current_row;
|
||||
}
|
||||
return $result[$this->current_row];
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* The following functions are normally overloaded by the identically named
|
||||
* methods in the platform-specific driver -- except when query caching
|
||||
* is used. When caching is enabled we do not load the other driver.
|
||||
* These functions are primarily here to prevent undefined function errors
|
||||
* when a cached result object is in use. They are not otherwise fully
|
||||
* operational due to the unavailability of the database resource IDs with
|
||||
* cached results.
|
||||
*/
|
||||
function num_rows() { return $this->num_rows; }
|
||||
function num_fields() { return 0; }
|
||||
function list_fields() { return array(); }
|
||||
function field_data() { return array(); }
|
||||
function free_result() { return TRUE; }
|
||||
function _data_seek() { return TRUE; }
|
||||
function _fetch_assoc() { return array(); }
|
||||
function _fetch_object() { return array(); }
|
||||
|
||||
}
|
||||
// END DB_result class
|
||||
|
||||
/* End of file DB_result.php */
|
||||
/* Location: ./system/database/DB_result.php */
|
||||
389
system/database/DB_utility.php
Normal file
389
system/database/DB_utility.php
Normal file
@@ -0,0 +1,389 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/**
|
||||
* Code Igniter
|
||||
*
|
||||
* An open source application development framework for PHP 4.3.2 or newer
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2010, EllisLab, Inc.
|
||||
* @license http://codeigniter.com/user_guide/license.html
|
||||
* @link http://codeigniter.com
|
||||
* @since Version 1.0
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Database Utility Class
|
||||
*
|
||||
* @category Database
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @link http://codeigniter.com/user_guide/database/
|
||||
*/
|
||||
class CI_DB_utility extends CI_DB_forge {
|
||||
|
||||
var $db;
|
||||
var $data_cache = array();
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* Grabs the CI super object instance so we can access it.
|
||||
*
|
||||
*/
|
||||
function CI_DB_utility()
|
||||
{
|
||||
// Assign the main database object to $this->db
|
||||
$CI =& get_instance();
|
||||
$this->db =& $CI->db;
|
||||
|
||||
log_message('debug', "Database Utility Class Initialized");
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* List databases
|
||||
*
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
function list_databases()
|
||||
{
|
||||
// Is there a cached result?
|
||||
if (isset($this->data_cache['db_names']))
|
||||
{
|
||||
return $this->data_cache['db_names'];
|
||||
}
|
||||
|
||||
$query = $this->db->query($this->_list_databases());
|
||||
$dbs = array();
|
||||
if ($query->num_rows() > 0)
|
||||
{
|
||||
foreach ($query->result_array() as $row)
|
||||
{
|
||||
$dbs[] = current($row);
|
||||
}
|
||||
}
|
||||
|
||||
$this->data_cache['db_names'] = $dbs;
|
||||
return $this->data_cache['db_names'];
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Optimize Table
|
||||
*
|
||||
* @access public
|
||||
* @param string the table name
|
||||
* @return bool
|
||||
*/
|
||||
function optimize_table($table_name)
|
||||
{
|
||||
$sql = $this->_optimize_table($table_name);
|
||||
|
||||
if (is_bool($sql))
|
||||
{
|
||||
show_error('db_must_use_set');
|
||||
}
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
$res = $query->result_array();
|
||||
|
||||
// Note: Due to a bug in current() that affects some versions
|
||||
// of PHP we can not pass function call directly into it
|
||||
return current($res);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Optimize Database
|
||||
*
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
function optimize_database()
|
||||
{
|
||||
$result = array();
|
||||
foreach ($this->db->list_tables() as $table_name)
|
||||
{
|
||||
$sql = $this->_optimize_table($table_name);
|
||||
|
||||
if (is_bool($sql))
|
||||
{
|
||||
return $sql;
|
||||
}
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
// Build the result array...
|
||||
// Note: Due to a bug in current() that affects some versions
|
||||
// of PHP we can not pass function call directly into it
|
||||
$res = $query->result_array();
|
||||
$res = current($res);
|
||||
$key = str_replace($this->db->database.'.', '', current($res));
|
||||
$keys = array_keys($res);
|
||||
unset($res[$keys[0]]);
|
||||
|
||||
$result[$key] = $res;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Repair Table
|
||||
*
|
||||
* @access public
|
||||
* @param string the table name
|
||||
* @return bool
|
||||
*/
|
||||
function repair_table($table_name)
|
||||
{
|
||||
$sql = $this->_repair_table($table_name);
|
||||
|
||||
if (is_bool($sql))
|
||||
{
|
||||
return $sql;
|
||||
}
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
// Note: Due to a bug in current() that affects some versions
|
||||
// of PHP we can not pass function call directly into it
|
||||
$res = $query->result_array();
|
||||
return current($res);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Generate CSV from a query result object
|
||||
*
|
||||
* @access public
|
||||
* @param object The query result object
|
||||
* @param string The delimiter - comma by default
|
||||
* @param string The newline character - \n by default
|
||||
* @param string The enclosure - double quote by default
|
||||
* @return string
|
||||
*/
|
||||
function csv_from_result($query, $delim = ",", $newline = "\n", $enclosure = '"')
|
||||
{
|
||||
if ( ! is_object($query) OR ! method_exists($query, 'list_fields'))
|
||||
{
|
||||
show_error('You must submit a valid result object');
|
||||
}
|
||||
|
||||
$out = '';
|
||||
|
||||
// First generate the headings from the table column names
|
||||
foreach ($query->list_fields() as $name)
|
||||
{
|
||||
$out .= $enclosure.str_replace($enclosure, $enclosure.$enclosure, $name).$enclosure.$delim;
|
||||
}
|
||||
|
||||
$out = rtrim($out);
|
||||
$out .= $newline;
|
||||
|
||||
// Next blast through the result array and build out the rows
|
||||
foreach ($query->result_array() as $row)
|
||||
{
|
||||
foreach ($row as $item)
|
||||
{
|
||||
$out .= $enclosure.str_replace($enclosure, $enclosure.$enclosure, $item).$enclosure.$delim;
|
||||
}
|
||||
$out = rtrim($out);
|
||||
$out .= $newline;
|
||||
}
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Generate XML data from a query result object
|
||||
*
|
||||
* @access public
|
||||
* @param object The query result object
|
||||
* @param array Any preferences
|
||||
* @return string
|
||||
*/
|
||||
function xml_from_result($query, $params = array())
|
||||
{
|
||||
if ( ! is_object($query) OR ! method_exists($query, 'list_fields'))
|
||||
{
|
||||
show_error('You must submit a valid result object');
|
||||
}
|
||||
|
||||
// Set our default values
|
||||
foreach (array('root' => 'root', 'element' => 'element', 'newline' => "\n", 'tab' => "\t") as $key => $val)
|
||||
{
|
||||
if ( ! isset($params[$key]))
|
||||
{
|
||||
$params[$key] = $val;
|
||||
}
|
||||
}
|
||||
|
||||
// Create variables for convenience
|
||||
extract($params);
|
||||
|
||||
// Load the xml helper
|
||||
$CI =& get_instance();
|
||||
$CI->load->helper('xml');
|
||||
|
||||
// Generate the result
|
||||
$xml = "<{$root}>".$newline;
|
||||
foreach ($query->result_array() as $row)
|
||||
{
|
||||
$xml .= $tab."<{$element}>".$newline;
|
||||
|
||||
foreach ($row as $key => $val)
|
||||
{
|
||||
$xml .= $tab.$tab."<{$key}>".xml_convert($val)."</{$key}>".$newline;
|
||||
}
|
||||
$xml .= $tab."</{$element}>".$newline;
|
||||
}
|
||||
$xml .= "</$root>".$newline;
|
||||
|
||||
return $xml;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Database Backup
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function backup($params = array())
|
||||
{
|
||||
// If the parameters have not been submitted as an
|
||||
// array then we know that it is simply the table
|
||||
// name, which is a valid short cut.
|
||||
if (is_string($params))
|
||||
{
|
||||
$params = array('tables' => $params);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------
|
||||
|
||||
// Set up our default preferences
|
||||
$prefs = array(
|
||||
'tables' => array(),
|
||||
'ignore' => array(),
|
||||
'filename' => '',
|
||||
'format' => 'gzip', // gzip, zip, txt
|
||||
'add_drop' => TRUE,
|
||||
'add_insert' => TRUE,
|
||||
'newline' => "\n"
|
||||
);
|
||||
|
||||
// Did the user submit any preferences? If so set them....
|
||||
if (count($params) > 0)
|
||||
{
|
||||
foreach ($prefs as $key => $val)
|
||||
{
|
||||
if (isset($params[$key]))
|
||||
{
|
||||
$prefs[$key] = $params[$key];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------
|
||||
|
||||
// Are we backing up a complete database or individual tables?
|
||||
// If no table names were submitted we'll fetch the entire table list
|
||||
if (count($prefs['tables']) == 0)
|
||||
{
|
||||
$prefs['tables'] = $this->db->list_tables();
|
||||
}
|
||||
|
||||
// ------------------------------------------------------
|
||||
|
||||
// Validate the format
|
||||
if ( ! in_array($prefs['format'], array('gzip', 'zip', 'txt'), TRUE))
|
||||
{
|
||||
$prefs['format'] = 'txt';
|
||||
}
|
||||
|
||||
// ------------------------------------------------------
|
||||
|
||||
// Is the encoder supported? If not, we'll either issue an
|
||||
// error or use plain text depending on the debug settings
|
||||
if (($prefs['format'] == 'gzip' AND ! @function_exists('gzencode'))
|
||||
OR ($prefs['format'] == 'zip' AND ! @function_exists('gzcompress')))
|
||||
{
|
||||
if ($this->db->db_debug)
|
||||
{
|
||||
return $this->db->display_error('db_unsuported_compression');
|
||||
}
|
||||
|
||||
$prefs['format'] = 'txt';
|
||||
}
|
||||
|
||||
// ------------------------------------------------------
|
||||
|
||||
// Set the filename if not provided - Only needed with Zip files
|
||||
if ($prefs['filename'] == '' AND $prefs['format'] == 'zip')
|
||||
{
|
||||
$prefs['filename'] = (count($prefs['tables']) == 1) ? $prefs['tables'] : $this->db->database;
|
||||
$prefs['filename'] .= '_'.date('Y-m-d_H-i', time());
|
||||
}
|
||||
|
||||
// ------------------------------------------------------
|
||||
|
||||
// Was a Gzip file requested?
|
||||
if ($prefs['format'] == 'gzip')
|
||||
{
|
||||
return gzencode($this->_backup($prefs));
|
||||
}
|
||||
|
||||
// ------------------------------------------------------
|
||||
|
||||
// Was a text file requested?
|
||||
if ($prefs['format'] == 'txt')
|
||||
{
|
||||
return $this->_backup($prefs);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------
|
||||
|
||||
// Was a Zip file requested?
|
||||
if ($prefs['format'] == 'zip')
|
||||
{
|
||||
// If they included the .zip file extension we'll remove it
|
||||
if (preg_match("|.+?\.zip$|", $prefs['filename']))
|
||||
{
|
||||
$prefs['filename'] = str_replace('.zip', '', $prefs['filename']);
|
||||
}
|
||||
|
||||
// Tack on the ".sql" file extension if needed
|
||||
if ( ! preg_match("|.+?\.sql$|", $prefs['filename']))
|
||||
{
|
||||
$prefs['filename'] .= '.sql';
|
||||
}
|
||||
|
||||
// Load the Zip class and output it
|
||||
|
||||
$CI =& get_instance();
|
||||
$CI->load->library('zip');
|
||||
$CI->zip->add_data($prefs['filename'], $this->_backup($prefs));
|
||||
return $CI->zip->get_zip();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* End of file DB_utility.php */
|
||||
/* Location: ./system/database/DB_utility.php */
|
||||
10
system/database/drivers/index.html
Normal file
10
system/database/drivers/index.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
10
system/database/drivers/mssql/index.html
Normal file
10
system/database/drivers/mssql/index.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
667
system/database/drivers/mssql/mssql_driver.php
Normal file
667
system/database/drivers/mssql/mssql_driver.php
Normal file
@@ -0,0 +1,667 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP 4.3.2 or newer
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2010, EllisLab, Inc.
|
||||
* @license http://codeigniter.com/user_guide/license.html
|
||||
* @link http://codeigniter.com
|
||||
* @since Version 1.0
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* MS SQL Database Adapter Class
|
||||
*
|
||||
* Note: _DB is an extender class that the app controller
|
||||
* creates dynamically based on whether the active record
|
||||
* class is being used or not.
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @subpackage Drivers
|
||||
* @category Database
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @link http://codeigniter.com/user_guide/database/
|
||||
*/
|
||||
class CI_DB_mssql_driver extends CI_DB {
|
||||
|
||||
var $dbdriver = 'mssql';
|
||||
|
||||
// The character used for escaping
|
||||
var $_escape_char = '';
|
||||
|
||||
// clause and character used for LIKE escape sequences
|
||||
var $_like_escape_str = " ESCAPE '%s' ";
|
||||
var $_like_escape_chr = '!';
|
||||
|
||||
/**
|
||||
* The syntax to count rows is slightly different across different
|
||||
* database engines, so this string appears in each driver and is
|
||||
* used for the count_all() and count_all_results() functions.
|
||||
*/
|
||||
var $_count_string = "SELECT COUNT(*) AS ";
|
||||
var $_random_keyword = ' ASC'; // not currently supported
|
||||
|
||||
/**
|
||||
* Non-persistent database connection
|
||||
*
|
||||
* @access private called by the base class
|
||||
* @return resource
|
||||
*/
|
||||
function db_connect()
|
||||
{
|
||||
if ($this->port != '')
|
||||
{
|
||||
$this->hostname .= ','.$this->port;
|
||||
}
|
||||
|
||||
return @mssql_connect($this->hostname, $this->username, $this->password);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Persistent database connection
|
||||
*
|
||||
* @access private called by the base class
|
||||
* @return resource
|
||||
*/
|
||||
function db_pconnect()
|
||||
{
|
||||
if ($this->port != '')
|
||||
{
|
||||
$this->hostname .= ','.$this->port;
|
||||
}
|
||||
|
||||
return @mssql_pconnect($this->hostname, $this->username, $this->password);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Reconnect
|
||||
*
|
||||
* Keep / reestablish the db connection if no queries have been
|
||||
* sent for a length of time exceeding the server's idle timeout
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function reconnect()
|
||||
{
|
||||
// not implemented in MSSQL
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Select the database
|
||||
*
|
||||
* @access private called by the base class
|
||||
* @return resource
|
||||
*/
|
||||
function db_select()
|
||||
{
|
||||
// Note: The brackets are required in the event that the DB name
|
||||
// contains reserved characters
|
||||
return @mssql_select_db('['.$this->database.']', $this->conn_id);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Set client character set
|
||||
*
|
||||
* @access public
|
||||
* @param string
|
||||
* @param string
|
||||
* @return resource
|
||||
*/
|
||||
function db_set_charset($charset, $collation)
|
||||
{
|
||||
// @todo - add support if needed
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Execute the query
|
||||
*
|
||||
* @access private called by the base class
|
||||
* @param string an SQL query
|
||||
* @return resource
|
||||
*/
|
||||
function _execute($sql)
|
||||
{
|
||||
$sql = $this->_prep_query($sql);
|
||||
return @mssql_query($sql, $this->conn_id);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Prep the query
|
||||
*
|
||||
* If needed, each database adapter can prep the query string
|
||||
*
|
||||
* @access private called by execute()
|
||||
* @param string an SQL query
|
||||
* @return string
|
||||
*/
|
||||
function _prep_query($sql)
|
||||
{
|
||||
return $sql;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Begin Transaction
|
||||
*
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
function trans_begin($test_mode = FALSE)
|
||||
{
|
||||
if ( ! $this->trans_enabled)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// When transactions are nested we only begin/commit/rollback the outermost ones
|
||||
if ($this->_trans_depth > 0)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// Reset the transaction failure flag.
|
||||
// If the $test_mode flag is set to TRUE transactions will be rolled back
|
||||
// even if the queries produce a successful result.
|
||||
$this->_trans_failure = ($test_mode === TRUE) ? TRUE : FALSE;
|
||||
|
||||
$this->simple_query('BEGIN TRAN');
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Commit Transaction
|
||||
*
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
function trans_commit()
|
||||
{
|
||||
if ( ! $this->trans_enabled)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// When transactions are nested we only begin/commit/rollback the outermost ones
|
||||
if ($this->_trans_depth > 0)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
$this->simple_query('COMMIT TRAN');
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Rollback Transaction
|
||||
*
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
function trans_rollback()
|
||||
{
|
||||
if ( ! $this->trans_enabled)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// When transactions are nested we only begin/commit/rollback the outermost ones
|
||||
if ($this->_trans_depth > 0)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
$this->simple_query('ROLLBACK TRAN');
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Escape String
|
||||
*
|
||||
* @access public
|
||||
* @param string
|
||||
* @param bool whether or not the string will be used in a LIKE condition
|
||||
* @return string
|
||||
*/
|
||||
function escape_str($str, $like = FALSE)
|
||||
{
|
||||
if (is_array($str))
|
||||
{
|
||||
foreach($str as $key => $val)
|
||||
{
|
||||
$str[$key] = $this->escape_str($val, $like);
|
||||
}
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
// Access the CI object
|
||||
$CI =& get_instance();
|
||||
|
||||
// Escape single quotes
|
||||
$str = str_replace("'", "''", $CI->input->_remove_invisible_characters($str));
|
||||
|
||||
// escape LIKE condition wildcards
|
||||
if ($like === TRUE)
|
||||
{
|
||||
$str = str_replace( array('%', '_', $this->_like_escape_chr),
|
||||
array($this->_like_escape_chr.'%', $this->_like_escape_chr.'_', $this->_like_escape_chr.$this->_like_escape_chr),
|
||||
$str);
|
||||
}
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Affected Rows
|
||||
*
|
||||
* @access public
|
||||
* @return integer
|
||||
*/
|
||||
function affected_rows()
|
||||
{
|
||||
return @mssql_rows_affected($this->conn_id);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Insert ID
|
||||
*
|
||||
* Returns the last id created in the Identity column.
|
||||
*
|
||||
* @access public
|
||||
* @return integer
|
||||
*/
|
||||
function insert_id()
|
||||
{
|
||||
$ver = self::_parse_major_version($this->version());
|
||||
$sql = ($ver >= 8 ? "SELECT SCOPE_IDENTITY() AS last_id" : "SELECT @@IDENTITY AS last_id");
|
||||
$query = $this->query($sql);
|
||||
$row = $query->row();
|
||||
return $row->last_id;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Parse major version
|
||||
*
|
||||
* Grabs the major version number from the
|
||||
* database server version string passed in.
|
||||
*
|
||||
* @access private
|
||||
* @param string $version
|
||||
* @return int16 major version number
|
||||
*/
|
||||
function _parse_major_version($version)
|
||||
{
|
||||
preg_match('/([0-9]+)\.([0-9]+)\.([0-9]+)/', $version, $ver_info);
|
||||
return $ver_info[1]; // return the major version b/c that's all we're interested in.
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Version number query string
|
||||
*
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
function _version()
|
||||
{
|
||||
return "SELECT @@VERSION AS ver";
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* "Count All" query
|
||||
*
|
||||
* Generates a platform-specific query string that counts all records in
|
||||
* the specified database
|
||||
*
|
||||
* @access public
|
||||
* @param string
|
||||
* @return string
|
||||
*/
|
||||
function count_all($table = '')
|
||||
{
|
||||
if ($table == '')
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
$query = $this->query($this->_count_string . $this->_protect_identifiers('numrows') . " FROM " . $this->_protect_identifiers($table, TRUE, NULL, FALSE));
|
||||
|
||||
if ($query->num_rows() == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
$row = $query->row();
|
||||
return (int) $row->numrows;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* List table query
|
||||
*
|
||||
* Generates a platform-specific query string so that the table names can be fetched
|
||||
*
|
||||
* @access private
|
||||
* @param boolean
|
||||
* @return string
|
||||
*/
|
||||
function _list_tables($prefix_limit = FALSE)
|
||||
{
|
||||
$sql = "SELECT name FROM sysobjects WHERE type = 'U' ORDER BY name";
|
||||
|
||||
// for future compatibility
|
||||
if ($prefix_limit !== FALSE AND $this->dbprefix != '')
|
||||
{
|
||||
//$sql .= " LIKE '".$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_char);
|
||||
return FALSE; // not currently supported
|
||||
}
|
||||
|
||||
return $sql;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* List column query
|
||||
*
|
||||
* Generates a platform-specific query string so that the column names can be fetched
|
||||
*
|
||||
* @access private
|
||||
* @param string the table name
|
||||
* @return string
|
||||
*/
|
||||
function _list_columns($table = '')
|
||||
{
|
||||
return "SELECT * FROM INFORMATION_SCHEMA.Columns WHERE TABLE_NAME = '".$table."'";
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Field data query
|
||||
*
|
||||
* Generates a platform-specific query so that the column data can be retrieved
|
||||
*
|
||||
* @access public
|
||||
* @param string the table name
|
||||
* @return object
|
||||
*/
|
||||
function _field_data($table)
|
||||
{
|
||||
return "SELECT TOP 1 * FROM ".$table;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* The error message string
|
||||
*
|
||||
* @access private
|
||||
* @return string
|
||||
*/
|
||||
function _error_message()
|
||||
{
|
||||
return mssql_get_last_message();
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* The error message number
|
||||
*
|
||||
* @access private
|
||||
* @return integer
|
||||
*/
|
||||
function _error_number()
|
||||
{
|
||||
// Are error numbers supported?
|
||||
return '';
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Escape the SQL Identifiers
|
||||
*
|
||||
* This function escapes column and table names
|
||||
*
|
||||
* @access private
|
||||
* @param string
|
||||
* @return string
|
||||
*/
|
||||
function _escape_identifiers($item)
|
||||
{
|
||||
if ($this->_escape_char == '')
|
||||
{
|
||||
return $item;
|
||||
}
|
||||
|
||||
foreach ($this->_reserved_identifiers as $id)
|
||||
{
|
||||
if (strpos($item, '.'.$id) !== FALSE)
|
||||
{
|
||||
$str = $this->_escape_char. str_replace('.', $this->_escape_char.'.', $item);
|
||||
|
||||
// remove duplicates if the user already included the escape
|
||||
return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str);
|
||||
}
|
||||
}
|
||||
|
||||
if (strpos($item, '.') !== FALSE)
|
||||
{
|
||||
$str = $this->_escape_char.str_replace('.', $this->_escape_char.'.'.$this->_escape_char, $item).$this->_escape_char;
|
||||
}
|
||||
else
|
||||
{
|
||||
$str = $this->_escape_char.$item.$this->_escape_char;
|
||||
}
|
||||
|
||||
// remove duplicates if the user already included the escape
|
||||
return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* From Tables
|
||||
*
|
||||
* This function implicitly groups FROM tables so there is no confusion
|
||||
* about operator precedence in harmony with SQL standards
|
||||
*
|
||||
* @access public
|
||||
* @param type
|
||||
* @return type
|
||||
*/
|
||||
function _from_tables($tables)
|
||||
{
|
||||
if ( ! is_array($tables))
|
||||
{
|
||||
$tables = array($tables);
|
||||
}
|
||||
|
||||
return implode(', ', $tables);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Insert statement
|
||||
*
|
||||
* Generates a platform-specific insert string from the supplied data
|
||||
*
|
||||
* @access public
|
||||
* @param string the table name
|
||||
* @param array the insert keys
|
||||
* @param array the insert values
|
||||
* @return string
|
||||
*/
|
||||
function _insert($table, $keys, $values)
|
||||
{
|
||||
return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")";
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Update statement
|
||||
*
|
||||
* Generates a platform-specific update string from the supplied data
|
||||
*
|
||||
* @access public
|
||||
* @param string the table name
|
||||
* @param array the update data
|
||||
* @param array the where clause
|
||||
* @param array the orderby clause
|
||||
* @param array the limit clause
|
||||
* @return string
|
||||
*/
|
||||
function _update($table, $values, $where, $orderby = array(), $limit = FALSE)
|
||||
{
|
||||
foreach($values as $key => $val)
|
||||
{
|
||||
$valstr[] = $key." = ".$val;
|
||||
}
|
||||
|
||||
$limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
|
||||
|
||||
$orderby = (count($orderby) >= 1)?' ORDER BY '.implode(", ", $orderby):'';
|
||||
|
||||
$sql = "UPDATE ".$table." SET ".implode(', ', $valstr);
|
||||
|
||||
$sql .= ($where != '' AND count($where) >=1) ? " WHERE ".implode(" ", $where) : '';
|
||||
|
||||
$sql .= $orderby.$limit;
|
||||
|
||||
return $sql;
|
||||
}
|
||||
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Truncate statement
|
||||
*
|
||||
* Generates a platform-specific truncate string from the supplied data
|
||||
* If the database does not support the truncate() command
|
||||
* This function maps to "DELETE FROM table"
|
||||
*
|
||||
* @access public
|
||||
* @param string the table name
|
||||
* @return string
|
||||
*/
|
||||
function _truncate($table)
|
||||
{
|
||||
return "TRUNCATE ".$table;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Delete statement
|
||||
*
|
||||
* Generates a platform-specific delete string from the supplied data
|
||||
*
|
||||
* @access public
|
||||
* @param string the table name
|
||||
* @param array the where clause
|
||||
* @param string the limit clause
|
||||
* @return string
|
||||
*/
|
||||
function _delete($table, $where = array(), $like = array(), $limit = FALSE)
|
||||
{
|
||||
$conditions = '';
|
||||
|
||||
if (count($where) > 0 OR count($like) > 0)
|
||||
{
|
||||
$conditions = "\nWHERE ";
|
||||
$conditions .= implode("\n", $this->ar_where);
|
||||
|
||||
if (count($where) > 0 && count($like) > 0)
|
||||
{
|
||||
$conditions .= " AND ";
|
||||
}
|
||||
$conditions .= implode("\n", $like);
|
||||
}
|
||||
|
||||
$limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
|
||||
|
||||
return "DELETE FROM ".$table.$conditions.$limit;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Limit string
|
||||
*
|
||||
* Generates a platform-specific LIMIT clause
|
||||
*
|
||||
* @access public
|
||||
* @param string the sql query string
|
||||
* @param integer the number of rows to limit the query to
|
||||
* @param integer the offset value
|
||||
* @return string
|
||||
*/
|
||||
function _limit($sql, $limit, $offset)
|
||||
{
|
||||
$i = $limit + $offset;
|
||||
|
||||
return preg_replace('/(^\SELECT (DISTINCT)?)/i','\\1 TOP '.$i.' ', $sql);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Close DB Connection
|
||||
*
|
||||
* @access public
|
||||
* @param resource
|
||||
* @return void
|
||||
*/
|
||||
function _close($conn_id)
|
||||
{
|
||||
@mssql_close($conn_id);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* End of file mssql_driver.php */
|
||||
/* Location: ./system/database/drivers/mssql/mssql_driver.php */
|
||||
248
system/database/drivers/mssql/mssql_forge.php
Normal file
248
system/database/drivers/mssql/mssql_forge.php
Normal file
@@ -0,0 +1,248 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP 4.3.2 or newer
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2010, EllisLab, Inc.
|
||||
* @license http://codeigniter.com/user_guide/license.html
|
||||
* @link http://codeigniter.com
|
||||
* @since Version 1.0
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* MS SQL Forge Class
|
||||
*
|
||||
* @category Database
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @link http://codeigniter.com/user_guide/database/
|
||||
*/
|
||||
class CI_DB_mssql_forge extends CI_DB_forge {
|
||||
|
||||
/**
|
||||
* Create database
|
||||
*
|
||||
* @access private
|
||||
* @param string the database name
|
||||
* @return bool
|
||||
*/
|
||||
function _create_database($name)
|
||||
{
|
||||
return "CREATE DATABASE ".$name;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Drop database
|
||||
*
|
||||
* @access private
|
||||
* @param string the database name
|
||||
* @return bool
|
||||
*/
|
||||
function _drop_database($name)
|
||||
{
|
||||
return "DROP DATABASE ".$name;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Drop Table
|
||||
*
|
||||
* @access private
|
||||
* @return bool
|
||||
*/
|
||||
function _drop_table($table)
|
||||
{
|
||||
return "DROP TABLE ".$this->db->_escape_identifiers($table);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Create Table
|
||||
*
|
||||
* @access private
|
||||
* @param string the table name
|
||||
* @param array the fields
|
||||
* @param mixed primary key(s)
|
||||
* @param mixed key(s)
|
||||
* @param boolean should 'IF NOT EXISTS' be added to the SQL
|
||||
* @return bool
|
||||
*/
|
||||
function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists)
|
||||
{
|
||||
$sql = 'CREATE TABLE ';
|
||||
|
||||
if ($if_not_exists === TRUE)
|
||||
{
|
||||
$sql .= 'IF NOT EXISTS ';
|
||||
}
|
||||
|
||||
$sql .= $this->db->_escape_identifiers($table)." (";
|
||||
$current_field_count = 0;
|
||||
|
||||
foreach ($fields as $field=>$attributes)
|
||||
{
|
||||
// Numeric field names aren't allowed in databases, so if the key is
|
||||
// numeric, we know it was assigned by PHP and the developer manually
|
||||
// entered the field information, so we'll simply add it to the list
|
||||
if (is_numeric($field))
|
||||
{
|
||||
$sql .= "\n\t$attributes";
|
||||
}
|
||||
else
|
||||
{
|
||||
$attributes = array_change_key_case($attributes, CASE_UPPER);
|
||||
|
||||
$sql .= "\n\t".$this->db->_protect_identifiers($field);
|
||||
|
||||
$sql .= ' '.$attributes['TYPE'];
|
||||
|
||||
if (array_key_exists('CONSTRAINT', $attributes))
|
||||
{
|
||||
$sql .= '('.$attributes['CONSTRAINT'].')';
|
||||
}
|
||||
|
||||
if (array_key_exists('UNSIGNED', $attributes) && $attributes['UNSIGNED'] === TRUE)
|
||||
{
|
||||
$sql .= ' UNSIGNED';
|
||||
}
|
||||
|
||||
if (array_key_exists('DEFAULT', $attributes))
|
||||
{
|
||||
$sql .= ' DEFAULT \''.$attributes['DEFAULT'].'\'';
|
||||
}
|
||||
|
||||
if (array_key_exists('NULL', $attributes) && $attributes['NULL'] === TRUE)
|
||||
{
|
||||
$sql .= ' NULL';
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql .= ' NOT NULL';
|
||||
}
|
||||
|
||||
if (array_key_exists('AUTO_INCREMENT', $attributes) && $attributes['AUTO_INCREMENT'] === TRUE)
|
||||
{
|
||||
$sql .= ' AUTO_INCREMENT';
|
||||
}
|
||||
}
|
||||
|
||||
// don't add a comma on the end of the last field
|
||||
if (++$current_field_count < count($fields))
|
||||
{
|
||||
$sql .= ',';
|
||||
}
|
||||
}
|
||||
|
||||
if (count($primary_keys) > 0)
|
||||
{
|
||||
$primary_keys = $this->db->_protect_identifiers($primary_keys);
|
||||
$sql .= ",\n\tPRIMARY KEY (" . implode(', ', $primary_keys) . ")";
|
||||
}
|
||||
|
||||
if (is_array($keys) && count($keys) > 0)
|
||||
{
|
||||
foreach ($keys as $key)
|
||||
{
|
||||
if (is_array($key))
|
||||
{
|
||||
$key = $this->db->_protect_identifiers($key);
|
||||
}
|
||||
else
|
||||
{
|
||||
$key = array($this->db->_protect_identifiers($key));
|
||||
}
|
||||
|
||||
$sql .= ",\n\tFOREIGN KEY (" . implode(', ', $key) . ")";
|
||||
}
|
||||
}
|
||||
|
||||
$sql .= "\n)";
|
||||
|
||||
return $sql;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Alter table query
|
||||
*
|
||||
* Generates a platform-specific query so that a table can be altered
|
||||
* Called by add_column(), drop_column(), and column_alter(),
|
||||
*
|
||||
* @access private
|
||||
* @param string the ALTER type (ADD, DROP, CHANGE)
|
||||
* @param string the column name
|
||||
* @param string the table name
|
||||
* @param string the column definition
|
||||
* @param string the default value
|
||||
* @param boolean should 'NOT NULL' be added
|
||||
* @param string the field after which we should add the new field
|
||||
* @return object
|
||||
*/
|
||||
function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '')
|
||||
{
|
||||
$sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table)." $alter_type ".$this->db->_protect_identifiers($column_name);
|
||||
|
||||
// DROP has everything it needs now.
|
||||
if ($alter_type == 'DROP')
|
||||
{
|
||||
return $sql;
|
||||
}
|
||||
|
||||
$sql .= " $column_definition";
|
||||
|
||||
if ($default_value != '')
|
||||
{
|
||||
$sql .= " DEFAULT \"$default_value\"";
|
||||
}
|
||||
|
||||
if ($null === NULL)
|
||||
{
|
||||
$sql .= ' NULL';
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql .= ' NOT NULL';
|
||||
}
|
||||
|
||||
if ($after_field != '')
|
||||
{
|
||||
$sql .= ' AFTER ' . $this->db->_protect_identifiers($after_field);
|
||||
}
|
||||
|
||||
return $sql;
|
||||
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Rename a table
|
||||
*
|
||||
* Generates a platform-specific query so that a table can be renamed
|
||||
*
|
||||
* @access private
|
||||
* @param string the old table name
|
||||
* @param string the new table name
|
||||
* @return string
|
||||
*/
|
||||
function _rename_table($table_name, $new_table_name)
|
||||
{
|
||||
// I think this syntax will work, but can find little documentation on renaming tables in MSSQL
|
||||
$sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table_name)." RENAME TO ".$this->db->_protect_identifiers($new_table_name);
|
||||
return $sql;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* End of file mssql_forge.php */
|
||||
/* Location: ./system/database/drivers/mssql/mssql_forge.php */
|
||||
169
system/database/drivers/mssql/mssql_result.php
Normal file
169
system/database/drivers/mssql/mssql_result.php
Normal file
@@ -0,0 +1,169 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP 4.3.2 or newer
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2010, EllisLab, Inc.
|
||||
* @license http://codeigniter.com/user_guide/license.html
|
||||
* @link http://codeigniter.com
|
||||
* @since Version 1.0
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* MS SQL Result Class
|
||||
*
|
||||
* This class extends the parent result class: CI_DB_result
|
||||
*
|
||||
* @category Database
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @link http://codeigniter.com/user_guide/database/
|
||||
*/
|
||||
class CI_DB_mssql_result extends CI_DB_result {
|
||||
|
||||
/**
|
||||
* Number of rows in the result set
|
||||
*
|
||||
* @access public
|
||||
* @return integer
|
||||
*/
|
||||
function num_rows()
|
||||
{
|
||||
return @mssql_num_rows($this->result_id);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Number of fields in the result set
|
||||
*
|
||||
* @access public
|
||||
* @return integer
|
||||
*/
|
||||
function num_fields()
|
||||
{
|
||||
return @mssql_num_fields($this->result_id);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Fetch Field Names
|
||||
*
|
||||
* Generates an array of column names
|
||||
*
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
function list_fields()
|
||||
{
|
||||
$field_names = array();
|
||||
while ($field = mssql_fetch_field($this->result_id))
|
||||
{
|
||||
$field_names[] = $field->name;
|
||||
}
|
||||
|
||||
return $field_names;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Field data
|
||||
*
|
||||
* Generates an array of objects containing field meta-data
|
||||
*
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
function field_data()
|
||||
{
|
||||
$retval = array();
|
||||
while ($field = mssql_fetch_field($this->result_id))
|
||||
{
|
||||
$F = new stdClass();
|
||||
$F->name = $field->name;
|
||||
$F->type = $field->type;
|
||||
$F->max_length = $field->max_length;
|
||||
$F->primary_key = 0;
|
||||
$F->default = '';
|
||||
|
||||
$retval[] = $F;
|
||||
}
|
||||
|
||||
return $retval;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Free the result
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
function free_result()
|
||||
{
|
||||
if (is_resource($this->result_id))
|
||||
{
|
||||
mssql_free_result($this->result_id);
|
||||
$this->result_id = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Data Seek
|
||||
*
|
||||
* Moves the internal pointer to the desired offset. We call
|
||||
* this internally before fetching results to make sure the
|
||||
* result set starts at zero
|
||||
*
|
||||
* @access private
|
||||
* @return array
|
||||
*/
|
||||
function _data_seek($n = 0)
|
||||
{
|
||||
return mssql_data_seek($this->result_id, $n);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Result - associative array
|
||||
*
|
||||
* Returns the result set as an array
|
||||
*
|
||||
* @access private
|
||||
* @return array
|
||||
*/
|
||||
function _fetch_assoc()
|
||||
{
|
||||
return mssql_fetch_assoc($this->result_id);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Result - object
|
||||
*
|
||||
* Returns the result set as an object
|
||||
*
|
||||
* @access private
|
||||
* @return object
|
||||
*/
|
||||
function _fetch_object()
|
||||
{
|
||||
return mssql_fetch_object($this->result_id);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* End of file mssql_result.php */
|
||||
/* Location: ./system/database/drivers/mssql/mssql_result.php */
|
||||
123
system/database/drivers/mssql/mssql_utility.php
Normal file
123
system/database/drivers/mssql/mssql_utility.php
Normal file
@@ -0,0 +1,123 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP 4.3.2 or newer
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2010, EllisLab, Inc.
|
||||
* @license http://codeigniter.com/user_guide/license.html
|
||||
* @link http://codeigniter.com
|
||||
* @since Version 1.0
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* MS SQL Utility Class
|
||||
*
|
||||
* @category Database
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @link http://codeigniter.com/user_guide/database/
|
||||
*/
|
||||
class CI_DB_mssql_utility extends CI_DB_utility {
|
||||
|
||||
/**
|
||||
* List databases
|
||||
*
|
||||
* @access private
|
||||
* @return bool
|
||||
*/
|
||||
function _list_databases()
|
||||
{
|
||||
return "EXEC sp_helpdb"; // Can also be: EXEC sp_databases
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Optimize table query
|
||||
*
|
||||
* Generates a platform-specific query so that a table can be optimized
|
||||
*
|
||||
* @access private
|
||||
* @param string the table name
|
||||
* @return object
|
||||
*/
|
||||
function _optimize_table($table)
|
||||
{
|
||||
return FALSE; // Is this supported in MS SQL?
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Repair table query
|
||||
*
|
||||
* Generates a platform-specific query so that a table can be repaired
|
||||
*
|
||||
* @access private
|
||||
* @param string the table name
|
||||
* @return object
|
||||
*/
|
||||
function _repair_table($table)
|
||||
{
|
||||
return FALSE; // Is this supported in MS SQL?
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* MSSQL Export
|
||||
*
|
||||
* @access private
|
||||
* @param array Preferences
|
||||
* @return mixed
|
||||
*/
|
||||
function _backup($params = array())
|
||||
{
|
||||
// Currently unsupported
|
||||
return $this->db->display_error('db_unsuported_feature');
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* The functions below have been deprecated as of 1.6, and are only here for backwards
|
||||
* compatibility. They now reside in dbforge(). The use of dbutils for database manipulation
|
||||
* is STRONGLY discouraged in favour if using dbforge.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Create database
|
||||
*
|
||||
* @access private
|
||||
* @param string the database name
|
||||
* @return bool
|
||||
*/
|
||||
function _create_database($name)
|
||||
{
|
||||
return "CREATE DATABASE ".$name;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Drop database
|
||||
*
|
||||
* @access private
|
||||
* @param string the database name
|
||||
* @return bool
|
||||
*/
|
||||
function _drop_database($name)
|
||||
{
|
||||
return "DROP DATABASE ".$name;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* End of file mssql_utility.php */
|
||||
/* Location: ./system/database/drivers/mssql/mssql_utility.php */
|
||||
10
system/database/drivers/mysql/index.html
Normal file
10
system/database/drivers/mysql/index.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
670
system/database/drivers/mysql/mysql_driver.php
Normal file
670
system/database/drivers/mysql/mysql_driver.php
Normal file
@@ -0,0 +1,670 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP 4.3.2 or newer
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2010, EllisLab, Inc.
|
||||
* @license http://codeigniter.com/user_guide/license.html
|
||||
* @link http://codeigniter.com
|
||||
* @since Version 1.0
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* MySQL Database Adapter Class
|
||||
*
|
||||
* Note: _DB is an extender class that the app controller
|
||||
* creates dynamically based on whether the active record
|
||||
* class is being used or not.
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @subpackage Drivers
|
||||
* @category Database
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @link http://codeigniter.com/user_guide/database/
|
||||
*/
|
||||
class CI_DB_mysql_driver extends CI_DB {
|
||||
|
||||
var $dbdriver = 'mysql';
|
||||
|
||||
// The character used for escaping
|
||||
var $_escape_char = '`';
|
||||
|
||||
// clause and character used for LIKE escape sequences - not used in MySQL
|
||||
var $_like_escape_str = '';
|
||||
var $_like_escape_chr = '';
|
||||
|
||||
/**
|
||||
* Whether to use the MySQL "delete hack" which allows the number
|
||||
* of affected rows to be shown. Uses a preg_replace when enabled,
|
||||
* adding a bit more processing to all queries.
|
||||
*/
|
||||
var $delete_hack = TRUE;
|
||||
|
||||
/**
|
||||
* The syntax to count rows is slightly different across different
|
||||
* database engines, so this string appears in each driver and is
|
||||
* used for the count_all() and count_all_results() functions.
|
||||
*/
|
||||
var $_count_string = 'SELECT COUNT(*) AS ';
|
||||
var $_random_keyword = ' RAND()'; // database specific random keyword
|
||||
|
||||
/**
|
||||
* Non-persistent database connection
|
||||
*
|
||||
* @access private called by the base class
|
||||
* @return resource
|
||||
*/
|
||||
function db_connect()
|
||||
{
|
||||
if ($this->port != '')
|
||||
{
|
||||
$this->hostname .= ':'.$this->port;
|
||||
}
|
||||
|
||||
return @mysql_connect($this->hostname, $this->username, $this->password, TRUE);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Persistent database connection
|
||||
*
|
||||
* @access private called by the base class
|
||||
* @return resource
|
||||
*/
|
||||
function db_pconnect()
|
||||
{
|
||||
if ($this->port != '')
|
||||
{
|
||||
$this->hostname .= ':'.$this->port;
|
||||
}
|
||||
|
||||
return @mysql_pconnect($this->hostname, $this->username, $this->password);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Reconnect
|
||||
*
|
||||
* Keep / reestablish the db connection if no queries have been
|
||||
* sent for a length of time exceeding the server's idle timeout
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function reconnect()
|
||||
{
|
||||
if (mysql_ping($this->conn_id) === FALSE)
|
||||
{
|
||||
$this->conn_id = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Select the database
|
||||
*
|
||||
* @access private called by the base class
|
||||
* @return resource
|
||||
*/
|
||||
function db_select()
|
||||
{
|
||||
return @mysql_select_db($this->database, $this->conn_id);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Set client character set
|
||||
*
|
||||
* @access public
|
||||
* @param string
|
||||
* @param string
|
||||
* @return resource
|
||||
*/
|
||||
function db_set_charset($charset, $collation)
|
||||
{
|
||||
return @mysql_query("SET NAMES '".$this->escape_str($charset)."' COLLATE '".$this->escape_str($collation)."'", $this->conn_id);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Version number query string
|
||||
*
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
function _version()
|
||||
{
|
||||
return "SELECT version() AS ver";
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Execute the query
|
||||
*
|
||||
* @access private called by the base class
|
||||
* @param string an SQL query
|
||||
* @return resource
|
||||
*/
|
||||
function _execute($sql)
|
||||
{
|
||||
$sql = $this->_prep_query($sql);
|
||||
return @mysql_query($sql, $this->conn_id);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Prep the query
|
||||
*
|
||||
* If needed, each database adapter can prep the query string
|
||||
*
|
||||
* @access private called by execute()
|
||||
* @param string an SQL query
|
||||
* @return string
|
||||
*/
|
||||
function _prep_query($sql)
|
||||
{
|
||||
// "DELETE FROM TABLE" returns 0 affected rows This hack modifies
|
||||
// the query so that it returns the number of affected rows
|
||||
if ($this->delete_hack === TRUE)
|
||||
{
|
||||
if (preg_match('/^\s*DELETE\s+FROM\s+(\S+)\s*$/i', $sql))
|
||||
{
|
||||
$sql = preg_replace("/^\s*DELETE\s+FROM\s+(\S+)\s*$/", "DELETE FROM \\1 WHERE 1=1", $sql);
|
||||
}
|
||||
}
|
||||
|
||||
return $sql;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Begin Transaction
|
||||
*
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
function trans_begin($test_mode = FALSE)
|
||||
{
|
||||
if ( ! $this->trans_enabled)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// When transactions are nested we only begin/commit/rollback the outermost ones
|
||||
if ($this->_trans_depth > 0)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// Reset the transaction failure flag.
|
||||
// If the $test_mode flag is set to TRUE transactions will be rolled back
|
||||
// even if the queries produce a successful result.
|
||||
$this->_trans_failure = ($test_mode === TRUE) ? TRUE : FALSE;
|
||||
|
||||
$this->simple_query('SET AUTOCOMMIT=0');
|
||||
$this->simple_query('START TRANSACTION'); // can also be BEGIN or BEGIN WORK
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Commit Transaction
|
||||
*
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
function trans_commit()
|
||||
{
|
||||
if ( ! $this->trans_enabled)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// When transactions are nested we only begin/commit/rollback the outermost ones
|
||||
if ($this->_trans_depth > 0)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
$this->simple_query('COMMIT');
|
||||
$this->simple_query('SET AUTOCOMMIT=1');
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Rollback Transaction
|
||||
*
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
function trans_rollback()
|
||||
{
|
||||
if ( ! $this->trans_enabled)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// When transactions are nested we only begin/commit/rollback the outermost ones
|
||||
if ($this->_trans_depth > 0)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
$this->simple_query('ROLLBACK');
|
||||
$this->simple_query('SET AUTOCOMMIT=1');
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Escape String
|
||||
*
|
||||
* @access public
|
||||
* @param string
|
||||
* @param bool whether or not the string will be used in a LIKE condition
|
||||
* @return string
|
||||
*/
|
||||
function escape_str($str, $like = FALSE)
|
||||
{
|
||||
if (is_array($str))
|
||||
{
|
||||
foreach($str as $key => $val)
|
||||
{
|
||||
$str[$key] = $this->escape_str($val, $like);
|
||||
}
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
if (function_exists('mysql_real_escape_string') AND is_resource($this->conn_id))
|
||||
{
|
||||
$str = mysql_real_escape_string($str, $this->conn_id);
|
||||
}
|
||||
elseif (function_exists('mysql_escape_string'))
|
||||
{
|
||||
$str = mysql_escape_string($str);
|
||||
}
|
||||
else
|
||||
{
|
||||
$str = addslashes($str);
|
||||
}
|
||||
|
||||
// escape LIKE condition wildcards
|
||||
if ($like === TRUE)
|
||||
{
|
||||
$str = str_replace(array('%', '_'), array('\\%', '\\_'), $str);
|
||||
}
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Affected Rows
|
||||
*
|
||||
* @access public
|
||||
* @return integer
|
||||
*/
|
||||
function affected_rows()
|
||||
{
|
||||
return @mysql_affected_rows($this->conn_id);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Insert ID
|
||||
*
|
||||
* @access public
|
||||
* @return integer
|
||||
*/
|
||||
function insert_id()
|
||||
{
|
||||
return @mysql_insert_id($this->conn_id);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* "Count All" query
|
||||
*
|
||||
* Generates a platform-specific query string that counts all records in
|
||||
* the specified database
|
||||
*
|
||||
* @access public
|
||||
* @param string
|
||||
* @return string
|
||||
*/
|
||||
function count_all($table = '')
|
||||
{
|
||||
if ($table == '')
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
$query = $this->query($this->_count_string . $this->_protect_identifiers('numrows') . " FROM " . $this->_protect_identifiers($table, TRUE, NULL, FALSE));
|
||||
|
||||
if ($query->num_rows() == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
$row = $query->row();
|
||||
return (int) $row->numrows;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* List table query
|
||||
*
|
||||
* Generates a platform-specific query string so that the table names can be fetched
|
||||
*
|
||||
* @access private
|
||||
* @param boolean
|
||||
* @return string
|
||||
*/
|
||||
function _list_tables($prefix_limit = FALSE)
|
||||
{
|
||||
$sql = "SHOW TABLES FROM ".$this->_escape_char.$this->database.$this->_escape_char;
|
||||
|
||||
if ($prefix_limit !== FALSE AND $this->dbprefix != '')
|
||||
{
|
||||
$sql .= " LIKE '".$this->escape_like_str($this->dbprefix)."%'";
|
||||
}
|
||||
|
||||
return $sql;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Show column query
|
||||
*
|
||||
* Generates a platform-specific query string so that the column names can be fetched
|
||||
*
|
||||
* @access public
|
||||
* @param string the table name
|
||||
* @return string
|
||||
*/
|
||||
function _list_columns($table = '')
|
||||
{
|
||||
return "SHOW COLUMNS FROM ".$table;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Field data query
|
||||
*
|
||||
* Generates a platform-specific query so that the column data can be retrieved
|
||||
*
|
||||
* @access public
|
||||
* @param string the table name
|
||||
* @return object
|
||||
*/
|
||||
function _field_data($table)
|
||||
{
|
||||
return "SELECT * FROM ".$table." LIMIT 1";
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* The error message string
|
||||
*
|
||||
* @access private
|
||||
* @return string
|
||||
*/
|
||||
function _error_message()
|
||||
{
|
||||
return mysql_error($this->conn_id);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* The error message number
|
||||
*
|
||||
* @access private
|
||||
* @return integer
|
||||
*/
|
||||
function _error_number()
|
||||
{
|
||||
return mysql_errno($this->conn_id);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Escape the SQL Identifiers
|
||||
*
|
||||
* This function escapes column and table names
|
||||
*
|
||||
* @access private
|
||||
* @param string
|
||||
* @return string
|
||||
*/
|
||||
function _escape_identifiers($item)
|
||||
{
|
||||
if ($this->_escape_char == '')
|
||||
{
|
||||
return $item;
|
||||
}
|
||||
|
||||
foreach ($this->_reserved_identifiers as $id)
|
||||
{
|
||||
if (strpos($item, '.'.$id) !== FALSE)
|
||||
{
|
||||
$str = $this->_escape_char. str_replace('.', $this->_escape_char.'.', $item);
|
||||
|
||||
// remove duplicates if the user already included the escape
|
||||
return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str);
|
||||
}
|
||||
}
|
||||
|
||||
if (strpos($item, '.') !== FALSE)
|
||||
{
|
||||
$str = $this->_escape_char.str_replace('.', $this->_escape_char.'.'.$this->_escape_char, $item).$this->_escape_char;
|
||||
}
|
||||
else
|
||||
{
|
||||
$str = $this->_escape_char.$item.$this->_escape_char;
|
||||
}
|
||||
|
||||
// remove duplicates if the user already included the escape
|
||||
return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* From Tables
|
||||
*
|
||||
* This function implicitly groups FROM tables so there is no confusion
|
||||
* about operator precedence in harmony with SQL standards
|
||||
*
|
||||
* @access public
|
||||
* @param type
|
||||
* @return type
|
||||
*/
|
||||
function _from_tables($tables)
|
||||
{
|
||||
if ( ! is_array($tables))
|
||||
{
|
||||
$tables = array($tables);
|
||||
}
|
||||
|
||||
return '('.implode(', ', $tables).')';
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Insert statement
|
||||
*
|
||||
* Generates a platform-specific insert string from the supplied data
|
||||
*
|
||||
* @access public
|
||||
* @param string the table name
|
||||
* @param array the insert keys
|
||||
* @param array the insert values
|
||||
* @return string
|
||||
*/
|
||||
function _insert($table, $keys, $values)
|
||||
{
|
||||
return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")";
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Update statement
|
||||
*
|
||||
* Generates a platform-specific update string from the supplied data
|
||||
*
|
||||
* @access public
|
||||
* @param string the table name
|
||||
* @param array the update data
|
||||
* @param array the where clause
|
||||
* @param array the orderby clause
|
||||
* @param array the limit clause
|
||||
* @return string
|
||||
*/
|
||||
function _update($table, $values, $where, $orderby = array(), $limit = FALSE)
|
||||
{
|
||||
foreach($values as $key => $val)
|
||||
{
|
||||
$valstr[] = $key." = ".$val;
|
||||
}
|
||||
|
||||
$limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
|
||||
|
||||
$orderby = (count($orderby) >= 1)?' ORDER BY '.implode(", ", $orderby):'';
|
||||
|
||||
$sql = "UPDATE ".$table." SET ".implode(', ', $valstr);
|
||||
|
||||
$sql .= ($where != '' AND count($where) >=1) ? " WHERE ".implode(" ", $where) : '';
|
||||
|
||||
$sql .= $orderby.$limit;
|
||||
|
||||
return $sql;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Truncate statement
|
||||
*
|
||||
* Generates a platform-specific truncate string from the supplied data
|
||||
* If the database does not support the truncate() command
|
||||
* This function maps to "DELETE FROM table"
|
||||
*
|
||||
* @access public
|
||||
* @param string the table name
|
||||
* @return string
|
||||
*/
|
||||
function _truncate($table)
|
||||
{
|
||||
return "TRUNCATE ".$table;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Delete statement
|
||||
*
|
||||
* Generates a platform-specific delete string from the supplied data
|
||||
*
|
||||
* @access public
|
||||
* @param string the table name
|
||||
* @param array the where clause
|
||||
* @param string the limit clause
|
||||
* @return string
|
||||
*/
|
||||
function _delete($table, $where = array(), $like = array(), $limit = FALSE)
|
||||
{
|
||||
$conditions = '';
|
||||
|
||||
if (count($where) > 0 OR count($like) > 0)
|
||||
{
|
||||
$conditions = "\nWHERE ";
|
||||
$conditions .= implode("\n", $this->ar_where);
|
||||
|
||||
if (count($where) > 0 && count($like) > 0)
|
||||
{
|
||||
$conditions .= " AND ";
|
||||
}
|
||||
$conditions .= implode("\n", $like);
|
||||
}
|
||||
|
||||
$limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
|
||||
|
||||
return "DELETE FROM ".$table.$conditions.$limit;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Limit string
|
||||
*
|
||||
* Generates a platform-specific LIMIT clause
|
||||
*
|
||||
* @access public
|
||||
* @param string the sql query string
|
||||
* @param integer the number of rows to limit the query to
|
||||
* @param integer the offset value
|
||||
* @return string
|
||||
*/
|
||||
function _limit($sql, $limit, $offset)
|
||||
{
|
||||
if ($offset == 0)
|
||||
{
|
||||
$offset = '';
|
||||
}
|
||||
else
|
||||
{
|
||||
$offset .= ", ";
|
||||
}
|
||||
|
||||
return $sql."LIMIT ".$offset.$limit;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Close DB Connection
|
||||
*
|
||||
* @access public
|
||||
* @param resource
|
||||
* @return void
|
||||
*/
|
||||
function _close($conn_id)
|
||||
{
|
||||
@mysql_close($conn_id);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* End of file mysql_driver.php */
|
||||
/* Location: ./system/database/drivers/mysql/mysql_driver.php */
|
||||
254
system/database/drivers/mysql/mysql_forge.php
Normal file
254
system/database/drivers/mysql/mysql_forge.php
Normal file
@@ -0,0 +1,254 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP 4.3.2 or newer
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2010, EllisLab, Inc.
|
||||
* @license http://codeigniter.com/user_guide/license.html
|
||||
* @link http://codeigniter.com
|
||||
* @since Version 1.0
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* MySQL Forge Class
|
||||
*
|
||||
* @category Database
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @link http://codeigniter.com/user_guide/database/
|
||||
*/
|
||||
class CI_DB_mysql_forge extends CI_DB_forge {
|
||||
|
||||
/**
|
||||
* Create database
|
||||
*
|
||||
* @access private
|
||||
* @param string the database name
|
||||
* @return bool
|
||||
*/
|
||||
function _create_database($name)
|
||||
{
|
||||
return "CREATE DATABASE ".$name;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Drop database
|
||||
*
|
||||
* @access private
|
||||
* @param string the database name
|
||||
* @return bool
|
||||
*/
|
||||
function _drop_database($name)
|
||||
{
|
||||
return "DROP DATABASE ".$name;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Process Fields
|
||||
*
|
||||
* @access private
|
||||
* @param mixed the fields
|
||||
* @return string
|
||||
*/
|
||||
function _process_fields($fields)
|
||||
{
|
||||
$current_field_count = 0;
|
||||
$sql = '';
|
||||
|
||||
foreach ($fields as $field=>$attributes)
|
||||
{
|
||||
// Numeric field names aren't allowed in databases, so if the key is
|
||||
// numeric, we know it was assigned by PHP and the developer manually
|
||||
// entered the field information, so we'll simply add it to the list
|
||||
if (is_numeric($field))
|
||||
{
|
||||
$sql .= "\n\t$attributes";
|
||||
}
|
||||
else
|
||||
{
|
||||
$attributes = array_change_key_case($attributes, CASE_UPPER);
|
||||
|
||||
$sql .= "\n\t".$this->db->_protect_identifiers($field);
|
||||
|
||||
if (array_key_exists('NAME', $attributes))
|
||||
{
|
||||
$sql .= ' '.$this->db->_protect_identifiers($attributes['NAME']).' ';
|
||||
}
|
||||
|
||||
if (array_key_exists('TYPE', $attributes))
|
||||
{
|
||||
$sql .= ' '.$attributes['TYPE'];
|
||||
}
|
||||
|
||||
if (array_key_exists('CONSTRAINT', $attributes))
|
||||
{
|
||||
$sql .= '('.$attributes['CONSTRAINT'].')';
|
||||
}
|
||||
|
||||
if (array_key_exists('UNSIGNED', $attributes) && $attributes['UNSIGNED'] === TRUE)
|
||||
{
|
||||
$sql .= ' UNSIGNED';
|
||||
}
|
||||
|
||||
if (array_key_exists('DEFAULT', $attributes))
|
||||
{
|
||||
$sql .= ' DEFAULT \''.$attributes['DEFAULT'].'\'';
|
||||
}
|
||||
|
||||
if (array_key_exists('NULL', $attributes))
|
||||
{
|
||||
$sql .= ($attributes['NULL'] === TRUE) ? ' NULL' : ' NOT NULL';
|
||||
}
|
||||
|
||||
if (array_key_exists('AUTO_INCREMENT', $attributes) && $attributes['AUTO_INCREMENT'] === TRUE)
|
||||
{
|
||||
$sql .= ' AUTO_INCREMENT';
|
||||
}
|
||||
}
|
||||
|
||||
// don't add a comma on the end of the last field
|
||||
if (++$current_field_count < count($fields))
|
||||
{
|
||||
$sql .= ',';
|
||||
}
|
||||
}
|
||||
|
||||
return $sql;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Create Table
|
||||
*
|
||||
* @access private
|
||||
* @param string the table name
|
||||
* @param mixed the fields
|
||||
* @param mixed primary key(s)
|
||||
* @param mixed key(s)
|
||||
* @param boolean should 'IF NOT EXISTS' be added to the SQL
|
||||
* @return bool
|
||||
*/
|
||||
function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists)
|
||||
{
|
||||
$sql = 'CREATE TABLE ';
|
||||
|
||||
if ($if_not_exists === TRUE)
|
||||
{
|
||||
$sql .= 'IF NOT EXISTS ';
|
||||
}
|
||||
|
||||
$sql .= $this->db->_escape_identifiers($table)." (";
|
||||
|
||||
$sql .= $this->_process_fields($fields);
|
||||
|
||||
if (count($primary_keys) > 0)
|
||||
{
|
||||
$key_name = $this->db->_protect_identifiers(implode('_', $primary_keys));
|
||||
$primary_keys = $this->db->_protect_identifiers($primary_keys);
|
||||
$sql .= ",\n\tPRIMARY KEY ".$key_name." (" . implode(', ', $primary_keys) . ")";
|
||||
}
|
||||
|
||||
if (is_array($keys) && count($keys) > 0)
|
||||
{
|
||||
foreach ($keys as $key)
|
||||
{
|
||||
if (is_array($key))
|
||||
{
|
||||
$key_name = $this->db->_protect_identifiers(implode('_', $key));
|
||||
$key = $this->db->_protect_identifiers($key);
|
||||
}
|
||||
else
|
||||
{
|
||||
$key_name = $this->db->_protect_identifiers($key);
|
||||
$key = array($key_name);
|
||||
}
|
||||
|
||||
$sql .= ",\n\tKEY {$key_name} (" . implode(', ', $key) . ")";
|
||||
}
|
||||
}
|
||||
|
||||
$sql .= "\n) DEFAULT CHARACTER SET {$this->db->char_set} COLLATE {$this->db->dbcollat};";
|
||||
|
||||
return $sql;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Drop Table
|
||||
*
|
||||
* @access private
|
||||
* @return string
|
||||
*/
|
||||
function _drop_table($table)
|
||||
{
|
||||
return "DROP TABLE IF EXISTS ".$this->db->_escape_identifiers($table);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Alter table query
|
||||
*
|
||||
* Generates a platform-specific query so that a table can be altered
|
||||
* Called by add_column(), drop_column(), and column_alter(),
|
||||
*
|
||||
* @access private
|
||||
* @param string the ALTER type (ADD, DROP, CHANGE)
|
||||
* @param string the column name
|
||||
* @param array fields
|
||||
* @param string the field after which we should add the new field
|
||||
* @return object
|
||||
*/
|
||||
function _alter_table($alter_type, $table, $fields, $after_field = '')
|
||||
{
|
||||
$sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table)." $alter_type ";
|
||||
|
||||
// DROP has everything it needs now.
|
||||
if ($alter_type == 'DROP')
|
||||
{
|
||||
return $sql.$this->db->_protect_identifiers($fields);
|
||||
}
|
||||
|
||||
$sql .= $this->_process_fields($fields);
|
||||
|
||||
if ($after_field != '')
|
||||
{
|
||||
$sql .= ' AFTER ' . $this->db->_protect_identifiers($after_field);
|
||||
}
|
||||
|
||||
return $sql;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Rename a table
|
||||
*
|
||||
* Generates a platform-specific query so that a table can be renamed
|
||||
*
|
||||
* @access private
|
||||
* @param string the old table name
|
||||
* @param string the new table name
|
||||
* @return string
|
||||
*/
|
||||
function _rename_table($table_name, $new_table_name)
|
||||
{
|
||||
$sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table_name)." RENAME TO ".$this->db->_protect_identifiers($new_table_name);
|
||||
return $sql;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* End of file mysql_forge.php */
|
||||
/* Location: ./system/database/drivers/mysql/mysql_forge.php */
|
||||
169
system/database/drivers/mysql/mysql_result.php
Normal file
169
system/database/drivers/mysql/mysql_result.php
Normal file
@@ -0,0 +1,169 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP 4.3.2 or newer
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2010, EllisLab, Inc.
|
||||
* @license http://codeigniter.com/user_guide/license.html
|
||||
* @link http://codeigniter.com
|
||||
* @since Version 1.0
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* MySQL Result Class
|
||||
*
|
||||
* This class extends the parent result class: CI_DB_result
|
||||
*
|
||||
* @category Database
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @link http://codeigniter.com/user_guide/database/
|
||||
*/
|
||||
class CI_DB_mysql_result extends CI_DB_result {
|
||||
|
||||
/**
|
||||
* Number of rows in the result set
|
||||
*
|
||||
* @access public
|
||||
* @return integer
|
||||
*/
|
||||
function num_rows()
|
||||
{
|
||||
return @mysql_num_rows($this->result_id);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Number of fields in the result set
|
||||
*
|
||||
* @access public
|
||||
* @return integer
|
||||
*/
|
||||
function num_fields()
|
||||
{
|
||||
return @mysql_num_fields($this->result_id);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Fetch Field Names
|
||||
*
|
||||
* Generates an array of column names
|
||||
*
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
function list_fields()
|
||||
{
|
||||
$field_names = array();
|
||||
while ($field = mysql_fetch_field($this->result_id))
|
||||
{
|
||||
$field_names[] = $field->name;
|
||||
}
|
||||
|
||||
return $field_names;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Field data
|
||||
*
|
||||
* Generates an array of objects containing field meta-data
|
||||
*
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
function field_data()
|
||||
{
|
||||
$retval = array();
|
||||
while ($field = mysql_fetch_field($this->result_id))
|
||||
{
|
||||
$F = new stdClass();
|
||||
$F->name = $field->name;
|
||||
$F->type = $field->type;
|
||||
$F->default = $field->def;
|
||||
$F->max_length = $field->max_length;
|
||||
$F->primary_key = $field->primary_key;
|
||||
|
||||
$retval[] = $F;
|
||||
}
|
||||
|
||||
return $retval;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Free the result
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
function free_result()
|
||||
{
|
||||
if (is_resource($this->result_id))
|
||||
{
|
||||
mysql_free_result($this->result_id);
|
||||
$this->result_id = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Data Seek
|
||||
*
|
||||
* Moves the internal pointer to the desired offset. We call
|
||||
* this internally before fetching results to make sure the
|
||||
* result set starts at zero
|
||||
*
|
||||
* @access private
|
||||
* @return array
|
||||
*/
|
||||
function _data_seek($n = 0)
|
||||
{
|
||||
return mysql_data_seek($this->result_id, $n);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Result - associative array
|
||||
*
|
||||
* Returns the result set as an array
|
||||
*
|
||||
* @access private
|
||||
* @return array
|
||||
*/
|
||||
function _fetch_assoc()
|
||||
{
|
||||
return mysql_fetch_assoc($this->result_id);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Result - object
|
||||
*
|
||||
* Returns the result set as an object
|
||||
*
|
||||
* @access private
|
||||
* @return object
|
||||
*/
|
||||
function _fetch_object()
|
||||
{
|
||||
return mysql_fetch_object($this->result_id);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* End of file mysql_result.php */
|
||||
/* Location: ./system/database/drivers/mysql/mysql_result.php */
|
||||
245
system/database/drivers/mysql/mysql_utility.php
Normal file
245
system/database/drivers/mysql/mysql_utility.php
Normal file
@@ -0,0 +1,245 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP 4.3.2 or newer
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2010, EllisLab, Inc.
|
||||
* @license http://codeigniter.com/user_guide/license.html
|
||||
* @link http://codeigniter.com
|
||||
* @since Version 1.0
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* MySQL Utility Class
|
||||
*
|
||||
* @category Database
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @link http://codeigniter.com/user_guide/database/
|
||||
*/
|
||||
class CI_DB_mysql_utility extends CI_DB_utility {
|
||||
|
||||
/**
|
||||
* List databases
|
||||
*
|
||||
* @access private
|
||||
* @return bool
|
||||
*/
|
||||
function _list_databases()
|
||||
{
|
||||
return "SHOW DATABASES";
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Optimize table query
|
||||
*
|
||||
* Generates a platform-specific query so that a table can be optimized
|
||||
*
|
||||
* @access private
|
||||
* @param string the table name
|
||||
* @return object
|
||||
*/
|
||||
function _optimize_table($table)
|
||||
{
|
||||
return "OPTIMIZE TABLE ".$this->db->_escape_identifiers($table);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Repair table query
|
||||
*
|
||||
* Generates a platform-specific query so that a table can be repaired
|
||||
*
|
||||
* @access private
|
||||
* @param string the table name
|
||||
* @return object
|
||||
*/
|
||||
function _repair_table($table)
|
||||
{
|
||||
return "REPAIR TABLE ".$this->db->_escape_identifiers($table);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
/**
|
||||
* MySQL Export
|
||||
*
|
||||
* @access private
|
||||
* @param array Preferences
|
||||
* @return mixed
|
||||
*/
|
||||
function _backup($params = array())
|
||||
{
|
||||
if (count($params) == 0)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Extract the prefs for simplicity
|
||||
extract($params);
|
||||
|
||||
// Build the output
|
||||
$output = '';
|
||||
foreach ((array)$tables as $table)
|
||||
{
|
||||
// Is the table in the "ignore" list?
|
||||
if (in_array($table, (array)$ignore, TRUE))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Get the table schema
|
||||
$query = $this->db->query("SHOW CREATE TABLE `".$this->db->database.'`.'.$table);
|
||||
|
||||
// No result means the table name was invalid
|
||||
if ($query === FALSE)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Write out the table schema
|
||||
$output .= '#'.$newline.'# TABLE STRUCTURE FOR: '.$table.$newline.'#'.$newline.$newline;
|
||||
|
||||
if ($add_drop == TRUE)
|
||||
{
|
||||
$output .= 'DROP TABLE IF EXISTS '.$table.';'.$newline.$newline;
|
||||
}
|
||||
|
||||
$i = 0;
|
||||
$result = $query->result_array();
|
||||
foreach ($result[0] as $val)
|
||||
{
|
||||
if ($i++ % 2)
|
||||
{
|
||||
$output .= $val.';'.$newline.$newline;
|
||||
}
|
||||
}
|
||||
|
||||
// If inserts are not needed we're done...
|
||||
if ($add_insert == FALSE)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Grab all the data from the current table
|
||||
$query = $this->db->query("SELECT * FROM $table");
|
||||
|
||||
if ($query->num_rows() == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Fetch the field names and determine if the field is an
|
||||
// integer type. We use this info to decide whether to
|
||||
// surround the data with quotes or not
|
||||
|
||||
$i = 0;
|
||||
$field_str = '';
|
||||
$is_int = array();
|
||||
while ($field = mysql_fetch_field($query->result_id))
|
||||
{
|
||||
// Most versions of MySQL store timestamp as a string
|
||||
$is_int[$i] = (in_array(
|
||||
strtolower(mysql_field_type($query->result_id, $i)),
|
||||
array('tinyint', 'smallint', 'mediumint', 'int', 'bigint'), //, 'timestamp'),
|
||||
TRUE)
|
||||
) ? TRUE : FALSE;
|
||||
|
||||
// Create a string of field names
|
||||
$field_str .= '`'.$field->name.'`, ';
|
||||
$i++;
|
||||
}
|
||||
|
||||
// Trim off the end comma
|
||||
$field_str = preg_replace( "/, $/" , "" , $field_str);
|
||||
|
||||
|
||||
// Build the insert string
|
||||
foreach ($query->result_array() as $row)
|
||||
{
|
||||
$val_str = '';
|
||||
|
||||
$i = 0;
|
||||
foreach ($row as $v)
|
||||
{
|
||||
// Is the value NULL?
|
||||
if ($v === NULL)
|
||||
{
|
||||
$val_str .= 'NULL';
|
||||
}
|
||||
else
|
||||
{
|
||||
// Escape the data if it's not an integer
|
||||
if ($is_int[$i] == FALSE)
|
||||
{
|
||||
$val_str .= $this->db->escape($v);
|
||||
}
|
||||
else
|
||||
{
|
||||
$val_str .= $v;
|
||||
}
|
||||
}
|
||||
|
||||
// Append a comma
|
||||
$val_str .= ', ';
|
||||
$i++;
|
||||
}
|
||||
|
||||
// Remove the comma at the end of the string
|
||||
$val_str = preg_replace( "/, $/" , "" , $val_str);
|
||||
|
||||
// Build the INSERT string
|
||||
$output .= 'INSERT INTO '.$table.' ('.$field_str.') VALUES ('.$val_str.');'.$newline;
|
||||
}
|
||||
|
||||
$output .= $newline.$newline;
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* The functions below have been deprecated as of 1.6, and are only here for backwards
|
||||
* compatibility. They now reside in dbforge(). The use of dbutils for database manipulation
|
||||
* is STRONGLY discouraged in favour if using dbforge.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Create database
|
||||
*
|
||||
* @access private
|
||||
* @param string the database name
|
||||
* @return bool
|
||||
*/
|
||||
function _create_database($name)
|
||||
{
|
||||
return "CREATE DATABASE ".$name;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Drop database
|
||||
*
|
||||
* @access private
|
||||
* @param string the database name
|
||||
* @return bool
|
||||
*/
|
||||
function _drop_database($name)
|
||||
{
|
||||
return "DROP DATABASE ".$name;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* End of file mysql_utility.php */
|
||||
/* Location: ./system/database/drivers/mysql/mysql_utility.php */
|
||||
10
system/database/drivers/mysqli/index.html
Normal file
10
system/database/drivers/mysqli/index.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
671
system/database/drivers/mysqli/mysqli_driver.php
Normal file
671
system/database/drivers/mysqli/mysqli_driver.php
Normal file
@@ -0,0 +1,671 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP 4.3.2 or newer
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2010, EllisLab, Inc.
|
||||
* @license http://codeigniter.com/user_guide/license.html
|
||||
* @link http://codeigniter.com
|
||||
* @since Version 1.0
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* MySQLi Database Adapter Class - MySQLi only works with PHP 5
|
||||
*
|
||||
* Note: _DB is an extender class that the app controller
|
||||
* creates dynamically based on whether the active record
|
||||
* class is being used or not.
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @subpackage Drivers
|
||||
* @category Database
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @link http://codeigniter.com/user_guide/database/
|
||||
*/
|
||||
class CI_DB_mysqli_driver extends CI_DB {
|
||||
|
||||
var $dbdriver = 'mysqli';
|
||||
|
||||
// The character used for escaping
|
||||
var $_escape_char = '`';
|
||||
|
||||
// clause and character used for LIKE escape sequences - not used in MySQL
|
||||
var $_like_escape_str = '';
|
||||
var $_like_escape_chr = '';
|
||||
|
||||
/**
|
||||
* The syntax to count rows is slightly different across different
|
||||
* database engines, so this string appears in each driver and is
|
||||
* used for the count_all() and count_all_results() functions.
|
||||
*/
|
||||
var $_count_string = "SELECT COUNT(*) AS ";
|
||||
var $_random_keyword = ' RAND()'; // database specific random keyword
|
||||
|
||||
/**
|
||||
* Whether to use the MySQL "delete hack" which allows the number
|
||||
* of affected rows to be shown. Uses a preg_replace when enabled,
|
||||
* adding a bit more processing to all queries.
|
||||
*/
|
||||
var $delete_hack = TRUE;
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Non-persistent database connection
|
||||
*
|
||||
* @access private called by the base class
|
||||
* @return resource
|
||||
*/
|
||||
function db_connect()
|
||||
{
|
||||
if ($this->port != '')
|
||||
{
|
||||
return @mysqli_connect($this->hostname, $this->username, $this->password, $this->database, $this->port);
|
||||
}
|
||||
else
|
||||
{
|
||||
return @mysqli_connect($this->hostname, $this->username, $this->password, $this->database);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Persistent database connection
|
||||
*
|
||||
* @access private called by the base class
|
||||
* @return resource
|
||||
*/
|
||||
function db_pconnect()
|
||||
{
|
||||
return $this->db_connect();
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Reconnect
|
||||
*
|
||||
* Keep / reestablish the db connection if no queries have been
|
||||
* sent for a length of time exceeding the server's idle timeout
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function reconnect()
|
||||
{
|
||||
if (mysqli_ping($this->conn_id) === FALSE)
|
||||
{
|
||||
$this->conn_id = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Select the database
|
||||
*
|
||||
* @access private called by the base class
|
||||
* @return resource
|
||||
*/
|
||||
function db_select()
|
||||
{
|
||||
return @mysqli_select_db($this->conn_id, $this->database);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Set client character set
|
||||
*
|
||||
* @access private
|
||||
* @param string
|
||||
* @param string
|
||||
* @return resource
|
||||
*/
|
||||
function _db_set_charset($charset, $collation)
|
||||
{
|
||||
return @mysqli_query($this->conn_id, "SET NAMES '".$this->escape_str($charset)."' COLLATE '".$this->escape_str($collation)."'");
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Version number query string
|
||||
*
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
function _version()
|
||||
{
|
||||
return "SELECT version() AS ver";
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Execute the query
|
||||
*
|
||||
* @access private called by the base class
|
||||
* @param string an SQL query
|
||||
* @return resource
|
||||
*/
|
||||
function _execute($sql)
|
||||
{
|
||||
$sql = $this->_prep_query($sql);
|
||||
$result = @mysqli_query($this->conn_id, $sql);
|
||||
return $result;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Prep the query
|
||||
*
|
||||
* If needed, each database adapter can prep the query string
|
||||
*
|
||||
* @access private called by execute()
|
||||
* @param string an SQL query
|
||||
* @return string
|
||||
*/
|
||||
function _prep_query($sql)
|
||||
{
|
||||
// "DELETE FROM TABLE" returns 0 affected rows This hack modifies
|
||||
// the query so that it returns the number of affected rows
|
||||
if ($this->delete_hack === TRUE)
|
||||
{
|
||||
if (preg_match('/^\s*DELETE\s+FROM\s+(\S+)\s*$/i', $sql))
|
||||
{
|
||||
$sql = preg_replace("/^\s*DELETE\s+FROM\s+(\S+)\s*$/", "DELETE FROM \\1 WHERE 1=1", $sql);
|
||||
}
|
||||
}
|
||||
|
||||
return $sql;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Begin Transaction
|
||||
*
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
function trans_begin($test_mode = FALSE)
|
||||
{
|
||||
if ( ! $this->trans_enabled)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// When transactions are nested we only begin/commit/rollback the outermost ones
|
||||
if ($this->_trans_depth > 0)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// Reset the transaction failure flag.
|
||||
// If the $test_mode flag is set to TRUE transactions will be rolled back
|
||||
// even if the queries produce a successful result.
|
||||
$this->_trans_failure = ($test_mode === TRUE) ? TRUE : FALSE;
|
||||
|
||||
$this->simple_query('SET AUTOCOMMIT=0');
|
||||
$this->simple_query('START TRANSACTION'); // can also be BEGIN or BEGIN WORK
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Commit Transaction
|
||||
*
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
function trans_commit()
|
||||
{
|
||||
if ( ! $this->trans_enabled)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// When transactions are nested we only begin/commit/rollback the outermost ones
|
||||
if ($this->_trans_depth > 0)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
$this->simple_query('COMMIT');
|
||||
$this->simple_query('SET AUTOCOMMIT=1');
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Rollback Transaction
|
||||
*
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
function trans_rollback()
|
||||
{
|
||||
if ( ! $this->trans_enabled)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// When transactions are nested we only begin/commit/rollback the outermost ones
|
||||
if ($this->_trans_depth > 0)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
$this->simple_query('ROLLBACK');
|
||||
$this->simple_query('SET AUTOCOMMIT=1');
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Escape String
|
||||
*
|
||||
* @access public
|
||||
* @param string
|
||||
* @param bool whether or not the string will be used in a LIKE condition
|
||||
* @return string
|
||||
*/
|
||||
function escape_str($str, $like = FALSE)
|
||||
{
|
||||
if (is_array($str))
|
||||
{
|
||||
foreach($str as $key => $val)
|
||||
{
|
||||
$str[$key] = $this->escape_str($val, $like);
|
||||
}
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
if (function_exists('mysqli_real_escape_string') AND is_object($this->conn_id))
|
||||
{
|
||||
$str = mysqli_real_escape_string($this->conn_id, $str);
|
||||
}
|
||||
elseif (function_exists('mysql_escape_string'))
|
||||
{
|
||||
$str = mysql_escape_string($str);
|
||||
}
|
||||
else
|
||||
{
|
||||
$str = addslashes($str);
|
||||
}
|
||||
|
||||
// escape LIKE condition wildcards
|
||||
if ($like === TRUE)
|
||||
{
|
||||
$str = str_replace(array('%', '_'), array('\\%', '\\_'), $str);
|
||||
}
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Affected Rows
|
||||
*
|
||||
* @access public
|
||||
* @return integer
|
||||
*/
|
||||
function affected_rows()
|
||||
{
|
||||
return @mysqli_affected_rows($this->conn_id);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Insert ID
|
||||
*
|
||||
* @access public
|
||||
* @return integer
|
||||
*/
|
||||
function insert_id()
|
||||
{
|
||||
return @mysqli_insert_id($this->conn_id);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* "Count All" query
|
||||
*
|
||||
* Generates a platform-specific query string that counts all records in
|
||||
* the specified database
|
||||
*
|
||||
* @access public
|
||||
* @param string
|
||||
* @return string
|
||||
*/
|
||||
function count_all($table = '')
|
||||
{
|
||||
if ($table == '')
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
$query = $this->query($this->_count_string . $this->_protect_identifiers('numrows') . " FROM " . $this->_protect_identifiers($table, TRUE, NULL, FALSE));
|
||||
|
||||
if ($query->num_rows() == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
$row = $query->row();
|
||||
return (int) $row->numrows;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* List table query
|
||||
*
|
||||
* Generates a platform-specific query string so that the table names can be fetched
|
||||
*
|
||||
* @access private
|
||||
* @param boolean
|
||||
* @return string
|
||||
*/
|
||||
function _list_tables($prefix_limit = FALSE)
|
||||
{
|
||||
$sql = "SHOW TABLES FROM ".$this->_escape_char.$this->database.$this->_escape_char;
|
||||
|
||||
if ($prefix_limit !== FALSE AND $this->dbprefix != '')
|
||||
{
|
||||
$sql .= " LIKE '".$this->escape_like_str($this->dbprefix)."%'";
|
||||
}
|
||||
|
||||
return $sql;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Show column query
|
||||
*
|
||||
* Generates a platform-specific query string so that the column names can be fetched
|
||||
*
|
||||
* @access public
|
||||
* @param string the table name
|
||||
* @return string
|
||||
*/
|
||||
function _list_columns($table = '')
|
||||
{
|
||||
return "SHOW COLUMNS FROM ".$table;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Field data query
|
||||
*
|
||||
* Generates a platform-specific query so that the column data can be retrieved
|
||||
*
|
||||
* @access public
|
||||
* @param string the table name
|
||||
* @return object
|
||||
*/
|
||||
function _field_data($table)
|
||||
{
|
||||
return "SELECT * FROM ".$table." LIMIT 1";
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* The error message string
|
||||
*
|
||||
* @access private
|
||||
* @return string
|
||||
*/
|
||||
function _error_message()
|
||||
{
|
||||
return mysqli_error($this->conn_id);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* The error message number
|
||||
*
|
||||
* @access private
|
||||
* @return integer
|
||||
*/
|
||||
function _error_number()
|
||||
{
|
||||
return mysqli_errno($this->conn_id);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Escape the SQL Identifiers
|
||||
*
|
||||
* This function escapes column and table names
|
||||
*
|
||||
* @access private
|
||||
* @param string
|
||||
* @return string
|
||||
*/
|
||||
function _escape_identifiers($item)
|
||||
{
|
||||
if ($this->_escape_char == '')
|
||||
{
|
||||
return $item;
|
||||
}
|
||||
|
||||
foreach ($this->_reserved_identifiers as $id)
|
||||
{
|
||||
if (strpos($item, '.'.$id) !== FALSE)
|
||||
{
|
||||
$str = $this->_escape_char. str_replace('.', $this->_escape_char.'.', $item);
|
||||
|
||||
// remove duplicates if the user already included the escape
|
||||
return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str);
|
||||
}
|
||||
}
|
||||
|
||||
if (strpos($item, '.') !== FALSE)
|
||||
{
|
||||
$str = $this->_escape_char.str_replace('.', $this->_escape_char.'.'.$this->_escape_char, $item).$this->_escape_char;
|
||||
}
|
||||
else
|
||||
{
|
||||
$str = $this->_escape_char.$item.$this->_escape_char;
|
||||
}
|
||||
|
||||
// remove duplicates if the user already included the escape
|
||||
return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* From Tables
|
||||
*
|
||||
* This function implicitly groups FROM tables so there is no confusion
|
||||
* about operator precedence in harmony with SQL standards
|
||||
*
|
||||
* @access public
|
||||
* @param type
|
||||
* @return type
|
||||
*/
|
||||
function _from_tables($tables)
|
||||
{
|
||||
if ( ! is_array($tables))
|
||||
{
|
||||
$tables = array($tables);
|
||||
}
|
||||
|
||||
return '('.implode(', ', $tables).')';
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Insert statement
|
||||
*
|
||||
* Generates a platform-specific insert string from the supplied data
|
||||
*
|
||||
* @access public
|
||||
* @param string the table name
|
||||
* @param array the insert keys
|
||||
* @param array the insert values
|
||||
* @return string
|
||||
*/
|
||||
function _insert($table, $keys, $values)
|
||||
{
|
||||
return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")";
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Update statement
|
||||
*
|
||||
* Generates a platform-specific update string from the supplied data
|
||||
*
|
||||
* @access public
|
||||
* @param string the table name
|
||||
* @param array the update data
|
||||
* @param array the where clause
|
||||
* @param array the orderby clause
|
||||
* @param array the limit clause
|
||||
* @return string
|
||||
*/
|
||||
function _update($table, $values, $where, $orderby = array(), $limit = FALSE)
|
||||
{
|
||||
foreach($values as $key => $val)
|
||||
{
|
||||
$valstr[] = $key." = ".$val;
|
||||
}
|
||||
|
||||
$limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
|
||||
|
||||
$orderby = (count($orderby) >= 1)?' ORDER BY '.implode(", ", $orderby):'';
|
||||
|
||||
$sql = "UPDATE ".$table." SET ".implode(', ', $valstr);
|
||||
|
||||
$sql .= ($where != '' AND count($where) >=1) ? " WHERE ".implode(" ", $where) : '';
|
||||
|
||||
$sql .= $orderby.$limit;
|
||||
|
||||
return $sql;
|
||||
}
|
||||
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Truncate statement
|
||||
*
|
||||
* Generates a platform-specific truncate string from the supplied data
|
||||
* If the database does not support the truncate() command
|
||||
* This function maps to "DELETE FROM table"
|
||||
*
|
||||
* @access public
|
||||
* @param string the table name
|
||||
* @return string
|
||||
*/
|
||||
function _truncate($table)
|
||||
{
|
||||
return "TRUNCATE ".$table;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Delete statement
|
||||
*
|
||||
* Generates a platform-specific delete string from the supplied data
|
||||
*
|
||||
* @access public
|
||||
* @param string the table name
|
||||
* @param array the where clause
|
||||
* @param string the limit clause
|
||||
* @return string
|
||||
*/
|
||||
function _delete($table, $where = array(), $like = array(), $limit = FALSE)
|
||||
{
|
||||
$conditions = '';
|
||||
|
||||
if (count($where) > 0 OR count($like) > 0)
|
||||
{
|
||||
$conditions = "\nWHERE ";
|
||||
$conditions .= implode("\n", $this->ar_where);
|
||||
|
||||
if (count($where) > 0 && count($like) > 0)
|
||||
{
|
||||
$conditions .= " AND ";
|
||||
}
|
||||
$conditions .= implode("\n", $like);
|
||||
}
|
||||
|
||||
$limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
|
||||
|
||||
return "DELETE FROM ".$table.$conditions.$limit;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Limit string
|
||||
*
|
||||
* Generates a platform-specific LIMIT clause
|
||||
*
|
||||
* @access public
|
||||
* @param string the sql query string
|
||||
* @param integer the number of rows to limit the query to
|
||||
* @param integer the offset value
|
||||
* @return string
|
||||
*/
|
||||
function _limit($sql, $limit, $offset)
|
||||
{
|
||||
$sql .= "LIMIT ".$limit;
|
||||
|
||||
if ($offset > 0)
|
||||
{
|
||||
$sql .= " OFFSET ".$offset;
|
||||
}
|
||||
|
||||
return $sql;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Close DB Connection
|
||||
*
|
||||
* @access public
|
||||
* @param resource
|
||||
* @return void
|
||||
*/
|
||||
function _close($conn_id)
|
||||
{
|
||||
@mysqli_close($conn_id);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* End of file mysqli_driver.php */
|
||||
/* Location: ./system/database/drivers/mysqli/mysqli_driver.php */
|
||||
254
system/database/drivers/mysqli/mysqli_forge.php
Normal file
254
system/database/drivers/mysqli/mysqli_forge.php
Normal file
@@ -0,0 +1,254 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP 4.3.2 or newer
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2010, EllisLab, Inc.
|
||||
* @license http://codeigniter.com/user_guide/license.html
|
||||
* @link http://codeigniter.com
|
||||
* @since Version 1.0
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* MySQLi Forge Class
|
||||
*
|
||||
* @category Database
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @link http://codeigniter.com/user_guide/database/
|
||||
*/
|
||||
class CI_DB_mysqli_forge extends CI_DB_forge {
|
||||
|
||||
/**
|
||||
* Create database
|
||||
*
|
||||
* @access private
|
||||
* @param string the database name
|
||||
* @return bool
|
||||
*/
|
||||
function _create_database($name)
|
||||
{
|
||||
return "CREATE DATABASE ".$name;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Drop database
|
||||
*
|
||||
* @access private
|
||||
* @param string the database name
|
||||
* @return bool
|
||||
*/
|
||||
function _drop_database($name)
|
||||
{
|
||||
return "DROP DATABASE ".$name;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Process Fields
|
||||
*
|
||||
* @access private
|
||||
* @param mixed the fields
|
||||
* @return string
|
||||
*/
|
||||
function _process_fields($fields)
|
||||
{
|
||||
$current_field_count = 0;
|
||||
$sql = '';
|
||||
|
||||
foreach ($fields as $field=>$attributes)
|
||||
{
|
||||
// Numeric field names aren't allowed in databases, so if the key is
|
||||
// numeric, we know it was assigned by PHP and the developer manually
|
||||
// entered the field information, so we'll simply add it to the list
|
||||
if (is_numeric($field))
|
||||
{
|
||||
$sql .= "\n\t$attributes";
|
||||
}
|
||||
else
|
||||
{
|
||||
$attributes = array_change_key_case($attributes, CASE_UPPER);
|
||||
|
||||
$sql .= "\n\t".$this->db->_protect_identifiers($field);
|
||||
|
||||
if (array_key_exists('NAME', $attributes))
|
||||
{
|
||||
$sql .= ' '.$this->db->_protect_identifiers($attributes['NAME']).' ';
|
||||
}
|
||||
|
||||
if (array_key_exists('TYPE', $attributes))
|
||||
{
|
||||
$sql .= ' '.$attributes['TYPE'];
|
||||
}
|
||||
|
||||
if (array_key_exists('CONSTRAINT', $attributes))
|
||||
{
|
||||
$sql .= '('.$attributes['CONSTRAINT'].')';
|
||||
}
|
||||
|
||||
if (array_key_exists('UNSIGNED', $attributes) && $attributes['UNSIGNED'] === TRUE)
|
||||
{
|
||||
$sql .= ' UNSIGNED';
|
||||
}
|
||||
|
||||
if (array_key_exists('DEFAULT', $attributes))
|
||||
{
|
||||
$sql .= ' DEFAULT \''.$attributes['DEFAULT'].'\'';
|
||||
}
|
||||
|
||||
if (array_key_exists('NULL', $attributes))
|
||||
{
|
||||
$sql .= ($attributes['NULL'] === TRUE) ? ' NULL' : ' NOT NULL';
|
||||
}
|
||||
|
||||
if (array_key_exists('AUTO_INCREMENT', $attributes) && $attributes['AUTO_INCREMENT'] === TRUE)
|
||||
{
|
||||
$sql .= ' AUTO_INCREMENT';
|
||||
}
|
||||
}
|
||||
|
||||
// don't add a comma on the end of the last field
|
||||
if (++$current_field_count < count($fields))
|
||||
{
|
||||
$sql .= ',';
|
||||
}
|
||||
}
|
||||
|
||||
return $sql;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Create Table
|
||||
*
|
||||
* @access private
|
||||
* @param string the table name
|
||||
* @param mixed the fields
|
||||
* @param mixed primary key(s)
|
||||
* @param mixed key(s)
|
||||
* @param boolean should 'IF NOT EXISTS' be added to the SQL
|
||||
* @return bool
|
||||
*/
|
||||
function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists)
|
||||
{
|
||||
$sql = 'CREATE TABLE ';
|
||||
|
||||
if ($if_not_exists === TRUE)
|
||||
{
|
||||
$sql .= 'IF NOT EXISTS ';
|
||||
}
|
||||
|
||||
$sql .= $this->db->_escape_identifiers($table)." (";
|
||||
|
||||
$sql .= $this->_process_fields($fields);
|
||||
|
||||
if (count($primary_keys) > 0)
|
||||
{
|
||||
$key_name = $this->db->_protect_identifiers(implode('_', $primary_keys));
|
||||
$primary_keys = $this->db->_protect_identifiers($primary_keys);
|
||||
$sql .= ",\n\tPRIMARY KEY ".$key_name." (" . implode(', ', $primary_keys) . ")";
|
||||
}
|
||||
|
||||
if (is_array($keys) && count($keys) > 0)
|
||||
{
|
||||
foreach ($keys as $key)
|
||||
{
|
||||
if (is_array($key))
|
||||
{
|
||||
$key_name = $this->db->_protect_identifiers(implode('_', $key));
|
||||
$key = $this->db->_protect_identifiers($key);
|
||||
}
|
||||
else
|
||||
{
|
||||
$key_name = $this->db->_protect_identifiers($key);
|
||||
$key = array($key_name);
|
||||
}
|
||||
|
||||
$sql .= ",\n\tKEY {$key_name} (" . implode(', ', $key) . ")";
|
||||
}
|
||||
}
|
||||
|
||||
$sql .= "\n) DEFAULT CHARACTER SET {$this->db->char_set} COLLATE {$this->db->dbcollat};";
|
||||
|
||||
return $sql;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Drop Table
|
||||
*
|
||||
* @access private
|
||||
* @return string
|
||||
*/
|
||||
function _drop_table($table)
|
||||
{
|
||||
return "DROP TABLE IF EXISTS ".$this->db->_escape_identifiers($table);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Alter table query
|
||||
*
|
||||
* Generates a platform-specific query so that a table can be altered
|
||||
* Called by add_column(), drop_column(), and column_alter(),
|
||||
*
|
||||
* @access private
|
||||
* @param string the ALTER type (ADD, DROP, CHANGE)
|
||||
* @param string the column name
|
||||
* @param array fields
|
||||
* @param string the field after which we should add the new field
|
||||
* @return object
|
||||
*/
|
||||
function _alter_table($alter_type, $table, $fields, $after_field = '')
|
||||
{
|
||||
$sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table)." $alter_type ";
|
||||
|
||||
// DROP has everything it needs now.
|
||||
if ($alter_type == 'DROP')
|
||||
{
|
||||
return $sql.$this->db->_protect_identifiers($fields);
|
||||
}
|
||||
|
||||
$sql .= $this->_process_fields($fields);
|
||||
|
||||
if ($after_field != '')
|
||||
{
|
||||
$sql .= ' AFTER ' . $this->db->_protect_identifiers($after_field);
|
||||
}
|
||||
|
||||
return $sql;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Rename a table
|
||||
*
|
||||
* Generates a platform-specific query so that a table can be renamed
|
||||
*
|
||||
* @access private
|
||||
* @param string the old table name
|
||||
* @param string the new table name
|
||||
* @return string
|
||||
*/
|
||||
function _rename_table($table_name, $new_table_name)
|
||||
{
|
||||
$sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table_name)." RENAME TO ".$this->db->_protect_identifiers($new_table_name);
|
||||
return $sql;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* End of file mysqli_forge.php */
|
||||
/* Location: ./system/database/drivers/mysqli/mysqli_forge.php */
|
||||
169
system/database/drivers/mysqli/mysqli_result.php
Normal file
169
system/database/drivers/mysqli/mysqli_result.php
Normal file
@@ -0,0 +1,169 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP 4.3.2 or newer
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2010, EllisLab, Inc.
|
||||
* @license http://codeigniter.com/user_guide/license.html
|
||||
* @link http://codeigniter.com
|
||||
* @since Version 1.0
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* MySQLi Result Class
|
||||
*
|
||||
* This class extends the parent result class: CI_DB_result
|
||||
*
|
||||
* @category Database
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @link http://codeigniter.com/user_guide/database/
|
||||
*/
|
||||
class CI_DB_mysqli_result extends CI_DB_result {
|
||||
|
||||
/**
|
||||
* Number of rows in the result set
|
||||
*
|
||||
* @access public
|
||||
* @return integer
|
||||
*/
|
||||
function num_rows()
|
||||
{
|
||||
return @mysqli_num_rows($this->result_id);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Number of fields in the result set
|
||||
*
|
||||
* @access public
|
||||
* @return integer
|
||||
*/
|
||||
function num_fields()
|
||||
{
|
||||
return @mysqli_num_fields($this->result_id);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Fetch Field Names
|
||||
*
|
||||
* Generates an array of column names
|
||||
*
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
function list_fields()
|
||||
{
|
||||
$field_names = array();
|
||||
while ($field = mysqli_fetch_field($this->result_id))
|
||||
{
|
||||
$field_names[] = $field->name;
|
||||
}
|
||||
|
||||
return $field_names;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Field data
|
||||
*
|
||||
* Generates an array of objects containing field meta-data
|
||||
*
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
function field_data()
|
||||
{
|
||||
$retval = array();
|
||||
while ($field = mysqli_fetch_field($this->result_id))
|
||||
{
|
||||
$F = new stdClass();
|
||||
$F->name = $field->name;
|
||||
$F->type = $field->type;
|
||||
$F->default = $field->def;
|
||||
$F->max_length = $field->max_length;
|
||||
$F->primary_key = ($field->flags & MYSQLI_PRI_KEY_FLAG) ? 1 : 0;
|
||||
|
||||
$retval[] = $F;
|
||||
}
|
||||
|
||||
return $retval;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Free the result
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
function free_result()
|
||||
{
|
||||
if (is_object($this->result_id))
|
||||
{
|
||||
mysqli_free_result($this->result_id);
|
||||
$this->result_id = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Data Seek
|
||||
*
|
||||
* Moves the internal pointer to the desired offset. We call
|
||||
* this internally before fetching results to make sure the
|
||||
* result set starts at zero
|
||||
*
|
||||
* @access private
|
||||
* @return array
|
||||
*/
|
||||
function _data_seek($n = 0)
|
||||
{
|
||||
return mysqli_data_seek($this->result_id, $n);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Result - associative array
|
||||
*
|
||||
* Returns the result set as an array
|
||||
*
|
||||
* @access private
|
||||
* @return array
|
||||
*/
|
||||
function _fetch_assoc()
|
||||
{
|
||||
return mysqli_fetch_assoc($this->result_id);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Result - object
|
||||
*
|
||||
* Returns the result set as an object
|
||||
*
|
||||
* @access private
|
||||
* @return object
|
||||
*/
|
||||
function _fetch_object()
|
||||
{
|
||||
return mysqli_fetch_object($this->result_id);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* End of file mysqli_result.php */
|
||||
/* Location: ./system/database/drivers/mysqli/mysqli_result.php */
|
||||
123
system/database/drivers/mysqli/mysqli_utility.php
Normal file
123
system/database/drivers/mysqli/mysqli_utility.php
Normal file
@@ -0,0 +1,123 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP 4.3.2 or newer
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2010, EllisLab, Inc.
|
||||
* @license http://codeigniter.com/user_guide/license.html
|
||||
* @link http://codeigniter.com
|
||||
* @since Version 1.0
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* MySQLi Utility Class
|
||||
*
|
||||
* @category Database
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @link http://codeigniter.com/user_guide/database/
|
||||
*/
|
||||
class CI_DB_mysqli_utility extends CI_DB_utility {
|
||||
|
||||
/**
|
||||
* List databases
|
||||
*
|
||||
* @access private
|
||||
* @return bool
|
||||
*/
|
||||
function _list_databases()
|
||||
{
|
||||
return "SHOW DATABASES";
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Optimize table query
|
||||
*
|
||||
* Generates a platform-specific query so that a table can be optimized
|
||||
*
|
||||
* @access private
|
||||
* @param string the table name
|
||||
* @return object
|
||||
*/
|
||||
function _optimize_table($table)
|
||||
{
|
||||
return "OPTIMIZE TABLE ".$this->db->_escape_identifiers($table);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Repair table query
|
||||
*
|
||||
* Generates a platform-specific query so that a table can be repaired
|
||||
*
|
||||
* @access private
|
||||
* @param string the table name
|
||||
* @return object
|
||||
*/
|
||||
function _repair_table($table)
|
||||
{
|
||||
return "REPAIR TABLE ".$this->db->_escape_identifiers($table);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* MySQLi Export
|
||||
*
|
||||
* @access private
|
||||
* @param array Preferences
|
||||
* @return mixed
|
||||
*/
|
||||
function _backup($params = array())
|
||||
{
|
||||
// Currently unsupported
|
||||
return $this->db->display_error('db_unsuported_feature');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* The functions below have been deprecated as of 1.6, and are only here for backwards
|
||||
* compatibility. They now reside in dbforge(). The use of dbutils for database manipulation
|
||||
* is STRONGLY discouraged in favour if using dbforge.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Create database
|
||||
*
|
||||
* @access private
|
||||
* @param string the database name
|
||||
* @return bool
|
||||
*/
|
||||
function _create_database($name)
|
||||
{
|
||||
return "CREATE DATABASE ".$name;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Drop database
|
||||
*
|
||||
* @access private
|
||||
* @param string the database name
|
||||
* @return bool
|
||||
*/
|
||||
function _drop_database($name)
|
||||
{
|
||||
return "DROP DATABASE ".$name;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* End of file mysqli_utility.php */
|
||||
/* Location: ./system/database/drivers/mysqli/mysqli_utility.php */
|
||||
10
system/database/drivers/oci8/index.html
Normal file
10
system/database/drivers/oci8/index.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
780
system/database/drivers/oci8/oci8_driver.php
Normal file
780
system/database/drivers/oci8/oci8_driver.php
Normal file
@@ -0,0 +1,780 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP 4.3.2 or newer
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2010, EllisLab, Inc.
|
||||
* @license http://codeigniter.com/user_guide/license.html
|
||||
* @link http://codeigniter.com
|
||||
* @since Version 1.0
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* oci8 Database Adapter Class
|
||||
*
|
||||
* Note: _DB is an extender class that the app controller
|
||||
* creates dynamically based on whether the active record
|
||||
* class is being used or not.
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @subpackage Drivers
|
||||
* @category Database
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @link http://codeigniter.com/user_guide/database/
|
||||
*/
|
||||
|
||||
/**
|
||||
* oci8 Database Adapter Class
|
||||
*
|
||||
* This is a modification of the DB_driver class to
|
||||
* permit access to oracle databases
|
||||
*
|
||||
* NOTE: this uses the PHP 4 oci methods
|
||||
*
|
||||
* @author Kelly McArdle
|
||||
*
|
||||
*/
|
||||
|
||||
class CI_DB_oci8_driver extends CI_DB {
|
||||
|
||||
var $dbdriver = 'oci8';
|
||||
|
||||
// The character used for excaping
|
||||
var $_escape_char = '"';
|
||||
|
||||
// clause and character used for LIKE escape sequences
|
||||
var $_like_escape_str = " escape '%s' ";
|
||||
var $_like_escape_chr = '!';
|
||||
|
||||
/**
|
||||
* The syntax to count rows is slightly different across different
|
||||
* database engines, so this string appears in each driver and is
|
||||
* used for the count_all() and count_all_results() functions.
|
||||
*/
|
||||
var $_count_string = "SELECT COUNT(1) AS ";
|
||||
var $_random_keyword = ' ASC'; // not currently supported
|
||||
|
||||
// Set "auto commit" by default
|
||||
var $_commit = OCI_COMMIT_ON_SUCCESS;
|
||||
|
||||
// need to track statement id and cursor id
|
||||
var $stmt_id;
|
||||
var $curs_id;
|
||||
|
||||
// if we use a limit, we will add a field that will
|
||||
// throw off num_fields later
|
||||
var $limit_used;
|
||||
|
||||
/**
|
||||
* Non-persistent database connection
|
||||
*
|
||||
* @access private called by the base class
|
||||
* @return resource
|
||||
*/
|
||||
function db_connect()
|
||||
{
|
||||
return @ocilogon($this->username, $this->password, $this->hostname);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Persistent database connection
|
||||
*
|
||||
* @access private called by the base class
|
||||
* @return resource
|
||||
*/
|
||||
function db_pconnect()
|
||||
{
|
||||
return @ociplogon($this->username, $this->password, $this->hostname);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Reconnect
|
||||
*
|
||||
* Keep / reestablish the db connection if no queries have been
|
||||
* sent for a length of time exceeding the server's idle timeout
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function reconnect()
|
||||
{
|
||||
// not implemented in oracle
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Select the database
|
||||
*
|
||||
* @access private called by the base class
|
||||
* @return resource
|
||||
*/
|
||||
function db_select()
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Set client character set
|
||||
*
|
||||
* @access public
|
||||
* @param string
|
||||
* @param string
|
||||
* @return resource
|
||||
*/
|
||||
function db_set_charset($charset, $collation)
|
||||
{
|
||||
// @todo - add support if needed
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Version number query string
|
||||
*
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
function _version()
|
||||
{
|
||||
return ociserverversion($this->conn_id);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Execute the query
|
||||
*
|
||||
* @access private called by the base class
|
||||
* @param string an SQL query
|
||||
* @return resource
|
||||
*/
|
||||
function _execute($sql)
|
||||
{
|
||||
// oracle must parse the query before it is run. All of the actions with
|
||||
// the query are based on the statement id returned by ociparse
|
||||
$this->stmt_id = FALSE;
|
||||
$this->_set_stmt_id($sql);
|
||||
ocisetprefetch($this->stmt_id, 1000);
|
||||
return @ociexecute($this->stmt_id, $this->_commit);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a statement ID
|
||||
*
|
||||
* @access private
|
||||
* @param string an SQL query
|
||||
* @return none
|
||||
*/
|
||||
function _set_stmt_id($sql)
|
||||
{
|
||||
if ( ! is_resource($this->stmt_id))
|
||||
{
|
||||
$this->stmt_id = ociparse($this->conn_id, $this->_prep_query($sql));
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Prep the query
|
||||
*
|
||||
* If needed, each database adapter can prep the query string
|
||||
*
|
||||
* @access private called by execute()
|
||||
* @param string an SQL query
|
||||
* @return string
|
||||
*/
|
||||
function _prep_query($sql)
|
||||
{
|
||||
return $sql;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* getCursor. Returns a cursor from the datbase
|
||||
*
|
||||
* @access public
|
||||
* @return cursor id
|
||||
*/
|
||||
function get_cursor()
|
||||
{
|
||||
$this->curs_id = ocinewcursor($this->conn_id);
|
||||
return $this->curs_id;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Stored Procedure. Executes a stored procedure
|
||||
*
|
||||
* @access public
|
||||
* @param package package stored procedure is in
|
||||
* @param procedure stored procedure to execute
|
||||
* @param params array of parameters
|
||||
* @return array
|
||||
*
|
||||
* params array keys
|
||||
*
|
||||
* KEY OPTIONAL NOTES
|
||||
* name no the name of the parameter should be in :<param_name> format
|
||||
* value no the value of the parameter. If this is an OUT or IN OUT parameter,
|
||||
* this should be a reference to a variable
|
||||
* type yes the type of the parameter
|
||||
* length yes the max size of the parameter
|
||||
*/
|
||||
function stored_procedure($package, $procedure, $params)
|
||||
{
|
||||
if ($package == '' OR $procedure == '' OR ! is_array($params))
|
||||
{
|
||||
if ($this->db_debug)
|
||||
{
|
||||
log_message('error', 'Invalid query: '.$package.'.'.$procedure);
|
||||
return $this->display_error('db_invalid_query');
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// build the query string
|
||||
$sql = "begin $package.$procedure(";
|
||||
|
||||
$have_cursor = FALSE;
|
||||
foreach($params as $param)
|
||||
{
|
||||
$sql .= $param['name'] . ",";
|
||||
|
||||
if (array_key_exists('type', $param) && ($param['type'] == OCI_B_CURSOR))
|
||||
{
|
||||
$have_cursor = TRUE;
|
||||
}
|
||||
}
|
||||
$sql = trim($sql, ",") . "); end;";
|
||||
|
||||
$this->stmt_id = FALSE;
|
||||
$this->_set_stmt_id($sql);
|
||||
$this->_bind_params($params);
|
||||
$this->query($sql, FALSE, $have_cursor);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Bind parameters
|
||||
*
|
||||
* @access private
|
||||
* @return none
|
||||
*/
|
||||
function _bind_params($params)
|
||||
{
|
||||
if ( ! is_array($params) OR ! is_resource($this->stmt_id))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($params as $param)
|
||||
{
|
||||
foreach (array('name', 'value', 'type', 'length') as $val)
|
||||
{
|
||||
if ( ! isset($param[$val]))
|
||||
{
|
||||
$param[$val] = '';
|
||||
}
|
||||
}
|
||||
|
||||
ocibindbyname($this->stmt_id, $param['name'], $param['value'], $param['length'], $param['type']);
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Begin Transaction
|
||||
*
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
function trans_begin($test_mode = FALSE)
|
||||
{
|
||||
if ( ! $this->trans_enabled)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// When transactions are nested we only begin/commit/rollback the outermost ones
|
||||
if ($this->_trans_depth > 0)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// Reset the transaction failure flag.
|
||||
// If the $test_mode flag is set to TRUE transactions will be rolled back
|
||||
// even if the queries produce a successful result.
|
||||
$this->_trans_failure = ($test_mode === TRUE) ? TRUE : FALSE;
|
||||
|
||||
$this->_commit = OCI_DEFAULT;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Commit Transaction
|
||||
*
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
function trans_commit()
|
||||
{
|
||||
if ( ! $this->trans_enabled)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// When transactions are nested we only begin/commit/rollback the outermost ones
|
||||
if ($this->_trans_depth > 0)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
$ret = OCIcommit($this->conn_id);
|
||||
$this->_commit = OCI_COMMIT_ON_SUCCESS;
|
||||
return $ret;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Rollback Transaction
|
||||
*
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
function trans_rollback()
|
||||
{
|
||||
if ( ! $this->trans_enabled)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// When transactions are nested we only begin/commit/rollback the outermost ones
|
||||
if ($this->_trans_depth > 0)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
$ret = OCIrollback($this->conn_id);
|
||||
$this->_commit = OCI_COMMIT_ON_SUCCESS;
|
||||
return $ret;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Escape String
|
||||
*
|
||||
* @access public
|
||||
* @param string
|
||||
* @param bool whether or not the string will be used in a LIKE condition
|
||||
* @return string
|
||||
*/
|
||||
function escape_str($str, $like = FALSE)
|
||||
{
|
||||
if (is_array($str))
|
||||
{
|
||||
foreach($str as $key => $val)
|
||||
{
|
||||
$str[$key] = $this->escape_str($val, $like);
|
||||
}
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
// Access the CI object
|
||||
$CI =& get_instance();
|
||||
|
||||
$str = $CI->input->_remove_invisible_characters($str);
|
||||
|
||||
// escape LIKE condition wildcards
|
||||
if ($like === TRUE)
|
||||
{
|
||||
$str = str_replace( array('%', '_', $this->_like_escape_chr),
|
||||
array($this->_like_escape_chr.'%', $this->_like_escape_chr.'_', $this->_like_escape_chr.$this->_like_escape_chr),
|
||||
$str);
|
||||
}
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Affected Rows
|
||||
*
|
||||
* @access public
|
||||
* @return integer
|
||||
*/
|
||||
function affected_rows()
|
||||
{
|
||||
return @ocirowcount($this->stmt_id);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Insert ID
|
||||
*
|
||||
* @access public
|
||||
* @return integer
|
||||
*/
|
||||
function insert_id()
|
||||
{
|
||||
// not supported in oracle
|
||||
return $this->display_error('db_unsupported_function');
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* "Count All" query
|
||||
*
|
||||
* Generates a platform-specific query string that counts all records in
|
||||
* the specified database
|
||||
*
|
||||
* @access public
|
||||
* @param string
|
||||
* @return string
|
||||
*/
|
||||
function count_all($table = '')
|
||||
{
|
||||
if ($table == '')
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
$query = $this->query($this->_count_string . $this->_protect_identifiers('numrows') . " FROM " . $this->_protect_identifiers($table, TRUE, NULL, FALSE));
|
||||
|
||||
if ($query == FALSE)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
$row = $query->row();
|
||||
return (int) $row->numrows;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Show table query
|
||||
*
|
||||
* Generates a platform-specific query string so that the table names can be fetched
|
||||
*
|
||||
* @access private
|
||||
* @param boolean
|
||||
* @return string
|
||||
*/
|
||||
function _list_tables($prefix_limit = FALSE)
|
||||
{
|
||||
$sql = "SELECT TABLE_NAME FROM ALL_TABLES";
|
||||
|
||||
if ($prefix_limit !== FALSE AND $this->dbprefix != '')
|
||||
{
|
||||
$sql .= " WHERE TABLE_NAME LIKE '".$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_char);
|
||||
}
|
||||
|
||||
return $sql;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Show column query
|
||||
*
|
||||
* Generates a platform-specific query string so that the column names can be fetched
|
||||
*
|
||||
* @access public
|
||||
* @param string the table name
|
||||
* @return string
|
||||
*/
|
||||
function _list_columns($table = '')
|
||||
{
|
||||
return "SELECT COLUMN_NAME FROM all_tab_columns WHERE table_name = '$table'";
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Field data query
|
||||
*
|
||||
* Generates a platform-specific query so that the column data can be retrieved
|
||||
*
|
||||
* @access public
|
||||
* @param string the table name
|
||||
* @return object
|
||||
*/
|
||||
function _field_data($table)
|
||||
{
|
||||
return "SELECT * FROM ".$table." where rownum = 1";
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* The error message string
|
||||
*
|
||||
* @access private
|
||||
* @return string
|
||||
*/
|
||||
function _error_message()
|
||||
{
|
||||
$error = ocierror($this->conn_id);
|
||||
return $error['message'];
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* The error message number
|
||||
*
|
||||
* @access private
|
||||
* @return integer
|
||||
*/
|
||||
function _error_number()
|
||||
{
|
||||
$error = ocierror($this->conn_id);
|
||||
return $error['code'];
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Escape the SQL Identifiers
|
||||
*
|
||||
* This function escapes column and table names
|
||||
*
|
||||
* @access private
|
||||
* @param string
|
||||
* @return string
|
||||
*/
|
||||
function _escape_identifiers($item)
|
||||
{
|
||||
if ($this->_escape_char == '')
|
||||
{
|
||||
return $item;
|
||||
}
|
||||
|
||||
foreach ($this->_reserved_identifiers as $id)
|
||||
{
|
||||
if (strpos($item, '.'.$id) !== FALSE)
|
||||
{
|
||||
$str = $this->_escape_char. str_replace('.', $this->_escape_char.'.', $item);
|
||||
|
||||
// remove duplicates if the user already included the escape
|
||||
return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str);
|
||||
}
|
||||
}
|
||||
|
||||
if (strpos($item, '.') !== FALSE)
|
||||
{
|
||||
$str = $this->_escape_char.str_replace('.', $this->_escape_char.'.'.$this->_escape_char, $item).$this->_escape_char;
|
||||
}
|
||||
else
|
||||
{
|
||||
$str = $this->_escape_char.$item.$this->_escape_char;
|
||||
}
|
||||
|
||||
// remove duplicates if the user already included the escape
|
||||
return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* From Tables
|
||||
*
|
||||
* This function implicitly groups FROM tables so there is no confusion
|
||||
* about operator precedence in harmony with SQL standards
|
||||
*
|
||||
* @access public
|
||||
* @param type
|
||||
* @return type
|
||||
*/
|
||||
function _from_tables($tables)
|
||||
{
|
||||
if ( ! is_array($tables))
|
||||
{
|
||||
$tables = array($tables);
|
||||
}
|
||||
|
||||
return implode(', ', $tables);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Insert statement
|
||||
*
|
||||
* Generates a platform-specific insert string from the supplied data
|
||||
*
|
||||
* @access public
|
||||
* @param string the table name
|
||||
* @param array the insert keys
|
||||
* @param array the insert values
|
||||
* @return string
|
||||
*/
|
||||
function _insert($table, $keys, $values)
|
||||
{
|
||||
return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")";
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Update statement
|
||||
*
|
||||
* Generates a platform-specific update string from the supplied data
|
||||
*
|
||||
* @access public
|
||||
* @param string the table name
|
||||
* @param array the update data
|
||||
* @param array the where clause
|
||||
* @param array the orderby clause
|
||||
* @param array the limit clause
|
||||
* @return string
|
||||
*/
|
||||
function _update($table, $values, $where, $orderby = array(), $limit = FALSE)
|
||||
{
|
||||
foreach($values as $key => $val)
|
||||
{
|
||||
$valstr[] = $key." = ".$val;
|
||||
}
|
||||
|
||||
$limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
|
||||
|
||||
$orderby = (count($orderby) >= 1)?' ORDER BY '.implode(", ", $orderby):'';
|
||||
|
||||
$sql = "UPDATE ".$table." SET ".implode(', ', $valstr);
|
||||
|
||||
$sql .= ($where != '' AND count($where) >=1) ? " WHERE ".implode(" ", $where) : '';
|
||||
|
||||
$sql .= $orderby.$limit;
|
||||
|
||||
return $sql;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Truncate statement
|
||||
*
|
||||
* Generates a platform-specific truncate string from the supplied data
|
||||
* If the database does not support the truncate() command
|
||||
* This function maps to "DELETE FROM table"
|
||||
*
|
||||
* @access public
|
||||
* @param string the table name
|
||||
* @return string
|
||||
*/
|
||||
function _truncate($table)
|
||||
{
|
||||
return "TRUNCATE TABLE ".$table;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Delete statement
|
||||
*
|
||||
* Generates a platform-specific delete string from the supplied data
|
||||
*
|
||||
* @access public
|
||||
* @param string the table name
|
||||
* @param array the where clause
|
||||
* @param string the limit clause
|
||||
* @return string
|
||||
*/
|
||||
function _delete($table, $where = array(), $like = array(), $limit = FALSE)
|
||||
{
|
||||
$conditions = '';
|
||||
|
||||
if (count($where) > 0 OR count($like) > 0)
|
||||
{
|
||||
$conditions = "\nWHERE ";
|
||||
$conditions .= implode("\n", $this->ar_where);
|
||||
|
||||
if (count($where) > 0 && count($like) > 0)
|
||||
{
|
||||
$conditions .= " AND ";
|
||||
}
|
||||
$conditions .= implode("\n", $like);
|
||||
}
|
||||
|
||||
$limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
|
||||
|
||||
return "DELETE FROM ".$table.$conditions.$limit;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Limit string
|
||||
*
|
||||
* Generates a platform-specific LIMIT clause
|
||||
*
|
||||
* @access public
|
||||
* @param string the sql query string
|
||||
* @param integer the number of rows to limit the query to
|
||||
* @param integer the offset value
|
||||
* @return string
|
||||
*/
|
||||
function _limit($sql, $limit, $offset)
|
||||
{
|
||||
$limit = $offset + $limit;
|
||||
$newsql = "SELECT * FROM (select inner_query.*, rownum rnum FROM ($sql) inner_query WHERE rownum < $limit)";
|
||||
|
||||
if ($offset != 0)
|
||||
{
|
||||
$newsql .= " WHERE rnum >= $offset";
|
||||
}
|
||||
|
||||
// remember that we used limits
|
||||
$this->limit_used = TRUE;
|
||||
|
||||
return $newsql;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Close DB Connection
|
||||
*
|
||||
* @access public
|
||||
* @param resource
|
||||
* @return void
|
||||
*/
|
||||
function _close($conn_id)
|
||||
{
|
||||
@ocilogoff($conn_id);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* End of file oci8_driver.php */
|
||||
/* Location: ./system/database/drivers/oci8/oci8_driver.php */
|
||||
248
system/database/drivers/oci8/oci8_forge.php
Normal file
248
system/database/drivers/oci8/oci8_forge.php
Normal file
@@ -0,0 +1,248 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP 4.3.2 or newer
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2010, EllisLab, Inc.
|
||||
* @license http://codeigniter.com/user_guide/license.html
|
||||
* @link http://codeigniter.com
|
||||
* @since Version 1.0
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Oracle Forge Class
|
||||
*
|
||||
* @category Database
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @link http://codeigniter.com/user_guide/database/
|
||||
*/
|
||||
class CI_DB_oci8_forge extends CI_DB_forge {
|
||||
|
||||
/**
|
||||
* Create database
|
||||
*
|
||||
* @access public
|
||||
* @param string the database name
|
||||
* @return bool
|
||||
*/
|
||||
function _create_database($name)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Drop database
|
||||
*
|
||||
* @access private
|
||||
* @param string the database name
|
||||
* @return bool
|
||||
*/
|
||||
function _drop_database($name)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Create Table
|
||||
*
|
||||
* @access private
|
||||
* @param string the table name
|
||||
* @param array the fields
|
||||
* @param mixed primary key(s)
|
||||
* @param mixed key(s)
|
||||
* @param boolean should 'IF NOT EXISTS' be added to the SQL
|
||||
* @return bool
|
||||
*/
|
||||
function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists)
|
||||
{
|
||||
$sql = 'CREATE TABLE ';
|
||||
|
||||
if ($if_not_exists === TRUE)
|
||||
{
|
||||
$sql .= 'IF NOT EXISTS ';
|
||||
}
|
||||
|
||||
$sql .= $this->db->_escape_identifiers($table)." (";
|
||||
$current_field_count = 0;
|
||||
|
||||
foreach ($fields as $field=>$attributes)
|
||||
{
|
||||
// Numeric field names aren't allowed in databases, so if the key is
|
||||
// numeric, we know it was assigned by PHP and the developer manually
|
||||
// entered the field information, so we'll simply add it to the list
|
||||
if (is_numeric($field))
|
||||
{
|
||||
$sql .= "\n\t$attributes";
|
||||
}
|
||||
else
|
||||
{
|
||||
$attributes = array_change_key_case($attributes, CASE_UPPER);
|
||||
|
||||
$sql .= "\n\t".$this->db->_protect_identifiers($field);
|
||||
|
||||
$sql .= ' '.$attributes['TYPE'];
|
||||
|
||||
if (array_key_exists('CONSTRAINT', $attributes))
|
||||
{
|
||||
$sql .= '('.$attributes['CONSTRAINT'].')';
|
||||
}
|
||||
|
||||
if (array_key_exists('UNSIGNED', $attributes) && $attributes['UNSIGNED'] === TRUE)
|
||||
{
|
||||
$sql .= ' UNSIGNED';
|
||||
}
|
||||
|
||||
if (array_key_exists('DEFAULT', $attributes))
|
||||
{
|
||||
$sql .= ' DEFAULT \''.$attributes['DEFAULT'].'\'';
|
||||
}
|
||||
|
||||
if (array_key_exists('NULL', $attributes) && $attributes['NULL'] === TRUE)
|
||||
{
|
||||
$sql .= ' NULL';
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql .= ' NOT NULL';
|
||||
}
|
||||
|
||||
if (array_key_exists('AUTO_INCREMENT', $attributes) && $attributes['AUTO_INCREMENT'] === TRUE)
|
||||
{
|
||||
$sql .= ' AUTO_INCREMENT';
|
||||
}
|
||||
}
|
||||
|
||||
// don't add a comma on the end of the last field
|
||||
if (++$current_field_count < count($fields))
|
||||
{
|
||||
$sql .= ',';
|
||||
}
|
||||
}
|
||||
|
||||
if (count($primary_keys) > 0)
|
||||
{
|
||||
$primary_keys = $this->db->_protect_identifiers($primary_keys);
|
||||
$sql .= ",\n\tPRIMARY KEY (" . implode(', ', $primary_keys) . ")";
|
||||
}
|
||||
|
||||
if (is_array($keys) && count($keys) > 0)
|
||||
{
|
||||
foreach ($keys as $key)
|
||||
{
|
||||
if (is_array($key))
|
||||
{
|
||||
$key = $this->db->_protect_identifiers($key);
|
||||
}
|
||||
else
|
||||
{
|
||||
$key = array($this->db->_protect_identifiers($key));
|
||||
}
|
||||
|
||||
$sql .= ",\n\tUNIQUE COLUMNS (" . implode(', ', $key) . ")";
|
||||
}
|
||||
}
|
||||
|
||||
$sql .= "\n)";
|
||||
|
||||
return $sql;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Drop Table
|
||||
*
|
||||
* @access private
|
||||
* @return bool
|
||||
*/
|
||||
function _drop_table($table)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Alter table query
|
||||
*
|
||||
* Generates a platform-specific query so that a table can be altered
|
||||
* Called by add_column(), drop_column(), and column_alter(),
|
||||
*
|
||||
* @access private
|
||||
* @param string the ALTER type (ADD, DROP, CHANGE)
|
||||
* @param string the column name
|
||||
* @param string the table name
|
||||
* @param string the column definition
|
||||
* @param string the default value
|
||||
* @param boolean should 'NOT NULL' be added
|
||||
* @param string the field after which we should add the new field
|
||||
* @return object
|
||||
*/
|
||||
function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '')
|
||||
{
|
||||
$sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table)." $alter_type ".$this->db->_protect_identifiers($column_name);
|
||||
|
||||
// DROP has everything it needs now.
|
||||
if ($alter_type == 'DROP')
|
||||
{
|
||||
return $sql;
|
||||
}
|
||||
|
||||
$sql .= " $column_definition";
|
||||
|
||||
if ($default_value != '')
|
||||
{
|
||||
$sql .= " DEFAULT \"$default_value\"";
|
||||
}
|
||||
|
||||
if ($null === NULL)
|
||||
{
|
||||
$sql .= ' NULL';
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql .= ' NOT NULL';
|
||||
}
|
||||
|
||||
if ($after_field != '')
|
||||
{
|
||||
$sql .= ' AFTER ' . $this->db->_protect_identifiers($after_field);
|
||||
}
|
||||
|
||||
return $sql;
|
||||
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Rename a table
|
||||
*
|
||||
* Generates a platform-specific query so that a table can be renamed
|
||||
*
|
||||
* @access private
|
||||
* @param string the old table name
|
||||
* @param string the new table name
|
||||
* @return string
|
||||
*/
|
||||
function _rename_table($table_name, $new_table_name)
|
||||
{
|
||||
$sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table_name)." RENAME TO ".$this->db->_protect_identifiers($new_table_name);
|
||||
return $sql;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/* End of file oci8_forge.php */
|
||||
/* Location: ./system/database/drivers/oci8/oci8_forge.php */
|
||||
249
system/database/drivers/oci8/oci8_result.php
Normal file
249
system/database/drivers/oci8/oci8_result.php
Normal file
@@ -0,0 +1,249 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP 4.3.2 or newer
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2010, EllisLab, Inc.
|
||||
* @license http://codeigniter.com/user_guide/license.html
|
||||
* @link http://codeigniter.com
|
||||
* @since Version 1.0
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* oci8 Result Class
|
||||
*
|
||||
* This class extends the parent result class: CI_DB_result
|
||||
*
|
||||
* @category Database
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @link http://codeigniter.com/user_guide/database/
|
||||
*/
|
||||
class CI_DB_oci8_result extends CI_DB_result {
|
||||
|
||||
var $stmt_id;
|
||||
var $curs_id;
|
||||
var $limit_used;
|
||||
|
||||
/**
|
||||
* Number of rows in the result set.
|
||||
*
|
||||
* Oracle doesn't have a graceful way to retun the number of rows
|
||||
* so we have to use what amounts to a hack.
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @return integer
|
||||
*/
|
||||
function num_rows()
|
||||
{
|
||||
$rowcount = count($this->result_array());
|
||||
@ociexecute($this->stmt_id);
|
||||
|
||||
if ($this->curs_id)
|
||||
{
|
||||
@ociexecute($this->curs_id);
|
||||
}
|
||||
|
||||
return $rowcount;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Number of fields in the result set
|
||||
*
|
||||
* @access public
|
||||
* @return integer
|
||||
*/
|
||||
function num_fields()
|
||||
{
|
||||
$count = @ocinumcols($this->stmt_id);
|
||||
|
||||
// if we used a limit we subtract it
|
||||
if ($this->limit_used)
|
||||
{
|
||||
$count = $count - 1;
|
||||
}
|
||||
|
||||
return $count;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Fetch Field Names
|
||||
*
|
||||
* Generates an array of column names
|
||||
*
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
function list_fields()
|
||||
{
|
||||
$field_names = array();
|
||||
$fieldCount = $this->num_fields();
|
||||
for ($c = 1; $c <= $fieldCount; $c++)
|
||||
{
|
||||
$field_names[] = ocicolumnname($this->stmt_id, $c);
|
||||
}
|
||||
return $field_names;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Field data
|
||||
*
|
||||
* Generates an array of objects containing field meta-data
|
||||
*
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
function field_data()
|
||||
{
|
||||
$retval = array();
|
||||
$fieldCount = $this->num_fields();
|
||||
for ($c = 1; $c <= $fieldCount; $c++)
|
||||
{
|
||||
$F = new stdClass();
|
||||
$F->name = ocicolumnname($this->stmt_id, $c);
|
||||
$F->type = ocicolumntype($this->stmt_id, $c);
|
||||
$F->max_length = ocicolumnsize($this->stmt_id, $c);
|
||||
|
||||
$retval[] = $F;
|
||||
}
|
||||
|
||||
return $retval;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Free the result
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
function free_result()
|
||||
{
|
||||
if (is_resource($this->result_id))
|
||||
{
|
||||
ocifreestatement($this->result_id);
|
||||
$this->result_id = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Result - associative array
|
||||
*
|
||||
* Returns the result set as an array
|
||||
*
|
||||
* @access private
|
||||
* @return array
|
||||
*/
|
||||
function _fetch_assoc(&$row)
|
||||
{
|
||||
$id = ($this->curs_id) ? $this->curs_id : $this->stmt_id;
|
||||
|
||||
return ocifetchinto($id, $row, OCI_ASSOC + OCI_RETURN_NULLS);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Result - object
|
||||
*
|
||||
* Returns the result set as an object
|
||||
*
|
||||
* @access private
|
||||
* @return object
|
||||
*/
|
||||
function _fetch_object()
|
||||
{
|
||||
$result = array();
|
||||
|
||||
// If PHP 5 is being used we can fetch an result object
|
||||
if (function_exists('oci_fetch_object'))
|
||||
{
|
||||
$id = ($this->curs_id) ? $this->curs_id : $this->stmt_id;
|
||||
|
||||
return @oci_fetch_object($id);
|
||||
}
|
||||
|
||||
// If PHP 4 is being used we have to build our own result
|
||||
foreach ($this->result_array() as $key => $val)
|
||||
{
|
||||
$obj = new stdClass();
|
||||
if (is_array($val))
|
||||
{
|
||||
foreach ($val as $k => $v)
|
||||
{
|
||||
$obj->$k = $v;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$obj->$key = $val;
|
||||
}
|
||||
|
||||
$result[] = $obj;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Query result. "array" version.
|
||||
*
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
function result_array()
|
||||
{
|
||||
if (count($this->result_array) > 0)
|
||||
{
|
||||
return $this->result_array;
|
||||
}
|
||||
|
||||
// oracle's fetch functions do not return arrays.
|
||||
// The information is returned in reference parameters
|
||||
$row = NULL;
|
||||
while ($this->_fetch_assoc($row))
|
||||
{
|
||||
$this->result_array[] = $row;
|
||||
}
|
||||
|
||||
return $this->result_array;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Data Seek
|
||||
*
|
||||
* Moves the internal pointer to the desired offset. We call
|
||||
* this internally before fetching results to make sure the
|
||||
* result set starts at zero
|
||||
*
|
||||
* @access private
|
||||
* @return array
|
||||
*/
|
||||
function _data_seek($n = 0)
|
||||
{
|
||||
return FALSE; // Not needed
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* End of file oci8_result.php */
|
||||
/* Location: ./system/database/drivers/oci8/oci8_result.php */
|
||||
122
system/database/drivers/oci8/oci8_utility.php
Normal file
122
system/database/drivers/oci8/oci8_utility.php
Normal file
@@ -0,0 +1,122 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP 4.3.2 or newer
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2010, EllisLab, Inc.
|
||||
* @license http://codeigniter.com/user_guide/license.html
|
||||
* @link http://codeigniter.com
|
||||
* @since Version 1.0
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Oracle Utility Class
|
||||
*
|
||||
* @category Database
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @link http://codeigniter.com/user_guide/database/
|
||||
*/
|
||||
class CI_DB_oci8_utility extends CI_DB_utility {
|
||||
|
||||
/**
|
||||
* List databases
|
||||
*
|
||||
* @access private
|
||||
* @return bool
|
||||
*/
|
||||
function _list_databases()
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Optimize table query
|
||||
*
|
||||
* Generates a platform-specific query so that a table can be optimized
|
||||
*
|
||||
* @access private
|
||||
* @param string the table name
|
||||
* @return object
|
||||
*/
|
||||
function _optimize_table($table)
|
||||
{
|
||||
return FALSE; // Is this supported in Oracle?
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Repair table query
|
||||
*
|
||||
* Generates a platform-specific query so that a table can be repaired
|
||||
*
|
||||
* @access private
|
||||
* @param string the table name
|
||||
* @return object
|
||||
*/
|
||||
function _repair_table($table)
|
||||
{
|
||||
return FALSE; // Is this supported in Oracle?
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Oracle Export
|
||||
*
|
||||
* @access private
|
||||
* @param array Preferences
|
||||
* @return mixed
|
||||
*/
|
||||
function _backup($params = array())
|
||||
{
|
||||
// Currently unsupported
|
||||
return $this->db->display_error('db_unsuported_feature');
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* The functions below have been deprecated as of 1.6, and are only here for backwards
|
||||
* compatibility. They now reside in dbforge(). The use of dbutils for database manipulation
|
||||
* is STRONGLY discouraged in favour if using dbforge.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Create database
|
||||
*
|
||||
* @access public
|
||||
* @param string the database name
|
||||
* @return bool
|
||||
*/
|
||||
function _create_database($name)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Drop database
|
||||
*
|
||||
* @access private
|
||||
* @param string the database name
|
||||
* @return bool
|
||||
*/
|
||||
function _drop_database($name)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* End of file oci8_utility.php */
|
||||
/* Location: ./system/database/drivers/oci8/oci8_utility.php */
|
||||
10
system/database/drivers/odbc/index.html
Normal file
10
system/database/drivers/odbc/index.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
639
system/database/drivers/odbc/odbc_driver.php
Normal file
639
system/database/drivers/odbc/odbc_driver.php
Normal file
@@ -0,0 +1,639 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP 4.3.2 or newer
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2010, EllisLab, Inc.
|
||||
* @license http://codeigniter.com/user_guide/license.html
|
||||
* @link http://codeigniter.com
|
||||
* @since Version 1.0
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* ODBC Database Adapter Class
|
||||
*
|
||||
* Note: _DB is an extender class that the app controller
|
||||
* creates dynamically based on whether the active record
|
||||
* class is being used or not.
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @subpackage Drivers
|
||||
* @category Database
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @link http://codeigniter.com/user_guide/database/
|
||||
*/
|
||||
class CI_DB_odbc_driver extends CI_DB {
|
||||
|
||||
var $dbdriver = 'odbc';
|
||||
|
||||
// the character used to excape - not necessary for ODBC
|
||||
var $_escape_char = '';
|
||||
|
||||
// clause and character used for LIKE escape sequences
|
||||
var $_like_escape_str = " {escape '%s'} ";
|
||||
var $_like_escape_chr = '!';
|
||||
|
||||
/**
|
||||
* The syntax to count rows is slightly different across different
|
||||
* database engines, so this string appears in each driver and is
|
||||
* used for the count_all() and count_all_results() functions.
|
||||
*/
|
||||
var $_count_string = "SELECT COUNT(*) AS ";
|
||||
var $_random_keyword;
|
||||
|
||||
|
||||
function CI_DB_odbc_driver($params)
|
||||
{
|
||||
parent::CI_DB($params);
|
||||
|
||||
$this->_random_keyword = ' RND('.time().')'; // database specific random keyword
|
||||
}
|
||||
|
||||
/**
|
||||
* Non-persistent database connection
|
||||
*
|
||||
* @access private called by the base class
|
||||
* @return resource
|
||||
*/
|
||||
function db_connect()
|
||||
{
|
||||
return @odbc_connect($this->hostname, $this->username, $this->password);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Persistent database connection
|
||||
*
|
||||
* @access private called by the base class
|
||||
* @return resource
|
||||
*/
|
||||
function db_pconnect()
|
||||
{
|
||||
return @odbc_pconnect($this->hostname, $this->username, $this->password);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Reconnect
|
||||
*
|
||||
* Keep / reestablish the db connection if no queries have been
|
||||
* sent for a length of time exceeding the server's idle timeout
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function reconnect()
|
||||
{
|
||||
// not implemented in odbc
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Select the database
|
||||
*
|
||||
* @access private called by the base class
|
||||
* @return resource
|
||||
*/
|
||||
function db_select()
|
||||
{
|
||||
// Not needed for ODBC
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Set client character set
|
||||
*
|
||||
* @access public
|
||||
* @param string
|
||||
* @param string
|
||||
* @return resource
|
||||
*/
|
||||
function db_set_charset($charset, $collation)
|
||||
{
|
||||
// @todo - add support if needed
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Version number query string
|
||||
*
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
function _version()
|
||||
{
|
||||
return "SELECT version() AS ver";
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Execute the query
|
||||
*
|
||||
* @access private called by the base class
|
||||
* @param string an SQL query
|
||||
* @return resource
|
||||
*/
|
||||
function _execute($sql)
|
||||
{
|
||||
$sql = $this->_prep_query($sql);
|
||||
return @odbc_exec($this->conn_id, $sql);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Prep the query
|
||||
*
|
||||
* If needed, each database adapter can prep the query string
|
||||
*
|
||||
* @access private called by execute()
|
||||
* @param string an SQL query
|
||||
* @return string
|
||||
*/
|
||||
function _prep_query($sql)
|
||||
{
|
||||
return $sql;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Begin Transaction
|
||||
*
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
function trans_begin($test_mode = FALSE)
|
||||
{
|
||||
if ( ! $this->trans_enabled)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// When transactions are nested we only begin/commit/rollback the outermost ones
|
||||
if ($this->_trans_depth > 0)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// Reset the transaction failure flag.
|
||||
// If the $test_mode flag is set to TRUE transactions will be rolled back
|
||||
// even if the queries produce a successful result.
|
||||
$this->_trans_failure = ($test_mode === TRUE) ? TRUE : FALSE;
|
||||
|
||||
return odbc_autocommit($this->conn_id, FALSE);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Commit Transaction
|
||||
*
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
function trans_commit()
|
||||
{
|
||||
if ( ! $this->trans_enabled)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// When transactions are nested we only begin/commit/rollback the outermost ones
|
||||
if ($this->_trans_depth > 0)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
$ret = odbc_commit($this->conn_id);
|
||||
odbc_autocommit($this->conn_id, TRUE);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Rollback Transaction
|
||||
*
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
function trans_rollback()
|
||||
{
|
||||
if ( ! $this->trans_enabled)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// When transactions are nested we only begin/commit/rollback the outermost ones
|
||||
if ($this->_trans_depth > 0)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
$ret = odbc_rollback($this->conn_id);
|
||||
odbc_autocommit($this->conn_id, TRUE);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Escape String
|
||||
*
|
||||
* @access public
|
||||
* @param string
|
||||
* @param bool whether or not the string will be used in a LIKE condition
|
||||
* @return string
|
||||
*/
|
||||
function escape_str($str, $like = FALSE)
|
||||
{
|
||||
if (is_array($str))
|
||||
{
|
||||
foreach($str as $key => $val)
|
||||
{
|
||||
$str[$key] = $this->escape_str($val, $like);
|
||||
}
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
// Access the CI object
|
||||
$CI =& get_instance();
|
||||
|
||||
// ODBC doesn't require escaping
|
||||
$str = $CI->input->_remove_invisible_characters($str);
|
||||
|
||||
// escape LIKE condition wildcards
|
||||
if ($like === TRUE)
|
||||
{
|
||||
$str = str_replace( array('%', '_', $this->_like_escape_chr),
|
||||
array($this->_like_escape_chr.'%', $this->_like_escape_chr.'_', $this->_like_escape_chr.$this->_like_escape_chr),
|
||||
$str);
|
||||
}
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Affected Rows
|
||||
*
|
||||
* @access public
|
||||
* @return integer
|
||||
*/
|
||||
function affected_rows()
|
||||
{
|
||||
return @odbc_num_rows($this->conn_id);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Insert ID
|
||||
*
|
||||
* @access public
|
||||
* @return integer
|
||||
*/
|
||||
function insert_id()
|
||||
{
|
||||
return @odbc_insert_id($this->conn_id);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* "Count All" query
|
||||
*
|
||||
* Generates a platform-specific query string that counts all records in
|
||||
* the specified database
|
||||
*
|
||||
* @access public
|
||||
* @param string
|
||||
* @return string
|
||||
*/
|
||||
function count_all($table = '')
|
||||
{
|
||||
if ($table == '')
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
$query = $this->query($this->_count_string . $this->_protect_identifiers('numrows') . " FROM " . $this->_protect_identifiers($table, TRUE, NULL, FALSE));
|
||||
|
||||
if ($query->num_rows() == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
$row = $query->row();
|
||||
return (int) $row->numrows;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Show table query
|
||||
*
|
||||
* Generates a platform-specific query string so that the table names can be fetched
|
||||
*
|
||||
* @access private
|
||||
* @param boolean
|
||||
* @return string
|
||||
*/
|
||||
function _list_tables($prefix_limit = FALSE)
|
||||
{
|
||||
$sql = "SHOW TABLES FROM `".$this->database."`";
|
||||
|
||||
if ($prefix_limit !== FALSE AND $this->dbprefix != '')
|
||||
{
|
||||
//$sql .= " LIKE '".$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_char);
|
||||
return FALSE; // not currently supported
|
||||
}
|
||||
|
||||
return $sql;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Show column query
|
||||
*
|
||||
* Generates a platform-specific query string so that the column names can be fetched
|
||||
*
|
||||
* @access public
|
||||
* @param string the table name
|
||||
* @return string
|
||||
*/
|
||||
function _list_columns($table = '')
|
||||
{
|
||||
return "SHOW COLUMNS FROM ".$table;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Field data query
|
||||
*
|
||||
* Generates a platform-specific query so that the column data can be retrieved
|
||||
*
|
||||
* @access public
|
||||
* @param string the table name
|
||||
* @return object
|
||||
*/
|
||||
function _field_data($table)
|
||||
{
|
||||
return "SELECT TOP 1 FROM ".$table;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* The error message string
|
||||
*
|
||||
* @access private
|
||||
* @return string
|
||||
*/
|
||||
function _error_message()
|
||||
{
|
||||
return odbc_errormsg($this->conn_id);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* The error message number
|
||||
*
|
||||
* @access private
|
||||
* @return integer
|
||||
*/
|
||||
function _error_number()
|
||||
{
|
||||
return odbc_error($this->conn_id);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Escape the SQL Identifiers
|
||||
*
|
||||
* This function escapes column and table names
|
||||
*
|
||||
* @access private
|
||||
* @param string
|
||||
* @return string
|
||||
*/
|
||||
function _escape_identifiers($item)
|
||||
{
|
||||
if ($this->_escape_char == '')
|
||||
{
|
||||
return $item;
|
||||
}
|
||||
|
||||
foreach ($this->_reserved_identifiers as $id)
|
||||
{
|
||||
if (strpos($item, '.'.$id) !== FALSE)
|
||||
{
|
||||
$str = $this->_escape_char. str_replace('.', $this->_escape_char.'.', $item);
|
||||
|
||||
// remove duplicates if the user already included the escape
|
||||
return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str);
|
||||
}
|
||||
}
|
||||
|
||||
if (strpos($item, '.') !== FALSE)
|
||||
{
|
||||
$str = $this->_escape_char.str_replace('.', $this->_escape_char.'.'.$this->_escape_char, $item).$this->_escape_char;
|
||||
}
|
||||
else
|
||||
{
|
||||
$str = $this->_escape_char.$item.$this->_escape_char;
|
||||
}
|
||||
|
||||
// remove duplicates if the user already included the escape
|
||||
return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* From Tables
|
||||
*
|
||||
* This function implicitly groups FROM tables so there is no confusion
|
||||
* about operator precedence in harmony with SQL standards
|
||||
*
|
||||
* @access public
|
||||
* @param type
|
||||
* @return type
|
||||
*/
|
||||
function _from_tables($tables)
|
||||
{
|
||||
if ( ! is_array($tables))
|
||||
{
|
||||
$tables = array($tables);
|
||||
}
|
||||
|
||||
return '('.implode(', ', $tables).')';
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Insert statement
|
||||
*
|
||||
* Generates a platform-specific insert string from the supplied data
|
||||
*
|
||||
* @access public
|
||||
* @param string the table name
|
||||
* @param array the insert keys
|
||||
* @param array the insert values
|
||||
* @return string
|
||||
*/
|
||||
function _insert($table, $keys, $values)
|
||||
{
|
||||
return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")";
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Update statement
|
||||
*
|
||||
* Generates a platform-specific update string from the supplied data
|
||||
*
|
||||
* @access public
|
||||
* @param string the table name
|
||||
* @param array the update data
|
||||
* @param array the where clause
|
||||
* @param array the orderby clause
|
||||
* @param array the limit clause
|
||||
* @return string
|
||||
*/
|
||||
function _update($table, $values, $where, $orderby = array(), $limit = FALSE)
|
||||
{
|
||||
foreach($values as $key => $val)
|
||||
{
|
||||
$valstr[] = $key." = ".$val;
|
||||
}
|
||||
|
||||
$limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
|
||||
|
||||
$orderby = (count($orderby) >= 1)?' ORDER BY '.implode(", ", $orderby):'';
|
||||
|
||||
$sql = "UPDATE ".$table." SET ".implode(', ', $valstr);
|
||||
|
||||
$sql .= ($where != '' AND count($where) >=1) ? " WHERE ".implode(" ", $where) : '';
|
||||
|
||||
$sql .= $orderby.$limit;
|
||||
|
||||
return $sql;
|
||||
}
|
||||
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Truncate statement
|
||||
*
|
||||
* Generates a platform-specific truncate string from the supplied data
|
||||
* If the database does not support the truncate() command
|
||||
* This function maps to "DELETE FROM table"
|
||||
*
|
||||
* @access public
|
||||
* @param string the table name
|
||||
* @return string
|
||||
*/
|
||||
function _truncate($table)
|
||||
{
|
||||
return $this->_delete($table);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Delete statement
|
||||
*
|
||||
* Generates a platform-specific delete string from the supplied data
|
||||
*
|
||||
* @access public
|
||||
* @param string the table name
|
||||
* @param array the where clause
|
||||
* @param string the limit clause
|
||||
* @return string
|
||||
*/
|
||||
function _delete($table, $where = array(), $like = array(), $limit = FALSE)
|
||||
{
|
||||
$conditions = '';
|
||||
|
||||
if (count($where) > 0 OR count($like) > 0)
|
||||
{
|
||||
$conditions = "\nWHERE ";
|
||||
$conditions .= implode("\n", $this->ar_where);
|
||||
|
||||
if (count($where) > 0 && count($like) > 0)
|
||||
{
|
||||
$conditions .= " AND ";
|
||||
}
|
||||
$conditions .= implode("\n", $like);
|
||||
}
|
||||
|
||||
$limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
|
||||
|
||||
return "DELETE FROM ".$table.$conditions.$limit;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Limit string
|
||||
*
|
||||
* Generates a platform-specific LIMIT clause
|
||||
*
|
||||
* @access public
|
||||
* @param string the sql query string
|
||||
* @param integer the number of rows to limit the query to
|
||||
* @param integer the offset value
|
||||
* @return string
|
||||
*/
|
||||
function _limit($sql, $limit, $offset)
|
||||
{
|
||||
// Does ODBC doesn't use the LIMIT clause?
|
||||
return $sql;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Close DB Connection
|
||||
*
|
||||
* @access public
|
||||
* @param resource
|
||||
* @return void
|
||||
*/
|
||||
function _close($conn_id)
|
||||
{
|
||||
@odbc_close($conn_id);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* End of file odbc_driver.php */
|
||||
/* Location: ./system/database/drivers/odbc/odbc_driver.php */
|
||||
266
system/database/drivers/odbc/odbc_forge.php
Normal file
266
system/database/drivers/odbc/odbc_forge.php
Normal file
@@ -0,0 +1,266 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP 4.3.2 or newer
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2010, EllisLab, Inc.
|
||||
* @license http://codeigniter.com/user_guide/license.html
|
||||
* @link http://codeigniter.com
|
||||
* @since Version 1.0
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* ODBC Forge Class
|
||||
*
|
||||
* @category Database
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @link http://codeigniter.com/database/
|
||||
*/
|
||||
class CI_DB_odbc_forge extends CI_DB_forge {
|
||||
|
||||
/**
|
||||
* Create database
|
||||
*
|
||||
* @access private
|
||||
* @param string the database name
|
||||
* @return bool
|
||||
*/
|
||||
function _create_database()
|
||||
{
|
||||
// ODBC has no "create database" command since it's
|
||||
// designed to connect to an existing database
|
||||
if ($this->db->db_debug)
|
||||
{
|
||||
return $this->db->display_error('db_unsuported_feature');
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Drop database
|
||||
*
|
||||
* @access private
|
||||
* @param string the database name
|
||||
* @return bool
|
||||
*/
|
||||
function _drop_database($name)
|
||||
{
|
||||
// ODBC has no "drop database" command since it's
|
||||
// designed to connect to an existing database
|
||||
if ($this->db->db_debug)
|
||||
{
|
||||
return $this->db->display_error('db_unsuported_feature');
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Create Table
|
||||
*
|
||||
* @access private
|
||||
* @param string the table name
|
||||
* @param array the fields
|
||||
* @param mixed primary key(s)
|
||||
* @param mixed key(s)
|
||||
* @param boolean should 'IF NOT EXISTS' be added to the SQL
|
||||
* @return bool
|
||||
*/
|
||||
function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists)
|
||||
{
|
||||
$sql = 'CREATE TABLE ';
|
||||
|
||||
if ($if_not_exists === TRUE)
|
||||
{
|
||||
$sql .= 'IF NOT EXISTS ';
|
||||
}
|
||||
|
||||
$sql .= $this->db->_escape_identifiers($table)." (";
|
||||
$current_field_count = 0;
|
||||
|
||||
foreach ($fields as $field=>$attributes)
|
||||
{
|
||||
// Numeric field names aren't allowed in databases, so if the key is
|
||||
// numeric, we know it was assigned by PHP and the developer manually
|
||||
// entered the field information, so we'll simply add it to the list
|
||||
if (is_numeric($field))
|
||||
{
|
||||
$sql .= "\n\t$attributes";
|
||||
}
|
||||
else
|
||||
{
|
||||
$attributes = array_change_key_case($attributes, CASE_UPPER);
|
||||
|
||||
$sql .= "\n\t".$this->db->_protect_identifiers($field);
|
||||
|
||||
$sql .= ' '.$attributes['TYPE'];
|
||||
|
||||
if (array_key_exists('CONSTRAINT', $attributes))
|
||||
{
|
||||
$sql .= '('.$attributes['CONSTRAINT'].')';
|
||||
}
|
||||
|
||||
if (array_key_exists('UNSIGNED', $attributes) && $attributes['UNSIGNED'] === TRUE)
|
||||
{
|
||||
$sql .= ' UNSIGNED';
|
||||
}
|
||||
|
||||
if (array_key_exists('DEFAULT', $attributes))
|
||||
{
|
||||
$sql .= ' DEFAULT \''.$attributes['DEFAULT'].'\'';
|
||||
}
|
||||
|
||||
if (array_key_exists('NULL', $attributes) && $attributes['NULL'] === TRUE)
|
||||
{
|
||||
$sql .= ' NULL';
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql .= ' NOT NULL';
|
||||
}
|
||||
|
||||
if (array_key_exists('AUTO_INCREMENT', $attributes) && $attributes['AUTO_INCREMENT'] === TRUE)
|
||||
{
|
||||
$sql .= ' AUTO_INCREMENT';
|
||||
}
|
||||
}
|
||||
|
||||
// don't add a comma on the end of the last field
|
||||
if (++$current_field_count < count($fields))
|
||||
{
|
||||
$sql .= ',';
|
||||
}
|
||||
}
|
||||
|
||||
if (count($primary_keys) > 0)
|
||||
{
|
||||
$primary_keys = $this->db->_protect_identifiers($primary_keys);
|
||||
$sql .= ",\n\tPRIMARY KEY (" . implode(', ', $primary_keys) . ")";
|
||||
}
|
||||
|
||||
if (is_array($keys) && count($keys) > 0)
|
||||
{
|
||||
foreach ($keys as $key)
|
||||
{
|
||||
if (is_array($key))
|
||||
{
|
||||
$key = $this->db->_protect_identifiers($key);
|
||||
}
|
||||
else
|
||||
{
|
||||
$key = array($this->db->_protect_identifiers($key));
|
||||
}
|
||||
|
||||
$sql .= ",\n\tFOREIGN KEY (" . implode(', ', $key) . ")";
|
||||
}
|
||||
}
|
||||
|
||||
$sql .= "\n)";
|
||||
|
||||
return $sql;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Drop Table
|
||||
*
|
||||
* @access private
|
||||
* @return bool
|
||||
*/
|
||||
function _drop_table($table)
|
||||
{
|
||||
// Not a supported ODBC feature
|
||||
if ($this->db->db_debug)
|
||||
{
|
||||
return $this->db->display_error('db_unsuported_feature');
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Alter table query
|
||||
*
|
||||
* Generates a platform-specific query so that a table can be altered
|
||||
* Called by add_column(), drop_column(), and column_alter(),
|
||||
*
|
||||
* @access private
|
||||
* @param string the ALTER type (ADD, DROP, CHANGE)
|
||||
* @param string the column name
|
||||
* @param string the table name
|
||||
* @param string the column definition
|
||||
* @param string the default value
|
||||
* @param boolean should 'NOT NULL' be added
|
||||
* @param string the field after which we should add the new field
|
||||
* @return object
|
||||
*/
|
||||
function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '')
|
||||
{
|
||||
$sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table)." $alter_type ".$this->db->_protect_identifiers($column_name);
|
||||
|
||||
// DROP has everything it needs now.
|
||||
if ($alter_type == 'DROP')
|
||||
{
|
||||
return $sql;
|
||||
}
|
||||
|
||||
$sql .= " $column_definition";
|
||||
|
||||
if ($default_value != '')
|
||||
{
|
||||
$sql .= " DEFAULT \"$default_value\"";
|
||||
}
|
||||
|
||||
if ($null === NULL)
|
||||
{
|
||||
$sql .= ' NULL';
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql .= ' NOT NULL';
|
||||
}
|
||||
|
||||
if ($after_field != '')
|
||||
{
|
||||
$sql .= ' AFTER ' . $this->db->_protect_identifiers($after_field);
|
||||
}
|
||||
|
||||
return $sql;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Rename a table
|
||||
*
|
||||
* Generates a platform-specific query so that a table can be renamed
|
||||
*
|
||||
* @access private
|
||||
* @param string the old table name
|
||||
* @param string the new table name
|
||||
* @return string
|
||||
*/
|
||||
function _rename_table($table_name, $new_table_name)
|
||||
{
|
||||
$sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table_name)." RENAME TO ".$this->db->_protect_identifiers($new_table_name);
|
||||
return $sql;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/* End of file odbc_forge.php */
|
||||
/* Location: ./system/database/drivers/odbc/odbc_forge.php */
|
||||
228
system/database/drivers/odbc/odbc_result.php
Normal file
228
system/database/drivers/odbc/odbc_result.php
Normal file
@@ -0,0 +1,228 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP 4.3.2 or newer
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2010, EllisLab, Inc.
|
||||
* @license http://codeigniter.com/user_guide/license.html
|
||||
* @link http://codeigniter.com
|
||||
* @since Version 1.0
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* ODBC Result Class
|
||||
*
|
||||
* This class extends the parent result class: CI_DB_result
|
||||
*
|
||||
* @category Database
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @link http://codeigniter.com/user_guide/database/
|
||||
*/
|
||||
class CI_DB_odbc_result extends CI_DB_result {
|
||||
|
||||
/**
|
||||
* Number of rows in the result set
|
||||
*
|
||||
* @access public
|
||||
* @return integer
|
||||
*/
|
||||
function num_rows()
|
||||
{
|
||||
return @odbc_num_rows($this->result_id);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Number of fields in the result set
|
||||
*
|
||||
* @access public
|
||||
* @return integer
|
||||
*/
|
||||
function num_fields()
|
||||
{
|
||||
return @odbc_num_fields($this->result_id);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Fetch Field Names
|
||||
*
|
||||
* Generates an array of column names
|
||||
*
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
function list_fields()
|
||||
{
|
||||
$field_names = array();
|
||||
for ($i = 0; $i < $this->num_fields(); $i++)
|
||||
{
|
||||
$field_names[] = odbc_field_name($this->result_id, $i);
|
||||
}
|
||||
|
||||
return $field_names;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Field data
|
||||
*
|
||||
* Generates an array of objects containing field meta-data
|
||||
*
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
function field_data()
|
||||
{
|
||||
$retval = array();
|
||||
for ($i = 0; $i < $this->num_fields(); $i++)
|
||||
{
|
||||
$F = new stdClass();
|
||||
$F->name = odbc_field_name($this->result_id, $i);
|
||||
$F->type = odbc_field_type($this->result_id, $i);
|
||||
$F->max_length = odbc_field_len($this->result_id, $i);
|
||||
$F->primary_key = 0;
|
||||
$F->default = '';
|
||||
|
||||
$retval[] = $F;
|
||||
}
|
||||
|
||||
return $retval;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Free the result
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
function free_result()
|
||||
{
|
||||
if (is_resource($this->result_id))
|
||||
{
|
||||
odbc_free_result($this->result_id);
|
||||
$this->result_id = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Data Seek
|
||||
*
|
||||
* Moves the internal pointer to the desired offset. We call
|
||||
* this internally before fetching results to make sure the
|
||||
* result set starts at zero
|
||||
*
|
||||
* @access private
|
||||
* @return array
|
||||
*/
|
||||
function _data_seek($n = 0)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Result - associative array
|
||||
*
|
||||
* Returns the result set as an array
|
||||
*
|
||||
* @access private
|
||||
* @return array
|
||||
*/
|
||||
function _fetch_assoc()
|
||||
{
|
||||
if (function_exists('odbc_fetch_object'))
|
||||
{
|
||||
return odbc_fetch_array($this->result_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->_odbc_fetch_array($this->result_id);
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Result - object
|
||||
*
|
||||
* Returns the result set as an object
|
||||
*
|
||||
* @access private
|
||||
* @return object
|
||||
*/
|
||||
function _fetch_object()
|
||||
{
|
||||
if (function_exists('odbc_fetch_object'))
|
||||
{
|
||||
return odbc_fetch_object($this->result_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->_odbc_fetch_object($this->result_id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Result - object
|
||||
*
|
||||
* subsititutes the odbc_fetch_object function when
|
||||
* not available (odbc_fetch_object requires unixODBC)
|
||||
*
|
||||
* @access private
|
||||
* @return object
|
||||
*/
|
||||
function _odbc_fetch_object(& $odbc_result) {
|
||||
$rs = array();
|
||||
$rs_obj = false;
|
||||
if (odbc_fetch_into($odbc_result, $rs)) {
|
||||
foreach ($rs as $k=>$v) {
|
||||
$field_name= odbc_field_name($odbc_result, $k+1);
|
||||
$rs_obj->$field_name = $v;
|
||||
}
|
||||
}
|
||||
return $rs_obj;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Result - array
|
||||
*
|
||||
* subsititutes the odbc_fetch_array function when
|
||||
* not available (odbc_fetch_array requires unixODBC)
|
||||
*
|
||||
* @access private
|
||||
* @return array
|
||||
*/
|
||||
function _odbc_fetch_array(& $odbc_result) {
|
||||
$rs = array();
|
||||
$rs_assoc = false;
|
||||
if (odbc_fetch_into($odbc_result, $rs)) {
|
||||
$rs_assoc=array();
|
||||
foreach ($rs as $k=>$v) {
|
||||
$field_name= odbc_field_name($odbc_result, $k+1);
|
||||
$rs_assoc[$field_name] = $v;
|
||||
}
|
||||
}
|
||||
return $rs_assoc;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* End of file odbc_result.php */
|
||||
/* Location: ./system/database/drivers/odbc/odbc_result.php */
|
||||
148
system/database/drivers/odbc/odbc_utility.php
Normal file
148
system/database/drivers/odbc/odbc_utility.php
Normal file
@@ -0,0 +1,148 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP 4.3.2 or newer
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2010, EllisLab, Inc.
|
||||
* @license http://codeigniter.com/user_guide/license.html
|
||||
* @link http://codeigniter.com
|
||||
* @since Version 1.0
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* ODBC Utility Class
|
||||
*
|
||||
* @category Database
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @link http://codeigniter.com/database/
|
||||
*/
|
||||
class CI_DB_odbc_utility extends CI_DB_utility {
|
||||
|
||||
/**
|
||||
* List databases
|
||||
*
|
||||
* @access private
|
||||
* @return bool
|
||||
*/
|
||||
function _list_databases()
|
||||
{
|
||||
// Not sure if ODBC lets you list all databases...
|
||||
if ($this->db->db_debug)
|
||||
{
|
||||
return $this->db->display_error('db_unsuported_feature');
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Optimize table query
|
||||
*
|
||||
* Generates a platform-specific query so that a table can be optimized
|
||||
*
|
||||
* @access private
|
||||
* @param string the table name
|
||||
* @return object
|
||||
*/
|
||||
function _optimize_table($table)
|
||||
{
|
||||
// Not a supported ODBC feature
|
||||
if ($this->db->db_debug)
|
||||
{
|
||||
return $this->db->display_error('db_unsuported_feature');
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Repair table query
|
||||
*
|
||||
* Generates a platform-specific query so that a table can be repaired
|
||||
*
|
||||
* @access private
|
||||
* @param string the table name
|
||||
* @return object
|
||||
*/
|
||||
function _repair_table($table)
|
||||
{
|
||||
// Not a supported ODBC feature
|
||||
if ($this->db->db_debug)
|
||||
{
|
||||
return $this->db->display_error('db_unsuported_feature');
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* ODBC Export
|
||||
*
|
||||
* @access private
|
||||
* @param array Preferences
|
||||
* @return mixed
|
||||
*/
|
||||
function _backup($params = array())
|
||||
{
|
||||
// Currently unsupported
|
||||
return $this->db->display_error('db_unsuported_feature');
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* The functions below have been deprecated as of 1.6, and are only here for backwards
|
||||
* compatibility. They now reside in dbforge(). The use of dbutils for database manipulation
|
||||
* is STRONGLY discouraged in favour if using dbforge.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Create database
|
||||
*
|
||||
* @access private
|
||||
* @param string the database name
|
||||
* @return bool
|
||||
*/
|
||||
function _create_database()
|
||||
{
|
||||
// ODBC has no "create database" command since it's
|
||||
// designed to connect to an existing database
|
||||
if ($this->db->db_debug)
|
||||
{
|
||||
return $this->db->display_error('db_unsuported_feature');
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Drop database
|
||||
*
|
||||
* @access private
|
||||
* @param string the database name
|
||||
* @return bool
|
||||
*/
|
||||
function _drop_database($name)
|
||||
{
|
||||
// ODBC has no "drop database" command since it's
|
||||
// designed to connect to an existing database
|
||||
if ($this->db->db_debug)
|
||||
{
|
||||
return $this->db->display_error('db_unsuported_feature');
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/* End of file odbc_utility.php */
|
||||
/* Location: ./system/database/drivers/odbc/odbc_utility.php */
|
||||
10
system/database/drivers/postgre/index.html
Normal file
10
system/database/drivers/postgre/index.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
684
system/database/drivers/postgre/postgre_driver.php
Normal file
684
system/database/drivers/postgre/postgre_driver.php
Normal file
@@ -0,0 +1,684 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP 4.3.2 or newer
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2010, EllisLab, Inc.
|
||||
* @license http://codeigniter.com/user_guide/license.html
|
||||
* @link http://codeigniter.com
|
||||
* @since Version 1.0
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Postgre Database Adapter Class
|
||||
*
|
||||
* Note: _DB is an extender class that the app controller
|
||||
* creates dynamically based on whether the active record
|
||||
* class is being used or not.
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @subpackage Drivers
|
||||
* @category Database
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @link http://codeigniter.com/user_guide/database/
|
||||
*/
|
||||
class CI_DB_postgre_driver extends CI_DB {
|
||||
|
||||
var $dbdriver = 'postgre';
|
||||
|
||||
var $_escape_char = '"';
|
||||
|
||||
// clause and character used for LIKE escape sequences
|
||||
var $_like_escape_str = " ESCAPE '%s' ";
|
||||
var $_like_escape_chr = '!';
|
||||
|
||||
/**
|
||||
* The syntax to count rows is slightly different across different
|
||||
* database engines, so this string appears in each driver and is
|
||||
* used for the count_all() and count_all_results() functions.
|
||||
*/
|
||||
var $_count_string = "SELECT COUNT(*) AS ";
|
||||
var $_random_keyword = ' RANDOM()'; // database specific random keyword
|
||||
|
||||
/**
|
||||
* Connection String
|
||||
*
|
||||
* @access private
|
||||
* @return string
|
||||
*/
|
||||
function _connect_string()
|
||||
{
|
||||
$components = array(
|
||||
'hostname' => 'host',
|
||||
'port' => 'port',
|
||||
'database' => 'dbname',
|
||||
'username' => 'user',
|
||||
'password' => 'password'
|
||||
);
|
||||
|
||||
$connect_string = "";
|
||||
foreach ($components as $key => $val)
|
||||
{
|
||||
if (isset($this->$key) && $this->$key != '')
|
||||
{
|
||||
$connect_string .= " $val=".$this->$key;
|
||||
}
|
||||
}
|
||||
return trim($connect_string);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Non-persistent database connection
|
||||
*
|
||||
* @access private called by the base class
|
||||
* @return resource
|
||||
*/
|
||||
function db_connect()
|
||||
{
|
||||
return @pg_connect($this->_connect_string());
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Persistent database connection
|
||||
*
|
||||
* @access private called by the base class
|
||||
* @return resource
|
||||
*/
|
||||
function db_pconnect()
|
||||
{
|
||||
return @pg_pconnect($this->_connect_string());
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Reconnect
|
||||
*
|
||||
* Keep / reestablish the db connection if no queries have been
|
||||
* sent for a length of time exceeding the server's idle timeout
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function reconnect()
|
||||
{
|
||||
if (pg_ping($this->conn_id) === FALSE)
|
||||
{
|
||||
$this->conn_id = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Select the database
|
||||
*
|
||||
* @access private called by the base class
|
||||
* @return resource
|
||||
*/
|
||||
function db_select()
|
||||
{
|
||||
// Not needed for Postgre so we'll return TRUE
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Set client character set
|
||||
*
|
||||
* @access public
|
||||
* @param string
|
||||
* @param string
|
||||
* @return resource
|
||||
*/
|
||||
function db_set_charset($charset, $collation)
|
||||
{
|
||||
// @todo - add support if needed
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Version number query string
|
||||
*
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
function _version()
|
||||
{
|
||||
return "SELECT version() AS ver";
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Execute the query
|
||||
*
|
||||
* @access private called by the base class
|
||||
* @param string an SQL query
|
||||
* @return resource
|
||||
*/
|
||||
function _execute($sql)
|
||||
{
|
||||
$sql = $this->_prep_query($sql);
|
||||
return @pg_query($this->conn_id, $sql);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Prep the query
|
||||
*
|
||||
* If needed, each database adapter can prep the query string
|
||||
*
|
||||
* @access private called by execute()
|
||||
* @param string an SQL query
|
||||
* @return string
|
||||
*/
|
||||
function _prep_query($sql)
|
||||
{
|
||||
return $sql;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Begin Transaction
|
||||
*
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
function trans_begin($test_mode = FALSE)
|
||||
{
|
||||
if ( ! $this->trans_enabled)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// When transactions are nested we only begin/commit/rollback the outermost ones
|
||||
if ($this->_trans_depth > 0)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// Reset the transaction failure flag.
|
||||
// If the $test_mode flag is set to TRUE transactions will be rolled back
|
||||
// even if the queries produce a successful result.
|
||||
$this->_trans_failure = ($test_mode === TRUE) ? TRUE : FALSE;
|
||||
|
||||
return @pg_exec($this->conn_id, "begin");
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Commit Transaction
|
||||
*
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
function trans_commit()
|
||||
{
|
||||
if ( ! $this->trans_enabled)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// When transactions are nested we only begin/commit/rollback the outermost ones
|
||||
if ($this->_trans_depth > 0)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return @pg_exec($this->conn_id, "commit");
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Rollback Transaction
|
||||
*
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
function trans_rollback()
|
||||
{
|
||||
if ( ! $this->trans_enabled)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// When transactions are nested we only begin/commit/rollback the outermost ones
|
||||
if ($this->_trans_depth > 0)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return @pg_exec($this->conn_id, "rollback");
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Escape String
|
||||
*
|
||||
* @access public
|
||||
* @param string
|
||||
* @param bool whether or not the string will be used in a LIKE condition
|
||||
* @return string
|
||||
*/
|
||||
function escape_str($str, $like = FALSE)
|
||||
{
|
||||
if (is_array($str))
|
||||
{
|
||||
foreach($str as $key => $val)
|
||||
{
|
||||
$str[$key] = $this->escape_str($val, $like);
|
||||
}
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
$str = pg_escape_string($str);
|
||||
|
||||
// escape LIKE condition wildcards
|
||||
if ($like === TRUE)
|
||||
{
|
||||
$str = str_replace( array('%', '_', $this->_like_escape_chr),
|
||||
array($this->_like_escape_chr.'%', $this->_like_escape_chr.'_', $this->_like_escape_chr.$this->_like_escape_chr),
|
||||
$str);
|
||||
}
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Affected Rows
|
||||
*
|
||||
* @access public
|
||||
* @return integer
|
||||
*/
|
||||
function affected_rows()
|
||||
{
|
||||
return @pg_affected_rows($this->result_id);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Insert ID
|
||||
*
|
||||
* @access public
|
||||
* @return integer
|
||||
*/
|
||||
function insert_id()
|
||||
{
|
||||
$v = $this->_version();
|
||||
$v = $v['server'];
|
||||
|
||||
$table = func_num_args() > 0 ? func_get_arg(0) : null;
|
||||
$column = func_num_args() > 1 ? func_get_arg(1) : null;
|
||||
|
||||
if ($table == null && $v >= '8.1')
|
||||
{
|
||||
$sql='SELECT LASTVAL() as ins_id';
|
||||
}
|
||||
elseif ($table != null && $column != null && $v >= '8.0')
|
||||
{
|
||||
$sql = sprintf("SELECT pg_get_serial_sequence('%s','%s') as seq", $table, $column);
|
||||
$query = $this->query($sql);
|
||||
$row = $query->row();
|
||||
$sql = sprintf("SELECT CURRVAL('%s') as ins_id", $row->seq);
|
||||
}
|
||||
elseif ($table != null)
|
||||
{
|
||||
// seq_name passed in table parameter
|
||||
$sql = sprintf("SELECT CURRVAL('%s') as ins_id", $table);
|
||||
}
|
||||
else
|
||||
{
|
||||
return pg_last_oid($this->result_id);
|
||||
}
|
||||
$query = $this->query($sql);
|
||||
$row = $query->row();
|
||||
return $row->ins_id;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* "Count All" query
|
||||
*
|
||||
* Generates a platform-specific query string that counts all records in
|
||||
* the specified database
|
||||
*
|
||||
* @access public
|
||||
* @param string
|
||||
* @return string
|
||||
*/
|
||||
function count_all($table = '')
|
||||
{
|
||||
if ($table == '')
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
$query = $this->query($this->_count_string . $this->_protect_identifiers('numrows') . " FROM " . $this->_protect_identifiers($table, TRUE, NULL, FALSE));
|
||||
|
||||
if ($query->num_rows() == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
$row = $query->row();
|
||||
return (int) $row->numrows;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Show table query
|
||||
*
|
||||
* Generates a platform-specific query string so that the table names can be fetched
|
||||
*
|
||||
* @access private
|
||||
* @param boolean
|
||||
* @return string
|
||||
*/
|
||||
function _list_tables($prefix_limit = FALSE)
|
||||
{
|
||||
$sql = "SELECT table_name FROM information_schema.tables WHERE table_schema = 'public'";
|
||||
|
||||
if ($prefix_limit !== FALSE AND $this->dbprefix != '')
|
||||
{
|
||||
$sql .= " AND table_name LIKE '".$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_char);
|
||||
}
|
||||
|
||||
return $sql;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Show column query
|
||||
*
|
||||
* Generates a platform-specific query string so that the column names can be fetched
|
||||
*
|
||||
* @access public
|
||||
* @param string the table name
|
||||
* @return string
|
||||
*/
|
||||
function _list_columns($table = '')
|
||||
{
|
||||
return "SELECT column_name FROM information_schema.columns WHERE table_name ='".$table."'";
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Field data query
|
||||
*
|
||||
* Generates a platform-specific query so that the column data can be retrieved
|
||||
*
|
||||
* @access public
|
||||
* @param string the table name
|
||||
* @return object
|
||||
*/
|
||||
function _field_data($table)
|
||||
{
|
||||
return "SELECT * FROM ".$table." LIMIT 1";
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* The error message string
|
||||
*
|
||||
* @access private
|
||||
* @return string
|
||||
*/
|
||||
function _error_message()
|
||||
{
|
||||
return pg_last_error($this->conn_id);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* The error message number
|
||||
*
|
||||
* @access private
|
||||
* @return integer
|
||||
*/
|
||||
function _error_number()
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Escape the SQL Identifiers
|
||||
*
|
||||
* This function escapes column and table names
|
||||
*
|
||||
* @access private
|
||||
* @param string
|
||||
* @return string
|
||||
*/
|
||||
function _escape_identifiers($item)
|
||||
{
|
||||
if ($this->_escape_char == '')
|
||||
{
|
||||
return $item;
|
||||
}
|
||||
|
||||
foreach ($this->_reserved_identifiers as $id)
|
||||
{
|
||||
if (strpos($item, '.'.$id) !== FALSE)
|
||||
{
|
||||
$str = $this->_escape_char. str_replace('.', $this->_escape_char.'.', $item);
|
||||
|
||||
// remove duplicates if the user already included the escape
|
||||
return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str);
|
||||
}
|
||||
}
|
||||
|
||||
if (strpos($item, '.') !== FALSE)
|
||||
{
|
||||
$str = $this->_escape_char.str_replace('.', $this->_escape_char.'.'.$this->_escape_char, $item).$this->_escape_char;
|
||||
}
|
||||
else
|
||||
{
|
||||
$str = $this->_escape_char.$item.$this->_escape_char;
|
||||
}
|
||||
|
||||
// remove duplicates if the user already included the escape
|
||||
return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* From Tables
|
||||
*
|
||||
* This function implicitly groups FROM tables so there is no confusion
|
||||
* about operator precedence in harmony with SQL standards
|
||||
*
|
||||
* @access public
|
||||
* @param type
|
||||
* @return type
|
||||
*/
|
||||
function _from_tables($tables)
|
||||
{
|
||||
if ( ! is_array($tables))
|
||||
{
|
||||
$tables = array($tables);
|
||||
}
|
||||
|
||||
return implode(', ', $tables);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Insert statement
|
||||
*
|
||||
* Generates a platform-specific insert string from the supplied data
|
||||
*
|
||||
* @access public
|
||||
* @param string the table name
|
||||
* @param array the insert keys
|
||||
* @param array the insert values
|
||||
* @return string
|
||||
*/
|
||||
function _insert($table, $keys, $values)
|
||||
{
|
||||
return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")";
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Update statement
|
||||
*
|
||||
* Generates a platform-specific update string from the supplied data
|
||||
*
|
||||
* @access public
|
||||
* @param string the table name
|
||||
* @param array the update data
|
||||
* @param array the where clause
|
||||
* @param array the orderby clause
|
||||
* @param array the limit clause
|
||||
* @return string
|
||||
*/
|
||||
function _update($table, $values, $where, $orderby = array(), $limit = FALSE)
|
||||
{
|
||||
foreach($values as $key => $val)
|
||||
{
|
||||
$valstr[] = $key." = ".$val;
|
||||
}
|
||||
|
||||
$limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
|
||||
|
||||
$orderby = (count($orderby) >= 1)?' ORDER BY '.implode(", ", $orderby):'';
|
||||
|
||||
$sql = "UPDATE ".$table." SET ".implode(', ', $valstr);
|
||||
|
||||
$sql .= ($where != '' AND count($where) >=1) ? " WHERE ".implode(" ", $where) : '';
|
||||
|
||||
$sql .= $orderby.$limit;
|
||||
|
||||
return $sql;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Truncate statement
|
||||
*
|
||||
* Generates a platform-specific truncate string from the supplied data
|
||||
* If the database does not support the truncate() command
|
||||
* This function maps to "DELETE FROM table"
|
||||
*
|
||||
* @access public
|
||||
* @param string the table name
|
||||
* @return string
|
||||
*/
|
||||
function _truncate($table)
|
||||
{
|
||||
return "TRUNCATE ".$table;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Delete statement
|
||||
*
|
||||
* Generates a platform-specific delete string from the supplied data
|
||||
*
|
||||
* @access public
|
||||
* @param string the table name
|
||||
* @param array the where clause
|
||||
* @param string the limit clause
|
||||
* @return string
|
||||
*/
|
||||
function _delete($table, $where = array(), $like = array(), $limit = FALSE)
|
||||
{
|
||||
$conditions = '';
|
||||
|
||||
if (count($where) > 0 OR count($like) > 0)
|
||||
{
|
||||
$conditions = "\nWHERE ";
|
||||
$conditions .= implode("\n", $this->ar_where);
|
||||
|
||||
if (count($where) > 0 && count($like) > 0)
|
||||
{
|
||||
$conditions .= " AND ";
|
||||
}
|
||||
$conditions .= implode("\n", $like);
|
||||
}
|
||||
|
||||
$limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
|
||||
|
||||
return "DELETE FROM ".$table.$conditions.$limit;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
/**
|
||||
* Limit string
|
||||
*
|
||||
* Generates a platform-specific LIMIT clause
|
||||
*
|
||||
* @access public
|
||||
* @param string the sql query string
|
||||
* @param integer the number of rows to limit the query to
|
||||
* @param integer the offset value
|
||||
* @return string
|
||||
*/
|
||||
function _limit($sql, $limit, $offset)
|
||||
{
|
||||
$sql .= "LIMIT ".$limit;
|
||||
|
||||
if ($offset > 0)
|
||||
{
|
||||
$sql .= " OFFSET ".$offset;
|
||||
}
|
||||
|
||||
return $sql;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Close DB Connection
|
||||
*
|
||||
* @access public
|
||||
* @param resource
|
||||
* @return void
|
||||
*/
|
||||
function _close($conn_id)
|
||||
{
|
||||
@pg_close($conn_id);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* End of file postgre_driver.php */
|
||||
/* Location: ./system/database/drivers/postgre/postgre_driver.php */
|
||||
248
system/database/drivers/postgre/postgre_forge.php
Normal file
248
system/database/drivers/postgre/postgre_forge.php
Normal file
@@ -0,0 +1,248 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP 4.3.2 or newer
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2010, EllisLab, Inc.
|
||||
* @license http://codeigniter.com/user_guide/license.html
|
||||
* @link http://codeigniter.com
|
||||
* @since Version 1.0
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Postgre Forge Class
|
||||
*
|
||||
* @category Database
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @link http://codeigniter.com/user_guide/database/
|
||||
*/
|
||||
class CI_DB_postgre_forge extends CI_DB_forge {
|
||||
|
||||
/**
|
||||
* Create database
|
||||
*
|
||||
* @access private
|
||||
* @param string the database name
|
||||
* @return bool
|
||||
*/
|
||||
function _create_database($name)
|
||||
{
|
||||
return "CREATE DATABASE ".$name;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Drop database
|
||||
*
|
||||
* @access private
|
||||
* @param string the database name
|
||||
* @return bool
|
||||
*/
|
||||
function _drop_database($name)
|
||||
{
|
||||
return "DROP DATABASE ".$name;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Create Table
|
||||
*
|
||||
* @access private
|
||||
* @param string the table name
|
||||
* @param array the fields
|
||||
* @param mixed primary key(s)
|
||||
* @param mixed key(s)
|
||||
* @param boolean should 'IF NOT EXISTS' be added to the SQL
|
||||
* @return bool
|
||||
*/
|
||||
function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists)
|
||||
{
|
||||
$sql = 'CREATE TABLE ';
|
||||
|
||||
if ($if_not_exists === TRUE)
|
||||
{
|
||||
$sql .= 'IF NOT EXISTS ';
|
||||
}
|
||||
|
||||
$sql .= $this->db->_escape_identifiers($table)." (";
|
||||
$current_field_count = 0;
|
||||
|
||||
foreach ($fields as $field=>$attributes)
|
||||
{
|
||||
// Numeric field names aren't allowed in databases, so if the key is
|
||||
// numeric, we know it was assigned by PHP and the developer manually
|
||||
// entered the field information, so we'll simply add it to the list
|
||||
if (is_numeric($field))
|
||||
{
|
||||
$sql .= "\n\t$attributes";
|
||||
}
|
||||
else
|
||||
{
|
||||
$attributes = array_change_key_case($attributes, CASE_UPPER);
|
||||
|
||||
$sql .= "\n\t".$this->db->_protect_identifiers($field);
|
||||
|
||||
$sql .= ' '.$attributes['TYPE'];
|
||||
|
||||
if (array_key_exists('CONSTRAINT', $attributes))
|
||||
{
|
||||
$sql .= '('.$attributes['CONSTRAINT'].')';
|
||||
}
|
||||
|
||||
if (array_key_exists('UNSIGNED', $attributes) && $attributes['UNSIGNED'] === TRUE)
|
||||
{
|
||||
$sql .= ' UNSIGNED';
|
||||
}
|
||||
|
||||
if (array_key_exists('DEFAULT', $attributes))
|
||||
{
|
||||
$sql .= ' DEFAULT \''.$attributes['DEFAULT'].'\'';
|
||||
}
|
||||
|
||||
if (array_key_exists('NULL', $attributes) && $attributes['NULL'] === TRUE)
|
||||
{
|
||||
$sql .= ' NULL';
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql .= ' NOT NULL';
|
||||
}
|
||||
|
||||
if (array_key_exists('AUTO_INCREMENT', $attributes) && $attributes['AUTO_INCREMENT'] === TRUE)
|
||||
{
|
||||
$sql .= ' AUTO_INCREMENT';
|
||||
}
|
||||
}
|
||||
|
||||
// don't add a comma on the end of the last field
|
||||
if (++$current_field_count < count($fields))
|
||||
{
|
||||
$sql .= ',';
|
||||
}
|
||||
}
|
||||
|
||||
if (count($primary_keys) > 0)
|
||||
{
|
||||
$primary_keys = $this->db->_protect_identifiers($primary_keys);
|
||||
$sql .= ",\n\tPRIMARY KEY (" . implode(', ', $primary_keys) . ")";
|
||||
}
|
||||
|
||||
if (is_array($keys) && count($keys) > 0)
|
||||
{
|
||||
foreach ($keys as $key)
|
||||
{
|
||||
if (is_array($key))
|
||||
{
|
||||
$key = $this->db->_protect_identifiers($key);
|
||||
}
|
||||
else
|
||||
{
|
||||
$key = array($this->db->_protect_identifiers($key));
|
||||
}
|
||||
|
||||
$sql .= ",\n\tFOREIGN KEY (" . implode(', ', $key) . ")";
|
||||
}
|
||||
}
|
||||
|
||||
$sql .= "\n);";
|
||||
|
||||
return $sql;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Drop Table
|
||||
*
|
||||
* @access private
|
||||
* @return bool
|
||||
*/
|
||||
function _drop_table($table)
|
||||
{
|
||||
return "DROP TABLE ".$this->db->_escape_identifiers($table)." CASCADE";
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Alter table query
|
||||
*
|
||||
* Generates a platform-specific query so that a table can be altered
|
||||
* Called by add_column(), drop_column(), and column_alter(),
|
||||
*
|
||||
* @access private
|
||||
* @param string the ALTER type (ADD, DROP, CHANGE)
|
||||
* @param string the column name
|
||||
* @param string the table name
|
||||
* @param string the column definition
|
||||
* @param string the default value
|
||||
* @param boolean should 'NOT NULL' be added
|
||||
* @param string the field after which we should add the new field
|
||||
* @return object
|
||||
*/
|
||||
function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '')
|
||||
{
|
||||
$sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table)." $alter_type ".$this->db->_protect_identifiers($column_name);
|
||||
|
||||
// DROP has everything it needs now.
|
||||
if ($alter_type == 'DROP')
|
||||
{
|
||||
return $sql;
|
||||
}
|
||||
|
||||
$sql .= " $column_definition";
|
||||
|
||||
if ($default_value != '')
|
||||
{
|
||||
$sql .= " DEFAULT \"$default_value\"";
|
||||
}
|
||||
|
||||
if ($null === NULL)
|
||||
{
|
||||
$sql .= ' NULL';
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql .= ' NOT NULL';
|
||||
}
|
||||
|
||||
if ($after_field != '')
|
||||
{
|
||||
$sql .= ' AFTER ' . $this->db->_protect_identifiers($after_field);
|
||||
}
|
||||
|
||||
return $sql;
|
||||
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Rename a table
|
||||
*
|
||||
* Generates a platform-specific query so that a table can be renamed
|
||||
*
|
||||
* @access private
|
||||
* @param string the old table name
|
||||
* @param string the new table name
|
||||
* @return string
|
||||
*/
|
||||
function _rename_table($table_name, $new_table_name)
|
||||
{
|
||||
$sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table_name)." RENAME TO ".$this->db->_protect_identifiers($new_table_name);
|
||||
return $sql;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/* End of file postgre_forge.php */
|
||||
/* Location: ./system/database/drivers/postgre/postgre_forge.php */
|
||||
169
system/database/drivers/postgre/postgre_result.php
Normal file
169
system/database/drivers/postgre/postgre_result.php
Normal file
@@ -0,0 +1,169 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP 4.3.2 or newer
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2010, EllisLab, Inc.
|
||||
* @license http://codeigniter.com/user_guide/license.html
|
||||
* @link http://codeigniter.com
|
||||
* @since Version 1.0
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Postgres Result Class
|
||||
*
|
||||
* This class extends the parent result class: CI_DB_result
|
||||
*
|
||||
* @category Database
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @link http://codeigniter.com/user_guide/database/
|
||||
*/
|
||||
class CI_DB_postgre_result extends CI_DB_result {
|
||||
|
||||
/**
|
||||
* Number of rows in the result set
|
||||
*
|
||||
* @access public
|
||||
* @return integer
|
||||
*/
|
||||
function num_rows()
|
||||
{
|
||||
return @pg_num_rows($this->result_id);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Number of fields in the result set
|
||||
*
|
||||
* @access public
|
||||
* @return integer
|
||||
*/
|
||||
function num_fields()
|
||||
{
|
||||
return @pg_num_fields($this->result_id);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Fetch Field Names
|
||||
*
|
||||
* Generates an array of column names
|
||||
*
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
function list_fields()
|
||||
{
|
||||
$field_names = array();
|
||||
for ($i = 0; $i < $this->num_fields(); $i++)
|
||||
{
|
||||
$field_names[] = pg_field_name($this->result_id, $i);
|
||||
}
|
||||
|
||||
return $field_names;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Field data
|
||||
*
|
||||
* Generates an array of objects containing field meta-data
|
||||
*
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
function field_data()
|
||||
{
|
||||
$retval = array();
|
||||
for ($i = 0; $i < $this->num_fields(); $i++)
|
||||
{
|
||||
$F = new stdClass();
|
||||
$F->name = pg_field_name($this->result_id, $i);
|
||||
$F->type = pg_field_type($this->result_id, $i);
|
||||
$F->max_length = pg_field_size($this->result_id, $i);
|
||||
$F->primary_key = 0;
|
||||
$F->default = '';
|
||||
|
||||
$retval[] = $F;
|
||||
}
|
||||
|
||||
return $retval;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Free the result
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
function free_result()
|
||||
{
|
||||
if (is_resource($this->result_id))
|
||||
{
|
||||
pg_free_result($this->result_id);
|
||||
$this->result_id = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Data Seek
|
||||
*
|
||||
* Moves the internal pointer to the desired offset. We call
|
||||
* this internally before fetching results to make sure the
|
||||
* result set starts at zero
|
||||
*
|
||||
* @access private
|
||||
* @return array
|
||||
*/
|
||||
function _data_seek($n = 0)
|
||||
{
|
||||
return pg_result_seek($this->result_id, $n);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Result - associative array
|
||||
*
|
||||
* Returns the result set as an array
|
||||
*
|
||||
* @access private
|
||||
* @return array
|
||||
*/
|
||||
function _fetch_assoc()
|
||||
{
|
||||
return pg_fetch_assoc($this->result_id);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Result - object
|
||||
*
|
||||
* Returns the result set as an object
|
||||
*
|
||||
* @access private
|
||||
* @return object
|
||||
*/
|
||||
function _fetch_object()
|
||||
{
|
||||
return pg_fetch_object($this->result_id);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* End of file postgre_result.php */
|
||||
/* Location: ./system/database/drivers/postgre/postgre_result.php */
|
||||
124
system/database/drivers/postgre/postgre_utility.php
Normal file
124
system/database/drivers/postgre/postgre_utility.php
Normal file
@@ -0,0 +1,124 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP 4.3.2 or newer
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2010, EllisLab, Inc.
|
||||
* @license http://codeigniter.com/user_guide/license.html
|
||||
* @link http://codeigniter.com
|
||||
* @since Version 1.0
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Postgre Utility Class
|
||||
*
|
||||
* @category Database
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @link http://codeigniter.com/user_guide/database/
|
||||
*/
|
||||
class CI_DB_postgre_utility extends CI_DB_utility {
|
||||
|
||||
/**
|
||||
* List databases
|
||||
*
|
||||
* @access private
|
||||
* @return bool
|
||||
*/
|
||||
function _list_databases()
|
||||
{
|
||||
return "SELECT datname FROM pg_database";
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Optimize table query
|
||||
*
|
||||
* Is table optimization supported in Postgre?
|
||||
*
|
||||
* @access private
|
||||
* @param string the table name
|
||||
* @return object
|
||||
*/
|
||||
function _optimize_table($table)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Repair table query
|
||||
*
|
||||
* Are table repairs supported in Postgre?
|
||||
*
|
||||
* @access private
|
||||
* @param string the table name
|
||||
* @return object
|
||||
*/
|
||||
function _repair_table($table)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Postgre Export
|
||||
*
|
||||
* @access private
|
||||
* @param array Preferences
|
||||
* @return mixed
|
||||
*/
|
||||
function _backup($params = array())
|
||||
{
|
||||
// Currently unsupported
|
||||
return $this->db->display_error('db_unsuported_feature');
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* The functions below have been deprecated as of 1.6, and are only here for backwards
|
||||
* compatibility. They now reside in dbforge(). The use of dbutils for database manipulation
|
||||
* is STRONGLY discouraged in favour if using dbforge.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Create database
|
||||
*
|
||||
* @access private
|
||||
* @param string the database name
|
||||
* @return bool
|
||||
*/
|
||||
function _create_database($name)
|
||||
{
|
||||
return "CREATE DATABASE ".$name;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Drop database
|
||||
*
|
||||
* @access private
|
||||
* @param string the database name
|
||||
* @return bool
|
||||
*/
|
||||
function _drop_database($name)
|
||||
{
|
||||
return "DROP DATABASE ".$name;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* End of file postgre_utility.php */
|
||||
/* Location: ./system/database/drivers/postgre/postgre_utility.php */
|
||||
10
system/database/drivers/sqlite/index.html
Normal file
10
system/database/drivers/sqlite/index.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
657
system/database/drivers/sqlite/sqlite_driver.php
Normal file
657
system/database/drivers/sqlite/sqlite_driver.php
Normal file
@@ -0,0 +1,657 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP 4.3.2 or newer
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2010, EllisLab, Inc.
|
||||
* @license http://codeigniter.com/user_guide/license.html
|
||||
* @link http://codeigniter.com
|
||||
* @since Version 1.0
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* SQLite Database Adapter Class
|
||||
*
|
||||
* Note: _DB is an extender class that the app controller
|
||||
* creates dynamically based on whether the active record
|
||||
* class is being used or not.
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @subpackage Drivers
|
||||
* @category Database
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @link http://codeigniter.com/user_guide/database/
|
||||
*/
|
||||
class CI_DB_sqlite_driver extends CI_DB {
|
||||
|
||||
var $dbdriver = 'sqlite';
|
||||
|
||||
// The character used to escape with - not needed for SQLite
|
||||
var $_escape_char = '';
|
||||
|
||||
// clause and character used for LIKE escape sequences
|
||||
var $_like_escape_str = " ESCAPE '%s' ";
|
||||
var $_like_escape_chr = '!';
|
||||
|
||||
/**
|
||||
* The syntax to count rows is slightly different across different
|
||||
* database engines, so this string appears in each driver and is
|
||||
* used for the count_all() and count_all_results() functions.
|
||||
*/
|
||||
var $_count_string = "SELECT COUNT(*) AS ";
|
||||
var $_random_keyword = ' Random()'; // database specific random keyword
|
||||
|
||||
/**
|
||||
* Non-persistent database connection
|
||||
*
|
||||
* @access private called by the base class
|
||||
* @return resource
|
||||
*/
|
||||
function db_connect()
|
||||
{
|
||||
if ( ! $conn_id = @sqlite_open($this->database, FILE_WRITE_MODE, $error))
|
||||
{
|
||||
log_message('error', $error);
|
||||
|
||||
if ($this->db_debug)
|
||||
{
|
||||
$this->display_error($error, '', TRUE);
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return $conn_id;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Persistent database connection
|
||||
*
|
||||
* @access private called by the base class
|
||||
* @return resource
|
||||
*/
|
||||
function db_pconnect()
|
||||
{
|
||||
if ( ! $conn_id = @sqlite_popen($this->database, FILE_WRITE_MODE, $error))
|
||||
{
|
||||
log_message('error', $error);
|
||||
|
||||
if ($this->db_debug)
|
||||
{
|
||||
$this->display_error($error, '', TRUE);
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return $conn_id;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Reconnect
|
||||
*
|
||||
* Keep / reestablish the db connection if no queries have been
|
||||
* sent for a length of time exceeding the server's idle timeout
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function reconnect()
|
||||
{
|
||||
// not implemented in SQLite
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Select the database
|
||||
*
|
||||
* @access private called by the base class
|
||||
* @return resource
|
||||
*/
|
||||
function db_select()
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Set client character set
|
||||
*
|
||||
* @access public
|
||||
* @param string
|
||||
* @param string
|
||||
* @return resource
|
||||
*/
|
||||
function db_set_charset($charset, $collation)
|
||||
{
|
||||
// @todo - add support if needed
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Version number query string
|
||||
*
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
function _version()
|
||||
{
|
||||
return sqlite_libversion();
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Execute the query
|
||||
*
|
||||
* @access private called by the base class
|
||||
* @param string an SQL query
|
||||
* @return resource
|
||||
*/
|
||||
function _execute($sql)
|
||||
{
|
||||
$sql = $this->_prep_query($sql);
|
||||
return @sqlite_query($this->conn_id, $sql);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Prep the query
|
||||
*
|
||||
* If needed, each database adapter can prep the query string
|
||||
*
|
||||
* @access private called by execute()
|
||||
* @param string an SQL query
|
||||
* @return string
|
||||
*/
|
||||
function _prep_query($sql)
|
||||
{
|
||||
return $sql;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Begin Transaction
|
||||
*
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
function trans_begin($test_mode = FALSE)
|
||||
{
|
||||
if ( ! $this->trans_enabled)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// When transactions are nested we only begin/commit/rollback the outermost ones
|
||||
if ($this->_trans_depth > 0)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// Reset the transaction failure flag.
|
||||
// If the $test_mode flag is set to TRUE transactions will be rolled back
|
||||
// even if the queries produce a successful result.
|
||||
$this->_trans_failure = ($test_mode === TRUE) ? TRUE : FALSE;
|
||||
|
||||
$this->simple_query('BEGIN TRANSACTION');
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Commit Transaction
|
||||
*
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
function trans_commit()
|
||||
{
|
||||
if ( ! $this->trans_enabled)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// When transactions are nested we only begin/commit/rollback the outermost ones
|
||||
if ($this->_trans_depth > 0)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
$this->simple_query('COMMIT');
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Rollback Transaction
|
||||
*
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
function trans_rollback()
|
||||
{
|
||||
if ( ! $this->trans_enabled)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// When transactions are nested we only begin/commit/rollback the outermost ones
|
||||
if ($this->_trans_depth > 0)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
$this->simple_query('ROLLBACK');
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Escape String
|
||||
*
|
||||
* @access public
|
||||
* @param string
|
||||
* @param bool whether or not the string will be used in a LIKE condition
|
||||
* @return string
|
||||
*/
|
||||
function escape_str($str, $like = FALSE)
|
||||
{
|
||||
if (is_array($str))
|
||||
{
|
||||
foreach($str as $key => $val)
|
||||
{
|
||||
$str[$key] = $this->escape_str($val, $like);
|
||||
}
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
$str = sqlite_escape_string($str);
|
||||
|
||||
// escape LIKE condition wildcards
|
||||
if ($like === TRUE)
|
||||
{
|
||||
$str = str_replace( array('%', '_', $this->_like_escape_chr),
|
||||
array($this->_like_escape_chr.'%', $this->_like_escape_chr.'_', $this->_like_escape_chr.$this->_like_escape_chr),
|
||||
$str);
|
||||
}
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Affected Rows
|
||||
*
|
||||
* @access public
|
||||
* @return integer
|
||||
*/
|
||||
function affected_rows()
|
||||
{
|
||||
return sqlite_changes($this->conn_id);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Insert ID
|
||||
*
|
||||
* @access public
|
||||
* @return integer
|
||||
*/
|
||||
function insert_id()
|
||||
{
|
||||
return @sqlite_last_insert_rowid($this->conn_id);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* "Count All" query
|
||||
*
|
||||
* Generates a platform-specific query string that counts all records in
|
||||
* the specified database
|
||||
*
|
||||
* @access public
|
||||
* @param string
|
||||
* @return string
|
||||
*/
|
||||
function count_all($table = '')
|
||||
{
|
||||
if ($table == '')
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
$query = $this->query($this->_count_string . $this->_protect_identifiers('numrows') . " FROM " . $this->_protect_identifiers($table, TRUE, NULL, FALSE));
|
||||
|
||||
if ($query->num_rows() == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
$row = $query->row();
|
||||
return (int) $row->numrows;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* List table query
|
||||
*
|
||||
* Generates a platform-specific query string so that the table names can be fetched
|
||||
*
|
||||
* @access private
|
||||
* @param boolean
|
||||
* @return string
|
||||
*/
|
||||
function _list_tables($prefix_limit = FALSE)
|
||||
{
|
||||
$sql = "SELECT name from sqlite_master WHERE type='table'";
|
||||
|
||||
if ($prefix_limit !== FALSE AND $this->dbprefix != '')
|
||||
{
|
||||
$sql .= " AND 'name' LIKE '".$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_char);
|
||||
}
|
||||
return $sql;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Show column query
|
||||
*
|
||||
* Generates a platform-specific query string so that the column names can be fetched
|
||||
*
|
||||
* @access public
|
||||
* @param string the table name
|
||||
* @return string
|
||||
*/
|
||||
function _list_columns($table = '')
|
||||
{
|
||||
// Not supported
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Field data query
|
||||
*
|
||||
* Generates a platform-specific query so that the column data can be retrieved
|
||||
*
|
||||
* @access public
|
||||
* @param string the table name
|
||||
* @return object
|
||||
*/
|
||||
function _field_data($table)
|
||||
{
|
||||
return "SELECT * FROM ".$table." LIMIT 1";
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* The error message string
|
||||
*
|
||||
* @access private
|
||||
* @return string
|
||||
*/
|
||||
function _error_message()
|
||||
{
|
||||
return sqlite_error_string(sqlite_last_error($this->conn_id));
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* The error message number
|
||||
*
|
||||
* @access private
|
||||
* @return integer
|
||||
*/
|
||||
function _error_number()
|
||||
{
|
||||
return sqlite_last_error($this->conn_id);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Escape the SQL Identifiers
|
||||
*
|
||||
* This function escapes column and table names
|
||||
*
|
||||
* @access private
|
||||
* @param string
|
||||
* @return string
|
||||
*/
|
||||
function _escape_identifiers($item)
|
||||
{
|
||||
if ($this->_escape_char == '')
|
||||
{
|
||||
return $item;
|
||||
}
|
||||
|
||||
foreach ($this->_reserved_identifiers as $id)
|
||||
{
|
||||
if (strpos($item, '.'.$id) !== FALSE)
|
||||
{
|
||||
$str = $this->_escape_char. str_replace('.', $this->_escape_char.'.', $item);
|
||||
|
||||
// remove duplicates if the user already included the escape
|
||||
return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str);
|
||||
}
|
||||
}
|
||||
|
||||
if (strpos($item, '.') !== FALSE)
|
||||
{
|
||||
$str = $this->_escape_char.str_replace('.', $this->_escape_char.'.'.$this->_escape_char, $item).$this->_escape_char;
|
||||
}
|
||||
else
|
||||
{
|
||||
$str = $this->_escape_char.$item.$this->_escape_char;
|
||||
}
|
||||
|
||||
// remove duplicates if the user already included the escape
|
||||
return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* From Tables
|
||||
*
|
||||
* This function implicitly groups FROM tables so there is no confusion
|
||||
* about operator precedence in harmony with SQL standards
|
||||
*
|
||||
* @access public
|
||||
* @param type
|
||||
* @return type
|
||||
*/
|
||||
function _from_tables($tables)
|
||||
{
|
||||
if ( ! is_array($tables))
|
||||
{
|
||||
$tables = array($tables);
|
||||
}
|
||||
|
||||
return '('.implode(', ', $tables).')';
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Insert statement
|
||||
*
|
||||
* Generates a platform-specific insert string from the supplied data
|
||||
*
|
||||
* @access public
|
||||
* @param string the table name
|
||||
* @param array the insert keys
|
||||
* @param array the insert values
|
||||
* @return string
|
||||
*/
|
||||
function _insert($table, $keys, $values)
|
||||
{
|
||||
return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")";
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Update statement
|
||||
*
|
||||
* Generates a platform-specific update string from the supplied data
|
||||
*
|
||||
* @access public
|
||||
* @param string the table name
|
||||
* @param array the update data
|
||||
* @param array the where clause
|
||||
* @param array the orderby clause
|
||||
* @param array the limit clause
|
||||
* @return string
|
||||
*/
|
||||
function _update($table, $values, $where, $orderby = array(), $limit = FALSE)
|
||||
{
|
||||
foreach($values as $key => $val)
|
||||
{
|
||||
$valstr[] = $key." = ".$val;
|
||||
}
|
||||
|
||||
$limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
|
||||
|
||||
$orderby = (count($orderby) >= 1)?' ORDER BY '.implode(", ", $orderby):'';
|
||||
|
||||
$sql = "UPDATE ".$table." SET ".implode(', ', $valstr);
|
||||
|
||||
$sql .= ($where != '' AND count($where) >=1) ? " WHERE ".implode(" ", $where) : '';
|
||||
|
||||
$sql .= $orderby.$limit;
|
||||
|
||||
return $sql;
|
||||
}
|
||||
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Truncate statement
|
||||
*
|
||||
* Generates a platform-specific truncate string from the supplied data
|
||||
* If the database does not support the truncate() command
|
||||
* This function maps to "DELETE FROM table"
|
||||
*
|
||||
* @access public
|
||||
* @param string the table name
|
||||
* @return string
|
||||
*/
|
||||
function _truncate($table)
|
||||
{
|
||||
return $this->_delete($table);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Delete statement
|
||||
*
|
||||
* Generates a platform-specific delete string from the supplied data
|
||||
*
|
||||
* @access public
|
||||
* @param string the table name
|
||||
* @param array the where clause
|
||||
* @param string the limit clause
|
||||
* @return string
|
||||
*/
|
||||
function _delete($table, $where = array(), $like = array(), $limit = FALSE)
|
||||
{
|
||||
$conditions = '';
|
||||
|
||||
if (count($where) > 0 OR count($like) > 0)
|
||||
{
|
||||
$conditions = "\nWHERE ";
|
||||
$conditions .= implode("\n", $this->ar_where);
|
||||
|
||||
if (count($where) > 0 && count($like) > 0)
|
||||
{
|
||||
$conditions .= " AND ";
|
||||
}
|
||||
$conditions .= implode("\n", $like);
|
||||
}
|
||||
|
||||
$limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
|
||||
|
||||
return "DELETE FROM ".$table.$conditions.$limit;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Limit string
|
||||
*
|
||||
* Generates a platform-specific LIMIT clause
|
||||
*
|
||||
* @access public
|
||||
* @param string the sql query string
|
||||
* @param integer the number of rows to limit the query to
|
||||
* @param integer the offset value
|
||||
* @return string
|
||||
*/
|
||||
function _limit($sql, $limit, $offset)
|
||||
{
|
||||
if ($offset == 0)
|
||||
{
|
||||
$offset = '';
|
||||
}
|
||||
else
|
||||
{
|
||||
$offset .= ", ";
|
||||
}
|
||||
|
||||
return $sql."LIMIT ".$offset.$limit;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Close DB Connection
|
||||
*
|
||||
* @access public
|
||||
* @param resource
|
||||
* @return void
|
||||
*/
|
||||
function _close($conn_id)
|
||||
{
|
||||
@sqlite_close($conn_id);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* End of file sqlite_driver.php */
|
||||
/* Location: ./system/database/drivers/sqlite/sqlite_driver.php */
|
||||
265
system/database/drivers/sqlite/sqlite_forge.php
Normal file
265
system/database/drivers/sqlite/sqlite_forge.php
Normal file
@@ -0,0 +1,265 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP 4.3.2 or newer
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2010, EllisLab, Inc.
|
||||
* @license http://codeigniter.com/user_guide/license.html
|
||||
* @link http://codeigniter.com
|
||||
* @since Version 1.0
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* SQLite Forge Class
|
||||
*
|
||||
* @category Database
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @link http://codeigniter.com/user_guide/database/
|
||||
*/
|
||||
class CI_DB_sqlite_forge extends CI_DB_forge {
|
||||
|
||||
/**
|
||||
* Create database
|
||||
*
|
||||
* @access public
|
||||
* @param string the database name
|
||||
* @return bool
|
||||
*/
|
||||
function _create_database()
|
||||
{
|
||||
// In SQLite, a database is created when you connect to the database.
|
||||
// We'll return TRUE so that an error isn't generated
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Drop database
|
||||
*
|
||||
* @access private
|
||||
* @param string the database name
|
||||
* @return bool
|
||||
*/
|
||||
function _drop_database($name)
|
||||
{
|
||||
if ( ! @file_exists($this->db->database) OR ! @unlink($this->db->database))
|
||||
{
|
||||
if ($this->db->db_debug)
|
||||
{
|
||||
return $this->db->display_error('db_unable_to_drop');
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Create Table
|
||||
*
|
||||
* @access private
|
||||
* @param string the table name
|
||||
* @param array the fields
|
||||
* @param mixed primary key(s)
|
||||
* @param mixed key(s)
|
||||
* @param boolean should 'IF NOT EXISTS' be added to the SQL
|
||||
* @return bool
|
||||
*/
|
||||
function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists)
|
||||
{
|
||||
$sql = 'CREATE TABLE ';
|
||||
|
||||
// IF NOT EXISTS added to SQLite in 3.3.0
|
||||
if ($if_not_exists === TRUE && version_compare($this->_version(), '3.3.0', '>=') === TRUE)
|
||||
{
|
||||
$sql .= 'IF NOT EXISTS ';
|
||||
}
|
||||
|
||||
$sql .= $this->db->_escape_identifiers($table)."(";
|
||||
$current_field_count = 0;
|
||||
|
||||
foreach ($fields as $field=>$attributes)
|
||||
{
|
||||
// Numeric field names aren't allowed in databases, so if the key is
|
||||
// numeric, we know it was assigned by PHP and the developer manually
|
||||
// entered the field information, so we'll simply add it to the list
|
||||
if (is_numeric($field))
|
||||
{
|
||||
$sql .= "\n\t$attributes";
|
||||
}
|
||||
else
|
||||
{
|
||||
$attributes = array_change_key_case($attributes, CASE_UPPER);
|
||||
|
||||
$sql .= "\n\t".$this->db->_protect_identifiers($field);
|
||||
|
||||
$sql .= ' '.$attributes['TYPE'];
|
||||
|
||||
if (array_key_exists('CONSTRAINT', $attributes))
|
||||
{
|
||||
$sql .= '('.$attributes['CONSTRAINT'].')';
|
||||
}
|
||||
|
||||
if (array_key_exists('UNSIGNED', $attributes) && $attributes['UNSIGNED'] === TRUE)
|
||||
{
|
||||
$sql .= ' UNSIGNED';
|
||||
}
|
||||
|
||||
if (array_key_exists('DEFAULT', $attributes))
|
||||
{
|
||||
$sql .= ' DEFAULT \''.$attributes['DEFAULT'].'\'';
|
||||
}
|
||||
|
||||
if (array_key_exists('NULL', $attributes) && $attributes['NULL'] === TRUE)
|
||||
{
|
||||
$sql .= ' NULL';
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql .= ' NOT NULL';
|
||||
}
|
||||
|
||||
if (array_key_exists('AUTO_INCREMENT', $attributes) && $attributes['AUTO_INCREMENT'] === TRUE)
|
||||
{
|
||||
$sql .= ' AUTO_INCREMENT';
|
||||
}
|
||||
}
|
||||
|
||||
// don't add a comma on the end of the last field
|
||||
if (++$current_field_count < count($fields))
|
||||
{
|
||||
$sql .= ',';
|
||||
}
|
||||
}
|
||||
|
||||
if (count($primary_keys) > 0)
|
||||
{
|
||||
$primary_keys = $this->db->_protect_identifiers($primary_keys);
|
||||
$sql .= ",\n\tPRIMARY KEY (" . implode(', ', $primary_keys) . ")";
|
||||
}
|
||||
|
||||
if (is_array($keys) && count($keys) > 0)
|
||||
{
|
||||
foreach ($keys as $key)
|
||||
{
|
||||
if (is_array($key))
|
||||
{
|
||||
$key = $this->db->_protect_identifiers($key);
|
||||
}
|
||||
else
|
||||
{
|
||||
$key = array($this->db->_protect_identifiers($key));
|
||||
}
|
||||
|
||||
$sql .= ",\n\tUNIQUE (" . implode(', ', $key) . ")";
|
||||
}
|
||||
}
|
||||
|
||||
$sql .= "\n)";
|
||||
|
||||
return $sql;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Drop Table
|
||||
*
|
||||
* Unsupported feature in SQLite
|
||||
*
|
||||
* @access private
|
||||
* @return bool
|
||||
*/
|
||||
function _drop_table($table)
|
||||
{
|
||||
if ($this->db->db_debug)
|
||||
{
|
||||
return $this->db->display_error('db_unsuported_feature');
|
||||
}
|
||||
return array();
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Alter table query
|
||||
*
|
||||
* Generates a platform-specific query so that a table can be altered
|
||||
* Called by add_column(), drop_column(), and column_alter(),
|
||||
*
|
||||
* @access private
|
||||
* @param string the ALTER type (ADD, DROP, CHANGE)
|
||||
* @param string the column name
|
||||
* @param string the table name
|
||||
* @param string the column definition
|
||||
* @param string the default value
|
||||
* @param boolean should 'NOT NULL' be added
|
||||
* @param string the field after which we should add the new field
|
||||
* @return object
|
||||
*/
|
||||
function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '')
|
||||
{
|
||||
$sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table)." $alter_type ".$this->db->_protect_identifiers($column_name);
|
||||
|
||||
// DROP has everything it needs now.
|
||||
if ($alter_type == 'DROP')
|
||||
{
|
||||
// SQLite does not support dropping columns
|
||||
// http://www.sqlite.org/omitted.html
|
||||
// http://www.sqlite.org/faq.html#q11
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$sql .= " $column_definition";
|
||||
|
||||
if ($default_value != '')
|
||||
{
|
||||
$sql .= " DEFAULT \"$default_value\"";
|
||||
}
|
||||
|
||||
if ($null === NULL)
|
||||
{
|
||||
$sql .= ' NULL';
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql .= ' NOT NULL';
|
||||
}
|
||||
|
||||
if ($after_field != '')
|
||||
{
|
||||
$sql .= ' AFTER ' . $this->db->_protect_identifiers($after_field);
|
||||
}
|
||||
|
||||
return $sql;
|
||||
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Rename a table
|
||||
*
|
||||
* Generates a platform-specific query so that a table can be renamed
|
||||
*
|
||||
* @access private
|
||||
* @param string the old table name
|
||||
* @param string the new table name
|
||||
* @return string
|
||||
*/
|
||||
function _rename_table($table_name, $new_table_name)
|
||||
{
|
||||
$sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table_name)." RENAME TO ".$this->db->_protect_identifiers($new_table_name);
|
||||
return $sql;
|
||||
}
|
||||
}
|
||||
|
||||
/* End of file sqlite_forge.php */
|
||||
/* Location: ./system/database/drivers/sqlite/sqlite_forge.php */
|
||||
179
system/database/drivers/sqlite/sqlite_result.php
Normal file
179
system/database/drivers/sqlite/sqlite_result.php
Normal file
@@ -0,0 +1,179 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP 4.3.2 or newer
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2010, EllisLab, Inc.
|
||||
* @license http://codeigniter.com/user_guide/license.html
|
||||
* @link http://codeigniter.com
|
||||
* @since Version 1.0
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* SQLite Result Class
|
||||
*
|
||||
* This class extends the parent result class: CI_DB_result
|
||||
*
|
||||
* @category Database
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @link http://codeigniter.com/user_guide/database/
|
||||
*/
|
||||
class CI_DB_sqlite_result extends CI_DB_result {
|
||||
|
||||
/**
|
||||
* Number of rows in the result set
|
||||
*
|
||||
* @access public
|
||||
* @return integer
|
||||
*/
|
||||
function num_rows()
|
||||
{
|
||||
return @sqlite_num_rows($this->result_id);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Number of fields in the result set
|
||||
*
|
||||
* @access public
|
||||
* @return integer
|
||||
*/
|
||||
function num_fields()
|
||||
{
|
||||
return @sqlite_num_fields($this->result_id);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Fetch Field Names
|
||||
*
|
||||
* Generates an array of column names
|
||||
*
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
function list_fields()
|
||||
{
|
||||
$field_names = array();
|
||||
for ($i = 0; $i < $this->num_fields(); $i++)
|
||||
{
|
||||
$field_names[] = sqlite_field_name($this->result_id, $i);
|
||||
}
|
||||
|
||||
return $field_names;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Field data
|
||||
*
|
||||
* Generates an array of objects containing field meta-data
|
||||
*
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
function field_data()
|
||||
{
|
||||
$retval = array();
|
||||
for ($i = 0; $i < $this->num_fields(); $i++)
|
||||
{
|
||||
$F = new stdClass();
|
||||
$F->name = sqlite_field_name($this->result_id, $i);
|
||||
$F->type = 'varchar';
|
||||
$F->max_length = 0;
|
||||
$F->primary_key = 0;
|
||||
$F->default = '';
|
||||
|
||||
$retval[] = $F;
|
||||
}
|
||||
|
||||
return $retval;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Free the result
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
function free_result()
|
||||
{
|
||||
// Not implemented in SQLite
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Data Seek
|
||||
*
|
||||
* Moves the internal pointer to the desired offset. We call
|
||||
* this internally before fetching results to make sure the
|
||||
* result set starts at zero
|
||||
*
|
||||
* @access private
|
||||
* @return array
|
||||
*/
|
||||
function _data_seek($n = 0)
|
||||
{
|
||||
return sqlite_seek($this->result_id, $n);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Result - associative array
|
||||
*
|
||||
* Returns the result set as an array
|
||||
*
|
||||
* @access private
|
||||
* @return array
|
||||
*/
|
||||
function _fetch_assoc()
|
||||
{
|
||||
return sqlite_fetch_array($this->result_id);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Result - object
|
||||
*
|
||||
* Returns the result set as an object
|
||||
*
|
||||
* @access private
|
||||
* @return object
|
||||
*/
|
||||
function _fetch_object()
|
||||
{
|
||||
if (function_exists('sqlite_fetch_object'))
|
||||
{
|
||||
return sqlite_fetch_object($this->result_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
$arr = sqlite_fetch_array($this->result_id, SQLITE_ASSOC);
|
||||
if (is_array($arr))
|
||||
{
|
||||
$obj = (object) $arr;
|
||||
return $obj;
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* End of file sqlite_result.php */
|
||||
/* Location: ./system/database/drivers/sqlite/sqlite_result.php */
|
||||
141
system/database/drivers/sqlite/sqlite_utility.php
Normal file
141
system/database/drivers/sqlite/sqlite_utility.php
Normal file
@@ -0,0 +1,141 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP 4.3.2 or newer
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2010, EllisLab, Inc.
|
||||
* @license http://codeigniter.com/user_guide/license.html
|
||||
* @link http://codeigniter.com
|
||||
* @since Version 1.0
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* SQLite Utility Class
|
||||
*
|
||||
* @category Database
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @link http://codeigniter.com/user_guide/database/
|
||||
*/
|
||||
class CI_DB_sqlite_utility extends CI_DB_utility {
|
||||
|
||||
/**
|
||||
* List databases
|
||||
*
|
||||
* I don't believe you can do a database listing with SQLite
|
||||
* since each database is its own file. I suppose we could
|
||||
* try reading a directory looking for SQLite files, but
|
||||
* that doesn't seem like a terribly good idea
|
||||
*
|
||||
* @access private
|
||||
* @return bool
|
||||
*/
|
||||
function _list_databases()
|
||||
{
|
||||
if ($this->db_debug)
|
||||
{
|
||||
return $this->display_error('db_unsuported_feature');
|
||||
}
|
||||
return array();
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Optimize table query
|
||||
*
|
||||
* Is optimization even supported in SQLite?
|
||||
*
|
||||
* @access private
|
||||
* @param string the table name
|
||||
* @return object
|
||||
*/
|
||||
function _optimize_table($table)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Repair table query
|
||||
*
|
||||
* Are table repairs even supported in SQLite?
|
||||
*
|
||||
* @access private
|
||||
* @param string the table name
|
||||
* @return object
|
||||
*/
|
||||
function _repair_table($table)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* SQLite Export
|
||||
*
|
||||
* @access private
|
||||
* @param array Preferences
|
||||
* @return mixed
|
||||
*/
|
||||
function _backup($params = array())
|
||||
{
|
||||
// Currently unsupported
|
||||
return $this->db->display_error('db_unsuported_feature');
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* The functions below have been deprecated as of 1.6, and are only here for backwards
|
||||
* compatibility. They now reside in dbforge(). The use of dbutils for database manipulation
|
||||
* is STRONGLY discouraged in favour if using dbforge.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Create database
|
||||
*
|
||||
* @access public
|
||||
* @param string the database name
|
||||
* @return bool
|
||||
*/
|
||||
function _create_database()
|
||||
{
|
||||
// In SQLite, a database is created when you connect to the database.
|
||||
// We'll return TRUE so that an error isn't generated
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Drop database
|
||||
*
|
||||
* @access private
|
||||
* @param string the database name
|
||||
* @return bool
|
||||
*/
|
||||
function _drop_database($name)
|
||||
{
|
||||
if ( ! @file_exists($this->db->database) OR ! @unlink($this->db->database))
|
||||
{
|
||||
if ($this->db->db_debug)
|
||||
{
|
||||
return $this->db->display_error('db_unable_to_drop');
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* End of file sqlite_utility.php */
|
||||
/* Location: ./system/database/drivers/sqlite/sqlite_utility.php */
|
||||
10
system/database/index.html
Normal file
10
system/database/index.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
10
system/fonts/index.html
Normal file
10
system/fonts/index.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
BIN
system/fonts/texb.ttf
Normal file
BIN
system/fonts/texb.ttf
Normal file
Binary file not shown.
78
system/helpers/array_helper.php
Normal file
78
system/helpers/array_helper.php
Normal file
@@ -0,0 +1,78 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP 4.3.2 or newer
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2010, EllisLab, Inc.
|
||||
* @license http://codeigniter.com/user_guide/license.html
|
||||
* @link http://codeigniter.com
|
||||
* @since Version 1.0
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* CodeIgniter Array Helpers
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @subpackage Helpers
|
||||
* @category Helpers
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @link http://codeigniter.com/user_guide/helpers/array_helper.html
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Element
|
||||
*
|
||||
* Lets you determine whether an array index is set and whether it has a value.
|
||||
* If the element is empty it returns FALSE (or whatever you specify as the default value.)
|
||||
*
|
||||
* @access public
|
||||
* @param string
|
||||
* @param array
|
||||
* @param mixed
|
||||
* @return mixed depends on what the array contains
|
||||
*/
|
||||
if ( ! function_exists('element'))
|
||||
{
|
||||
function element($item, $array, $default = FALSE)
|
||||
{
|
||||
if ( ! isset($array[$item]) OR $array[$item] == "")
|
||||
{
|
||||
return $default;
|
||||
}
|
||||
|
||||
return $array[$item];
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Random Element - Takes an array as input and returns a random element
|
||||
*
|
||||
* @access public
|
||||
* @param array
|
||||
* @return mixed depends on what the array contains
|
||||
*/
|
||||
if ( ! function_exists('random_element'))
|
||||
{
|
||||
function random_element($array)
|
||||
{
|
||||
if ( ! is_array($array))
|
||||
{
|
||||
return $array;
|
||||
}
|
||||
return $array[array_rand($array)];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* End of file array_helper.php */
|
||||
/* Location: ./system/helpers/array_helper.php */
|
||||
498
system/helpers/compatibility_helper.php
Normal file
498
system/helpers/compatibility_helper.php
Normal file
@@ -0,0 +1,498 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP 4.3.2 or newer
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2010, EllisLab, Inc.
|
||||
* @license http://codeigniter.com/user_guide/license.html
|
||||
* @link http://codeigniter.com
|
||||
* @since Version 1.0
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* CodeIgniter Compatibility Helpers
|
||||
*
|
||||
* This helper contains some functions based on the PEAR PHP_Compat library
|
||||
* http://pear.php.net/package/PHP_Compat
|
||||
*
|
||||
* The PEAR compat library is a little bloated and the code doesn't harmonize
|
||||
* well with CodeIgniter, so those functions have been refactored.
|
||||
* We cheat a little and use CI's _exception_handler() to output our own PHP errors
|
||||
* so that the behavior fully mimicks the PHP 5 counterparts. -- Derek Jones
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @subpackage Helpers
|
||||
* @category Helpers
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @link http://codeigniter.com/user_guide/helpers/compatibility_helper.html
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
if ( ! defined('PHP_EOL'))
|
||||
{
|
||||
define('PHP_EOL', (DIRECTORY_SEPARATOR == '/') ? "\n" : "\r\n");
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* file_put_contents()
|
||||
*
|
||||
* Writes a string to a file
|
||||
* http://us.php.net/manual/en/function.file_put_contents.php
|
||||
* argument 4, $context, not supported
|
||||
*
|
||||
* @access public
|
||||
* @param string file name
|
||||
* @param mixed data to be written
|
||||
* @param int flags
|
||||
* @return int length of written string
|
||||
*/
|
||||
if ( ! function_exists('file_put_contents'))
|
||||
{
|
||||
function file_put_contents($filename, $data, $flags = NULL)
|
||||
{
|
||||
if (is_scalar($data))
|
||||
{
|
||||
settype($data, 'STRING');
|
||||
}
|
||||
|
||||
if ( ! is_string($data) && ! is_array($data) && ! is_resource($data))
|
||||
{
|
||||
$backtrace = debug_backtrace();
|
||||
_exception_handler(E_USER_WARNING, 'file_put_contents(): the 2nd parameter should be either a string or an array', $backtrace[0]['file'], $backtrace[0]['line']);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// read stream if given a stream resource
|
||||
if (is_resource($data))
|
||||
{
|
||||
if (get_resource_type($data) !== 'stream')
|
||||
{
|
||||
$backtrace = debug_backtrace();
|
||||
_exception_handler(E_USER_WARNING, 'file_put_contents(): supplied resource is not a valid stream resource', $backtrace[0]['file'], $backtrace[0]['line']);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$text = '';
|
||||
|
||||
while ( ! feof($data))
|
||||
{
|
||||
$text .= fread($data, 4096);
|
||||
}
|
||||
|
||||
$data = $text;
|
||||
unset($text);
|
||||
}
|
||||
|
||||
// strings only please!
|
||||
if (is_array($data))
|
||||
{
|
||||
$data = implode('', $data);
|
||||
}
|
||||
|
||||
// Set the appropriate mode
|
||||
if (($flags & 8) > 0) // 8 = FILE_APPEND flag
|
||||
{
|
||||
$mode = FOPEN_WRITE_CREATE;
|
||||
}
|
||||
else
|
||||
{
|
||||
$mode = FOPEN_WRITE_CREATE_DESTRUCTIVE;
|
||||
}
|
||||
|
||||
// Check if we're using the include path
|
||||
if (($flags & 1) > 0) // 1 = FILE_USE_INCLUDE_PATH flag
|
||||
{
|
||||
$use_include_path = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
$use_include_path = FALSE;
|
||||
}
|
||||
|
||||
$fp = @fopen($filename, $mode, $use_include_path);
|
||||
|
||||
if ($fp === FALSE)
|
||||
{
|
||||
$backtrace = debug_backtrace();
|
||||
_exception_handler(E_USER_WARNING, 'file_put_contents('.htmlentities($filename).') failed to open stream', $backtrace[0]['file'], $backtrace[0]['line']);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (($flags & LOCK_EX) > 0)
|
||||
{
|
||||
if ( ! flock($fp, LOCK_EX))
|
||||
{
|
||||
$backtrace = debug_backtrace();
|
||||
_exception_handler(E_USER_WARNING, 'file_put_contents('.htmlentities($filename).') unable to acquire an exclusive lock on file', $backtrace[0]['file'], $backtrace[0]['line']);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
// write it
|
||||
if (($written = @fwrite($fp, $data)) === FALSE)
|
||||
{
|
||||
$backtrace = debug_backtrace();
|
||||
_exception_handler(E_USER_WARNING, 'file_put_contents('.htmlentities($filename).') failed to write to '.htmlentities($filename), $backtrace[0]['file'], $backtrace[0]['line']);
|
||||
}
|
||||
|
||||
// Close the handle
|
||||
@fclose($fp);
|
||||
|
||||
// Return length
|
||||
return $written;
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* fputcsv()
|
||||
*
|
||||
* Format line as CSV and write to file pointer
|
||||
* http://us.php.net/manual/en/function.fputcsv.php
|
||||
*
|
||||
* @access public
|
||||
* @param resource file pointer
|
||||
* @param array data to be written
|
||||
* @param string delimiter
|
||||
* @param string enclosure
|
||||
* @return int length of written string
|
||||
*/
|
||||
if ( ! function_exists('fputcsv'))
|
||||
{
|
||||
function fputcsv($handle, $fields, $delimiter = ',', $enclosure = '"')
|
||||
{
|
||||
// Checking for a handle resource
|
||||
if ( ! is_resource($handle))
|
||||
{
|
||||
$backtrace = debug_backtrace();
|
||||
_exception_handler(E_USER_WARNING, 'fputcsv() expects parameter 1 to be stream resource, '.gettype($handle).' given', $backtrace[0]['file'], $backtrace[0]['line']);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// OK, it is a resource, but is it a stream?
|
||||
if (get_resource_type($handle) !== 'stream')
|
||||
{
|
||||
$backtrace = debug_backtrace();
|
||||
_exception_handler(E_USER_WARNING, 'fputcsv() expects parameter 1 to be stream resource, '.get_resource_type($handle).' given', $backtrace[0]['file'], $backtrace[0]['line']);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Checking for an array of fields
|
||||
if ( ! is_array($fields))
|
||||
{
|
||||
$backtrace = debug_backtrace();
|
||||
_exception_handler(E_USER_WARNING, 'fputcsv() expects parameter 2 to be array, '.gettype($fields).' given', $backtrace[0]['file'], $backtrace[0]['line']);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// validate delimiter
|
||||
if (strlen($delimiter) > 1)
|
||||
{
|
||||
$delimiter = substr($delimiter, 0, 1);
|
||||
$backtrace = debug_backtrace();
|
||||
_exception_handler(E_NOTICE, 'fputcsv() delimiter must be one character long, "'.htmlentities($delimiter).'" used', $backtrace[0]['file'], $backtrace[0]['line']);
|
||||
}
|
||||
|
||||
// validate enclosure
|
||||
if (strlen($enclosure) > 1)
|
||||
{
|
||||
$enclosure = substr($enclosure, 0, 1);
|
||||
$backtrace = debug_backtrace();
|
||||
_exception_handler(E_NOTICE, 'fputcsv() enclosure must be one character long, "'.htmlentities($enclosure).'" used', $backtrace[0]['file'], $backtrace[0]['line']);
|
||||
|
||||
}
|
||||
|
||||
$out = '';
|
||||
|
||||
foreach ($fields as $cell)
|
||||
{
|
||||
$cell = str_replace($enclosure, $enclosure.$enclosure, $cell);
|
||||
|
||||
if (strpos($cell, $delimiter) !== FALSE OR strpos($cell, $enclosure) !== FALSE OR strpos($cell, "\n") !== FALSE)
|
||||
{
|
||||
$out .= $enclosure.$cell.$enclosure.$delimiter;
|
||||
}
|
||||
else
|
||||
{
|
||||
$out .= $cell.$delimiter;
|
||||
}
|
||||
}
|
||||
|
||||
$length = @fwrite($handle, substr($out, 0, -1)."\n");
|
||||
|
||||
return $length;
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* stripos()
|
||||
*
|
||||
* Find position of first occurrence of a case-insensitive string
|
||||
* http://us.php.net/manual/en/function.stripos.php
|
||||
*
|
||||
* @access public
|
||||
* @param string haystack
|
||||
* @param string needle
|
||||
* @param int offset
|
||||
* @return int numeric position of the first occurrence of needle in the haystack
|
||||
*/
|
||||
if ( ! function_exists('stripos'))
|
||||
{
|
||||
function stripos($haystack, $needle, $offset = NULL)
|
||||
{
|
||||
// Cast non string scalar values
|
||||
if (is_scalar($haystack))
|
||||
{
|
||||
settype($haystack, 'STRING');
|
||||
}
|
||||
|
||||
if ( ! is_string($haystack))
|
||||
{
|
||||
$backtrace = debug_backtrace();
|
||||
_exception_handler(E_USER_WARNING, 'stripos() expects parameter 1 to be string, '.gettype($haystack).' given', $backtrace[0]['file'], $backtrace[0]['line']);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ( ! is_scalar($needle))
|
||||
{
|
||||
$backtrace = debug_backtrace();
|
||||
_exception_handler(E_USER_WARNING, 'stripos() needle is not a string or an integer in '.$backtrace[0]['file'], $backtrace[0]['line']);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (is_float($offset))
|
||||
{
|
||||
$offset = (int)$offset;
|
||||
}
|
||||
|
||||
if ( ! is_int($offset) && ! is_bool($offset) && ! is_null($offset))
|
||||
{
|
||||
$backtrace = debug_backtrace();
|
||||
_exception_handler(E_USER_WARNING, 'stripos() expects parameter 3 to be long, '.gettype($offset).' given', $backtrace[0]['file'], $backtrace[0]['line']);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return strpos(strtolower($haystack), strtolower($needle), $offset);
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* str_ireplace()
|
||||
*
|
||||
* Find position of first occurrence of a case-insensitive string
|
||||
* http://us.php.net/manual/en/function.str-ireplace.php
|
||||
* (parameter 4, $count, is not supported as to do so in PHP 4 would make
|
||||
* it a required parameter)
|
||||
*
|
||||
* @access public
|
||||
* @param mixed search
|
||||
* @param mixed replace
|
||||
* @param mixed subject
|
||||
* @return int numeric position of the first occurrence of needle in the haystack
|
||||
*/
|
||||
if ( ! function_exists('str_ireplace'))
|
||||
{
|
||||
function str_ireplace($search, $replace, $subject)
|
||||
{
|
||||
// Nothing to do here
|
||||
if ($search === NULL OR $subject === NULL)
|
||||
{
|
||||
return $subject;
|
||||
}
|
||||
|
||||
// Crazy arguments
|
||||
if (is_scalar($search) && is_array($replace))
|
||||
{
|
||||
$backtrace = debug_backtrace();
|
||||
|
||||
if (is_object($replace))
|
||||
{
|
||||
show_error('Object of class '.get_class($replace).' could not be converted to string in '.$backtrace[0]['file'].' on line '.$backtrace[0]['line']);
|
||||
}
|
||||
else
|
||||
{
|
||||
_exception_handler(E_USER_NOTICE, 'Array to string conversion in '.$backtrace[0]['file'], $backtrace[0]['line']);
|
||||
}
|
||||
}
|
||||
|
||||
// Searching for an array
|
||||
if (is_array($search))
|
||||
{
|
||||
// Replacing with an array
|
||||
if (is_array($replace))
|
||||
{
|
||||
$search = array_values($search);
|
||||
$replace = array_values($replace);
|
||||
|
||||
if (count($search) >= count($replace))
|
||||
{
|
||||
$replace = array_pad($replace, count($search), '');
|
||||
}
|
||||
else
|
||||
{
|
||||
$replace = array_slice($replace, 0, count($search));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Replacing with a string all positions
|
||||
$replace = array_fill(0, count($search), $replace);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Searching for a string and replacing with a string.
|
||||
$search = array((string)$search);
|
||||
$replace = array((string)$replace);
|
||||
}
|
||||
|
||||
// Prepare the search array
|
||||
foreach ($search as $search_key => $search_value)
|
||||
{
|
||||
$search[$search_key] = '/'.preg_quote($search_value, '/').'/i';
|
||||
}
|
||||
|
||||
// Prepare the replace array (escape backreferences)
|
||||
foreach ($replace as $k => $v)
|
||||
{
|
||||
$replace[$k] = str_replace(array(chr(92), '$'), array(chr(92).chr(92), '\$'), $v);
|
||||
}
|
||||
|
||||
// do the replacement
|
||||
$result = preg_replace($search, $replace, (array)$subject);
|
||||
|
||||
// Check if subject was initially a string and return it as a string
|
||||
if ( ! is_array($subject))
|
||||
{
|
||||
return current($result);
|
||||
}
|
||||
|
||||
// Otherwise, just return the array
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* http_build_query()
|
||||
*
|
||||
* Generate URL-encoded query string
|
||||
* http://us.php.net/manual/en/function.http-build-query.php
|
||||
*
|
||||
* @access public
|
||||
* @param array form data
|
||||
* @param string numeric prefix
|
||||
* @param string argument separator
|
||||
* @return string URL-encoded string
|
||||
*/
|
||||
if ( ! function_exists('http_build_query'))
|
||||
{
|
||||
function http_build_query($formdata, $numeric_prefix = NULL, $separator = NULL)
|
||||
{
|
||||
// Check the data
|
||||
if ( ! is_array($formdata) && ! is_object($formdata))
|
||||
{
|
||||
$backtrace = debug_backtrace();
|
||||
_exception_handler(E_USER_WARNING, 'http_build_query() Parameter 1 expected to be Array or Object. Incorrect value given', $backtrace[0]['file'], $backtrace[0]['line']);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Cast it as array
|
||||
if (is_object($formdata))
|
||||
{
|
||||
$formdata = get_object_vars($formdata);
|
||||
}
|
||||
|
||||
// If the array is empty, return NULL
|
||||
if (empty($formdata))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Argument separator
|
||||
if ($separator === NULL)
|
||||
{
|
||||
$separator = ini_get('arg_separator.output');
|
||||
|
||||
if (strlen($separator) == 0)
|
||||
{
|
||||
$separator = '&';
|
||||
}
|
||||
}
|
||||
|
||||
// Start building the query
|
||||
$tmp = array();
|
||||
|
||||
foreach ($formdata as $key => $val)
|
||||
{
|
||||
if ($val === NULL)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (is_integer($key) && $numeric_prefix != NULL)
|
||||
{
|
||||
$key = $numeric_prefix.$key;
|
||||
}
|
||||
|
||||
if (is_resource($val))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// hand it off to a recursive parser
|
||||
$tmp[] = _http_build_query_helper($key, $val, $separator);
|
||||
}
|
||||
|
||||
return implode($separator, $tmp);
|
||||
}
|
||||
|
||||
|
||||
// Helper helper. Remind anyone of college?
|
||||
// Required to handle recursion in nested arrays.
|
||||
//
|
||||
// You could shave fractions of fractions of a second by moving where
|
||||
// the urlencoding takes place, but it's much less intuitive, and if
|
||||
// your application has 10,000 form fields, well, you have other problems ;)
|
||||
function _http_build_query_helper($key, $val, $separator = '&')
|
||||
{
|
||||
if (is_scalar($val))
|
||||
{
|
||||
return urlencode($key).'='.urlencode($val);
|
||||
}
|
||||
else
|
||||
{
|
||||
// arrays please
|
||||
if (is_object($val))
|
||||
{
|
||||
$val = get_object_vars($val);
|
||||
}
|
||||
|
||||
foreach ($val as $k => $v)
|
||||
{
|
||||
$tmp[] = _http_build_query_helper($key.'['.$k.']', $v, $separator);
|
||||
}
|
||||
}
|
||||
|
||||
return implode($separator, $tmp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* End of file compatibility_helper.php */
|
||||
/* Location: ./system/helpers/compatibility_helper.php */
|
||||
144
system/helpers/cookie_helper.php
Normal file
144
system/helpers/cookie_helper.php
Normal file
@@ -0,0 +1,144 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP 4.3.2 or newer
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2010, EllisLab, Inc.
|
||||
* @license http://codeigniter.com/user_guide/license.html
|
||||
* @link http://codeigniter.com
|
||||
* @since Version 1.0
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* CodeIgniter Cookie Helpers
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @subpackage Helpers
|
||||
* @category Helpers
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @link http://codeigniter.com/user_guide/helpers/cookie_helper.html
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Set cookie
|
||||
*
|
||||
* Accepts six parameter, or you can submit an associative
|
||||
* array in the first parameter containing all the values.
|
||||
*
|
||||
* @access public
|
||||
* @param mixed
|
||||
* @param string the value of the cookie
|
||||
* @param string the number of seconds until expiration
|
||||
* @param string the cookie domain. Usually: .yourdomain.com
|
||||
* @param string the cookie path
|
||||
* @param string the cookie prefix
|
||||
* @return void
|
||||
*/
|
||||
if ( ! function_exists('set_cookie'))
|
||||
{
|
||||
function set_cookie($name = '', $value = '', $expire = '', $domain = '', $path = '/', $prefix = '')
|
||||
{
|
||||
if (is_array($name))
|
||||
{
|
||||
foreach (array('value', 'expire', 'domain', 'path', 'prefix', 'name') as $item)
|
||||
{
|
||||
if (isset($name[$item]))
|
||||
{
|
||||
$$item = $name[$item];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Set the config file options
|
||||
$CI =& get_instance();
|
||||
|
||||
if ($prefix == '' AND $CI->config->item('cookie_prefix') != '')
|
||||
{
|
||||
$prefix = $CI->config->item('cookie_prefix');
|
||||
}
|
||||
if ($domain == '' AND $CI->config->item('cookie_domain') != '')
|
||||
{
|
||||
$domain = $CI->config->item('cookie_domain');
|
||||
}
|
||||
if ($path == '/' AND $CI->config->item('cookie_path') != '/')
|
||||
{
|
||||
$path = $CI->config->item('cookie_path');
|
||||
}
|
||||
|
||||
if ( ! is_numeric($expire))
|
||||
{
|
||||
$expire = time() - 86500;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($expire > 0)
|
||||
{
|
||||
$expire = time() + $expire;
|
||||
}
|
||||
else
|
||||
{
|
||||
$expire = 0;
|
||||
}
|
||||
}
|
||||
|
||||
setcookie($prefix.$name, $value, $expire, $path, $domain, 0);
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Fetch an item from the COOKIE array
|
||||
*
|
||||
* @access public
|
||||
* @param string
|
||||
* @param bool
|
||||
* @return mixed
|
||||
*/
|
||||
if ( ! function_exists('get_cookie'))
|
||||
{
|
||||
function get_cookie($index = '', $xss_clean = FALSE)
|
||||
{
|
||||
$CI =& get_instance();
|
||||
|
||||
$prefix = '';
|
||||
|
||||
if ( ! isset($_COOKIE[$index]) && config_item('cookie_prefix') != '')
|
||||
{
|
||||
$prefix = config_item('cookie_prefix');
|
||||
}
|
||||
|
||||
return $CI->input->cookie($prefix.$index, $xss_clean);
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Delete a COOKIE
|
||||
*
|
||||
* @param mixed
|
||||
* @param string the cookie domain. Usually: .yourdomain.com
|
||||
* @param string the cookie path
|
||||
* @param string the cookie prefix
|
||||
* @return void
|
||||
*/
|
||||
if ( ! function_exists('delete_cookie'))
|
||||
{
|
||||
function delete_cookie($name = '', $domain = '', $path = '/', $prefix = '')
|
||||
{
|
||||
set_cookie($name, '', '', $domain, $path, $prefix);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* End of file cookie_helper.php */
|
||||
/* Location: ./system/helpers/cookie_helper.php */
|
||||
611
system/helpers/date_helper.php
Normal file
611
system/helpers/date_helper.php
Normal file
@@ -0,0 +1,611 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP 4.3.2 or newer
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2010, EllisLab, Inc.
|
||||
* @license http://codeigniter.com/user_guide/license.html
|
||||
* @link http://codeigniter.com
|
||||
* @since Version 1.0
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* CodeIgniter Date Helpers
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @subpackage Helpers
|
||||
* @category Helpers
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @link http://codeigniter.com/user_guide/helpers/date_helper.html
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Get "now" time
|
||||
*
|
||||
* Returns time() or its GMT equivalent based on the config file preference
|
||||
*
|
||||
* @access public
|
||||
* @return integer
|
||||
*/
|
||||
if ( ! function_exists('now'))
|
||||
{
|
||||
function now()
|
||||
{
|
||||
$CI =& get_instance();
|
||||
|
||||
if (strtolower($CI->config->item('time_reference')) == 'gmt')
|
||||
{
|
||||
$now = time();
|
||||
$system_time = mktime(gmdate("H", $now), gmdate("i", $now), gmdate("s", $now), gmdate("m", $now), gmdate("d", $now), gmdate("Y", $now));
|
||||
|
||||
if (strlen($system_time) < 10)
|
||||
{
|
||||
$system_time = time();
|
||||
log_message('error', 'The Date class could not set a proper GMT timestamp so the local time() value was used.');
|
||||
}
|
||||
|
||||
return $system_time;
|
||||
}
|
||||
else
|
||||
{
|
||||
return time();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Convert MySQL Style Datecodes
|
||||
*
|
||||
* This function is identical to PHPs date() function,
|
||||
* except that it allows date codes to be formatted using
|
||||
* the MySQL style, where each code letter is preceded
|
||||
* with a percent sign: %Y %m %d etc...
|
||||
*
|
||||
* The benefit of doing dates this way is that you don't
|
||||
* have to worry about escaping your text letters that
|
||||
* match the date codes.
|
||||
*
|
||||
* @access public
|
||||
* @param string
|
||||
* @param integer
|
||||
* @return integer
|
||||
*/
|
||||
if ( ! function_exists('mdate'))
|
||||
{
|
||||
function mdate($datestr = '', $time = '')
|
||||
{
|
||||
if ($datestr == '')
|
||||
return '';
|
||||
|
||||
if ($time == '')
|
||||
$time = now();
|
||||
|
||||
$datestr = str_replace('%\\', '', preg_replace("/([a-z]+?){1}/i", "\\\\\\1", $datestr));
|
||||
return date($datestr, $time);
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Standard Date
|
||||
*
|
||||
* Returns a date formatted according to the submitted standard.
|
||||
*
|
||||
* @access public
|
||||
* @param string the chosen format
|
||||
* @param integer Unix timestamp
|
||||
* @return string
|
||||
*/
|
||||
if ( ! function_exists('standard_date'))
|
||||
{
|
||||
function standard_date($fmt = 'DATE_RFC822', $time = '')
|
||||
{
|
||||
$formats = array(
|
||||
'DATE_ATOM' => '%Y-%m-%dT%H:%i:%s%Q',
|
||||
'DATE_COOKIE' => '%l, %d-%M-%y %H:%i:%s UTC',
|
||||
'DATE_ISO8601' => '%Y-%m-%dT%H:%i:%s%O',
|
||||
'DATE_RFC822' => '%D, %d %M %y %H:%i:%s %O',
|
||||
'DATE_RFC850' => '%l, %d-%M-%y %H:%m:%i UTC',
|
||||
'DATE_RFC1036' => '%D, %d %M %y %H:%i:%s %O',
|
||||
'DATE_RFC1123' => '%D, %d %M %Y %H:%i:%s %O',
|
||||
'DATE_RSS' => '%D, %d %M %Y %H:%i:%s %O',
|
||||
'DATE_W3C' => '%Y-%m-%dT%H:%i:%s%Q'
|
||||
);
|
||||
|
||||
if ( ! isset($formats[$fmt]))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return mdate($formats[$fmt], $time);
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Timespan
|
||||
*
|
||||
* Returns a span of seconds in this format:
|
||||
* 10 days 14 hours 36 minutes 47 seconds
|
||||
*
|
||||
* @access public
|
||||
* @param integer a number of seconds
|
||||
* @param integer Unix timestamp
|
||||
* @return integer
|
||||
*/
|
||||
if ( ! function_exists('timespan'))
|
||||
{
|
||||
function timespan($seconds = 1, $time = '')
|
||||
{
|
||||
$CI =& get_instance();
|
||||
$CI->lang->load('date');
|
||||
|
||||
if ( ! is_numeric($seconds))
|
||||
{
|
||||
$seconds = 1;
|
||||
}
|
||||
|
||||
if ( ! is_numeric($time))
|
||||
{
|
||||
$time = time();
|
||||
}
|
||||
|
||||
if ($time <= $seconds)
|
||||
{
|
||||
$seconds = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$seconds = $time - $seconds;
|
||||
}
|
||||
|
||||
$str = '';
|
||||
$years = floor($seconds / 31536000);
|
||||
|
||||
if ($years > 0)
|
||||
{
|
||||
$str .= $years.' '.$CI->lang->line((($years > 1) ? 'date_years' : 'date_year')).', ';
|
||||
}
|
||||
|
||||
$seconds -= $years * 31536000;
|
||||
$months = floor($seconds / 2628000);
|
||||
|
||||
if ($years > 0 OR $months > 0)
|
||||
{
|
||||
if ($months > 0)
|
||||
{
|
||||
$str .= $months.' '.$CI->lang->line((($months > 1) ? 'date_months' : 'date_month')).', ';
|
||||
}
|
||||
|
||||
$seconds -= $months * 2628000;
|
||||
}
|
||||
|
||||
$weeks = floor($seconds / 604800);
|
||||
|
||||
if ($years > 0 OR $months > 0 OR $weeks > 0)
|
||||
{
|
||||
if ($weeks > 0)
|
||||
{
|
||||
$str .= $weeks.' '.$CI->lang->line((($weeks > 1) ? 'date_weeks' : 'date_week')).', ';
|
||||
}
|
||||
|
||||
$seconds -= $weeks * 604800;
|
||||
}
|
||||
|
||||
$days = floor($seconds / 86400);
|
||||
|
||||
if ($months > 0 OR $weeks > 0 OR $days > 0)
|
||||
{
|
||||
if ($days > 0)
|
||||
{
|
||||
$str .= $days.' '.$CI->lang->line((($days > 1) ? 'date_days' : 'date_day')).', ';
|
||||
}
|
||||
|
||||
$seconds -= $days * 86400;
|
||||
}
|
||||
|
||||
$hours = floor($seconds / 3600);
|
||||
|
||||
if ($days > 0 OR $hours > 0)
|
||||
{
|
||||
if ($hours > 0)
|
||||
{
|
||||
$str .= $hours.' '.$CI->lang->line((($hours > 1) ? 'date_hours' : 'date_hour')).', ';
|
||||
}
|
||||
|
||||
$seconds -= $hours * 3600;
|
||||
}
|
||||
|
||||
$minutes = floor($seconds / 60);
|
||||
|
||||
if ($days > 0 OR $hours > 0 OR $minutes > 0)
|
||||
{
|
||||
if ($minutes > 0)
|
||||
{
|
||||
$str .= $minutes.' '.$CI->lang->line((($minutes > 1) ? 'date_minutes' : 'date_minute')).', ';
|
||||
}
|
||||
|
||||
$seconds -= $minutes * 60;
|
||||
}
|
||||
|
||||
if ($str == '')
|
||||
{
|
||||
$str .= $seconds.' '.$CI->lang->line((($seconds > 1) ? 'date_seconds' : 'date_second')).', ';
|
||||
}
|
||||
|
||||
return substr(trim($str), 0, -1);
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Number of days in a month
|
||||
*
|
||||
* Takes a month/year as input and returns the number of days
|
||||
* for the given month/year. Takes leap years into consideration.
|
||||
*
|
||||
* @access public
|
||||
* @param integer a numeric month
|
||||
* @param integer a numeric year
|
||||
* @return integer
|
||||
*/
|
||||
if ( ! function_exists('days_in_month'))
|
||||
{
|
||||
function days_in_month($month = 0, $year = '')
|
||||
{
|
||||
if ($month < 1 OR $month > 12)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ( ! is_numeric($year) OR strlen($year) != 4)
|
||||
{
|
||||
$year = date('Y');
|
||||
}
|
||||
|
||||
if ($month == 2)
|
||||
{
|
||||
if ($year % 400 == 0 OR ($year % 4 == 0 AND $year % 100 != 0))
|
||||
{
|
||||
return 29;
|
||||
}
|
||||
}
|
||||
|
||||
$days_in_month = array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
|
||||
return $days_in_month[$month - 1];
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Converts a local Unix timestamp to GMT
|
||||
*
|
||||
* @access public
|
||||
* @param integer Unix timestamp
|
||||
* @return integer
|
||||
*/
|
||||
if ( ! function_exists('local_to_gmt'))
|
||||
{
|
||||
function local_to_gmt($time = '')
|
||||
{
|
||||
if ($time == '')
|
||||
$time = time();
|
||||
|
||||
return mktime( gmdate("H", $time), gmdate("i", $time), gmdate("s", $time), gmdate("m", $time), gmdate("d", $time), gmdate("Y", $time));
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Converts GMT time to a localized value
|
||||
*
|
||||
* Takes a Unix timestamp (in GMT) as input, and returns
|
||||
* at the local value based on the timezone and DST setting
|
||||
* submitted
|
||||
*
|
||||
* @access public
|
||||
* @param integer Unix timestamp
|
||||
* @param string timezone
|
||||
* @param bool whether DST is active
|
||||
* @return integer
|
||||
*/
|
||||
if ( ! function_exists('gmt_to_local'))
|
||||
{
|
||||
function gmt_to_local($time = '', $timezone = 'UTC', $dst = FALSE)
|
||||
{
|
||||
if ($time == '')
|
||||
{
|
||||
return now();
|
||||
}
|
||||
|
||||
$time += timezones($timezone) * 3600;
|
||||
|
||||
if ($dst == TRUE)
|
||||
{
|
||||
$time += 3600;
|
||||
}
|
||||
|
||||
return $time;
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Converts a MySQL Timestamp to Unix
|
||||
*
|
||||
* @access public
|
||||
* @param integer Unix timestamp
|
||||
* @return integer
|
||||
*/
|
||||
if ( ! function_exists('mysql_to_unix'))
|
||||
{
|
||||
function mysql_to_unix($time = '')
|
||||
{
|
||||
// We'll remove certain characters for backward compatibility
|
||||
// since the formatting changed with MySQL 4.1
|
||||
// YYYY-MM-DD HH:MM:SS
|
||||
|
||||
$time = str_replace('-', '', $time);
|
||||
$time = str_replace(':', '', $time);
|
||||
$time = str_replace(' ', '', $time);
|
||||
|
||||
// YYYYMMDDHHMMSS
|
||||
return mktime(
|
||||
substr($time, 8, 2),
|
||||
substr($time, 10, 2),
|
||||
substr($time, 12, 2),
|
||||
substr($time, 4, 2),
|
||||
substr($time, 6, 2),
|
||||
substr($time, 0, 4)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Unix to "Human"
|
||||
*
|
||||
* Formats Unix timestamp to the following prototype: 2006-08-21 11:35 PM
|
||||
*
|
||||
* @access public
|
||||
* @param integer Unix timestamp
|
||||
* @param bool whether to show seconds
|
||||
* @param string format: us or euro
|
||||
* @return string
|
||||
*/
|
||||
if ( ! function_exists('unix_to_human'))
|
||||
{
|
||||
function unix_to_human($time = '', $seconds = FALSE, $fmt = 'us')
|
||||
{
|
||||
$r = date('Y', $time).'-'.date('m', $time).'-'.date('d', $time).' ';
|
||||
|
||||
if ($fmt == 'us')
|
||||
{
|
||||
$r .= date('h', $time).':'.date('i', $time);
|
||||
}
|
||||
else
|
||||
{
|
||||
$r .= date('H', $time).':'.date('i', $time);
|
||||
}
|
||||
|
||||
if ($seconds)
|
||||
{
|
||||
$r .= ':'.date('s', $time);
|
||||
}
|
||||
|
||||
if ($fmt == 'us')
|
||||
{
|
||||
$r .= ' '.date('A', $time);
|
||||
}
|
||||
|
||||
return $r;
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Convert "human" date to GMT
|
||||
*
|
||||
* Reverses the above process
|
||||
*
|
||||
* @access public
|
||||
* @param string format: us or euro
|
||||
* @return integer
|
||||
*/
|
||||
if ( ! function_exists('human_to_unix'))
|
||||
{
|
||||
function human_to_unix($datestr = '')
|
||||
{
|
||||
if ($datestr == '')
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$datestr = trim($datestr);
|
||||
$datestr = preg_replace("/\040+/", "\040", $datestr);
|
||||
|
||||
if ( ! preg_match('/^[0-9]{2,4}\-[0-9]{1,2}\-[0-9]{1,2}\s[0-9]{1,2}:[0-9]{1,2}(?::[0-9]{1,2})?(?:\s[AP]M)?$/i', $datestr))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$split = preg_split("/\040/", $datestr);
|
||||
|
||||
$ex = explode("-", $split['0']);
|
||||
|
||||
$year = (strlen($ex['0']) == 2) ? '20'.$ex['0'] : $ex['0'];
|
||||
$month = (strlen($ex['1']) == 1) ? '0'.$ex['1'] : $ex['1'];
|
||||
$day = (strlen($ex['2']) == 1) ? '0'.$ex['2'] : $ex['2'];
|
||||
|
||||
$ex = explode(":", $split['1']);
|
||||
|
||||
$hour = (strlen($ex['0']) == 1) ? '0'.$ex['0'] : $ex['0'];
|
||||
$min = (strlen($ex['1']) == 1) ? '0'.$ex['1'] : $ex['1'];
|
||||
|
||||
if (isset($ex['2']) && preg_match('/[0-9]{1,2}/', $ex['2']))
|
||||
{
|
||||
$sec = (strlen($ex['2']) == 1) ? '0'.$ex['2'] : $ex['2'];
|
||||
}
|
||||
else
|
||||
{
|
||||
// Unless specified, seconds get set to zero.
|
||||
$sec = '00';
|
||||
}
|
||||
|
||||
if (isset($split['2']))
|
||||
{
|
||||
$ampm = strtolower($split['2']);
|
||||
|
||||
if (substr($ampm, 0, 1) == 'p' AND $hour < 12)
|
||||
$hour = $hour + 12;
|
||||
|
||||
if (substr($ampm, 0, 1) == 'a' AND $hour == 12)
|
||||
$hour = '00';
|
||||
|
||||
if (strlen($hour) == 1)
|
||||
$hour = '0'.$hour;
|
||||
}
|
||||
|
||||
return mktime($hour, $min, $sec, $month, $day, $year);
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Timezone Menu
|
||||
*
|
||||
* Generates a drop-down menu of timezones.
|
||||
*
|
||||
* @access public
|
||||
* @param string timezone
|
||||
* @param string classname
|
||||
* @param string menu name
|
||||
* @return string
|
||||
*/
|
||||
if ( ! function_exists('timezone_menu'))
|
||||
{
|
||||
function timezone_menu($default = 'UTC', $class = "", $name = 'timezones')
|
||||
{
|
||||
$CI =& get_instance();
|
||||
$CI->lang->load('date');
|
||||
|
||||
if ($default == 'GMT')
|
||||
$default = 'UTC';
|
||||
|
||||
$menu = '<select name="'.$name.'"';
|
||||
|
||||
if ($class != '')
|
||||
{
|
||||
$menu .= ' class="'.$class.'"';
|
||||
}
|
||||
|
||||
$menu .= ">\n";
|
||||
|
||||
foreach (timezones() as $key => $val)
|
||||
{
|
||||
$selected = ($default == $key) ? " selected='selected'" : '';
|
||||
$menu .= "<option value='{$key}'{$selected}>".$CI->lang->line($key)."</option>\n";
|
||||
}
|
||||
|
||||
$menu .= "</select>";
|
||||
|
||||
return $menu;
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Timezones
|
||||
*
|
||||
* Returns an array of timezones. This is a helper function
|
||||
* for various other ones in this library
|
||||
*
|
||||
* @access public
|
||||
* @param string timezone
|
||||
* @return string
|
||||
*/
|
||||
if ( ! function_exists('timezones'))
|
||||
{
|
||||
function timezones($tz = '')
|
||||
{
|
||||
// Note: Don't change the order of these even though
|
||||
// some items appear to be in the wrong order
|
||||
|
||||
$zones = array(
|
||||
'UM12' => -12,
|
||||
'UM11' => -11,
|
||||
'UM10' => -10,
|
||||
'UM95' => -9.5,
|
||||
'UM9' => -9,
|
||||
'UM8' => -8,
|
||||
'UM7' => -7,
|
||||
'UM6' => -6,
|
||||
'UM5' => -5,
|
||||
'UM45' => -4.5,
|
||||
'UM4' => -4,
|
||||
'UM35' => -3.5,
|
||||
'UM3' => -3,
|
||||
'UM2' => -2,
|
||||
'UM1' => -1,
|
||||
'UTC' => 0,
|
||||
'UP1' => +1,
|
||||
'UP2' => +2,
|
||||
'UP3' => +3,
|
||||
'UP35' => +3.5,
|
||||
'UP4' => +4,
|
||||
'UP45' => +4.5,
|
||||
'UP5' => +5,
|
||||
'UP55' => +5.5,
|
||||
'UP575' => +5.75,
|
||||
'UP6' => +6,
|
||||
'UP65' => +6.5,
|
||||
'UP7' => +7,
|
||||
'UP8' => +8,
|
||||
'UP875' => +8.75,
|
||||
'UP9' => +9,
|
||||
'UP95' => +9.5,
|
||||
'UP10' => +10,
|
||||
'UP105' => +10.5,
|
||||
'UP11' => +11,
|
||||
'UP115' => +11.5,
|
||||
'UP12' => +12,
|
||||
'UP1275' => +12.75,
|
||||
'UP13' => +13,
|
||||
'UP14' => +14
|
||||
);
|
||||
|
||||
if ($tz == '')
|
||||
{
|
||||
return $zones;
|
||||
}
|
||||
|
||||
if ($tz == 'GMT')
|
||||
$tz = 'UTC';
|
||||
|
||||
return ( ! isset($zones[$tz])) ? 0 : $zones[$tz];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* End of file date_helper.php */
|
||||
/* Location: ./system/helpers/date_helper.php */
|
||||
84
system/helpers/directory_helper.php
Normal file
84
system/helpers/directory_helper.php
Normal file
@@ -0,0 +1,84 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP 4.3.2 or newer
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2010, EllisLab, Inc.
|
||||
* @license http://codeigniter.com/user_guide/license.html
|
||||
* @link http://codeigniter.com
|
||||
* @since Version 1.0
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* CodeIgniter Directory Helpers
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @subpackage Helpers
|
||||
* @category Helpers
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @link http://codeigniter.com/user_guide/helpers/directory_helper.html
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Create a Directory Map
|
||||
*
|
||||
* Reads the specified directory and builds an array
|
||||
* representation of it. Sub-folders contained with the
|
||||
* directory will be mapped as well.
|
||||
*
|
||||
* @access public
|
||||
* @param string path to source
|
||||
* @param bool whether to limit the result to the top level only
|
||||
* @return array
|
||||
*/
|
||||
if ( ! function_exists('directory_map'))
|
||||
{
|
||||
function directory_map($source_dir, $top_level_only = FALSE, $hidden = FALSE)
|
||||
{
|
||||
if ($fp = @opendir($source_dir))
|
||||
{
|
||||
$source_dir = rtrim($source_dir, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR;
|
||||
$filedata = array();
|
||||
|
||||
while (FALSE !== ($file = readdir($fp)))
|
||||
{
|
||||
if (($hidden == FALSE && strncmp($file, '.', 1) == 0) OR ($file == '.' OR $file == '..'))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($top_level_only == FALSE && @is_dir($source_dir.$file))
|
||||
{
|
||||
$temp_array = array();
|
||||
|
||||
$temp_array = directory_map($source_dir.$file.DIRECTORY_SEPARATOR, $top_level_only, $hidden);
|
||||
|
||||
$filedata[$file] = $temp_array;
|
||||
}
|
||||
else
|
||||
{
|
||||
$filedata[] = $file;
|
||||
}
|
||||
}
|
||||
|
||||
closedir($fp);
|
||||
return $filedata;
|
||||
}
|
||||
else
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* End of file directory_helper.php */
|
||||
/* Location: ./system/helpers/directory_helper.php */
|
||||
100
system/helpers/download_helper.php
Normal file
100
system/helpers/download_helper.php
Normal file
@@ -0,0 +1,100 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP 4.3.2 or newer
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2010, EllisLab, Inc.
|
||||
* @license http://codeigniter.com/user_guide/license.html
|
||||
* @link http://codeigniter.com
|
||||
* @since Version 1.0
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* CodeIgniter Download Helpers
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @subpackage Helpers
|
||||
* @category Helpers
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @link http://codeigniter.com/user_guide/helpers/download_helper.html
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Force Download
|
||||
*
|
||||
* Generates headers that force a download to happen
|
||||
*
|
||||
* @access public
|
||||
* @param string filename
|
||||
* @param mixed the data to be downloaded
|
||||
* @return void
|
||||
*/
|
||||
if ( ! function_exists('force_download'))
|
||||
{
|
||||
function force_download($filename = '', $data = '')
|
||||
{
|
||||
if ($filename == '' OR $data == '')
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Try to determine if the filename includes a file extension.
|
||||
// We need it in order to set the MIME type
|
||||
if (FALSE === strpos($filename, '.'))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Grab the file extension
|
||||
$x = explode('.', $filename);
|
||||
$extension = end($x);
|
||||
|
||||
// Load the mime types
|
||||
@include(APPPATH.'config/mimes'.EXT);
|
||||
|
||||
// Set a default mime if we can't find it
|
||||
if ( ! isset($mimes[$extension]))
|
||||
{
|
||||
$mime = 'application/octet-stream';
|
||||
}
|
||||
else
|
||||
{
|
||||
$mime = (is_array($mimes[$extension])) ? $mimes[$extension][0] : $mimes[$extension];
|
||||
}
|
||||
|
||||
// Generate the server headers
|
||||
if (strstr($_SERVER['HTTP_USER_AGENT'], "MSIE"))
|
||||
{
|
||||
header('Content-Type: "'.$mime.'"');
|
||||
header('Content-Disposition: attachment; filename="'.$filename.'"');
|
||||
header('Expires: 0');
|
||||
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
|
||||
header("Content-Transfer-Encoding: binary");
|
||||
header('Pragma: public');
|
||||
header("Content-Length: ".strlen($data));
|
||||
}
|
||||
else
|
||||
{
|
||||
header('Content-Type: "'.$mime.'"');
|
||||
header('Content-Disposition: attachment; filename="'.$filename.'"');
|
||||
header("Content-Transfer-Encoding: binary");
|
||||
header('Expires: 0');
|
||||
header('Pragma: no-cache');
|
||||
header("Content-Length: ".strlen($data));
|
||||
}
|
||||
|
||||
exit($data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* End of file download_helper.php */
|
||||
/* Location: ./system/helpers/download_helper.php */
|
||||
62
system/helpers/email_helper.php
Normal file
62
system/helpers/email_helper.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP 4.3.2 or newer
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2010, EllisLab, Inc.
|
||||
* @license http://codeigniter.com/user_guide/license.html
|
||||
* @link http://codeigniter.com
|
||||
* @since Version 1.0
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* CodeIgniter Email Helpers
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @subpackage Helpers
|
||||
* @category Helpers
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @link http://codeigniter.com/user_guide/helpers/email_helper.html
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Validate email address
|
||||
*
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
if ( ! function_exists('valid_email'))
|
||||
{
|
||||
function valid_email($address)
|
||||
{
|
||||
return ( ! preg_match("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix", $address)) ? FALSE : TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Send an email
|
||||
*
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
if ( ! function_exists('send_email'))
|
||||
{
|
||||
function send_email($recipient, $subject = 'Test email', $message = 'Hello World')
|
||||
{
|
||||
return mail($recipient, $subject, $message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* End of file email_helper.php */
|
||||
/* Location: ./system/helpers/email_helper.php */
|
||||
464
system/helpers/file_helper.php
Normal file
464
system/helpers/file_helper.php
Normal file
@@ -0,0 +1,464 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP 4.3.2 or newer
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2010, EllisLab, Inc.
|
||||
* @license http://codeigniter.com/user_guide/license.html
|
||||
* @link http://codeigniter.com
|
||||
* @since Version 1.0
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* CodeIgniter File Helpers
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @subpackage Helpers
|
||||
* @category Helpers
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @link http://codeigniter.com/user_guide/helpers/file_helpers.html
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Read File
|
||||
*
|
||||
* Opens the file specfied in the path and returns it as a string.
|
||||
*
|
||||
* @access public
|
||||
* @param string path to file
|
||||
* @return string
|
||||
*/
|
||||
if ( ! function_exists('read_file'))
|
||||
{
|
||||
function read_file($file)
|
||||
{
|
||||
if ( ! file_exists($file))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (function_exists('file_get_contents'))
|
||||
{
|
||||
return file_get_contents($file);
|
||||
}
|
||||
|
||||
if ( ! $fp = @fopen($file, FOPEN_READ))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
flock($fp, LOCK_SH);
|
||||
|
||||
$data = '';
|
||||
if (filesize($file) > 0)
|
||||
{
|
||||
$data =& fread($fp, filesize($file));
|
||||
}
|
||||
|
||||
flock($fp, LOCK_UN);
|
||||
fclose($fp);
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Write File
|
||||
*
|
||||
* Writes data to the file specified in the path.
|
||||
* Creates a new file if non-existent.
|
||||
*
|
||||
* @access public
|
||||
* @param string path to file
|
||||
* @param string file data
|
||||
* @return bool
|
||||
*/
|
||||
if ( ! function_exists('write_file'))
|
||||
{
|
||||
function write_file($path, $data, $mode = FOPEN_WRITE_CREATE_DESTRUCTIVE)
|
||||
{
|
||||
if ( ! $fp = @fopen($path, $mode))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
flock($fp, LOCK_EX);
|
||||
fwrite($fp, $data);
|
||||
flock($fp, LOCK_UN);
|
||||
fclose($fp);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Delete Files
|
||||
*
|
||||
* Deletes all files contained in the supplied directory path.
|
||||
* Files must be writable or owned by the system in order to be deleted.
|
||||
* If the second parameter is set to TRUE, any directories contained
|
||||
* within the supplied base directory will be nuked as well.
|
||||
*
|
||||
* @access public
|
||||
* @param string path to file
|
||||
* @param bool whether to delete any directories found in the path
|
||||
* @return bool
|
||||
*/
|
||||
if ( ! function_exists('delete_files'))
|
||||
{
|
||||
function delete_files($path, $del_dir = FALSE, $level = 0)
|
||||
{
|
||||
// Trim the trailing slash
|
||||
$path = rtrim($path, DIRECTORY_SEPARATOR);
|
||||
|
||||
if ( ! $current_dir = @opendir($path))
|
||||
return;
|
||||
|
||||
while(FALSE !== ($filename = @readdir($current_dir)))
|
||||
{
|
||||
if ($filename != "." and $filename != "..")
|
||||
{
|
||||
if (is_dir($path.DIRECTORY_SEPARATOR.$filename))
|
||||
{
|
||||
// Ignore empty folders
|
||||
if (substr($filename, 0, 1) != '.')
|
||||
{
|
||||
delete_files($path.DIRECTORY_SEPARATOR.$filename, $del_dir, $level + 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
unlink($path.DIRECTORY_SEPARATOR.$filename);
|
||||
}
|
||||
}
|
||||
}
|
||||
@closedir($current_dir);
|
||||
|
||||
if ($del_dir == TRUE AND $level > 0)
|
||||
{
|
||||
@rmdir($path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Get Filenames
|
||||
*
|
||||
* Reads the specified directory and builds an array containing the filenames.
|
||||
* Any sub-folders contained within the specified path are read as well.
|
||||
*
|
||||
* @access public
|
||||
* @param string path to source
|
||||
* @param bool whether to include the path as part of the filename
|
||||
* @param bool internal variable to determine recursion status - do not use in calls
|
||||
* @return array
|
||||
*/
|
||||
if ( ! function_exists('get_filenames'))
|
||||
{
|
||||
function get_filenames($source_dir, $include_path = FALSE, $_recursion = FALSE)
|
||||
{
|
||||
static $_filedata = array();
|
||||
|
||||
if ($fp = @opendir($source_dir))
|
||||
{
|
||||
// reset the array and make sure $source_dir has a trailing slash on the initial call
|
||||
if ($_recursion === FALSE)
|
||||
{
|
||||
$_filedata = array();
|
||||
$source_dir = rtrim(realpath($source_dir), DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR;
|
||||
}
|
||||
|
||||
while (FALSE !== ($file = readdir($fp)))
|
||||
{
|
||||
if (@is_dir($source_dir.$file) && strncmp($file, '.', 1) !== 0)
|
||||
{
|
||||
get_filenames($source_dir.$file.DIRECTORY_SEPARATOR, $include_path, TRUE);
|
||||
}
|
||||
elseif (strncmp($file, '.', 1) !== 0)
|
||||
{
|
||||
$_filedata[] = ($include_path == TRUE) ? $source_dir.$file : $file;
|
||||
}
|
||||
}
|
||||
return $_filedata;
|
||||
}
|
||||
else
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Get Directory File Information
|
||||
*
|
||||
* Reads the specified directory and builds an array containing the filenames,
|
||||
* filesize, dates, and permissions
|
||||
*
|
||||
* Any sub-folders contained within the specified path are read as well.
|
||||
*
|
||||
* @access public
|
||||
* @param string path to source
|
||||
* @param bool whether to include the path as part of the filename
|
||||
* @param bool internal variable to determine recursion status - do not use in calls
|
||||
* @return array
|
||||
*/
|
||||
if ( ! function_exists('get_dir_file_info'))
|
||||
{
|
||||
function get_dir_file_info($source_dir, $include_path = FALSE, $_recursion = FALSE)
|
||||
{
|
||||
static $_filedata = array();
|
||||
$relative_path = $source_dir;
|
||||
|
||||
if ($fp = @opendir($source_dir))
|
||||
{
|
||||
// reset the array and make sure $source_dir has a trailing slash on the initial call
|
||||
if ($_recursion === FALSE)
|
||||
{
|
||||
$_filedata = array();
|
||||
$source_dir = rtrim(realpath($source_dir), DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR;
|
||||
}
|
||||
|
||||
while (FALSE !== ($file = readdir($fp)))
|
||||
{
|
||||
if (@is_dir($source_dir.$file) && strncmp($file, '.', 1) !== 0)
|
||||
{
|
||||
get_dir_file_info($source_dir.$file.DIRECTORY_SEPARATOR, $include_path, TRUE);
|
||||
}
|
||||
elseif (strncmp($file, '.', 1) !== 0)
|
||||
{
|
||||
$_filedata[$file] = get_file_info($source_dir.$file);
|
||||
$_filedata[$file]['relative_path'] = $relative_path;
|
||||
}
|
||||
}
|
||||
return $_filedata;
|
||||
}
|
||||
else
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Get File Info
|
||||
*
|
||||
* Given a file and path, returns the name, path, size, date modified
|
||||
* Second parameter allows you to explicitly declare what information you want returned
|
||||
* Options are: name, server_path, size, date, readable, writable, executable, fileperms
|
||||
* Returns FALSE if the file cannot be found.
|
||||
*
|
||||
* @access public
|
||||
* @param string path to file
|
||||
* @param mixed array or comma separated string of information returned
|
||||
* @return array
|
||||
*/
|
||||
if ( ! function_exists('get_file_info'))
|
||||
{
|
||||
function get_file_info($file, $returned_values = array('name', 'server_path', 'size', 'date'))
|
||||
{
|
||||
|
||||
if ( ! file_exists($file))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (is_string($returned_values))
|
||||
{
|
||||
$returned_values = explode(',', $returned_values);
|
||||
}
|
||||
|
||||
foreach ($returned_values as $key)
|
||||
{
|
||||
switch ($key)
|
||||
{
|
||||
case 'name':
|
||||
$fileinfo['name'] = substr(strrchr($file, DIRECTORY_SEPARATOR), 1);
|
||||
break;
|
||||
case 'server_path':
|
||||
$fileinfo['server_path'] = $file;
|
||||
break;
|
||||
case 'size':
|
||||
$fileinfo['size'] = filesize($file);
|
||||
break;
|
||||
case 'date':
|
||||
$fileinfo['date'] = filectime($file);
|
||||
break;
|
||||
case 'readable':
|
||||
$fileinfo['readable'] = is_readable($file);
|
||||
break;
|
||||
case 'writable':
|
||||
// There are known problems using is_weritable on IIS. It may not be reliable - consider fileperms()
|
||||
$fileinfo['writable'] = is_writable($file);
|
||||
break;
|
||||
case 'executable':
|
||||
$fileinfo['executable'] = is_executable($file);
|
||||
break;
|
||||
case 'fileperms':
|
||||
$fileinfo['fileperms'] = fileperms($file);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $fileinfo;
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Get Mime by Extension
|
||||
*
|
||||
* Translates a file extension into a mime type based on config/mimes.php.
|
||||
* Returns FALSE if it can't determine the type, or open the mime config file
|
||||
*
|
||||
* Note: this is NOT an accurate way of determining file mime types, and is here strictly as a convenience
|
||||
* It should NOT be trusted, and should certainly NOT be used for security
|
||||
*
|
||||
* @access public
|
||||
* @param string path to file
|
||||
* @return mixed
|
||||
*/
|
||||
if ( ! function_exists('get_mime_by_extension'))
|
||||
{
|
||||
function get_mime_by_extension($file)
|
||||
{
|
||||
$extension = substr(strrchr($file, '.'), 1);
|
||||
|
||||
global $mimes;
|
||||
|
||||
if ( ! is_array($mimes))
|
||||
{
|
||||
if ( ! require_once(APPPATH.'config/mimes.php'))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (array_key_exists($extension, $mimes))
|
||||
{
|
||||
if (is_array($mimes[$extension]))
|
||||
{
|
||||
// Multiple mime types, just give the first one
|
||||
return current($mimes[$extension]);
|
||||
}
|
||||
else
|
||||
{
|
||||
return $mimes[$extension];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Symbolic Permissions
|
||||
*
|
||||
* Takes a numeric value representing a file's permissions and returns
|
||||
* standard symbolic notation representing that value
|
||||
*
|
||||
* @access public
|
||||
* @param int
|
||||
* @return string
|
||||
*/
|
||||
if ( ! function_exists('symbolic_permissions'))
|
||||
{
|
||||
function symbolic_permissions($perms)
|
||||
{
|
||||
if (($perms & 0xC000) == 0xC000)
|
||||
{
|
||||
$symbolic = 's'; // Socket
|
||||
}
|
||||
elseif (($perms & 0xA000) == 0xA000)
|
||||
{
|
||||
$symbolic = 'l'; // Symbolic Link
|
||||
}
|
||||
elseif (($perms & 0x8000) == 0x8000)
|
||||
{
|
||||
$symbolic = '-'; // Regular
|
||||
}
|
||||
elseif (($perms & 0x6000) == 0x6000)
|
||||
{
|
||||
$symbolic = 'b'; // Block special
|
||||
}
|
||||
elseif (($perms & 0x4000) == 0x4000)
|
||||
{
|
||||
$symbolic = 'd'; // Directory
|
||||
}
|
||||
elseif (($perms & 0x2000) == 0x2000)
|
||||
{
|
||||
$symbolic = 'c'; // Character special
|
||||
}
|
||||
elseif (($perms & 0x1000) == 0x1000)
|
||||
{
|
||||
$symbolic = 'p'; // FIFO pipe
|
||||
}
|
||||
else
|
||||
{
|
||||
$symbolic = 'u'; // Unknown
|
||||
}
|
||||
|
||||
// Owner
|
||||
$symbolic .= (($perms & 0x0100) ? 'r' : '-');
|
||||
$symbolic .= (($perms & 0x0080) ? 'w' : '-');
|
||||
$symbolic .= (($perms & 0x0040) ? (($perms & 0x0800) ? 's' : 'x' ) : (($perms & 0x0800) ? 'S' : '-'));
|
||||
|
||||
// Group
|
||||
$symbolic .= (($perms & 0x0020) ? 'r' : '-');
|
||||
$symbolic .= (($perms & 0x0010) ? 'w' : '-');
|
||||
$symbolic .= (($perms & 0x0008) ? (($perms & 0x0400) ? 's' : 'x' ) : (($perms & 0x0400) ? 'S' : '-'));
|
||||
|
||||
// World
|
||||
$symbolic .= (($perms & 0x0004) ? 'r' : '-');
|
||||
$symbolic .= (($perms & 0x0002) ? 'w' : '-');
|
||||
$symbolic .= (($perms & 0x0001) ? (($perms & 0x0200) ? 't' : 'x' ) : (($perms & 0x0200) ? 'T' : '-'));
|
||||
|
||||
return $symbolic;
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Octal Permissions
|
||||
*
|
||||
* Takes a numeric value representing a file's permissions and returns
|
||||
* a three character string representing the file's octal permissions
|
||||
*
|
||||
* @access public
|
||||
* @param int
|
||||
* @return string
|
||||
*/
|
||||
if ( ! function_exists('octal_permissions'))
|
||||
{
|
||||
function octal_permissions($perms)
|
||||
{
|
||||
return substr(sprintf('%o', $perms), -3);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* End of file file_helper.php */
|
||||
/* Location: ./system/helpers/file_helper.php */
|
||||
1025
system/helpers/form_helper.php
Normal file
1025
system/helpers/form_helper.php
Normal file
File diff suppressed because it is too large
Load Diff
416
system/helpers/html_helper.php
Normal file
416
system/helpers/html_helper.php
Normal file
@@ -0,0 +1,416 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP 4.3.2 or newer
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2010, EllisLab, Inc.
|
||||
* @license http://codeigniter.com/user_guide/license.html
|
||||
* @link http://codeigniter.com
|
||||
* @since Version 1.0
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* CodeIgniter HTML Helpers
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @subpackage Helpers
|
||||
* @category Helpers
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @link http://codeigniter.com/user_guide/helpers/html_helper.html
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Heading
|
||||
*
|
||||
* Generates an HTML heading tag. First param is the data.
|
||||
* Second param is the size of the heading tag.
|
||||
*
|
||||
* @access public
|
||||
* @param string
|
||||
* @param integer
|
||||
* @return string
|
||||
*/
|
||||
if ( ! function_exists('heading'))
|
||||
{
|
||||
function heading($data = '', $h = '1')
|
||||
{
|
||||
return "<h".$h.">".$data."</h".$h.">";
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Unordered List
|
||||
*
|
||||
* Generates an HTML unordered list from an single or multi-dimensional array.
|
||||
*
|
||||
* @access public
|
||||
* @param array
|
||||
* @param mixed
|
||||
* @return string
|
||||
*/
|
||||
if ( ! function_exists('ul'))
|
||||
{
|
||||
function ul($list, $attributes = '')
|
||||
{
|
||||
return _list('ul', $list, $attributes);
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Ordered List
|
||||
*
|
||||
* Generates an HTML ordered list from an single or multi-dimensional array.
|
||||
*
|
||||
* @access public
|
||||
* @param array
|
||||
* @param mixed
|
||||
* @return string
|
||||
*/
|
||||
if ( ! function_exists('ol'))
|
||||
{
|
||||
function ol($list, $attributes = '')
|
||||
{
|
||||
return _list('ol', $list, $attributes);
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Generates the list
|
||||
*
|
||||
* Generates an HTML ordered list from an single or multi-dimensional array.
|
||||
*
|
||||
* @access private
|
||||
* @param string
|
||||
* @param mixed
|
||||
* @param mixed
|
||||
* @param intiger
|
||||
* @return string
|
||||
*/
|
||||
if ( ! function_exists('_list'))
|
||||
{
|
||||
function _list($type = 'ul', $list, $attributes = '', $depth = 0)
|
||||
{
|
||||
// If an array wasn't submitted there's nothing to do...
|
||||
if ( ! is_array($list))
|
||||
{
|
||||
return $list;
|
||||
}
|
||||
|
||||
// Set the indentation based on the depth
|
||||
$out = str_repeat(" ", $depth);
|
||||
|
||||
// Were any attributes submitted? If so generate a string
|
||||
if (is_array($attributes))
|
||||
{
|
||||
$atts = '';
|
||||
foreach ($attributes as $key => $val)
|
||||
{
|
||||
$atts .= ' ' . $key . '="' . $val . '"';
|
||||
}
|
||||
$attributes = $atts;
|
||||
}
|
||||
|
||||
// Write the opening list tag
|
||||
$out .= "<".$type.$attributes.">\n";
|
||||
|
||||
// Cycle through the list elements. If an array is
|
||||
// encountered we will recursively call _list()
|
||||
|
||||
static $_last_list_item = '';
|
||||
foreach ($list as $key => $val)
|
||||
{
|
||||
$_last_list_item = $key;
|
||||
|
||||
$out .= str_repeat(" ", $depth + 2);
|
||||
$out .= "<li>";
|
||||
|
||||
if ( ! is_array($val))
|
||||
{
|
||||
$out .= $val;
|
||||
}
|
||||
else
|
||||
{
|
||||
$out .= $_last_list_item."\n";
|
||||
$out .= _list($type, $val, '', $depth + 4);
|
||||
$out .= str_repeat(" ", $depth + 2);
|
||||
}
|
||||
|
||||
$out .= "</li>\n";
|
||||
}
|
||||
|
||||
// Set the indentation for the closing tag
|
||||
$out .= str_repeat(" ", $depth);
|
||||
|
||||
// Write the closing list tag
|
||||
$out .= "</".$type.">\n";
|
||||
|
||||
return $out;
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Generates HTML BR tags based on number supplied
|
||||
*
|
||||
* @access public
|
||||
* @param integer
|
||||
* @return string
|
||||
*/
|
||||
if ( ! function_exists('br'))
|
||||
{
|
||||
function br($num = 1)
|
||||
{
|
||||
return str_repeat("<br />", $num);
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Image
|
||||
*
|
||||
* Generates an <img /> element
|
||||
*
|
||||
* @access public
|
||||
* @param mixed
|
||||
* @return string
|
||||
*/
|
||||
if ( ! function_exists('img'))
|
||||
{
|
||||
function img($src = '', $index_page = FALSE)
|
||||
{
|
||||
if ( ! is_array($src) )
|
||||
{
|
||||
$src = array('src' => $src);
|
||||
}
|
||||
|
||||
$img = '<img';
|
||||
|
||||
foreach ($src as $k=>$v)
|
||||
{
|
||||
|
||||
if ($k == 'src' AND strpos($v, '://') === FALSE)
|
||||
{
|
||||
$CI =& get_instance();
|
||||
|
||||
if ($index_page === TRUE)
|
||||
{
|
||||
$img .= ' src="'.$CI->config->site_url($v).'" ';
|
||||
}
|
||||
else
|
||||
{
|
||||
$img .= ' src="'.$CI->config->slash_item('base_url').$v.'" ';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$img .= " $k=\"$v\" ";
|
||||
}
|
||||
}
|
||||
|
||||
$img .= '/>';
|
||||
|
||||
return $img;
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Doctype
|
||||
*
|
||||
* Generates a page document type declaration
|
||||
*
|
||||
* Valid options are xhtml-11, xhtml-strict, xhtml-trans, xhtml-frame,
|
||||
* html4-strict, html4-trans, and html4-frame. Values are saved in the
|
||||
* doctypes config file.
|
||||
*
|
||||
* @access public
|
||||
* @param string type The doctype to be generated
|
||||
* @return string
|
||||
*/
|
||||
if ( ! function_exists('doctype'))
|
||||
{
|
||||
function doctype($type = 'xhtml1-strict')
|
||||
{
|
||||
global $_doctypes;
|
||||
|
||||
if ( ! is_array($_doctypes))
|
||||
{
|
||||
if ( ! require_once(APPPATH.'config/doctypes.php'))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_doctypes[$type]))
|
||||
{
|
||||
return $_doctypes[$type];
|
||||
}
|
||||
else
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Link
|
||||
*
|
||||
* Generates link to a CSS file
|
||||
*
|
||||
* @access public
|
||||
* @param mixed stylesheet hrefs or an array
|
||||
* @param string rel
|
||||
* @param string type
|
||||
* @param string title
|
||||
* @param string media
|
||||
* @param boolean should index_page be added to the css path
|
||||
* @return string
|
||||
*/
|
||||
if ( ! function_exists('link_tag'))
|
||||
{
|
||||
function link_tag($href = '', $rel = 'stylesheet', $type = 'text/css', $title = '', $media = '', $index_page = FALSE)
|
||||
{
|
||||
$CI =& get_instance();
|
||||
|
||||
$link = '<link ';
|
||||
|
||||
if (is_array($href))
|
||||
{
|
||||
foreach ($href as $k=>$v)
|
||||
{
|
||||
if ($k == 'href' AND strpos($v, '://') === FALSE)
|
||||
{
|
||||
if ($index_page === TRUE)
|
||||
{
|
||||
$link .= ' href="'.$CI->config->site_url($v).'" ';
|
||||
}
|
||||
else
|
||||
{
|
||||
$link .= ' href="'.$CI->config->slash_item('base_url').$v.'" ';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$link .= "$k=\"$v\" ";
|
||||
}
|
||||
}
|
||||
|
||||
$link .= "/>";
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( strpos($href, '://') !== FALSE)
|
||||
{
|
||||
$link .= ' href="'.$href.'" ';
|
||||
}
|
||||
elseif ($index_page === TRUE)
|
||||
{
|
||||
$link .= ' href="'.$CI->config->site_url($href).'" ';
|
||||
}
|
||||
else
|
||||
{
|
||||
$link .= ' href="'.$CI->config->slash_item('base_url').$href.'" ';
|
||||
}
|
||||
|
||||
$link .= 'rel="'.$rel.'" type="'.$type.'" ';
|
||||
|
||||
if ($media != '')
|
||||
{
|
||||
$link .= 'media="'.$media.'" ';
|
||||
}
|
||||
|
||||
if ($title != '')
|
||||
{
|
||||
$link .= 'title="'.$title.'" ';
|
||||
}
|
||||
|
||||
$link .= '/>';
|
||||
}
|
||||
|
||||
|
||||
return $link;
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Generates meta tags from an array of key/values
|
||||
*
|
||||
* @access public
|
||||
* @param array
|
||||
* @return string
|
||||
*/
|
||||
if ( ! function_exists('meta'))
|
||||
{
|
||||
function meta($name = '', $content = '', $type = 'name', $newline = "\n")
|
||||
{
|
||||
// Since we allow the data to be passes as a string, a simple array
|
||||
// or a multidimensional one, we need to do a little prepping.
|
||||
if ( ! is_array($name))
|
||||
{
|
||||
$name = array(array('name' => $name, 'content' => $content, 'type' => $type, 'newline' => $newline));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Turn single array into multidimensional
|
||||
if (isset($name['name']))
|
||||
{
|
||||
$name = array($name);
|
||||
}
|
||||
}
|
||||
|
||||
$str = '';
|
||||
foreach ($name as $meta)
|
||||
{
|
||||
$type = ( ! isset($meta['type']) OR $meta['type'] == 'name') ? 'name' : 'http-equiv';
|
||||
$name = ( ! isset($meta['name'])) ? '' : $meta['name'];
|
||||
$content = ( ! isset($meta['content'])) ? '' : $meta['content'];
|
||||
$newline = ( ! isset($meta['newline'])) ? "\n" : $meta['newline'];
|
||||
|
||||
$str .= '<meta '.$type.'="'.$name.'" content="'.$content.'" />'.$newline;
|
||||
}
|
||||
|
||||
return $str;
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Generates non-breaking space entities based on number supplied
|
||||
*
|
||||
* @access public
|
||||
* @param integer
|
||||
* @return string
|
||||
*/
|
||||
if ( ! function_exists('nbs'))
|
||||
{
|
||||
function nbs($num = 1)
|
||||
{
|
||||
return str_repeat(" ", $num);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* End of file html_helper.php */
|
||||
/* Location: ./system/helpers/html_helper.php */
|
||||
10
system/helpers/index.html
Normal file
10
system/helpers/index.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
171
system/helpers/inflector_helper.php
Normal file
171
system/helpers/inflector_helper.php
Normal file
@@ -0,0 +1,171 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP 4.3.2 or newer
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2010, EllisLab, Inc.
|
||||
* @license http://codeigniter.com/user_guide/license.html
|
||||
* @link http://codeigniter.com
|
||||
* @since Version 1.0
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* CodeIgniter Inflector Helpers
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @subpackage Helpers
|
||||
* @category Helpers
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @link http://codeigniter.com/user_guide/helpers/directory_helper.html
|
||||
*/
|
||||
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Singular
|
||||
*
|
||||
* Takes a plural word and makes it singular
|
||||
*
|
||||
* @access public
|
||||
* @param string
|
||||
* @return str
|
||||
*/
|
||||
if ( ! function_exists('singular'))
|
||||
{
|
||||
function singular($str)
|
||||
{
|
||||
$str = strtolower(trim($str));
|
||||
$end = substr($str, -3);
|
||||
|
||||
if ($end == 'ies')
|
||||
{
|
||||
$str = substr($str, 0, strlen($str)-3).'y';
|
||||
}
|
||||
elseif ($end == 'ses')
|
||||
{
|
||||
$str = substr($str, 0, strlen($str)-2);
|
||||
}
|
||||
else
|
||||
{
|
||||
$end = substr($str, -1);
|
||||
|
||||
if ($end == 's')
|
||||
{
|
||||
$str = substr($str, 0, strlen($str)-1);
|
||||
}
|
||||
}
|
||||
|
||||
return $str;
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Plural
|
||||
*
|
||||
* Takes a singular word and makes it plural
|
||||
*
|
||||
* @access public
|
||||
* @param string
|
||||
* @param bool
|
||||
* @return str
|
||||
*/
|
||||
if ( ! function_exists('plural'))
|
||||
{
|
||||
function plural($str, $force = FALSE)
|
||||
{
|
||||
$str = strtolower(trim($str));
|
||||
$end = substr($str, -1);
|
||||
|
||||
if ($end == 'y')
|
||||
{
|
||||
// Y preceded by vowel => regular plural
|
||||
$vowels = array('a', 'e', 'i', 'o', 'u');
|
||||
$str = in_array(substr($str, -2, 1), $vowels) ? $str.'s' : substr($str, 0, -1).'ies';
|
||||
}
|
||||
elseif ($end == 's')
|
||||
{
|
||||
if ($force == TRUE)
|
||||
{
|
||||
$str .= 'es';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$str .= 's';
|
||||
}
|
||||
|
||||
return $str;
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Camelize
|
||||
*
|
||||
* Takes multiple words separated by spaces or underscores and camelizes them
|
||||
*
|
||||
* @access public
|
||||
* @param string
|
||||
* @return str
|
||||
*/
|
||||
if ( ! function_exists('camelize'))
|
||||
{
|
||||
function camelize($str)
|
||||
{
|
||||
$str = 'x'.strtolower(trim($str));
|
||||
$str = ucwords(preg_replace('/[\s_]+/', ' ', $str));
|
||||
return substr(str_replace(' ', '', $str), 1);
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Underscore
|
||||
*
|
||||
* Takes multiple words separated by spaces and underscores them
|
||||
*
|
||||
* @access public
|
||||
* @param string
|
||||
* @return str
|
||||
*/
|
||||
if ( ! function_exists('underscore'))
|
||||
{
|
||||
function underscore($str)
|
||||
{
|
||||
return preg_replace('/[\s]+/', '_', strtolower(trim($str)));
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Humanize
|
||||
*
|
||||
* Takes multiple words separated by underscores and changes them to spaces
|
||||
*
|
||||
* @access public
|
||||
* @param string
|
||||
* @return str
|
||||
*/
|
||||
if ( ! function_exists('humanize'))
|
||||
{
|
||||
function humanize($str)
|
||||
{
|
||||
return ucwords(preg_replace('/[_]+/', ' ', strtolower(trim($str))));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* End of file inflector_helper.php */
|
||||
/* Location: ./system/helpers/inflector_helper.php */
|
||||
58
system/helpers/language_helper.php
Normal file
58
system/helpers/language_helper.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP 4.3.2 or newer
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2010, EllisLab, Inc.
|
||||
* @license http://codeigniter.com/user_guide/license.html
|
||||
* @link http://codeigniter.com
|
||||
* @since Version 1.0
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* CodeIgniter Language Helpers
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @subpackage Helpers
|
||||
* @category Helpers
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @link http://codeigniter.com/user_guide/helpers/language_helper.html
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Lang
|
||||
*
|
||||
* Fetches a language variable and optionally outputs a form label
|
||||
*
|
||||
* @access public
|
||||
* @param string the language line
|
||||
* @param string the id of the form element
|
||||
* @return string
|
||||
*/
|
||||
if ( ! function_exists('lang'))
|
||||
{
|
||||
function lang($line, $id = '')
|
||||
{
|
||||
$CI =& get_instance();
|
||||
$line = $CI->lang->line($line);
|
||||
|
||||
if ($id != '')
|
||||
{
|
||||
$line = '<label for="'.$id.'">'.$line."</label>";
|
||||
}
|
||||
|
||||
return $line;
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/* End of file language_helper.php */
|
||||
/* Location: ./system/helpers/language_helper.php */
|
||||
75
system/helpers/number_helper.php
Normal file
75
system/helpers/number_helper.php
Normal file
@@ -0,0 +1,75 @@
|
||||
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP 4.3.2 or newer
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2010, EllisLab, Inc.
|
||||
* @license http://codeigniter.com/user_guide/license.html
|
||||
* @link http://codeigniter.com
|
||||
* @since Version 1.0
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* CodeIgniter Number Helpers
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @subpackage Helpers
|
||||
* @category Helpers
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @link http://codeigniter.com/user_guide/helpers/number_helper.html
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Formats a numbers as bytes, based on size, and adds the appropriate suffix
|
||||
*
|
||||
* @access public
|
||||
* @param mixed // will be cast as int
|
||||
* @return string
|
||||
*/
|
||||
if ( ! function_exists('byte_format'))
|
||||
{
|
||||
function byte_format($num)
|
||||
{
|
||||
$CI =& get_instance();
|
||||
$CI->lang->load('number');
|
||||
|
||||
if ($num >= 1000000000000)
|
||||
{
|
||||
$num = round($num / 1099511627776, 1);
|
||||
$unit = $CI->lang->line('terabyte_abbr');
|
||||
}
|
||||
elseif ($num >= 1000000000)
|
||||
{
|
||||
$num = round($num / 1073741824, 1);
|
||||
$unit = $CI->lang->line('gigabyte_abbr');
|
||||
}
|
||||
elseif ($num >= 1000000)
|
||||
{
|
||||
$num = round($num / 1048576, 1);
|
||||
$unit = $CI->lang->line('megabyte_abbr');
|
||||
}
|
||||
elseif ($num >= 1000)
|
||||
{
|
||||
$num = round($num / 1024, 1);
|
||||
$unit = $CI->lang->line('kilobyte_abbr');
|
||||
}
|
||||
else
|
||||
{
|
||||
$unit = $CI->lang->line('bytes');
|
||||
return number_format($num).' '.$unit;
|
||||
}
|
||||
|
||||
return number_format($num, 1).' '.$unit;
|
||||
}
|
||||
}
|
||||
|
||||
/* End of file number_helper.php */
|
||||
/* Location: ./system/helpers/number_helper.php */
|
||||
72
system/helpers/path_helper.php
Normal file
72
system/helpers/path_helper.php
Normal file
@@ -0,0 +1,72 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP 4.3.2 or newer
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2010, EllisLab, Inc.
|
||||
* @license http://codeigniter.com/user_guide/license.html
|
||||
* @link http://codeigniter.com
|
||||
* @since Version 1.0
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* CodeIgniter Path Helpers
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @subpackage Helpers
|
||||
* @category Helpers
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @link http://codeigniter.com/user_guide/helpers/xml_helper.html
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Set Realpath
|
||||
*
|
||||
* @access public
|
||||
* @param string
|
||||
* @param bool checks to see if the path exists
|
||||
* @return string
|
||||
*/
|
||||
if ( ! function_exists('set_realpath'))
|
||||
{
|
||||
function set_realpath($path, $check_existance = FALSE)
|
||||
{
|
||||
// Security check to make sure the path is NOT a URL. No remote file inclusion!
|
||||
if (preg_match("#^(http:\/\/|https:\/\/|www\.|ftp|[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})#i", $path))
|
||||
{
|
||||
show_error('The path you submitted must be a local server path, not a URL');
|
||||
}
|
||||
|
||||
// Resolve the path
|
||||
if (function_exists('realpath') AND @realpath($path) !== FALSE)
|
||||
{
|
||||
$path = realpath($path).'/';
|
||||
}
|
||||
|
||||
// Add a trailing slash
|
||||
$path = preg_replace("#([^/])/*$#", "\\1/", $path);
|
||||
|
||||
// Make sure the path exists
|
||||
if ($check_existance == TRUE)
|
||||
{
|
||||
if ( ! is_dir($path))
|
||||
{
|
||||
show_error('Not a valid path: '.$path);
|
||||
}
|
||||
}
|
||||
|
||||
return $path;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* End of file path_helper.php */
|
||||
/* Location: ./system/helpers/path_helper.php */
|
||||
126
system/helpers/security_helper.php
Normal file
126
system/helpers/security_helper.php
Normal file
@@ -0,0 +1,126 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP 4.3.2 or newer
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2010, EllisLab, Inc.
|
||||
* @license http://codeigniter.com/user_guide/license.html
|
||||
* @link http://codeigniter.com
|
||||
* @since Version 1.0
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* CodeIgniter Security Helpers
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @subpackage Helpers
|
||||
* @category Helpers
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @link http://codeigniter.com/user_guide/helpers/security_helper.html
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* XSS Filtering
|
||||
*
|
||||
* @access public
|
||||
* @param string
|
||||
* @param bool whether or not the content is an image file
|
||||
* @return string
|
||||
*/
|
||||
if ( ! function_exists('xss_clean'))
|
||||
{
|
||||
function xss_clean($str, $is_image = FALSE)
|
||||
{
|
||||
$CI =& get_instance();
|
||||
return $CI->input->xss_clean($str, $is_image);
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Hash encode a string
|
||||
*
|
||||
* @access public
|
||||
* @param string
|
||||
* @return string
|
||||
*/
|
||||
if ( ! function_exists('dohash'))
|
||||
{
|
||||
function dohash($str, $type = 'sha1')
|
||||
{
|
||||
if ($type == 'sha1')
|
||||
{
|
||||
if ( ! function_exists('sha1'))
|
||||
{
|
||||
if ( ! function_exists('mhash'))
|
||||
{
|
||||
require_once(BASEPATH.'libraries/Sha1'.EXT);
|
||||
$SH = new CI_SHA;
|
||||
return $SH->generate($str);
|
||||
}
|
||||
else
|
||||
{
|
||||
return bin2hex(mhash(MHASH_SHA1, $str));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return sha1($str);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return md5($str);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Strip Image Tags
|
||||
*
|
||||
* @access public
|
||||
* @param string
|
||||
* @return string
|
||||
*/
|
||||
if ( ! function_exists('strip_image_tags'))
|
||||
{
|
||||
function strip_image_tags($str)
|
||||
{
|
||||
$str = preg_replace("#<img\s+.*?src\s*=\s*[\"'](.+?)[\"'].*?\>#", "\\1", $str);
|
||||
$str = preg_replace("#<img\s+.*?src\s*=\s*(.+?).*?\>#", "\\1", $str);
|
||||
|
||||
return $str;
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Convert PHP tags to entities
|
||||
*
|
||||
* @access public
|
||||
* @param string
|
||||
* @return string
|
||||
*/
|
||||
if ( ! function_exists('encode_php_tags'))
|
||||
{
|
||||
function encode_php_tags($str)
|
||||
{
|
||||
return str_replace(array('<?php', '<?PHP', '<?', '?>'), array('<?php', '<?PHP', '<?', '?>'), $str);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* End of file security_helper.php */
|
||||
/* Location: ./system/helpers/security_helper.php */
|
||||
273
system/helpers/smiley_helper.php
Normal file
273
system/helpers/smiley_helper.php
Normal file
@@ -0,0 +1,273 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP 4.3.2 or newer
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2010, EllisLab, Inc.
|
||||
* @license http://codeigniter.com/user_guide/license.html
|
||||
* @link http://codeigniter.com
|
||||
* @since Version 1.0
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* CodeIgniter Smiley Helpers
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @subpackage Helpers
|
||||
* @category Helpers
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @link http://codeigniter.com/user_guide/helpers/smiley_helper.html
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Smiley Javascript
|
||||
*
|
||||
* Returns the javascript required for the smiley insertion. Optionally takes
|
||||
* an array of aliases to loosely couple the smiley array to the view.
|
||||
*
|
||||
* @access public
|
||||
* @param mixed alias name or array of alias->field_id pairs
|
||||
* @param string field_id if alias name was passed in
|
||||
* @return array
|
||||
*/
|
||||
if ( ! function_exists('smiley_js'))
|
||||
{
|
||||
function smiley_js($alias = '', $field_id = '')
|
||||
{
|
||||
static $do_setup = TRUE;
|
||||
|
||||
$r = '';
|
||||
|
||||
if ($alias != '' && ! is_array($alias))
|
||||
{
|
||||
$alias = array($alias => $field_id);
|
||||
}
|
||||
|
||||
if ($do_setup === TRUE)
|
||||
{
|
||||
$do_setup = FALSE;
|
||||
|
||||
$m = array();
|
||||
|
||||
if (is_array($alias))
|
||||
{
|
||||
foreach($alias as $name => $id)
|
||||
{
|
||||
$m[] = '"'.$name.'" : "'.$id.'"';
|
||||
}
|
||||
}
|
||||
|
||||
$m = '{'.implode(',', $m).'}';
|
||||
|
||||
$r .= <<<EOF
|
||||
|
||||
var smiley_map = {$m};
|
||||
|
||||
function insert_smiley(smiley, field_id) {
|
||||
var el = document.getElementById(field_id), newStart;
|
||||
|
||||
if ( ! el && smiley_map[field_id]) {
|
||||
el = document.getElementById(smiley_map[field_id]);
|
||||
|
||||
if ( ! el)
|
||||
return false;
|
||||
}
|
||||
|
||||
el.focus();
|
||||
smiley = " " + smiley;
|
||||
|
||||
if ('selectionStart' in el) {
|
||||
newStart = el.selectionStart + smiley.length;
|
||||
|
||||
el.value = el.value.substr(0, el.selectionStart) +
|
||||
smiley +
|
||||
el.value.substr(el.selectionEnd, el.value.length);
|
||||
el.setSelectionRange(newStart, newStart);
|
||||
}
|
||||
else if (document.selection) {
|
||||
document.selection.createRange().text = text;
|
||||
}
|
||||
}
|
||||
EOF;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (is_array($alias))
|
||||
{
|
||||
foreach($alias as $name => $id)
|
||||
{
|
||||
$r .= 'smiley_map["'.$name.'"] = "'.$id.'";'."\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return '<script type="text/javascript" charset="utf-8">'.$r.'</script>';
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Get Clickable Smileys
|
||||
*
|
||||
* Returns an array of image tag links that can be clicked to be inserted
|
||||
* into a form field.
|
||||
*
|
||||
* @access public
|
||||
* @param string the URL to the folder containing the smiley images
|
||||
* @return array
|
||||
*/
|
||||
if ( ! function_exists('get_clickable_smileys'))
|
||||
{
|
||||
function get_clickable_smileys($image_url, $alias = '', $smileys = NULL)
|
||||
{
|
||||
// For backward compatibility with js_insert_smiley
|
||||
|
||||
if (is_array($alias))
|
||||
{
|
||||
$smileys = $alias;
|
||||
}
|
||||
|
||||
if ( ! is_array($smileys))
|
||||
{
|
||||
if (FALSE === ($smileys = _get_smiley_array()))
|
||||
{
|
||||
return $smileys;
|
||||
}
|
||||
}
|
||||
|
||||
// Add a trailing slash to the file path if needed
|
||||
$image_url = rtrim($image_url, '/').'/';
|
||||
|
||||
$used = array();
|
||||
foreach ($smileys as $key => $val)
|
||||
{
|
||||
// Keep duplicates from being used, which can happen if the
|
||||
// mapping array contains multiple identical replacements. For example:
|
||||
// :-) and :) might be replaced with the same image so both smileys
|
||||
// will be in the array.
|
||||
if (isset($used[$smileys[$key][0]]))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$link[] = "<a href=\"javascript:void(0);\" onClick=\"insert_smiley('".$key."', '".$alias."')\"><img src=\"".$image_url.$smileys[$key][0]."\" width=\"".$smileys[$key][1]."\" height=\"".$smileys[$key][2]."\" alt=\"".$smileys[$key][3]."\" style=\"border:0;\" /></a>";
|
||||
|
||||
$used[$smileys[$key][0]] = TRUE;
|
||||
}
|
||||
|
||||
return $link;
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Parse Smileys
|
||||
*
|
||||
* Takes a string as input and swaps any contained smileys for the actual image
|
||||
*
|
||||
* @access public
|
||||
* @param string the text to be parsed
|
||||
* @param string the URL to the folder containing the smiley images
|
||||
* @return string
|
||||
*/
|
||||
if ( ! function_exists('parse_smileys'))
|
||||
{
|
||||
function parse_smileys($str = '', $image_url = '', $smileys = NULL)
|
||||
{
|
||||
if ($image_url == '')
|
||||
{
|
||||
return $str;
|
||||
}
|
||||
|
||||
if ( ! is_array($smileys))
|
||||
{
|
||||
if (FALSE === ($smileys = _get_smiley_array()))
|
||||
{
|
||||
return $str;
|
||||
}
|
||||
}
|
||||
|
||||
// Add a trailing slash to the file path if needed
|
||||
$image_url = preg_replace("/(.+?)\/*$/", "\\1/", $image_url);
|
||||
|
||||
foreach ($smileys as $key => $val)
|
||||
{
|
||||
$str = str_replace($key, "<img src=\"".$image_url.$smileys[$key][0]."\" width=\"".$smileys[$key][1]."\" height=\"".$smileys[$key][2]."\" alt=\"".$smileys[$key][3]."\" style=\"border:0;\" />", $str);
|
||||
}
|
||||
|
||||
return $str;
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Get Smiley Array
|
||||
*
|
||||
* Fetches the config/smiley.php file
|
||||
*
|
||||
* @access private
|
||||
* @return mixed
|
||||
*/
|
||||
if ( ! function_exists('_get_smiley_array'))
|
||||
{
|
||||
function _get_smiley_array()
|
||||
{
|
||||
if ( ! file_exists(APPPATH.'config/smileys'.EXT))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
include(APPPATH.'config/smileys'.EXT);
|
||||
|
||||
if ( ! isset($smileys) OR ! is_array($smileys))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return $smileys;
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* JS Insert Smiley
|
||||
*
|
||||
* Generates the javascript function needed to insert smileys into a form field
|
||||
*
|
||||
* DEPRECATED as of version 1.7.2, use smiley_js instead
|
||||
*
|
||||
* @access public
|
||||
* @param string form name
|
||||
* @param string field name
|
||||
* @return string
|
||||
*/
|
||||
if ( ! function_exists('js_insert_smiley'))
|
||||
{
|
||||
function js_insert_smiley($form_name = '', $form_field = '')
|
||||
{
|
||||
return <<<EOF
|
||||
<script type="text/javascript">
|
||||
function insert_smiley(smiley)
|
||||
{
|
||||
document.{$form_name}.{$form_field}.value += " " + smiley;
|
||||
}
|
||||
</script>
|
||||
EOF;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* End of file smiley_helper.php */
|
||||
/* Location: ./system/helpers/smiley_helper.php */
|
||||
273
system/helpers/string_helper.php
Normal file
273
system/helpers/string_helper.php
Normal file
@@ -0,0 +1,273 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP 4.3.2 or newer
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2010, EllisLab, Inc.
|
||||
* @license http://codeigniter.com/user_guide/license.html
|
||||
* @link http://codeigniter.com
|
||||
* @since Version 1.0
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* CodeIgniter String Helpers
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @subpackage Helpers
|
||||
* @category Helpers
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @link http://codeigniter.com/user_guide/helpers/string_helper.html
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Trim Slashes
|
||||
*
|
||||
* Removes any leading/traling slashes from a string:
|
||||
*
|
||||
* /this/that/theother/
|
||||
*
|
||||
* becomes:
|
||||
*
|
||||
* this/that/theother
|
||||
*
|
||||
* @access public
|
||||
* @param string
|
||||
* @return string
|
||||
*/
|
||||
if ( ! function_exists('trim_slashes'))
|
||||
{
|
||||
function trim_slashes($str)
|
||||
{
|
||||
return trim($str, '/');
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Strip Slashes
|
||||
*
|
||||
* Removes slashes contained in a string or in an array
|
||||
*
|
||||
* @access public
|
||||
* @param mixed string or array
|
||||
* @return mixed string or array
|
||||
*/
|
||||
if ( ! function_exists('strip_slashes'))
|
||||
{
|
||||
function strip_slashes($str)
|
||||
{
|
||||
if (is_array($str))
|
||||
{
|
||||
foreach ($str as $key => $val)
|
||||
{
|
||||
$str[$key] = strip_slashes($val);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$str = stripslashes($str);
|
||||
}
|
||||
|
||||
return $str;
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Strip Quotes
|
||||
*
|
||||
* Removes single and double quotes from a string
|
||||
*
|
||||
* @access public
|
||||
* @param string
|
||||
* @return string
|
||||
*/
|
||||
if ( ! function_exists('strip_quotes'))
|
||||
{
|
||||
function strip_quotes($str)
|
||||
{
|
||||
return str_replace(array('"', "'"), '', $str);
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Quotes to Entities
|
||||
*
|
||||
* Converts single and double quotes to entities
|
||||
*
|
||||
* @access public
|
||||
* @param string
|
||||
* @return string
|
||||
*/
|
||||
if ( ! function_exists('quotes_to_entities'))
|
||||
{
|
||||
function quotes_to_entities($str)
|
||||
{
|
||||
return str_replace(array("\'","\"","'",'"'), array("'",""","'","""), $str);
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/**
|
||||
* Reduce Double Slashes
|
||||
*
|
||||
* Converts double slashes in a string to a single slash,
|
||||
* except those found in http://
|
||||
*
|
||||
* http://www.some-site.com//index.php
|
||||
*
|
||||
* becomes:
|
||||
*
|
||||
* http://www.some-site.com/index.php
|
||||
*
|
||||
* @access public
|
||||
* @param string
|
||||
* @return string
|
||||
*/
|
||||
if ( ! function_exists('reduce_double_slashes'))
|
||||
{
|
||||
function reduce_double_slashes($str)
|
||||
{
|
||||
return preg_replace("#([^:])//+#", "\\1/", $str);
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Reduce Multiples
|
||||
*
|
||||
* Reduces multiple instances of a particular character. Example:
|
||||
*
|
||||
* Fred, Bill,, Joe, Jimmy
|
||||
*
|
||||
* becomes:
|
||||
*
|
||||
* Fred, Bill, Joe, Jimmy
|
||||
*
|
||||
* @access public
|
||||
* @param string
|
||||
* @param string the character you wish to reduce
|
||||
* @param bool TRUE/FALSE - whether to trim the character from the beginning/end
|
||||
* @return string
|
||||
*/
|
||||
if ( ! function_exists('reduce_multiples'))
|
||||
{
|
||||
function reduce_multiples($str, $character = ',', $trim = FALSE)
|
||||
{
|
||||
$str = preg_replace('#'.preg_quote($character, '#').'{2,}#', $character, $str);
|
||||
|
||||
if ($trim === TRUE)
|
||||
{
|
||||
$str = trim($str, $character);
|
||||
}
|
||||
|
||||
return $str;
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Create a Random String
|
||||
*
|
||||
* Useful for generating passwords or hashes.
|
||||
*
|
||||
* @access public
|
||||
* @param string type of random string. Options: alunum, numeric, nozero, unique
|
||||
* @param integer number of characters
|
||||
* @return string
|
||||
*/
|
||||
if ( ! function_exists('random_string'))
|
||||
{
|
||||
function random_string($type = 'alnum', $len = 8)
|
||||
{
|
||||
switch($type)
|
||||
{
|
||||
case 'alnum' :
|
||||
case 'numeric' :
|
||||
case 'nozero' :
|
||||
|
||||
switch ($type)
|
||||
{
|
||||
case 'alnum' : $pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||||
break;
|
||||
case 'numeric' : $pool = '0123456789';
|
||||
break;
|
||||
case 'nozero' : $pool = '123456789';
|
||||
break;
|
||||
}
|
||||
|
||||
$str = '';
|
||||
for ($i=0; $i < $len; $i++)
|
||||
{
|
||||
$str .= substr($pool, mt_rand(0, strlen($pool) -1), 1);
|
||||
}
|
||||
return $str;
|
||||
break;
|
||||
case 'unique' : return md5(uniqid(mt_rand()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Alternator
|
||||
*
|
||||
* Allows strings to be alternated. See docs...
|
||||
*
|
||||
* @access public
|
||||
* @param string (as many parameters as needed)
|
||||
* @return string
|
||||
*/
|
||||
if ( ! function_exists('alternator'))
|
||||
{
|
||||
function alternator()
|
||||
{
|
||||
static $i;
|
||||
|
||||
if (func_num_args() == 0)
|
||||
{
|
||||
$i = 0;
|
||||
return '';
|
||||
}
|
||||
$args = func_get_args();
|
||||
return $args[($i++ % count($args))];
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Repeater function
|
||||
*
|
||||
* @access public
|
||||
* @param string
|
||||
* @param integer number of repeats
|
||||
* @return string
|
||||
*/
|
||||
if ( ! function_exists('repeater'))
|
||||
{
|
||||
function repeater($data, $num = 1)
|
||||
{
|
||||
return (($num > 0) ? str_repeat($data, $num) : '');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* End of file string_helper.php */
|
||||
/* Location: ./system/helpers/string_helper.php */
|
||||
462
system/helpers/text_helper.php
Normal file
462
system/helpers/text_helper.php
Normal file
@@ -0,0 +1,462 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP 4.3.2 or newer
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2010, EllisLab, Inc.
|
||||
* @license http://codeigniter.com/user_guide/license.html
|
||||
* @link http://codeigniter.com
|
||||
* @since Version 1.0
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* CodeIgniter Text Helpers
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @subpackage Helpers
|
||||
* @category Helpers
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @link http://codeigniter.com/user_guide/helpers/text_helper.html
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Word Limiter
|
||||
*
|
||||
* Limits a string to X number of words.
|
||||
*
|
||||
* @access public
|
||||
* @param string
|
||||
* @param integer
|
||||
* @param string the end character. Usually an ellipsis
|
||||
* @return string
|
||||
*/
|
||||
if ( ! function_exists('word_limiter'))
|
||||
{
|
||||
function word_limiter($str, $limit = 100, $end_char = '…')
|
||||
{
|
||||
if (trim($str) == '')
|
||||
{
|
||||
return $str;
|
||||
}
|
||||
|
||||
preg_match('/^\s*+(?:\S++\s*+){1,'.(int) $limit.'}/', $str, $matches);
|
||||
|
||||
if (strlen($str) == strlen($matches[0]))
|
||||
{
|
||||
$end_char = '';
|
||||
}
|
||||
|
||||
return rtrim($matches[0]).$end_char;
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Character Limiter
|
||||
*
|
||||
* Limits the string based on the character count. Preserves complete words
|
||||
* so the character count may not be exactly as specified.
|
||||
*
|
||||
* @access public
|
||||
* @param string
|
||||
* @param integer
|
||||
* @param string the end character. Usually an ellipsis
|
||||
* @return string
|
||||
*/
|
||||
if ( ! function_exists('character_limiter'))
|
||||
{
|
||||
function character_limiter($str, $n = 500, $end_char = '…')
|
||||
{
|
||||
if (strlen($str) < $n)
|
||||
{
|
||||
return $str;
|
||||
}
|
||||
|
||||
$str = preg_replace("/\s+/", ' ', str_replace(array("\r\n", "\r", "\n"), ' ', $str));
|
||||
|
||||
if (strlen($str) <= $n)
|
||||
{
|
||||
return $str;
|
||||
}
|
||||
|
||||
$out = "";
|
||||
foreach (explode(' ', trim($str)) as $val)
|
||||
{
|
||||
$out .= $val.' ';
|
||||
|
||||
if (strlen($out) >= $n)
|
||||
{
|
||||
$out = trim($out);
|
||||
return (strlen($out) == strlen($str)) ? $out : $out.$end_char;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* High ASCII to Entities
|
||||
*
|
||||
* Converts High ascii text and MS Word special characters to character entities
|
||||
*
|
||||
* @access public
|
||||
* @param string
|
||||
* @return string
|
||||
*/
|
||||
if ( ! function_exists('ascii_to_entities'))
|
||||
{
|
||||
function ascii_to_entities($str)
|
||||
{
|
||||
$count = 1;
|
||||
$out = '';
|
||||
$temp = array();
|
||||
|
||||
for ($i = 0, $s = strlen($str); $i < $s; $i++)
|
||||
{
|
||||
$ordinal = ord($str[$i]);
|
||||
|
||||
if ($ordinal < 128)
|
||||
{
|
||||
/*
|
||||
If the $temp array has a value but we have moved on, then it seems only
|
||||
fair that we output that entity and restart $temp before continuing. -Paul
|
||||
*/
|
||||
if (count($temp) == 1)
|
||||
{
|
||||
$out .= '&#'.array_shift($temp).';';
|
||||
$count = 1;
|
||||
}
|
||||
|
||||
$out .= $str[$i];
|
||||
}
|
||||
else
|
||||
{
|
||||
if (count($temp) == 0)
|
||||
{
|
||||
$count = ($ordinal < 224) ? 2 : 3;
|
||||
}
|
||||
|
||||
$temp[] = $ordinal;
|
||||
|
||||
if (count($temp) == $count)
|
||||
{
|
||||
$number = ($count == 3) ? (($temp['0'] % 16) * 4096) + (($temp['1'] % 64) * 64) + ($temp['2'] % 64) : (($temp['0'] % 32) * 64) + ($temp['1'] % 64);
|
||||
|
||||
$out .= '&#'.$number.';';
|
||||
$count = 1;
|
||||
$temp = array();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $out;
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Entities to ASCII
|
||||
*
|
||||
* Converts character entities back to ASCII
|
||||
*
|
||||
* @access public
|
||||
* @param string
|
||||
* @param bool
|
||||
* @return string
|
||||
*/
|
||||
if ( ! function_exists('entities_to_ascii'))
|
||||
{
|
||||
function entities_to_ascii($str, $all = TRUE)
|
||||
{
|
||||
if (preg_match_all('/\&#(\d+)\;/', $str, $matches))
|
||||
{
|
||||
for ($i = 0, $s = count($matches['0']); $i < $s; $i++)
|
||||
{
|
||||
$digits = $matches['1'][$i];
|
||||
|
||||
$out = '';
|
||||
|
||||
if ($digits < 128)
|
||||
{
|
||||
$out .= chr($digits);
|
||||
|
||||
}
|
||||
elseif ($digits < 2048)
|
||||
{
|
||||
$out .= chr(192 + (($digits - ($digits % 64)) / 64));
|
||||
$out .= chr(128 + ($digits % 64));
|
||||
}
|
||||
else
|
||||
{
|
||||
$out .= chr(224 + (($digits - ($digits % 4096)) / 4096));
|
||||
$out .= chr(128 + ((($digits % 4096) - ($digits % 64)) / 64));
|
||||
$out .= chr(128 + ($digits % 64));
|
||||
}
|
||||
|
||||
$str = str_replace($matches['0'][$i], $out, $str);
|
||||
}
|
||||
}
|
||||
|
||||
if ($all)
|
||||
{
|
||||
$str = str_replace(array("&", "<", ">", """, "'", "-"),
|
||||
array("&","<",">","\"", "'", "-"),
|
||||
$str);
|
||||
}
|
||||
|
||||
return $str;
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Word Censoring Function
|
||||
*
|
||||
* Supply a string and an array of disallowed words and any
|
||||
* matched words will be converted to #### or to the replacement
|
||||
* word you've submitted.
|
||||
*
|
||||
* @access public
|
||||
* @param string the text string
|
||||
* @param string the array of censoered words
|
||||
* @param string the optional replacement value
|
||||
* @return string
|
||||
*/
|
||||
if ( ! function_exists('word_censor'))
|
||||
{
|
||||
function word_censor($str, $censored, $replacement = '')
|
||||
{
|
||||
if ( ! is_array($censored))
|
||||
{
|
||||
return $str;
|
||||
}
|
||||
|
||||
$str = ' '.$str.' ';
|
||||
|
||||
// \w, \b and a few others do not match on a unicode character
|
||||
// set for performance reasons. As a result words like über
|
||||
// will not match on a word boundary. Instead, we'll assume that
|
||||
// a bad word will be bookended by any of these characters.
|
||||
$delim = '[-_\'\"`(){}<>\[\]|!?@#%&,.:;^~*+=\/ 0-9\n\r\t]';
|
||||
|
||||
foreach ($censored as $badword)
|
||||
{
|
||||
if ($replacement != '')
|
||||
{
|
||||
$str = preg_replace("/({$delim})(".str_replace('\*', '\w*?', preg_quote($badword, '/')).")({$delim})/i", "\\1{$replacement}\\3", $str);
|
||||
}
|
||||
else
|
||||
{
|
||||
$str = preg_replace("/({$delim})(".str_replace('\*', '\w*?', preg_quote($badword, '/')).")({$delim})/ie", "'\\1'.str_repeat('#', strlen('\\2')).'\\3'", $str);
|
||||
}
|
||||
}
|
||||
|
||||
return trim($str);
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Code Highlighter
|
||||
*
|
||||
* Colorizes code strings
|
||||
*
|
||||
* @access public
|
||||
* @param string the text string
|
||||
* @return string
|
||||
*/
|
||||
if ( ! function_exists('highlight_code'))
|
||||
{
|
||||
function highlight_code($str)
|
||||
{
|
||||
// The highlight string function encodes and highlights
|
||||
// brackets so we need them to start raw
|
||||
$str = str_replace(array('<', '>'), array('<', '>'), $str);
|
||||
|
||||
// Replace any existing PHP tags to temporary markers so they don't accidentally
|
||||
// break the string out of PHP, and thus, thwart the highlighting.
|
||||
|
||||
$str = str_replace(array('<?', '?>', '<%', '%>', '\\', '</script>'),
|
||||
array('phptagopen', 'phptagclose', 'asptagopen', 'asptagclose', 'backslashtmp', 'scriptclose'), $str);
|
||||
|
||||
// The highlight_string function requires that the text be surrounded
|
||||
// by PHP tags, which we will remove later
|
||||
$str = '<?php '.$str.' ?>'; // <?
|
||||
|
||||
// All the magic happens here, baby!
|
||||
$str = highlight_string($str, TRUE);
|
||||
|
||||
// Prior to PHP 5, the highligh function used icky <font> tags
|
||||
// so we'll replace them with <span> tags.
|
||||
|
||||
if (abs(PHP_VERSION) < 5)
|
||||
{
|
||||
$str = str_replace(array('<font ', '</font>'), array('<span ', '</span>'), $str);
|
||||
$str = preg_replace('#color="(.*?)"#', 'style="color: \\1"', $str);
|
||||
}
|
||||
|
||||
// Remove our artificially added PHP, and the syntax highlighting that came with it
|
||||
$str = preg_replace('/<span style="color: #([A-Z0-9]+)"><\?php( | )/i', '<span style="color: #$1">', $str);
|
||||
$str = preg_replace('/(<span style="color: #[A-Z0-9]+">.*?)\?><\/span>\n<\/span>\n<\/code>/is', "$1</span>\n</span>\n</code>", $str);
|
||||
$str = preg_replace('/<span style="color: #[A-Z0-9]+"\><\/span>/i', '', $str);
|
||||
|
||||
// Replace our markers back to PHP tags.
|
||||
$str = str_replace(array('phptagopen', 'phptagclose', 'asptagopen', 'asptagclose', 'backslashtmp', 'scriptclose'),
|
||||
array('<?', '?>', '<%', '%>', '\\', '</script>'), $str);
|
||||
|
||||
return $str;
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Phrase Highlighter
|
||||
*
|
||||
* Highlights a phrase within a text string
|
||||
*
|
||||
* @access public
|
||||
* @param string the text string
|
||||
* @param string the phrase you'd like to highlight
|
||||
* @param string the openging tag to precede the phrase with
|
||||
* @param string the closing tag to end the phrase with
|
||||
* @return string
|
||||
*/
|
||||
if ( ! function_exists('highlight_phrase'))
|
||||
{
|
||||
function highlight_phrase($str, $phrase, $tag_open = '<strong>', $tag_close = '</strong>')
|
||||
{
|
||||
if ($str == '')
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
if ($phrase != '')
|
||||
{
|
||||
return preg_replace('/('.preg_quote($phrase, '/').')/i', $tag_open."\\1".$tag_close, $str);
|
||||
}
|
||||
|
||||
return $str;
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Word Wrap
|
||||
*
|
||||
* Wraps text at the specified character. Maintains the integrity of words.
|
||||
* Anything placed between {unwrap}{/unwrap} will not be word wrapped, nor
|
||||
* will URLs.
|
||||
*
|
||||
* @access public
|
||||
* @param string the text string
|
||||
* @param integer the number of characters to wrap at
|
||||
* @return string
|
||||
*/
|
||||
if ( ! function_exists('word_wrap'))
|
||||
{
|
||||
function word_wrap($str, $charlim = '76')
|
||||
{
|
||||
// Se the character limit
|
||||
if ( ! is_numeric($charlim))
|
||||
$charlim = 76;
|
||||
|
||||
// Reduce multiple spaces
|
||||
$str = preg_replace("| +|", " ", $str);
|
||||
|
||||
// Standardize newlines
|
||||
if (strpos($str, "\r") !== FALSE)
|
||||
{
|
||||
$str = str_replace(array("\r\n", "\r"), "\n", $str);
|
||||
}
|
||||
|
||||
// If the current word is surrounded by {unwrap} tags we'll
|
||||
// strip the entire chunk and replace it with a marker.
|
||||
$unwrap = array();
|
||||
if (preg_match_all("|(\{unwrap\}.+?\{/unwrap\})|s", $str, $matches))
|
||||
{
|
||||
for ($i = 0; $i < count($matches['0']); $i++)
|
||||
{
|
||||
$unwrap[] = $matches['1'][$i];
|
||||
$str = str_replace($matches['1'][$i], "{{unwrapped".$i."}}", $str);
|
||||
}
|
||||
}
|
||||
|
||||
// Use PHP's native function to do the initial wordwrap.
|
||||
// We set the cut flag to FALSE so that any individual words that are
|
||||
// too long get left alone. In the next step we'll deal with them.
|
||||
$str = wordwrap($str, $charlim, "\n", FALSE);
|
||||
|
||||
// Split the string into individual lines of text and cycle through them
|
||||
$output = "";
|
||||
foreach (explode("\n", $str) as $line)
|
||||
{
|
||||
// Is the line within the allowed character count?
|
||||
// If so we'll join it to the output and continue
|
||||
if (strlen($line) <= $charlim)
|
||||
{
|
||||
$output .= $line."\n";
|
||||
continue;
|
||||
}
|
||||
|
||||
$temp = '';
|
||||
while((strlen($line)) > $charlim)
|
||||
{
|
||||
// If the over-length word is a URL we won't wrap it
|
||||
if (preg_match("!\[url.+\]|://|wwww.!", $line))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
// Trim the word down
|
||||
$temp .= substr($line, 0, $charlim-1);
|
||||
$line = substr($line, $charlim-1);
|
||||
}
|
||||
|
||||
// If $temp contains data it means we had to split up an over-length
|
||||
// word into smaller chunks so we'll add it back to our current line
|
||||
if ($temp != '')
|
||||
{
|
||||
$output .= $temp . "\n" . $line;
|
||||
}
|
||||
else
|
||||
{
|
||||
$output .= $line;
|
||||
}
|
||||
|
||||
$output .= "\n";
|
||||
}
|
||||
|
||||
// Put our markers back
|
||||
if (count($unwrap) > 0)
|
||||
{
|
||||
foreach ($unwrap as $key => $val)
|
||||
{
|
||||
$output = str_replace("{{unwrapped".$key."}}", $val, $output);
|
||||
}
|
||||
}
|
||||
|
||||
// Remove the unwrap tags
|
||||
$output = str_replace(array('{unwrap}', '{/unwrap}'), '', $output);
|
||||
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* End of file text_helper.php */
|
||||
/* Location: ./system/helpers/text_helper.php */
|
||||
71
system/helpers/typography_helper.php
Normal file
71
system/helpers/typography_helper.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP 4.3.2 or newer
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2010, EllisLab, Inc.
|
||||
* @license http://codeigniter.com/user_guide/license.html
|
||||
* @link http://codeigniter.com
|
||||
* @since Version 1.0
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* CodeIgniter Typography Helpers
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @subpackage Helpers
|
||||
* @category Helpers
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @link http://codeigniter.com/user_guide/helpers/typography_helper.html
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Convert newlines to HTML line breaks except within PRE tags
|
||||
*
|
||||
* @access public
|
||||
* @param string
|
||||
* @return string
|
||||
*/
|
||||
if ( ! function_exists('nl2br_except_pre'))
|
||||
{
|
||||
function nl2br_except_pre($str)
|
||||
{
|
||||
$CI =& get_instance();
|
||||
|
||||
$CI->load->library('typography');
|
||||
|
||||
return $CI->typography->nl2br_except_pre($str);
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Auto Typography Wrapper Function
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @param string
|
||||
* @param bool whether to reduce multiple instances of double newlines to two
|
||||
* @return string
|
||||
*/
|
||||
if ( ! function_exists('auto_typography'))
|
||||
{
|
||||
function auto_typography($str, $reduce_linebreaks = FALSE)
|
||||
{
|
||||
$CI =& get_instance();
|
||||
$CI->load->library('typography');
|
||||
return $CI->typography->auto_typography($str, $reduce_linebreaks);
|
||||
}
|
||||
}
|
||||
|
||||
/* End of file typography_helper.php */
|
||||
/* Location: ./system/helpers/typography_helper.php */
|
||||
593
system/helpers/url_helper.php
Normal file
593
system/helpers/url_helper.php
Normal file
@@ -0,0 +1,593 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP 4.3.2 or newer
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2010, EllisLab, Inc.
|
||||
* @license http://codeigniter.com/user_guide/license.html
|
||||
* @link http://codeigniter.com
|
||||
* @since Version 1.0
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* CodeIgniter URL Helpers
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @subpackage Helpers
|
||||
* @category Helpers
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @link http://codeigniter.com/user_guide/helpers/url_helper.html
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Site URL
|
||||
*
|
||||
* Create a local URL based on your basepath. Segments can be passed via the
|
||||
* first parameter either as a string or an array.
|
||||
*
|
||||
* @access public
|
||||
* @param string
|
||||
* @return string
|
||||
*/
|
||||
if ( ! function_exists('site_url'))
|
||||
{
|
||||
function site_url($uri = '')
|
||||
{
|
||||
$CI =& get_instance();
|
||||
return $CI->config->site_url($uri);
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Base URL
|
||||
*
|
||||
* Returns the "base_url" item from your config file
|
||||
*
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
if ( ! function_exists('base_url'))
|
||||
{
|
||||
function base_url()
|
||||
{
|
||||
$CI =& get_instance();
|
||||
return $CI->config->slash_item('base_url');
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Current URL
|
||||
*
|
||||
* Returns the full URL (including segments) of the page where this
|
||||
* function is placed
|
||||
*
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
if ( ! function_exists('current_url'))
|
||||
{
|
||||
function current_url()
|
||||
{
|
||||
$CI =& get_instance();
|
||||
return $CI->config->site_url($CI->uri->uri_string());
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/**
|
||||
* URL String
|
||||
*
|
||||
* Returns the URI segments.
|
||||
*
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
if ( ! function_exists('uri_string'))
|
||||
{
|
||||
function uri_string()
|
||||
{
|
||||
$CI =& get_instance();
|
||||
return $CI->uri->uri_string();
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Index page
|
||||
*
|
||||
* Returns the "index_page" from your config file
|
||||
*
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
if ( ! function_exists('index_page'))
|
||||
{
|
||||
function index_page()
|
||||
{
|
||||
$CI =& get_instance();
|
||||
return $CI->config->item('index_page');
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Anchor Link
|
||||
*
|
||||
* Creates an anchor based on the local URL.
|
||||
*
|
||||
* @access public
|
||||
* @param string the URL
|
||||
* @param string the link title
|
||||
* @param mixed any attributes
|
||||
* @return string
|
||||
*/
|
||||
if ( ! function_exists('anchor'))
|
||||
{
|
||||
function anchor($uri = '', $title = '', $attributes = '')
|
||||
{
|
||||
$title = (string) $title;
|
||||
|
||||
if ( ! is_array($uri))
|
||||
{
|
||||
$site_url = ( ! preg_match('!^\w+://! i', $uri)) ? site_url($uri) : $uri;
|
||||
}
|
||||
else
|
||||
{
|
||||
$site_url = site_url($uri);
|
||||
}
|
||||
|
||||
if ($title == '')
|
||||
{
|
||||
$title = $site_url;
|
||||
}
|
||||
|
||||
if ($attributes != '')
|
||||
{
|
||||
$attributes = _parse_attributes($attributes);
|
||||
}
|
||||
|
||||
return '<a href="'.$site_url.'"'.$attributes.'>'.$title.'</a>';
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Anchor Link - Pop-up version
|
||||
*
|
||||
* Creates an anchor based on the local URL. The link
|
||||
* opens a new window based on the attributes specified.
|
||||
*
|
||||
* @access public
|
||||
* @param string the URL
|
||||
* @param string the link title
|
||||
* @param mixed any attributes
|
||||
* @return string
|
||||
*/
|
||||
if ( ! function_exists('anchor_popup'))
|
||||
{
|
||||
function anchor_popup($uri = '', $title = '', $attributes = FALSE)
|
||||
{
|
||||
$title = (string) $title;
|
||||
|
||||
$site_url = ( ! preg_match('!^\w+://! i', $uri)) ? site_url($uri) : $uri;
|
||||
|
||||
if ($title == '')
|
||||
{
|
||||
$title = $site_url;
|
||||
}
|
||||
|
||||
if ($attributes === FALSE)
|
||||
{
|
||||
return "<a href='javascript:void(0);' onclick=\"window.open('".$site_url."', '_blank');\">".$title."</a>";
|
||||
}
|
||||
|
||||
if ( ! is_array($attributes))
|
||||
{
|
||||
$attributes = array();
|
||||
}
|
||||
|
||||
foreach (array('width' => '800', 'height' => '600', 'scrollbars' => 'yes', 'status' => 'yes', 'resizable' => 'yes', 'screenx' => '0', 'screeny' => '0', ) as $key => $val)
|
||||
{
|
||||
$atts[$key] = ( ! isset($attributes[$key])) ? $val : $attributes[$key];
|
||||
unset($attributes[$key]);
|
||||
}
|
||||
|
||||
if ($attributes != '')
|
||||
{
|
||||
$attributes = _parse_attributes($attributes);
|
||||
}
|
||||
|
||||
return "<a href='javascript:void(0);' onclick=\"window.open('".$site_url."', '_blank', '"._parse_attributes($atts, TRUE)."');\"$attributes>".$title."</a>";
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Mailto Link
|
||||
*
|
||||
* @access public
|
||||
* @param string the email address
|
||||
* @param string the link title
|
||||
* @param mixed any attributes
|
||||
* @return string
|
||||
*/
|
||||
if ( ! function_exists('mailto'))
|
||||
{
|
||||
function mailto($email, $title = '', $attributes = '')
|
||||
{
|
||||
$title = (string) $title;
|
||||
|
||||
if ($title == "")
|
||||
{
|
||||
$title = $email;
|
||||
}
|
||||
|
||||
$attributes = _parse_attributes($attributes);
|
||||
|
||||
return '<a href="mailto:'.$email.'"'.$attributes.'>'.$title.'</a>';
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Encoded Mailto Link
|
||||
*
|
||||
* Create a spam-protected mailto link written in Javascript
|
||||
*
|
||||
* @access public
|
||||
* @param string the email address
|
||||
* @param string the link title
|
||||
* @param mixed any attributes
|
||||
* @return string
|
||||
*/
|
||||
if ( ! function_exists('safe_mailto'))
|
||||
{
|
||||
function safe_mailto($email, $title = '', $attributes = '')
|
||||
{
|
||||
$title = (string) $title;
|
||||
|
||||
if ($title == "")
|
||||
{
|
||||
$title = $email;
|
||||
}
|
||||
|
||||
for ($i = 0; $i < 16; $i++)
|
||||
{
|
||||
$x[] = substr('<a href="mailto:', $i, 1);
|
||||
}
|
||||
|
||||
for ($i = 0; $i < strlen($email); $i++)
|
||||
{
|
||||
$x[] = "|".ord(substr($email, $i, 1));
|
||||
}
|
||||
|
||||
$x[] = '"';
|
||||
|
||||
if ($attributes != '')
|
||||
{
|
||||
if (is_array($attributes))
|
||||
{
|
||||
foreach ($attributes as $key => $val)
|
||||
{
|
||||
$x[] = ' '.$key.'="';
|
||||
for ($i = 0; $i < strlen($val); $i++)
|
||||
{
|
||||
$x[] = "|".ord(substr($val, $i, 1));
|
||||
}
|
||||
$x[] = '"';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for ($i = 0; $i < strlen($attributes); $i++)
|
||||
{
|
||||
$x[] = substr($attributes, $i, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$x[] = '>';
|
||||
|
||||
$temp = array();
|
||||
for ($i = 0; $i < strlen($title); $i++)
|
||||
{
|
||||
$ordinal = ord($title[$i]);
|
||||
|
||||
if ($ordinal < 128)
|
||||
{
|
||||
$x[] = "|".$ordinal;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (count($temp) == 0)
|
||||
{
|
||||
$count = ($ordinal < 224) ? 2 : 3;
|
||||
}
|
||||
|
||||
$temp[] = $ordinal;
|
||||
if (count($temp) == $count)
|
||||
{
|
||||
$number = ($count == 3) ? (($temp['0'] % 16) * 4096) + (($temp['1'] % 64) * 64) + ($temp['2'] % 64) : (($temp['0'] % 32) * 64) + ($temp['1'] % 64);
|
||||
$x[] = "|".$number;
|
||||
$count = 1;
|
||||
$temp = array();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$x[] = '<'; $x[] = '/'; $x[] = 'a'; $x[] = '>';
|
||||
|
||||
$x = array_reverse($x);
|
||||
ob_start();
|
||||
|
||||
?><script type="text/javascript">
|
||||
//<![CDATA[
|
||||
var l=new Array();
|
||||
<?php
|
||||
$i = 0;
|
||||
foreach ($x as $val){ ?>l[<?php echo $i++; ?>]='<?php echo $val; ?>';<?php } ?>
|
||||
|
||||
for (var i = l.length-1; i >= 0; i=i-1){
|
||||
if (l[i].substring(0, 1) == '|') document.write("&#"+unescape(l[i].substring(1))+";");
|
||||
else document.write(unescape(l[i]));}
|
||||
//]]>
|
||||
</script><?php
|
||||
|
||||
$buffer = ob_get_contents();
|
||||
ob_end_clean();
|
||||
return $buffer;
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Auto-linker
|
||||
*
|
||||
* Automatically links URL and Email addresses.
|
||||
* Note: There's a bit of extra code here to deal with
|
||||
* URLs or emails that end in a period. We'll strip these
|
||||
* off and add them after the link.
|
||||
*
|
||||
* @access public
|
||||
* @param string the string
|
||||
* @param string the type: email, url, or both
|
||||
* @param bool whether to create pop-up links
|
||||
* @return string
|
||||
*/
|
||||
if ( ! function_exists('auto_link'))
|
||||
{
|
||||
function auto_link($str, $type = 'both', $popup = FALSE)
|
||||
{
|
||||
if ($type != 'email')
|
||||
{
|
||||
if (preg_match_all("#(^|\s|\()((http(s?)://)|(www\.))(\w+[^\s\)\<]+)#i", $str, $matches))
|
||||
{
|
||||
$pop = ($popup == TRUE) ? " target=\"_blank\" " : "";
|
||||
|
||||
for ($i = 0; $i < count($matches['0']); $i++)
|
||||
{
|
||||
$period = '';
|
||||
if (preg_match("|\.$|", $matches['6'][$i]))
|
||||
{
|
||||
$period = '.';
|
||||
$matches['6'][$i] = substr($matches['6'][$i], 0, -1);
|
||||
}
|
||||
|
||||
$str = str_replace($matches['0'][$i],
|
||||
$matches['1'][$i].'<a href="http'.
|
||||
$matches['4'][$i].'://'.
|
||||
$matches['5'][$i].
|
||||
$matches['6'][$i].'"'.$pop.'>http'.
|
||||
$matches['4'][$i].'://'.
|
||||
$matches['5'][$i].
|
||||
$matches['6'][$i].'</a>'.
|
||||
$period, $str);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($type != 'url')
|
||||
{
|
||||
if (preg_match_all("/([a-zA-Z0-9_\.\-\+]+)@([a-zA-Z0-9\-]+)\.([a-zA-Z0-9\-\.]*)/i", $str, $matches))
|
||||
{
|
||||
for ($i = 0; $i < count($matches['0']); $i++)
|
||||
{
|
||||
$period = '';
|
||||
if (preg_match("|\.$|", $matches['3'][$i]))
|
||||
{
|
||||
$period = '.';
|
||||
$matches['3'][$i] = substr($matches['3'][$i], 0, -1);
|
||||
}
|
||||
|
||||
$str = str_replace($matches['0'][$i], safe_mailto($matches['1'][$i].'@'.$matches['2'][$i].'.'.$matches['3'][$i]).$period, $str);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $str;
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Prep URL
|
||||
*
|
||||
* Simply adds the http:// part if missing
|
||||
*
|
||||
* @access public
|
||||
* @param string the URL
|
||||
* @return string
|
||||
*/
|
||||
if ( ! function_exists('prep_url'))
|
||||
{
|
||||
function prep_url($str = '')
|
||||
{
|
||||
if ($str == 'http://' OR $str == '')
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
if (substr($str, 0, 7) != 'http://' && substr($str, 0, 8) != 'https://')
|
||||
{
|
||||
$str = 'http://'.$str;
|
||||
}
|
||||
|
||||
return $str;
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Create URL Title
|
||||
*
|
||||
* Takes a "title" string as input and creates a
|
||||
* human-friendly URL string with either a dash
|
||||
* or an underscore as the word separator.
|
||||
*
|
||||
* @access public
|
||||
* @param string the string
|
||||
* @param string the separator: dash, or underscore
|
||||
* @return string
|
||||
*/
|
||||
if ( ! function_exists('url_title'))
|
||||
{
|
||||
function url_title($str, $separator = 'dash', $lowercase = FALSE)
|
||||
{
|
||||
if ($separator == 'dash')
|
||||
{
|
||||
$search = '_';
|
||||
$replace = '-';
|
||||
}
|
||||
else
|
||||
{
|
||||
$search = '-';
|
||||
$replace = '_';
|
||||
}
|
||||
|
||||
$trans = array(
|
||||
'&\#\d+?;' => '',
|
||||
'&\S+?;' => '',
|
||||
'\s+' => $replace,
|
||||
'[^a-z0-9\-\._]' => '',
|
||||
$replace.'+' => $replace,
|
||||
$replace.'$' => $replace,
|
||||
'^'.$replace => $replace,
|
||||
'\.+$' => ''
|
||||
);
|
||||
|
||||
$str = strip_tags($str);
|
||||
|
||||
foreach ($trans as $key => $val)
|
||||
{
|
||||
$str = preg_replace("#".$key."#i", $val, $str);
|
||||
}
|
||||
|
||||
if ($lowercase === TRUE)
|
||||
{
|
||||
$str = strtolower($str);
|
||||
}
|
||||
|
||||
return trim(stripslashes($str));
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Header Redirect
|
||||
*
|
||||
* Header redirect in two flavors
|
||||
* For very fine grained control over headers, you could use the Output
|
||||
* Library's set_header() function.
|
||||
*
|
||||
* @access public
|
||||
* @param string the URL
|
||||
* @param string the method: location or redirect
|
||||
* @return string
|
||||
*/
|
||||
if ( ! function_exists('redirect'))
|
||||
{
|
||||
function redirect($uri = '', $method = 'location', $http_response_code = 302)
|
||||
{
|
||||
if ( ! preg_match('#^https?://#i', $uri))
|
||||
{
|
||||
$uri = site_url($uri);
|
||||
}
|
||||
|
||||
switch($method)
|
||||
{
|
||||
case 'refresh' : header("Refresh:0;url=".$uri);
|
||||
break;
|
||||
default : header("Location: ".$uri, TRUE, $http_response_code);
|
||||
break;
|
||||
}
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Parse out the attributes
|
||||
*
|
||||
* Some of the functions use this
|
||||
*
|
||||
* @access private
|
||||
* @param array
|
||||
* @param bool
|
||||
* @return string
|
||||
*/
|
||||
if ( ! function_exists('_parse_attributes'))
|
||||
{
|
||||
function _parse_attributes($attributes, $javascript = FALSE)
|
||||
{
|
||||
if (is_string($attributes))
|
||||
{
|
||||
return ($attributes != '') ? ' '.$attributes : '';
|
||||
}
|
||||
|
||||
$att = '';
|
||||
foreach ($attributes as $key => $val)
|
||||
{
|
||||
if ($javascript == TRUE)
|
||||
{
|
||||
$att .= $key . '=' . $val . ',';
|
||||
}
|
||||
else
|
||||
{
|
||||
$att .= ' ' . $key . '="' . $val . '"';
|
||||
}
|
||||
}
|
||||
|
||||
if ($javascript == TRUE AND $att != '')
|
||||
{
|
||||
$att = substr($att, 0, -1);
|
||||
}
|
||||
|
||||
return $att;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* End of file url_helper.php */
|
||||
/* Location: ./system/helpers/url_helper.php */
|
||||
62
system/helpers/xml_helper.php
Normal file
62
system/helpers/xml_helper.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP 4.3.2 or newer
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2010, EllisLab, Inc.
|
||||
* @license http://codeigniter.com/user_guide/license.html
|
||||
* @link http://codeigniter.com
|
||||
* @since Version 1.0
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* CodeIgniter XML Helpers
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @subpackage Helpers
|
||||
* @category Helpers
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @link http://codeigniter.com/user_guide/helpers/xml_helper.html
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Convert Reserved XML characters to Entities
|
||||
*
|
||||
* @access public
|
||||
* @param string
|
||||
* @return string
|
||||
*/
|
||||
if ( ! function_exists('xml_convert'))
|
||||
{
|
||||
function xml_convert($str)
|
||||
{
|
||||
$temp = '__TEMP_AMPERSANDS__';
|
||||
|
||||
// Replace entities to temporary markers so that
|
||||
// ampersands won't get messed up
|
||||
$str = preg_replace("/&#(\d+);/", "$temp\\1;", $str);
|
||||
$str = preg_replace("/&(\w+);/", "$temp\\1;", $str);
|
||||
|
||||
$str = str_replace(array("&","<",">","\"", "'", "-"),
|
||||
array("&", "<", ">", """, "'", "-"),
|
||||
$str);
|
||||
|
||||
// Decode the temp markers back to entities
|
||||
$str = preg_replace("/$temp(\d+);/","&#\\1;",$str);
|
||||
$str = preg_replace("/$temp(\w+);/","&\\1;", $str);
|
||||
|
||||
return $str;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* End of file xml_helper.php */
|
||||
/* Location: ./system/helpers/xml_helper.php */
|
||||
10
system/index.html
Normal file
10
system/index.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
51
system/language/english/calendar_lang.php
Normal file
51
system/language/english/calendar_lang.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
$lang['cal_su'] = "Su";
|
||||
$lang['cal_mo'] = "Mo";
|
||||
$lang['cal_tu'] = "Tu";
|
||||
$lang['cal_we'] = "We";
|
||||
$lang['cal_th'] = "Th";
|
||||
$lang['cal_fr'] = "Fr";
|
||||
$lang['cal_sa'] = "Sa";
|
||||
$lang['cal_sun'] = "Sun";
|
||||
$lang['cal_mon'] = "Mon";
|
||||
$lang['cal_tue'] = "Tue";
|
||||
$lang['cal_wed'] = "Wed";
|
||||
$lang['cal_thu'] = "Thu";
|
||||
$lang['cal_fri'] = "Fri";
|
||||
$lang['cal_sat'] = "Sat";
|
||||
$lang['cal_sunday'] = "Sunday";
|
||||
$lang['cal_monday'] = "Monday";
|
||||
$lang['cal_tuesday'] = "Tuesday";
|
||||
$lang['cal_wednesday'] = "Wednesday";
|
||||
$lang['cal_thursday'] = "Thursday";
|
||||
$lang['cal_friday'] = "Friday";
|
||||
$lang['cal_saturday'] = "Saturday";
|
||||
$lang['cal_jan'] = "Jan";
|
||||
$lang['cal_feb'] = "Feb";
|
||||
$lang['cal_mar'] = "Mar";
|
||||
$lang['cal_apr'] = "Apr";
|
||||
$lang['cal_may'] = "May";
|
||||
$lang['cal_jun'] = "Jun";
|
||||
$lang['cal_jul'] = "Jul";
|
||||
$lang['cal_aug'] = "Aug";
|
||||
$lang['cal_sep'] = "Sep";
|
||||
$lang['cal_oct'] = "Oct";
|
||||
$lang['cal_nov'] = "Nov";
|
||||
$lang['cal_dec'] = "Dec";
|
||||
$lang['cal_january'] = "January";
|
||||
$lang['cal_february'] = "February";
|
||||
$lang['cal_march'] = "March";
|
||||
$lang['cal_april'] = "April";
|
||||
$lang['cal_mayl'] = "May";
|
||||
$lang['cal_june'] = "June";
|
||||
$lang['cal_july'] = "July";
|
||||
$lang['cal_august'] = "August";
|
||||
$lang['cal_september'] = "September";
|
||||
$lang['cal_october'] = "October";
|
||||
$lang['cal_november'] = "November";
|
||||
$lang['cal_december'] = "December";
|
||||
|
||||
|
||||
/* End of file calendar_lang.php */
|
||||
/* Location: ./system/language/english/calendar_lang.php */
|
||||
60
system/language/english/date_lang.php
Normal file
60
system/language/english/date_lang.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
$lang['date_year'] = "Year";
|
||||
$lang['date_years'] = "Years";
|
||||
$lang['date_month'] = "Month";
|
||||
$lang['date_months'] = "Months";
|
||||
$lang['date_week'] = "Week";
|
||||
$lang['date_weeks'] = "Weeks";
|
||||
$lang['date_day'] = "Day";
|
||||
$lang['date_days'] = "Days";
|
||||
$lang['date_hour'] = "Hour";
|
||||
$lang['date_hours'] = "Hours";
|
||||
$lang['date_minute'] = "Minute";
|
||||
$lang['date_minutes'] = "Minutes";
|
||||
$lang['date_second'] = "Second";
|
||||
$lang['date_seconds'] = "Seconds";
|
||||
|
||||
$lang['UM12'] = '(UTC -12:00) Baker/Howland Island';
|
||||
$lang['UM11'] = '(UTC -11:00) Samoa Time Zone, Niue';
|
||||
$lang['UM10'] = '(UTC -10:00) Hawaii-Aleutian Standard Time, Cook Islands, Tahiti';
|
||||
$lang['UM95'] = '(UTC -9:30) Marquesas Islands';
|
||||
$lang['UM9'] = '(UTC -9:00) Alaska Standard Time, Gambier Islands';
|
||||
$lang['UM8'] = '(UTC -8:00) Pacific Standard Time, Clipperton Island';
|
||||
$lang['UM7'] = '(UTC -7:00) Mountain Standard Time';
|
||||
$lang['UM6'] = '(UTC -6:00) Central Standard Time';
|
||||
$lang['UM5'] = '(UTC -5:00) Eastern Standard Time, Western Caribbean Standard Time';
|
||||
$lang['UM45'] = '(UTC -4:30) Venezuelan Standard Time';
|
||||
$lang['UM4'] = '(UTC -4:00) Atlantic Standard Time, Eastern Caribbean Standard Time';
|
||||
$lang['UM35'] = '(UTC -3:30) Newfoundland Standard Time';
|
||||
$lang['UM3'] = '(UTC -3:00) Argentina, Brazil, French Guiana, Uruguay';
|
||||
$lang['UM2'] = '(UTC -2:00) South Georgia/South Sandwich Islands';
|
||||
$lang['UM1'] = '(UTC -1:00) Azores, Cape Verde Islands';
|
||||
$lang['UTC'] = '(UTC) Greenwich Mean Time, Western European Time';
|
||||
$lang['UP1'] = '(UTC +1:00) Central European Time, West Africa Time';
|
||||
$lang['UP2'] = '(UTC +2:00) Central Africa Time, Eastern European Time, Kaliningrad Time';
|
||||
$lang['UP3'] = '(UTC +3:00) Moscow Time, East Africa Time';
|
||||
$lang['UP35'] = '(UTC +3:30) Iran Standard Time';
|
||||
$lang['UP4'] = '(UTC +4:00) Azerbaijan Standard Time, Samara Time';
|
||||
$lang['UP45'] = '(UTC +4:30) Afghanistan';
|
||||
$lang['UP5'] = '(UTC +5:00) Pakistan Standard Time, Yekaterinburg Time';
|
||||
$lang['UP55'] = '(UTC +5:30) Indian Standard Time, Sri Lanka Time';
|
||||
$lang['UP575'] = '(UTC +5:45) Nepal Time';
|
||||
$lang['UP6'] = '(UTC +6:00) Bangladesh Standard Time, Bhutan Time, Omsk Time';
|
||||
$lang['UP65'] = '(UTC +6:30) Cocos Islands, Myanmar';
|
||||
$lang['UP7'] = '(UTC +7:00) Krasnoyarsk Time, Cambodia, Laos, Thailand, Vietnam';
|
||||
$lang['UP8'] = '(UTC +8:00) Australian Western Standard Time, Beijing Time, Irkutsk Time';
|
||||
$lang['UP875'] = '(UTC +8:45) Australian Central Western Standard Time';
|
||||
$lang['UP9'] = '(UTC +9:00) Japan Standard Time, Korea Standard Time, Yakutsk Time';
|
||||
$lang['UP95'] = '(UTC +9:30) Australian Central Standard Time';
|
||||
$lang['UP10'] = '(UTC +10:00) Australian Eastern Standard Time, Vladivostok Time';
|
||||
$lang['UP105'] = '(UTC +10:30) Lord Howe Island';
|
||||
$lang['UP11'] = '(UTC +11:00) Magadan Time, Solomon Islands, Vanuatu';
|
||||
$lang['UP115'] = '(UTC +11:30) Norfolk Island';
|
||||
$lang['UP12'] = '(UTC +12:00) Fiji, Gilbert Islands, Kamchatka Time, New Zealand Standard Time';
|
||||
$lang['UP1275'] = '(UTC +12:45) Chatham Islands Standard Time';
|
||||
$lang['UP13'] = '(UTC +13:00) Phoenix Islands Time, Tonga';
|
||||
$lang['UP14'] = '(UTC +14:00) Line Islands';
|
||||
|
||||
/* End of file date_lang.php */
|
||||
/* Location: ./system/language/english/date_lang.php */
|
||||
28
system/language/english/db_lang.php
Normal file
28
system/language/english/db_lang.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
$lang['db_invalid_connection_str'] = 'Unable to determine the database settings based on the connection string you submitted.';
|
||||
$lang['db_unable_to_connect'] = 'Unable to connect to your database server using the provided settings.';
|
||||
$lang['db_unable_to_select'] = 'Unable to select the specified database: %s';
|
||||
$lang['db_unable_to_create'] = 'Unable to create the specified database: %s';
|
||||
$lang['db_invalid_query'] = 'The query you submitted is not valid.';
|
||||
$lang['db_must_set_table'] = 'You must set the database table to be used with your query.';
|
||||
$lang['db_must_set_database'] = 'You must set the database name in your database config file.';
|
||||
$lang['db_must_use_set'] = 'You must use the "set" method to update an entry.';
|
||||
$lang['db_must_use_where'] = 'Updates are not allowed unless they contain a "where" clause.';
|
||||
$lang['db_del_must_use_where'] = 'Deletes are not allowed unless they contain a "where" or "like" clause.';
|
||||
$lang['db_field_param_missing'] = 'To fetch fields requires the name of the table as a parameter.';
|
||||
$lang['db_unsupported_function'] = 'This feature is not available for the database you are using.';
|
||||
$lang['db_transaction_failure'] = 'Transaction failure: Rollback performed.';
|
||||
$lang['db_unable_to_drop'] = 'Unable to drop the specified database.';
|
||||
$lang['db_unsuported_feature'] = 'Unsupported feature of the database platform you are using.';
|
||||
$lang['db_unsuported_compression'] = 'The file compression format you chose is not supported by your server.';
|
||||
$lang['db_filepath_error'] = 'Unable to write data to the file path you have submitted.';
|
||||
$lang['db_invalid_cache_path'] = 'The cache path you submitted is not valid or writable.';
|
||||
$lang['db_table_name_required'] = 'A table name is required for that operation.';
|
||||
$lang['db_column_name_required'] = 'A column name is required for that operation.';
|
||||
$lang['db_column_definition_required'] = 'A column definition is required for that operation.';
|
||||
$lang['db_unable_to_set_charset'] = 'Unable to set client connection character set: %s';
|
||||
$lang['db_error_heading'] = 'A Database Error Occurred';
|
||||
|
||||
/* End of file db_lang.php */
|
||||
/* Location: ./system/language/english/db_lang.php */
|
||||
24
system/language/english/email_lang.php
Normal file
24
system/language/english/email_lang.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
$lang['email_must_be_array'] = "The email validation method must be passed an array.";
|
||||
$lang['email_invalid_address'] = "Invalid email address: %s";
|
||||
$lang['email_attachment_missing'] = "Unable to locate the following email attachment: %s";
|
||||
$lang['email_attachment_unreadable'] = "Unable to open this attachment: %s";
|
||||
$lang['email_no_recipients'] = "You must include recipients: To, Cc, or Bcc";
|
||||
$lang['email_send_failure_phpmail'] = "Unable to send email using PHP mail(). Your server might not be configured to send mail using this method.";
|
||||
$lang['email_send_failure_sendmail'] = "Unable to send email using PHP Sendmail. Your server might not be configured to send mail using this method.";
|
||||
$lang['email_send_failure_smtp'] = "Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method.";
|
||||
$lang['email_sent'] = "Your message has been successfully sent using the following protocol: %s";
|
||||
$lang['email_no_socket'] = "Unable to open a socket to Sendmail. Please check settings.";
|
||||
$lang['email_no_hostname'] = "You did not specify a SMTP hostname.";
|
||||
$lang['email_smtp_error'] = "The following SMTP error was encountered: %s";
|
||||
$lang['email_no_smtp_unpw'] = "Error: You must assign a SMTP username and password.";
|
||||
$lang['email_failed_smtp_login'] = "Failed to send AUTH LOGIN command. Error: %s";
|
||||
$lang['email_smtp_auth_un'] = "Failed to authenticate username. Error: %s";
|
||||
$lang['email_smtp_auth_pw'] = "Failed to authenticate password. Error: %s";
|
||||
$lang['email_smtp_data_failure'] = "Unable to send data: %s";
|
||||
$lang['email_exit_status'] = "Exit status code: %s";
|
||||
|
||||
|
||||
/* End of file email_lang.php */
|
||||
/* Location: ./system/language/english/email_lang.php */
|
||||
24
system/language/english/form_validation_lang.php
Normal file
24
system/language/english/form_validation_lang.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
$lang['required'] = "The %s field is required.";
|
||||
$lang['isset'] = "The %s field must have a value.";
|
||||
$lang['valid_email'] = "The %s field must contain a valid email address.";
|
||||
$lang['valid_emails'] = "The %s field must contain all valid email addresses.";
|
||||
$lang['valid_url'] = "The %s field must contain a valid URL.";
|
||||
$lang['valid_ip'] = "The %s field must contain a valid IP.";
|
||||
$lang['min_length'] = "The %s field must be at least %s characters in length.";
|
||||
$lang['max_length'] = "The %s field can not exceed %s characters in length.";
|
||||
$lang['exact_length'] = "The %s field must be exactly %s characters in length.";
|
||||
$lang['alpha'] = "The %s field may only contain alphabetical characters.";
|
||||
$lang['alpha_numeric'] = "The %s field may only contain alpha-numeric characters.";
|
||||
$lang['alpha_dash'] = "The %s field may only contain alpha-numeric characters, underscores, and dashes.";
|
||||
$lang['numeric'] = "The %s field must contain only numbers.";
|
||||
$lang['is_numeric'] = "The %s field must contain only numeric characters.";
|
||||
$lang['integer'] = "The %s field must contain an integer.";
|
||||
$lang['matches'] = "The %s field does not match the %s field.";
|
||||
$lang['is_natural'] = "The %s field must contain only positive numbers.";
|
||||
$lang['is_natural_no_zero'] = "The %s field must contain a number greater than zero.";
|
||||
|
||||
|
||||
/* End of file form_validation_lang.php */
|
||||
/* Location: ./system/language/english/form_validation_lang.php */
|
||||
17
system/language/english/ftp_lang.php
Normal file
17
system/language/english/ftp_lang.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
$lang['ftp_no_connection'] = "Unable to locate a valid connection ID. Please make sure you are connected before peforming any file routines.";
|
||||
$lang['ftp_unable_to_connect'] = "Unable to connect to your FTP server using the supplied hostname.";
|
||||
$lang['ftp_unable_to_login'] = "Unable to login to your FTP server. Please check your username and password.";
|
||||
$lang['ftp_unable_to_makdir'] = "Unable to create the directory you have specified.";
|
||||
$lang['ftp_unable_to_changedir'] = "Unable to change directories.";
|
||||
$lang['ftp_unable_to_chmod'] = "Unable to set file permissions. Please check your path. Note: This feature is only available in PHP 5 or higher.";
|
||||
$lang['ftp_unable_to_upload'] = "Unable to upload the specified file. Please check your path.";
|
||||
$lang['ftp_no_source_file'] = "Unable to locate the source file. Please check your path.";
|
||||
$lang['ftp_unable_to_rename'] = "Unable to rename the file.";
|
||||
$lang['ftp_unable_to_delete'] = "Unable to delete the file.";
|
||||
$lang['ftp_unable_to_move'] = "Unable to move the file. Please make sure the destination directory exists.";
|
||||
|
||||
|
||||
/* End of file ftp_lang.php */
|
||||
/* Location: ./system/language/english/ftp_lang.php */
|
||||
24
system/language/english/imglib_lang.php
Normal file
24
system/language/english/imglib_lang.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
$lang['imglib_source_image_required'] = "You must specify a source image in your preferences.";
|
||||
$lang['imglib_gd_required'] = "The GD image library is required for this feature.";
|
||||
$lang['imglib_gd_required_for_props'] = "Your server must support the GD image library in order to determine the image properties.";
|
||||
$lang['imglib_unsupported_imagecreate'] = "Your server does not support the GD function required to process this type of image.";
|
||||
$lang['imglib_gif_not_supported'] = "GIF images are often not supported due to licensing restrictions. You may have to use JPG or PNG images instead.";
|
||||
$lang['imglib_jpg_not_supported'] = "JPG images are not supported.";
|
||||
$lang['imglib_png_not_supported'] = "PNG images are not supported.";
|
||||
$lang['imglib_jpg_or_png_required'] = "The image resize protocol specified in your preferences only works with JPEG or PNG image types.";
|
||||
$lang['imglib_copy_error'] = "An error was encountered while attempting to replace the file. Please make sure your file directory is writable.";
|
||||
$lang['imglib_rotate_unsupported'] = "Image rotation does not appear to be supported by your server.";
|
||||
$lang['imglib_libpath_invalid'] = "The path to your image library is not correct. Please set the correct path in your image preferences.";
|
||||
$lang['imglib_image_process_failed'] = "Image processing failed. Please verify that your server supports the chosen protocol and that the path to your image library is correct.";
|
||||
$lang['imglib_rotation_angle_required'] = "An angle of rotation is required to rotate the image.";
|
||||
$lang['imglib_writing_failed_gif'] = "GIF image.";
|
||||
$lang['imglib_invalid_path'] = "The path to the image is not correct.";
|
||||
$lang['imglib_copy_failed'] = "The image copy routine failed.";
|
||||
$lang['imglib_missing_font'] = "Unable to find a font to use.";
|
||||
$lang['imglib_save_failed'] = "Unable to save the image. Please make sure the image and file directory are writable.";
|
||||
|
||||
|
||||
/* End of file imglib_lang.php */
|
||||
/* Location: ./system/language/english/imglib_lang.php */
|
||||
10
system/language/english/index.html
Normal file
10
system/language/english/index.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
10
system/language/english/number_lang.php
Normal file
10
system/language/english/number_lang.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
$lang['terabyte_abbr'] = "TB";
|
||||
$lang['gigabyte_abbr'] = "GB";
|
||||
$lang['megabyte_abbr'] = "MB";
|
||||
$lang['kilobyte_abbr'] = "KB";
|
||||
$lang['bytes'] = "Bytes";
|
||||
|
||||
/* End of file number_lang.php */
|
||||
/* Location: ./system/language/english/number_lang.php */
|
||||
19
system/language/english/profiler_lang.php
Normal file
19
system/language/english/profiler_lang.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
$lang['profiler_database'] = 'DATABASE';
|
||||
$lang['profiler_controller_info'] = 'CLASS/METHOD';
|
||||
$lang['profiler_benchmarks'] = 'BENCHMARKS';
|
||||
$lang['profiler_queries'] = 'QUERIES';
|
||||
$lang['profiler_get_data'] = 'GET DATA';
|
||||
$lang['profiler_post_data'] = 'POST DATA';
|
||||
$lang['profiler_uri_string'] = 'URI STRING';
|
||||
$lang['profiler_memory_usage'] = 'MEMORY USAGE';
|
||||
$lang['profiler_no_db'] = 'Database driver is not currently loaded';
|
||||
$lang['profiler_no_queries'] = 'No queries were run';
|
||||
$lang['profiler_no_post'] = 'No POST data exists';
|
||||
$lang['profiler_no_get'] = 'No GET data exists';
|
||||
$lang['profiler_no_uri'] = 'No URI data exists';
|
||||
$lang['profiler_no_memory'] = 'Memory Usage Unavailable';
|
||||
|
||||
/* End of file profiler_lang.php */
|
||||
/* Location: ./system/language/english/profiler_lang.php */
|
||||
17
system/language/english/scaffolding_lang.php
Normal file
17
system/language/english/scaffolding_lang.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
$lang['scaff_view_records'] = 'View Records';
|
||||
$lang['scaff_create_record'] = 'Create New Record';
|
||||
$lang['scaff_add'] = 'Add Data';
|
||||
$lang['scaff_view'] = 'View Data';
|
||||
$lang['scaff_edit'] = 'Edit';
|
||||
$lang['scaff_delete'] = 'Delete';
|
||||
$lang['scaff_view_all'] = 'View All';
|
||||
$lang['scaff_yes'] = 'Yes';
|
||||
$lang['scaff_no'] = 'No';
|
||||
$lang['scaff_no_data'] = 'No data exists for this table yet.';
|
||||
$lang['scaff_del_confirm'] = 'Are you sure you want to delete the following row:';
|
||||
|
||||
|
||||
/* End of file scaffolding_lang.php */
|
||||
/* Location: ./system/language/english/scaffolding_lang.php */
|
||||
24
system/language/english/unit_test_lang.php
Normal file
24
system/language/english/unit_test_lang.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
$lang['ut_test_name'] = 'Test Name';
|
||||
$lang['ut_test_datatype'] = 'Test Datatype';
|
||||
$lang['ut_res_datatype'] = 'Expected Datatype';
|
||||
$lang['ut_result'] = 'Result';
|
||||
$lang['ut_undefined'] = 'Undefined Test Name';
|
||||
$lang['ut_file'] = 'File Name';
|
||||
$lang['ut_line'] = 'Line Number';
|
||||
$lang['ut_passed'] = 'Passed';
|
||||
$lang['ut_failed'] = 'Failed';
|
||||
$lang['ut_boolean'] = 'Boolean';
|
||||
$lang['ut_integer'] = 'Integer';
|
||||
$lang['ut_float'] = 'Float';
|
||||
$lang['ut_double'] = 'Float'; // can be the same as float
|
||||
$lang['ut_string'] = 'String';
|
||||
$lang['ut_array'] = 'Array';
|
||||
$lang['ut_object'] = 'Object';
|
||||
$lang['ut_resource'] = 'Resource';
|
||||
$lang['ut_null'] = 'Null';
|
||||
|
||||
|
||||
/* End of file unit_test_lang.php */
|
||||
/* Location: ./system/language/english/unit_test_lang.php */
|
||||
22
system/language/english/upload_lang.php
Normal file
22
system/language/english/upload_lang.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
$lang['upload_userfile_not_set'] = "Unable to find a post variable called userfile.";
|
||||
$lang['upload_file_exceeds_limit'] = "The uploaded file exceeds the maximum allowed size in your PHP configuration file.";
|
||||
$lang['upload_file_exceeds_form_limit'] = "The uploaded file exceeds the maximum size allowed by the submission form.";
|
||||
$lang['upload_file_partial'] = "The file was only partially uploaded.";
|
||||
$lang['upload_no_temp_directory'] = "The temporary folder is missing.";
|
||||
$lang['upload_unable_to_write_file'] = "The file could not be written to disk.";
|
||||
$lang['upload_stopped_by_extension'] = "The file upload was stopped by extension.";
|
||||
$lang['upload_no_file_selected'] = "You did not select a file to upload.";
|
||||
$lang['upload_invalid_filetype'] = "The filetype you are attempting to upload is not allowed.";
|
||||
$lang['upload_invalid_filesize'] = "The file you are attempting to upload is larger than the permitted size.";
|
||||
$lang['upload_invalid_dimensions'] = "The image you are attempting to upload exceedes the maximum height or width.";
|
||||
$lang['upload_destination_error'] = "A problem was encountered while attempting to move the uploaded file to the final destination.";
|
||||
$lang['upload_no_filepath'] = "The upload path does not appear to be valid.";
|
||||
$lang['upload_no_file_types'] = "You have not specified any allowed file types.";
|
||||
$lang['upload_bad_filename'] = "The file name you submitted already exists on the server.";
|
||||
$lang['upload_not_writable'] = "The upload destination folder does not appear to be writable.";
|
||||
|
||||
|
||||
/* End of file upload_lang.php */
|
||||
/* Location: ./system/language/english/upload_lang.php */
|
||||
24
system/language/english/validation_lang.php
Normal file
24
system/language/english/validation_lang.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
$lang['required'] = "The %s field is required.";
|
||||
$lang['isset'] = "The %s field must have a value.";
|
||||
$lang['valid_email'] = "The %s field must contain a valid email address.";
|
||||
$lang['valid_emails'] = "The %s field must contain all valid email addresses.";
|
||||
$lang['valid_url'] = "The %s field must contain a valid URL.";
|
||||
$lang['valid_ip'] = "The %s field must contain a valid IP.";
|
||||
$lang['min_length'] = "The %s field must be at least %s characters in length.";
|
||||
$lang['max_length'] = "The %s field can not exceed %s characters in length.";
|
||||
$lang['exact_length'] = "The %s field must be exactly %s characters in length.";
|
||||
$lang['alpha'] = "The %s field may only contain alphabetical characters.";
|
||||
$lang['alpha_numeric'] = "The %s field may only contain alpha-numeric characters.";
|
||||
$lang['alpha_dash'] = "The %s field may only contain alpha-numeric characters, underscores, and dashes.";
|
||||
$lang['numeric'] = "The %s field must contain a number.";
|
||||
$lang['is_numeric'] = "The %s field must contain a number.";
|
||||
$lang['integer'] = "The %s field must contain an integer.";
|
||||
$lang['matches'] = "The %s field does not match the %s field.";
|
||||
$lang['is_natural'] = "The %s field must contain a number.";
|
||||
$lang['is_natural_no_zero'] = "The %s field must contain a number greater than zero.";
|
||||
|
||||
|
||||
/* End of file validation_lang.php */
|
||||
/* Location: ./system/language/english/validation_lang.php */
|
||||
10
system/language/index.html
Normal file
10
system/language/index.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
51
system/language/indonesia/calendar_lang.php
Normal file
51
system/language/indonesia/calendar_lang.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
$lang['cal_su'] = "Su";
|
||||
$lang['cal_mo'] = "Mo";
|
||||
$lang['cal_tu'] = "Tu";
|
||||
$lang['cal_we'] = "We";
|
||||
$lang['cal_th'] = "Th";
|
||||
$lang['cal_fr'] = "Fr";
|
||||
$lang['cal_sa'] = "Sa";
|
||||
$lang['cal_sun'] = "Sun";
|
||||
$lang['cal_mon'] = "Mon";
|
||||
$lang['cal_tue'] = "Tue";
|
||||
$lang['cal_wed'] = "Wed";
|
||||
$lang['cal_thu'] = "Thu";
|
||||
$lang['cal_fri'] = "Fri";
|
||||
$lang['cal_sat'] = "Sat";
|
||||
$lang['cal_sunday'] = "Sunday";
|
||||
$lang['cal_monday'] = "Monday";
|
||||
$lang['cal_tuesday'] = "Tuesday";
|
||||
$lang['cal_wednesday'] = "Wednesday";
|
||||
$lang['cal_thursday'] = "Thursday";
|
||||
$lang['cal_friday'] = "Friday";
|
||||
$lang['cal_saturday'] = "Saturday";
|
||||
$lang['cal_jan'] = "Jan";
|
||||
$lang['cal_feb'] = "Feb";
|
||||
$lang['cal_mar'] = "Mar";
|
||||
$lang['cal_apr'] = "Apr";
|
||||
$lang['cal_may'] = "May";
|
||||
$lang['cal_jun'] = "Jun";
|
||||
$lang['cal_jul'] = "Jul";
|
||||
$lang['cal_aug'] = "Aug";
|
||||
$lang['cal_sep'] = "Sep";
|
||||
$lang['cal_oct'] = "Oct";
|
||||
$lang['cal_nov'] = "Nov";
|
||||
$lang['cal_dec'] = "Dec";
|
||||
$lang['cal_january'] = "January";
|
||||
$lang['cal_february'] = "February";
|
||||
$lang['cal_march'] = "March";
|
||||
$lang['cal_april'] = "April";
|
||||
$lang['cal_mayl'] = "May";
|
||||
$lang['cal_june'] = "June";
|
||||
$lang['cal_july'] = "July";
|
||||
$lang['cal_august'] = "August";
|
||||
$lang['cal_september'] = "September";
|
||||
$lang['cal_october'] = "October";
|
||||
$lang['cal_november'] = "November";
|
||||
$lang['cal_december'] = "December";
|
||||
|
||||
|
||||
/* End of file calendar_lang.php */
|
||||
/* Location: ./system/language/english/calendar_lang.php */
|
||||
60
system/language/indonesia/date_lang.php
Normal file
60
system/language/indonesia/date_lang.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
$lang['date_year'] = "Year";
|
||||
$lang['date_years'] = "Years";
|
||||
$lang['date_month'] = "Month";
|
||||
$lang['date_months'] = "Months";
|
||||
$lang['date_week'] = "Week";
|
||||
$lang['date_weeks'] = "Weeks";
|
||||
$lang['date_day'] = "Day";
|
||||
$lang['date_days'] = "Days";
|
||||
$lang['date_hour'] = "Hour";
|
||||
$lang['date_hours'] = "Hours";
|
||||
$lang['date_minute'] = "Minute";
|
||||
$lang['date_minutes'] = "Minutes";
|
||||
$lang['date_second'] = "Second";
|
||||
$lang['date_seconds'] = "Seconds";
|
||||
|
||||
$lang['UM12'] = '(UTC -12:00) Baker/Howland Island';
|
||||
$lang['UM11'] = '(UTC -11:00) Samoa Time Zone, Niue';
|
||||
$lang['UM10'] = '(UTC -10:00) Hawaii-Aleutian Standard Time, Cook Islands, Tahiti';
|
||||
$lang['UM95'] = '(UTC -9:30) Marquesas Islands';
|
||||
$lang['UM9'] = '(UTC -9:00) Alaska Standard Time, Gambier Islands';
|
||||
$lang['UM8'] = '(UTC -8:00) Pacific Standard Time, Clipperton Island';
|
||||
$lang['UM7'] = '(UTC -7:00) Mountain Standard Time';
|
||||
$lang['UM6'] = '(UTC -6:00) Central Standard Time';
|
||||
$lang['UM5'] = '(UTC -5:00) Eastern Standard Time, Western Caribbean Standard Time';
|
||||
$lang['UM45'] = '(UTC -4:30) Venezuelan Standard Time';
|
||||
$lang['UM4'] = '(UTC -4:00) Atlantic Standard Time, Eastern Caribbean Standard Time';
|
||||
$lang['UM35'] = '(UTC -3:30) Newfoundland Standard Time';
|
||||
$lang['UM3'] = '(UTC -3:00) Argentina, Brazil, French Guiana, Uruguay';
|
||||
$lang['UM2'] = '(UTC -2:00) South Georgia/South Sandwich Islands';
|
||||
$lang['UM1'] = '(UTC -1:00) Azores, Cape Verde Islands';
|
||||
$lang['UTC'] = '(UTC) Greenwich Mean Time, Western European Time';
|
||||
$lang['UP1'] = '(UTC +1:00) Central European Time, West Africa Time';
|
||||
$lang['UP2'] = '(UTC +2:00) Central Africa Time, Eastern European Time, Kaliningrad Time';
|
||||
$lang['UP3'] = '(UTC +3:00) Moscow Time, East Africa Time';
|
||||
$lang['UP35'] = '(UTC +3:30) Iran Standard Time';
|
||||
$lang['UP4'] = '(UTC +4:00) Azerbaijan Standard Time, Samara Time';
|
||||
$lang['UP45'] = '(UTC +4:30) Afghanistan';
|
||||
$lang['UP5'] = '(UTC +5:00) Pakistan Standard Time, Yekaterinburg Time';
|
||||
$lang['UP55'] = '(UTC +5:30) Indian Standard Time, Sri Lanka Time';
|
||||
$lang['UP575'] = '(UTC +5:45) Nepal Time';
|
||||
$lang['UP6'] = '(UTC +6:00) Bangladesh Standard Time, Bhutan Time, Omsk Time';
|
||||
$lang['UP65'] = '(UTC +6:30) Cocos Islands, Myanmar';
|
||||
$lang['UP7'] = '(UTC +7:00) Krasnoyarsk Time, Cambodia, Laos, Thailand, Vietnam';
|
||||
$lang['UP8'] = '(UTC +8:00) Australian Western Standard Time, Beijing Time, Irkutsk Time';
|
||||
$lang['UP875'] = '(UTC +8:45) Australian Central Western Standard Time';
|
||||
$lang['UP9'] = '(UTC +9:00) Japan Standard Time, Korea Standard Time, Yakutsk Time';
|
||||
$lang['UP95'] = '(UTC +9:30) Australian Central Standard Time';
|
||||
$lang['UP10'] = '(UTC +10:00) Australian Eastern Standard Time, Vladivostok Time';
|
||||
$lang['UP105'] = '(UTC +10:30) Lord Howe Island';
|
||||
$lang['UP11'] = '(UTC +11:00) Magadan Time, Solomon Islands, Vanuatu';
|
||||
$lang['UP115'] = '(UTC +11:30) Norfolk Island';
|
||||
$lang['UP12'] = '(UTC +12:00) Fiji, Gilbert Islands, Kamchatka Time, New Zealand Standard Time';
|
||||
$lang['UP1275'] = '(UTC +12:45) Chatham Islands Standard Time';
|
||||
$lang['UP13'] = '(UTC +13:00) Phoenix Islands Time, Tonga';
|
||||
$lang['UP14'] = '(UTC +14:00) Line Islands';
|
||||
|
||||
/* End of file date_lang.php */
|
||||
/* Location: ./system/language/english/date_lang.php */
|
||||
28
system/language/indonesia/db_lang.php
Normal file
28
system/language/indonesia/db_lang.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
$lang['db_invalid_connection_str'] = 'Unable to determine the database settings based on the connection string you submitted.';
|
||||
$lang['db_unable_to_connect'] = 'Unable to connect to your database server using the provided settings.';
|
||||
$lang['db_unable_to_select'] = 'Unable to select the specified database: %s';
|
||||
$lang['db_unable_to_create'] = 'Unable to create the specified database: %s';
|
||||
$lang['db_invalid_query'] = 'The query you submitted is not valid.';
|
||||
$lang['db_must_set_table'] = 'You must set the database table to be used with your query.';
|
||||
$lang['db_must_set_database'] = 'You must set the database name in your database config file.';
|
||||
$lang['db_must_use_set'] = 'You must use the "set" method to update an entry.';
|
||||
$lang['db_must_use_where'] = 'Updates are not allowed unless they contain a "where" clause.';
|
||||
$lang['db_del_must_use_where'] = 'Deletes are not allowed unless they contain a "where" or "like" clause.';
|
||||
$lang['db_field_param_missing'] = 'To fetch fields requires the name of the table as a parameter.';
|
||||
$lang['db_unsupported_function'] = 'This feature is not available for the database you are using.';
|
||||
$lang['db_transaction_failure'] = 'Transaction failure: Rollback performed.';
|
||||
$lang['db_unable_to_drop'] = 'Unable to drop the specified database.';
|
||||
$lang['db_unsuported_feature'] = 'Unsupported feature of the database platform you are using.';
|
||||
$lang['db_unsuported_compression'] = 'The file compression format you chose is not supported by your server.';
|
||||
$lang['db_filepath_error'] = 'Unable to write data to the file path you have submitted.';
|
||||
$lang['db_invalid_cache_path'] = 'The cache path you submitted is not valid or writable.';
|
||||
$lang['db_table_name_required'] = 'A table name is required for that operation.';
|
||||
$lang['db_column_name_required'] = 'A column name is required for that operation.';
|
||||
$lang['db_column_definition_required'] = 'A column definition is required for that operation.';
|
||||
$lang['db_unable_to_set_charset'] = 'Unable to set client connection character set: %s';
|
||||
$lang['db_error_heading'] = 'A Database Error Occurred';
|
||||
|
||||
/* End of file db_lang.php */
|
||||
/* Location: ./system/language/english/db_lang.php */
|
||||
24
system/language/indonesia/email_lang.php
Normal file
24
system/language/indonesia/email_lang.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
$lang['email_must_be_array'] = "The email validation method must be passed an array.";
|
||||
$lang['email_invalid_address'] = "Invalid email address: %s";
|
||||
$lang['email_attachment_missing'] = "Unable to locate the following email attachment: %s";
|
||||
$lang['email_attachment_unreadable'] = "Unable to open this attachment: %s";
|
||||
$lang['email_no_recipients'] = "You must include recipients: To, Cc, or Bcc";
|
||||
$lang['email_send_failure_phpmail'] = "Unable to send email using PHP mail(). Your server might not be configured to send mail using this method.";
|
||||
$lang['email_send_failure_sendmail'] = "Unable to send email using PHP Sendmail. Your server might not be configured to send mail using this method.";
|
||||
$lang['email_send_failure_smtp'] = "Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method.";
|
||||
$lang['email_sent'] = "Your message has been successfully sent using the following protocol: %s";
|
||||
$lang['email_no_socket'] = "Unable to open a socket to Sendmail. Please check settings.";
|
||||
$lang['email_no_hostname'] = "You did not specify a SMTP hostname.";
|
||||
$lang['email_smtp_error'] = "The following SMTP error was encountered: %s";
|
||||
$lang['email_no_smtp_unpw'] = "Error: You must assign a SMTP username and password.";
|
||||
$lang['email_failed_smtp_login'] = "Failed to send AUTH LOGIN command. Error: %s";
|
||||
$lang['email_smtp_auth_un'] = "Failed to authenticate username. Error: %s";
|
||||
$lang['email_smtp_auth_pw'] = "Failed to authenticate password. Error: %s";
|
||||
$lang['email_smtp_data_failure'] = "Unable to send data: %s";
|
||||
$lang['email_exit_status'] = "Exit status code: %s";
|
||||
|
||||
|
||||
/* End of file email_lang.php */
|
||||
/* Location: ./system/language/english/email_lang.php */
|
||||
24
system/language/indonesia/form_validation_lang.php
Normal file
24
system/language/indonesia/form_validation_lang.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
$lang['required'] = "The %s field is required.";
|
||||
$lang['isset'] = "The %s field must have a value.";
|
||||
$lang['valid_email'] = "The %s field must contain a valid email address.";
|
||||
$lang['valid_emails'] = "The %s field must contain all valid email addresses.";
|
||||
$lang['valid_url'] = "The %s field must contain a valid URL.";
|
||||
$lang['valid_ip'] = "The %s field must contain a valid IP.";
|
||||
$lang['min_length'] = "The %s field must be at least %s characters in length.";
|
||||
$lang['max_length'] = "The %s field can not exceed %s characters in length.";
|
||||
$lang['exact_length'] = "The %s field must be exactly %s characters in length.";
|
||||
$lang['alpha'] = "The %s field may only contain alphabetical characters.";
|
||||
$lang['alpha_numeric'] = "The %s field may only contain alpha-numeric characters.";
|
||||
$lang['alpha_dash'] = "The %s field may only contain alpha-numeric characters, underscores, and dashes.";
|
||||
$lang['numeric'] = "The %s field must contain only numbers.";
|
||||
$lang['is_numeric'] = "The %s field must contain only numeric characters.";
|
||||
$lang['integer'] = "The %s field must contain an integer.";
|
||||
$lang['matches'] = "The %s field does not match the %s field.";
|
||||
$lang['is_natural'] = "The %s field must contain only positive numbers.";
|
||||
$lang['is_natural_no_zero'] = "The %s field must contain a number greater than zero.";
|
||||
|
||||
|
||||
/* End of file form_validation_lang.php */
|
||||
/* Location: ./system/language/english/form_validation_lang.php */
|
||||
17
system/language/indonesia/ftp_lang.php
Normal file
17
system/language/indonesia/ftp_lang.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
$lang['ftp_no_connection'] = "Unable to locate a valid connection ID. Please make sure you are connected before peforming any file routines.";
|
||||
$lang['ftp_unable_to_connect'] = "Unable to connect to your FTP server using the supplied hostname.";
|
||||
$lang['ftp_unable_to_login'] = "Unable to login to your FTP server. Please check your username and password.";
|
||||
$lang['ftp_unable_to_makdir'] = "Unable to create the directory you have specified.";
|
||||
$lang['ftp_unable_to_changedir'] = "Unable to change directories.";
|
||||
$lang['ftp_unable_to_chmod'] = "Unable to set file permissions. Please check your path. Note: This feature is only available in PHP 5 or higher.";
|
||||
$lang['ftp_unable_to_upload'] = "Unable to upload the specified file. Please check your path.";
|
||||
$lang['ftp_no_source_file'] = "Unable to locate the source file. Please check your path.";
|
||||
$lang['ftp_unable_to_rename'] = "Unable to rename the file.";
|
||||
$lang['ftp_unable_to_delete'] = "Unable to delete the file.";
|
||||
$lang['ftp_unable_to_move'] = "Unable to move the file. Please make sure the destination directory exists.";
|
||||
|
||||
|
||||
/* End of file ftp_lang.php */
|
||||
/* Location: ./system/language/english/ftp_lang.php */
|
||||
24
system/language/indonesia/imglib_lang.php
Normal file
24
system/language/indonesia/imglib_lang.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
$lang['imglib_source_image_required'] = "You must specify a source image in your preferences.";
|
||||
$lang['imglib_gd_required'] = "The GD image library is required for this feature.";
|
||||
$lang['imglib_gd_required_for_props'] = "Your server must support the GD image library in order to determine the image properties.";
|
||||
$lang['imglib_unsupported_imagecreate'] = "Your server does not support the GD function required to process this type of image.";
|
||||
$lang['imglib_gif_not_supported'] = "GIF images are often not supported due to licensing restrictions. You may have to use JPG or PNG images instead.";
|
||||
$lang['imglib_jpg_not_supported'] = "JPG images are not supported.";
|
||||
$lang['imglib_png_not_supported'] = "PNG images are not supported.";
|
||||
$lang['imglib_jpg_or_png_required'] = "The image resize protocol specified in your preferences only works with JPEG or PNG image types.";
|
||||
$lang['imglib_copy_error'] = "An error was encountered while attempting to replace the file. Please make sure your file directory is writable.";
|
||||
$lang['imglib_rotate_unsupported'] = "Image rotation does not appear to be supported by your server.";
|
||||
$lang['imglib_libpath_invalid'] = "The path to your image library is not correct. Please set the correct path in your image preferences.";
|
||||
$lang['imglib_image_process_failed'] = "Image processing failed. Please verify that your server supports the chosen protocol and that the path to your image library is correct.";
|
||||
$lang['imglib_rotation_angle_required'] = "An angle of rotation is required to rotate the image.";
|
||||
$lang['imglib_writing_failed_gif'] = "GIF image.";
|
||||
$lang['imglib_invalid_path'] = "The path to the image is not correct.";
|
||||
$lang['imglib_copy_failed'] = "The image copy routine failed.";
|
||||
$lang['imglib_missing_font'] = "Unable to find a font to use.";
|
||||
$lang['imglib_save_failed'] = "Unable to save the image. Please make sure the image and file directory are writable.";
|
||||
|
||||
|
||||
/* End of file imglib_lang.php */
|
||||
/* Location: ./system/language/english/imglib_lang.php */
|
||||
10
system/language/indonesia/index.html
Normal file
10
system/language/indonesia/index.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
10
system/language/indonesia/number_lang.php
Normal file
10
system/language/indonesia/number_lang.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
$lang['terabyte_abbr'] = "TB";
|
||||
$lang['gigabyte_abbr'] = "GB";
|
||||
$lang['megabyte_abbr'] = "MB";
|
||||
$lang['kilobyte_abbr'] = "KB";
|
||||
$lang['bytes'] = "Bytes";
|
||||
|
||||
/* End of file number_lang.php */
|
||||
/* Location: ./system/language/english/number_lang.php */
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user