Added Basic Files

pull/106/merge
Peter Goodhall 2011-04-25 16:24:01 +01:00
rodzic 7f20a75f02
commit f2b50c4573
332 zmienionych plików z 73829 dodań i 0 usunięć

3
README
Wyświetl plik

@ -0,0 +1,3 @@
HRD Web Frontend
Website front end to support Ham Radio Deluxe Logbooks MySQL backend Table to allow logging from any location.

Wyświetl plik

@ -0,0 +1 @@
Deny from all

1
application/cache/.htaccess vendored 100644
Wyświetl plik

@ -0,0 +1 @@
deny from all

10
application/cache/index.html vendored 100644
Wyświetl plik

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

Wyświetl plik

@ -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. Packages
| 2. Libraries
| 3. Helper files
| 4. Custom config files
| 5. Language files
| 6. Models
|
*/
/*
| -------------------------------------------------------------------
| Auto-load Packges
| -------------------------------------------------------------------
| Prototype:
|
| $autoload['packages'] = array(APPPATH.'third_party', '/usr/local/shared');
|
*/
$autoload['packages'] = array(APPPATH.'third_party');
/*
| -------------------------------------------------------------------
| Auto-load Libraries
| -------------------------------------------------------------------
| These are the classes located in the system/libraries folder
| or in your application/libraries folder.
|
| Prototype:
|
| $autoload['libraries'] = array('database', 'session', 'xmlrpc');
*/
$autoload['libraries'] = array('database');
/*
| -------------------------------------------------------------------
| Auto-load Helper Files
| -------------------------------------------------------------------
| Prototype:
|
| $autoload['helper'] = array('url', 'file');
*/
$autoload['helper'] = array('url');
/*
| -------------------------------------------------------------------
| 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: ./application/config/autoload.php */

Wyświetl plik

@ -0,0 +1,362 @@
<?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/
|
| If this is not set then CodeIgniter will guess the protocol, domain and
| path to your installation.
|
*/
$config['base_url'] = 'http://localhost/logger/';
/*
|--------------------------------------------------------------------------
| 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/
|
| By default CodeIgniter enables access to the $_GET array. If for some
| reason you would like to disable it, set 'allow_get_array' to FALSE.
|
| 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['allow_get_array'] = TRUE;
$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
| application/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 Session class you
| MUST set an encryption key. See the user guide for info.
|
*/
$config['encryption_key'] = '';
/*
|--------------------------------------------------------------------------
| Session Variables
|--------------------------------------------------------------------------
|
| 'sess_cookie_name' = the name you want for the cookie
| 'sess_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.
| 'sess_expire_on_close' = Whether to cause the session to expire automatically
| when the browser window is closed
| 'sess_encrypt_cookie' = Whether to encrypt the cookie
| 'sess_use_database' = Whether to save the session data to a database
| 'sess_table_name' = The name of the session database table
| 'sess_match_ip' = Whether to match the user's IP address when reading the session data
| 'sess_match_useragent' = Whether to match the User Agent when reading the session data
| 'sess_time_to_update' = how many seconds between CI refreshing Session Information
|
*/
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_expire_on_close'] = FALSE;
$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
| 'cookie_secure' = Cookies will only be set if a secure HTTPS connection exists.
|
*/
$config['cookie_prefix'] = "";
$config['cookie_domain'] = "";
$config['cookie_path'] = "/";
$config['cookie_secure'] = FALSE;
/*
|--------------------------------------------------------------------------
| Global XSS Filtering
|--------------------------------------------------------------------------
|
| Determines whether the XSS filter is always active when GET, POST or
| COOKIE data is encountered
|
*/
$config['global_xss_filtering'] = FALSE;
/*
|--------------------------------------------------------------------------
| Cross Site Request Forgery
|--------------------------------------------------------------------------
| Enables a CSRF cookie token to be set. When set to TRUE, token will be
| checked on a submitted form. If you are accepting user data, it is strongly
| recommended CSRF protection be enabled.
|
| 'csrf_token_name' = The token name
| 'csrf_cookie_name' = The cookie name
| 'csrf_expire' = The number in seconds the token should expire.
*/
$config['csrf_protection'] = FALSE;
$config['csrf_token_name'] = 'csrf_test_name';
$config['csrf_cookie_name'] = 'csrf_cookie_name';
$config['csrf_expire'] = 7200;
/*
|--------------------------------------------------------------------------
| 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: ./application/config/config.php */

Wyświetl plik

@ -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: ./application/config/constants.php */

Wyświetl plik

@ -0,0 +1,62 @@
<?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
| ['swap_pre'] A default table prefix that should be swapped with the dbprefix
| ['autoinit'] Whether or not to automatically initialize the database.
| ['stricton'] TRUE/FALSE - forces 'Strict Mode' connections
| - good for ensuring strict SQL while developing
|
| 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'] = 'root';
$db['default']['password'] = '';
$db['default']['database'] = '2e0sql_log';
$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';
$db['default']['swap_pre'] = '';
$db['default']['autoinit'] = TRUE;
$db['default']['stricton'] = FALSE;
/* End of file database.php */
/* Location: ./application/config/database.php */

Wyświetl plik

@ -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 */

Wyświetl plik

@ -0,0 +1,64 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/*
| -------------------------------------------------------------------
| Foreign Characters
| -------------------------------------------------------------------
| This file contains an array of foreign characters for transliteration
| conversion used by the Text helper
|
*/
$foreign_characters = array(
'/ä|æ|ǽ/' => 'ae',
'/ö|œ/' => 'oe',
'/ü/' => 'ue',
'/Ä/' => 'Ae',
'/Ü/' => 'Ue',
'/Ö/' => 'Oe',
'/À|Á|Â|Ã|Ä|Å|Ǻ|Ā|Ă|Ą|Ǎ/' => 'A',
'/à|á|â|ã|å|ǻ|ā|ă|ą|ǎ|ª/' => 'a',
'/Ç|Ć|Ĉ|Ċ|Č/' => 'C',
'/ç|ć|ĉ|ċ|č/' => 'c',
'/Ð|Ď|Đ/' => 'D',
'/ð|ď|đ/' => 'd',
'/È|É|Ê|Ë|Ē|Ĕ|Ė|Ę|Ě/' => 'E',
'/è|é|ê|ë|ē|ĕ|ė|ę|ě/' => 'e',
'/Ĝ|Ğ|Ġ|Ģ/' => 'G',
'/ĝ|ğ|ġ|ģ/' => 'g',
'/Ĥ|Ħ/' => 'H',
'/ĥ|ħ/' => 'h',
'/Ì|Í|Î|Ï|Ĩ|Ī|Ĭ|Ǐ|Į|İ/' => 'I',
'/ì|í|î|ï|ĩ|ī|ĭ|ǐ|į|ı/' => 'i',
'/Ĵ/' => 'J',
'/ĵ/' => 'j',
'/Ķ/' => 'K',
'/ķ/' => 'k',
'/Ĺ|Ļ|Ľ|Ŀ|Ł/' => 'L',
'/ĺ|ļ|ľ|ŀ|ł/' => 'l',
'/Ñ|Ń|Ņ|Ň/' => 'N',
'/ñ|ń|ņ|ň|ʼn/' => 'n',
'/Ò|Ó|Ô|Õ|Ō|Ŏ|Ǒ|Ő|Ơ|Ø|Ǿ/' => 'O',
'/ò|ó|ô|õ|ō|ŏ|ǒ|ő|ơ|ø|ǿ|º/' => 'o',
'/Ŕ|Ŗ|Ř/' => 'R',
'/ŕ|ŗ|ř/' => 'r',
'/Ś|Ŝ|Ş|Š/' => 'S',
'/ś|ŝ|ş|š|ſ/' => 's',
'/Ţ|Ť|Ŧ/' => 'T',
'/ţ|ť|ŧ/' => 't',
'/Ù|Ú|Û|Ũ|Ū|Ŭ|Ů|Ű|Ų|Ư|Ǔ|Ǖ|Ǘ|Ǚ|Ǜ/' => 'U',
'/ù|ú|û|ũ|ū|ŭ|ů|ű|ų|ư|ǔ|ǖ|ǘ|ǚ|ǜ/' => 'u',
'/Ý|Ÿ|Ŷ/' => 'Y',
'/ý|ÿ|ŷ/' => 'y',
'/Ŵ/' => 'W',
'/ŵ/' => 'w',
'/Ź|Ż|Ž/' => 'Z',
'/ź|ż|ž/' => 'z',
'/Æ|Ǽ/' => 'AE',
'/ß/'=> 'ss',
'/IJ/' => 'IJ',
'/ij/' => 'ij',
'/Œ/' => 'OE',
'/ƒ/' => 'f'
);
/* End of file foreign_chars.php */
/* Location: ./application/config/foreign_chars.php */

Wyświetl plik

@ -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: ./application/config/hooks.php */

Wyświetl plik

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

Wyświetl plik

@ -0,0 +1,106 @@
<?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/x-csv', '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' => array('application/octet-stream', 'application/x-msdownload'),
'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' => array('application/x-tar', 'application/x-gzip-compressed'),
'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', 'audio/mpeg3', 'audio/mp3'),
'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',
'json' => array('application/json', 'text/json')
);
/* End of file mimes.php */
/* Location: ./application/config/mimes.php */

Wyświetl plik

@ -0,0 +1,17 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/*
| -------------------------------------------------------------------------
| Profiler Sections
| -------------------------------------------------------------------------
| This file lets you determine whether or not various sections of Profiler
| data are displayed when the Profiler is enabled.
| Please see the user guide for info:
|
| http://codeigniter.com/user_guide/general/profiling.html
|
*/
/* End of file profiler.php */
/* Location: ./application/config/profiler.php */

Wyświetl plik

@ -0,0 +1,46 @@
<?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 area 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['404_override'] = 'errors/page_missing';
|
| This route will tell the Router what URI segments to use if those provided
| in the URL cannot be matched to a valid route.
|
*/
$route['default_controller'] = "dashboard";
$route['404_override'] = '';
/* End of file routes.php */
/* Location: ./application/config/routes.php */

Wyświetl plik

@ -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: ./application/config/smileys.php */

Wyświetl plik

@ -0,0 +1,178 @@
<?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(
'Flock' => 'Flock',
'Chrome' => 'Chrome',
'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",
'ipad' => "iPad",
'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: ./application/config/user_agents.php */

Wyświetl plik

@ -0,0 +1,11 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Dashboard extends CI_Controller {
public function index()
{
$this->load->view('layout/header');
$this->load->view('dashboard/index');
$this->load->view('layout/footer');
}
}

Wyświetl plik

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

Wyświetl plik

@ -0,0 +1,11 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class QSO extends CI_Controller {
public function index()
{
$this->load->view('layout/header');
$this->load->view('qso/index');
$this->load->view('layout/footer');
}
}

Wyświetl plik

@ -0,0 +1,27 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Welcome extends CI_Controller {
/**
* Index Page for this controller.
*
* Maps to the following URL
* http://example.com/index.php/welcome
* - or -
* http://example.com/index.php/welcome/index
* - or -
* Since this controller is set as the default controller in
* config/routes.php, it's displayed at http://example.com/
*
* So any other public methods not prefixed with an underscore will
* map to /index.php/welcome/<method_name>
* @see http://codeigniter.com/user_guide/general/urls.html
*/
public function index()
{
$this->load->view('welcome_message');
}
}
/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */

Wyświetl plik

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

Wyświetl plik

@ -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>

Wyświetl plik

@ -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>

Wyświetl plik

@ -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>

Wyświetl plik

@ -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>

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

@ -0,0 +1,32 @@
<?php defined('BASEPATH') OR exit('No direct script access allowed');
class Migration_Create_accounts extends CI_Migration {
function up()
{
if ( ! $this->db->table_exists('accounts'))
{
// Setup Keys
$this->dbforge->add_key('id', TRUE);
$this->dbforge->add_field(array(
'id' => array('type' => 'INT', 'constraint' => 5, 'unsigned' => TRUE, 'auto_increment' => TRUE),
'company_name' => array('type' => 'VARCHAR', 'constraint' => '200', 'null' => FALSE),
'first_name' => array('type' => 'VARCHAR', 'constraint' => '200', 'null' => FALSE),
'last_name' => array('type' => 'VARCHAR', 'constraint' => '200', 'null' => FALSE),
'phone' => array('type' => 'TEXT', 'null' => FALSE),
'email' => array('type' => 'TEXT', 'null' => FALSE),
'address' => array('type' => 'TEXT', 'null' => FALSE),
'Last_Update' => array('type' => 'DATETIME', 'null' => FALSE)
));
$this->dbforge->add_field("Created_At TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP");
$this->dbforge->create_table('accounts', TRUE);
}
}
function down()
{
$this->dbforge->drop_table('accounts');
}
}

Wyświetl plik

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

Wyświetl plik

@ -0,0 +1,19 @@
<?php
class Logbook_model extends CI_Model {
function __construct()
{
// Call the Model constructor
parent::__construct();
}
function get_qsos($num, $offset) {
$this->db->select('COL_CALL, COL_BAND, COL_TIME_ON, COL_RST_RCVD, COL_RST_SENT, COL_MODE, COL_NAME, COL_COUNTRY');
$this->db->order_by("COL_TIME_ON", "desc");
$query = $this->db->get('table_hrd_contacts_v01', $num, $offset);
return $query;
}
}
?>

Wyświetl plik

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

Wyświetl plik

@ -0,0 +1,3 @@
<div class="wrap_content">
Content Here
</div>

Wyświetl plik

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

Wyświetl plik

@ -0,0 +1,6 @@
<div id="footer">
</div>
</body>
</html>

Wyświetl plik

@ -0,0 +1,65 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Web Logbook</title>
<link rel="stylesheet" href="<?php echo base_url();?>css/reset.css" type="text/css" />
<style type="text/css" media="screen" >
body {
background-color: #e6e6e6;
font-family: Arial, "Trebuchet MS", sans-serif;
}
td {
padding: 5px;
}
#nav {
background-image: url('/logger/images/nav_bg.gif');
height: 39px;
color: #ffffff;
border-bottom: 1px solid #9bc9ed;
}
/* Nav List CSS */
ul#navlist { font: bold 15px "Trebuchet MS", sans-serif; list-style-type: none; margin: 0; margin-left: 10px; }
ul#navlist li.active { float: left; background-image: none; background-color: #fff; margin: 2px 2px 0 3px; height:34px; text-align:center; }
ul#navlist li { float: left; margin: 2px 2px 0 3px; height:43px; border-bottom: none; text-align:center; }
#navlist .active a{ color: #ebebeb ; }
#navlist a { float: left; display: block; color: #ebebeb; text-decoration: none; padding-top: 7px; padding-left: 6px; padding-right: 5px; text-align:center; }
#navlist a:hover { }
.wrap_content {
margin: 0 auto;
width: 80%;
border: 1px solid #d7d7d7;
background-color: #ffffff;
}
.clear { clear: both; }
h2 {
margin: 0 auto;
width: 80%;
font-weight: bold;
font-size: 23px;
margin-top: 5px;
margin-bottom: 10px;
}
table .titles {
font-weight: bold;
}
</style>
</head>
<body>
<div id="nav">
<ul id="navlist">
<li><a href="<?php echo site_url();?> " title="Dashboard">Dashboard</a></li>
<li><a href="<?php echo site_url('logbook');?>" title="View Log">View Log</a></li>
<li><a href="<?php echo site_url('qso');?>" title="Add QSO">Add QSO</a></li>
</ul>
</div>
<div class="clear"></div>

Wyświetl plik

@ -0,0 +1,80 @@
<h2>Add QSO</h2>
<div class="wrap_content">
<table>
<tr>
<td>Date</td>
<td><?php echo date('d/m/Y'); ?></td>
</tr>
<tr>
<td>Start Time</td>
<td></td>
</tr>
<tr>
<td>Callsign</td>
<td><input type="text" name="callsign" value="" /></td>
</tr>
<tr>
<td>Band</td>
<td><select name="band">
<option value="160m">160m</option>
<option value="80m">80m</option>
<option value="40m">40m</option>
<option value="30m">30m</option>
<option value="20m">20m</option>
<option value="17m">17m</option>
<option value="15m">15m</option>
<option value="12m">12m</option>
<option value="10m">10m</option>
<option value="6m">6m</option>
<option value="4m">4m</option>
<option value="2m">2m</option>
<option value="70cm">70cm</option>
</select></td>
</tr>
<tr>
<td>RST Sent</td>
<td><select name="rst_sent">
<option value="51">51</option>
<option value="52">52</option>
<option value="53">53</option>
<option value="54">54</option>
<option value="55">55</option>
<option value="56">56</option>
<option value="57">57</option>
<option value="58">58</option>
<option value="59" selected="selected">59</option>
<option value="59+10dB">59+10dB</option>
<option value="59+20dB">59+20dB</option>
<option value="59+30dB">59+30dB</option>
</select></td>
</tr>
<tr>
<td>RST Recv</td>
<td><select name="rst_recv">
<option value="51">51</option>
<option value="52">52</option>
<option value="53">53</option>
<option value="54">54</option>
<option value="55">55</option>
<option value="56">56</option>
<option value="57">57</option>
<option value="58">58</option>
<option value="59" selected="selected">59</option>
<option value="59+10dB">59+10dB</option>
<option value="59+20dB">59+20dB</option>
<option value="59+30dB">59+30dB</option>
</select></td>
</tr>
<tr>
<td>Comment</td>
<td><input type="text" name="comment" value="" /></td>
</tr>
</table>
</div>

Wyświetl plik

@ -0,0 +1,35 @@
<h2>Logbook</h2>
<div class="wrap_content">
<table width="100%">
<tr class="titles">
<td>Date</td>
<td>Time</td>
<td>Call</td>
<td>Mode</td>
<td>Sent</td>
<td>Recv</td>
<td>Band</td>
<td>Name</td>
<td>Country</td>
</tr>
<?php foreach ($results->result() as $row) { ?>
<tr>
<td><?php $timestamp = strtotime($row->COL_TIME_ON); echo date('d/m/y', $timestamp); ?></td>
<td><?php $timestamp = strtotime($row->COL_TIME_ON); echo date('H:i', $timestamp); ?></td>
<td><?php echo strtoupper($row->COL_CALL); ?></td>
<td><?php echo $row->COL_MODE; ?></td>
<td><?php echo $row->COL_RST_SENT; ?></td>
<td><?php echo $row->COL_RST_RCVD; ?></td>
<td><?php echo $row->COL_BAND; ?></td>
<td><?php echo substr($row->COL_NAME, 0, 15); ?></td>
<td><?php echo $row->COL_COUNTRY; ?></td>
</tr>
<?php } ?>
</table>
<?php echo $this->pagination->create_links(); ?>
</div>

Wyświetl plik

@ -0,0 +1,64 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<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>application/views/welcome_message.php</code>
<p>The corresponding controller for this page is found at:</p>
<code>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>

48
css/reset.css 100644
Wyświetl plik

@ -0,0 +1,48 @@
/* http://meyerweb.com/eric/tools/css/reset/
v2.0 | 20110126
License: none (public domain)
*/
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
display: block;
}
body {
line-height: 1;
}
ol, ul {
list-style: none;
}
blockquote, q {
quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
content: '';
content: none;
}
table {
border-collapse: collapse;
border-spacing: 0;
}

BIN
images/nav_bg.gif 100644

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 1.5 KiB

201
index.php 100644
Wyświetl plik

@ -0,0 +1,201 @@
<?php
/*
*---------------------------------------------------------------
* APPLICATION ENVIRONMENT
*---------------------------------------------------------------
*
* You can load different configurations depending on your
* current environment. Setting the environment also influences
* things like logging and error reporting.
*
* This can be set to anything, but default usage is:
*
* development
* testing
* production
*
* NOTE: If you change these, also change the error_reporting() code below
*
*/
define('ENVIRONMENT', 'development');
/*
*---------------------------------------------------------------
* ERROR REPORTING
*---------------------------------------------------------------
*
* Different environments will require different levels of error reporting.
* By default development will show errors but testing and live will hide them.
*/
switch (ENVIRONMENT)
{
case 'development':
error_reporting(E_ALL);
break;
case 'testing':
case 'production':
error_reporting(0);
break;
default:
exit('The application environment is not set correctly.');
}
/*
*---------------------------------------------------------------
* 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.
*
*/
$system_path = '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. If
* you do, use a full server path. For more info please see the user guide:
* http://codeigniter.com/user_guide/general/managing_apps.html
*
* NO TRAILING SLASH!
*
*/
$application_folder = 'application';
/*
* --------------------------------------------------------------------
* DEFAULT CONTROLLER
* --------------------------------------------------------------------
*
* Normally you will set your default controller in the routes.php file.
* You can, however, force a custom routing by hard-coding a
* specific controller class/function here. For most applications, you
* WILL NOT set your routing here, but it's an option for those
* special instances where you might want to override the standard
* routing in a specific front controller that shares a common CI installation.
*
* IMPORTANT: If you set the routing here, NO OTHER controller will be
* callable. In essence, this preference limits your application to ONE
* specific controller. Leave the function name blank if you need
* to call functions dynamically via the URI.
*
* Un-comment the $routing array below to use this feature
*
*/
// The directory name, relative to the "controllers" folder. Leave blank
// if your controller is not in a sub-folder within the "controllers" folder
// $routing['directory'] = '';
// The controller class file name. Example: Mycontroller.php
// $routing['controller'] = '';
// The controller function you wish to be called.
// $routing['function'] = '';
/*
* -------------------------------------------------------------------
* CUSTOM CONFIG VALUES
* -------------------------------------------------------------------
*
* The $assign_to_config array below will be passed dynamically to the
* config class when initialized. This allows you to set custom config
* items or override any default config values found in the config.php file.
* This can be handy as it permits you to share one application between
* multiple front controller files, with each file containing different
* config values.
*
* Un-comment the $assign_to_config array below to use this feature
*
*/
// $assign_to_config['name_of_config_item'] = 'value of config item';
// --------------------------------------------------------------------
// END OF USER CONFIGURABLE SETTINGS. DO NOT EDIT BELOW THIS LINE
// --------------------------------------------------------------------
/*
* ---------------------------------------------------------------
* Resolve the system path for increased reliability
* ---------------------------------------------------------------
*/
// Set the current directory correctly for CLI requests
if (defined('STDIN'))
{
chdir(dirname(__FILE__));
}
if (realpath($system_path) !== FALSE)
{
$system_path = realpath($system_path).'/';
}
// ensure there's a trailing slash
$system_path = rtrim($system_path, '/').'/';
// Is the system path correct?
if ( ! is_dir($system_path))
{
exit("Your system folder path does not appear to be set correctly. Please open the following file and correct this: ".pathinfo(__FILE__, PATHINFO_BASENAME));
}
/*
* -------------------------------------------------------------------
* Now that we know the path, set the main path constants
* -------------------------------------------------------------------
*/
// The name of THIS file
define('SELF', pathinfo(__FILE__, PATHINFO_BASENAME));
// The PHP file extension
define('EXT', '.php');
// Path to the system folder
define('BASEPATH', str_replace("\\", "/", $system_path));
// Path to the front controller (this file)
define('FCPATH', str_replace(SELF, '', __FILE__));
// Name of the "system folder"
define('SYSDIR', trim(strrchr(trim(BASEPATH, '/'), '/'), '/'));
// The path to the "application" folder
if (is_dir($application_folder))
{
define('APPPATH', $application_folder.'/');
}
else
{
if ( ! is_dir(BASEPATH.$application_folder.'/'))
{
exit("Your application folder path does not appear to be set correctly. Please open the following file and correct this: ".SELF);
}
define('APPPATH', BASEPATH.$application_folder.'/');
}
/*
* --------------------------------------------------------------------
* LOAD THE BOOTSTRAP FILE
* --------------------------------------------------------------------
*
* And away we go...
*
*/
require_once BASEPATH.'core/CodeIgniter'.EXT;
/* End of file index.php */
/* Location: ./index.php */

