Initial commit
This commit is contained in:
commit
84d3b511a0
118
index.php
Normal file
118
index.php
Normal file
@ -0,0 +1,118 @@
|
||||
<?php
|
||||
/*
|
||||
|---------------------------------------------------------------
|
||||
| PHP ERROR REPORTING LEVEL
|
||||
|---------------------------------------------------------------
|
||||
|
|
||||
| By default CI runs with error reporting set to ALL. For security
|
||||
| reasons you are encouraged to change this when your site goes live.
|
||||
| For more info visit: http://www.php.net/error_reporting
|
||||
|
|
||||
*/
|
||||
error_reporting(E_ALL);
|
||||
|
||||
/*
|
||||
|---------------------------------------------------------------
|
||||
| SYSTEM FOLDER NAME
|
||||
|---------------------------------------------------------------
|
||||
|
|
||||
| This variable must contain the name of your "system" folder.
|
||||
| Include the path if the folder is not in the same directory
|
||||
| as this file.
|
||||
|
|
||||
| NO TRAILING SLASH!
|
||||
|
|
||||
*/
|
||||
$system_folder = "system";
|
||||
|
||||
/*
|
||||
|---------------------------------------------------------------
|
||||
| APPLICATION FOLDER NAME
|
||||
|---------------------------------------------------------------
|
||||
|
|
||||
| If you want this front controller to use a different "application"
|
||||
| folder then the default one you can set its name here. The folder
|
||||
| can also be renamed or relocated anywhere on your server.
|
||||
| For more info please see the user guide:
|
||||
| http://codeigniter.com/user_guide/general/managing_apps.html
|
||||
|
|
||||
|
|
||||
| NO TRAILING SLASH!
|
||||
|
|
||||
*/
|
||||
$application_folder = "application";
|
||||
|
||||
/*
|
||||
|===============================================================
|
||||
| END OF USER CONFIGURABLE SETTINGS
|
||||
|===============================================================
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
|---------------------------------------------------------------
|
||||
| SET THE SERVER PATH
|
||||
|---------------------------------------------------------------
|
||||
|
|
||||
| Let's attempt to determine the full-server path to the "system"
|
||||
| folder in order to reduce the possibility of path problems.
|
||||
| Note: We only attempt this if the user hasn't specified a
|
||||
| full server path.
|
||||
|
|
||||
*/
|
||||
if (strpos($system_folder, '/') === FALSE)
|
||||
{
|
||||
if (function_exists('realpath') AND @realpath(dirname(__FILE__)) !== FALSE)
|
||||
{
|
||||
$system_folder = realpath(dirname(__FILE__)).'/'.$system_folder;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Swap directory separators to Unix style for consistency
|
||||
$system_folder = str_replace("\\", "/", $system_folder);
|
||||
}
|
||||
|
||||
/*
|
||||
|---------------------------------------------------------------
|
||||
| DEFINE APPLICATION CONSTANTS
|
||||
|---------------------------------------------------------------
|
||||
|
|
||||
| EXT - The file extension. Typically ".php"
|
||||
| SELF - The name of THIS file (typically "index.php")
|
||||
| FCPATH - The full server path to THIS file
|
||||
| BASEPATH - The full server path to the "system" folder
|
||||
| APPPATH - The full server path to the "application" folder
|
||||
|
|
||||
*/
|
||||
define('EXT', '.php');
|
||||
define('SELF', pathinfo(__FILE__, PATHINFO_BASENAME));
|
||||
define('FCPATH', str_replace(SELF, '', __FILE__));
|
||||
define('BASEPATH', $system_folder.'/');
|
||||
|
||||
if (is_dir($application_folder))
|
||||
{
|
||||
define('APPPATH', $application_folder.'/');
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($application_folder == '')
|
||||
{
|
||||
$application_folder = 'application';
|
||||
}
|
||||
|
||||
define('APPPATH', BASEPATH.$application_folder.'/');
|
||||
}
|
||||
|
||||
/*
|
||||
|---------------------------------------------------------------
|
||||
| LOAD THE FRONT CONTROLLER
|
||||
|---------------------------------------------------------------
|
||||
|
|
||||
| And away we go...
|
||||
|
|
||||
*/
|
||||
require_once BASEPATH.'codeigniter/CodeIgniter'.EXT;
|
||||
|
||||
/* End of file index.php */
|
||||
/* Location: ./index.php */
|
52
license.txt
Normal file
52
license.txt
Normal file
@ -0,0 +1,52 @@
|
||||
Copyright (c) 2008 - 2010, EllisLab, Inc.
|
||||
All rights reserved.
|
||||
|
||||
This license is a legal agreement between you and EllisLab Inc. for the use
|
||||
of CodeIgniter Software (the "Software"). By obtaining the Software you
|
||||
agree to comply with the terms and conditions of this license.
|
||||
|
||||
PERMITTED USE
|
||||
You are permitted to use, copy, modify, and distribute the Software and its
|
||||
documentation, with or without modification, for any purpose, provided that
|
||||
the following conditions are met:
|
||||
|
||||
1. A copy of this license agreement must be included with the distribution.
|
||||
|
||||
2. Redistributions of source code must retain the above copyright notice in
|
||||
all source code files.
|
||||
|
||||
3. Redistributions in binary form must reproduce the above copyright notice
|
||||
in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
4. Any files that have been modified must carry notices stating the nature
|
||||
of the change and the names of those who changed them.
|
||||
|
||||
5. Products derived from the Software must include an acknowledgment that
|
||||
they are derived from CodeIgniter in their documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
6. Products derived from the Software may not be called "CodeIgniter",
|
||||
nor may "CodeIgniter" appear in their name, without prior written
|
||||
permission from EllisLab, Inc.
|
||||
|
||||
|
||||
INDEMNITY
|
||||
You agree to indemnify and hold harmless the authors of the Software and
|
||||
any contributors for any direct, indirect, incidental, or consequential
|
||||
third-party claims, actions or suits, as well as any related expenses,
|
||||
liabilities, damages, settlements or fees arising from your use or misuse
|
||||
of the Software, or a violation of any terms of this license.
|
||||
|
||||
DISCLAIMER OF WARRANTY
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESSED OR
|
||||
IMPLIED, INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF QUALITY, PERFORMANCE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
LIMITATIONS OF LIABILITY
|
||||
YOU ASSUME ALL RISK ASSOCIATED WITH THE INSTALLATION AND USE OF THE SOFTWARE.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS OF THE SOFTWARE BE LIABLE
|
||||
FOR CLAIMS, DAMAGES OR OTHER LIABILITY ARISING FROM, OUT OF, OR IN CONNECTION
|
||||
WITH THE SOFTWARE. LICENSE HOLDERS ARE SOLELY RESPONSIBLE FOR DETERMINING THE
|
||||
APPROPRIATENESS OF USE AND ASSUME ALL RISKS ASSOCIATED WITH ITS USE, INCLUDING
|
||||
BUT NOT LIMITED TO THE RISKS OF PROGRAM ERRORS, DAMAGE TO EQUIPMENT, LOSS OF
|
||||
DATA OR SOFTWARE PROGRAMS, OR UNAVAILABILITY OR INTERRUPTION OF OPERATIONS.
|
14
system/application/config/Dynect_API.php
Normal file
14
system/application/config/Dynect_API.php
Normal file
@ -0,0 +1,14 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| DYNECT API LOGIN INFO
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Enter your Dynect API login info here.
|
||||
|
|
||||
$config['customer_name'] = 'demo-pagely';
|
||||
$config['user_name'] = 'jstrebel';
|
||||
$config['password'] = '1234test';
|
||||
|
||||
*/
|
116
system/application/config/autoload.php
Normal file
116
system/application/config/autoload.php
Normal file
@ -0,0 +1,116 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/*
|
||||
| -------------------------------------------------------------------
|
||||
| AUTO-LOADER
|
||||
| -------------------------------------------------------------------
|
||||
| This file specifies which systems should be loaded by default.
|
||||
|
|
||||
| In order to keep the framework as light-weight as possible only the
|
||||
| absolute minimal resources are loaded by default. For example,
|
||||
| the database is not connected to automatically since no assumption
|
||||
| is made regarding whether you intend to use it. This file lets
|
||||
| you globally define which systems you would like loaded with every
|
||||
| request.
|
||||
|
|
||||
| -------------------------------------------------------------------
|
||||
| Instructions
|
||||
| -------------------------------------------------------------------
|
||||
|
|
||||
| These are the things you can load automatically:
|
||||
|
|
||||
| 1. Libraries
|
||||
| 2. Helper files
|
||||
| 3. Plugins
|
||||
| 4. Custom config files
|
||||
| 5. Language files
|
||||
| 6. Models
|
||||
|
|
||||
*/
|
||||
|
||||
/*
|
||||
| -------------------------------------------------------------------
|
||||
| Auto-load Libraries
|
||||
| -------------------------------------------------------------------
|
||||
| These are the classes located in the system/libraries folder
|
||||
| or in your system/application/libraries folder.
|
||||
|
|
||||
| Prototype:
|
||||
|
|
||||
| $autoload['libraries'] = array('database', 'session', 'xmlrpc');
|
||||
*/
|
||||
|
||||
$autoload['libraries'] = array();
|
||||
|
||||
|
||||
/*
|
||||
| -------------------------------------------------------------------
|
||||
| Auto-load Helper Files
|
||||
| -------------------------------------------------------------------
|
||||
| Prototype:
|
||||
|
|
||||
| $autoload['helper'] = array('url', 'file');
|
||||
*/
|
||||
|
||||
$autoload['helper'] = array();
|
||||
|
||||
|
||||
/*
|
||||
| -------------------------------------------------------------------
|
||||
| Auto-load Plugins
|
||||
| -------------------------------------------------------------------
|
||||
| Prototype:
|
||||
|
|
||||
| $autoload['plugin'] = array('captcha', 'js_calendar');
|
||||
*/
|
||||
|
||||
$autoload['plugin'] = array();
|
||||
|
||||
|
||||
/*
|
||||
| -------------------------------------------------------------------
|
||||
| Auto-load Config files
|
||||
| -------------------------------------------------------------------
|
||||
| Prototype:
|
||||
|
|
||||
| $autoload['config'] = array('config1', 'config2');
|
||||
|
|
||||
| NOTE: This item is intended for use ONLY if you have created custom
|
||||
| config files. Otherwise, leave it blank.
|
||||
|
|
||||
*/
|
||||
|
||||
$autoload['config'] = array();
|
||||
|
||||
|
||||
/*
|
||||
| -------------------------------------------------------------------
|
||||
| Auto-load Language files
|
||||
| -------------------------------------------------------------------
|
||||
| Prototype:
|
||||
|
|
||||
| $autoload['language'] = array('lang1', 'lang2');
|
||||
|
|
||||
| NOTE: Do not include the "_lang" part of your file. For example
|
||||
| "codeigniter_lang.php" would be referenced as array('codeigniter');
|
||||
|
|
||||
*/
|
||||
|
||||
$autoload['language'] = array();
|
||||
|
||||
|
||||
/*
|
||||
| -------------------------------------------------------------------
|
||||
| Auto-load Models
|
||||
| -------------------------------------------------------------------
|
||||
| Prototype:
|
||||
|
|
||||
| $autoload['model'] = array('model1', 'model2');
|
||||
|
|
||||
*/
|
||||
|
||||
$autoload['model'] = array();
|
||||
|
||||
|
||||
|
||||
/* End of file autoload.php */
|
||||
/* Location: ./system/application/config/autoload.php */
|
329
system/application/config/config.php
Normal file
329
system/application/config/config.php
Normal file
@ -0,0 +1,329 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Base Site URL
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| URL to your CodeIgniter root. Typically this will be your base URL,
|
||||
| WITH a trailing slash:
|
||||
|
|
||||
| http://example.com/
|
||||
|
|
||||
*/
|
||||
$config['base_url'] = "http://example.com/";
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Index File
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Typically this will be your index.php file, unless you've renamed it to
|
||||
| something else. If you are using mod_rewrite to remove the page set this
|
||||
| variable so that it is blank.
|
||||
|
|
||||
*/
|
||||
$config['index_page'] = "index.php";
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| URI PROTOCOL
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This item determines which server global should be used to retrieve the
|
||||
| URI string. The default setting of "AUTO" works for most servers.
|
||||
| If your links do not seem to work, try one of the other delicious flavors:
|
||||
|
|
||||
| 'AUTO' Default - auto detects
|
||||
| 'PATH_INFO' Uses the PATH_INFO
|
||||
| 'QUERY_STRING' Uses the QUERY_STRING
|
||||
| 'REQUEST_URI' Uses the REQUEST_URI
|
||||
| 'ORIG_PATH_INFO' Uses the ORIG_PATH_INFO
|
||||
|
|
||||
*/
|
||||
$config['uri_protocol'] = "AUTO";
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| URL suffix
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option allows you to add a suffix to all URLs generated by CodeIgniter.
|
||||
| For more information please see the user guide:
|
||||
|
|
||||
| http://codeigniter.com/user_guide/general/urls.html
|
||||
*/
|
||||
|
||||
$config['url_suffix'] = "";
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Language
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This determines which set of language files should be used. Make sure
|
||||
| there is an available translation if you intend to use something other
|
||||
| than english.
|
||||
|
|
||||
*/
|
||||
$config['language'] = "english";
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Character Set
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This determines which character set is used by default in various methods
|
||||
| that require a character set to be provided.
|
||||
|
|
||||
*/
|
||||
$config['charset'] = "UTF-8";
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Enable/Disable System Hooks
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| If you would like to use the "hooks" feature you must enable it by
|
||||
| setting this variable to TRUE (boolean). See the user guide for details.
|
||||
|
|
||||
*/
|
||||
$config['enable_hooks'] = FALSE;
|
||||
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Class Extension Prefix
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This item allows you to set the filename/classname prefix when extending
|
||||
| native libraries. For more information please see the user guide:
|
||||
|
|
||||
| http://codeigniter.com/user_guide/general/core_classes.html
|
||||
| http://codeigniter.com/user_guide/general/creating_libraries.html
|
||||
|
|
||||
*/
|
||||
$config['subclass_prefix'] = 'MY_';
|
||||
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Allowed URL Characters
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This lets you specify with a regular expression which characters are permitted
|
||||
| within your URLs. When someone tries to submit a URL with disallowed
|
||||
| characters they will get a warning message.
|
||||
|
|
||||
| As a security measure you are STRONGLY encouraged to restrict URLs to
|
||||
| as few characters as possible. By default only these are allowed: a-z 0-9~%.:_-
|
||||
|
|
||||
| Leave blank to allow all characters -- but only if you are insane.
|
||||
|
|
||||
| DO NOT CHANGE THIS UNLESS YOU FULLY UNDERSTAND THE REPERCUSSIONS!!
|
||||
|
|
||||
*/
|
||||
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-';
|
||||
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Enable Query Strings
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| By default CodeIgniter uses search-engine friendly segment based URLs:
|
||||
| example.com/who/what/where/
|
||||
|
|
||||
| You can optionally enable standard query string based URLs:
|
||||
| example.com?who=me&what=something&where=here
|
||||
|
|
||||
| Options are: TRUE or FALSE (boolean)
|
||||
|
|
||||
| The other items let you set the query string "words" that will
|
||||
| invoke your controllers and its functions:
|
||||
| example.com/index.php?c=controller&m=function
|
||||
|
|
||||
| Please note that some of the helpers won't work as expected when
|
||||
| this feature is enabled, since CodeIgniter is designed primarily to
|
||||
| use segment based URLs.
|
||||
|
|
||||
*/
|
||||
$config['enable_query_strings'] = FALSE;
|
||||
$config['controller_trigger'] = 'c';
|
||||
$config['function_trigger'] = 'm';
|
||||
$config['directory_trigger'] = 'd'; // experimental not currently in use
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Error Logging Threshold
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| If you have enabled error logging, you can set an error threshold to
|
||||
| determine what gets logged. Threshold options are:
|
||||
| You can enable error logging by setting a threshold over zero. The
|
||||
| threshold determines what gets logged. Threshold options are:
|
||||
|
|
||||
| 0 = Disables logging, Error logging TURNED OFF
|
||||
| 1 = Error Messages (including PHP errors)
|
||||
| 2 = Debug Messages
|
||||
| 3 = Informational Messages
|
||||
| 4 = All Messages
|
||||
|
|
||||
| For a live site you'll usually only enable Errors (1) to be logged otherwise
|
||||
| your log files will fill up very fast.
|
||||
|
|
||||
*/
|
||||
$config['log_threshold'] = 0;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Error Logging Directory Path
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Leave this BLANK unless you would like to set something other than the default
|
||||
| system/logs/ folder. Use a full server path with trailing slash.
|
||||
|
|
||||
*/
|
||||
$config['log_path'] = '';
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Date Format for Logs
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Each item that is logged has an associated date. You can use PHP date
|
||||
| codes to set your own date formatting
|
||||
|
|
||||
*/
|
||||
$config['log_date_format'] = 'Y-m-d H:i:s';
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Cache Directory Path
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Leave this BLANK unless you would like to set something other than the default
|
||||
| system/cache/ folder. Use a full server path with trailing slash.
|
||||
|
|
||||
*/
|
||||
$config['cache_path'] = '';
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Encryption Key
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| If you use the Encryption class or the Sessions class with encryption
|
||||
| enabled you MUST set an encryption key. See the user guide for info.
|
||||
|
|
||||
*/
|
||||
$config['encryption_key'] = "";
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Variables
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| 'session_cookie_name' = the name you want for the cookie
|
||||
| 'encrypt_sess_cookie' = TRUE/FALSE (boolean). Whether to encrypt the cookie
|
||||
| 'session_expiration' = the number of SECONDS you want the session to last.
|
||||
| by default sessions last 7200 seconds (two hours). Set to zero for no expiration.
|
||||
| 'time_to_update' = how many seconds between CI refreshing Session Information
|
||||
|
|
||||
*/
|
||||
$config['sess_cookie_name'] = 'ci_session';
|
||||
$config['sess_expiration'] = 7200;
|
||||
$config['sess_encrypt_cookie'] = FALSE;
|
||||
$config['sess_use_database'] = FALSE;
|
||||
$config['sess_table_name'] = 'ci_sessions';
|
||||
$config['sess_match_ip'] = FALSE;
|
||||
$config['sess_match_useragent'] = TRUE;
|
||||
$config['sess_time_to_update'] = 300;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Cookie Related Variables
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| 'cookie_prefix' = Set a prefix if you need to avoid collisions
|
||||
| 'cookie_domain' = Set to .your-domain.com for site-wide cookies
|
||||
| 'cookie_path' = Typically will be a forward slash
|
||||
|
|
||||
*/
|
||||
$config['cookie_prefix'] = "";
|
||||
$config['cookie_domain'] = "";
|
||||
$config['cookie_path'] = "/";
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Global XSS Filtering
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Determines whether the XSS filter is always active when GET, POST or
|
||||
| COOKIE data is encountered
|
||||
|
|
||||
*/
|
||||
$config['global_xss_filtering'] = FALSE;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Output Compression
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Enables Gzip output compression for faster page loads. When enabled,
|
||||
| the output class will test whether your server supports Gzip.
|
||||
| Even if it does, however, not all browsers support compression
|
||||
| so enable only if you are reasonably sure your visitors can handle it.
|
||||
|
|
||||
| VERY IMPORTANT: If you are getting a blank page when compression is enabled it
|
||||
| means you are prematurely outputting something to your browser. It could
|
||||
| even be a line of whitespace at the end of one of your scripts. For
|
||||
| compression to work, nothing can be sent before the output buffer is called
|
||||
| by the output class. Do not "echo" any values with compression enabled.
|
||||
|
|
||||
*/
|
||||
$config['compress_output'] = FALSE;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Master Time Reference
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Options are "local" or "gmt". This pref tells the system whether to use
|
||||
| your server's local time as the master "now" reference, or convert it to
|
||||
| GMT. See the "date helper" page of the user guide for information
|
||||
| regarding date handling.
|
||||
|
|
||||
*/
|
||||
$config['time_reference'] = 'local';
|
||||
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Rewrite PHP Short Tags
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| If your PHP installation does not have short tag support enabled CI
|
||||
| can rewrite the tags on-the-fly, enabling you to utilize that syntax
|
||||
| in your view files. Options are TRUE or FALSE (boolean)
|
||||
|
|
||||
*/
|
||||
$config['rewrite_short_tags'] = FALSE;
|
||||
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Reverse Proxy IPs
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| If your server is behind a reverse proxy, you must whitelist the proxy IP
|
||||
| addresses from which CodeIgniter should trust the HTTP_X_FORWARDED_FOR
|
||||
| header in order to properly identify the visitor's IP address.
|
||||
| Comma-delimited, e.g. '10.0.1.200,10.0.1.201'
|
||||
|
|
||||
*/
|
||||
$config['proxy_ips'] = '';
|
||||
|
||||
|
||||
/* End of file config.php */
|
||||
/* Location: ./system/application/config/config.php */
|
41
system/application/config/constants.php
Normal file
41
system/application/config/constants.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| File and Directory Modes
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| These prefs are used when checking and setting modes when working
|
||||
| with the file system. The defaults are fine on servers with proper
|
||||
| security, but you may wish (or even need) to change the values in
|
||||
| certain environments (Apache running a separate process for each
|
||||
| user, PHP under CGI with Apache suEXEC, etc.). Octal values should
|
||||
| always be used to set the mode correctly.
|
||||
|
|
||||
*/
|
||||
define('FILE_READ_MODE', 0644);
|
||||
define('FILE_WRITE_MODE', 0666);
|
||||
define('DIR_READ_MODE', 0755);
|
||||
define('DIR_WRITE_MODE', 0777);
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| File Stream Modes
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| These modes are used when working with fopen()/popen()
|
||||
|
|
||||
*/
|
||||
|
||||
define('FOPEN_READ', 'rb');
|
||||
define('FOPEN_READ_WRITE', 'r+b');
|
||||
define('FOPEN_WRITE_CREATE_DESTRUCTIVE', 'wb'); // truncates existing file data, use with care
|
||||
define('FOPEN_READ_WRITE_CREATE_DESTRUCTIVE', 'w+b'); // truncates existing file data, use with care
|
||||
define('FOPEN_WRITE_CREATE', 'ab');
|
||||
define('FOPEN_READ_WRITE_CREATE', 'a+b');
|
||||
define('FOPEN_WRITE_CREATE_STRICT', 'xb');
|
||||
define('FOPEN_READ_WRITE_CREATE_STRICT', 'x+b');
|
||||
|
||||
|
||||
/* End of file constants.php */
|
||||
/* Location: ./system/application/config/constants.php */
|
55
system/application/config/database.php
Normal file
55
system/application/config/database.php
Normal file
@ -0,0 +1,55 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/*
|
||||
| -------------------------------------------------------------------
|
||||
| DATABASE CONNECTIVITY SETTINGS
|
||||
| -------------------------------------------------------------------
|
||||
| This file will contain the settings needed to access your database.
|
||||
|
|
||||
| For complete instructions please consult the "Database Connection"
|
||||
| page of the User Guide.
|
||||
|
|
||||
| -------------------------------------------------------------------
|
||||
| EXPLANATION OF VARIABLES
|
||||
| -------------------------------------------------------------------
|
||||
|
|
||||
| ['hostname'] The hostname of your database server.
|
||||
| ['username'] The username used to connect to the database
|
||||
| ['password'] The password used to connect to the database
|
||||
| ['database'] The name of the database you want to connect to
|
||||
| ['dbdriver'] The database type. ie: mysql. Currently supported:
|
||||
mysql, mysqli, postgre, odbc, mssql, sqlite, oci8
|
||||
| ['dbprefix'] You can add an optional prefix, which will be added
|
||||
| to the table name when using the Active Record class
|
||||
| ['pconnect'] TRUE/FALSE - Whether to use a persistent connection
|
||||
| ['db_debug'] TRUE/FALSE - Whether database errors should be displayed.
|
||||
| ['cache_on'] TRUE/FALSE - Enables/disables query caching
|
||||
| ['cachedir'] The path to the folder where cache files should be stored
|
||||
| ['char_set'] The character set used in communicating with the database
|
||||
| ['dbcollat'] The character collation used in communicating with the database
|
||||
|
|
||||
| The $active_group variable lets you choose which connection group to
|
||||
| make active. By default there is only one group (the "default" group).
|
||||
|
|
||||
| The $active_record variables lets you determine whether or not to load
|
||||
| the active record class
|
||||
*/
|
||||
|
||||
$active_group = "default";
|
||||
$active_record = TRUE;
|
||||
|
||||
$db['default']['hostname'] = "localhost";
|
||||
$db['default']['username'] = "";
|
||||
$db['default']['password'] = "";
|
||||
$db['default']['database'] = "";
|
||||
$db['default']['dbdriver'] = "mysql";
|
||||
$db['default']['dbprefix'] = "";
|
||||
$db['default']['pconnect'] = TRUE;
|
||||
$db['default']['db_debug'] = TRUE;
|
||||
$db['default']['cache_on'] = FALSE;
|
||||
$db['default']['cachedir'] = "";
|
||||
$db['default']['char_set'] = "utf8";
|
||||
$db['default']['dbcollat'] = "utf8_general_ci";
|
||||
|
||||
|
||||
/* End of file database.php */
|
||||
/* Location: ./system/application/config/database.php */
|
15
system/application/config/doctypes.php
Normal file
15
system/application/config/doctypes.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
$_doctypes = array(
|
||||
'xhtml11' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">',
|
||||
'xhtml1-strict' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">',
|
||||
'xhtml1-trans' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">',
|
||||
'xhtml1-frame' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">',
|
||||
'html5' => '<!DOCTYPE html>',
|
||||
'html4-strict' => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">',
|
||||
'html4-trans' => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">',
|
||||
'html4-frame' => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">'
|
||||
);
|
||||
|
||||
/* End of file doctypes.php */
|
||||
/* Location: application/config/doctypes.php */
|
14
system/application/config/dynect_api.php
Normal file
14
system/application/config/dynect_api.php
Normal file
@ -0,0 +1,14 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| DYNECT API LOGIN INFO
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Enter your Dynect API login info here.
|
||||
|
|
||||
*/
|
||||
$config['customer_name'] = 'demo-pagely';
|
||||
$config['user_name'] = 'jstrebel';
|
||||
$config['password'] = '1234test';
|
||||
|
16
system/application/config/hooks.php
Normal file
16
system/application/config/hooks.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/*
|
||||
| -------------------------------------------------------------------------
|
||||
| Hooks
|
||||
| -------------------------------------------------------------------------
|
||||
| This file lets you define "hooks" to extend CI without hacking the core
|
||||
| files. Please see the user guide for info:
|
||||
|
|
||||
| http://codeigniter.com/user_guide/general/hooks.html
|
||||
|
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/* End of file hooks.php */
|
||||
/* Location: ./system/application/config/hooks.php */
|
10
system/application/config/index.html
Normal file
10
system/application/config/index.html
Normal file
@ -0,0 +1,10 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
105
system/application/config/mimes.php
Normal file
105
system/application/config/mimes.php
Normal file
@ -0,0 +1,105 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/*
|
||||
| -------------------------------------------------------------------
|
||||
| MIME TYPES
|
||||
| -------------------------------------------------------------------
|
||||
| This file contains an array of mime types. It is used by the
|
||||
| Upload class to help identify allowed file types.
|
||||
|
|
||||
*/
|
||||
|
||||
$mimes = array( 'hqx' => 'application/mac-binhex40',
|
||||
'cpt' => 'application/mac-compactpro',
|
||||
'csv' => array('text/x-comma-separated-values', 'text/comma-separated-values', 'application/octet-stream', 'application/vnd.ms-excel', 'text/csv', 'application/csv', 'application/excel', 'application/vnd.msexcel'),
|
||||
'bin' => 'application/macbinary',
|
||||
'dms' => 'application/octet-stream',
|
||||
'lha' => 'application/octet-stream',
|
||||
'lzh' => 'application/octet-stream',
|
||||
'exe' => 'application/octet-stream',
|
||||
'class' => 'application/octet-stream',
|
||||
'psd' => 'application/x-photoshop',
|
||||
'so' => 'application/octet-stream',
|
||||
'sea' => 'application/octet-stream',
|
||||
'dll' => 'application/octet-stream',
|
||||
'oda' => 'application/oda',
|
||||
'pdf' => array('application/pdf', 'application/x-download'),
|
||||
'ai' => 'application/postscript',
|
||||
'eps' => 'application/postscript',
|
||||
'ps' => 'application/postscript',
|
||||
'smi' => 'application/smil',
|
||||
'smil' => 'application/smil',
|
||||
'mif' => 'application/vnd.mif',
|
||||
'xls' => array('application/excel', 'application/vnd.ms-excel', 'application/msexcel'),
|
||||
'ppt' => array('application/powerpoint', 'application/vnd.ms-powerpoint'),
|
||||
'wbxml' => 'application/wbxml',
|
||||
'wmlc' => 'application/wmlc',
|
||||
'dcr' => 'application/x-director',
|
||||
'dir' => 'application/x-director',
|
||||
'dxr' => 'application/x-director',
|
||||
'dvi' => 'application/x-dvi',
|
||||
'gtar' => 'application/x-gtar',
|
||||
'gz' => 'application/x-gzip',
|
||||
'php' => 'application/x-httpd-php',
|
||||
'php4' => 'application/x-httpd-php',
|
||||
'php3' => 'application/x-httpd-php',
|
||||
'phtml' => 'application/x-httpd-php',
|
||||
'phps' => 'application/x-httpd-php-source',
|
||||
'js' => 'application/x-javascript',
|
||||
'swf' => 'application/x-shockwave-flash',
|
||||
'sit' => 'application/x-stuffit',
|
||||
'tar' => 'application/x-tar',
|
||||
'tgz' => 'application/x-tar',
|
||||
'xhtml' => 'application/xhtml+xml',
|
||||
'xht' => 'application/xhtml+xml',
|
||||
'zip' => array('application/x-zip', 'application/zip', 'application/x-zip-compressed'),
|
||||
'mid' => 'audio/midi',
|
||||
'midi' => 'audio/midi',
|
||||
'mpga' => 'audio/mpeg',
|
||||
'mp2' => 'audio/mpeg',
|
||||
'mp3' => array('audio/mpeg', 'audio/mpg'),
|
||||
'aif' => 'audio/x-aiff',
|
||||
'aiff' => 'audio/x-aiff',
|
||||
'aifc' => 'audio/x-aiff',
|
||||
'ram' => 'audio/x-pn-realaudio',
|
||||
'rm' => 'audio/x-pn-realaudio',
|
||||
'rpm' => 'audio/x-pn-realaudio-plugin',
|
||||
'ra' => 'audio/x-realaudio',
|
||||
'rv' => 'video/vnd.rn-realvideo',
|
||||
'wav' => 'audio/x-wav',
|
||||
'bmp' => 'image/bmp',
|
||||
'gif' => 'image/gif',
|
||||
'jpeg' => array('image/jpeg', 'image/pjpeg'),
|
||||
'jpg' => array('image/jpeg', 'image/pjpeg'),
|
||||
'jpe' => array('image/jpeg', 'image/pjpeg'),
|
||||
'png' => array('image/png', 'image/x-png'),
|
||||
'tiff' => 'image/tiff',
|
||||
'tif' => 'image/tiff',
|
||||
'css' => 'text/css',
|
||||
'html' => 'text/html',
|
||||
'htm' => 'text/html',
|
||||
'shtml' => 'text/html',
|
||||
'txt' => 'text/plain',
|
||||
'text' => 'text/plain',
|
||||
'log' => array('text/plain', 'text/x-log'),
|
||||
'rtx' => 'text/richtext',
|
||||
'rtf' => 'text/rtf',
|
||||
'xml' => 'text/xml',
|
||||
'xsl' => 'text/xml',
|
||||
'mpeg' => 'video/mpeg',
|
||||
'mpg' => 'video/mpeg',
|
||||
'mpe' => 'video/mpeg',
|
||||
'qt' => 'video/quicktime',
|
||||
'mov' => 'video/quicktime',
|
||||
'avi' => 'video/x-msvideo',
|
||||
'movie' => 'video/x-sgi-movie',
|
||||
'doc' => 'application/msword',
|
||||
'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
||||
'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
||||
'word' => array('application/msword', 'application/octet-stream'),
|
||||
'xl' => 'application/excel',
|
||||
'eml' => 'message/rfc822'
|
||||
);
|
||||
|
||||
|
||||
/* End of file mimes.php */
|
||||
/* Location: ./system/application/config/mimes.php */
|
71
system/application/config/postmark.php
Normal file
71
system/application/config/postmark.php
Normal file
@ -0,0 +1,71 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| POSTMARK API KEY
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Enter your Postmark API key here.
|
||||
|
|
||||
| This key is available by visiting your Postmark Rack, clicking 'Details'
|
||||
| next to the desiered server, then clicking 'Settings & API Credentials'
|
||||
|
|
||||
*/
|
||||
$config['api_key'] = '';
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| FROM NAME & FROM ADDRESS
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| These are optional settings
|
||||
|
|
||||
| If you're going to be using the same Sender Signature for all emails, it
|
||||
| might be easier to assign it here, than doing so with each individual
|
||||
| email. If you are not using this setting, comment it out.
|
||||
|
|
||||
| Configure your Sender Signatures at http://postmarkapp.com/signatures
|
||||
*/
|
||||
$config['from_name'] = 'Will Bradley';
|
||||
$config['from_address'] = 'bradley.will@gmail.com';
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| VALIDATION
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Setting validation to TRUE will require that you pass Postmark valid
|
||||
| email addresses for sender and reciever. If these are not valid email
|
||||
| addresses, the request to send an email will not be sent to Postmark.
|
||||
|
|
||||
| This is reccomended on high traffic servers
|
||||
|
|
||||
*/
|
||||
$config['validation'] = TRUE;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| STRIP_HTML
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Setting strip_tags to TRUE will strip all HTML tags from _plain_message
|
||||
| using PHP's strip_tags() function. It should be noted that the output
|
||||
| will probably be far from what you would expect.
|
||||
|
|
||||
| Experimental Feature
|
||||
|
|
||||
*/
|
||||
$config['strip_html'] = TRUE;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| DEVELOP
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Often when implementing your client library or when integrating an
|
||||
| existing library into your application you would want to send 'test'
|
||||
| emails that don't actually get delivered to the recipient. You just need
|
||||
| to know if your data is valid. You can do that by setting this to TRUE
|
||||
|
|
||||
*/
|
||||
$config['develop'] = TRUE;
|
48
system/application/config/routes.php
Normal file
48
system/application/config/routes.php
Normal file
@ -0,0 +1,48 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/*
|
||||
| -------------------------------------------------------------------------
|
||||
| URI ROUTING
|
||||
| -------------------------------------------------------------------------
|
||||
| This file lets you re-map URI requests to specific controller functions.
|
||||
|
|
||||
| Typically there is a one-to-one relationship between a URL string
|
||||
| and its corresponding controller class/method. The segments in a
|
||||
| URL normally follow this pattern:
|
||||
|
|
||||
| example.com/class/method/id/
|
||||
|
|
||||
| In some instances, however, you may want to remap this relationship
|
||||
| so that a different class/function is called than the one
|
||||
| corresponding to the URL.
|
||||
|
|
||||
| Please see the user guide for complete details:
|
||||
|
|
||||
| http://codeigniter.com/user_guide/general/routing.html
|
||||
|
|
||||
| -------------------------------------------------------------------------
|
||||
| RESERVED ROUTES
|
||||
| -------------------------------------------------------------------------
|
||||
|
|
||||
| There are two reserved routes:
|
||||
|
|
||||
| $route['default_controller'] = 'welcome';
|
||||
|
|
||||
| This route indicates which controller class should be loaded if the
|
||||
| URI contains no data. In the above example, the "welcome" class
|
||||
| would be loaded.
|
||||
|
|
||||
| $route['scaffolding_trigger'] = 'scaffolding';
|
||||
|
|
||||
| This route lets you set a "secret" word that will trigger the
|
||||
| scaffolding feature for added security. Note: Scaffolding must be
|
||||
| enabled in the controller in which you intend to use it. The reserved
|
||||
| routes must come before any wildcard or regular expression routes.
|
||||
|
|
||||
*/
|
||||
|
||||
$route['default_controller'] = "welcome";
|
||||
$route['scaffolding_trigger'] = "";
|
||||
|
||||
|
||||
/* End of file routes.php */
|
||||
/* Location: ./system/application/config/routes.php */
|
66
system/application/config/smileys.php
Normal file
66
system/application/config/smileys.php
Normal file
@ -0,0 +1,66 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/*
|
||||
| -------------------------------------------------------------------
|
||||
| SMILEYS
|
||||
| -------------------------------------------------------------------
|
||||
| This file contains an array of smileys for use with the emoticon helper.
|
||||
| Individual images can be used to replace multiple simileys. For example:
|
||||
| :-) and :) use the same image replacement.
|
||||
|
|
||||
| Please see user guide for more info:
|
||||
| http://codeigniter.com/user_guide/helpers/smiley_helper.html
|
||||
|
|
||||
*/
|
||||
|
||||
$smileys = array(
|
||||
|
||||
// smiley image name width height alt
|
||||
|
||||
':-)' => array('grin.gif', '19', '19', 'grin'),
|
||||
':lol:' => array('lol.gif', '19', '19', 'LOL'),
|
||||
':cheese:' => array('cheese.gif', '19', '19', 'cheese'),
|
||||
':)' => array('smile.gif', '19', '19', 'smile'),
|
||||
';-)' => array('wink.gif', '19', '19', 'wink'),
|
||||
';)' => array('wink.gif', '19', '19', 'wink'),
|
||||
':smirk:' => array('smirk.gif', '19', '19', 'smirk'),
|
||||
':roll:' => array('rolleyes.gif', '19', '19', 'rolleyes'),
|
||||
':-S' => array('confused.gif', '19', '19', 'confused'),
|
||||
':wow:' => array('surprise.gif', '19', '19', 'surprised'),
|
||||
':bug:' => array('bigsurprise.gif', '19', '19', 'big surprise'),
|
||||
':-P' => array('tongue_laugh.gif', '19', '19', 'tongue laugh'),
|
||||
'%-P' => array('tongue_rolleye.gif', '19', '19', 'tongue rolleye'),
|
||||
';-P' => array('tongue_wink.gif', '19', '19', 'tongue wink'),
|
||||
':P' => array('raspberry.gif', '19', '19', 'raspberry'),
|
||||
':blank:' => array('blank.gif', '19', '19', 'blank stare'),
|
||||
':long:' => array('longface.gif', '19', '19', 'long face'),
|
||||
':ohh:' => array('ohh.gif', '19', '19', 'ohh'),
|
||||
':grrr:' => array('grrr.gif', '19', '19', 'grrr'),
|
||||
':gulp:' => array('gulp.gif', '19', '19', 'gulp'),
|
||||
'8-/' => array('ohoh.gif', '19', '19', 'oh oh'),
|
||||
':down:' => array('downer.gif', '19', '19', 'downer'),
|
||||
':red:' => array('embarrassed.gif', '19', '19', 'red face'),
|
||||
':sick:' => array('sick.gif', '19', '19', 'sick'),
|
||||
':shut:' => array('shuteye.gif', '19', '19', 'shut eye'),
|
||||
':-/' => array('hmm.gif', '19', '19', 'hmmm'),
|
||||
'>:(' => array('mad.gif', '19', '19', 'mad'),
|
||||
':mad:' => array('mad.gif', '19', '19', 'mad'),
|
||||
'>:-(' => array('angry.gif', '19', '19', 'angry'),
|
||||
':angry:' => array('angry.gif', '19', '19', 'angry'),
|
||||
':zip:' => array('zip.gif', '19', '19', 'zipper'),
|
||||
':kiss:' => array('kiss.gif', '19', '19', 'kiss'),
|
||||
':ahhh:' => array('shock.gif', '19', '19', 'shock'),
|
||||
':coolsmile:' => array('shade_smile.gif', '19', '19', 'cool smile'),
|
||||
':coolsmirk:' => array('shade_smirk.gif', '19', '19', 'cool smirk'),
|
||||
':coolgrin:' => array('shade_grin.gif', '19', '19', 'cool grin'),
|
||||
':coolhmm:' => array('shade_hmm.gif', '19', '19', 'cool hmm'),
|
||||
':coolmad:' => array('shade_mad.gif', '19', '19', 'cool mad'),
|
||||
':coolcheese:' => array('shade_cheese.gif', '19', '19', 'cool cheese'),
|
||||
':vampire:' => array('vampire.gif', '19', '19', 'vampire'),
|
||||
':snake:' => array('snake.gif', '19', '19', 'snake'),
|
||||
':exclaim:' => array('exclaim.gif', '19', '19', 'excaim'),
|
||||
':question:' => array('question.gif', '19', '19', 'question') // no comma after last item
|
||||
|
||||
);
|
||||
|
||||
/* End of file smileys.php */
|
||||
/* Location: ./system/application/config/smileys.php */
|
175
system/application/config/user_agents.php
Normal file
175
system/application/config/user_agents.php
Normal file
@ -0,0 +1,175 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/*
|
||||
| -------------------------------------------------------------------
|
||||
| USER AGENT TYPES
|
||||
| -------------------------------------------------------------------
|
||||
| This file contains four arrays of user agent data. It is used by the
|
||||
| User Agent Class to help identify browser, platform, robot, and
|
||||
| mobile device data. The array keys are used to identify the device
|
||||
| and the array values are used to set the actual name of the item.
|
||||
|
|
||||
*/
|
||||
|
||||
$platforms = array (
|
||||
'windows nt 6.0' => 'Windows Longhorn',
|
||||
'windows nt 5.2' => 'Windows 2003',
|
||||
'windows nt 5.0' => 'Windows 2000',
|
||||
'windows nt 5.1' => 'Windows XP',
|
||||
'windows nt 4.0' => 'Windows NT 4.0',
|
||||
'winnt4.0' => 'Windows NT 4.0',
|
||||
'winnt 4.0' => 'Windows NT',
|
||||
'winnt' => 'Windows NT',
|
||||
'windows 98' => 'Windows 98',
|
||||
'win98' => 'Windows 98',
|
||||
'windows 95' => 'Windows 95',
|
||||
'win95' => 'Windows 95',
|
||||
'windows' => 'Unknown Windows OS',
|
||||
'os x' => 'Mac OS X',
|
||||
'ppc mac' => 'Power PC Mac',
|
||||
'freebsd' => 'FreeBSD',
|
||||
'ppc' => 'Macintosh',
|
||||
'linux' => 'Linux',
|
||||
'debian' => 'Debian',
|
||||
'sunos' => 'Sun Solaris',
|
||||
'beos' => 'BeOS',
|
||||
'apachebench' => 'ApacheBench',
|
||||
'aix' => 'AIX',
|
||||
'irix' => 'Irix',
|
||||
'osf' => 'DEC OSF',
|
||||
'hp-ux' => 'HP-UX',
|
||||
'netbsd' => 'NetBSD',
|
||||
'bsdi' => 'BSDi',
|
||||
'openbsd' => 'OpenBSD',
|
||||
'gnu' => 'GNU/Linux',
|
||||
'unix' => 'Unknown Unix OS'
|
||||
);
|
||||
|
||||
|
||||
// The order of this array should NOT be changed. Many browsers return
|
||||
// multiple browser types so we want to identify the sub-type first.
|
||||
$browsers = array(
|
||||
'Opera' => 'Opera',
|
||||
'MSIE' => 'Internet Explorer',
|
||||
'Internet Explorer' => 'Internet Explorer',
|
||||
'Shiira' => 'Shiira',
|
||||
'Firefox' => 'Firefox',
|
||||
'Chimera' => 'Chimera',
|
||||
'Phoenix' => 'Phoenix',
|
||||
'Firebird' => 'Firebird',
|
||||
'Camino' => 'Camino',
|
||||
'Netscape' => 'Netscape',
|
||||
'OmniWeb' => 'OmniWeb',
|
||||
'Safari' => 'Safari',
|
||||
'Mozilla' => 'Mozilla',
|
||||
'Konqueror' => 'Konqueror',
|
||||
'icab' => 'iCab',
|
||||
'Lynx' => 'Lynx',
|
||||
'Links' => 'Links',
|
||||
'hotjava' => 'HotJava',
|
||||
'amaya' => 'Amaya',
|
||||
'IBrowse' => 'IBrowse'
|
||||
);
|
||||
|
||||
$mobiles = array(
|
||||
// legacy array, old values commented out
|
||||
'mobileexplorer' => 'Mobile Explorer',
|
||||
// 'openwave' => 'Open Wave',
|
||||
// 'opera mini' => 'Opera Mini',
|
||||
// 'operamini' => 'Opera Mini',
|
||||
// 'elaine' => 'Palm',
|
||||
'palmsource' => 'Palm',
|
||||
// 'digital paths' => 'Palm',
|
||||
// 'avantgo' => 'Avantgo',
|
||||
// 'xiino' => 'Xiino',
|
||||
'palmscape' => 'Palmscape',
|
||||
// 'nokia' => 'Nokia',
|
||||
// 'ericsson' => 'Ericsson',
|
||||
// 'blackberry' => 'BlackBerry',
|
||||
// 'motorola' => 'Motorola'
|
||||
|
||||
// Phones and Manufacturers
|
||||
'motorola' => "Motorola",
|
||||
'nokia' => "Nokia",
|
||||
'palm' => "Palm",
|
||||
'iphone' => "Apple iPhone",
|
||||
'ipod' => "Apple iPod Touch",
|
||||
'sony' => "Sony Ericsson",
|
||||
'ericsson' => "Sony Ericsson",
|
||||
'blackberry' => "BlackBerry",
|
||||
'cocoon' => "O2 Cocoon",
|
||||
'blazer' => "Treo",
|
||||
'lg' => "LG",
|
||||
'amoi' => "Amoi",
|
||||
'xda' => "XDA",
|
||||
'mda' => "MDA",
|
||||
'vario' => "Vario",
|
||||
'htc' => "HTC",
|
||||
'samsung' => "Samsung",
|
||||
'sharp' => "Sharp",
|
||||
'sie-' => "Siemens",
|
||||
'alcatel' => "Alcatel",
|
||||
'benq' => "BenQ",
|
||||
'ipaq' => "HP iPaq",
|
||||
'mot-' => "Motorola",
|
||||
'playstation portable' => "PlayStation Portable",
|
||||
'hiptop' => "Danger Hiptop",
|
||||
'nec-' => "NEC",
|
||||
'panasonic' => "Panasonic",
|
||||
'philips' => "Philips",
|
||||
'sagem' => "Sagem",
|
||||
'sanyo' => "Sanyo",
|
||||
'spv' => "SPV",
|
||||
'zte' => "ZTE",
|
||||
'sendo' => "Sendo",
|
||||
|
||||
// Operating Systems
|
||||
'symbian' => "Symbian",
|
||||
'SymbianOS' => "SymbianOS",
|
||||
'elaine' => "Palm",
|
||||
'palm' => "Palm",
|
||||
'series60' => "Symbian S60",
|
||||
'windows ce' => "Windows CE",
|
||||
|
||||
// Browsers
|
||||
'obigo' => "Obigo",
|
||||
'netfront' => "Netfront Browser",
|
||||
'openwave' => "Openwave Browser",
|
||||
'mobilexplorer' => "Mobile Explorer",
|
||||
'operamini' => "Opera Mini",
|
||||
'opera mini' => "Opera Mini",
|
||||
|
||||
// Other
|
||||
'digital paths' => "Digital Paths",
|
||||
'avantgo' => "AvantGo",
|
||||
'xiino' => "Xiino",
|
||||
'novarra' => "Novarra Transcoder",
|
||||
'vodafone' => "Vodafone",
|
||||
'docomo' => "NTT DoCoMo",
|
||||
'o2' => "O2",
|
||||
|
||||
// Fallback
|
||||
'mobile' => "Generic Mobile",
|
||||
'wireless' => "Generic Mobile",
|
||||
'j2me' => "Generic Mobile",
|
||||
'midp' => "Generic Mobile",
|
||||
'cldc' => "Generic Mobile",
|
||||
'up.link' => "Generic Mobile",
|
||||
'up.browser' => "Generic Mobile",
|
||||
'smartphone' => "Generic Mobile",
|
||||
'cellphone' => "Generic Mobile"
|
||||
);
|
||||
|
||||
// There are hundreds of bots but these are the most common.
|
||||
$robots = array(
|
||||
'googlebot' => 'Googlebot',
|
||||
'msnbot' => 'MSNBot',
|
||||
'slurp' => 'Inktomi Slurp',
|
||||
'yahoo' => 'Yahoo',
|
||||
'askjeeves' => 'AskJeeves',
|
||||
'fastcrawler' => 'FastCrawler',
|
||||
'infoseek' => 'InfoSeek Robot 1.0',
|
||||
'lycos' => 'Lycos'
|
||||
);
|
||||
|
||||
/* End of file user_agents.php */
|
||||
/* Location: ./system/application/config/user_agents.php */
|
10
system/application/controllers/index.html
Normal file
10
system/application/controllers/index.html
Normal file
@ -0,0 +1,10 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
30
system/application/controllers/welcome.php
Normal file
30
system/application/controllers/welcome.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
class Welcome extends Controller {
|
||||
|
||||
function Welcome()
|
||||
{
|
||||
parent::Controller();
|
||||
}
|
||||
|
||||
function index()
|
||||
{
|
||||
$this->load->library('Dynect_API');
|
||||
$dyn = new Dynect_API();
|
||||
$dyn->login();
|
||||
// print_r($dyn->get_all_records('foobo.com','test.foobo.com'));
|
||||
// print_r($dyn->get_zones());
|
||||
print_r($dyn->create_zone("feebeetest1.com", "admin@feebeetest1.com", 3600));
|
||||
print_r($dyn->publish_zone("feebeetest1.com"));
|
||||
print_r($dyn->delete_zone("feebeetest1.com"));
|
||||
// print_r($dyn->get_records('A','foobo.com','test.foobo.com'));
|
||||
// print_r($dyn->create_record('A', 'feebeetest1.com', 'test.feebeetest1.com', array('address' => '127.0.0.1')));
|
||||
// print_r($dyn->delete_records('A', 'foobo.com', 'test.foobo.com'));
|
||||
|
||||
$dyn->logout();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/* End of file welcome.php */
|
||||
/* Location: ./system/application/controllers/welcome.php */
|
34
system/application/errors/error_404.php
Normal file
34
system/application/errors/error_404.php
Normal file
@ -0,0 +1,34 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>404 Page Not Found</title>
|
||||
<style type="text/css">
|
||||
|
||||
body {
|
||||
background-color: #fff;
|
||||
margin: 40px;
|
||||
font-family: Lucida Grande, Verdana, Sans-serif;
|
||||
font-size: 12px;
|
||||
color: #000;
|
||||
}
|
||||
|
||||
#content {
|
||||
border: #999 1px solid;
|
||||
background-color: #fff;
|
||||
padding: 20px 20px 12px 20px;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-weight: normal;
|
||||
font-size: 14px;
|
||||
color: #990000;
|
||||
margin: 0 0 4px 0;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="content">
|
||||
<h1><?php echo $heading; ?></h1>
|
||||
<?php echo $message; ?>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
34
system/application/errors/error_db.php
Normal file
34
system/application/errors/error_db.php
Normal file
@ -0,0 +1,34 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Database Error</title>
|
||||
<style type="text/css">
|
||||
|
||||
body {
|
||||
background-color: #fff;
|
||||
margin: 40px;
|
||||
font-family: Lucida Grande, Verdana, Sans-serif;
|
||||
font-size: 12px;
|
||||
color: #000;
|
||||
}
|
||||
|
||||
#content {
|
||||
border: #999 1px solid;
|
||||
background-color: #fff;
|
||||
padding: 20px 20px 12px 20px;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-weight: normal;
|
||||
font-size: 14px;
|
||||
color: #990000;
|
||||
margin: 0 0 4px 0;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="content">
|
||||
<h1><?php echo $heading; ?></h1>
|
||||
<?php echo $message; ?>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
34
system/application/errors/error_general.php
Normal file
34
system/application/errors/error_general.php
Normal file
@ -0,0 +1,34 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Error</title>
|
||||
<style type="text/css">
|
||||
|
||||
body {
|
||||
background-color: #fff;
|
||||
margin: 40px;
|
||||
font-family: Lucida Grande, Verdana, Sans-serif;
|
||||
font-size: 12px;
|
||||
color: #000;
|
||||
}
|
||||
|
||||
#content {
|
||||
border: #999 1px solid;
|
||||
background-color: #fff;
|
||||
padding: 20px 20px 12px 20px;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-weight: normal;
|
||||
font-size: 14px;
|
||||
color: #990000;
|
||||
margin: 0 0 4px 0;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="content">
|
||||
<h1><?php echo $heading; ?></h1>
|
||||
<?php echo $message; ?>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
10
system/application/errors/error_php.php
Normal file
10
system/application/errors/error_php.php
Normal file
@ -0,0 +1,10 @@
|
||||
<div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;">
|
||||
|
||||
<h4>A PHP Error was encountered</h4>
|
||||
|
||||
<p>Severity: <?php echo $severity; ?></p>
|
||||
<p>Message: <?php echo $message; ?></p>
|
||||
<p>Filename: <?php echo $filepath; ?></p>
|
||||
<p>Line Number: <?php echo $line; ?></p>
|
||||
|
||||
</div>
|
10
system/application/errors/index.html
Normal file
10
system/application/errors/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/application/helpers/index.html
Normal file
10
system/application/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>
|
10
system/application/hooks/index.html
Normal file
10
system/application/hooks/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/application/index.html
Normal file
10
system/application/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/application/language/english/index.html
Normal file
10
system/application/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>
|
428
system/application/libraries/Dynect_API.php
Normal file
428
system/application/libraries/Dynect_API.php
Normal file
@ -0,0 +1,428 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Dynect API SOAP Library
|
||||
*
|
||||
* Interfaces with the Dynect DNS service to query and modfiy DNS records.
|
||||
*
|
||||
* @category Libraries
|
||||
* @author Will Bradley, based on Dynect API examples.
|
||||
* @link http://www.zyphon.com
|
||||
*/
|
||||
|
||||
class Dynect_API {
|
||||
|
||||
//private
|
||||
var $CI;
|
||||
var $base_url = 'https://api2.dynect.net/wsdl/2.0.0/Dynect.wsdl'; // The Base Dynect API2 URL
|
||||
var $client; // The SOAP client
|
||||
var $token; // Dynect login token
|
||||
var $user_name = 'jstrebel'; // set by config
|
||||
var $customer_name = 'demo-pagely'; // set by config
|
||||
var $password = '1234test'; // set by config
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function Dynect_API() {
|
||||
$this->CI =& get_instance();
|
||||
|
||||
$this->client = new SoapClient($this->base_url, array('cache_wsdl' => 0)); //Connect to the WSDL
|
||||
|
||||
log_message('debug', 'Dynect_API Class Initialized');
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
|
||||
function login() {
|
||||
|
||||
/* ##########################
|
||||
|
||||
Logging In
|
||||
------------
|
||||
To log in to the dynect API you must call SessionLogin with customer name, username and password
|
||||
|
||||
Some Returned Values
|
||||
status - success or failure
|
||||
data->token - to be used with all other commands
|
||||
|
||||
** Complete Documentations can be found at
|
||||
https://manage.dynect.net/help/docs/api2/soap/
|
||||
|
||||
########################## */
|
||||
|
||||
if(!isset($this->user_name) || !isset($this->customer_name) || !isset($this->password)) {
|
||||
show_error('You must set your username, customer name, and password in application/config/dynect_api.php in order to login.');
|
||||
}
|
||||
else {
|
||||
|
||||
$parameters = array(
|
||||
'parameters' => array(
|
||||
'user_name'=> $this->user_name,
|
||||
'customer_name' => $this->customer_name,
|
||||
'password' => $this->password
|
||||
)
|
||||
);
|
||||
|
||||
$result = $this->client->__soapCall('SessionLogin',$parameters);
|
||||
|
||||
if(is_soap_fault($result)){
|
||||
trigger_error("SOAP Fault: (faultcode: {$result->faultcode}, faultstring: {$result->faultstring})", E_USER_ERROR);
|
||||
die();
|
||||
}
|
||||
|
||||
if($result->status == 'success'){
|
||||
$this->token = $result->data->token;
|
||||
return true;
|
||||
} else {
|
||||
log_message('error', 'Dynect_API could not log in. Result status: '.$result->status);
|
||||
die();
|
||||
}
|
||||
|
||||
} // end if isset user_name
|
||||
} // end login
|
||||
|
||||
function get_all_records($zone, $fqdn) {
|
||||
|
||||
/* ##########################
|
||||
|
||||
Getting All Records on a zone
|
||||
------------
|
||||
To get a list of all records send a GetANYRecords command with the token, zone, and fqdn as paramters
|
||||
|
||||
Some Returned Values
|
||||
status - success or failure
|
||||
data - object containing a list record type containers each with the rdata, fqdn, record_type, ttl and zone
|
||||
|
||||
** Complete Documentations can be found at
|
||||
https://manage.dynect.net/help/docs/api2/soap/
|
||||
|
||||
########################## */
|
||||
|
||||
$parameters = array(
|
||||
'parameters' => array(
|
||||
'token'=> $this->token,
|
||||
'zone' => $zone,
|
||||
'fqdn' => $fqdn
|
||||
)
|
||||
);
|
||||
|
||||
echo '<b>Retrieving all Records</b><br/>';
|
||||
echo '--------------------------<br/>';
|
||||
$result = $this->client->__soapCall('GetANYRecords',$parameters);
|
||||
|
||||
if(is_soap_fault($result)){
|
||||
trigger_error("SOAP Fault: (faultcode: {$result->faultcode}, faultstring: {$result->faultstring})", E_USER_ERROR);
|
||||
die();
|
||||
}
|
||||
|
||||
if($result->status == 'success'){
|
||||
return $result->data;
|
||||
} else {
|
||||
die('Unable to Get records');
|
||||
}
|
||||
|
||||
} // end get_record
|
||||
|
||||
|
||||
/**
|
||||
* Create a Zone
|
||||
*
|
||||
* @access public
|
||||
* @param Name of the zone
|
||||
* @param Administrative contact for this zone
|
||||
* @param Default TTL (in seconds) for records in the zone
|
||||
* @return void
|
||||
*/
|
||||
function create_zone($zone, $rname, $ttl = 3600) {
|
||||
|
||||
$parameters = array(
|
||||
'parameters' => array(
|
||||
'token'=> $this->token,
|
||||
'zone' => $zone,
|
||||
'rname' => $rname,
|
||||
'ttl' => $ttl
|
||||
)
|
||||
);
|
||||
|
||||
try{
|
||||
$result = $this->client->__soapCall('CreateZone',$parameters);
|
||||
}
|
||||
catch (SoapFault $ex) {
|
||||
trigger_error("SOAP Fault: ( ".var_export($ex->detail,true)." )", E_USER_ERROR);
|
||||
die();
|
||||
}
|
||||
|
||||
if($result->status == 'success'){
|
||||
return $result->data;
|
||||
} else {
|
||||
die('Unable to create zone');
|
||||
}
|
||||
|
||||
} // end create_zone
|
||||
|
||||
/**
|
||||
* Delete a Zone
|
||||
*
|
||||
* @access public
|
||||
* @param Name of the zone
|
||||
* @return boolean (true = success)
|
||||
*/
|
||||
function delete_zone($zone) {
|
||||
|
||||
$parameters = array(
|
||||
'parameters' => array(
|
||||
'token'=> $this->token,
|
||||
'zone' => $zone
|
||||
)
|
||||
);
|
||||
|
||||
try{
|
||||
$result = $this->client->__soapCall('DeleteOneZone',$parameters);
|
||||
}
|
||||
catch (SoapFault $ex) {
|
||||
trigger_error("SOAP Fault: ( ".var_export($ex->detail,true)." )", E_USER_ERROR);
|
||||
die();
|
||||
}
|
||||
|
||||
if($result->status == 'success'){
|
||||
return true;
|
||||
} else {
|
||||
die('Unable to delete zone');
|
||||
}
|
||||
|
||||
} // end delete_zone
|
||||
|
||||
|
||||
/**
|
||||
* Publish a Zone
|
||||
*
|
||||
* @access public
|
||||
* @param Name of the zone
|
||||
* @return boolean (true = success)
|
||||
*/
|
||||
function publish_zone($zone) {
|
||||
|
||||
$parameters = array(
|
||||
'parameters' => array(
|
||||
'token'=> $this->token,
|
||||
'zone' => $zone
|
||||
)
|
||||
);
|
||||
|
||||
try{
|
||||
$result = $this->client->__soapCall('PublishZone',$parameters);
|
||||
}
|
||||
catch (SoapFault $ex) {
|
||||
trigger_error("SOAP Fault: ( ".var_export($ex->detail,true)." )", E_USER_ERROR);
|
||||
die();
|
||||
}
|
||||
|
||||
if($result->status == 'success'){
|
||||
return true;
|
||||
} else {
|
||||
die('Unable to publish zone');
|
||||
}
|
||||
|
||||
} // end publish_zone
|
||||
|
||||
|
||||
/**
|
||||
* Delete Records - Deletes all records at fqdn of type
|
||||
*
|
||||
* @access public
|
||||
* @param Type of record to delete (A, AAAA, CNAME, DNSKEY, DS, KEY, LOC, MX, NS, PTR, RP, SOA, SRV, TXT)
|
||||
* @param Name of zone to delete records from
|
||||
* @param Name of node to delete records from
|
||||
* @return bool (true=success)
|
||||
*/
|
||||
function delete_records($type, $zone, $fqdn) {
|
||||
if(in_array($type, array('A', 'AAAA', 'CNAME', 'DNSKEY', 'DS', 'KEY', 'LOC', 'MX', 'NS', 'PTR', 'RP', 'SOA', 'SRV', 'TXT'))) {
|
||||
|
||||
$parameters = array(
|
||||
'parameters' => array(
|
||||
'token'=> $this->token,
|
||||
'fqdn' => $fqdn,
|
||||
'zone' => $zone
|
||||
)
|
||||
);
|
||||
|
||||
try{
|
||||
$result = $this->client->__soapCall('Delete'.$type.'Records',$parameters);
|
||||
}
|
||||
catch (SoapFault $ex) {
|
||||
trigger_error("SOAP Fault: ( ".var_export($ex->detail,true)." )", E_USER_ERROR);
|
||||
die();
|
||||
}
|
||||
|
||||
if($result->status == 'success'){
|
||||
return true;
|
||||
} else {
|
||||
die('Unable to create '.$type.' record.');
|
||||
}
|
||||
|
||||
}
|
||||
} // end delete_records
|
||||
|
||||
|
||||
/**
|
||||
* Create Record
|
||||
*
|
||||
* @access public
|
||||
* @param Type of record to create (A, AAAA, CNAME, DNSKEY, DS, KEY, LOC, MX, NS, PTR, RP, SOA, SRV, TXT)
|
||||
* @param Name of zone to add the record to
|
||||
* @param Name of node to add the record to
|
||||
* @param RData defining the record to add
|
||||
* @return array data
|
||||
string fqdn Fully qualified domain name of a node in the zone
|
||||
hash rdata RData defining the record
|
||||
(response data)
|
||||
string record_type The RRType of the record
|
||||
string ttl TTL for the record.
|
||||
string zone Name of the zone
|
||||
*/
|
||||
function create_record($type, $zone, $fqdn, $rdata) {
|
||||
if(in_array($type, array('A', 'AAAA', 'CNAME', 'DNSKEY', 'DS', 'KEY', 'LOC', 'MX', 'NS', 'PTR', 'RP', 'SOA', 'SRV', 'TXT'))) {
|
||||
|
||||
$parameters = array(
|
||||
'parameters' => array(
|
||||
'token'=> $this->token,
|
||||
'fqdn' => $fqdn,
|
||||
'zone' => $zone,
|
||||
'rdata' => $rdata
|
||||
)
|
||||
);
|
||||
|
||||
try{
|
||||
$result = $this->client->__soapCall('Create'.$type.'Record',$parameters);
|
||||
}
|
||||
catch (SoapFault $ex) {
|
||||
trigger_error("SOAP Fault: ( ".var_export($ex->detail,true)." )", E_USER_ERROR);
|
||||
die();
|
||||
}
|
||||
|
||||
if($result->status == 'success'){
|
||||
return $result->data;
|
||||
} else {
|
||||
die('Unable to create '.$type.' record.');
|
||||
}
|
||||
|
||||
}
|
||||
} // end create_record
|
||||
|
||||
|
||||
/**
|
||||
* Get Records
|
||||
*
|
||||
* @access public
|
||||
* @param Type of record to get (A, AAAA, CNAME, DNSKEY, DS, KEY, LOC, MX, NS, PTR, RP, SOA, SRV, TXT)
|
||||
* @param Name of zone to get the record of
|
||||
* @param Name of node to get the record of
|
||||
* @return array data
|
||||
string fqdn Fully qualified domain name of a node in the zone
|
||||
hash rdata RData defining the record
|
||||
(response data)
|
||||
string record_type The RRType of the record
|
||||
string ttl TTL for the record.
|
||||
string zone Name of the zone
|
||||
*/
|
||||
function get_records($type, $zone, $fqdn) {
|
||||
if(in_array($type, array('A', 'AAAA', 'CNAME', 'DNSKEY', 'DS', 'KEY', 'LOC', 'MX', 'NS', 'PTR', 'RP', 'SOA', 'SRV', 'TXT'))) {
|
||||
|
||||
$parameters = array(
|
||||
'parameters' => array(
|
||||
'token'=> $this->token,
|
||||
'fqdn' => $fqdn,
|
||||
'zone' => $zone
|
||||
)
|
||||
);
|
||||
|
||||
try{
|
||||
$result = $this->client->__soapCall('Get'.$type.'Records',$parameters);
|
||||
}
|
||||
catch (SoapFault $ex) {
|
||||
trigger_error("SOAP Fault: ( ".var_export($ex->faultstring,true)." )", E_USER_ERROR);
|
||||
die();
|
||||
}
|
||||
|
||||
if($result->status == 'success'){
|
||||
return $result->data;
|
||||
} else {
|
||||
die('Unable to get '.$type.' records.');
|
||||
}
|
||||
|
||||
}
|
||||
} // end get_records
|
||||
|
||||
|
||||
/**
|
||||
* Get all Zones
|
||||
*
|
||||
* @access public
|
||||
* @return zone data
|
||||
*/
|
||||
function get_zones() {
|
||||
|
||||
$parameters = array(
|
||||
'parameters' => array(
|
||||
'token'=> $this->token
|
||||
)
|
||||
);
|
||||
|
||||
$result = $this->client->__soapCall('GetZones',$parameters);
|
||||
|
||||
if(is_soap_fault($result)){
|
||||
trigger_error("SOAP Fault: (faultcode: {$result->faultcode}, faultstring: {$result->faultstring})", E_USER_ERROR);
|
||||
die();
|
||||
}
|
||||
|
||||
if($result->status == 'success'){
|
||||
return $result->data;
|
||||
} else {
|
||||
die('Unable to get zones');
|
||||
}
|
||||
|
||||
} // end get_zones
|
||||
|
||||
|
||||
function logout() {
|
||||
/* ##########################
|
||||
|
||||
Logging Out
|
||||
------------
|
||||
To log in to the dynect API you must call SessionLogout with the token received at login
|
||||
|
||||
Some Returned Values
|
||||
status - success or failure
|
||||
|
||||
** Complete Documentations can be found at
|
||||
https://manage.dynect.net/help/docs/api2/soap/
|
||||
|
||||
########################## */
|
||||
|
||||
$parameters = array(
|
||||
'parameters' => array(
|
||||
'token'=> $this->token
|
||||
)
|
||||
);
|
||||
|
||||
$result = $this->client->__soapCall('SessionLogout',$parameters);
|
||||
|
||||
if(is_soap_fault($result)){
|
||||
trigger_error("SOAP Fault: (faultcode: {$result->faultcode}, faultstring: {$result->faultstring})", E_USER_ERROR);
|
||||
die();
|
||||
}
|
||||
|
||||
$message = $result->msgs;
|
||||
|
||||
if($result->status != 'success'){
|
||||
log_message('error','Dynect_API unable to log out.');
|
||||
}
|
||||
} // end logout
|
||||
|
||||
|
||||
} // end class
|
452
system/application/libraries/Postmark.php
Normal file
452
system/application/libraries/Postmark.php
Normal file
@ -0,0 +1,452 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Postmark Email Library
|
||||
*
|
||||
* Permits email to be sent using Postmarkapp.com's Servers
|
||||
*
|
||||
* @category Libraries
|
||||
* @author Based on work by János Rusiczki & Markus Hedlund’s.
|
||||
* @modified Heavily Modified by Zack Kitzmiller
|
||||
* @link http://www.github.com/zackkitzmiller/postmark-codeigniter
|
||||
*/
|
||||
|
||||
class Postmark {
|
||||
|
||||
//private
|
||||
var $CI;
|
||||
var $api_key = '';
|
||||
var $validation = FALSE;
|
||||
var $strip_html = FALSE;
|
||||
var $develop = FALSE;
|
||||
|
||||
var $from_name;
|
||||
var $from_address;
|
||||
|
||||
var $_reply_to_name;
|
||||
var $_reply_to_address;
|
||||
|
||||
var $_to_name;
|
||||
var $_to_address;
|
||||
|
||||
var $_cc_name;
|
||||
var $_cc_address;
|
||||
|
||||
var $_subject;
|
||||
var $_message_plain;
|
||||
var $_message_html;
|
||||
|
||||
var $_tag;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @access public
|
||||
* @param array initialization parameters
|
||||
*/
|
||||
function Postmark($params = array())
|
||||
{
|
||||
$this->CI =& get_instance();
|
||||
|
||||
if (count($params) > 0)
|
||||
{
|
||||
$this->initialize($params);
|
||||
}
|
||||
|
||||
if ($this->develop == TRUE)
|
||||
{
|
||||
$this->api_key = 'POSTMARK_API_TEST';
|
||||
}
|
||||
|
||||
log_message('debug', 'Postmark Class Initialized');
|
||||
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Initialize Preferences
|
||||
*
|
||||
* @access public
|
||||
* @param array initialization parameters
|
||||
* @return void
|
||||
*/
|
||||
function initialize($params)
|
||||
{
|
||||
$this->clear();
|
||||
if (count($params) > 0)
|
||||
{
|
||||
foreach ($params as $key => $value)
|
||||
{
|
||||
if (isset($this->$key))
|
||||
{
|
||||
$this->$key = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Clear the Email Data
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function clear() {
|
||||
|
||||
$this->from_name = '';
|
||||
$this->from_address = '';
|
||||
|
||||
$this->_to_name = '';
|
||||
$this->_to_address = '';
|
||||
|
||||
$this->_cc_name = '';
|
||||
$this->_cc_address = '';
|
||||
|
||||
$this->_subject = '';
|
||||
$this->_message_plain = '';
|
||||
$this->_message_html = '';
|
||||
|
||||
$this->_tag = '';
|
||||
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Set Email FROM address
|
||||
*
|
||||
* This could also be set in the config file
|
||||
*
|
||||
* TODO:
|
||||
* Validate Email Addresses ala CodeIgniter's Email Class
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function from($address, $name = null)
|
||||
{
|
||||
|
||||
if ( ! $this->validation == TRUE)
|
||||
{
|
||||
$this->from_address = $address;
|
||||
$this->from_name = $name;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($this->_validate_email($address))
|
||||
{
|
||||
$this->from_address = $address;
|
||||
$this->from_name = $name;
|
||||
}
|
||||
else
|
||||
{
|
||||
show_error('You have entered an invalid sender address.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Set Email TO address
|
||||
*
|
||||
* TODO:
|
||||
* Validate Email Addresses ala CodeIgniter's Email Class
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function to($address, $name = null)
|
||||
{
|
||||
|
||||
if ( ! $this->validation == TRUE)
|
||||
{
|
||||
$this->_to_address = $address;
|
||||
$this->_to_name = $name;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($this->_validate_email($address))
|
||||
{
|
||||
$this->_to_address = $address;
|
||||
$this->_to_name = $name;
|
||||
}
|
||||
else
|
||||
{
|
||||
show_error('You have entered an invalid recipient address.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Set Email ReplyTo address
|
||||
*
|
||||
* TODO:
|
||||
* Validate Email Addresses ala CodeIgniter's Email Class
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function reply_to($address, $name = null)
|
||||
{
|
||||
|
||||
if ( ! $this->validation == TRUE)
|
||||
{
|
||||
$this->_reply_to_address = $address;
|
||||
$this->_reply_to_name = $name;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($this->_validate_email($address))
|
||||
{
|
||||
$this->_reply_to_address = $address;
|
||||
$this->_reply_to_name = $name;
|
||||
}
|
||||
else
|
||||
{
|
||||
show_error('You have entered an invalid reply to address.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Set Email CC address
|
||||
*
|
||||
* TODO:
|
||||
* Validate Email Addresses ala CodeIgniter's Email Class
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function cc($address, $name = null)
|
||||
{
|
||||
|
||||
if ( ! $this->validation == TRUE)
|
||||
{
|
||||
$this->_cc_address = $address;
|
||||
$this->_cc_name = $name;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($this->_validate_email($address))
|
||||
{
|
||||
$this->_cc_address = $address;
|
||||
$this->_cc_name = $name;
|
||||
}
|
||||
else
|
||||
{
|
||||
show_error('You have entered an invalid recipient address.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Set Email Subject
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function subject($subject)
|
||||
{
|
||||
$this->_subject = $subject;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Set Tag
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function tag($tag)
|
||||
{
|
||||
$this->_tag = $tag;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Set Email Message in Plain Text
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function message_plain($message)
|
||||
{
|
||||
if ( ! $this->strip_html )
|
||||
{
|
||||
$this->_message_plain = $message;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->_message_plain = $this->_strip_html($message);
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Set Email Message in HTML
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function message_html($message)
|
||||
{
|
||||
$this->_message_html = $message;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
/**
|
||||
* Private Function to prepare and send email
|
||||
*/
|
||||
function _prepare_data()
|
||||
{
|
||||
$data = array();
|
||||
$data['Subject'] = $this->_subject;
|
||||
|
||||
$data['From'] = is_null($this->from_name) ? $this->from_address : "{$this->from_name} <{$this->from_address}>";
|
||||
$data['To'] = is_null($this->_to_name) ? $this->_to_address : "{$this->_to_name} <{$this->_to_address}>";
|
||||
|
||||
if (!is_null($this->_cc_address) && ($this->_cc_address != '')) {
|
||||
$data['Cc'] = is_null($this->_cc_name) ? $this->_cc_address : "{$this->_cc_name} <{$this->_cc_address}>";
|
||||
}
|
||||
|
||||
if (!is_null($this->_reply_to_address) && ($this->_reply_to_address != '')) {
|
||||
$data['ReplyTo'] = is_null($this->_reply_to_name) ? $this->_reply_to_address : "{$this->_reply_to_name} <{$this->_reply_to_address}>";
|
||||
}
|
||||
|
||||
if (!is_null($this->_tag) && ($this->_tag != '')) {
|
||||
$data['tag'] = $this->_tag;
|
||||
}
|
||||
|
||||
if (!is_null($this->_message_html)) {
|
||||
$data['HtmlBody'] = $this->_message_html;
|
||||
}
|
||||
|
||||
if (!is_null($this->_message_plain)) {
|
||||
$data['TextBody'] = $this->_message_plain;
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
function send($from_address = null, $from_name = null, $to_address = null, $to_name = null, $subject = null, $message_plain = null, $message_html = null)
|
||||
{
|
||||
|
||||
if (!function_exists('curl_init'))
|
||||
{
|
||||
|
||||
if(function_exists('log_message'))
|
||||
{
|
||||
log_message('error', 'Postmark - PHP was not built with cURL enabled. Rebuild PHP with --with-curl to use cURL.');
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
if (!is_null($from_address)) $this->from($from_address, $from_name);
|
||||
if (!is_null($to_address)) $this->to($to_address, $to_name);
|
||||
if (!is_null($subject)) $this->subject($subject);
|
||||
if (!is_null($message_plain)) $this->message_plain($message_plain);
|
||||
if (!is_null($message_html)) $this->message_html($message_html);
|
||||
|
||||
if (is_null($this->api_key)) {
|
||||
show_error("Postmark API key is not set!");
|
||||
}
|
||||
|
||||
if (is_null($this->from_address)) {
|
||||
show_error("From address is not set!");
|
||||
}
|
||||
|
||||
if (is_null($this->_to_address)) {
|
||||
show_error("To address is not set!");
|
||||
}
|
||||
|
||||
if (is_null($this->_subject)) {
|
||||
show_error("Subject is not set!");
|
||||
}
|
||||
|
||||
if (is_null($this->_message_plain) && is_null($this->_message_html)) {
|
||||
show_error("Please either set plain message, HTML message or both!");
|
||||
}
|
||||
|
||||
$encoded_data = json_encode($this->_prepare_data());
|
||||
|
||||
$headers = array(
|
||||
'Accept: application/json',
|
||||
'Content-Type: application/json',
|
||||
'X-Postmark-Server-Token: ' . $this->api_key
|
||||
);
|
||||
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, 'http://api.postmarkapp.com/email');
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $encoded_data);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
||||
|
||||
$return = curl_exec($ch);
|
||||
log_message('debug', 'POSTMARK JSON: ' . $encoded_data . "\nHeaders: \n\t" . implode("\n\t", $headers) . "\nReturn:\n$return");
|
||||
|
||||
if (curl_error($ch) != '') {
|
||||
show_error(curl_error($ch));
|
||||
}
|
||||
|
||||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
log_message('debug', 'POSTMARK http code:' . $httpCode);
|
||||
|
||||
if (intval($httpCode / 100) != 2) {
|
||||
$message = json_decode($return)->Message;
|
||||
show_error('Error while mailing. Postmark returned HTTP code ' . $httpCode . ' with message "'.$message.'"');
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Email Validation
|
||||
*
|
||||
* @access public
|
||||
* @param string
|
||||
* @return bool
|
||||
*/
|
||||
function _validate_email($address)
|
||||
{
|
||||
$addresses = explode(',', $address);
|
||||
|
||||
foreach($addresses as $k => $v) {
|
||||
if ( ! preg_match("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix", trim($v))) {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Strip Html
|
||||
*
|
||||
* @access public
|
||||
* @param string
|
||||
* @return string
|
||||
*/
|
||||
function _strip_html($message)
|
||||
{
|
||||
$message = preg_replace('/\<br(\s*)?\/?\>/i', "\n", $message);
|
||||
return strip_tags($message);
|
||||
}
|
||||
}
|
10
system/application/libraries/index.html
Normal file
10
system/application/libraries/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/application/models/index.html
Normal file
10
system/application/models/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/application/views/index.html
Normal file
10
system/application/views/index.html
Normal file
@ -0,0 +1,10 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
62
system/application/views/welcome_message.php
Normal file
62
system/application/views/welcome_message.php
Normal file
@ -0,0 +1,62 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Welcome to CodeIgniter</title>
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
body {
|
||||
background-color: #fff;
|
||||
margin: 40px;
|
||||
font-family: Lucida Grande, Verdana, Sans-serif;
|
||||
font-size: 14px;
|
||||
color: #4F5155;
|
||||
}
|
||||
|
||||
a {
|
||||
color: #003399;
|
||||
background-color: transparent;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
h1 {
|
||||
color: #444;
|
||||
background-color: transparent;
|
||||
border-bottom: 1px solid #D0D0D0;
|
||||
font-size: 16px;
|
||||
font-weight: bold;
|
||||
margin: 24px 0 2px 0;
|
||||
padding: 5px 0 6px 0;
|
||||
}
|
||||
|
||||
code {
|
||||
font-family: Monaco, Verdana, Sans-serif;
|
||||
font-size: 12px;
|
||||
background-color: #f9f9f9;
|
||||
border: 1px solid #D0D0D0;
|
||||
color: #002166;
|
||||
display: block;
|
||||
margin: 14px 0 14px 0;
|
||||
padding: 12px 10px 12px 10px;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>Welcome to CodeIgniter!</h1>
|
||||
|
||||
<p>The page you are looking at is being generated dynamically by CodeIgniter.</p>
|
||||
|
||||
<p>If you would like to edit this page you'll find it located at:</p>
|
||||
<code>system/application/views/welcome_message.php</code>
|
||||
|
||||
<p>The corresponding controller for this page is found at:</p>
|
||||
<code>system/application/controllers/welcome.php</code>
|
||||
|
||||
<p>If you are exploring CodeIgniter for the very first time, you should start by reading the <a href="user_guide/">User Guide</a>.</p>
|
||||
|
||||
|
||||
<p><br />Page rendered in {elapsed_time} seconds</p>
|
||||
|
||||
</body>
|
||||
</html>
|
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
|
||||
< |