51
license.txt 100644
Wyświetl plik

@ -0,0 +1,51 @@
Copyright (c) 2008 - 2011, 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.

1
system/.htaccess 100644
Wyświetl plik

@ -0,0 +1 @@
Deny from all

Wyświetl plik

@ -0,0 +1,113 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* CodeIgniter Benchmark Class
*
* This class enables you to mark points and calculate the time difference
* between them. Memory consumption can also be displayed.
*
* @package CodeIgniter
* @subpackage Libraries
* @category Libraries
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/libraries/benchmark.html
*/
class CI_Benchmark {
var $marker = array();
// --------------------------------------------------------------------
/**
* Set a benchmark marker
*
* Multiple calls to this function can be made so that several
* execution points can be timed
*
* @access public
* @param string $name name of the marker
* @return void
*/
function mark($name)
{
$this->marker[$name] = microtime();
}
// --------------------------------------------------------------------
/**
* Calculates the time difference between two marked points.
*
* If the first parameter is empty this function instead returns the
* {elapsed_time} pseudo-variable. This permits the full system
* execution time to be shown in a template. The output class will
* swap the real value for this variable.
*
* @access public
* @param string a particular marked point
* @param string a particular marked point
* @param integer the number of decimal places
* @return mixed
*/
function elapsed_time($point1 = '', $point2 = '', $decimals = 4)
{
if ($point1 == '')
{
return '{elapsed_time}';
}
if ( ! isset($this->marker[$point1]))
{
return '';
}
if ( ! isset($this->marker[$point2]))
{
$this->marker[$point2] = microtime();
}
list($sm, $ss) = explode(' ', $this->marker[$point1]);
list($em, $es) = explode(' ', $this->marker[$point2]);
return number_format(($em + $es) - ($sm + $ss), $decimals);
}
// --------------------------------------------------------------------
/**
* Memory Usage
*
* This function returns the {memory_usage} pseudo-variable.
* This permits it to be put it anywhere in a template
* without the memory being calculated until the end.
* The output class will swap the real value for this variable.
*
* @access public
* @return string
*/
function memory_usage()
{
return '{memory_usage}';
}
}
// END CI_Benchmark class
/* End of file Benchmark.php */
/* Location: ./system/core/Benchmark.php */

Wyświetl plik

@ -0,0 +1,368 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* System Initialization File
*
* 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/
*/
/*
* ------------------------------------------------------
* Define the CodeIgniter Version
* ------------------------------------------------------
*/
define('CI_VERSION', '2.0.1');
/*
* ------------------------------------------------------
* Define the CodeIgniter Branch (Core = TRUE, Reactor = FALSE)
* ------------------------------------------------------
*/
define('CI_CORE', FALSE);
/*
* ------------------------------------------------------
* Load the global functions
* ------------------------------------------------------
*/
require(BASEPATH.'core/Common'.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
}
/*
* ------------------------------------------------------
* Set the subclass_prefix
* ------------------------------------------------------
*
* Normally the "subclass_prefix" is set in the config file.
* The subclass prefix allows CI to know if a core class is
* being extended via a library in the local application
* "libraries" folder. Since CI allows config items to be
* overriden via data set in the main index. php file,
* before proceeding we need to know if a subclass_prefix
* override exists. If so, we will set this value now,
* before any classes are loaded
* Note: Since the config file data is cached it doesn't
* hurt to load it here.
*/
if (isset($assign_to_config['subclass_prefix']) AND $assign_to_config['subclass_prefix'] != '')
{
get_config(array('subclass_prefix' => $assign_to_config['subclass_prefix']));
}
/*
* ------------------------------------------------------
* Set a liberal script execution time limit
* ------------------------------------------------------
*/
if (function_exists("set_time_limit") == TRUE AND @ini_get("safe_mode") == 0)
{
@set_time_limit(300);
}
/*
* ------------------------------------------------------
* Start the timer... tick tock tick tock...
* ------------------------------------------------------
*/
$BM =& load_class('Benchmark', 'core');
$BM->mark('total_execution_time_start');
$BM->mark('loading_time:_base_classes_start');
/*
* ------------------------------------------------------
* Instantiate the hooks class
* ------------------------------------------------------
*/
$EXT =& load_class('Hooks', 'core');
/*
* ------------------------------------------------------
* Is there a "pre_system" hook?
* ------------------------------------------------------
*/
$EXT->_call_hook('pre_system');
/*
* ------------------------------------------------------
* Instantiate the config class
* ------------------------------------------------------
*/
$CFG =& load_class('Config', 'core');
// Do we have any manually set config items in the index.php file?
if (isset($assign_to_config))
{
$CFG->_assign_to_config($assign_to_config);
}
/*
* ------------------------------------------------------
* Instantiate the UTF-8 class
* ------------------------------------------------------
*
* Note: Order here is rather important as the UTF-8
* class needs to be used very early on, but it cannot
* properly determine if UTf-8 can be supported until
* after the Config class is instantiated.
*
*/
$UNI =& load_class('Utf8', 'core');
/*
* ------------------------------------------------------
* Instantiate the URI class
* ------------------------------------------------------
*/
$URI =& load_class('URI', 'core');
/*
* ------------------------------------------------------
* Instantiate the routing class and set the routing
* ------------------------------------------------------
*/
$RTR =& load_class('Router', 'core');
$RTR->_set_routing();
// Set any routing overrides that may exist in the main index file
if (isset($routing))
{
$RTR->_set_overrides($routing);
}
/*
* ------------------------------------------------------
* Instantiate the output class
* ------------------------------------------------------
*/
$OUT =& load_class('Output', 'core');
/*
* ------------------------------------------------------
* 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 Input class and sanitize globals
* ------------------------------------------------------
*/
$IN =& load_class('Input', 'core');
/*
* ------------------------------------------------------
* Load the Language class
* ------------------------------------------------------
*/
$LANG =& load_class('Lang', 'core');
/*
* ------------------------------------------------------
* Load the app controller and local controller
* ------------------------------------------------------
*
*/
// Load the base controller class
require BASEPATH.'core/Controller'.EXT;
function &get_instance()
{
return CI_Controller::get_instance();
}
if (file_exists(APPPATH.'core/'.$CFG->config['subclass_prefix'].'Controller'.EXT))
{
require APPPATH.'core/'.$CFG->config['subclass_prefix'].'Controller'.EXT;
}
// Load the local application controller
// Note: The Router class automatically validates the controller path using the router->_validate_request().
// 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 strncmp($method, '_', 1) == 0
OR in_array(strtolower($method), array_map('strtolower', get_class_methods('CI_Controller')))
)
{
show_404("{$class}/{$method}");
}
/*
* ------------------------------------------------------
* Is there a "pre_controller" hook?
* ------------------------------------------------------
*/
$EXT->_call_hook('pre_controller');
/*
* ------------------------------------------------------
* Instantiate the requested controller
* ------------------------------------------------------
*/
// Mark a start point so we can benchmark the controller
$BM->mark('controller_execution_time_( '.$class.' / '.$method.' )_start');
$CI = new $class();
/*
* ------------------------------------------------------
* Is there a "post_controller_constructor" hook?
* ------------------------------------------------------
*/
$EXT->_call_hook('post_controller_constructor');
/*
* ------------------------------------------------------
* Call the requested method
* ------------------------------------------------------
*/
// Is there a "remap" function? If so, we call it instead
if (method_exists($CI, '_remap'))
{
$CI->_remap($method, array_slice($URI->rsegments, 2));
}
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))))
{
// Check and see if we are using a 404 override and use it.
if ( ! empty($RTR->routes['404_override']))
{
$x = explode('/', $RTR->routes['404_override']);
$class = $x[0];
$method = (isset($x[1]) ? $x[1] : 'index');
if ( ! class_exists($class))
{
if ( ! file_exists(APPPATH.'controllers/'.$class.EXT))
{
show_404("{$class}/{$method}");
}
include_once(APPPATH.'controllers/'.$class.EXT);
unset($CI);
$CI = new $class();
}
}
else
{
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/core/CodeIgniter.php */

Wyświetl plik

@ -0,0 +1,508 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* Common Functions
*
* Loads the base classes and executes the request.
*
* @package CodeIgniter
* @subpackage codeigniter
* @category Common Functions
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/
*/
// ------------------------------------------------------------------------
/**
* 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 TRUE if the current version is $version or higher
*/
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(mt_rand(1,100).mt_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 string the directory where the class should be found
* @param string the class name prefix
* @return object
*/
function &load_class($class, $directory = 'libraries', $prefix = 'CI_')
{
static $_classes = array();
// Does the class exist? If so, we're done...
if (isset($_classes[$class]))
{
return $_classes[$class];
}
$name = FALSE;
// Look for the class first in the native system/libraries folder
// thenin the local application/libraries folder
foreach (array(BASEPATH, APPPATH) as $path)
{
if (file_exists($path.$directory.'/'.$class.EXT))
{
$name = $prefix.$class;
if (class_exists($name) === FALSE)
{
require($path.$directory.'/'.$class.EXT);
}
break;
}
}
// Is the request a class extension? If so we load it too
if (file_exists(APPPATH.$directory.'/'.config_item('subclass_prefix').$class.EXT))
{
$name = config_item('subclass_prefix').$class;
if (class_exists($name) === FALSE)
{
require(APPPATH.$directory.'/'.config_item('subclass_prefix').$class.EXT);
}
}
// Did we find the class?
if ($name === FALSE)
{
// Note: We use exit() rather then show_error() in order to avoid a
// self-referencing loop with the Excptions class
exit('Unable to locate the specified class: '.$class.EXT);
}
// Keep track of what we just loaded
is_loaded($class);
$_classes[$class] = new $name();
return $_classes[$class];
}
// --------------------------------------------------------------------
/**
* Keeps track of which libraries have been loaded. This function is
* called by the load_class() function above
*
* @access public
* @return array
*/
function is_loaded($class = '')
{
static $_is_loaded = array();
if ($class != '')
{
$_is_loaded[strtolower($class)] = $class;
}
return $_is_loaded;
}
// ------------------------------------------------------------------------
/**
* Loads the main config.php file
*
* This function lets us grab the config file even if the Config class
* hasn't been instantiated yet
*
* @access private
* @return array
*/
function &get_config($replace = array())
{
static $_config;
if (isset($_config))
{
return $_config[0];
}
$file_path = APPPATH.'config/'.ENVIRONMENT.'/config'.EXT;
// Fetch the config file
if ( ! file_exists($file_path))
{
$file_path = APPPATH.'config/config'.EXT;
if ( ! file_exists($file_path))
{
exit('The configuration file does not exist.');
}
}
require($file_path);
// Does the $config array exist in the file?
if ( ! isset($config) OR ! is_array($config))
{
exit('Your config file does not appear to be formatted correctly.');
}
// Are any values being dynamically replaced?
if (count($replace) > 0)
{
foreach ($replace as $key => $val)
{
if (isset($config[$key]))
{
$config[$key] = $val;
}
}
}
return $_config[0] =& $config;
}
// ------------------------------------------------------------------------
/**
* Returns the specified 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, $heading = 'An Error Was Encountered')
{
$_error =& load_class('Exceptions', 'core');
echo $_error->show_error($heading, $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 = '', $log_error = TRUE)
{
$_error =& load_class('Exceptions', 'core');
$_error->show_404($page, $log_error);
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;
if (config_item('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 to permit
* PHP errors to be logged in our own log files since the user 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 tend to fill up
// the log file with excess 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', 'core');
// 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...
if (config_item('log_threshold') == 0)
{
return;
}
$_error->log_exception($severity, $message, $filepath, $line);
}
// --------------------------------------------------------------------
/**
* Remove Invisible Characters
*
* This prevents sandwiching null characters
* between ascii characters, like Java\0script.
*
* @access public
* @param string
* @return string
*/
function remove_invisible_characters($str)
{
static $non_displayables;
if ( ! isset($non_displayables))
{
// every control character except newline (dec 10), carriage return (dec 13), and horizontal tab (dec 09),
$non_displayables = array(
'/%0[0-8bcef]/', // url encoded 00-08, 11, 12, 14, 15
'/%1[0-9a-f]/', // url encoded 16-31
'/[\x00-\x08]/', // 00-08
'/\x0b/', '/\x0c/', // 11, 12
'/[\x0e-\x1f]/' // 14-31
);
}
do
{
$cleaned = $str;
$str = preg_replace($non_displayables, '', $str);
}
while ($cleaned != $str);
return $str;
}
/* End of file Common.php */
/* Location: ./system/core/Common.php */

Wyświetl plik

@ -0,0 +1,321 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* CodeIgniter Config Class
*
* This class contains functions that enable config files to be managed
*
* @package CodeIgniter
* @subpackage Libraries
* @category Libraries
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/libraries/config.html
*/
class CI_Config {
var $config = array();
var $is_loaded = array();
var $_config_paths = array(APPPATH);
/**
* Constructor
*
* Sets the $config data from the primary config.php file as a class variable
*
* @access public
* @param string the config file name
* @param boolean if configuration values should be loaded into their own section
* @param boolean true if errors should just return false, false if an error message should be displayed
* @return boolean if the file was successfully loaded or not
*/
function __construct()
{
$this->config =& get_config();
log_message('debug', "Config Class Initialized");
// Set the base_url automatically if none was provided
if ($this->config['base_url'] == '')
{
if (isset($_SERVER['HTTP_HOST']))
{
$base_url = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off' ? 'https' : 'http';
$base_url .= '://'. $_SERVER['HTTP_HOST'];
$base_url .= str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']);
}
else
{
$base_url = 'http://localhost/';
}
$this->set_item('base_url', $base_url);
}
}
// --------------------------------------------------------------------
/**
* Load Config File
*
* @access public
* @param string the config file name
* @param boolean if configuration values should be loaded into their own section
* @param boolean true if errors should just return false, false if an error message should be displayed
* @return boolean if the file was loaded correctly
*/
function load($file = '', $use_sections = FALSE, $fail_gracefully = FALSE)
{
$file = ($file == '') ? 'config' : str_replace(EXT, '', $file);
$loaded = FALSE;
foreach ($this->_config_paths as $path)
{
$file_path = $path.'config/'.ENVIRONMENT.'/'.$file.EXT;
if (in_array($file_path, $this->is_loaded, TRUE))
{
$loaded = TRUE;
continue;
}
if ( ! file_exists($file_path))
{
log_message('debug', 'Config for '.ENVIRONMENT.' environment is not found. Trying global config.');
$file_path = $path.'config/'.$file.EXT;
if ( ! file_exists($file_path))
{
continue;
}
}
include($file_path);
if ( ! isset($config) OR ! is_array($config))
{
if ($fail_gracefully === TRUE)
{
return FALSE;
}
show_error('Your '.$file_path.' file does not appear to contain a valid configuration array.');
}
if ($use_sections === TRUE)
{
if (isset($this->config[$file]))
{
$this->config[$file] = array_merge($this->config[$file], $config);
}
else
{
$this->config[$file] = $config;
}
}
else
{
$this->config = array_merge($this->config, $config);
}
$this->is_loaded[] = $file_path;
unset($config);
$loaded = TRUE;
log_message('debug', 'Config file loaded: '.$file_path);
}
if ($loaded === FALSE)
{
if ($fail_gracefully === TRUE)
{
return FALSE;
}
show_error('The configuration file '.ENVIRONMENT.'/'.$file.EXT.' and '.$file.EXT.' do not exist.');
}
return TRUE;
}
// --------------------------------------------------------------------
/**
* Fetch a config file item
*
*
* @access public
* @param string the config item name
* @param string the index name
* @param bool
* @return string
*/
function item($item, $index = '')
{
if ($index == '')
{
if ( ! isset($this->config[$item]))
{
return FALSE;
}
$pref = $this->config[$item];
}
else
{
if ( ! isset($this->config[$index]))
{
return FALSE;
}
if ( ! isset($this->config[$index][$item]))
{
return FALSE;
}
$pref = $this->config[$index][$item];
}
return $pref;
}
// --------------------------------------------------------------------
/**
* Fetch a config file item - adds slash after item
*
* The second parameter allows a slash to be added to the end of
* the item, in the case of a path.
*
* @access public
* @param string the config item name
* @param bool
* @return string
*/
function slash_item($item)
{
if ( ! isset($this->config[$item]))
{
return FALSE;
}
return rtrim($this->config[$item], '/').'/';
}
// --------------------------------------------------------------------
/**
* Site URL
*
* @access public
* @param string the URI string
* @return string
*/
function site_url($uri = '')
{
if ($uri == '')
{
return $this->slash_item('base_url').$this->item('index_page');
}
if ($this->item('enable_query_strings') == FALSE)
{
if (is_array($uri))
{
$uri = implode('/', $uri);
}
$index = $this->item('index_page') == '' ? '' : $this->slash_item('index_page');
$suffix = ($this->item('url_suffix') == FALSE) ? '' : $this->item('url_suffix');
return $this->slash_item('base_url').$index.trim($uri, '/').$suffix;
}
else
{
if (is_array($uri))
{
$i = 0;
$str = '';
foreach ($uri as $key => $val)
{
$prefix = ($i == 0) ? '' : '&';
$str .= $prefix.$key.'='.$val;
$i++;
}
$uri = $str;
}
return $this->slash_item('base_url').$this->item('index_page').'?'.$uri;
}
}
// --------------------------------------------------------------------
/**
* System URL
*
* @access public
* @return string
*/
function system_url()
{
$x = explode("/", preg_replace("|/*(.+?)/*$|", "\\1", BASEPATH));
return $this->slash_item('base_url').end($x).'/';
}
// --------------------------------------------------------------------
/**
* Set a config file item
*
* @access public
* @param string the config item key
* @param string the config item value
* @return void
*/
function set_item($item, $value)
{
$this->config[$item] = $value;
}
// --------------------------------------------------------------------
/**
* Assign to Config
*
* This function is called by the front controller (CodeIgniter.php)
* after the Config class is instantiated. It permits config items
* to be assigned or overriden by variables contained in the index.php file
*
* @access private
* @param array
* @return void
*/
function _assign_to_config($items = array())
{
if (is_array($items))
{
foreach ($items as $key => $val)
{
$this->set_item($key, $val);
}
}
}
}
// END CI_Config class
/* End of file Config.php */
/* Location: ./system/core/Config.php */

Wyświetl plik

@ -0,0 +1,67 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* CodeIgniter Application Controller Class
*
* This class object is the super class that every library in
* CodeIgniter will be assigned to.
*
* @package CodeIgniter
* @subpackage Libraries
* @category Libraries
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/general/controllers.html
*/
class CI_Controller {
private static $instance;
/**
* Constructor
*/
public function __construct()
{
self::$instance =& $this;
// Assign all the class objects that were instantiated by the
// bootstrap file (CodeIgniter.php) to local class variables
// so that CI can run as one big super object.
foreach (is_loaded() as $var => $class)
{
$this->$var =& load_class($class);
}
$this->load =& load_class('Loader', 'core');
$this->load->_base_classes =& is_loaded();
$this->load->_ci_autoloader();
log_message('debug', "Controller Class Initialized");
}
public static function &get_instance()
{
return self::$instance;
}
}
// END Controller class
/* End of file Controller.php */
/* Location: ./system/core/Controller.php */

Wyświetl plik

@ -0,0 +1,178 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* Exceptions Class
*
* @package CodeIgniter
* @subpackage Libraries
* @category Exceptions
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/libraries/exceptions.html
*/
class CI_Exceptions {
var $action;
var $severity;
var $message;
var $filename;
var $line;
var $ob_level;
var $levels = array(
E_ERROR => 'Error',
E_WARNING => 'Warning',
E_PARSE => 'Parsing Error',
E_NOTICE => 'Notice',
E_CORE_ERROR => 'Core Error',
E_CORE_WARNING => 'Core Warning',
E_COMPILE_ERROR => 'Compile Error',
E_COMPILE_WARNING => 'Compile Warning',
E_USER_ERROR => 'User Error',
E_USER_WARNING => 'User Warning',
E_USER_NOTICE => 'User Notice',
E_STRICT => 'Runtime Notice'
);
/**
* Constructor
*/
public function __construct()
{
$this->ob_level = ob_get_level();
// Note: Do not log messages from this constructor.
}
// --------------------------------------------------------------------
/**
* Exception Logger
*
* This function logs PHP generated error messages
*
* @access private
* @param string the error severity
* @param string the error string
* @param string the error filepath
* @param string the error line number
* @return string
*/
function log_exception($severity, $message, $filepath, $line)
{
$severity = ( ! isset($this->levels[$severity])) ? $severity : $this->levels[$severity];
log_message('error', 'Severity: '.$severity.' --> '.$message. ' '.$filepath.' '.$line, TRUE);
}
// --------------------------------------------------------------------
/**
* 404 Page Not Found Handler
*
* @access private
* @param string
* @return string
*/
function show_404($page = '', $log_error = TRUE)
{
$heading = "404 Page Not Found";
$message = "The page you requested was not found.";
// By default we log this, but allow a dev to skip it
if ($log_error)
{
log_message('error', '404 Page Not Found --> '.$page);
}
echo $this->show_error($heading, $message, 'error_404', 404);
exit;
}
// --------------------------------------------------------------------
/**
* General Error Page
*
* This function takes an error message as input
* (either as a string or an array) and displays
* it using the specified template.
*
* @access private
* @param string the heading
* @param string the message
* @param string the template name
* @return string
*/
function show_error($heading, $message, $template = 'error_general', $status_code = 500)
{
set_status_header($status_code);
$message = '<p>'.implode('</p><p>', ( ! is_array($message)) ? array($message) : $message).'</p>';
if (ob_get_level() > $this->ob_level + 1)
{
ob_end_flush();
}
ob_start();
include(APPPATH.'errors/'.$template.EXT);
$buffer = ob_get_contents();
ob_end_clean();
return $buffer;
}
// --------------------------------------------------------------------
/**
* Native PHP error handler
*
* @access private
* @param string the error severity
* @param string the error string
* @param string the error filepath
* @param string the error line number
* @return string
*/
function show_php_error($severity, $message, $filepath, $line)
{
$severity = ( ! isset($this->levels[$severity])) ? $severity : $this->levels[$severity];
$filepath = str_replace("\\", "/", $filepath);
// For safety reasons we do not show the full file path
if (FALSE !== strpos($filepath, '/'))
{
$x = explode('/', $filepath);
$filepath = $x[count($x)-2].'/'.end($x);
}
if (ob_get_level() > $this->ob_level + 1)
{
ob_end_flush();
}
ob_start();
include(APPPATH.'errors/error_php'.EXT);
$buffer = ob_get_contents();
ob_end_clean();
echo $buffer;
}
}
// END Exceptions Class
/* End of file Exceptions.php */
/* Location: ./system/core/Exceptions.php */

Wyświetl plik

@ -0,0 +1,225 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* CodeIgniter Hooks Class
*
* Provides a mechanism to extend the base system without hacking.
*
* @package CodeIgniter
* @subpackage Libraries
* @category Libraries
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/libraries/encryption.html
*/
class CI_Hooks {
var $enabled = FALSE;
var $hooks = array();
var $in_progress = FALSE;
/**
* Constructor
*
*/
function __construct()
{
$this->_initialize();
log_message('debug', "Hooks Class Initialized");
}
// --------------------------------------------------------------------
/**
* Initialize the Hooks Preferences
*
* @access private
* @return void
*/
function _initialize()
{
$CFG =& load_class('Config', 'core');
// If hooks are not enabled in the config file
// there is nothing else to do
if ($CFG->item('enable_hooks') == FALSE)
{
return;
}
// Grab the "hooks" definition file.
// If there are no hooks, we're done.
@include(APPPATH.'config/hooks'.EXT);
if ( ! isset($hook) OR ! is_array($hook))
{
return;
}
$this->hooks =& $hook;
$this->enabled = TRUE;
}
// --------------------------------------------------------------------
/**
* Call Hook
*
* Calls a particular hook
*
* @access private
* @param string the hook name
* @return mixed
*/
function _call_hook($which = '')
{
if ( ! $this->enabled OR ! isset($this->hooks[$which]))
{
return FALSE;
}
if (isset($this->hooks[$which][0]) AND is_array($this->hooks[$which][0]))
{
foreach ($this->hooks[$which] as $val)
{
$this->_run_hook($val);
}
}
else
{
$this->_run_hook($this->hooks[$which]);
}
return TRUE;
}
// --------------------------------------------------------------------
/**
* Run Hook
*
* Runs a particular hook
*
* @access private
* @param array the hook details
* @return bool
*/
function _run_hook($data)
{
if ( ! is_array($data))
{
return FALSE;
}
// -----------------------------------
// Safety - Prevents run-away loops
// -----------------------------------
// If the script being called happens to have the same
// hook call within it a loop can happen
if ($this->in_progress == TRUE)
{
return;
}
// -----------------------------------
// Set file path
// -----------------------------------
if ( ! isset($data['filepath']) OR ! isset($data['filename']))
{
return FALSE;
}
$filepath = APPPATH.$data['filepath'].'/'.$data['filename'];
if ( ! file_exists($filepath))
{
return FALSE;
}
// -----------------------------------
// Set class/function name
// -----------------------------------
$class = FALSE;
$function = FALSE;
$params = '';
if (isset($data['class']) AND $data['class'] != '')
{
$class = $data['class'];
}
if (isset($data['function']))
{
$function = $data['function'];
}
if (isset($data['params']))
{
$params = $data['params'];
}
if ($class === FALSE AND $function === FALSE)
{
return FALSE;
}
// -----------------------------------
// Set the in_progress flag
// -----------------------------------
$this->in_progress = TRUE;
// -----------------------------------
// Call the requested class and/or function
// -----------------------------------
if ($class !== FALSE)
{
if ( ! class_exists($class))
{
require($filepath);
}
$HOOK = new $class;
$HOOK->$function($params);
}
else
{
if ( ! function_exists($function))
{
require($filepath);
}
$function($params);
}
$this->in_progress = FALSE;
return TRUE;
}
}
// END CI_Hooks class
/* End of file Hooks.php */
/* Location: ./system/core/Hooks.php */

Wyświetl plik

@ -0,0 +1,684 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* Input Class
*
* Pre-processes global input data for security
*
* @package CodeIgniter
* @subpackage Libraries
* @category Input
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/libraries/input.html
*/
class CI_Input {
var $ip_address = FALSE;
var $user_agent = FALSE;
var $_allow_get_array = TRUE;
var $_standardize_newlines = TRUE;
var $_enable_xss = FALSE; // Set automatically based on config setting
var $_enable_csrf = FALSE; // Set automatically based on config setting
protected $headers = array();
/**
* Constructor
*
* Sets whether to globally enable the XSS processing
* and whether to allow the $_GET array
*
*/
public function __construct()
{
log_message('debug', "Input Class Initialized");
$this->_allow_get_array = (config_item('allow_get_array') === TRUE);
$this->_enable_xss = (config_item('global_xss_filtering') === TRUE);
$this->_enable_csrf = (config_item('csrf_protection') === TRUE);
// Do we need to load the security class?
if ($this->_enable_xss == TRUE OR $this->_enable_csrf == TRUE)
{
$this->security =& load_class('Security');
}
// Do we need the UTF-8 class?
if (UTF8_ENABLED === TRUE)
{
global $UNI;
$this->uni =& $UNI;
}
// Sanitize global arrays
$this->_sanitize_globals();
}
// --------------------------------------------------------------------
/**
* Fetch from array
*
* This is a helper function to retrieve values from global arrays
*
* @access private
* @param array
* @param string
* @param bool
* @return string
*/
function _fetch_from_array(&$array, $index = '', $xss_clean = FALSE)
{
if ( ! isset($array[$index]))
{
return FALSE;
}
if ($xss_clean === TRUE)
{
$_security =& load_class('Security');
return $_security->xss_clean($array[$index]);
}
return $array[$index];
}
// --------------------------------------------------------------------
/**
* Fetch an item from the GET array
*
* @access public
* @param string
* @param bool
* @return string
*/
function get($index = NULL, $xss_clean = FALSE)
{
// Check if a field has been provided
if ($index === NULL AND ! empty($_GET))
{
$get = array();
// loop through the full _GET array
foreach (array_keys($_GET) as $key)
{
$get[$key] = $this->_fetch_from_array($_GET, $key, $xss_clean);
}
return $get;
}
return $this->_fetch_from_array($_GET, $index, $xss_clean);
}
// --------------------------------------------------------------------
/**
* Fetch an item from the POST array
*
* @access public
* @param string
* @param bool
* @return string
*/
function post($index = NULL, $xss_clean = FALSE)
{
// Check if a field has been provided
if ($index === NULL AND ! empty($_POST))
{
$post = array();
// Loop through the full _POST array and return it
foreach (array_keys($_POST) as $key)
{
$post[$key] = $this->_fetch_from_array($_POST, $key, $xss_clean);
}
return $post;
}
return $this->_fetch_from_array($_POST, $index, $xss_clean);
}
// --------------------------------------------------------------------
/**
* Fetch an item from either the GET array or the POST
*
* @access public
* @param string The index key
* @param bool XSS cleaning
* @return string
*/
function get_post($index = '', $xss_clean = FALSE)
{
if ( ! isset($_POST[$index]) )
{
return $this->get($index, $xss_clean);
}
else
{
return $this->post($index, $xss_clean);
}
}
// --------------------------------------------------------------------
/**
* Fetch an item from the COOKIE array
*
* @access public
* @param string
* @param bool
* @return string
*/
function cookie($index = '', $xss_clean = FALSE)
{
return $this->_fetch_from_array($_COOKIE, $index, $xss_clean);
}
// ------------------------------------------------------------------------
/**
* Set cookie
*
* Accepts six parameter, or you can submit an associative
* array in the first parameter containing all the values.
*
* @access public
* @param mixed
* @param string the value of the cookie
* @param string the number of seconds until expiration
* @param string the cookie domain. Usually: .yourdomain.com
* @param string the cookie path
* @param string the cookie prefix
* @param bool true makes the cookie secure
* @return void
*/
function set_cookie($name = '', $value = '', $expire = '', $domain = '', $path = '/', $prefix = '', $secure = FALSE)
{
if (is_array($name))
{
// always leave 'name' in last place, as the loop will break otherwise, due to $$item
foreach (array('value', 'expire', 'domain', 'path', 'prefix', 'secure', 'name') as $item)
{
if (isset($name[$item]))
{
$$item = $name[$item];
}
}
}
if ($prefix == '' AND config_item('cookie_prefix') != '')
{
$prefix = config_item('cookie_prefix');
}
if ($domain == '' AND config_item('cookie_domain') != '')
{
$domain = config_item('cookie_domain');
}
if ($path == '/' AND config_item('cookie_path') != '/')
{
$path = config_item('cookie_path');
}
if ($secure == FALSE AND config_item('cookie_secure') != FALSE)
{
$secure = config_item('cookie_secure');
}
if ( ! is_numeric($expire))
{
$expire = time() - 86500;
}
else
{
$expire = ($expire > 0) ? time() + $expire : 0;
}
setcookie($prefix.$name, $value, $expire, $path, $domain, $secure);
}
// --------------------------------------------------------------------
/**
* Fetch an item from the SERVER array
*
* @access public
* @param string
* @param bool
* @return string
*/
function server($index = '', $xss_clean = FALSE)
{
return $this->_fetch_from_array($_SERVER, $index, $xss_clean);
}
// --------------------------------------------------------------------
/**
* Fetch the IP Address
*
* @access public
* @return string
*/
function ip_address()
{
if ($this->ip_address !== FALSE)
{
return $this->ip_address;
}
if (config_item('proxy_ips') != '' && $this->server('HTTP_X_FORWARDED_FOR') && $this->server('REMOTE_ADDR'))
{
$proxies = preg_split('/[\s,]/', config_item('proxy_ips'), -1, PREG_SPLIT_NO_EMPTY);
$proxies = is_array($proxies) ? $proxies : array($proxies);
$this->ip_address = in_array($_SERVER['REMOTE_ADDR'], $proxies) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR'];
}
elseif ($this->server('REMOTE_ADDR') AND $this->server('HTTP_CLIENT_IP'))
{
$this->ip_address = $_SERVER['HTTP_CLIENT_IP'];
}
elseif ($this->server('REMOTE_ADDR'))
{
$this->ip_address = $_SERVER['REMOTE_ADDR'];
}
elseif ($this->server('HTTP_CLIENT_IP'))
{
$this->ip_address = $_SERVER['HTTP_CLIENT_IP'];
}
elseif ($this->server('HTTP_X_FORWARDED_FOR'))
{
$this->ip_address = $_SERVER['HTTP_X_FORWARDED_FOR'];
}
if ($this->ip_address === FALSE)
{
$this->ip_address = '0.0.0.0';
return $this->ip_address;
}
if (strpos($this->ip_address, ',') !== FALSE)
{
$x = explode(',', $this->ip_address);
$this->ip_address = trim(end($x));
}
if ( ! $this->valid_ip($this->ip_address))
{
$this->ip_address = '0.0.0.0';
}
return $this->ip_address;
}
// --------------------------------------------------------------------
/**
* Validate IP Address
*
* Updated version suggested by Geert De Deckere
*
* @access public
* @param string
* @return string
*/
function valid_ip($ip)
{
$ip_segments = explode('.', $ip);
// Always 4 segments needed
if (count($ip_segments) != 4)
{
return FALSE;
}
// IP can not start with 0
if ($ip_segments[0][0] == '0')
{
return FALSE;
}
// Check each segment
foreach ($ip_segments as $segment)
{
// IP segments must be digits and can not be
// longer than 3 digits or greater then 255
if ($segment == '' OR preg_match("/[^0-9]/", $segment) OR $segment > 255 OR strlen($segment) > 3)
{
return FALSE;
}
}
return TRUE;
}
// --------------------------------------------------------------------
/**
* User Agent
*
* @access public
* @return string
*/
function user_agent()
{
if ($this->user_agent !== FALSE)
{
return $this->user_agent;
}
$this->user_agent = ( ! isset($_SERVER['HTTP_USER_AGENT'])) ? FALSE : $_SERVER['HTTP_USER_AGENT'];
return $this->user_agent;
}
// --------------------------------------------------------------------
/**
* Sanitize Globals
*
* This function does the following:
*
* Unsets $_GET data (if query strings are not enabled)
*
* Unsets all globals if register_globals is enabled
*
* Standardizes newline characters to \n
*
* @access private
* @return void
*/
function _sanitize_globals()
{
// It would be "wrong" to unset any of these GLOBALS.
$protected = array('_SERVER', '_GET', '_POST', '_FILES', '_REQUEST',
'_SESSION', '_ENV', 'GLOBALS', 'HTTP_RAW_POST_DATA',
'system_folder', 'application_folder', 'BM', 'EXT',
'CFG', 'URI', 'RTR', 'OUT', 'IN');
// Unset globals for securiy.
// This is effectively the same as register_globals = off
foreach (array($_GET, $_POST, $_COOKIE) as $global)
{
if ( ! is_array($global))
{
if ( ! in_array($global, $protected))
{
global $$global;
$$global = NULL;
}
}
else
{
foreach ($global as $key => $val)
{
if ( ! in_array($key, $protected))
{
global $$key;
$$key = NULL;
}
}
}
}
// Is $_GET data allowed? If not we'll set the $_GET to an empty array
if ($this->_allow_get_array == FALSE)
{
$_GET = array();
}
else
{
if (is_array($_GET) AND count($_GET) > 0)
{
foreach ($_GET as $key => $val)
{
$_GET[$this->_clean_input_keys($key)] = $this->_clean_input_data($val);
}
}
}
// Clean $_POST Data
if (is_array($_POST) AND count($_POST) > 0)
{
foreach ($_POST as $key => $val)
{
$_POST[$this->_clean_input_keys($key)] = $this->_clean_input_data($val);
}
}
// Clean $_COOKIE Data
if (is_array($_COOKIE) AND count($_COOKIE) > 0)
{
// Also get rid of specially treated cookies that might be set by a server
// or silly application, that are of no use to a CI application anyway
// but that when present will trip our 'Disallowed Key Characters' alarm
// http://www.ietf.org/rfc/rfc2109.txt
// note that the key names below are single quoted strings, and are not PHP variables
unset($_COOKIE['$Version']);
unset($_COOKIE['$Path']);
unset($_COOKIE['$Domain']);
foreach ($_COOKIE as $key => $val)
{
$_COOKIE[$this->_clean_input_keys($key)] = $this->_clean_input_data($val);
}
}
// Sanitize PHP_SELF
$_SERVER['PHP_SELF'] = strip_tags($_SERVER['PHP_SELF']);
// CSRF Protection check
if ($this->_enable_csrf == TRUE)
{
$this->security->csrf_verify();
}
log_message('debug', "Global POST and COOKIE data sanitized");
}
// --------------------------------------------------------------------
/**
* Clean Input Data
*
* This is a helper function. It escapes data and
* standardizes newline characters to \n
*
* @access private
* @param string
* @return string
*/
function _clean_input_data($str)
{
if (is_array($str))
{
$new_array = array();
foreach ($str as $key => $val)
{
$new_array[$this->_clean_input_keys($key)] = $this->_clean_input_data($val);
}
return $new_array;
}
// We strip slashes if magic quotes is on to keep things consistent
if (function_exists('get_magic_quotes_gpc') AND get_magic_quotes_gpc())
{
$str = stripslashes($str);
}
// Clean UTF-8 if supported
if (UTF8_ENABLED === TRUE)
{
$str = $this->uni->clean_string($str);
}
// Should we filter the input data?
if ($this->_enable_xss === TRUE)
{
$str = $this->security->xss_clean($str);
}
// Standardize newlines if needed
if ($this->_standardize_newlines == TRUE)
{
if (strpos($str, "\r") !== FALSE)
{
$str = str_replace(array("\r\n", "\r"), PHP_EOL, $str);
}
}
return $str;
}
// --------------------------------------------------------------------
/**
* Clean Keys
*
* This is a helper function. To prevent malicious users
* from trying to exploit keys we make sure that keys are
* only named with alpha-numeric text and a few other items.
*
* @access private
* @param string
* @return string
*/
function _clean_input_keys($str)
{
if ( ! preg_match("/^[a-z0-9:_\/-]+$/i", $str))
{
exit('Disallowed Key Characters.');
}
// Clean UTF-8 if supported
if (UTF8_ENABLED === TRUE)
{
$str = $this->uni->clean_string($str);
}
return $str;
}
// --------------------------------------------------------------------
/**
* Request Headers
*
* In Apache, you can simply call apache_request_headers(), however for
* people running other webservers the function is undefined.
*
* @return array
*/
public function request_headers($xss_clean = FALSE)
{
// Look at Apache go!
if (function_exists('apache_request_headers'))
{
$headers = apache_request_headers();
}
else
{
$headers['Content-Type'] = (isset($_SERVER['CONTENT_TYPE'])) ? $_SERVER['CONTENT_TYPE'] : @getenv('CONTENT_TYPE');
foreach ($_SERVER as $key => $val)
{
if (strncmp($key, 'HTTP_', 5) === 0)
{
$headers[substr($key, 5)] = $this->_fetch_from_array($_SERVER, $key, $xss_clean);
}
}
}
// take SOME_HEADER and turn it into Some-Header
foreach ($headers as $key => $val)
{
$key = str_replace('_', ' ', strtolower($key));
$key = str_replace(' ', '-', ucwords($key));
$this->headers[$key] = $val;
}
return $this->headers;
}
// --------------------------------------------------------------------
/**
* Get Request Header
*
* Returns the value of a single member of the headers class member
*
* @param string array key for $this->headers
* @param boolean XSS Clean or not
* @return mixed FALSE on failure, string on success
*/
public function get_request_header($index, $xss_clean = FALSE)
{
if (empty($this->headers))
{
$this->request_headers();
}
if ( ! isset($this->headers[$index]))
{
return FALSE;
}
if ($xss_clean === TRUE)
{
$_security =& load_class('Security');
return $_security->xss_clean($this->headers[$index]);
}
return $this->headers[$index];
}
// --------------------------------------------------------------------
/**
* Is ajax Request?
*
* Test to see if a request contains the HTTP_X_REQUESTED_WITH header
*
* @return boolean
*/
public function is_ajax_request()
{
return ($this->server('HTTP_X_REQUESTED_WITH') === 'XMLHttpRequest');
}
// --------------------------------------------------------------------
/**
* Is cli Request?
*
* Test to see if a request was made from the command line
*
* @return boolean
*/
public function is_cli_request()
{
return (bool) defined('STDIN');
}
}
// END Input class
/* End of file Input.php */
/* Location: ./system/core/Input.php */

Wyświetl plik

@ -0,0 +1,140 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* Language Class
*
* @package CodeIgniter
* @subpackage Libraries
* @category Language
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/libraries/language.html
*/
class CI_Lang {
var $language = array();
var $is_loaded = array();
/**
* Constructor
*
* @access public
*/
function __construct()
{
log_message('debug', "Language Class Initialized");
}
// --------------------------------------------------------------------
/**
* Load a language file
*
* @access public
* @param mixed the name of the language file to be loaded. Can be an array
* @param string the language (english, etc.)
* @return mixed
*/
function load($langfile = '', $idiom = '', $return = FALSE, $add_suffix = TRUE, $alt_path = '')
{
$langfile = str_replace(EXT, '', $langfile);
if ($add_suffix == TRUE)
{
$langfile = str_replace('_lang.', '', $langfile).'_lang';
}
$langfile .= EXT;
if (in_array($langfile, $this->is_loaded, TRUE))
{
return;
}
$config =& get_config();
if ($idiom == '')
{
$deft_lang = ( ! isset($config['language'])) ? 'english' : $config['language'];
$idiom = ($deft_lang == '') ? 'english' : $deft_lang;
}
// Determine where the language file is and load it
if ($alt_path != '' && file_exists($alt_path.'language/'.$idiom.'/'.$langfile))
{
include($alt_path.'language/'.$idiom.'/'.$langfile);
}
else
{
$found = FALSE;
foreach (get_instance()->load->get_package_paths(TRUE) as $package_path)
{
if (file_exists($package_path.'language/'.$idiom.'/'.$langfile))
{
include($package_path.'language/'.$idiom.'/'.$langfile);
$found = TRUE;
break;
}
}
if ($found !== TRUE)
{
show_error('Unable to load the requested language file: language/'.$idiom.'/'.$langfile);
}
}
if ( ! isset($lang))
{
log_message('error', 'Language file contains no data: language/'.$idiom.'/'.$langfile);
return;
}
if ($return == TRUE)
{
return $lang;
}
$this->is_loaded[] = $langfile;
$this->language = array_merge($this->language, $lang);
unset($lang);
log_message('debug', 'Language file loaded: language/'.$idiom.'/'.$langfile);
return TRUE;
}
// --------------------------------------------------------------------
/**
* Fetch a single line of text from the language array
*
* @access public
* @param string $line the language line
* @return string
*/
function line($line = '')
{
$line = ($line == '' OR ! isset($this->language[$line])) ? FALSE : $this->language[$line];
return $line;
}
}
// END Language Class
/* End of file Lang.php */
/* Location: ./system/core/Lang.php */

Plik diff jest za duży Load Diff

Wyświetl plik

@ -0,0 +1,56 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* CodeIgniter Model Class
*
* @package CodeIgniter
* @subpackage Libraries
* @category Libraries
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/libraries/config.html
*/
class CI_Model {
/**
* Constructor
*
* @access public
*/
function __construct()
{
log_message('debug', "Model Class Initialized");
}
/**
* __get
*
* Allows models to access CI's loaded classes using the same
* syntax as controllers.
*
* @access private
*/
function __get($key)
{
$CI =& get_instance();
return $CI->$key;
}
}
// END Model Class
/* End of file Model.php */
/* Location: ./system/core/Model.php */

Wyświetl plik

@ -0,0 +1,509 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* Output Class
*
* Responsible for sending final output to browser
*
* @package CodeIgniter
* @subpackage Libraries
* @category Output
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/libraries/output.html
*/
class CI_Output {
protected $final_output;
protected $cache_expiration = 0;
protected $headers = array();
protected $mime_types = array();
protected $enable_profiler = FALSE;
protected $parse_exec_vars = TRUE; // whether or not to parse variables like {elapsed_time} and {memory_usage}
protected $_zlib_oc = FALSE;
protected $_profiler_sections = array();
function __construct()
{
$this->_zlib_oc = @ini_get('zlib.output_compression');
// Get mime types for later
include APPPATH.'config/mimes'.EXT;
$this->mime_types = $mimes;
log_message('debug', "Output Class Initialized");
}
// --------------------------------------------------------------------
/**
* Get Output
*
* Returns the current output string
*
* @access public
* @return string
*/
function get_output()
{
return $this->final_output;
}
// --------------------------------------------------------------------
/**
* Set Output
*
* Sets the output string
*
* @access public
* @param string
* @return void
*/
function set_output($output)
{
$this->final_output = $output;
return $this;
}
// --------------------------------------------------------------------
/**
* Append Output
*
* Appends data onto the output string
*
* @access public
* @param string
* @return void
*/
function append_output($output)
{
if ($this->final_output == '')
{
$this->final_output = $output;
}
else
{
$this->final_output .= $output;
}
return $this;
}
// --------------------------------------------------------------------
/**
* Set Header
*
* Lets you set a server header which will be outputted with the final display.
*
* Note: If a file is cached, headers will not be sent. We need to figure out
* how to permit header data to be saved with the cache data...
*
* @access public
* @param string
* @return void
*/
function set_header($header, $replace = TRUE)
{
// If zlib.output_compression is enabled it will compress the output,
// but it will not modify the content-length header to compensate for
// the reduction, causing the browser to hang waiting for more data.
// We'll just skip content-length in those cases.
if ($this->_zlib_oc && strncasecmp($header, 'content-length', 14) == 0)
{
return;
}
$this->headers[] = array($header, $replace);
return $this;
}
// --------------------------------------------------------------------
/**
* Set Content Type Header
*
* @access public
* @param string extension of the file we're outputting
* @return void
*/
function set_content_type($mime_type)
{
if (strpos($mime_type, '/') === FALSE)
{
$extension = ltrim($mime_type, '.');
// Is this extension supported?
if (isset($this->mime_types[$extension]))
{
$mime_type =& $this->mime_types[$extension];
if (is_array($mime_type))
{
$mime_type = current($mime_type);
}
}
}
$header = 'Content-Type: '.$mime_type;
$this->headers[] = array($header, TRUE);
return $this;
}
// --------------------------------------------------------------------
/**
* Set HTTP Status Header
* moved to Common procedural functions in 1.7.2
*
* @access public
* @param int the status code
* @param string
* @return void
*/
function set_status_header($code = 200, $text = '')
{
set_status_header($code, $text);
return $this;
}
// --------------------------------------------------------------------
/**
* Enable/disable Profiler
*
* @access public
* @param bool
* @return void
*/
function enable_profiler($val = TRUE)
{
$this->enable_profiler = (is_bool($val)) ? $val : TRUE;
return $this;
}
// --------------------------------------------------------------------
/**
* Set Profiler Sections
*
* Allows override of default / config settings for Profiler section display
*
* @access public
* @param array
* @return void
*/
function set_profiler_sections($sections)
{
foreach ($sections as $section => $enable)
{
$this->_profiler_sections[$section] = ($enable !== FALSE) ? TRUE : FALSE;
}
return $this;
}
// --------------------------------------------------------------------
/**
* Set Cache
*
* @access public
* @param integer
* @return void
*/
function cache($time)
{
$this->cache_expiration = ( ! is_numeric($time)) ? 0 : $time;
return $this;
}
// --------------------------------------------------------------------
/**
* Display Output
*
* All "view" data is automatically put into this variable by the controller class:
*
* $this->final_output
*
* This function sends the finalized output data to the browser along
* with any server headers and profile data. It also stops the
* benchmark timer so the page rendering speed and memory usage can be shown.
*
* @access public
* @return mixed
*/
function _display($output = '')
{
// Note: We use globals because we can't use $CI =& get_instance()
// since this function is sometimes called by the caching mechanism,
// which happens before the CI super object is available.
global $BM, $CFG;
// Grab the super object if we can.
if (class_exists('CI_Controller'))
{
$CI =& get_instance();
}
// --------------------------------------------------------------------
// Set the output data
if ($output == '')
{
$output =& $this->final_output;
}
// --------------------------------------------------------------------
// Do we need to write a cache file? Only if the controller does not have its
// own _output() method and we are not dealing with a cache file, which we
// can determine by the existence of the $CI object above
if ($this->cache_expiration > 0 && isset($CI) && ! method_exists($CI, '_output'))
{
$this->_write_cache($output);
}
// --------------------------------------------------------------------
// Parse out the elapsed time and memory usage,
// then swap the pseudo-variables with the data
$elapsed = $BM->elapsed_time('total_execution_time_start', 'total_execution_time_end');
if ($this->parse_exec_vars === TRUE)
{
$memory = ( ! function_exists('memory_get_usage')) ? '0' : round(memory_get_usage()/1024/1024, 2).'MB';
$output = str_replace('{elapsed_time}', $elapsed, $output);
$output = str_replace('{memory_usage}', $memory, $output);
}
// --------------------------------------------------------------------
// Is compression requested?
if ($CFG->item('compress_output') === TRUE && $this->_zlib_oc == FALSE)
{
if (extension_loaded('zlib'))
{
if (isset($_SERVER['HTTP_ACCEPT_ENCODING']) AND strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== FALSE)
{
ob_start('ob_gzhandler');
}
}
}
// --------------------------------------------------------------------
// Are there any server headers to send?
if (count($this->headers) > 0)
{
foreach ($this->headers as $header)
{
@header($header[0], $header[1]);
}
}
// --------------------------------------------------------------------
// Does the $CI object exist?
// If not we know we are dealing with a cache file so we'll
// simply echo out the data and exit.
if ( ! isset($CI))
{
echo $output;
log_message('debug', "Final output sent to browser");
log_message('debug', "Total execution time: ".$elapsed);
return TRUE;
}
// --------------------------------------------------------------------
// Do we need to generate profile data?
// If so, load the Profile class and run it.
if ($this->enable_profiler == TRUE)
{
$CI->load->library('profiler');
if ( ! empty($this->_profiler_sections))
{
$CI->profiler->set_sections($this->_profiler_sections);
}
// If the output data contains closing </body> and </html> tags
// we will remove them and add them back after we insert the profile data
if (preg_match("|</body>.*?</html>|is", $output))
{
$output = preg_replace("|</body>.*?</html>|is", '', $output);
$output .= $CI->profiler->run();
$output .= '</body></html>';
}
else
{
$output .= $CI->profiler->run();
}
}
// --------------------------------------------------------------------
// Does the controller contain a function named _output()?
// If so send the output there. Otherwise, echo it.
if (method_exists($CI, '_output'))
{
$CI->_output($output);
}
else
{
echo $output; // Send it to the browser!
}
log_message('debug', "Final output sent to browser");
log_message('debug', "Total execution time: ".$elapsed);
}
// --------------------------------------------------------------------
/**
* Write a Cache File
*
* @access public
* @return void
*/
function _write_cache($output)
{
$CI =& get_instance();
$path = $CI->config->item('cache_path');
$cache_path = ($path == '') ? APPPATH.'cache/' : $path;
if ( ! is_dir($cache_path) OR ! is_really_writable($cache_path))
{
log_message('error', "Unable to write cache file: ".$cache_path);
return;
}
$uri = $CI->config->item('base_url').
$CI->config->item('index_page').
$CI->uri->uri_string();
$cache_path .= md5($uri);
if ( ! $fp = @fopen($cache_path, FOPEN_WRITE_CREATE_DESTRUCTIVE))
{
log_message('error', "Unable to write cache file: ".$cache_path);
return;
}
$expire = time() + ($this->cache_expiration * 60);
if (flock($fp, LOCK_EX))
{
fwrite($fp, $expire.'TS--->'.$output);
flock($fp, LOCK_UN);
}
else
{
log_message('error', "Unable to secure a file lock for file at: ".$cache_path);
return;
}
fclose($fp);
@chmod($cache_path, FILE_WRITE_MODE);
log_message('debug', "Cache file written: ".$cache_path);
}
// --------------------------------------------------------------------
/**
* Update/serve a cached file
*
* @access public
* @return void
*/
function _display_cache(&$CFG, &$URI)
{
$cache_path = ($CFG->item('cache_path') == '') ? APPPATH.'cache/' : $CFG->item('cache_path');
// Build the file path. The file name is an MD5 hash of the full URI
$uri = $CFG->item('base_url').
$CFG->item('index_page').
$URI->uri_string;
$filepath = $cache_path.md5($uri);
if ( ! @file_exists($filepath))
{
return FALSE;
}
if ( ! $fp = @fopen($filepath, FOPEN_READ))
{
return FALSE;
}
flock($fp, LOCK_SH);
$cache = '';
if (filesize($filepath) > 0)
{
$cache = fread($fp, filesize($filepath));
}
flock($fp, LOCK_UN);
fclose($fp);
// Strip out the embedded timestamp
if ( ! preg_match("/(\d+TS--->)/", $cache, $match))
{
return FALSE;
}
// Has the file expired? If so we'll delete it.
if (time() >= trim(str_replace('TS--->', '', $match['1'])))
{
if (is_really_writable($cache_path))
{
@unlink($filepath);
log_message('debug', "Cache file has expired. File deleted");
return FALSE;
}
}
// Display the cache
$this->_display(str_replace($match['0'], '', $cache));
log_message('debug', "Cache file is current. Sending it to browser.");
return TRUE;
}
}
// END Output Class
/* End of file Output.php */
/* Location: ./system/core/Output.php */

Wyświetl plik

@ -0,0 +1,459 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* Router Class
*
* Parses URIs and determines routing
*
* @package CodeIgniter
* @subpackage Libraries
* @author ExpressionEngine Dev Team
* @category Libraries
* @link http://codeigniter.com/user_guide/general/routing.html
*/
class CI_Router {
var $config;
var $routes = array();
var $error_routes = array();
var $class = '';
var $method = 'index';
var $directory = '';
var $default_controller;
/**
* Constructor
*
* Runs the route mapping function.
*/
function __construct()
{
$this->config =& load_class('Config', 'core');
$this->uri =& load_class('URI', 'core');
log_message('debug', "Router Class Initialized");
}
// --------------------------------------------------------------------
/**
* Set the route mapping
*
* This function determines what should be served based on the URI request,
* as well as any "routes" that have been set in the routing config file.
*
* @access private
* @return void
*/
function _set_routing()
{
// Are query strings enabled in the config file? Normally CI doesn't utilize query strings
// since URI segments are more search-engine friendly, but they can optionally be used.
// If this feature is enabled, we will gather the directory/class/method a little differently
$segments = array();
if ($this->config->item('enable_query_strings') === TRUE AND isset($_GET[$this->config->item('controller_trigger')]))
{
if (isset($_GET[$this->config->item('directory_trigger')]))
{
$this->set_directory(trim($this->uri->_filter_uri($_GET[$this->config->item('directory_trigger')])));
$segments[] = $this->fetch_directory();
}
if (isset($_GET[$this->config->item('controller_trigger')]))
{
$this->set_class(trim($this->uri->_filter_uri($_GET[$this->config->item('controller_trigger')])));
$segments[] = $this->fetch_class();
}
if (isset($_GET[$this->config->item('function_trigger')]))
{
$this->set_method(trim($this->uri->_filter_uri($_GET[$this->config->item('function_trigger')])));
$segments[] = $this->fetch_method();
}
}
// Load the routes.php file.
@include(APPPATH.'config/routes'.EXT);
$this->routes = ( ! isset($route) OR ! is_array($route)) ? array() : $route;
unset($route);
// Set the default controller so we can display it in the event
// the URI doesn't correlated to a valid controller.
$this->default_controller = ( ! isset($this->routes['default_controller']) OR $this->routes['default_controller'] == '') ? FALSE : strtolower($this->routes['default_controller']);
// Were there any query string segments? If so, we'll validate them and bail out since we're done.
if (count($segments) > 0)
{
return $this->_validate_request($segments);
}
// Fetch the complete URI string
$this->uri->_fetch_uri_string();
// Is there a URI string? If not, the default controller specified in the "routes" file will be shown.
if ($this->uri->uri_string == '')
{
return $this->_set_default_controller();
}
// Do we need to remove the URL suffix?
$this->uri->_remove_url_suffix();
// Compile the segments into an array
$this->uri->_explode_segments();
// Parse any custom routing that may exist
$this->_parse_routes();
// Re-index the segment array so that it starts with 1 rather than 0
$this->uri->_reindex_segments();
}
// --------------------------------------------------------------------
/**
* Set the default controller
*
* @access private
* @return void
*/
function _set_default_controller()
{
if ($this->default_controller === FALSE)
{
show_error("Unable to determine what should be displayed. A default route has not been specified in the routing file.");
}
// Is the method being specified?
if (strpos($this->default_controller, '/') !== FALSE)
{
$x = explode('/', $this->default_controller);
$this->set_class($x[0]);
$this->set_method($x[1]);
$this->_set_request($x);
}
else
{
$this->set_class($this->default_controller);
$this->set_method('index');
$this->_set_request(array($this->default_controller, 'index'));
}
// re-index the routed segments array so it starts with 1 rather than 0
$this->uri->_reindex_segments();
log_message('debug', "No URI present. Default controller set.");
}
// --------------------------------------------------------------------
/**
* Set the Route
*
* This function takes an array of URI segments as
* input, and sets the current class/method
*
* @access private
* @param array
* @param bool
* @return void
*/
function _set_request($segments = array())
{
$segments = $this->_validate_request($segments);
if (count($segments) == 0)
{
return $this->_set_default_controller();
}
$this->set_class($segments[0]);
if (isset($segments[1]))
{
// A standard method request
$this->set_method($segments[1]);
}
else
{
// This lets the "routed" segment array identify that the default
// index method is being used.
$segments[1] = 'index';
}
// Update our "routed" segment array to contain the segments.
// Note: If there is no custom routing, this array will be
// identical to $this->uri->segments
$this->uri->rsegments = $segments;
}
// --------------------------------------------------------------------
/**
* Validates the supplied segments. Attempts to determine the path to
* the controller.
*
* @access private
* @param array
* @return array
*/
function _validate_request($segments)
{
if (count($segments) == 0)
{
return $segments;
}
// Does the requested controller exist in the root folder?
if (file_exists(APPPATH.'controllers/'.$segments[0].EXT))
{
return $segments;
}
// Is the controller in a sub-folder?
if (is_dir(APPPATH.'controllers/'.$segments[0]))
{
// Set the directory and remove it from the segment array
$this->set_directory($segments[0]);
$segments = array_slice($segments, 1);
if (count($segments) > 0)
{
// Does the requested controller exist in the sub-folder?
if ( ! file_exists(APPPATH.'controllers/'.$this->fetch_directory().$segments[0].EXT))
{
show_404($this->fetch_directory().$segments[0]);
}
}
else
{
// Is the method being specified in the route?
if (strpos($this->default_controller, '/') !== FALSE)
{
$x = explode('/', $this->default_controller);
$this->set_class($x[0]);
$this->set_method($x[1]);
}
else
{
$this->set_class($this->default_controller);
$this->set_method('index');
}
// Does the default controller exist in the sub-folder?
if ( ! file_exists(APPPATH.'controllers/'.$this->fetch_directory().$this->default_controller.EXT))
{
$this->directory = '';
return array();
}
}
return $segments;
}
// If we've gotten this far it means that the URI does not correlate to a valid
// controller class. We will now see if there is an override
if ( ! empty($this->routes['404_override']))
{
$x = explode('/', $this->routes['404_override']);
$this->set_class($x[0]);
$this->set_method(isset($x[1]) ? $x[1] : 'index');
return $x;
}
// Nothing else to do at this point but show a 404
show_404($segments[0]);
}
// --------------------------------------------------------------------
/**
* Parse Routes
*
* This function matches any routes that may exist in
* the config/routes.php file against the URI to
* determine if the class/method need to be remapped.
*
* @access private
* @return void
*/
function _parse_routes()
{
// Turn the segment array into a URI string
$uri = implode('/', $this->uri->segments);
// Is there a literal match? If so we're done
if (isset($this->routes[$uri]))
{
return $this->_set_request(explode('/', $this->routes[$uri]));
}
// Loop through the route array looking for wild-cards
foreach ($this->routes as $key => $val)
{
// Convert wild-cards to RegEx
$key = str_replace(':any', '.+', str_replace(':num', '[0-9]+', $key));
// Does the RegEx match?
if (preg_match('#^'.$key.'$#', $uri))
{
// Do we have a back-reference?
if (strpos($val, '$') !== FALSE AND strpos($key, '(') !== FALSE)
{
$val = preg_replace('#^'.$key.'$#', $val, $uri);
}
return $this->_set_request(explode('/', $val));
}
}
// If we got this far it means we didn't encounter a
// matching route so we'll set the site default route
$this->_set_request($this->uri->segments);
}
// --------------------------------------------------------------------
/**
* Set the class name
*
* @access public
* @param string
* @return void
*/
function set_class($class)
{
$this->class = str_replace(array('/', '.'), '', $class);
}
// --------------------------------------------------------------------
/**
* Fetch the current class
*
* @access public
* @return string
*/
function fetch_class()
{
return $this->class;
}
// --------------------------------------------------------------------
/**
* Set the method name
*
* @access public
* @param string
* @return void
*/
function set_method($method)
{
$this->method = $method;
}
// --------------------------------------------------------------------
/**
* Fetch the current method
*
* @access public
* @return string
*/
function fetch_method()
{
if ($this->method == $this->fetch_class())
{
return 'index';
}
return $this->method;
}
// --------------------------------------------------------------------
/**
* Set the directory name
*
* @access public
* @param string
* @return void
*/
function set_directory($dir)
{
$this->directory = str_replace(array('/', '.'), '', $dir).'/';
}
// --------------------------------------------------------------------
/**
* Fetch the sub-directory (if any) that contains the requested controller class
*
* @access public
* @return string
*/
function fetch_directory()
{
return $this->directory;
}
// --------------------------------------------------------------------
/**
* Set the controller overrides
*
* @access public
* @param array
* @return null
*/
function _set_overrides($routing)
{
if ( ! is_array($routing))
{
return;
}
if (isset($routing['directory']))
{
$this->set_directory($routing['directory']);
}
if (isset($routing['controller']) AND $routing['controller'] != '')
{
$this->set_class($routing['controller']);
}
if (isset($routing['function']))
{
$routing['function'] = ($routing['function'] == '') ? 'index' : $routing['function'];
$this->set_method($routing['function']);
}
}
}
// END Router Class
/* End of file Router.php */
/* Location: ./system/core/Router.php */

612
system/core/URI.php 100644
Wyświetl plik

@ -0,0 +1,612 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* URI Class
*
* Parses URIs and determines routing
*
* @package CodeIgniter
* @subpackage Libraries
* @category URI
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/libraries/uri.html
*/
class CI_URI {
var $keyval = array();
var $uri_string;
var $segments = array();
var $rsegments = array();
/**
* Constructor
*
* Simply globalizes the $RTR object. The front
* loads the Router class early on so it's not available
* normally as other classes are.
*
* @access public
*/
function __construct()
{
$this->config =& load_class('Config', 'core');
log_message('debug', "URI Class Initialized");
}
// --------------------------------------------------------------------
/**
* Get the URI String
*
* @access private
* @return string
*/
function _fetch_uri_string()
{
if (strtoupper($this->config->item('uri_protocol')) == 'AUTO')
{
// Is the request coming from the command line?
if (defined('STDIN'))
{
$this->uri_string = $this->_parse_cli_args();
return;
}
// Let's try the REQUEST_URI first, this will work in most situations
if ($uri = $this->_detect_uri())
{
$this->uri_string = $uri;
return;
}
// Is there a PATH_INFO variable?
// Note: some servers seem to have trouble with getenv() so we'll test it two ways
$path = (isset($_SERVER['PATH_INFO'])) ? $_SERVER['PATH_INFO'] : @getenv('PATH_INFO');
if (trim($path, '/') != '' && $path != "/".SELF)
{
$this->uri_string = $path;
return;
}
// No PATH_INFO?... What about QUERY_STRING?
$path = (isset($_SERVER['QUERY_STRING'])) ? $_SERVER['QUERY_STRING'] : @getenv('QUERY_STRING');
if (trim($path, '/') != '')
{
$this->uri_string = $path;
return;
}
// As a last ditch effort lets try using the $_GET array
if (is_array($_GET) && count($_GET) == 1 && trim(key($_GET), '/') != '')
{
$this->uri_string = key($_GET);
return;
}
// We've exhausted all our options...
$this->uri_string = '';
}
else
{
$uri = strtoupper($this->config->item('uri_protocol'));
if ($uri == 'REQUEST_URI')
{
$this->uri_string = $this->_detect_uri();
return;
}
elseif ($uri == 'CLI')
{
$this->uri_string = $this->_parse_cli_args();
return;
}
$this->uri_string = (isset($_SERVER[$uri])) ? $_SERVER[$uri] : @getenv($uri);
}
// If the URI contains only a slash we'll kill it
if ($this->uri_string == '/')
{
$this->uri_string = '';
}
}
// --------------------------------------------------------------------
/**
* Detects the URI
*
* This function will detect the URI automatically and fix the query string
* if necessary.
*
* @access private
* @return string
*/
private function _detect_uri()
{
if ( ! isset($_SERVER['REQUEST_URI']))
{
return '';
}
$uri = $_SERVER['REQUEST_URI'];
if (strpos($uri, $_SERVER['SCRIPT_NAME']) === 0)
{
$uri = substr($uri, strlen($_SERVER['SCRIPT_NAME']));
}
elseif (strpos($uri, dirname($_SERVER['SCRIPT_NAME'])) === 0)
{
$uri = substr($uri, strlen(dirname($_SERVER['SCRIPT_NAME'])));
}
// This section ensures that even on servers that require the URI to be in the query string (Nginx) a correct
// URI is found, and also fixes the QUERY_STRING server var and $_GET array.
if (strncmp($uri, '?/', 2) === 0)
{
$uri = substr($uri, 2);
}
$parts = preg_split('#\?#i', $uri, 2);
$uri = $parts[0];
if (isset($parts[1]))
{
$_SERVER['QUERY_STRING'] = $parts[1];
parse_str($_SERVER['QUERY_STRING'], $_GET);
}
else
{
$_SERVER['QUERY_STRING'] = '';
$_GET = array();
}
if ($uri == '/' || empty($uri))
{
return '/';
}
$uri = parse_url($uri, PHP_URL_PATH);
// Do some final cleaning of the URI and return it
return str_replace(array('//', '../'), '/', trim($uri, '/'));
}
// --------------------------------------------------------------------
/**
* Parse cli arguments
*
* Take each command line argument and assume it is a URI segment.
*
* @access private
* @return string
*/
private function _parse_cli_args()
{
$args = array_slice($_SERVER['argv'], 1);
return $args ? '/' . implode('/', $args) : '';
}
// --------------------------------------------------------------------
/**
* Filter segments for malicious characters
*
* @access private
* @param string
* @return string
*/
function _filter_uri($str)
{
if ($str != '' && $this->config->item('permitted_uri_chars') != '' && $this->config->item('enable_query_strings') == FALSE)
{
// preg_quote() in PHP 5.3 escapes -, so the str_replace() and addition of - to preg_quote() is to maintain backwards
// compatibility as many are unaware of how characters in the permitted_uri_chars will be parsed as a regex pattern
if ( ! preg_match("|^[".str_replace(array('\\-', '\-'), '-', preg_quote($this->config->item('permitted_uri_chars'), '-'))."]+$|i", $str))
{
show_error('The URI you submitted has disallowed characters.', 400);
}
}
// Convert programatic characters to entities
$bad = array('$', '(', ')', '%28', '%29');
$good = array('&#36;', '&#40;', '&#41;', '&#40;', '&#41;');
return str_replace($bad, $good, $str);
}
// --------------------------------------------------------------------
/**
* Remove the suffix from the URL if needed
*
* @access private
* @return void
*/
function _remove_url_suffix()
{
if ($this->config->item('url_suffix') != "")
{
$this->uri_string = preg_replace("|".preg_quote($this->config->item('url_suffix'))."$|", "", $this->uri_string);
}
}
// --------------------------------------------------------------------
/**
* Explode the URI Segments. The individual segments will
* be stored in the $this->segments array.
*
* @access private
* @return void
*/
function _explode_segments()
{
foreach (explode("/", preg_replace("|/*(.+?)/*$|", "\\1", $this->uri_string)) as $val)
{
// Filter segments for security
$val = trim($this->_filter_uri($val));
if ($val != '')
{
$this->segments[] = $val;
}
}
}
// --------------------------------------------------------------------
/**
* Re-index Segments
*
* This function re-indexes the $this->segment array so that it
* starts at 1 rather than 0. Doing so makes it simpler to
* use functions like $this->uri->segment(n) since there is
* a 1:1 relationship between the segment array and the actual segments.
*
* @access private
* @return void
*/
function _reindex_segments()
{
array_unshift($this->segments, NULL);
array_unshift($this->rsegments, NULL);
unset($this->segments[0]);
unset($this->rsegments[0]);
}
// --------------------------------------------------------------------
/**
* Fetch a URI Segment
*
* This function returns the URI segment based on the number provided.
*
* @access public
* @param integer
* @param bool
* @return string
*/
function segment($n, $no_result = FALSE)
{
return ( ! isset($this->segments[$n])) ? $no_result : $this->segments[$n];
}
// --------------------------------------------------------------------
/**
* Fetch a URI "routed" Segment
*
* This function returns the re-routed URI segment (assuming routing rules are used)
* based on the number provided. If there is no routing this function returns the
* same result as $this->segment()
*
* @access public
* @param integer
* @param bool
* @return string
*/
function rsegment($n, $no_result = FALSE)
{
return ( ! isset($this->rsegments[$n])) ? $no_result : $this->rsegments[$n];
}
// --------------------------------------------------------------------
/**
* Generate a key value pair from the URI string
*
* This function generates and associative array of URI data starting
* at the supplied segment. For example, if this is your URI:
*
* example.com/user/search/name/joe/location/UK/gender/male
*
* You can use this function to generate an array with this prototype:
*
* array (
* name => joe
* location => UK
* gender => male
* )
*
* @access public
* @param integer the starting segment number
* @param array an array of default values
* @return array
*/
function uri_to_assoc($n = 3, $default = array())
{
return $this->_uri_to_assoc($n, $default, 'segment');
}
/**
* Identical to above only it uses the re-routed segment array
*
*/
function ruri_to_assoc($n = 3, $default = array())
{
return $this->_uri_to_assoc($n, $default, 'rsegment');
}
// --------------------------------------------------------------------
/**
* Generate a key value pair from the URI string or Re-routed URI string
*
* @access private
* @param integer the starting segment number
* @param array an array of default values
* @param string which array we should use
* @return array
*/
function _uri_to_assoc($n = 3, $default = array(), $which = 'segment')
{
if ($which == 'segment')
{
$total_segments = 'total_segments';
$segment_array = 'segment_array';
}
else
{
$total_segments = 'total_rsegments';
$segment_array = 'rsegment_array';
}
if ( ! is_numeric($n))
{
return $default;
}
if (isset($this->keyval[$n]))
{
return $this->keyval[$n];
}
if ($this->$total_segments() < $n)
{
if (count($default) == 0)
{
return array();
}
$retval = array();
foreach ($default as $val)
{
$retval[$val] = FALSE;
}
return $retval;
}
$segments = array_slice($this->$segment_array(), ($n - 1));
$i = 0;
$lastval = '';
$retval = array();
foreach ($segments as $seg)
{
if ($i % 2)
{
$retval[$lastval] = $seg;
}
else
{
$retval[$seg] = FALSE;
$lastval = $seg;
}
$i++;
}
if (count($default) > 0)
{
foreach ($default as $val)
{
if ( ! array_key_exists($val, $retval))
{
$retval[$val] = FALSE;
}
}
}
// Cache the array for reuse
$this->keyval[$n] = $retval;
return $retval;
}
// --------------------------------------------------------------------
/**
* Generate a URI string from an associative array
*
*
* @access public
* @param array an associative array of key/values
* @return array
*/
function assoc_to_uri($array)
{
$temp = array();
foreach ((array)$array as $key => $val)
{
$temp[] = $key;
$temp[] = $val;
}
return implode('/', $temp);
}
// --------------------------------------------------------------------
/**
* Fetch a URI Segment and add a trailing slash
*
* @access public
* @param integer
* @param string
* @return string
*/
function slash_segment($n, $where = 'trailing')
{
return $this->_slash_segment($n, $where, 'segment');
}
// --------------------------------------------------------------------
/**
* Fetch a URI Segment and add a trailing slash
*
* @access public
* @param integer
* @param string
* @return string
*/
function slash_rsegment($n, $where = 'trailing')
{
return $this->_slash_segment($n, $where, 'rsegment');
}
// --------------------------------------------------------------------
/**
* Fetch a URI Segment and add a trailing slash - helper function
*
* @access private
* @param integer
* @param string
* @param string
* @return string
*/
function _slash_segment($n, $where = 'trailing', $which = 'segment')
{
$leading = '/';
$trailing = '/';
if ($where == 'trailing')
{
$leading = '';
}
elseif ($where == 'leading')
{
$trailing = '';
}
return $leading.$this->$which($n).$trailing;
}
// --------------------------------------------------------------------
/**
* Segment Array
*
* @access public
* @return array
*/
function segment_array()
{
return $this->segments;
}
// --------------------------------------------------------------------
/**
* Routed Segment Array
*
* @access public
* @return array
*/
function rsegment_array()
{
return $this->rsegments;
}
// --------------------------------------------------------------------
/**
* Total number of segments
*
* @access public
* @return integer
*/
function total_segments()
{
return count($this->segments);
}
// --------------------------------------------------------------------
/**
* Total number of routed segments
*
* @access public
* @return integer
*/
function total_rsegments()
{
return count($this->rsegments);
}
// --------------------------------------------------------------------
/**
* Fetch the entire URI string
*
* @access public
* @return string
*/
function uri_string()
{
return $this->uri_string;
}
// --------------------------------------------------------------------
/**
* Fetch the entire Re-routed URI string
*
* @access public
* @return string
*/
function ruri_string()
{
return '/'.implode('/', $this->rsegment_array());
}
}
// END URI Class
/* End of file URI.php */
/* Location: ./system/core/URI.php */

Wyświetl plik

@ -0,0 +1,165 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 2.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* Utf8 Class
*
* Provides support for UTF-8 environments
*
* @package CodeIgniter
* @subpackage Libraries
* @category UTF-8
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/libraries/utf8.html
*/
class CI_Utf8 {
/**
* Constructor
*
* Determines if UTF-8 support is to be enabled
*
*/
function __construct()
{
log_message('debug', "Utf8 Class Initialized");
global $CFG;
if (
preg_match('/./u', 'é') === 1 // PCRE must support UTF-8
AND function_exists('iconv') // iconv must be installed
AND ini_get('mbstring.func_overload') != 1 // Multibyte string function overloading cannot be enabled
AND $CFG->item('charset') == 'UTF-8' // Application charset must be UTF-8
)
{
log_message('debug', "UTF-8 Support Enabled");
define('UTF8_ENABLED', TRUE);
// set internal encoding for multibyte string functions if necessary
// and set a flag so we don't have to repeatedly use extension_loaded()
// or function_exists()
if (extension_loaded('mbstring'))
{
define('MB_ENABLED', TRUE);
mb_internal_encoding('UTF-8');
}
else
{
define('MB_ENABLED', FALSE);
}
}
else
{
log_message('debug', "UTF-8 Support Disabled");
define('UTF8_ENABLED', FALSE);
}
}
// --------------------------------------------------------------------
/**
* Clean UTF-8 strings
*
* Ensures strings are UTF-8
*
* @access public
* @param string
* @return string
*/
function clean_string($str)
{
if ($this->_is_ascii($str) === FALSE)
{
$str = @iconv('UTF-8', 'UTF-8//IGNORE', $str);
}
return $str;
}
// --------------------------------------------------------------------
/**
* Remove ASCII control characters
*
* Removes all ASCII control characters except horizontal tabs,
* line feeds, and carriage returns, as all others can cause
* problems in XML
*
* @access public
* @param string
* @return string
*/
function safe_ascii_for_xml($str)
{
return preg_replace('/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]+/S', '', $str);
}
// --------------------------------------------------------------------
/**
* Convert to UTF-8
*
* Attempts to convert a string to UTF-8
*
* @access public
* @param string
* @param string - input encoding
* @return string
*/
function convert_to_utf8($str, $encoding)
{
if (function_exists('iconv'))
{
$str = @iconv($encoding, 'UTF-8', $str);
}
elseif (function_exists('mb_convert_encoding'))
{
$str = @mb_convert_encoding($str, 'UTF-8', $encoding);
}
else
{
return FALSE;
}
return $str;
}
// --------------------------------------------------------------------
/**
* Is ASCII?
*
* Tests if a string is standard 7-bit ASCII or not
*
* @access public
* @param string
* @return bool
*/
function _is_ascii($str)
{
return (preg_match('/[^\x00-\x7F]/S', $str) == 0);
}
// --------------------------------------------------------------------
}
// End Utf8 Class
/* End of file Utf8.php */
/* Location: ./system/core/Utf8.php */

Wyświetl plik

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

Wyświetl plik

@ -0,0 +1,165 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, 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 = NULL)
{
// Load the DB config file if a DSN string wasn't passed
if (is_string($params) AND strpos($params, '://') === FALSE)
{
$file_path = APPPATH.'config/'.ENVIRONMENT.'/database'.EXT;
if ( ! file_exists($file_path))
{
log_message('debug', 'Database config for '.ENVIRONMENT.' environment is not found. Trying global config.');
$file_path = APPPATH.'config/database'.EXT;
if ( ! file_exists($file_path))
{
continue;
}
}
include($file_path);
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 !== NULL)
{
$active_record = $active_record_override;
}
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 = new $driver($params);
if ($DB->autoinit == TRUE)
{
$DB->initialize();
}
if (isset($params['stricton']) && $params['stricton'] == TRUE)
{
$DB->query('SET SESSION sql_mode="STRICT_ALL_TABLES"');
}
return $DB;
}
/* End of file DB.php */
/* Location: ./system/database/DB.php */

Plik diff jest za duży Load Diff

Wyświetl plik

@ -0,0 +1,195 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, 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, FILE_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 */

Plik diff jest za duży Load Diff

Wyświetl plik

@ -0,0 +1,382 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* Code Igniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, 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)
{
// If no name provided, use the current name
if ( ! isset($field[$k]['name']))
{
$field[$k]['name'] = $k;
}
$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 */

Wyświetl plik

@ -0,0 +1,405 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, 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 $custom_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')
{
if ($type == 'array') return $this->result_array();
else if ($type == 'object') return $this->result_object();
else return $this->custom_result_object($type);
}
// --------------------------------------------------------------------
/**
* Custom query result.
*
* @param class_name A string that represents the type of object you want back
* @return array of objects
*/
function custom_result_object($class_name)
{
if (array_key_exists($class_name, $this->custom_result_object))
{
return $this->custom_result_object[$class_name];
}
if ($this->result_id === FALSE OR $this->num_rows() == 0)
{
return array();
}
// add the data to the object
$this->_data_seek(0);
$result_object = array();
while ($row = $this->_fetch_object())
{
$object = new $class_name();
foreach ($row as $key => $value)
{
$object->$key = $value;
}
$result_object[] = $object;
}
// return the array
return $this->custom_result_object[$class_name] = $result_object;
}
/**
* 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;
}
if ($type == 'object') return $this->row_object($n);
else if ($type == 'array') return $this->row_array($n);
else return $this->custom_row_object($n, $type);
}
// --------------------------------------------------------------------
/**
* 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 - custom object version
*
* @access public
* @return object
*/
function custom_row_object($n, $type)
{
$result = $this->custom_result_object($type);
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 - 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 */

Wyświetl plik

@ -0,0 +1,414 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* Code Igniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, 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'];
}
// --------------------------------------------------------------------
/**
* Determine if a particular database exists
*
* @access public
* @param string
* @return boolean
*/
function database_exists($database_name)
{
// Some databases won't have access to the list_databases() function, so
// this is intended to allow them to override with their own functions as
// defined in $driver_utility.php
if (method_exists($this, '_database_exists'))
{
return $this->_database_exists($database_name);
}
else
{
return ( ! in_array($database_name, $this->list_databases())) ? FALSE : TRUE;
}
}
// --------------------------------------------------------------------
/**
* 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 */

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

@ -0,0 +1,664 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, 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;
}
// Escape single quotes
$str = str_replace("'", "''", 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_chr);
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 */

Wyświetl plik

@ -0,0 +1,248 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, 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 */

Wyświetl plik

@ -0,0 +1,169 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, 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 */

Wyświetl plik

@ -0,0 +1,88 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, 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');
}
}
/* End of file mssql_utility.php */
/* Location: ./system/database/drivers/mssql/mssql_utility.php */

Wyświetl plik

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

Wyświetl plik

@ -0,0 +1,762 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, 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 ".$this->_protect_identifiers($table, TRUE, NULL, FALSE);
}
// --------------------------------------------------------------------
/**
* Field data query
*
* Generates a platform-specific query so that the column data can be retrieved
*
* @access public
* @param string the table name
* @return object
*/
function _field_data($table)
{
return "SELECT * FROM ".$table." LIMIT 1";
}
// --------------------------------------------------------------------
/**
* The error message string
*
* @access private
* @return string
*/
function _error_message()
{
return 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).")";
}
// --------------------------------------------------------------------
/**
* Replace statement
*
* Generates a platform-specific replace 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 _replace($table, $keys, $values)
{
return "REPLACE INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")";
}
// --------------------------------------------------------------------
/**
* Insert_batch 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_batch($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;
}
// --------------------------------------------------------------------
/**
* Update_Batch statement
*
* Generates a platform-specific batch update string from the supplied data
*
* @access public
* @param string the table name
* @param array the update data
* @param array the where clause
* @return string
*/
function _update_batch($table, $values, $index, $where = NULL)
{
$ids = array();
$where = ($where != '' AND count($where) >=1) ? implode(" ", $where).' AND ' : '';
foreach ($values as $key => $val)
{
$ids[] = $val[$index];
foreach (array_keys($val) as $field)
{
if ($field != $index)
{
$final[$field][] = 'WHEN '.$index.' = '.$val[$index].' THEN '.$val[$field];
}
}
}
$sql = "UPDATE ".$table." SET ";
$cases = '';
foreach ($final as $k => $v)
{
$cases .= $k.' = CASE '."\n";
foreach ($v as $row)
{
$cases .= $row."\n";
}
$cases .= 'ELSE '.$k.' END, ';
}
$sql .= substr($cases, 0, -2);
$sql .= ' WHERE '.$where.$index.' IN ('.implode(',', $ids).')';
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 */

Wyświetl plik

@ -0,0 +1,269 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, 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))
{
switch ($attributes['TYPE'])
{
case 'decimal':
case 'float':
case 'numeric':
$sql .= '('.implode(',', $attributes['CONSTRAINT']).')';
break;
case 'enum':
case 'set':
$sql .= '("'.implode('","', $attributes['CONSTRAINT']).'")';
break;
default:
$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 */

Wyświetl plik

@ -0,0 +1,169 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, 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 */

Wyświetl plik

@ -0,0 +1,210 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, 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;
}
}
/* End of file mysql_utility.php */
/* Location: ./system/database/drivers/mysql/mysql_utility.php */

Wyświetl plik

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

Wyświetl plik

@ -0,0 +1,740 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, 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 ".$this->_protect_identifiers($table, TRUE, NULL, FALSE);
}
// --------------------------------------------------------------------
/**
* Field data query
*
* Generates a platform-specific query so that the column data can be retrieved
*
* @access public
* @param string the table name
* @return object
*/
function _field_data($table)
{
return "SELECT * FROM ".$table." LIMIT 1";
}
// --------------------------------------------------------------------
/**
* The error message string
*
* @access private
* @return string
*/
function _error_message()
{
return mysqli_error($this->conn_id);
}
// --------------------------------------------------------------------
/**
* The error message number
*
* @access private
* @return integer
*/
function _error_number()
{
return mysqli_errno($this->conn_id);
}
// --------------------------------------------------------------------
/**
* Escape the SQL Identifiers
*
* This function escapes column and table names
*
* @access private
* @param string
* @return string
*/
function _escape_identifiers($item)
{
if ($this->_escape_char == '')
{
return $item;
}
foreach ($this->_reserved_identifiers as $id)
{
if (strpos($item, '.'.$id) !== FALSE)
{
$str = $this->_escape_char. str_replace('.', $this->_escape_char.'.', $item);
// remove duplicates if the user already included the escape
return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str);
}
}
if (strpos($item, '.') !== FALSE)
{
$str = $this->_escape_char.str_replace('.', $this->_escape_char.'.'.$this->_escape_char, $item).$this->_escape_char;
}
else
{
$str = $this->_escape_char.$item.$this->_escape_char;
}
// remove duplicates if the user already included the escape
return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str);
}
// --------------------------------------------------------------------
/**
* From Tables
*
* This function implicitly groups FROM tables so there is no confusion
* about operator precedence in harmony with SQL standards
*
* @access public
* @param type
* @return type
*/
function _from_tables($tables)
{
if ( ! is_array($tables))
{
$tables = array($tables);
}
return '('.implode(', ', $tables).')';
}
// --------------------------------------------------------------------
/**
* Insert statement
*
* Generates a platform-specific insert string from the supplied data
*
* @access public
* @param string the table name
* @param array the insert keys
* @param array the insert values
* @return string
*/
function _insert($table, $keys, $values)
{
return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")";
}
// --------------------------------------------------------------------
/**
* Insert_batch 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_batch($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;
}
// --------------------------------------------------------------------
/**
* Update_Batch statement
*
* Generates a platform-specific batch update string from the supplied data
*
* @access public
* @param string the table name
* @param array the update data
* @param array the where clause
* @return string
*/
function _update_batch($table, $values, $index, $where = NULL)
{
$ids = array();
$where = ($where != '' AND count($where) >=1) ? implode(" ", $where).' AND ' : '';
foreach ($values as $key => $val)
{
$ids[] = $val[$index];
foreach (array_keys($val) as $field)
{
if ($field != $index)
{
$final[$field][] = 'WHEN '.$index.' = '.$val[$index].' THEN '.$val[$field];
}
}
}
$sql = "UPDATE ".$table." SET ";
$cases = '';
foreach ($final as $k => $v)
{
$cases .= $k.' = CASE '."\n";
foreach ($v as $row)
{
$cases .= $row."\n";
}
$cases .= 'ELSE '.$k.' END, ';
}
$sql .= substr($cases, 0, -2);
$sql .= ' WHERE '.$where.$index.' IN ('.implode(',', $ids).')';
return $sql;
}
// --------------------------------------------------------------------
/**
* Truncate statement
*
* Generates a platform-specific truncate string from the supplied data
* If the database does not support the truncate() command
* This function maps to "DELETE FROM table"
*
* @access public
* @param string the table name
* @return string
*/
function _truncate($table)
{
return "TRUNCATE ".$table;
}
// --------------------------------------------------------------------
/**
* Delete statement
*
* Generates a platform-specific delete string from the supplied data
*
* @access public
* @param string the table name
* @param array the where clause
* @param string the limit clause
* @return string
*/
function _delete($table, $where = array(), $like = array(), $limit = FALSE)
{
$conditions = '';
if (count($where) > 0 OR count($like) > 0)
{
$conditions = "\nWHERE ";
$conditions .= implode("\n", $this->ar_where);
if (count($where) > 0 && count($like) > 0)
{
$conditions .= " AND ";
}
$conditions .= implode("\n", $like);
}
$limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
return "DELETE FROM ".$table.$conditions.$limit;
}
// --------------------------------------------------------------------
/**
* Limit string
*
* Generates a platform-specific LIMIT clause
*
* @access public
* @param string the sql query string
* @param integer the number of rows to limit the query to
* @param integer the offset value
* @return string
*/
function _limit($sql, $limit, $offset)
{
$sql .= "LIMIT ".$limit;
if ($offset > 0)
{
$sql .= " OFFSET ".$offset;
}
return $sql;
}
// --------------------------------------------------------------------
/**
* Close DB Connection
*
* @access public
* @param resource
* @return void
*/
function _close($conn_id)
{
@mysqli_close($conn_id);
}
}
/* End of file mysqli_driver.php */
/* Location: ./system/database/drivers/mysqli/mysqli_driver.php */

Wyświetl plik

@ -0,0 +1,254 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* MySQLi Forge Class
*
* @category Database
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/database/
*/
class CI_DB_mysqli_forge extends CI_DB_forge {
/**
* Create database
*
* @access private
* @param string the database name
* @return bool
*/
function _create_database($name)
{
return "CREATE DATABASE ".$name;
}
// --------------------------------------------------------------------
/**
* Drop database
*
* @access private
* @param string the database name
* @return bool
*/
function _drop_database($name)
{
return "DROP DATABASE ".$name;
}
// --------------------------------------------------------------------
/**
* Process Fields
*
* @access private
* @param mixed the fields
* @return string
*/
function _process_fields($fields)
{
$current_field_count = 0;
$sql = '';
foreach ($fields as $field=>$attributes)
{
// Numeric field names aren't allowed in databases, so if the key is
// numeric, we know it was assigned by PHP and the developer manually
// entered the field information, so we'll simply add it to the list
if (is_numeric($field))
{
$sql .= "\n\t$attributes";
}
else
{
$attributes = array_change_key_case($attributes, CASE_UPPER);
$sql .= "\n\t".$this->db->_protect_identifiers($field);
if (array_key_exists('NAME', $attributes))
{
$sql .= ' '.$this->db->_protect_identifiers($attributes['NAME']).' ';
}
if (array_key_exists('TYPE', $attributes))
{
$sql .= ' '.$attributes['TYPE'];
}
if (array_key_exists('CONSTRAINT', $attributes))
{
$sql .= '('.$attributes['CONSTRAINT'].')';
}
if (array_key_exists('UNSIGNED', $attributes) && $attributes['UNSIGNED'] === TRUE)
{
$sql .= ' UNSIGNED';
}
if (array_key_exists('DEFAULT', $attributes))
{
$sql .= ' DEFAULT \''.$attributes['DEFAULT'].'\'';
}
if (array_key_exists('NULL', $attributes))
{
$sql .= ($attributes['NULL'] === TRUE) ? ' NULL' : ' NOT NULL';
}
if (array_key_exists('AUTO_INCREMENT', $attributes) && $attributes['AUTO_INCREMENT'] === TRUE)
{
$sql .= ' AUTO_INCREMENT';
}
}
// don't add a comma on the end of the last field
if (++$current_field_count < count($fields))
{
$sql .= ',';
}
}
return $sql;
}
// --------------------------------------------------------------------
/**
* Create Table
*
* @access private
* @param string the table name
* @param mixed the fields
* @param mixed primary key(s)
* @param mixed key(s)
* @param boolean should 'IF NOT EXISTS' be added to the SQL
* @return bool
*/
function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists)
{
$sql = 'CREATE TABLE ';
if ($if_not_exists === TRUE)
{
$sql .= 'IF NOT EXISTS ';
}
$sql .= $this->db->_escape_identifiers($table)." (";
$sql .= $this->_process_fields($fields);
if (count($primary_keys) > 0)
{
$key_name = $this->db->_protect_identifiers(implode('_', $primary_keys));
$primary_keys = $this->db->_protect_identifiers($primary_keys);
$sql .= ",\n\tPRIMARY KEY ".$key_name." (" . implode(', ', $primary_keys) . ")";
}
if (is_array($keys) && count($keys) > 0)
{
foreach ($keys as $key)
{
if (is_array($key))
{
$key_name = $this->db->_protect_identifiers(implode('_', $key));
$key = $this->db->_protect_identifiers($key);
}
else
{
$key_name = $this->db->_protect_identifiers($key);
$key = array($key_name);
}
$sql .= ",\n\tKEY {$key_name} (" . implode(', ', $key) . ")";
}
}
$sql .= "\n) DEFAULT CHARACTER SET {$this->db->char_set} COLLATE {$this->db->dbcollat};";
return $sql;
}
// --------------------------------------------------------------------
/**
* Drop Table
*
* @access private
* @return string
*/
function _drop_table($table)
{
return "DROP TABLE IF EXISTS ".$this->db->_escape_identifiers($table);
}
// --------------------------------------------------------------------
/**
* Alter table query
*
* Generates a platform-specific query so that a table can be altered
* Called by add_column(), drop_column(), and column_alter(),
*
* @access private
* @param string the ALTER type (ADD, DROP, CHANGE)
* @param string the column name
* @param array fields
* @param string the field after which we should add the new field
* @return object
*/
function _alter_table($alter_type, $table, $fields, $after_field = '')
{
$sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table)." $alter_type ";
// DROP has everything it needs now.
if ($alter_type == 'DROP')
{
return $sql.$this->db->_protect_identifiers($fields);
}
$sql .= $this->_process_fields($fields);
if ($after_field != '')
{
$sql .= ' AFTER ' . $this->db->_protect_identifiers($after_field);
}
return $sql;
}
// --------------------------------------------------------------------
/**
* Rename a table
*
* Generates a platform-specific query so that a table can be renamed
*
* @access private
* @param string the old table name
* @param string the new table name
* @return string
*/
function _rename_table($table_name, $new_table_name)
{
$sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table_name)." RENAME TO ".$this->db->_protect_identifiers($new_table_name);
return $sql;
}
}
/* End of file mysqli_forge.php */
/* Location: ./system/database/drivers/mysqli/mysqli_forge.php */

Wyświetl plik

@ -0,0 +1,169 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* MySQLi Result Class
*
* This class extends the parent result class: CI_DB_result
*
* @category Database
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/database/
*/
class CI_DB_mysqli_result extends CI_DB_result {
/**
* Number of rows in the result set
*
* @access public
* @return integer
*/
function num_rows()
{
return @mysqli_num_rows($this->result_id);
}
// --------------------------------------------------------------------
/**
* Number of fields in the result set
*
* @access public
* @return integer
*/
function num_fields()
{
return @mysqli_num_fields($this->result_id);
}
// --------------------------------------------------------------------
/**
* Fetch Field Names
*
* Generates an array of column names
*
* @access public
* @return array
*/
function list_fields()
{
$field_names = array();
while ($field = mysqli_fetch_field($this->result_id))
{
$field_names[] = $field->name;
}
return $field_names;
}
// --------------------------------------------------------------------
/**
* Field data
*
* Generates an array of objects containing field meta-data
*
* @access public
* @return array
*/
function field_data()
{
$retval = array();
while ($field = mysqli_fetch_field($this->result_id))
{
$F = new stdClass();
$F->name = $field->name;
$F->type = $field->type;
$F->default = $field->def;
$F->max_length = $field->max_length;
$F->primary_key = ($field->flags & MYSQLI_PRI_KEY_FLAG) ? 1 : 0;
$retval[] = $F;
}
return $retval;
}
// --------------------------------------------------------------------
/**
* Free the result
*
* @return null
*/
function free_result()
{
if (is_object($this->result_id))
{
mysqli_free_result($this->result_id);
$this->result_id = FALSE;
}
}
// --------------------------------------------------------------------
/**
* Data Seek
*
* Moves the internal pointer to the desired offset. We call
* this internally before fetching results to make sure the
* result set starts at zero
*
* @access private
* @return array
*/
function _data_seek($n = 0)
{
return mysqli_data_seek($this->result_id, $n);
}
// --------------------------------------------------------------------
/**
* Result - associative array
*
* Returns the result set as an array
*
* @access private
* @return array
*/
function _fetch_assoc()
{
return mysqli_fetch_assoc($this->result_id);
}
// --------------------------------------------------------------------
/**
* Result - object
*
* Returns the result set as an object
*
* @access private
* @return object
*/
function _fetch_object()
{
return mysqli_fetch_object($this->result_id);
}
}
/* End of file mysqli_result.php */
/* Location: ./system/database/drivers/mysqli/mysqli_result.php */

Wyświetl plik

@ -0,0 +1,87 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* MySQLi Utility Class
*
* @category Database
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/database/
*/
class CI_DB_mysqli_utility extends CI_DB_utility {
/**
* List databases
*
* @access private
* @return bool
*/
function _list_databases()
{
return "SHOW DATABASES";
}
// --------------------------------------------------------------------
/**
* Optimize table query
*
* Generates a platform-specific query so that a table can be optimized
*
* @access private
* @param string the table name
* @return object
*/
function _optimize_table($table)
{
return "OPTIMIZE TABLE ".$this->db->_escape_identifiers($table);
}
// --------------------------------------------------------------------
/**
* Repair table query
*
* Generates a platform-specific query so that a table can be repaired
*
* @access private
* @param string the table name
* @return object
*/
function _repair_table($table)
{
return "REPAIR TABLE ".$this->db->_escape_identifiers($table);
}
// --------------------------------------------------------------------
/**
* MySQLi Export
*
* @access private
* @param array Preferences
* @return mixed
*/
function _backup($params = array())
{
// Currently unsupported
return $this->db->display_error('db_unsuported_feature');
}
}
/* End of file mysqli_utility.php */
/* Location: ./system/database/drivers/mysqli/mysqli_utility.php */

Wyświetl plik

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

Wyświetl plik

@ -0,0 +1,777 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* oci8 Database Adapter Class
*
* Note: _DB is an extender class that the app controller
* creates dynamically based on whether the active record
* class is being used or not.
*
* @package CodeIgniter
* @subpackage Drivers
* @category Database
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/database/
*/
/**
* oci8 Database Adapter Class
*
* This is a modification of the DB_driver class to
* permit access to oracle databases
*
* NOTE: this uses the PHP 4 oci methods
*
* @author Kelly McArdle
*
*/
class CI_DB_oci8_driver extends CI_DB {
var $dbdriver = 'oci8';
// The character used for excaping
var $_escape_char = '"';
// clause and character used for LIKE escape sequences
var $_like_escape_str = " escape '%s' ";
var $_like_escape_chr = '!';
/**
* The syntax to count rows is slightly different across different
* database engines, so this string appears in each driver and is
* used for the count_all() and count_all_results() functions.
*/
var $_count_string = "SELECT COUNT(1) AS ";
var $_random_keyword = ' ASC'; // not currently supported
// Set "auto commit" by default
var $_commit = OCI_COMMIT_ON_SUCCESS;
// need to track statement id and cursor id
var $stmt_id;
var $curs_id;
// if we use a limit, we will add a field that will
// throw off num_fields later
var $limit_used;
/**
* Non-persistent database connection
*
* @access private called by the base class
* @return resource
*/
function db_connect()
{
return @ocilogon($this->username, $this->password, $this->hostname);
}
// --------------------------------------------------------------------
/**
* Persistent database connection
*
* @access private called by the base class
* @return resource
*/
function db_pconnect()
{
return @ociplogon($this->username, $this->password, $this->hostname);
}
// --------------------------------------------------------------------
/**
* Reconnect
*
* Keep / reestablish the db connection if no queries have been
* sent for a length of time exceeding the server's idle timeout
*
* @access public
* @return void
*/
function reconnect()
{
// not implemented in oracle
}
// --------------------------------------------------------------------
/**
* Select the database
*
* @access private called by the base class
* @return resource
*/
function db_select()
{
return TRUE;
}
// --------------------------------------------------------------------
/**
* Set client character set
*
* @access public
* @param string
* @param string
* @return resource
*/
function db_set_charset($charset, $collation)
{
// @todo - add support if needed
return TRUE;
}
// --------------------------------------------------------------------
/**
* Version number query string
*
* @access public
* @return string
*/
function _version()
{
return ociserverversion($this->conn_id);
}
// --------------------------------------------------------------------
/**
* Execute the query
*
* @access private called by the base class
* @param string an SQL query
* @return resource
*/
function _execute($sql)
{
// oracle must parse the query before it is run. All of the actions with
// the query are based on the statement id returned by ociparse
$this->stmt_id = FALSE;
$this->_set_stmt_id($sql);
ocisetprefetch($this->stmt_id, 1000);
return @ociexecute($this->stmt_id, $this->_commit);
}
/**
* Generate a statement ID
*
* @access private
* @param string an SQL query
* @return none
*/
function _set_stmt_id($sql)
{
if ( ! is_resource($this->stmt_id))
{
$this->stmt_id = ociparse($this->conn_id, $this->_prep_query($sql));
}
}
// --------------------------------------------------------------------
/**
* Prep the query
*
* If needed, each database adapter can prep the query string
*
* @access private called by execute()
* @param string an SQL query
* @return string
*/
function _prep_query($sql)
{
return $sql;
}
// --------------------------------------------------------------------
/**
* getCursor. Returns a cursor from the datbase
*
* @access public
* @return cursor id
*/
function get_cursor()
{
$this->curs_id = ocinewcursor($this->conn_id);
return $this->curs_id;
}
// --------------------------------------------------------------------
/**
* Stored Procedure. Executes a stored procedure
*
* @access public
* @param package package stored procedure is in
* @param procedure stored procedure to execute
* @param params array of parameters
* @return array
*
* params array keys
*
* KEY OPTIONAL NOTES
* name no the name of the parameter should be in :<param_name> format
* value no the value of the parameter. If this is an OUT or IN OUT parameter,
* this should be a reference to a variable
* type yes the type of the parameter
* length yes the max size of the parameter
*/
function stored_procedure($package, $procedure, $params)
{
if ($package == '' OR $procedure == '' OR ! is_array($params))
{
if ($this->db_debug)
{
log_message('error', 'Invalid query: '.$package.'.'.$procedure);
return $this->display_error('db_invalid_query');
}
return FALSE;
}
// build the query string
$sql = "begin $package.$procedure(";
$have_cursor = FALSE;
foreach ($params as $param)
{
$sql .= $param['name'] . ",";
if (array_key_exists('type', $param) && ($param['type'] == OCI_B_CURSOR))
{
$have_cursor = TRUE;
}
}
$sql = trim($sql, ",") . "); end;";
$this->stmt_id = FALSE;
$this->_set_stmt_id($sql);
$this->_bind_params($params);
$this->query($sql, FALSE, $have_cursor);
}
// --------------------------------------------------------------------
/**
* Bind parameters
*
* @access private
* @return none
*/
function _bind_params($params)
{
if ( ! is_array($params) OR ! is_resource($this->stmt_id))
{
return;
}
foreach ($params as $param)
{
foreach (array('name', 'value', 'type', 'length') as $val)
{
if ( ! isset($param[$val]))
{
$param[$val] = '';
}
}
ocibindbyname($this->stmt_id, $param['name'], $param['value'], $param['length'], $param['type']);
}
}
// --------------------------------------------------------------------
/**
* Begin Transaction
*
* @access public
* @return bool
*/
function trans_begin($test_mode = FALSE)
{
if ( ! $this->trans_enabled)
{
return TRUE;
}
// When transactions are nested we only begin/commit/rollback the outermost ones
if ($this->_trans_depth > 0)
{
return TRUE;
}
// Reset the transaction failure flag.
// If the $test_mode flag is set to TRUE transactions will be rolled back
// even if the queries produce a successful result.
$this->_trans_failure = ($test_mode === TRUE) ? TRUE : FALSE;
$this->_commit = OCI_DEFAULT;
return TRUE;
}
// --------------------------------------------------------------------
/**
* Commit Transaction
*
* @access public
* @return bool
*/
function trans_commit()
{
if ( ! $this->trans_enabled)
{
return TRUE;
}
// When transactions are nested we only begin/commit/rollback the outermost ones
if ($this->_trans_depth > 0)
{
return TRUE;
}
$ret = OCIcommit($this->conn_id);
$this->_commit = OCI_COMMIT_ON_SUCCESS;
return $ret;
}
// --------------------------------------------------------------------
/**
* Rollback Transaction
*
* @access public
* @return bool
*/
function trans_rollback()
{
if ( ! $this->trans_enabled)
{
return TRUE;
}
// When transactions are nested we only begin/commit/rollback the outermost ones
if ($this->_trans_depth > 0)
{
return TRUE;
}
$ret = OCIrollback($this->conn_id);
$this->_commit = OCI_COMMIT_ON_SUCCESS;
return $ret;
}
// --------------------------------------------------------------------
/**
* Escape String
*
* @access public
* @param string
* @param bool whether or not the string will be used in a LIKE condition
* @return string
*/
function escape_str($str, $like = FALSE)
{
if (is_array($str))
{
foreach ($str as $key => $val)
{
$str[$key] = $this->escape_str($val, $like);
}
return $str;
}
$str = remove_invisible_characters($str);
// escape LIKE condition wildcards
if ($like === TRUE)
{
$str = str_replace( array('%', '_', $this->_like_escape_chr),
array($this->_like_escape_chr.'%', $this->_like_escape_chr.'_', $this->_like_escape_chr.$this->_like_escape_chr),
$str);
}
return $str;
}
// --------------------------------------------------------------------
/**
* Affected Rows
*
* @access public
* @return integer
*/
function affected_rows()
{
return @ocirowcount($this->stmt_id);
}
// --------------------------------------------------------------------
/**
* Insert ID
*
* @access public
* @return integer
*/
function insert_id()
{
// not supported in oracle
return $this->display_error('db_unsupported_function');
}
// --------------------------------------------------------------------
/**
* "Count All" query
*
* Generates a platform-specific query string that counts all records in
* the specified database
*
* @access public
* @param string
* @return string
*/
function count_all($table = '')
{
if ($table == '')
{
return 0;
}
$query = $this->query($this->_count_string . $this->_protect_identifiers('numrows') . " FROM " . $this->_protect_identifiers($table, TRUE, NULL, FALSE));
if ($query == FALSE)
{
return 0;
}
$row = $query->row();
return (int) $row->numrows;
}
// --------------------------------------------------------------------
/**
* Show table query
*
* Generates a platform-specific query string so that the table names can be fetched
*
* @access private
* @param boolean
* @return string
*/
function _list_tables($prefix_limit = FALSE)
{
$sql = "SELECT TABLE_NAME FROM ALL_TABLES";
if ($prefix_limit !== FALSE AND $this->dbprefix != '')
{
$sql .= " WHERE TABLE_NAME LIKE '".$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_chr);
}
return $sql;
}
// --------------------------------------------------------------------
/**
* Show column query
*
* Generates a platform-specific query string so that the column names can be fetched
*
* @access public
* @param string the table name
* @return string
*/
function _list_columns($table = '')
{
return "SELECT COLUMN_NAME FROM all_tab_columns WHERE table_name = '$table'";
}
// --------------------------------------------------------------------
/**
* Field data query
*
* Generates a platform-specific query so that the column data can be retrieved
*
* @access public
* @param string the table name
* @return object
*/
function _field_data($table)
{
return "SELECT * FROM ".$table." where rownum = 1";
}
// --------------------------------------------------------------------
/**
* The error message string
*
* @access private
* @return string
*/
function _error_message()
{
$error = ocierror($this->conn_id);
return $error['message'];
}
// --------------------------------------------------------------------
/**
* The error message number
*
* @access private
* @return integer
*/
function _error_number()
{
$error = ocierror($this->conn_id);
return $error['code'];
}
// --------------------------------------------------------------------
/**
* Escape the SQL Identifiers
*
* This function escapes column and table names
*
* @access private
* @param string
* @return string
*/
function _escape_identifiers($item)
{
if ($this->_escape_char == '')
{
return $item;
}
foreach ($this->_reserved_identifiers as $id)
{
if (strpos($item, '.'.$id) !== FALSE)
{
$str = $this->_escape_char. str_replace('.', $this->_escape_char.'.', $item);
// remove duplicates if the user already included the escape
return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str);
}
}
if (strpos($item, '.') !== FALSE)
{
$str = $this->_escape_char.str_replace('.', $this->_escape_char.'.'.$this->_escape_char, $item).$this->_escape_char;
}
else
{
$str = $this->_escape_char.$item.$this->_escape_char;
}
// remove duplicates if the user already included the escape
return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str);
}
// --------------------------------------------------------------------
/**
* From Tables
*
* This function implicitly groups FROM tables so there is no confusion
* about operator precedence in harmony with SQL standards
*
* @access public
* @param type
* @return type
*/
function _from_tables($tables)
{
if ( ! is_array($tables))
{
$tables = array($tables);
}
return implode(', ', $tables);
}
// --------------------------------------------------------------------
/**
* Insert statement
*
* Generates a platform-specific insert string from the supplied data
*
* @access public
* @param string the table name
* @param array the insert keys
* @param array the insert values
* @return string
*/
function _insert($table, $keys, $values)
{
return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")";
}
// --------------------------------------------------------------------
/**
* Update statement
*
* Generates a platform-specific update string from the supplied data
*
* @access public
* @param string the table name
* @param array the update data
* @param array the where clause
* @param array the orderby clause
* @param array the limit clause
* @return string
*/
function _update($table, $values, $where, $orderby = array(), $limit = FALSE)
{
foreach ($values as $key => $val)
{
$valstr[] = $key." = ".$val;
}
$limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
$orderby = (count($orderby) >= 1)?' ORDER BY '.implode(", ", $orderby):'';
$sql = "UPDATE ".$table." SET ".implode(', ', $valstr);
$sql .= ($where != '' AND count($where) >=1) ? " WHERE ".implode(" ", $where) : '';
$sql .= $orderby.$limit;
return $sql;
}
// --------------------------------------------------------------------
/**
* Truncate statement
*
* Generates a platform-specific truncate string from the supplied data
* If the database does not support the truncate() command
* This function maps to "DELETE FROM table"
*
* @access public
* @param string the table name
* @return string
*/
function _truncate($table)
{
return "TRUNCATE TABLE ".$table;
}
// --------------------------------------------------------------------
/**
* Delete statement
*
* Generates a platform-specific delete string from the supplied data
*
* @access public
* @param string the table name
* @param array the where clause
* @param string the limit clause
* @return string
*/
function _delete($table, $where = array(), $like = array(), $limit = FALSE)
{
$conditions = '';
if (count($where) > 0 OR count($like) > 0)
{
$conditions = "\nWHERE ";
$conditions .= implode("\n", $this->ar_where);
if (count($where) > 0 && count($like) > 0)
{
$conditions .= " AND ";
}
$conditions .= implode("\n", $like);
}
$limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
return "DELETE FROM ".$table.$conditions.$limit;
}
// --------------------------------------------------------------------
/**
* Limit string
*
* Generates a platform-specific LIMIT clause
*
* @access public
* @param string the sql query string
* @param integer the number of rows to limit the query to
* @param integer the offset value
* @return string
*/
function _limit($sql, $limit, $offset)
{
$limit = $offset + $limit;
$newsql = "SELECT * FROM (select inner_query.*, rownum rnum FROM ($sql) inner_query WHERE rownum < $limit)";
if ($offset != 0)
{
$newsql .= " WHERE rnum >= $offset";
}
// remember that we used limits
$this->limit_used = TRUE;
return $newsql;
}
// --------------------------------------------------------------------
/**
* Close DB Connection
*
* @access public
* @param resource
* @return void
*/
function _close($conn_id)
{
@ocilogoff($conn_id);
}
}
/* End of file oci8_driver.php */
/* Location: ./system/database/drivers/oci8/oci8_driver.php */

Wyświetl plik

@ -0,0 +1,248 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* Oracle Forge Class
*
* @category Database
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/database/
*/
class CI_DB_oci8_forge extends CI_DB_forge {
/**
* Create database
*
* @access public
* @param string the database name
* @return bool
*/
function _create_database($name)
{
return FALSE;
}
// --------------------------------------------------------------------
/**
* Drop database
*
* @access private
* @param string the database name
* @return bool
*/
function _drop_database($name)
{
return FALSE;
}
// --------------------------------------------------------------------
/**
* Create Table
*
* @access private
* @param string the table name
* @param array the fields
* @param mixed primary key(s)
* @param mixed key(s)
* @param boolean should 'IF NOT EXISTS' be added to the SQL
* @return bool
*/
function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists)
{
$sql = 'CREATE TABLE ';
if ($if_not_exists === TRUE)
{
$sql .= 'IF NOT EXISTS ';
}
$sql .= $this->db->_escape_identifiers($table)." (";
$current_field_count = 0;
foreach ($fields as $field=>$attributes)
{
// Numeric field names aren't allowed in databases, so if the key is
// numeric, we know it was assigned by PHP and the developer manually
// entered the field information, so we'll simply add it to the list
if (is_numeric($field))
{
$sql .= "\n\t$attributes";
}
else
{
$attributes = array_change_key_case($attributes, CASE_UPPER);
$sql .= "\n\t".$this->db->_protect_identifiers($field);
$sql .= ' '.$attributes['TYPE'];
if (array_key_exists('CONSTRAINT', $attributes))
{
$sql .= '('.$attributes['CONSTRAINT'].')';
}
if (array_key_exists('UNSIGNED', $attributes) && $attributes['UNSIGNED'] === TRUE)
{
$sql .= ' UNSIGNED';
}
if (array_key_exists('DEFAULT', $attributes))
{
$sql .= ' DEFAULT \''.$attributes['DEFAULT'].'\'';
}
if (array_key_exists('NULL', $attributes) && $attributes['NULL'] === TRUE)
{
$sql .= ' NULL';
}
else
{
$sql .= ' NOT NULL';
}
if (array_key_exists('AUTO_INCREMENT', $attributes) && $attributes['AUTO_INCREMENT'] === TRUE)
{
$sql .= ' AUTO_INCREMENT';
}
}
// don't add a comma on the end of the last field
if (++$current_field_count < count($fields))
{
$sql .= ',';
}
}
if (count($primary_keys) > 0)
{
$primary_keys = $this->db->_protect_identifiers($primary_keys);
$sql .= ",\n\tPRIMARY KEY (" . implode(', ', $primary_keys) . ")";
}
if (is_array($keys) && count($keys) > 0)
{
foreach ($keys as $key)
{
if (is_array($key))
{
$key = $this->db->_protect_identifiers($key);
}
else
{
$key = array($this->db->_protect_identifiers($key));
}
$sql .= ",\n\tUNIQUE COLUMNS (" . implode(', ', $key) . ")";
}
}
$sql .= "\n)";
return $sql;
}
// --------------------------------------------------------------------
/**
* Drop Table
*
* @access private
* @return bool
*/
function _drop_table($table)
{
return FALSE;
}
// --------------------------------------------------------------------
/**
* Alter table query
*
* Generates a platform-specific query so that a table can be altered
* Called by add_column(), drop_column(), and column_alter(),
*
* @access private
* @param string the ALTER type (ADD, DROP, CHANGE)
* @param string the column name
* @param string the table name
* @param string the column definition
* @param string the default value
* @param boolean should 'NOT NULL' be added
* @param string the field after which we should add the new field
* @return object
*/
function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '')
{
$sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table)." $alter_type ".$this->db->_protect_identifiers($column_name);
// DROP has everything it needs now.
if ($alter_type == 'DROP')
{
return $sql;
}
$sql .= " $column_definition";
if ($default_value != '')
{
$sql .= " DEFAULT \"$default_value\"";
}
if ($null === NULL)
{
$sql .= ' NULL';
}
else
{
$sql .= ' NOT NULL';
}
if ($after_field != '')
{
$sql .= ' AFTER ' . $this->db->_protect_identifiers($after_field);
}
return $sql;
}
// --------------------------------------------------------------------
/**
* Rename a table
*
* Generates a platform-specific query so that a table can be renamed
*
* @access private
* @param string the old table name
* @param string the new table name
* @return string
*/
function _rename_table($table_name, $new_table_name)
{
$sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table_name)." RENAME TO ".$this->db->_protect_identifiers($new_table_name);
return $sql;
}
}
/* End of file oci8_forge.php */
/* Location: ./system/database/drivers/oci8/oci8_forge.php */

Wyświetl plik

@ -0,0 +1,249 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* oci8 Result Class
*
* This class extends the parent result class: CI_DB_result
*
* @category Database
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/database/
*/
class CI_DB_oci8_result extends CI_DB_result {
var $stmt_id;
var $curs_id;
var $limit_used;
/**
* Number of rows in the result set.
*
* Oracle doesn't have a graceful way to retun the number of rows
* so we have to use what amounts to a hack.
*
*
* @access public
* @return integer
*/
function num_rows()
{
$rowcount = count($this->result_array());
@ociexecute($this->stmt_id);
if ($this->curs_id)
{
@ociexecute($this->curs_id);
}
return $rowcount;
}
// --------------------------------------------------------------------
/**
* Number of fields in the result set
*
* @access public
* @return integer
*/
function num_fields()
{
$count = @ocinumcols($this->stmt_id);
// if we used a limit we subtract it
if ($this->limit_used)
{
$count = $count - 1;
}
return $count;
}
// --------------------------------------------------------------------
/**
* Fetch Field Names
*
* Generates an array of column names
*
* @access public
* @return array
*/
function list_fields()
{
$field_names = array();
$fieldCount = $this->num_fields();
for ($c = 1; $c <= $fieldCount; $c++)
{
$field_names[] = ocicolumnname($this->stmt_id, $c);
}
return $field_names;
}
// --------------------------------------------------------------------
/**
* Field data
*
* Generates an array of objects containing field meta-data
*
* @access public
* @return array
*/
function field_data()
{
$retval = array();
$fieldCount = $this->num_fields();
for ($c = 1; $c <= $fieldCount; $c++)
{
$F = new stdClass();
$F->name = ocicolumnname($this->stmt_id, $c);
$F->type = ocicolumntype($this->stmt_id, $c);
$F->max_length = ocicolumnsize($this->stmt_id, $c);
$retval[] = $F;
}
return $retval;
}
// --------------------------------------------------------------------
/**
* Free the result
*
* @return null
*/
function free_result()
{
if (is_resource($this->result_id))
{
ocifreestatement($this->result_id);
$this->result_id = FALSE;
}
}
// --------------------------------------------------------------------
/**
* Result - associative array
*
* Returns the result set as an array
*
* @access private
* @return array
*/
function _fetch_assoc(&$row)
{
$id = ($this->curs_id) ? $this->curs_id : $this->stmt_id;
return ocifetchinto($id, $row, OCI_ASSOC + OCI_RETURN_NULLS);
}
// --------------------------------------------------------------------
/**
* Result - object
*
* Returns the result set as an object
*
* @access private
* @return object
*/
function _fetch_object()
{
$result = array();
// If PHP 5 is being used we can fetch an result object
if (function_exists('oci_fetch_object'))
{
$id = ($this->curs_id) ? $this->curs_id : $this->stmt_id;
return @oci_fetch_object($id);
}
// If PHP 4 is being used we have to build our own result
foreach ($this->result_array() as $key => $val)
{
$obj = new stdClass();
if (is_array($val))
{
foreach ($val as $k => $v)
{
$obj->$k = $v;
}
}
else
{
$obj->$key = $val;
}
$result[] = $obj;
}
return $result;
}
// --------------------------------------------------------------------
/**
* Query result. "array" version.
*
* @access public
* @return array
*/
function result_array()
{
if (count($this->result_array) > 0)
{
return $this->result_array;
}
// oracle's fetch functions do not return arrays.
// The information is returned in reference parameters
$row = NULL;
while ($this->_fetch_assoc($row))
{
$this->result_array[] = $row;
}
return $this->result_array;
}
// --------------------------------------------------------------------
/**
* Data Seek
*
* Moves the internal pointer to the desired offset. We call
* this internally before fetching results to make sure the
* result set starts at zero
*
* @access private
* @return array
*/
function _data_seek($n = 0)
{
return FALSE; // Not needed
}
}
/* End of file oci8_result.php */
/* Location: ./system/database/drivers/oci8/oci8_result.php */

Wyświetl plik

@ -0,0 +1,87 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* Oracle Utility Class
*
* @category Database
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/database/
*/
class CI_DB_oci8_utility extends CI_DB_utility {
/**
* List databases
*
* @access private
* @return bool
*/
function _list_databases()
{
return FALSE;
}
// --------------------------------------------------------------------
/**
* Optimize table query
*
* Generates a platform-specific query so that a table can be optimized
*
* @access private
* @param string the table name
* @return object
*/
function _optimize_table($table)
{
return FALSE; // Is this supported in Oracle?
}
// --------------------------------------------------------------------
/**
* Repair table query
*
* Generates a platform-specific query so that a table can be repaired
*
* @access private
* @param string the table name
* @return object
*/
function _repair_table($table)
{
return FALSE; // Is this supported in Oracle?
}
// --------------------------------------------------------------------
/**
* Oracle Export
*
* @access private
* @param array Preferences
* @return mixed
*/
function _backup($params = array())
{
// Currently unsupported
return $this->db->display_error('db_unsuported_feature');
}
}
/* End of file oci8_utility.php */
/* Location: ./system/database/drivers/oci8/oci8_utility.php */

Wyświetl plik

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

Wyświetl plik

@ -0,0 +1,636 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* ODBC Database Adapter Class
*
* Note: _DB is an extender class that the app controller
* creates dynamically based on whether the active record
* class is being used or not.
*
* @package CodeIgniter
* @subpackage Drivers
* @category Database
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/database/
*/
class CI_DB_odbc_driver extends CI_DB {
var $dbdriver = 'odbc';
// the character used to excape - not necessary for ODBC
var $_escape_char = '';
// clause and character used for LIKE escape sequences
var $_like_escape_str = " {escape '%s'} ";
var $_like_escape_chr = '!';
/**
* The syntax to count rows is slightly different across different
* database engines, so this string appears in each driver and is
* used for the count_all() and count_all_results() functions.
*/
var $_count_string = "SELECT COUNT(*) AS ";
var $_random_keyword;
function CI_DB_odbc_driver($params)
{
parent::CI_DB($params);
$this->_random_keyword = ' RND('.time().')'; // database specific random keyword
}
/**
* Non-persistent database connection
*
* @access private called by the base class
* @return resource
*/
function db_connect()
{
return @odbc_connect($this->hostname, $this->username, $this->password);
}
// --------------------------------------------------------------------
/**
* Persistent database connection
*
* @access private called by the base class
* @return resource
*/
function db_pconnect()
{
return @odbc_pconnect($this->hostname, $this->username, $this->password);
}
// --------------------------------------------------------------------
/**
* Reconnect
*
* Keep / reestablish the db connection if no queries have been
* sent for a length of time exceeding the server's idle timeout
*
* @access public
* @return void
*/
function reconnect()
{
// not implemented in odbc
}
// --------------------------------------------------------------------
/**
* Select the database
*
* @access private called by the base class
* @return resource
*/
function db_select()
{
// Not needed for ODBC
return TRUE;
}
// --------------------------------------------------------------------
/**
* Set client character set
*
* @access public
* @param string
* @param string
* @return resource
*/
function db_set_charset($charset, $collation)
{
// @todo - add support if needed
return TRUE;
}
// --------------------------------------------------------------------
/**
* Version number query string
*
* @access public
* @return string
*/
function _version()
{
return "SELECT version() AS ver";
}
// --------------------------------------------------------------------
/**
* Execute the query
*
* @access private called by the base class
* @param string an SQL query
* @return resource
*/
function _execute($sql)
{
$sql = $this->_prep_query($sql);
return @odbc_exec($this->conn_id, $sql);
}
// --------------------------------------------------------------------
/**
* Prep the query
*
* If needed, each database adapter can prep the query string
*
* @access private called by execute()
* @param string an SQL query
* @return string
*/
function _prep_query($sql)
{
return $sql;
}
// --------------------------------------------------------------------
/**
* Begin Transaction
*
* @access public
* @return bool
*/
function trans_begin($test_mode = FALSE)
{
if ( ! $this->trans_enabled)
{
return TRUE;
}
// When transactions are nested we only begin/commit/rollback the outermost ones
if ($this->_trans_depth > 0)
{
return TRUE;
}
// Reset the transaction failure flag.
// If the $test_mode flag is set to TRUE transactions will be rolled back
// even if the queries produce a successful result.
$this->_trans_failure = ($test_mode === TRUE) ? TRUE : FALSE;
return odbc_autocommit($this->conn_id, FALSE);
}
// --------------------------------------------------------------------
/**
* Commit Transaction
*
* @access public
* @return bool
*/
function trans_commit()
{
if ( ! $this->trans_enabled)
{
return TRUE;
}
// When transactions are nested we only begin/commit/rollback the outermost ones
if ($this->_trans_depth > 0)
{
return TRUE;
}
$ret = odbc_commit($this->conn_id);
odbc_autocommit($this->conn_id, TRUE);
return $ret;
}
// --------------------------------------------------------------------
/**
* Rollback Transaction
*
* @access public
* @return bool
*/
function trans_rollback()
{
if ( ! $this->trans_enabled)
{
return TRUE;
}
// When transactions are nested we only begin/commit/rollback the outermost ones
if ($this->_trans_depth > 0)
{
return TRUE;
}
$ret = odbc_rollback($this->conn_id);
odbc_autocommit($this->conn_id, TRUE);
return $ret;
}
// --------------------------------------------------------------------
/**
* Escape String
*
* @access public
* @param string
* @param bool whether or not the string will be used in a LIKE condition
* @return string
*/
function escape_str($str, $like = FALSE)
{
if (is_array($str))
{
foreach ($str as $key => $val)
{
$str[$key] = $this->escape_str($val, $like);
}
return $str;
}
// ODBC doesn't require escaping
$str = remove_invisible_characters($str);
// escape LIKE condition wildcards
if ($like === TRUE)
{
$str = str_replace( array('%', '_', $this->_like_escape_chr),
array($this->_like_escape_chr.'%', $this->_like_escape_chr.'_', $this->_like_escape_chr.$this->_like_escape_chr),
$str);
}
return $str;
}
// --------------------------------------------------------------------
/**
* Affected Rows
*
* @access public
* @return integer
*/
function affected_rows()
{
return @odbc_num_rows($this->conn_id);
}
// --------------------------------------------------------------------
/**
* Insert ID
*
* @access public
* @return integer
*/
function insert_id()
{
return @odbc_insert_id($this->conn_id);
}
// --------------------------------------------------------------------
/**
* "Count All" query
*
* Generates a platform-specific query string that counts all records in
* the specified database
*
* @access public
* @param string
* @return string
*/
function count_all($table = '')
{
if ($table == '')
{
return 0;
}
$query = $this->query($this->_count_string . $this->_protect_identifiers('numrows') . " FROM " . $this->_protect_identifiers($table, TRUE, NULL, FALSE));
if ($query->num_rows() == 0)
{
return 0;
}
$row = $query->row();
return (int) $row->numrows;
}
// --------------------------------------------------------------------
/**
* Show table query
*
* Generates a platform-specific query string so that the table names can be fetched
*
* @access private
* @param boolean
* @return string
*/
function _list_tables($prefix_limit = FALSE)
{
$sql = "SHOW TABLES FROM `".$this->database."`";
if ($prefix_limit !== FALSE AND $this->dbprefix != '')
{
//$sql .= " LIKE '".$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_chr);
return FALSE; // not currently supported
}
return $sql;
}
// --------------------------------------------------------------------
/**
* Show column query
*
* Generates a platform-specific query string so that the column names can be fetched
*
* @access public
* @param string the table name
* @return string
*/
function _list_columns($table = '')
{
return "SHOW COLUMNS FROM ".$table;
}
// --------------------------------------------------------------------
/**
* Field data query
*
* Generates a platform-specific query so that the column data can be retrieved
*
* @access public
* @param string the table name
* @return object
*/
function _field_data($table)
{
return "SELECT TOP 1 FROM ".$table;
}
// --------------------------------------------------------------------
/**
* The error message string
*
* @access private
* @return string
*/
function _error_message()
{
return odbc_errormsg($this->conn_id);
}
// --------------------------------------------------------------------
/**
* The error message number
*
* @access private
* @return integer
*/
function _error_number()
{
return odbc_error($this->conn_id);
}
// --------------------------------------------------------------------
/**
* Escape the SQL Identifiers
*
* This function escapes column and table names
*
* @access private
* @param string
* @return string
*/
function _escape_identifiers($item)
{
if ($this->_escape_char == '')
{
return $item;
}
foreach ($this->_reserved_identifiers as $id)
{
if (strpos($item, '.'.$id) !== FALSE)
{
$str = $this->_escape_char. str_replace('.', $this->_escape_char.'.', $item);
// remove duplicates if the user already included the escape
return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str);
}
}
if (strpos($item, '.') !== FALSE)
{
$str = $this->_escape_char.str_replace('.', $this->_escape_char.'.'.$this->_escape_char, $item).$this->_escape_char;
}
else
{
$str = $this->_escape_char.$item.$this->_escape_char;
}
// remove duplicates if the user already included the escape
return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str);
}
// --------------------------------------------------------------------
/**
* From Tables
*
* This function implicitly groups FROM tables so there is no confusion
* about operator precedence in harmony with SQL standards
*
* @access public
* @param type
* @return type
*/
function _from_tables($tables)
{
if ( ! is_array($tables))
{
$tables = array($tables);
}
return '('.implode(', ', $tables).')';
}
// --------------------------------------------------------------------
/**
* Insert statement
*
* Generates a platform-specific insert string from the supplied data
*
* @access public
* @param string the table name
* @param array the insert keys
* @param array the insert values
* @return string
*/
function _insert($table, $keys, $values)
{
return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")";
}
// --------------------------------------------------------------------
/**
* Update statement
*
* Generates a platform-specific update string from the supplied data
*
* @access public
* @param string the table name
* @param array the update data
* @param array the where clause
* @param array the orderby clause
* @param array the limit clause
* @return string
*/
function _update($table, $values, $where, $orderby = array(), $limit = FALSE)
{
foreach ($values as $key => $val)
{
$valstr[] = $key." = ".$val;
}
$limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
$orderby = (count($orderby) >= 1)?' ORDER BY '.implode(", ", $orderby):'';
$sql = "UPDATE ".$table." SET ".implode(', ', $valstr);
$sql .= ($where != '' AND count($where) >=1) ? " WHERE ".implode(" ", $where) : '';
$sql .= $orderby.$limit;
return $sql;
}
// --------------------------------------------------------------------
/**
* Truncate statement
*
* Generates a platform-specific truncate string from the supplied data
* If the database does not support the truncate() command
* This function maps to "DELETE FROM table"
*
* @access public
* @param string the table name
* @return string
*/
function _truncate($table)
{
return $this->_delete($table);
}
// --------------------------------------------------------------------
/**
* Delete statement
*
* Generates a platform-specific delete string from the supplied data
*
* @access public
* @param string the table name
* @param array the where clause
* @param string the limit clause
* @return string
*/
function _delete($table, $where = array(), $like = array(), $limit = FALSE)
{
$conditions = '';
if (count($where) > 0 OR count($like) > 0)
{
$conditions = "\nWHERE ";
$conditions .= implode("\n", $this->ar_where);
if (count($where) > 0 && count($like) > 0)
{
$conditions .= " AND ";
}
$conditions .= implode("\n", $like);
}
$limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
return "DELETE FROM ".$table.$conditions.$limit;
}
// --------------------------------------------------------------------
/**
* Limit string
*
* Generates a platform-specific LIMIT clause
*
* @access public
* @param string the sql query string
* @param integer the number of rows to limit the query to
* @param integer the offset value
* @return string
*/
function _limit($sql, $limit, $offset)
{
// Does ODBC doesn't use the LIMIT clause?
return $sql;
}
// --------------------------------------------------------------------
/**
* Close DB Connection
*
* @access public
* @param resource
* @return void
*/
function _close($conn_id)
{
@odbc_close($conn_id);
}
}
/* End of file odbc_driver.php */
/* Location: ./system/database/drivers/odbc/odbc_driver.php */

Wyświetl plik

@ -0,0 +1,266 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* ODBC Forge Class
*
* @category Database
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/database/
*/
class CI_DB_odbc_forge extends CI_DB_forge {
/**
* Create database
*
* @access private
* @param string the database name
* @return bool
*/
function _create_database()
{
// ODBC has no "create database" command since it's
// designed to connect to an existing database
if ($this->db->db_debug)
{
return $this->db->display_error('db_unsuported_feature');
}
return FALSE;
}
// --------------------------------------------------------------------
/**
* Drop database
*
* @access private
* @param string the database name
* @return bool
*/
function _drop_database($name)
{
// ODBC has no "drop database" command since it's
// designed to connect to an existing database
if ($this->db->db_debug)
{
return $this->db->display_error('db_unsuported_feature');
}
return FALSE;
}
// --------------------------------------------------------------------
/**
* Create Table
*
* @access private
* @param string the table name
* @param array the fields
* @param mixed primary key(s)
* @param mixed key(s)
* @param boolean should 'IF NOT EXISTS' be added to the SQL
* @return bool
*/
function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists)
{
$sql = 'CREATE TABLE ';
if ($if_not_exists === TRUE)
{
$sql .= 'IF NOT EXISTS ';
}
$sql .= $this->db->_escape_identifiers($table)." (";
$current_field_count = 0;
foreach ($fields as $field=>$attributes)
{
// Numeric field names aren't allowed in databases, so if the key is
// numeric, we know it was assigned by PHP and the developer manually
// entered the field information, so we'll simply add it to the list
if (is_numeric($field))
{
$sql .= "\n\t$attributes";
}
else
{
$attributes = array_change_key_case($attributes, CASE_UPPER);
$sql .= "\n\t".$this->db->_protect_identifiers($field);
$sql .= ' '.$attributes['TYPE'];
if (array_key_exists('CONSTRAINT', $attributes))
{
$sql .= '('.$attributes['CONSTRAINT'].')';
}
if (array_key_exists('UNSIGNED', $attributes) && $attributes['UNSIGNED'] === TRUE)
{
$sql .= ' UNSIGNED';
}
if (array_key_exists('DEFAULT', $attributes))
{
$sql .= ' DEFAULT \''.$attributes['DEFAULT'].'\'';
}
if (array_key_exists('NULL', $attributes) && $attributes['NULL'] === TRUE)
{
$sql .= ' NULL';
}
else
{
$sql .= ' NOT NULL';
}
if (array_key_exists('AUTO_INCREMENT', $attributes) && $attributes['AUTO_INCREMENT'] === TRUE)
{
$sql .= ' AUTO_INCREMENT';
}
}
// don't add a comma on the end of the last field
if (++$current_field_count < count($fields))
{
$sql .= ',';
}
}
if (count($primary_keys) > 0)
{
$primary_keys = $this->db->_protect_identifiers($primary_keys);
$sql .= ",\n\tPRIMARY KEY (" . implode(', ', $primary_keys) . ")";
}
if (is_array($keys) && count($keys) > 0)
{
foreach ($keys as $key)
{
if (is_array($key))
{
$key = $this->db->_protect_identifiers($key);
}
else
{
$key = array($this->db->_protect_identifiers($key));
}
$sql .= ",\n\tFOREIGN KEY (" . implode(', ', $key) . ")";
}
}
$sql .= "\n)";
return $sql;
}
// --------------------------------------------------------------------
/**
* Drop Table
*
* @access private
* @return bool
*/
function _drop_table($table)
{
// Not a supported ODBC feature
if ($this->db->db_debug)
{
return $this->db->display_error('db_unsuported_feature');
}
return FALSE;
}
// --------------------------------------------------------------------
/**
* Alter table query
*
* Generates a platform-specific query so that a table can be altered
* Called by add_column(), drop_column(), and column_alter(),
*
* @access private
* @param string the ALTER type (ADD, DROP, CHANGE)
* @param string the column name
* @param string the table name
* @param string the column definition
* @param string the default value
* @param boolean should 'NOT NULL' be added
* @param string the field after which we should add the new field
* @return object
*/
function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '')
{
$sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table)." $alter_type ".$this->db->_protect_identifiers($column_name);
// DROP has everything it needs now.
if ($alter_type == 'DROP')
{
return $sql;
}
$sql .= " $column_definition";
if ($default_value != '')
{
$sql .= " DEFAULT \"$default_value\"";
}
if ($null === NULL)
{
$sql .= ' NULL';
}
else
{
$sql .= ' NOT NULL';
}
if ($after_field != '')
{
$sql .= ' AFTER ' . $this->db->_protect_identifiers($after_field);
}
return $sql;
}
// --------------------------------------------------------------------
/**
* Rename a table
*
* Generates a platform-specific query so that a table can be renamed
*
* @access private
* @param string the old table name
* @param string the new table name
* @return string
*/
function _rename_table($table_name, $new_table_name)
{
$sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table_name)." RENAME TO ".$this->db->_protect_identifiers($new_table_name);
return $sql;
}
}
/* End of file odbc_forge.php */
/* Location: ./system/database/drivers/odbc/odbc_forge.php */

Wyświetl plik

@ -0,0 +1,228 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* ODBC Result Class
*
* This class extends the parent result class: CI_DB_result
*
* @category Database
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/database/
*/
class CI_DB_odbc_result extends CI_DB_result {
/**
* Number of rows in the result set
*
* @access public
* @return integer
*/
function num_rows()
{
return @odbc_num_rows($this->result_id);
}
// --------------------------------------------------------------------
/**
* Number of fields in the result set
*
* @access public
* @return integer
*/
function num_fields()
{
return @odbc_num_fields($this->result_id);
}
// --------------------------------------------------------------------
/**
* Fetch Field Names
*
* Generates an array of column names
*
* @access public
* @return array
*/
function list_fields()
{
$field_names = array();
for ($i = 0; $i < $this->num_fields(); $i++)
{
$field_names[] = odbc_field_name($this->result_id, $i);
}
return $field_names;
}
// --------------------------------------------------------------------
/**
* Field data
*
* Generates an array of objects containing field meta-data
*
* @access public
* @return array
*/
function field_data()
{
$retval = array();
for ($i = 0; $i < $this->num_fields(); $i++)
{
$F = new stdClass();
$F->name = odbc_field_name($this->result_id, $i);
$F->type = odbc_field_type($this->result_id, $i);
$F->max_length = odbc_field_len($this->result_id, $i);
$F->primary_key = 0;
$F->default = '';
$retval[] = $F;
}
return $retval;
}
// --------------------------------------------------------------------
/**
* Free the result
*
* @return null
*/
function free_result()
{
if (is_resource($this->result_id))
{
odbc_free_result($this->result_id);
$this->result_id = FALSE;
}
}
// --------------------------------------------------------------------
/**
* Data Seek
*
* Moves the internal pointer to the desired offset. We call
* this internally before fetching results to make sure the
* result set starts at zero
*
* @access private
* @return array
*/
function _data_seek($n = 0)
{
return FALSE;
}
// --------------------------------------------------------------------
/**
* Result - associative array
*
* Returns the result set as an array
*
* @access private
* @return array
*/
function _fetch_assoc()
{
if (function_exists('odbc_fetch_object'))
{
return odbc_fetch_array($this->result_id);
}
else
{
return $this->_odbc_fetch_array($this->result_id);
}
}
// --------------------------------------------------------------------
/**
* Result - object
*
* Returns the result set as an object
*
* @access private
* @return object
*/
function _fetch_object()
{
if (function_exists('odbc_fetch_object'))
{
return odbc_fetch_object($this->result_id);
}
else
{
return $this->_odbc_fetch_object($this->result_id);
}
}
/**
* Result - object
*
* subsititutes the odbc_fetch_object function when
* not available (odbc_fetch_object requires unixODBC)
*
* @access private
* @return object
*/
function _odbc_fetch_object(& $odbc_result) {
$rs = array();
$rs_obj = FALSE;
if (odbc_fetch_into($odbc_result, $rs)) {
foreach ($rs as $k=>$v) {
$field_name= odbc_field_name($odbc_result, $k+1);
$rs_obj->$field_name = $v;
}
}
return $rs_obj;
}
/**
* Result - array
*
* subsititutes the odbc_fetch_array function when
* not available (odbc_fetch_array requires unixODBC)
*
* @access private
* @return array
*/
function _odbc_fetch_array(& $odbc_result) {
$rs = array();
$rs_assoc = FALSE;
if (odbc_fetch_into($odbc_result, $rs)) {
$rs_assoc=array();
foreach ($rs as $k=>$v) {
$field_name= odbc_field_name($odbc_result, $k+1);
$rs_assoc[$field_name] = $v;
}
}
return $rs_assoc;
}
}
/* End of file odbc_result.php */
/* Location: ./system/database/drivers/odbc/odbc_result.php */

Wyświetl plik

@ -0,0 +1,103 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* ODBC Utility Class
*
* @category Database
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/database/
*/
class CI_DB_odbc_utility extends CI_DB_utility {
/**
* List databases
*
* @access private
* @return bool
*/
function _list_databases()
{
// Not sure if ODBC lets you list all databases...
if ($this->db->db_debug)
{
return $this->db->display_error('db_unsuported_feature');
}
return FALSE;
}
// --------------------------------------------------------------------
/**
* Optimize table query
*
* Generates a platform-specific query so that a table can be optimized
*
* @access private
* @param string the table name
* @return object
*/
function _optimize_table($table)
{
// Not a supported ODBC feature
if ($this->db->db_debug)
{
return $this->db->display_error('db_unsuported_feature');
}
return FALSE;
}
// --------------------------------------------------------------------
/**
* Repair table query
*
* Generates a platform-specific query so that a table can be repaired
*
* @access private
* @param string the table name
* @return object
*/
function _repair_table($table)
{
// Not a supported ODBC feature
if ($this->db->db_debug)
{
return $this->db->display_error('db_unsuported_feature');
}
return FALSE;
}
// --------------------------------------------------------------------
/**
* ODBC Export
*
* @access private
* @param array Preferences
* @return mixed
*/
function _backup($params = array())
{
// Currently unsupported
return $this->db->display_error('db_unsuported_feature');
}
}
/* End of file odbc_utility.php */
/* Location: ./system/database/drivers/odbc/odbc_utility.php */

Wyświetl plik

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

Wyświetl plik

@ -0,0 +1,684 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* Postgre Database Adapter Class
*
* Note: _DB is an extender class that the app controller
* creates dynamically based on whether the active record
* class is being used or not.
*
* @package CodeIgniter
* @subpackage Drivers
* @category Database
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/database/
*/
class CI_DB_postgre_driver extends CI_DB {
var $dbdriver = 'postgre';
var $_escape_char = '"';
// clause and character used for LIKE escape sequences
var $_like_escape_str = " ESCAPE '%s' ";
var $_like_escape_chr = '!';
/**
* The syntax to count rows is slightly different across different
* database engines, so this string appears in each driver and is
* used for the count_all() and count_all_results() functions.
*/
var $_count_string = "SELECT COUNT(*) AS ";
var $_random_keyword = ' RANDOM()'; // database specific random keyword
/**
* Connection String
*
* @access private
* @return string
*/
function _connect_string()
{
$components = array(
'hostname' => 'host',
'port' => 'port',
'database' => 'dbname',
'username' => 'user',
'password' => 'password'
);
$connect_string = "";
foreach ($components as $key => $val)
{
if (isset($this->$key) && $this->$key != '')
{
$connect_string .= " $val=".$this->$key;
}
}
return trim($connect_string);
}
// --------------------------------------------------------------------
/**
* Non-persistent database connection
*
* @access private called by the base class
* @return resource
*/
function db_connect()
{
return @pg_connect($this->_connect_string());
}
// --------------------------------------------------------------------
/**
* Persistent database connection
*
* @access private called by the base class
* @return resource
*/
function db_pconnect()
{
return @pg_pconnect($this->_connect_string());
}
// --------------------------------------------------------------------
/**
* Reconnect
*
* Keep / reestablish the db connection if no queries have been
* sent for a length of time exceeding the server's idle timeout
*
* @access public
* @return void
*/
function reconnect()
{
if (pg_ping($this->conn_id) === FALSE)
{
$this->conn_id = FALSE;
}
}
// --------------------------------------------------------------------
/**
* Select the database
*
* @access private called by the base class
* @return resource
*/
function db_select()
{
// Not needed for Postgre so we'll return TRUE
return TRUE;
}
// --------------------------------------------------------------------
/**
* Set client character set
*
* @access public
* @param string
* @param string
* @return resource
*/
function db_set_charset($charset, $collation)
{
// @todo - add support if needed
return TRUE;
}
// --------------------------------------------------------------------
/**
* Version number query string
*
* @access public
* @return string
*/
function _version()
{
return "SELECT version() AS ver";
}
// --------------------------------------------------------------------
/**
* Execute the query
*
* @access private called by the base class
* @param string an SQL query
* @return resource
*/
function _execute($sql)
{
$sql = $this->_prep_query($sql);
return @pg_query($this->conn_id, $sql);
}
// --------------------------------------------------------------------
/**
* Prep the query
*
* If needed, each database adapter can prep the query string
*
* @access private called by execute()
* @param string an SQL query
* @return string
*/
function _prep_query($sql)
{
return $sql;
}
// --------------------------------------------------------------------
/**
* Begin Transaction
*
* @access public
* @return bool
*/
function trans_begin($test_mode = FALSE)
{
if ( ! $this->trans_enabled)
{
return TRUE;
}
// When transactions are nested we only begin/commit/rollback the outermost ones
if ($this->_trans_depth > 0)
{
return TRUE;
}
// Reset the transaction failure flag.
// If the $test_mode flag is set to TRUE transactions will be rolled back
// even if the queries produce a successful result.
$this->_trans_failure = ($test_mode === TRUE) ? TRUE : FALSE;
return @pg_exec($this->conn_id, "begin");
}
// --------------------------------------------------------------------
/**
* Commit Transaction
*
* @access public
* @return bool
*/
function trans_commit()
{
if ( ! $this->trans_enabled)
{
return TRUE;
}
// When transactions are nested we only begin/commit/rollback the outermost ones
if ($this->_trans_depth > 0)
{
return TRUE;
}
return @pg_exec($this->conn_id, "commit");
}
// --------------------------------------------------------------------
/**
* Rollback Transaction
*
* @access public
* @return bool
*/
function trans_rollback()
{
if ( ! $this->trans_enabled)
{
return TRUE;
}
// When transactions are nested we only begin/commit/rollback the outermost ones
if ($this->_trans_depth > 0)
{
return TRUE;
}
return @pg_exec($this->conn_id, "rollback");
}
// --------------------------------------------------------------------
/**
* Escape String
*
* @access public
* @param string
* @param bool whether or not the string will be used in a LIKE condition
* @return string
*/
function escape_str($str, $like = FALSE)
{
if (is_array($str))
{
foreach ($str as $key => $val)
{
$str[$key] = $this->escape_str($val, $like);
}
return $str;
}
$str = pg_escape_string($str);
// escape LIKE condition wildcards
if ($like === TRUE)
{
$str = str_replace( array('%', '_', $this->_like_escape_chr),
array($this->_like_escape_chr.'%', $this->_like_escape_chr.'_', $this->_like_escape_chr.$this->_like_escape_chr),
$str);
}
return $str;
}
// --------------------------------------------------------------------
/**
* Affected Rows
*
* @access public
* @return integer
*/
function affected_rows()
{
return @pg_affected_rows($this->result_id);
}
// --------------------------------------------------------------------
/**
* Insert ID
*
* @access public
* @return integer
*/
function insert_id()
{
$v = $this->_version();
$v = $v['server'];
$table = func_num_args() > 0 ? func_get_arg(0) : NULL;
$column = func_num_args() > 1 ? func_get_arg(1) : NULL;
if ($table == NULL && $v >= '8.1')
{
$sql='SELECT LASTVAL() as ins_id';
}
elseif ($table != NULL && $column != NULL && $v >= '8.0')
{
$sql = sprintf("SELECT pg_get_serial_sequence('%s','%s') as seq", $table, $column);
$query = $this->query($sql);
$row = $query->row();
$sql = sprintf("SELECT CURRVAL('%s') as ins_id", $row->seq);
}
elseif ($table != NULL)
{
// seq_name passed in table parameter
$sql = sprintf("SELECT CURRVAL('%s') as ins_id", $table);
}
else
{
return pg_last_oid($this->result_id);
}
$query = $this->query($sql);
$row = $query->row();
return $row->ins_id;
}
// --------------------------------------------------------------------
/**
* "Count All" query
*
* Generates a platform-specific query string that counts all records in
* the specified database
*
* @access public
* @param string
* @return string
*/
function count_all($table = '')
{
if ($table == '')
{
return 0;
}
$query = $this->query($this->_count_string . $this->_protect_identifiers('numrows') . " FROM " . $this->_protect_identifiers($table, TRUE, NULL, FALSE));
if ($query->num_rows() == 0)
{
return 0;
}
$row = $query->row();
return (int) $row->numrows;
}
// --------------------------------------------------------------------
/**
* Show table query
*
* Generates a platform-specific query string so that the table names can be fetched
*
* @access private
* @param boolean
* @return string
*/
function _list_tables($prefix_limit = FALSE)
{
$sql = "SELECT table_name FROM information_schema.tables WHERE table_schema = 'public'";
if ($prefix_limit !== FALSE AND $this->dbprefix != '')
{
$sql .= " AND table_name LIKE '".$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_chr);
}
return $sql;
}
// --------------------------------------------------------------------
/**
* Show column query
*
* Generates a platform-specific query string so that the column names can be fetched
*
* @access public
* @param string the table name
* @return string
*/
function _list_columns($table = '')
{
return "SELECT column_name FROM information_schema.columns WHERE table_name ='".$table."'";
}
// --------------------------------------------------------------------
/**
* Field data query
*
* Generates a platform-specific query so that the column data can be retrieved
*
* @access public
* @param string the table name
* @return object
*/
function _field_data($table)
{
return "SELECT * FROM ".$table." LIMIT 1";
}
// --------------------------------------------------------------------
/**
* The error message string
*
* @access private
* @return string
*/
function _error_message()
{
return pg_last_error($this->conn_id);
}
// --------------------------------------------------------------------
/**
* The error message number
*
* @access private
* @return integer
*/
function _error_number()
{
return '';
}
// --------------------------------------------------------------------
/**
* Escape the SQL Identifiers
*
* This function escapes column and table names
*
* @access private
* @param string
* @return string
*/
function _escape_identifiers($item)
{
if ($this->_escape_char == '')
{
return $item;
}
foreach ($this->_reserved_identifiers as $id)
{
if (strpos($item, '.'.$id) !== FALSE)
{
$str = $this->_escape_char. str_replace('.', $this->_escape_char.'.', $item);
// remove duplicates if the user already included the escape
return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str);
}
}
if (strpos($item, '.') !== FALSE)
{
$str = $this->_escape_char.str_replace('.', $this->_escape_char.'.'.$this->_escape_char, $item).$this->_escape_char;
}
else
{
$str = $this->_escape_char.$item.$this->_escape_char;
}
// remove duplicates if the user already included the escape
return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str);
}
// --------------------------------------------------------------------
/**
* From Tables
*
* This function implicitly groups FROM tables so there is no confusion
* about operator precedence in harmony with SQL standards
*
* @access public
* @param type
* @return type
*/
function _from_tables($tables)
{
if ( ! is_array($tables))
{
$tables = array($tables);
}
return implode(', ', $tables);
}
// --------------------------------------------------------------------
/**
* Insert statement
*
* Generates a platform-specific insert string from the supplied data
*
* @access public
* @param string the table name
* @param array the insert keys
* @param array the insert values
* @return string
*/
function _insert($table, $keys, $values)
{
return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")";
}
// --------------------------------------------------------------------
/**
* Update statement
*
* Generates a platform-specific update string from the supplied data
*
* @access public
* @param string the table name
* @param array the update data
* @param array the where clause
* @param array the orderby clause
* @param array the limit clause
* @return string
*/
function _update($table, $values, $where, $orderby = array(), $limit = FALSE)
{
foreach ($values as $key => $val)
{
$valstr[] = $key." = ".$val;
}
$limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
$orderby = (count($orderby) >= 1)?' ORDER BY '.implode(", ", $orderby):'';
$sql = "UPDATE ".$table." SET ".implode(', ', $valstr);
$sql .= ($where != '' AND count($where) >=1) ? " WHERE ".implode(" ", $where) : '';
$sql .= $orderby.$limit;
return $sql;
}
// --------------------------------------------------------------------
/**
* Truncate statement
*
* Generates a platform-specific truncate string from the supplied data
* If the database does not support the truncate() command
* This function maps to "DELETE FROM table"
*
* @access public
* @param string the table name
* @return string
*/
function _truncate($table)
{
return "TRUNCATE ".$table;
}
// --------------------------------------------------------------------
/**
* Delete statement
*
* Generates a platform-specific delete string from the supplied data
*
* @access public
* @param string the table name
* @param array the where clause
* @param string the limit clause
* @return string
*/
function _delete($table, $where = array(), $like = array(), $limit = FALSE)
{
$conditions = '';
if (count($where) > 0 OR count($like) > 0)
{
$conditions = "\nWHERE ";
$conditions .= implode("\n", $this->ar_where);
if (count($where) > 0 && count($like) > 0)
{
$conditions .= " AND ";
}
$conditions .= implode("\n", $like);
}
$limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
return "DELETE FROM ".$table.$conditions.$limit;
}
// --------------------------------------------------------------------
/**
* Limit string
*
* Generates a platform-specific LIMIT clause
*
* @access public
* @param string the sql query string
* @param integer the number of rows to limit the query to
* @param integer the offset value
* @return string
*/
function _limit($sql, $limit, $offset)
{
$sql .= "LIMIT ".$limit;
if ($offset > 0)
{
$sql .= " OFFSET ".$offset;
}
return $sql;
}
// --------------------------------------------------------------------
/**
* Close DB Connection
*
* @access public
* @param resource
* @return void
*/
function _close($conn_id)
{
@pg_close($conn_id);
}
}
/* End of file postgre_driver.php */
/* Location: ./system/database/drivers/postgre/postgre_driver.php */

Some files were not shown because too many files have changed in this diff Show More